Skip to content

docs(prepareSpendCallData): replace Promise.all with sequential awaits in eth_sendTransaction example#343

Open
Sertug17 wants to merge 1 commit into
base:masterfrom
Sertug17:docs/fix-prepare-spend-call-data-example
Open

docs(prepareSpendCallData): replace Promise.all with sequential awaits in eth_sendTransaction example#343
Sertug17 wants to merge 1 commit into
base:masterfrom
Sertug17:docs/fix-prepare-spend-call-data-example

Conversation

@Sertug17

@Sertug17 Sertug17 commented Jun 2, 2026

Copy link
Copy Markdown

The eth_sendTransaction example in the prepareSpendCallData JSDoc used Promise.all to submit the calls, but the comment claimed they would execute "in exact order":

// Or send the calls using eth_sendTransaction to submit both calls in exact order
const promises = spendCalls.map((call) => provider.request({ ... }))
await Promise.all(promises);

Promise.all submits all requests concurrently there is no guarantee that approveWithSignature confirms before spend is mined. For a not-yet-approved permission, both transactions can land in the same block, causing spend to revert because the permission isn't approved yet.

This PR replaces the example with a sequential for...of loop that awaits each call before submitting the next, and adds a comment explaining why Promise.all is unsafe here and why wallet_sendCalls with atomicRequired: true is the recommended path.

No code changes JSDoc comment only.

@cb-heimdall

Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants