diff --git a/package.json b/package.json index 103ef0cd..64adbefb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@etherspot/react-transaction-buidler", - "version": "0.5.15", + "version": "0.5.16", "description": "Etherspot React component.", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", diff --git a/src/components/TransactionBlock/AssetBridgeTransactionBlock.tsx b/src/components/TransactionBlock/AssetBridgeTransactionBlock.tsx index 4144ce79..cb127486 100644 --- a/src/components/TransactionBlock/AssetBridgeTransactionBlock.tsx +++ b/src/components/TransactionBlock/AssetBridgeTransactionBlock.tsx @@ -242,8 +242,9 @@ const AssetBridgeTransactionBlock = ({ useEffect(() => { if (setTransactionBlockValues) { - const fromAsset = availableFromAssets?.find((availableAsset) => availableAsset.address === selectedFromAsset?.value); - const toAsset = availableToAssets?.find((availableAsset) => availableAsset.address === selectedToAsset?.value); + const fromAsset = availableFromAssets?.find((availableAsset) => addressesEqual(availableAsset.address, selectedFromAsset?.value)); + const toAsset = availableToAssets?.find((availableAsset) => addressesEqual(availableAsset.address, selectedToAsset?.value)); + const quote = availableQuotes?.find((availableQuote) => availableQuote.provider === selectedQuote?.value); setTransactionBlockValues(transactionBlockId, { fromChainId: selectedFromNetwork?.value, toChainId: selectedToNetwork?.value, @@ -251,6 +252,7 @@ const AssetBridgeTransactionBlock = ({ fromAssetDecimals: fromAsset?.decimals, toAssetAddress: toAsset?.address, amount, + quote, }); } }, [ @@ -262,10 +264,11 @@ const AssetBridgeTransactionBlock = ({ selectedFromAsset, selectedToAsset, amount, + selectedQuote, ]); const selectedFromAssetDisplayValue = useMemo( - () => availableFromAssets?.find((availableAsset) => availableAsset.address === selectedFromAsset?.value)?.symbol, + () => availableFromAssets?.find((availableAsset) => addressesEqual(availableAsset.address, selectedFromAsset?.value))?.symbol, [availableFromAssets, selectedFromAsset] ); @@ -352,7 +355,7 @@ const AssetBridgeTransactionBlock = ({ resetTransactionBlockFieldValidationError(transactionBlockId, 'quote'); setSelectedQuote(option); }} - errorMessage={errorMessages?.offer} + errorMessage={errorMessages?.quote} /> )} diff --git a/src/components/TransactionBlock/SendAssetTransactionBlock.tsx b/src/components/TransactionBlock/SendAssetTransactionBlock.tsx index 556035af..03a96717 100644 --- a/src/components/TransactionBlock/SendAssetTransactionBlock.tsx +++ b/src/components/TransactionBlock/SendAssetTransactionBlock.tsx @@ -107,7 +107,6 @@ const SendAssetTransactionBlock = ({ const assetsBalances = await getAssetsBalancesForChainId(assets, chainIdToLoad, addressToCheck); const assetsWithPositiveBalances = assets.filter((asset) => assetsBalances.some((assetBalance) => { - console.log({ assetBalance }) if (addressesEqual(asset.address, nativeAssetPerChainId[chainId]?.address)) return true; return addressesEqual(asset.address, assetBalance.token); })); diff --git a/src/providers/TransactionBuilderContextProvider.tsx b/src/providers/TransactionBuilderContextProvider.tsx index 6adbc1c1..e66ba2fa 100644 --- a/src/providers/TransactionBuilderContextProvider.tsx +++ b/src/providers/TransactionBuilderContextProvider.tsx @@ -258,15 +258,16 @@ const TransactionBuilderContextProvider = ({ let newCrossChainActions: CrossChainAction[] = []; let errorMessage; + if (Object.keys(validationErrors).length === 0) { // keep blocks in order for (const transactionBlock of transactionBlocks) { - const transaction = await buildCrossChainAction(sdk, transactionBlock); - if (!transaction?.crossChainAction || transaction?.errorMessage) { - errorMessage = transaction?.errorMessage ?? `Failed to build a cross chain action!`; + const result = await buildCrossChainAction(sdk, transactionBlock); + if (!result?.crossChainAction || result?.errorMessage) { + errorMessage = result?.errorMessage ?? `Failed to build a cross chain action!`; break; } - newCrossChainActions = [...newCrossChainActions, transaction.crossChainAction]; + newCrossChainActions = [...newCrossChainActions, result.crossChainAction]; } }