Use the configured signer, not the provider's

This commit is contained in:
Alexis Sellier
2021-07-26 17:06:27 +02:00
parent 191644e000
commit bf363d7c05
2 changed files with 9 additions and 4 deletions
+4 -2
View File
@@ -3,7 +3,7 @@ import { formatBalance } from "@app/utils";
import * as session from "@app/session";
import { State, state } from "./state";
import type { Config } from "@app/config";
import { assert } from "@app/error";
export interface VestingInfo {
token: string;
@@ -15,8 +15,10 @@ export interface VestingInfo {
}
export async function withdrawVested(address: string, config: Config): Promise<void> {
assert(config.signer);
const contract = new ethers.Contract(address, config.abi.vesting, config.provider);
const signer = config.provider.getSigner();
const signer = config.signer;
state.set(State.WithdrawingSign);
+5 -2
View File
@@ -48,6 +48,7 @@ export const loadState = (initial: State): Store => {
return {
subscribe: store.subscribe,
connect: async (config: Config) => {
assert(config.signer);
const state = get(store);
assertEq(state.connection, Connection.Disconnected);
@@ -60,7 +61,7 @@ export const loadState = (initial: State): Store => {
console.error(e);
}
const signer = config.provider.getSigner();
const signer = config.signer;
const address = await signer.getAddress();
try {
@@ -208,7 +209,9 @@ state.subscribe(s => {
});
export async function approveSpender(spender: string, amount: BigNumber, config: Config): Promise<void> {
const signer = config.provider.getSigner();
assert(config.signer);
const signer = config.signer;
const addr = await signer.getAddress();
const allowance = await config.token.allowance(addr, spender);