Skip to content

Commit

Permalink
fix: bridge initiated from core web (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
meeh0w authored Sep 18, 2024
1 parent 4c2f611 commit 8d5cc2c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,15 @@ describe('background/services/bridge/handlers/avalanche_bridgeAsset', () => {

const balanceServiceMock = {
getBalancesForNetworks: jest.fn().mockResolvedValueOnce({
[43113]: {
C_address: {
WETH: {
symbol: 'WETH',
type: TokenType.ERC20,
balance: new BN(100),
decimals: 1,
tokens: {
[43113]: {
C_address: {
WETH: {
symbol: 'WETH',
type: TokenType.ERC20,
balance: new BN(100),
decimals: 1,
},
},
},
},
Expand Down
11 changes: 6 additions & 5 deletions src/background/services/bridge/handlers/avalanche_bridgeAsset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,11 @@ export class AvalancheBridgeAsset extends DAppRequestHandler<BridgeActionParams>
}

// get the correct balance information for the asset
const balances = await this.balanceAggregatorService.getBalancesForNetworks(
[sourceNetwork.chainId],
[activeAccount]
);
const { tokens } =
await this.balanceAggregatorService.getBalancesForNetworks(
[sourceNetwork.chainId],
[activeAccount]
);

const balanceAddress =
sourceNetwork && isBitcoinNetwork(sourceNetwork)
Expand All @@ -179,7 +180,7 @@ export class AvalancheBridgeAsset extends DAppRequestHandler<BridgeActionParams>
findTokenForAsset(
asset.symbol,
asset.nativeNetwork,
Object.values(balances?.[sourceNetwork.chainId]?.[balanceAddress] ?? {})
Object.values(tokens?.[sourceNetwork.chainId]?.[balanceAddress] ?? {})
);

const action: Action<BridgeActionDisplayData> = {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ApproveAction/BridgeTransferAsset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function BridgeTransferAsset({
GasFeeModifier.INSTANT
);

const tokenPrice = displayData.token.priceInCurrency;
const tokenPrice = displayData?.token?.priceInCurrency;
const fiatValue: Big | undefined =
typeof tokenPrice === 'number'
? new Big(displayData.amountStr).times(tokenPrice)
Expand Down

0 comments on commit 8d5cc2c

Please sign in to comment.