Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Use the configured signer, not the provider's
Alexis Sellier committed 4 years ago
commit bf363d7c05b1ea23259dfc0b5293c0d4d4488f78
parent 191644e000d148522ec1866e8e80936f191ed2f0
2 files changed +9 -4
modified src/base/vesting/vesting.ts
@@ -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);

modified src/session.ts
@@ -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);