Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions packages/connect/src/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2500,6 +2500,4 @@ export const styles = String.raw`
--tw-gradient-to-position: 100%;
}
}
}

`
}`
26 changes: 23 additions & 3 deletions packages/connect/src/utils/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,29 @@ export const waitForTransactionReceipt = async ({
publicClient,
confirmations
}: WaitForTransactionReceiptInput): Promise<TransactionReceipt> => {
const { receipt } = await indexerClient.fetchTransactionReceipt({
txnHash
})
const RECEIPT_MAX_WAIT_MINUTES = 3
const WAIT_TIME_BETWEEN_REQUESTS_MS = 3000
const startTime = Date.now()
const maxWaitTime = RECEIPT_MAX_WAIT_MINUTES * 60 * 1000

let receipt: TransactionReceipt | undefined

while (Date.now() - startTime < maxWaitTime && !receipt) {
const response = await indexerClient.fetchTransactionReceipt({
txnHash
})

receipt = response.receipt

// Additional wait time between requests. fetchTransactionReceipt will wait for 400 blocks, but this could be short amount of time if the blocktime is very short
if (!receipt) {
await new Promise(resolve => setTimeout(resolve, WAIT_TIME_BETWEEN_REQUESTS_MS))
}
}

if (!receipt) {
throw new Error('Timeout: Transaction receipt not found')
}

if (confirmations) {
const blockConfirmationPromise = new Promise<void>(resolve => {
Expand Down