Skip to content

Commit

Permalink
Use best any time (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaut authored Sep 23, 2024
1 parent 93b400a commit ff432de
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/components/LocksCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down
8 changes: 4 additions & 4 deletions src/components/MyDelegations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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],
)
Expand Down
2 changes: 1 addition & 1 deletion src/contexts/DelegatesContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const DelegateContextProvider = ({ children }: DelegatesContextProps) => {
// useEffect(() => {
// const a = async (delegates: any[]) => {
// const result: Promise<any>[] = 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)
Expand Down
10 changes: 6 additions & 4 deletions src/pages/Delegate/MultiTransactionDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -107,10 +107,12 @@ export const MultiTransactionDialog = ({
setIsTxInitiated(false)
setWaitingForFinalization(true)
},
onInBlock: () => setWaitingForFinalization(true),
onFinalized: () => {
onInBlock: () => {
setWaitingForFinalization(true)
onProcessFinished()
setIsTxInitiated(false)
},
onFinalized: () => {
setWaitingForFinalization(false)
},
})
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Delegate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit ff432de

Please sign in to comment.