From bd263b8a0a252ec3c5a3b5098554ad38e94fe420 Mon Sep 17 00:00:00 2001 From: Noah Saso Date: Tue, 12 Nov 2024 23:28:36 -0500 Subject: [PATCH] support multi-NFT transfer in action 2 --- .../core/actions/TransferNft/index.tsx | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/packages/stateful/actions/core/actions/TransferNft/index.tsx b/packages/stateful/actions/core/actions/TransferNft/index.tsx index 99ac55198..782a0a240 100644 --- a/packages/stateful/actions/core/actions/TransferNft/index.tsx +++ b/packages/stateful/actions/core/actions/TransferNft/index.tsx @@ -232,28 +232,21 @@ export class TransferNftAction extends ActionBase { // Select all identical adjacent transfers starting with the first. Once one // does not match, stop. - const transfers = [] - for (const transfer of all) { - if (!transfer) { - continue - } - - // If this is the first transfer, add it. - if (!transfers.length) { - transfers.push(transfer) - } else if ( - // If the chainId, recipient, executeSmartContract, and smartContractMsg - // match, add it. - transfer.chainId === transfers[0].chainId && - transfer.recipient === transfers[0].recipient && - transfer.executeSmartContract === transfers[0].executeSmartContract && - transfer.smartContractMsg === transfers[0].smartContractMsg + const transfers = [all[0]] + for (const transfer of all.slice(1)) { + // If the chainId, recipient, executeSmartContract, and smartContractMsg + // don't match the first transfer, stop. + if ( + !transfer || + transfer.chainId !== transfers[0].chainId || + transfer.recipient !== transfers[0].recipient || + transfer.executeSmartContract !== transfers[0].executeSmartContract || + transfer.smartContractMsg !== transfers[0].smartContractMsg ) { - transfers.push(transfer) - } else { - // If it doesn't match, stop. break } + + transfers.push(transfer) } return transfers