Merge pull request #151 from eqlabs/fix/disable-delete-hook

Fixes issue #148
This commit is contained in:
Valtteri Karesto
2022-03-29 23:34:12 +03:00
committed by GitHub
2 changed files with 10 additions and 5 deletions

View File

@@ -249,6 +249,7 @@ export const AccountDialog = ({
<Button
size="xs"
outline
disabled={activeAccount.isLoading}
css={{ mt: "$3", mr: "$1", ml: "auto" }}
onClick={() => {
deleteHook(activeAccount);

View File

@@ -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({