Skip to content

Commit

Permalink
Fix confirmation issue
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpolman committed Nov 12, 2024
1 parent 863ca25 commit 043da7e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
<span class="text-opaque me-auto">Token ID</span>
<b-link :href="url" target="_blank">{{ collectible.tokenId }}</b-link>
</div>
<b-button variant="primary" class="w-100 my-3" @click="isModalTransferShown = true">
<b-button
variant="primary"
class="w-100 my-3"
:disabled="isLoading"
@click="isModalTransferShown = true"
>
Transfer
<BaseIcon icon="chevron-right" class="ms-1" />
</b-button>
Expand Down
1 change: 1 addition & 0 deletions apps/wallet/src/stores/Entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const useEntryStore = defineStore('entry', {
method: 'PATCH',
params: { walletId: wallet._id },
});
await this.get(uuid);
},
},
});
27 changes: 11 additions & 16 deletions apps/wallet/src/stores/Safe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,24 @@ export const useSafeStore = defineStore('safe', {
request(path: string, options?: TRequestOptions) {
return useAuthStore().request(path, options);
},
async waitForTransaction(tx: TTransaction) {
async waitForTransactionProposal(tx: TTransaction) {
return new Promise((resolve, reject) => {
setTimeout(async () => {
const newTx = await this.request(`/transactions/${tx._id}`);
if (![TransactionState.Mined, TransactionState.Failed].includes(tx.state)) {
this.waitForTransaction(newTx).then(resolve).catch(reject);
} else {
resolve(newTx);
}
if (tx.safeTxHash) resolve(newTx);
this.waitForTransactionProposal(newTx).then(resolve).catch(reject);
}, TX_POLLING_INTERVAL);
});
}) as unknown as TTransaction;
},
async waitForTransactionProposal(tx: TTransaction) {
async waitForTransaction(tx: TTransaction) {
return new Promise((resolve, reject) => {
setTimeout(async () => {
const newTx = await this.request(`/transactions/${tx._id}`);
if (!tx.safeTxHash) {
this.waitForTransactionProposal(newTx).then(resolve).catch(reject);
} else {
resolve(newTx);
}
const isMinedOrFailed = [TransactionState.Mined, TransactionState.Failed].includes(tx.state);
if (isMinedOrFailed) resolve(newTx);
this.waitForTransaction(newTx).then(resolve).catch(reject);
}, TX_POLLING_INTERVAL);
}) as unknown as TTransaction;
});
},
async confirmTransaction(tx: TTransaction) {
const { waitForTransactionProposal } = useSafeStore();
Expand All @@ -51,12 +46,12 @@ export const useSafeStore = defineStore('safe', {
const { wallet } = useWalletStore();
if (!wallet) throw new Error('Please select a multisig wallet.');

const signature = await this.signSafeTXHash(wallet, tx.safeTxHash);
const signature = await this.signSafeTXHash(wallet, safeTxHash);
if (!signature) throw new Error('Could not sign this transaction.');

return await this.request(`/account/wallets/confirm`, {
method: 'POST',
body: { chainId: wallet.chainId, safeTxHash: tx.safeTxHash, signature },
body: { chainId: wallet.chainId, safeTxHash, signature },
params: { walletId: wallet._id },
});
},
Expand Down

0 comments on commit 043da7e

Please sign in to comment.