mass-payout.js (not batching?)

Open Beginner friendly
#416 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
64/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
javascript
Domain
api

Research direction

Start with quickstart-template/mass-payout.js at the referenced line and inspect sendMassPayout, especially the transfer.wait() call. Verify whether each transfer is awaited before the next is created; done means all transfers can be queued before their statuses are checked, with the intended completion or failure output preserved.

Written by the indexing model from the issue text.

Description

https://github.com/coinbase/coinbase-sdk-nodejs/blob/524a5724fc89770d992f40032d9da4a1978ca70b/quickstart-template/mass-payout.js#L79

Question, in function sendMassPayout... the await transfer.wait() call, wouldn't this make the code not batch and wait for each transfer to complete?

Should we skip this transfer.wait(); but store the "pending transfers" in an array and then check their status later?

something like this:

const transfers = [];

// STEP 1: Queue all transfers (sequentially to enable batching)
for (const address of recipients) {
  const transfer = await wallet.createTransfer({
            amount: transferAmount,
            assetId: assetId,
            destination: address,
  });

  transfers.push({ address, transfer });
  console.log(`Queued transfer to ${address}`);
}

// STEP 2: Only after all are queued, check for status
for (const { address, transfer } of transfers) {
  await transfer.wait(); // Now we can wait without blocking the next transfer
  const status = transfer.getStatus();

  if (status === 'complete') {
    console.log(`Completed for ${address}`);
  } else {
    console.error(`Failed for ${address}`);
  }
}
Dominant language
TypeScript
Stars
123
Forks
94
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from coinbase/coinbase-sdk-nodejs

All issues in coinbase/coinbase-sdk-nodejs

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.