Skip to content

Commit

Permalink
fixed selected bridge quote param, chore, version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
poocart committed Sep 1, 2022
1 parent f07fe88 commit cad34bb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
11 changes: 7 additions & 4 deletions src/components/TransactionBlock/AssetBridgeTransactionBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,17 @@ 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,
fromAssetAddress: fromAsset?.address,
fromAssetDecimals: fromAsset?.decimals,
toAssetAddress: toAsset?.address,
amount,
quote,
});
}
}, [
Expand All @@ -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]
);

Expand Down Expand Up @@ -352,7 +355,7 @@ const AssetBridgeTransactionBlock = ({
resetTransactionBlockFieldValidationError(transactionBlockId, 'quote');
setSelectedQuote(option);
}}
errorMessage={errorMessages?.offer}
errorMessage={errorMessages?.quote}
/>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}));
Expand Down
9 changes: 5 additions & 4 deletions src/providers/TransactionBuilderContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}

Expand Down

0 comments on commit cad34bb

Please sign in to comment.