@across-protocol/sdk 4.2.15 → 4.2.16-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/arch/evm/SpokeUtils.d.ts +6 -2
- package/dist/cjs/arch/evm/SpokeUtils.js +21 -6
- package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/SpokeUtils.d.ts +6 -2
- package/dist/cjs/arch/svm/SpokeUtils.js +66 -67
- package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/utils.d.ts +3 -1
- package/dist/cjs/arch/svm/utils.js +20 -14
- package/dist/cjs/arch/svm/utils.js.map +1 -1
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +4 -2
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.d.ts +4 -4
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +60 -56
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js +13 -13
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +3 -2
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js +5 -1
- package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js +3 -3
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +63 -63
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +11 -8
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/cjs/clients/HubPoolClient.d.ts +21 -21
- package/dist/cjs/clients/HubPoolClient.js +83 -58
- package/dist/cjs/clients/HubPoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +1 -1
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +64 -45
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockHubPoolClient.d.ts +9 -9
- package/dist/cjs/clients/mocks/MockHubPoolClient.js +15 -9
- package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSpokePoolClient.d.ts +5 -3
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js +40 -36
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js +2 -2
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
- package/dist/cjs/interfaces/HubPool.d.ts +19 -14
- package/dist/cjs/interfaces/SpokePool.d.ts +13 -13
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +10 -10
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +5 -5
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +41 -48
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +5 -5
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +7 -7
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/cjs/utils/AddressUtils.d.ts +12 -13
- package/dist/cjs/utils/AddressUtils.js +44 -46
- package/dist/cjs/utils/AddressUtils.js.map +1 -1
- package/dist/cjs/utils/EventUtils.js +1 -1
- package/dist/cjs/utils/EventUtils.js.map +1 -1
- package/dist/cjs/utils/SpokeUtils.d.ts +3 -3
- package/dist/cjs/utils/SpokeUtils.js +4 -22
- package/dist/cjs/utils/SpokeUtils.js.map +1 -1
- package/dist/cjs/utils/TokenUtils.d.ts +4 -4
- package/dist/cjs/utils/TokenUtils.js +4 -6
- package/dist/cjs/utils/TokenUtils.js.map +1 -1
- package/dist/esm/arch/evm/SpokeUtils.d.ts +6 -2
- package/dist/esm/arch/evm/SpokeUtils.js +22 -7
- package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/SpokeUtils.d.ts +6 -2
- package/dist/esm/arch/svm/SpokeUtils.js +70 -71
- package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/utils.d.ts +6 -1
- package/dist/esm/arch/svm/utils.js +21 -13
- package/dist/esm/arch/svm/utils.js.map +1 -1
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +4 -2
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.d.ts +4 -4
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +61 -57
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +14 -14
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +5 -3
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js +5 -1
- package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js +4 -4
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +63 -63
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +12 -9
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/esm/clients/HubPoolClient.d.ts +23 -22
- package/dist/esm/clients/HubPoolClient.js +97 -63
- package/dist/esm/clients/HubPoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +2 -2
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +67 -47
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockHubPoolClient.d.ts +9 -9
- package/dist/esm/clients/mocks/MockHubPoolClient.js +16 -10
- package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSpokePoolClient.d.ts +5 -3
- package/dist/esm/clients/mocks/MockSpokePoolClient.js +42 -38
- package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js +3 -3
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
- package/dist/esm/interfaces/HubPool.d.ts +19 -14
- package/dist/esm/interfaces/SpokePool.d.ts +13 -13
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +11 -11
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.d.ts +6 -6
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +43 -50
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +5 -5
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +8 -8
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/esm/utils/AddressUtils.d.ts +13 -14
- package/dist/esm/utils/AddressUtils.js +50 -56
- package/dist/esm/utils/AddressUtils.js.map +1 -1
- package/dist/esm/utils/EventUtils.js +2 -2
- package/dist/esm/utils/EventUtils.js.map +1 -1
- package/dist/esm/utils/SpokeUtils.d.ts +3 -8
- package/dist/esm/utils/SpokeUtils.js +4 -26
- package/dist/esm/utils/SpokeUtils.js.map +1 -1
- package/dist/esm/utils/TokenUtils.d.ts +4 -16
- package/dist/esm/utils/TokenUtils.js +5 -7
- package/dist/esm/utils/TokenUtils.js.map +1 -1
- package/dist/types/arch/evm/SpokeUtils.d.ts +6 -2
- package/dist/types/arch/evm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/SpokeUtils.d.ts +6 -2
- package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/utils.d.ts +6 -1
- package/dist/types/arch/svm/utils.d.ts.map +1 -1
- package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
- package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts +4 -4
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/DataworkerUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
- package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/MerkleTreeUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/PoolRebalanceUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +63 -63
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts.map +1 -1
- package/dist/types/clients/HubPoolClient.d.ts +23 -22
- package/dist/types/clients/HubPoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
- package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts +9 -9
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts +5 -3
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
- package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts.map +1 -1
- package/dist/types/interfaces/HubPool.d.ts +19 -14
- package/dist/types/interfaces/HubPool.d.ts.map +1 -1
- package/dist/types/interfaces/SpokePool.d.ts +13 -13
- package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts +6 -6
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +5 -5
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
- package/dist/types/utils/AddressUtils.d.ts +13 -14
- package/dist/types/utils/AddressUtils.d.ts.map +1 -1
- package/dist/types/utils/SpokeUtils.d.ts +3 -8
- package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
- package/dist/types/utils/TokenUtils.d.ts +4 -16
- package/dist/types/utils/TokenUtils.d.ts.map +1 -1
- package/package.json +1 -2
- package/src/arch/evm/SpokeUtils.ts +52 -12
- package/src/arch/svm/SpokeUtils.ts +102 -51
- package/src/arch/svm/utils.ts +11 -4
- package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +7 -4
- package/src/clients/BundleDataClient/BundleDataClient.ts +57 -53
- package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +28 -13
- package/src/clients/BundleDataClient/utils/FillUtils.ts +10 -4
- package/src/clients/BundleDataClient/utils/MerkleTreeUtils.ts +7 -1
- package/src/clients/BundleDataClient/utils/PoolRebalanceUtils.ts +4 -4
- package/src/clients/BundleDataClient/utils/SuperstructUtils.ts +13 -9
- package/src/clients/HubPoolClient.ts +126 -82
- package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +6 -0
- package/src/clients/SpokePoolClient/SpokePoolClient.ts +118 -35
- package/src/clients/mocks/MockHubPoolClient.ts +24 -19
- package/src/clients/mocks/MockSpokePoolClient.ts +39 -27
- package/src/clients/mocks/MockSvmSpokePoolClient.ts +12 -3
- package/src/interfaces/HubPool.ts +23 -14
- package/src/interfaces/SpokePool.ts +13 -13
- package/src/relayFeeCalculator/chain-queries/baseQuery.ts +14 -12
- package/src/relayFeeCalculator/chain-queries/svmQuery.ts +41 -44
- package/src/relayFeeCalculator/relayFeeCalculator.ts +20 -12
- package/src/utils/AddressUtils.ts +58 -60
- package/src/utils/EventUtils.ts +2 -2
- package/src/utils/SpokeUtils.ts +11 -33
- package/src/utils/TokenUtils.ts +10 -11
package/src/utils/SpokeUtils.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { encodeAbiParameters, Hex, keccak256 } from "viem";
|
|
2
2
|
import { fixedPointAdjustment as fixedPoint } from "./common";
|
|
3
|
-
import { MAX_SAFE_DEPOSIT_ID,
|
|
4
|
-
import {
|
|
5
|
-
import { toBytes32 } from "./AddressUtils";
|
|
3
|
+
import { MAX_SAFE_DEPOSIT_ID, ZERO_BYTES } from "../constants";
|
|
4
|
+
import { Fill, FillType, RelayData, SlowFillLeaf } from "../interfaces";
|
|
6
5
|
import { BigNumber } from "./BigNumberUtils";
|
|
6
|
+
import { Address } from "./AddressUtils";
|
|
7
7
|
import { isMessageEmpty } from "./DepositUtils";
|
|
8
8
|
import { chainIsSvm } from "./NetworkUtils";
|
|
9
9
|
import { svm } from "../arch";
|
|
@@ -16,28 +16,6 @@ export function getSlowFillLeafLpFeePct(leaf: SlowFillLeaf): BigNumber {
|
|
|
16
16
|
const { relayData, updatedOutputAmount } = leaf;
|
|
17
17
|
return relayData.inputAmount.sub(updatedOutputAmount).mul(fixedPoint).div(relayData.inputAmount);
|
|
18
18
|
}
|
|
19
|
-
/**
|
|
20
|
-
* Produce the RelayData for a Deposit.
|
|
21
|
-
* @param deposit Deposit instance.
|
|
22
|
-
* @returns The corresponding RelayData object.
|
|
23
|
-
*/
|
|
24
|
-
export function getDepositRelayData(deposit: Omit<Deposit, "messageHash">): RelayData {
|
|
25
|
-
return {
|
|
26
|
-
depositor: toBytes32(deposit.depositor),
|
|
27
|
-
recipient: toBytes32(deposit.recipient),
|
|
28
|
-
exclusiveRelayer: toBytes32(deposit.exclusiveRelayer),
|
|
29
|
-
inputToken: toBytes32(deposit.inputToken),
|
|
30
|
-
outputToken: toBytes32(deposit.outputToken),
|
|
31
|
-
inputAmount: deposit.inputAmount,
|
|
32
|
-
outputAmount: deposit.outputAmount,
|
|
33
|
-
originChainId: deposit.originChainId,
|
|
34
|
-
depositId: deposit.depositId,
|
|
35
|
-
fillDeadline: deposit.fillDeadline,
|
|
36
|
-
exclusivityDeadline: deposit.exclusivityDeadline,
|
|
37
|
-
message: deposit.message,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
19
|
/**
|
|
42
20
|
* Compute the RelayData hash for a fill. This can be used to determine the fill status.
|
|
43
21
|
* @param relayData RelayData information that is used to complete a fill.
|
|
@@ -68,14 +46,14 @@ export function getRelayDataHash(relayData: RelayData, destinationChainId: numbe
|
|
|
68
46
|
|
|
69
47
|
const _relayData = {
|
|
70
48
|
...relayData,
|
|
71
|
-
depositor:
|
|
72
|
-
recipient:
|
|
73
|
-
inputToken:
|
|
74
|
-
outputToken:
|
|
75
|
-
exclusiveRelayer:
|
|
49
|
+
depositor: relayData.depositor.toBytes32(),
|
|
50
|
+
recipient: relayData.recipient.toBytes32(),
|
|
51
|
+
inputToken: relayData.inputToken.toBytes32(),
|
|
52
|
+
outputToken: relayData.outputToken.toBytes32(),
|
|
53
|
+
exclusiveRelayer: relayData.exclusiveRelayer.toBytes32(),
|
|
76
54
|
};
|
|
77
55
|
if (chainIsSvm(destinationChainId)) {
|
|
78
|
-
return svm.getRelayDataHash(
|
|
56
|
+
return svm.getRelayDataHash(relayData, destinationChainId);
|
|
79
57
|
}
|
|
80
58
|
return keccak256(encodeAbiParameters(abi, [_relayData, destinationChainId]));
|
|
81
59
|
}
|
|
@@ -95,8 +73,8 @@ export function isUnsafeDepositId(depositId: BigNumber): boolean {
|
|
|
95
73
|
}
|
|
96
74
|
|
|
97
75
|
// Determines if the input address (either a bytes32 or bytes20) is the zero address.
|
|
98
|
-
export function isZeroAddress(address:
|
|
99
|
-
return address ===
|
|
76
|
+
export function isZeroAddress(address: Address): boolean {
|
|
77
|
+
return address.toBytes32() === ZERO_BYTES;
|
|
100
78
|
}
|
|
101
79
|
|
|
102
80
|
export function getMessageHash(message: string): string {
|
package/src/utils/TokenUtils.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { BlockTag } from "@ethersproject/abstract-provider";
|
|
2
2
|
import { Contract, providers, Signer } from "ethers";
|
|
3
3
|
import * as constants from "../constants";
|
|
4
|
-
import {
|
|
4
|
+
import { L1TokenInfo, TokenInfo } from "../interfaces";
|
|
5
5
|
import { ERC20__factory } from "../typechain";
|
|
6
6
|
import { BigNumber } from "./BigNumberUtils";
|
|
7
|
-
import { getNetworkName, chainIsL1, chainIsProd
|
|
7
|
+
import { getNetworkName, chainIsL1, chainIsProd } from "./NetworkUtils";
|
|
8
8
|
import { isDefined } from "./TypeGuards";
|
|
9
9
|
import { compareAddressesSimple, toAddressType } from "./AddressUtils";
|
|
10
10
|
const { TOKEN_SYMBOLS_MAP, CHAIN_IDs, TOKEN_EQUIVALENCE_REMAPPING } = constants;
|
|
11
11
|
|
|
12
12
|
type SignerOrProvider = providers.Provider | Signer;
|
|
13
13
|
|
|
14
|
-
export async function fetchTokenInfo(address: string, signerOrProvider: SignerOrProvider): Promise<
|
|
14
|
+
export async function fetchTokenInfo(address: string, signerOrProvider: SignerOrProvider): Promise<TokenInfo> {
|
|
15
15
|
const token = new Contract(address, ERC20__factory.abi, signerOrProvider);
|
|
16
16
|
const [symbol, decimals] = await Promise.all([token.symbol(), token.decimals()]);
|
|
17
|
-
return { address, symbol, decimals };
|
|
17
|
+
return { address: toAddressType(address, CHAIN_IDs.MAINNET), symbol, decimals };
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export const getL2TokenAddresses = (
|
|
@@ -33,7 +33,7 @@ export const getL2TokenAddresses = (
|
|
|
33
33
|
* @param chainId Chain ID to query on.
|
|
34
34
|
* @returns Symbol, decimals and contract address on the requested chain.
|
|
35
35
|
*/
|
|
36
|
-
export function resolveSymbolOnChain(chainId: number, symbol: string):
|
|
36
|
+
export function resolveSymbolOnChain(chainId: number, symbol: string): TokenInfo {
|
|
37
37
|
// @dev Suppress tsc complaints by casting symbol to the expected type.
|
|
38
38
|
const token = TOKEN_SYMBOLS_MAP[symbol as keyof typeof TOKEN_SYMBOLS_MAP];
|
|
39
39
|
if (!isDefined(token) || !isDefined(token.addresses[chainId])) {
|
|
@@ -44,7 +44,7 @@ export function resolveSymbolOnChain(chainId: number, symbol: string): L1Token {
|
|
|
44
44
|
const { decimals, addresses } = token;
|
|
45
45
|
const address = addresses[chainId];
|
|
46
46
|
|
|
47
|
-
return { symbol, decimals, address };
|
|
47
|
+
return { symbol, decimals, address: toAddressType(address, chainId) };
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/**
|
|
@@ -111,10 +111,9 @@ export function isStablecoin(tokenSymbol: string): boolean {
|
|
|
111
111
|
* @param tokenMapping
|
|
112
112
|
* @returns
|
|
113
113
|
*/
|
|
114
|
-
export function getTokenInfo(l2TokenAddress: string, chainId: number, tokenMapping = TOKEN_SYMBOLS_MAP):
|
|
115
|
-
const parsedAddress =
|
|
116
|
-
|
|
117
|
-
: toAddressType(l2TokenAddress).toEvmAddress();
|
|
114
|
+
export function getTokenInfo(l2TokenAddress: string, chainId: number, tokenMapping = TOKEN_SYMBOLS_MAP): L1TokenInfo {
|
|
115
|
+
const parsedAddress = toAddressType(l2TokenAddress, chainId).toNative();
|
|
116
|
+
|
|
118
117
|
// @dev This might give false positives if tokens on different networks have the same address. I'm not sure how
|
|
119
118
|
// to get around this...
|
|
120
119
|
let tokenObject = Object.values(tokenMapping).find(({ addresses }) => addresses[chainId] === parsedAddress);
|
|
@@ -128,7 +127,7 @@ export function getTokenInfo(l2TokenAddress: string, chainId: number, tokenMappi
|
|
|
128
127
|
tokenObject = tokenMapping[l1TokenSymbol as keyof typeof tokenMapping];
|
|
129
128
|
}
|
|
130
129
|
return {
|
|
131
|
-
address: l2TokenAddress,
|
|
130
|
+
address: toAddressType(l2TokenAddress, chainId),
|
|
132
131
|
symbol: tokenObject.symbol,
|
|
133
132
|
decimals: tokenObject.decimals,
|
|
134
133
|
};
|