From 5aeed7c246b1146aea5100c72bb9eb639549fe3b Mon Sep 17 00:00:00 2001 From: Valtteri Karesto Date: Tue, 29 Mar 2022 15:23:30 +0300 Subject: [PATCH] Few more changes to deleteHook function --- state/actions/deployHook.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/state/actions/deployHook.ts b/state/actions/deployHook.ts index e6bf848..dd2c77f 100644 --- a/state/actions/deployHook.ts +++ b/state/actions/deployHook.ts @@ -153,13 +153,18 @@ export const deleteHook = async (account: IAccount & { name?: string }) => { if (!state.client) { return; } - + const currentAccount = state.accounts.find( + (acc) => acc.address === account.address + ); + if (currentAccount?.isLoading || !currentAccount?.hooks.length) { + return + } if (typeof window !== "undefined") { const tx = { Account: account.address, TransactionType: "SetHook", Sequence: account.sequence, - Fee: "1000000", + Fee: "100000", Hooks: [ { Hook: { @@ -172,9 +177,7 @@ export const deleteHook = async (account: IAccount & { name?: string }) => { const keypair = derive.familySeed(account.secret); const { signedTransaction } = sign(tx, keypair); - const currentAccount = state.accounts.find( - (acc) => acc.address === account.address - ); + if (currentAccount) { currentAccount.isLoading = true; } @@ -196,6 +199,7 @@ export const deleteHook = async (account: IAccount & { name?: string }) => { type: "success", message: `[${submitRes.engine_result}] ${submitRes.engine_result_message} Validated ledger index: ${submitRes.validated_ledger_index}`, }); + currentAccount.hooks = []; } else { toast.error(`${submitRes.engine_result_message || submitRes.error_exception}`, { id: toastId }) state.deployLogs.push({