Skip to content

Commit

Permalink
conditionally render gas row if non-zero (#1320)
Browse files Browse the repository at this point in the history
  • Loading branch information
artursapek authored Dec 12, 2023
1 parent f9f43f1 commit bcc19c8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
13 changes: 9 additions & 4 deletions wormhole-connect/src/routes/cctpRelay/cctpRelay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ export class CCTPRelayRoute extends CCTPManualRoute implements RelayAbstract {
MAX_DECIMALS,
);
const { gasToken } = CHAINS[txData.toChain]!;
return [
let rows = [
{
title: 'Amount',
value: `${formattedAmt} ${getDisplayName(token)}`,
Expand All @@ -552,13 +552,18 @@ export class CCTPRelayRoute extends CCTPManualRoute implements RelayAbstract {
title: 'Relayer fee',
value: `${formattedFee} ${getDisplayName(token)}`,
},
{
];

if (!BigNumber.from(txData.toNativeTokenAmount).isZero()) {
rows.push({
title: 'Convert to native gas token',
value: `≈ ${formattedToNative} ${getDisplayName(
token,
)} \u2192 ${getDisplayName(TOKENS[gasToken])}`,
},
];
});
}

return rows;
}

async getTransferDestInfo({
Expand Down
24 changes: 15 additions & 9 deletions wormhole-connect/src/routes/relay/relay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,13 +457,8 @@ export class RelayRoute extends BridgeRoute implements RelayAbstract {
txData.tokenDecimals,
MAX_DECIMALS,
);
const formattedToNative = toNormalizedDecimals(
txData.toNativeTokenAmount,
txData.tokenDecimals,
MAX_DECIMALS,
);
const { gasToken } = CHAINS[txData.toChain]!;
return [
let rows = [
{
title: 'Amount',
value: `${formattedAmt} ${getDisplayName(token)}`,
Expand All @@ -478,13 +473,24 @@ export class RelayRoute extends BridgeRoute implements RelayAbstract {
title: 'Relayer fee',
value: `${formattedFee} ${getDisplayName(token)}`,
},
{
];

if (!BigNumber.from(txData.toNativeTokenAmount).isZero()) {
const formattedToNative = toNormalizedDecimals(
txData.toNativeTokenAmount,
txData.tokenDecimals,
MAX_DECIMALS,
);

rows.push({
title: 'Convert to native gas token',
value: `≈ ${formattedToNative} ${getDisplayName(
token,
)} \u2192 ${getDisplayName(TOKENS[gasToken])}`,
},
];
});
}

return rows;
}

async getTransferDestInfo({
Expand Down

0 comments on commit bcc19c8

Please sign in to comment.