Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/to token addr issue #271

Merged
merged 11 commits into from
Jan 8, 2025
5 changes: 0 additions & 5 deletions .release/.changeset/hot-knives-pay.md

This file was deleted.

11 changes: 0 additions & 11 deletions .release/.changeset/pre.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ export function useTransferConfig() {
7565164: [
'So11111111111111111111111111111111111111112',
'FmqVMWXBESyu4g6FT1uz1GABKdJ4j6wbuuLFwPJtqpmu',
'2kaRSuDcz1V1kqq1sDmP23Wy98jutHQQgr5fGDWRpump',
'2FPyTwcZLUg1MDrwsyoP4D6s1tM7hAkHYRjkNb5w6Pxk',
],
},
},
Expand Down
6 changes: 6 additions & 0 deletions packages/canonical-bridge-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @bnb-chain/canonical-bridge-sdk

## 0.4.7

### Patch Changes

- 7c2e201: Confirmation popup

## 0.4.6

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/canonical-bridge-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bnb-chain/canonical-bridge-sdk",
"version": "0.4.6",
"version": "0.4.7",
"description": "canonical bridge sdk",
"author": "bnb-chain",
"private": false,
Expand Down
23 changes: 18 additions & 5 deletions packages/canonical-bridge-sdk/src/debridge/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class DeBridge {
toUserAddress,
affiliateFeePercent = 0,
accesstoken = '',
referralCode = '30229',
referralCode,
prependOperatingExpenses = false,
}: IDeBridgeEstimatedFeesInput): Promise<DeBridgeCreateQuoteResponse> {
try {
Expand Down Expand Up @@ -290,10 +290,23 @@ export class DeBridge {
fromTokenList.status === 'fulfilled' &&
toTokenList.status === 'fulfilled'
) {
const fromToken =
fromTokenList?.value?.data.tokens[fromTokenAddress.toLowerCase()];
const toToken =
toTokenList?.value?.data.tokens[toTokenAddress.toLowerCase()];
const fromTokenAddr =
fromChainType === 'solana'
? fromTokenAddress
: fromTokenAddress.toLowerCase();
const toTokenAddr =
toChainType === 'solana'
? toTokenAddress
: toTokenAddress.toLowerCase();
const fromToken = fromTokenList?.value?.data.tokens[fromTokenAddr];
const toToken = toTokenList?.value?.data.tokens[toTokenAddr];

if (!toToken) {
console.log('Can not find toToken info');
}
if (!fromToken) {
console.log('Can not find fromToken info');
}
if (
!!fromToken &&
fromToken?.address.toLowerCase() === fromTokenAddress.toLowerCase() &&
Expand Down
13 changes: 13 additions & 0 deletions packages/canonical-bridge-widget/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# @bnb-chain/canonical-bridge-widget

## 0.5.18

### Patch Changes

- eb0917b: feat: Confirmation popup

## 0.5.17

### Patch Changes

- 2179e93: feat: Send confirm popup
- 7c2e201: Confirmation popup

## 0.5.17-alpha.0

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/canonical-bridge-widget/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bnb-chain/canonical-bridge-widget",
"version": "0.5.17-alpha.0",
"version": "0.5.18",
"description": "canonical bridge widget",
"author": "bnb-chain",
"private": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const TokenInfo = ({
/>
<IconImage boxSize="32px" src={chainIconUrl} flexShrink={0} />
</Flex>
<Box fontSize={'16px'} py={'8px'} fontWeight={700} maxW={'103px'} whiteSpace={'wrap'}>
<Box fontSize={'16px'} py={'8px'} fontWeight={700} maxW={'142px'} whiteSpace={'wrap'}>
{chainName}
</Box>
</Flex>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Flex, Link, useBreakpointValue, useColorMode, useIntl, useTheme } from '@bnb-chain/space';
import { useMemo } from 'react';
import { BridgeType } from '@bnb-chain/canonical-bridge-sdk';

import { useAppSelector } from '@/modules/store/StoreProvider';
import { useGetReceiveAmount } from '@/modules/transfer/hooks/useGetReceiveAmount';
Expand All @@ -22,21 +23,28 @@ export const TransferSummary = () => {
const selectedToken = useAppSelector((state) => state.transfer.selectedToken);
const sendValue = useAppSelector((state) => state.transfer.sendValue);
const transferActionInfo = useAppSelector((state) => state.transfer.transferActionInfo);
const { toTokenInfo } = useToTokenInfo();
const { getToTokenAddress, toTokenInfo, getToTokenSymbol } = useToTokenInfo();

const bridgeType = useMemo(
() => transferActionInfo?.bridgeType,
[transferActionInfo],
) as BridgeType;
const receiveAmt = useMemo(() => {
if (!Number(sendValue)) return null;
if (transferActionInfo && transferActionInfo.bridgeType) {
const bridgeType = transferActionInfo.bridgeType;
if (bridgeType) {
const receiveValue = getSortedReceiveAmount();
return Number(receiveValue[bridgeType].value);
}
return null;
}, [getSortedReceiveAmount, transferActionInfo, sendValue]);
}, [getSortedReceiveAmount, bridgeType, sendValue]);

const toTokenAddress = useMemo(() => {
return bridgeType ? getToTokenAddress()[bridgeType] : '';
}, [bridgeType, getToTokenAddress]);

const isNative = useMemo(
() => isNativeToken(toTokenInfo?.address, toChain?.chainType),
[toTokenInfo?.address, toChain?.chainType],
() => isNativeToken(toTokenAddress, toChain?.chainType),
[toTokenAddress, toChain?.chainType],
);

return (
Expand Down Expand Up @@ -77,25 +85,27 @@ export const TransferSummary = () => {
<span style={{ marginRight: '2px' }}>
{formatMessage({ id: 'transfer.warning.confirm.to.address' })}
</span>
<Link
isExternal
href={formatTokenUrl(toChain?.tokenUrlPattern, toTokenInfo?.address)}
display="inline-block"
overflowWrap={'break-word'}
pointerEvents={'all'}
color="currentColor"
>
{isBase
? formatAppAddress({ address: toTokenInfo?.address, isTruncated: true })
: toTokenInfo?.address}
</Link>
{toTokenAddress ? (
<Link
isExternal
href={formatTokenUrl(toChain?.tokenUrlPattern, toTokenAddress)}
display="inline-block"
overflowWrap={'break-word'}
pointerEvents={'all'}
color="currentColor"
>
{isBase
? formatAppAddress({ address: toTokenAddress, isTruncated: true })
: toTokenAddress}
</Link>
) : null}
</>
) : (
<>
<span style={{ marginRight: '2px' }}>
{formatMessage({ id: 'transfer.warning.confirm.to.native.token.address' })}
</span>
<span>{toTokenInfo?.symbol?.toUpperCase()}</span>
<span>{getToTokenSymbol()?.[bridgeType]?.toUpperCase() ?? ''}</span>
</>
)}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const useToTokenInfo = () => {
deBridge: toTokenInfo?.deBridge?.raw?.address || '',
stargate: toTokenInfo?.stargate?.raw?.token?.address || '',
layerZero: toTokenInfo?.layerZero?.raw?.address || '',
meson: toTokenInfo?.meson?.raw?.addr || 0,
meson: toTokenInfo?.meson?.raw?.addr || '',
};
}, [toTokenInfo]);

Expand Down
Loading