Skip to content

Commit

Permalink
Fix send loading and notify transaction error (#13)
Browse files Browse the repository at this point in the history
* Fix loading status after rejecting signature

* Notify tx error
  • Loading branch information
JayJay1024 authored Nov 8, 2023
1 parent 33c2226 commit 8cda850
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/providers/transfer-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { EvmBridge } from "@/libs";

import { WalletAccount } from "@talismn/connect-wallets";
import { Signer } from "@polkadot/api/types";
import { notifyTransaction, parseCross, signAndSendExtrinsic } from "@/utils";
import { notifyError, notifyTransaction, parseCross, signAndSendExtrinsic } from "@/utils";
import { useApi, useBalance } from "@/hooks";

interface TransferCtx {
Expand Down Expand Up @@ -149,6 +149,8 @@ export default function TransferProvider({ children }: PropsWithChildren<unknown
}
} catch (err) {
console.error(err);
notifyError(err);
options.failedCb();
}
},
[],
Expand All @@ -167,6 +169,8 @@ export default function TransferProvider({ children }: PropsWithChildren<unknown
await signAndSendExtrinsic(_extrinsic, _signer, _sender, _bridge.getSourceChain(), options);
} catch (err) {
console.error(err);
notifyError(err);
options.failedCb();
}
}
},
Expand Down
4 changes: 4 additions & 0 deletions src/utils/notification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ export function notifyExtrinsic(hash: string, chain: ChainConfig, isSuccess: boo
notify(hash, explorer, "extrinsic", isSuccess);
}
}

export function notifyError(err: unknown) {
return notification.error({ title: "An error occurred", description: (err as Error).message });
}
4 changes: 3 additions & 1 deletion src/utils/tx.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Signer, SubmittableExtrinsic } from "@polkadot/api/types";
import { notifyExtrinsic } from ".";
import { notifyError, notifyExtrinsic } from ".";
import { ChainConfig } from "@/types";

const transferCb = {
Expand Down Expand Up @@ -42,6 +42,8 @@ export const signAndSendExtrinsic = async (
});
} catch (err) {
console.error(err);
notifyError(err);
options.failedCb();
} finally {
//
}
Expand Down

0 comments on commit 8cda850

Please sign in to comment.