@across-protocol/sdk 4.2.12 → 4.2.14-alpha.0
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 +5 -2
- package/dist/cjs/arch/evm/SpokeUtils.js +22 -5
- package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/SpokeUtils.js +14 -11
- package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/utils.d.ts +1 -1
- package/dist/cjs/arch/svm/utils.js +19 -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 -59
- 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 +53 -61
- 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 +39 -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 +7 -7
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +4 -4
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +14 -15
- 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 +6 -3
- package/dist/cjs/utils/AddressUtils.js +42 -14
- package/dist/cjs/utils/AddressUtils.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 +3 -3
- package/dist/cjs/utils/TokenUtils.js.map +1 -1
- package/dist/esm/arch/evm/SpokeUtils.d.ts +5 -2
- package/dist/esm/arch/evm/SpokeUtils.js +23 -6
- package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/SpokeUtils.js +15 -12
- package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/utils.d.ts +1 -1
- package/dist/esm/arch/svm/utils.js +19 -14
- 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 +4 -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 +96 -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 +55 -65
- 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 +41 -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 +8 -8
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.d.ts +4 -4
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +15 -16
- 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 +7 -3
- package/dist/esm/utils/AddressUtils.js +52 -19
- package/dist/esm/utils/AddressUtils.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 +18 -16
- package/dist/esm/utils/TokenUtils.js +3 -3
- package/dist/esm/utils/TokenUtils.js.map +1 -1
- package/dist/types/arch/evm/SpokeUtils.d.ts +5 -2
- package/dist/types/arch/evm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/utils.d.ts +1 -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 +4 -4
- 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 +7 -3
- 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 +18 -16
- package/dist/types/utils/TokenUtils.d.ts.map +1 -1
- package/package.json +2 -3
- package/src/arch/evm/SpokeUtils.ts +53 -11
- package/src/arch/svm/SpokeUtils.ts +44 -11
- package/src/arch/svm/utils.ts +9 -4
- package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +7 -4
- package/src/clients/BundleDataClient/BundleDataClient.ts +54 -52
- package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +28 -13
- package/src/clients/BundleDataClient/utils/FillUtils.ts +6 -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 +122 -82
- package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +6 -0
- package/src/clients/SpokePoolClient/SpokePoolClient.ts +110 -56
- package/src/clients/mocks/MockHubPoolClient.ts +24 -19
- package/src/clients/mocks/MockSpokePoolClient.ts +37 -26
- 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 +10 -8
- package/src/relayFeeCalculator/chain-queries/svmQuery.ts +16 -21
- package/src/relayFeeCalculator/relayFeeCalculator.ts +20 -12
- package/src/utils/AddressUtils.ts +56 -21
- package/src/utils/SpokeUtils.ts +11 -33
- package/src/utils/TokenUtils.ts +7 -7
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { SortableEvent } from "./Common";
|
|
2
2
|
import { SpokePoolClient } from "../clients";
|
|
3
|
-
import { BigNumber } from "../utils";
|
|
3
|
+
import { BigNumber, Address, EvmAddress } from "../utils";
|
|
4
4
|
import { RelayerRefundLeaf } from "./HubPool";
|
|
5
5
|
|
|
6
6
|
export interface RelayData {
|
|
7
7
|
originChainId: number;
|
|
8
|
-
depositor:
|
|
9
|
-
recipient:
|
|
8
|
+
depositor: Address;
|
|
9
|
+
recipient: Address;
|
|
10
10
|
depositId: BigNumber;
|
|
11
|
-
inputToken:
|
|
11
|
+
inputToken: Address;
|
|
12
12
|
inputAmount: BigNumber;
|
|
13
|
-
outputToken:
|
|
13
|
+
outputToken: Address;
|
|
14
14
|
outputAmount: BigNumber;
|
|
15
15
|
message: string;
|
|
16
16
|
fillDeadline: number;
|
|
17
|
-
exclusiveRelayer:
|
|
17
|
+
exclusiveRelayer: Address;
|
|
18
18
|
exclusivityDeadline: number;
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -23,7 +23,7 @@ export interface Deposit extends RelayData {
|
|
|
23
23
|
destinationChainId: number;
|
|
24
24
|
quoteTimestamp: number;
|
|
25
25
|
speedUpSignature?: string;
|
|
26
|
-
updatedRecipient?:
|
|
26
|
+
updatedRecipient?: Address;
|
|
27
27
|
updatedOutputAmount?: BigNumber;
|
|
28
28
|
updatedMessage?: string;
|
|
29
29
|
fromLiteChain: boolean;
|
|
@@ -51,7 +51,7 @@ export enum FillType {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export interface RelayExecutionEventInfo {
|
|
54
|
-
updatedRecipient:
|
|
54
|
+
updatedRecipient: Address;
|
|
55
55
|
updatedOutputAmount: BigNumber;
|
|
56
56
|
updatedMessage?: string;
|
|
57
57
|
updatedMessageHash: string;
|
|
@@ -61,7 +61,7 @@ export interface RelayExecutionEventInfo {
|
|
|
61
61
|
export interface Fill extends Omit<RelayData, "message"> {
|
|
62
62
|
messageHash: string;
|
|
63
63
|
destinationChainId: number;
|
|
64
|
-
relayer:
|
|
64
|
+
relayer: Address;
|
|
65
65
|
repaymentChainId: number;
|
|
66
66
|
relayExecutionInfo: RelayExecutionEventInfo;
|
|
67
67
|
}
|
|
@@ -72,18 +72,18 @@ export interface FillWithTime extends Fill, SortableEvent {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
export interface EnabledDepositRoute {
|
|
75
|
-
originToken:
|
|
75
|
+
originToken: Address;
|
|
76
76
|
destinationChainId: number;
|
|
77
77
|
enabled: boolean;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
export interface EnabledDepositRouteWithBlock extends EnabledDepositRoute, SortableEvent {}
|
|
81
81
|
export interface SpeedUp {
|
|
82
|
-
depositor:
|
|
82
|
+
depositor: EvmAddress;
|
|
83
83
|
depositorSignature: string;
|
|
84
84
|
depositId: BigNumber;
|
|
85
85
|
originChainId: number;
|
|
86
|
-
updatedRecipient:
|
|
86
|
+
updatedRecipient: Address;
|
|
87
87
|
updatedOutputAmount: BigNumber;
|
|
88
88
|
updatedMessage: string;
|
|
89
89
|
}
|
|
@@ -130,7 +130,7 @@ export interface TokensBridged extends SortableEvent {
|
|
|
130
130
|
amountToReturn: BigNumber;
|
|
131
131
|
chainId: number;
|
|
132
132
|
leafId: number;
|
|
133
|
-
l2TokenAddress:
|
|
133
|
+
l2TokenAddress: Address;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
export interface SpokePoolClientsByChain {
|
|
@@ -15,6 +15,8 @@ import {
|
|
|
15
15
|
bnZero,
|
|
16
16
|
chainIsOPStack,
|
|
17
17
|
fixedPointAdjustment,
|
|
18
|
+
toAddressType,
|
|
19
|
+
Address,
|
|
18
20
|
} from "../../utils";
|
|
19
21
|
import assert from "assert";
|
|
20
22
|
import { Logger, QueryInterface, getDefaultSimulatedRelayerAddress } from "../relayFeeCalculator";
|
|
@@ -72,7 +74,7 @@ export class QueryBase implements QueryInterface {
|
|
|
72
74
|
*/
|
|
73
75
|
async getGasCosts(
|
|
74
76
|
deposit: Omit<Deposit, "messageHash">,
|
|
75
|
-
relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
|
|
77
|
+
relayer = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId), deposit.destinationChainId),
|
|
76
78
|
options: Partial<{
|
|
77
79
|
gasPrice: BigNumberish;
|
|
78
80
|
gasUnits: BigNumberish;
|
|
@@ -122,7 +124,7 @@ export class QueryBase implements QueryInterface {
|
|
|
122
124
|
*/
|
|
123
125
|
getUnsignedTxFromDeposit(
|
|
124
126
|
deposit: Omit<Deposit, "messageHash">,
|
|
125
|
-
relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId)
|
|
127
|
+
relayer = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId), deposit.destinationChainId)
|
|
126
128
|
): Promise<PopulatedTransaction> {
|
|
127
129
|
return populateV3Relay(this.spokePool, deposit, relayer);
|
|
128
130
|
}
|
|
@@ -135,10 +137,10 @@ export class QueryBase implements QueryInterface {
|
|
|
135
137
|
*/
|
|
136
138
|
async getNativeGasCost(
|
|
137
139
|
deposit: Omit<Deposit, "messageHash">,
|
|
138
|
-
relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId)
|
|
140
|
+
relayer = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId), deposit.destinationChainId)
|
|
139
141
|
): Promise<BigNumber> {
|
|
140
142
|
const unsignedTx = await this.getUnsignedTxFromDeposit(deposit, relayer);
|
|
141
|
-
const voidSigner = new VoidSigner(relayer, this.provider);
|
|
143
|
+
const voidSigner = new VoidSigner(relayer.toEvmAddress(), this.provider);
|
|
142
144
|
return voidSigner.estimateGas(unsignedTx);
|
|
143
145
|
}
|
|
144
146
|
|
|
@@ -152,7 +154,7 @@ export class QueryBase implements QueryInterface {
|
|
|
152
154
|
*/
|
|
153
155
|
async getOpStackL1DataFee(
|
|
154
156
|
unsignedTx: PopulatedTransaction,
|
|
155
|
-
relayer = getDefaultSimulatedRelayerAddress(unsignedTx.chainId),
|
|
157
|
+
relayer = toAddressType(getDefaultSimulatedRelayerAddress(unsignedTx.chainId), unsignedTx.chainId),
|
|
156
158
|
options: Partial<{
|
|
157
159
|
opStackL2GasUnits: BigNumberish;
|
|
158
160
|
opStackL1DataFeeMultiplier: BigNumber;
|
|
@@ -161,7 +163,7 @@ export class QueryBase implements QueryInterface {
|
|
|
161
163
|
const { opStackL2GasUnits, opStackL1DataFeeMultiplier = toBNWei("1") } = options || {};
|
|
162
164
|
const { chainId } = await this.provider.getNetwork();
|
|
163
165
|
assert(isOptimismL2Provider(this.provider), `Unexpected provider for chain ID ${chainId}.`);
|
|
164
|
-
const voidSigner = new VoidSigner(relayer, this.provider);
|
|
166
|
+
const voidSigner = new VoidSigner(relayer.toEvmAddress(), this.provider);
|
|
165
167
|
const populatedTransaction = await voidSigner.populateTransaction({
|
|
166
168
|
...unsignedTx,
|
|
167
169
|
gasLimit: opStackL2GasUnits, // prevents additional gas estimation call
|
|
@@ -183,7 +185,7 @@ export class QueryBase implements QueryInterface {
|
|
|
183
185
|
*/
|
|
184
186
|
async estimateGas(
|
|
185
187
|
unsignedTx: PopulatedTransaction,
|
|
186
|
-
senderAddress:
|
|
188
|
+
senderAddress: Address,
|
|
187
189
|
provider: providers.Provider | L2Provider<providers.Provider>,
|
|
188
190
|
options: Partial<{
|
|
189
191
|
gasPrice: BigNumberish;
|
|
@@ -204,7 +206,7 @@ export class QueryBase implements QueryInterface {
|
|
|
204
206
|
} = options || {};
|
|
205
207
|
|
|
206
208
|
const { chainId } = await provider.getNetwork();
|
|
207
|
-
const voidSigner = new VoidSigner(senderAddress, provider);
|
|
209
|
+
const voidSigner = new VoidSigner(senderAddress.toEvmAddress(), provider);
|
|
208
210
|
|
|
209
211
|
// Estimate the Gas units required to submit this transaction.
|
|
210
212
|
const queries = [
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
getRelayDataHash,
|
|
26
26
|
toAddressType,
|
|
27
27
|
toBN,
|
|
28
|
+
Address,
|
|
28
29
|
} from "../../utils";
|
|
29
30
|
import { Logger, QueryInterface, getDefaultSimulatedRelayerAddress } from "../relayFeeCalculator";
|
|
30
31
|
import { SymbolMappingType } from "./";
|
|
@@ -74,7 +75,7 @@ export class SvmQuery implements QueryInterface {
|
|
|
74
75
|
*/
|
|
75
76
|
async getGasCosts(
|
|
76
77
|
deposit: Omit<Deposit, "messageHash">,
|
|
77
|
-
_relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
|
|
78
|
+
_relayer = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId), deposit.destinationChainId),
|
|
78
79
|
options: Partial<{
|
|
79
80
|
gasPrice: BigNumberish;
|
|
80
81
|
gasUnits: BigNumberish;
|
|
@@ -82,8 +83,8 @@ export class SvmQuery implements QueryInterface {
|
|
|
82
83
|
priorityFeeMultiplier: BigNumber;
|
|
83
84
|
}> = {}
|
|
84
85
|
): Promise<TransactionCostEstimate> {
|
|
85
|
-
const relayer = _relayer ?
|
|
86
|
-
const fillRelayTx = await this.getFillRelayTx(deposit, relayer
|
|
86
|
+
const relayer = _relayer ? _relayer.forceSvmAddress() : this.simulatedRelayerAddress;
|
|
87
|
+
const fillRelayTx = await this.getFillRelayTx(deposit, relayer);
|
|
87
88
|
|
|
88
89
|
const [computeUnitsConsumed, _gasPriceEstimate] = await Promise.all([
|
|
89
90
|
toBN(await this.computeUnitEstimator(fillRelayTx)),
|
|
@@ -116,7 +117,7 @@ export class SvmQuery implements QueryInterface {
|
|
|
116
117
|
*/
|
|
117
118
|
async getNativeGasCost(
|
|
118
119
|
deposit: Omit<Deposit, "messageHash">,
|
|
119
|
-
_relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId)
|
|
120
|
+
_relayer = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId), deposit.destinationChainId)
|
|
120
121
|
): Promise<BigNumber> {
|
|
121
122
|
const fillRelayTx = await this.getFillRelayTx(deposit, _relayer);
|
|
122
123
|
return toBN(await this.computeUnitEstimator(fillRelayTx));
|
|
@@ -130,35 +131,29 @@ export class SvmQuery implements QueryInterface {
|
|
|
130
131
|
*/
|
|
131
132
|
async getFillRelayTx(
|
|
132
133
|
deposit: Omit<Deposit, "messageHash">,
|
|
133
|
-
|
|
134
|
+
relayer = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId), deposit.destinationChainId),
|
|
134
135
|
repaymentChainId = deposit.destinationChainId,
|
|
135
|
-
repaymentAddress =
|
|
136
|
+
repaymentAddress = toAddressType(
|
|
137
|
+
getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
|
|
138
|
+
deposit.destinationChainId
|
|
139
|
+
)
|
|
136
140
|
) {
|
|
137
|
-
const toSvmAddress = (address:
|
|
138
|
-
const relayer = _relayer ? toAddressType(_relayer).forceSvmAddress() : this.simulatedRelayerAddress;
|
|
141
|
+
const toSvmAddress = (address: Address) => address.toV2Address();
|
|
139
142
|
const state = await getStatePda(this.spokePoolAddress.toV2Address());
|
|
140
143
|
const _relayDataHash = getRelayDataHash(deposit, deposit.destinationChainId);
|
|
141
144
|
const relayDataHash = new Uint8Array(Buffer.from(_relayDataHash.slice(2), "hex"));
|
|
142
145
|
const delegate = await getFillRelayDelegatePda(
|
|
143
146
|
relayDataHash,
|
|
144
147
|
BigInt(repaymentChainId),
|
|
145
|
-
|
|
148
|
+
repaymentAddress.toV2Address(),
|
|
146
149
|
this.spokePoolAddress.toV2Address()
|
|
147
150
|
);
|
|
148
|
-
const mint =
|
|
151
|
+
const mint = deposit.outputToken;
|
|
149
152
|
const mintInfo = await fetchMint(this.provider, mint.toV2Address());
|
|
150
|
-
const recipientAta = await getAssociatedTokenAddress(
|
|
151
|
-
|
|
152
|
-
mint,
|
|
153
|
-
mintInfo.programAddress
|
|
154
|
-
);
|
|
155
|
-
const relayerAta = await getAssociatedTokenAddress(
|
|
156
|
-
SvmAddress.from(relayer.toBase58()),
|
|
157
|
-
mint,
|
|
158
|
-
mintInfo.programAddress
|
|
159
|
-
);
|
|
153
|
+
const recipientAta = await getAssociatedTokenAddress(deposit.recipient, mint, mintInfo.programAddress);
|
|
154
|
+
const relayerAta = await getAssociatedTokenAddress(relayer, mint, mintInfo.programAddress);
|
|
160
155
|
const fillStatus = await getFillStatusPda(this.spokePoolAddress.toV2Address(), deposit, deposit.destinationChainId);
|
|
161
|
-
const eventAuthority = await getEventAuthority();
|
|
156
|
+
const eventAuthority = await getEventAuthority(this.spokePoolAddress.toV2Address());
|
|
162
157
|
|
|
163
158
|
const relayData: SvmSpokeClient.FillRelayInput["relayData"] = {
|
|
164
159
|
depositor: toSvmAddress(deposit.depositor),
|
|
@@ -9,12 +9,9 @@ import { Deposit } from "../interfaces";
|
|
|
9
9
|
import {
|
|
10
10
|
BigNumber,
|
|
11
11
|
BigNumberish,
|
|
12
|
-
ConvertDecimals,
|
|
13
12
|
MAX_BIG_INT,
|
|
14
13
|
TransactionCostEstimate,
|
|
15
14
|
bnZero,
|
|
16
|
-
chainIsSvm,
|
|
17
|
-
compareAddressesSimple,
|
|
18
15
|
fixedPointAdjustment,
|
|
19
16
|
getTokenInfo,
|
|
20
17
|
isDefined,
|
|
@@ -25,13 +22,18 @@ import {
|
|
|
25
22
|
percent,
|
|
26
23
|
toBN,
|
|
27
24
|
toBNWei,
|
|
25
|
+
compareAddressesSimple,
|
|
26
|
+
ConvertDecimals,
|
|
27
|
+
chainIsSvm,
|
|
28
|
+
toAddressType,
|
|
29
|
+
Address,
|
|
28
30
|
} from "../utils";
|
|
29
31
|
|
|
30
32
|
// This needs to be implemented for every chain and passed into RelayFeeCalculator
|
|
31
33
|
export interface QueryInterface {
|
|
32
34
|
getGasCosts: (
|
|
33
35
|
deposit: Omit<Deposit, "messageHash">,
|
|
34
|
-
relayer:
|
|
36
|
+
relayer: Address,
|
|
35
37
|
options?: Partial<{
|
|
36
38
|
gasPrice: BigNumberish;
|
|
37
39
|
gasUnits: BigNumberish;
|
|
@@ -42,7 +44,7 @@ export interface QueryInterface {
|
|
|
42
44
|
}>
|
|
43
45
|
) => Promise<TransactionCostEstimate>;
|
|
44
46
|
getTokenPrice: (tokenSymbol: string) => Promise<number>;
|
|
45
|
-
getNativeGasCost: (deposit: Omit<Deposit, "messageHash">, relayer:
|
|
47
|
+
getNativeGasCost: (deposit: Omit<Deposit, "messageHash">, relayer: Address) => Promise<BigNumber>;
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
export const expectedCapitalCostsKeys = ["lowerBound", "upperBound", "cutoff", "decimals"];
|
|
@@ -254,7 +256,10 @@ export class RelayFeeCalculator {
|
|
|
254
256
|
deposit: Deposit,
|
|
255
257
|
outputAmount: BigNumberish,
|
|
256
258
|
simulateZeroFill = false,
|
|
257
|
-
relayerAddress =
|
|
259
|
+
relayerAddress = toAddressType(
|
|
260
|
+
getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
|
|
261
|
+
deposit.destinationChainId
|
|
262
|
+
),
|
|
258
263
|
_tokenPrice?: number,
|
|
259
264
|
tokenMapping = TOKEN_SYMBOLS_MAP,
|
|
260
265
|
gasPrice?: BigNumberish,
|
|
@@ -271,14 +276,14 @@ export class RelayFeeCalculator {
|
|
|
271
276
|
// undefined address on destination.
|
|
272
277
|
const destinationChainTokenDetails = Object.values(tokenMapping).find(
|
|
273
278
|
(details) =>
|
|
274
|
-
compareAddressesSimple(details.addresses[originChainId], inputToken) &&
|
|
279
|
+
compareAddressesSimple(details.addresses[originChainId], inputToken.toAddress()) &&
|
|
275
280
|
isDefined(details.addresses[destinationChainId])
|
|
276
281
|
);
|
|
277
282
|
const outputToken = isZeroAddress(deposit.outputToken)
|
|
278
283
|
? destinationChainTokenDetails!.addresses[destinationChainId]
|
|
279
|
-
: deposit.outputToken;
|
|
284
|
+
: deposit.outputToken.toAddress();
|
|
280
285
|
const outputTokenInfo = getTokenInfo(outputToken, destinationChainId, tokenMapping);
|
|
281
|
-
const inputTokenInfo = getTokenInfo(inputToken, originChainId, tokenMapping);
|
|
286
|
+
const inputTokenInfo = getTokenInfo(inputToken.toAddress(), originChainId, tokenMapping);
|
|
282
287
|
if (!isDefined(outputTokenInfo) || !isDefined(inputTokenInfo)) {
|
|
283
288
|
throw new Error(`Could not find token information for ${inputToken} or ${outputToken}`);
|
|
284
289
|
}
|
|
@@ -493,7 +498,10 @@ export class RelayFeeCalculator {
|
|
|
493
498
|
deposit: Deposit,
|
|
494
499
|
outputAmount?: BigNumberish,
|
|
495
500
|
simulateZeroFill = false,
|
|
496
|
-
relayerAddress =
|
|
501
|
+
relayerAddress = toAddressType(
|
|
502
|
+
getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
|
|
503
|
+
deposit.destinationChainId
|
|
504
|
+
),
|
|
497
505
|
_tokenPrice?: number,
|
|
498
506
|
gasPrice?: BigNumberish,
|
|
499
507
|
gasUnits?: BigNumberish,
|
|
@@ -505,8 +513,8 @@ export class RelayFeeCalculator {
|
|
|
505
513
|
const { inputToken, originChainId, outputToken, destinationChainId } = deposit;
|
|
506
514
|
// We can perform a simple lookup with `getTokenInfo` here without resolving the exact token to resolve since we only need to
|
|
507
515
|
// resolve the L1 token symbol and not the L2 token decimals.
|
|
508
|
-
const inputTokenInfo = getTokenInfo(inputToken, originChainId);
|
|
509
|
-
const outputTokenInfo = getTokenInfo(outputToken, destinationChainId);
|
|
516
|
+
const inputTokenInfo = getTokenInfo(inputToken.toAddress(), originChainId);
|
|
517
|
+
const outputTokenInfo = getTokenInfo(outputToken.toAddress(), destinationChainId);
|
|
510
518
|
if (!isDefined(inputTokenInfo) || !isDefined(outputTokenInfo)) {
|
|
511
519
|
throw new Error(`Could not find token information for ${inputToken} or ${outputToken}`);
|
|
512
520
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { providers, utils } from "ethers";
|
|
2
|
+
import assert from "assert";
|
|
2
3
|
import bs58 from "bs58";
|
|
3
4
|
import { Address as V2Address } from "@solana/kit";
|
|
4
|
-
import { BigNumber, chainIsEvm } from "./";
|
|
5
|
+
import { BigNumber, chainIsEvm, isDefined } from "./";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Checks if a contract is deployed at the given address
|
|
@@ -75,20 +76,39 @@ export function isValidEvmAddress(address: string): boolean {
|
|
|
75
76
|
* Creates the proper address type given the input chain ID corresponding to the address's origin network.
|
|
76
77
|
* @param address Stringified address type to convert. Can be either hex encoded or base58 encoded.
|
|
77
78
|
* @param chainId Network ID corresponding to the input address, used to determine which address type to output.
|
|
79
|
+
* If no chain ID is specified, then fallback to inference via the structure of the address string.
|
|
78
80
|
* @returns a child `Address` type most fitting for the chain ID.
|
|
79
81
|
* @todo: Change this to `toAddress` once we remove the other `toAddress` function.
|
|
80
82
|
*/
|
|
81
|
-
export function toAddressType(address: string): Address | EvmAddress | SvmAddress {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
export function toAddressType(address: string, chainId?: number): Address | EvmAddress | SvmAddress {
|
|
84
|
+
const parseAddress = (address: string) => {
|
|
85
|
+
try {
|
|
86
|
+
if (utils.isHexString(address)) {
|
|
87
|
+
return EvmAddress.from(address);
|
|
88
|
+
}
|
|
89
|
+
return SvmAddress.from(address);
|
|
90
|
+
} catch (e) {
|
|
91
|
+
// If we hit this block, then the validation for one of the child address classes failed. We still may want to keep this address in our state, so
|
|
92
|
+
// return an unchecked address type.
|
|
93
|
+
assert(utils.isHexString(address));
|
|
94
|
+
assert(utils.hexDataLength(address) === 32);
|
|
95
|
+
return Address.__unsafeConstruct(utils.arrayify(address));
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
// If there is no network ID, then infer the address by the string format.
|
|
99
|
+
const addressType = parseAddress(address);
|
|
100
|
+
if (!isDefined(chainId)) {
|
|
101
|
+
return addressType;
|
|
102
|
+
}
|
|
103
|
+
// Wrap this in a try/catch in case we are trying to force an invalid EVM address to an EvmAddress type.
|
|
104
|
+
if (chainIsEvm(chainId)) {
|
|
105
|
+
try {
|
|
106
|
+
return addressType.forceEvmAddress();
|
|
107
|
+
} catch {
|
|
108
|
+
return addressType;
|
|
85
109
|
}
|
|
86
|
-
return SvmAddress.from(address);
|
|
87
|
-
} catch (e) {
|
|
88
|
-
// If we hit this block, then the validation for one of the child address classes failed. We still may want to keep this address in our state, so
|
|
89
|
-
// return an unchecked address type.
|
|
90
|
-
return new Address(utils.arrayify(address));
|
|
91
110
|
}
|
|
111
|
+
return addressType.forceSvmAddress();
|
|
92
112
|
}
|
|
93
113
|
|
|
94
114
|
// The Address class can contain any address type. It is up to the subclasses to determine how to format the address's internal representation,
|
|
@@ -113,12 +133,24 @@ export class Address {
|
|
|
113
133
|
this.rawAddress = utils.zeroPad(_rawAddress, 32);
|
|
114
134
|
}
|
|
115
135
|
|
|
136
|
+
static __unsafeConstruct(_rawAddress: Uint8Array): Address {
|
|
137
|
+
return new this(_rawAddress);
|
|
138
|
+
}
|
|
139
|
+
|
|
116
140
|
// Converts the address into a bytes32 string. Note that the output bytes will be lowercase so that it matches ethers event data. This function will never
|
|
117
141
|
// throw since address length validation was done at construction time.
|
|
118
142
|
toBytes32(): string {
|
|
119
143
|
return (this.bytes32Address ??= utils.hexZeroPad(utils.hexlify(this.rawAddress), 32).toLowerCase());
|
|
120
144
|
}
|
|
121
145
|
|
|
146
|
+
// Returns last 20 bytes of Address as a hex string. Truncates if necessary. This function is useful for comparing some longer addresses(e.g. Solana) to Solidity events
|
|
147
|
+
// that contain truncated `address` type as one of the fields
|
|
148
|
+
truncateToBytes20(): string {
|
|
149
|
+
// Take the last 20 bytes
|
|
150
|
+
const bytes20 = this.rawAddress.slice(-20);
|
|
151
|
+
return toAddress(utils.hexlify(bytes20));
|
|
152
|
+
}
|
|
153
|
+
|
|
122
154
|
// Converts the address (can be bytes32 or bytes20) to its base58 counterpart. This conversion will always succeed, even if the input address is not valid on Solana,
|
|
123
155
|
// as this address may be needed to represent an EVM address on Solana.
|
|
124
156
|
toBase58(): string {
|
|
@@ -160,7 +192,7 @@ export class Address {
|
|
|
160
192
|
// Checks if this address can be coerced into a bytes20 evm address. Returns true if it is possible and false otherwise.
|
|
161
193
|
isValidEvmAddress(): boolean {
|
|
162
194
|
try {
|
|
163
|
-
this.
|
|
195
|
+
this.toEvmAddress();
|
|
164
196
|
return true;
|
|
165
197
|
} catch {
|
|
166
198
|
return false;
|
|
@@ -191,6 +223,11 @@ export class Address {
|
|
|
191
223
|
return utils.stripZeros(this.rawAddress).length === 0;
|
|
192
224
|
}
|
|
193
225
|
|
|
226
|
+
// Small utility to convert an Address to a Solana Kit branded type.
|
|
227
|
+
toV2Address(): V2Address<string> {
|
|
228
|
+
return this.toBase58() as V2Address<string>;
|
|
229
|
+
}
|
|
230
|
+
|
|
194
231
|
// Forces `rawAddress` to become an SvmAddress type. This will only throw if `rawAddress.length > 32`.
|
|
195
232
|
forceSvmAddress(): SvmAddress {
|
|
196
233
|
return SvmAddress.from(this.toBase58());
|
|
@@ -220,6 +257,14 @@ export class Address {
|
|
|
220
257
|
return 0;
|
|
221
258
|
}
|
|
222
259
|
}
|
|
260
|
+
|
|
261
|
+
static isEvmAddress(address: Address): boolean {
|
|
262
|
+
return address instanceof EvmAddress;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
static isSvmAddress(address: Address): boolean {
|
|
266
|
+
return address instanceof SvmAddress;
|
|
267
|
+
}
|
|
223
268
|
}
|
|
224
269
|
|
|
225
270
|
// Subclass of address which strictly deals with 20-byte addresses. These addresses are guaranteed to be valid EVM addresses, so `toAddress` will always succeed.
|
|
@@ -269,16 +314,6 @@ export class SvmAddress extends Address {
|
|
|
269
314
|
return this.toBase58();
|
|
270
315
|
}
|
|
271
316
|
|
|
272
|
-
// Small utility to convert an SvmAddress to a Solana Kit branded type.
|
|
273
|
-
toV2Address(): V2Address<string> {
|
|
274
|
-
return this.toBase58() as V2Address<string>;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
// Forces an SvmAddress to an EVM address string by truncating the leading 12 bytes.
|
|
278
|
-
override toEvmAddress(): string {
|
|
279
|
-
return toAddress(`0x${this.toBytes32().slice(-40)}`);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
317
|
// Constructs a new SvmAddress type.
|
|
283
318
|
static from(address: string, encoding: "base58" | "base16" = "base58"): SvmAddress {
|
|
284
319
|
if (encoding === "base58") {
|
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,7 +1,7 @@
|
|
|
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 { TokenInfo } from "../interfaces";
|
|
5
5
|
import { ERC20__factory } from "../typechain";
|
|
6
6
|
import { BigNumber } from "./BigNumberUtils";
|
|
7
7
|
import { getNetworkName, chainIsL1, chainIsProd, chainIsSvm } from "./NetworkUtils";
|
|
@@ -11,10 +11,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).forceEvmAddress(), 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,7 +111,7 @@ 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):
|
|
114
|
+
export function getTokenInfo(l2TokenAddress: string, chainId: number, tokenMapping = TOKEN_SYMBOLS_MAP): TokenInfo {
|
|
115
115
|
const parsedAddress = chainIsSvm(chainId)
|
|
116
116
|
? toAddressType(l2TokenAddress).toBase58()
|
|
117
117
|
: toAddressType(l2TokenAddress).toEvmAddress();
|
|
@@ -128,7 +128,7 @@ export function getTokenInfo(l2TokenAddress: string, chainId: number, tokenMappi
|
|
|
128
128
|
tokenObject = tokenMapping[l1TokenSymbol as keyof typeof tokenMapping];
|
|
129
129
|
}
|
|
130
130
|
return {
|
|
131
|
-
address: l2TokenAddress,
|
|
131
|
+
address: toAddressType(l2TokenAddress, chainId),
|
|
132
132
|
symbol: tokenObject.symbol,
|
|
133
133
|
decimals: tokenObject.decimals,
|
|
134
134
|
};
|