From e3acbc81bbfb56a9d4295e7af23637f8f4c1f956 Mon Sep 17 00:00:00 2001 From: Hans Wang Date: Thu, 24 Oct 2024 20:51:09 -0700 Subject: [PATCH] Fixed bug issues in bridge routing logics, as it was written for handling only 1 accounts, when have multiple it will brdige all 0 balance accounts --- src/builder/Actions.sol | 46 +++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/builder/Actions.sol b/src/builder/Actions.sol index 8da1e7c..7bb320a 100644 --- a/src/builder/Actions.sol +++ b/src/builder/Actions.sol @@ -564,28 +564,30 @@ library Actions { } } - amountLeftToBridge -= amountToBridge; - - (IQuarkWallet.QuarkOperation memory operation, Actions.Action memory action) = bridgeAsset( - BridgeAsset({ - chainAccountsList: chainAccountsList, - assetSymbol: bridgeInfo.assetSymbol, - amount: amountToBridge, - // where it comes from - srcChainId: srcChainAccounts.chainId, - sender: srcAccountBalances[j].account, - // where it goes - destinationChainId: bridgeInfo.dstChainId, - recipient: bridgeInfo.recipient, - blockTimestamp: bridgeInfo.blockTimestamp - }), - payment, - bridgeInfo.useQuotecall - ); - - List.addAction(actions, action); - List.addQuarkOperation(quarkOperations, operation); - bridgeActionCount++; + if (amountToBridge > 0) { + amountLeftToBridge -= amountToBridge; + + (IQuarkWallet.QuarkOperation memory operation, Actions.Action memory action) = bridgeAsset( + BridgeAsset({ + chainAccountsList: chainAccountsList, + assetSymbol: bridgeInfo.assetSymbol, + amount: amountToBridge, + // where it comes from + srcChainId: srcChainAccounts.chainId, + sender: srcAccountBalances[j].account, + // where it goes + destinationChainId: bridgeInfo.dstChainId, + recipient: bridgeInfo.recipient, + blockTimestamp: bridgeInfo.blockTimestamp + }), + payment, + bridgeInfo.useQuotecall + ); + + List.addAction(actions, action); + List.addQuarkOperation(quarkOperations, operation); + bridgeActionCount++; + } } }