From ff432de3164e5970b46f7ce5e139ad9ed795564c Mon Sep 17 00:00:00 2001 From: Thibaut Sardan <33178835+Tbaut@users.noreply.github.com> Date: Mon, 23 Sep 2024 18:37:48 +0200 Subject: [PATCH] Use best any time (#159) --- src/components/LocksCard.tsx | 4 ++-- src/components/MyDelegations.tsx | 8 ++++---- src/contexts/DelegatesContext.tsx | 2 +- src/pages/Delegate/MultiTransactionDialog.tsx | 10 ++++++---- src/pages/Delegate/index.tsx | 4 ++-- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/components/LocksCard.tsx b/src/components/LocksCard.tsx index 3c83bab..c31bff1 100644 --- a/src/components/LocksCard.tsx +++ b/src/components/LocksCard.tsx @@ -109,12 +109,12 @@ export const LocksCard = () => { if (!unVoteTxs || !unlockTxs) return const subscriptionCallback = getSubscriptionCallBack({ - onFinalized: () => setIsUnlockingLoading(false), + onInBlock: () => setIsUnlockingLoading(false), onError: () => setIsUnlockingLoading(false), }) api.tx.Utility.batch({ calls: [...unVoteTxs, ...unlockTxs] }) - .signSubmitAndWatch(selectedAccount.polkadotSigner) + .signSubmitAndWatch(selectedAccount.polkadotSigner, { at: 'best' }) .subscribe(subscriptionCallback) }, [api, freeLocks, getSubscriptionCallBack, getUnlockTx, selectedAccount]) diff --git a/src/components/MyDelegations.tsx b/src/components/MyDelegations.tsx index 16ef05e..97e118d 100644 --- a/src/components/MyDelegations.tsx +++ b/src/components/MyDelegations.tsx @@ -67,15 +67,15 @@ export const MyDelegations = () => { onError: () => { setDelegatesLoading((prev) => prev.filter((id) => id !== delegate)) }, - onFinalized: () => { + onInBlock: () => { setDelegatesLoading((prev) => prev.filter((id) => id !== delegate)) refreshLocks() }, }) - tx.signSubmitAndWatch(selectedAccount.polkadotSigner).subscribe( - subscriptionCallback, - ) + tx.signSubmitAndWatch(selectedAccount.polkadotSigner, { + at: 'best', + }).subscribe(subscriptionCallback) }, [api, delegations, getSubscriptionCallback, refreshLocks, selectedAccount], ) diff --git a/src/contexts/DelegatesContext.tsx b/src/contexts/DelegatesContext.tsx index 89e31e4..dc37d30 100644 --- a/src/contexts/DelegatesContext.tsx +++ b/src/contexts/DelegatesContext.tsx @@ -59,7 +59,7 @@ const DelegateContextProvider = ({ children }: DelegatesContextProps) => { // useEffect(() => { // const a = async (delegates: any[]) => { // const result: Promise[] = delegates.map((d) => { - // return dotApi.query.ConvictionVoting.VotingFor.getEntries(d.address) + // return dotApi.query.ConvictionVoting.VotingFor.getEntries(d.address, 'best') // }) // await Promise.all(result).then((res) => { // console.log(res) diff --git a/src/pages/Delegate/MultiTransactionDialog.tsx b/src/pages/Delegate/MultiTransactionDialog.tsx index eb775be..80ee015 100644 --- a/src/pages/Delegate/MultiTransactionDialog.tsx +++ b/src/pages/Delegate/MultiTransactionDialog.tsx @@ -68,14 +68,14 @@ export const MultiTransactionDialog = ({ const subscriptionCallBack1 = getSubscriptionCallBack({ onError: () => setIsTxInitiated(false), - onFinalized: () => { + onInBlock: () => { setStep(2) setIsTxInitiated(false) }, }) ;(await step1Txs) - .signSubmitAndWatch(selectedAccount?.polkadotSigner) + .signSubmitAndWatch(selectedAccount?.polkadotSigner, { at: 'best' }) .subscribe(subscriptionCallBack1) } @@ -107,10 +107,12 @@ export const MultiTransactionDialog = ({ setIsTxInitiated(false) setWaitingForFinalization(true) }, - onInBlock: () => setWaitingForFinalization(true), - onFinalized: () => { + onInBlock: () => { + setWaitingForFinalization(true) onProcessFinished() setIsTxInitiated(false) + }, + onFinalized: () => { setWaitingForFinalization(false) }, }) diff --git a/src/pages/Delegate/index.tsx b/src/pages/Delegate/index.tsx index 9eff044..5a1b6f1 100644 --- a/src/pages/Delegate/index.tsx +++ b/src/pages/Delegate/index.tsx @@ -178,11 +178,11 @@ export const Delegate = () => { const subscriptionCallBack = getSubscriptionCallBack({ onError: () => setIsTxInitiated(false), - onFinalized: () => onProcessFinished(), + onInBlock: () => onProcessFinished(), }) await allTxs - .signSubmitAndWatch(selectedAccount?.polkadotSigner) + .signSubmitAndWatch(selectedAccount?.polkadotSigner, { at: 'best' }) .subscribe(subscriptionCallBack) }