Skip to content

Commit c2fc6ed

Browse files
committed
update abis
1 parent 6261b5c commit c2fc6ed

File tree

14 files changed

+159
-197
lines changed

14 files changed

+159
-197
lines changed

evm/ts/src/axelar.ts

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -58,37 +58,55 @@ export async function getAxelarGasFee(
5858
);
5959
}
6060

61-
const controller = new AbortController();
62-
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
63-
64-
try {
65-
const response = await fetch(baseUrl, {
66-
method: "POST",
67-
headers: {
68-
"Content-Type": "application/json",
69-
},
70-
body: JSON.stringify({
71-
sourceChain: axelarSourceChain,
72-
destinationChain: axelarDestinationChain,
73-
gasMultiplier: "auto",
74-
gasLimit: gasLimit.toString(),
75-
}),
76-
signal: controller.signal,
77-
});
78-
79-
if (!response.ok) {
80-
const errorText = await response.text();
81-
throw new Error(
82-
`Failed to estimate gas fee: ${response.status} ${errorText}`
83-
);
61+
const maxRetries = 3;
62+
let lastResult: bigint | null = null;
63+
64+
// TODO: the Axelar API sometimes returns 0 gas fee. Retry a few times if we get 0.
65+
// The issue is intermittent and the Axelar team is looking into it.
66+
for (let attempt = 0; attempt < maxRetries; attempt++) {
67+
const controller = new AbortController();
68+
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
69+
70+
try {
71+
const response = await fetch(baseUrl, {
72+
method: "POST",
73+
headers: {
74+
"Content-Type": "application/json",
75+
},
76+
body: JSON.stringify({
77+
sourceChain: axelarSourceChain,
78+
destinationChain: axelarDestinationChain,
79+
gasMultiplier: "auto",
80+
gasLimit: gasLimit.toString(),
81+
}),
82+
signal: controller.signal,
83+
});
84+
85+
if (!response.ok) {
86+
const errorText = await response.text();
87+
throw new Error(
88+
`Failed to estimate gas fee: ${response.status} ${errorText}`
89+
);
90+
}
91+
92+
const result = await response.json();
93+
lastResult = BigInt(result);
94+
95+
if (lastResult !== 0n) {
96+
return lastResult;
97+
}
98+
99+
// If we got 0 and have more retries, wait 1 second before trying again
100+
if (attempt < maxRetries - 1) {
101+
await new Promise((resolve) => setTimeout(resolve, 1000));
102+
}
103+
} finally {
104+
clearTimeout(timeoutId);
84105
}
85-
86-
const result = await response.json();
87-
88-
return BigInt(result);
89-
} finally {
90-
clearTimeout(timeoutId);
91106
}
107+
108+
// If all retries returned 0, just return 0
109+
return lastResult ?? 0n;
92110
}
93111

94112
export async function getAxelarTransactionStatus(

evm/ts/src/ethers-contracts/multiTokenNtt/1_1_0/GmpManager.sol/GmpManager.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export interface GmpManagerInterface extends Interface {
7676
| "attestationReceived"
7777
| "chainId"
7878
| "executeMsg"
79+
| "getKnownChains"
7980
| "getMigratesImmutables"
8081
| "getPeer"
8182
| "getReceiveTransceiversForChain"
@@ -97,6 +98,7 @@ export interface GmpManagerInterface extends Interface {
9798
| "pause"
9899
| "pauser"
99100
| "quoteDeliveryPrice"
101+
| "registerKnownChain"
100102
| "removeReceiveTransceiverForChain"
101103
| "removeSendTransceiverForChain"
102104
| "removeTransceiver"
@@ -158,6 +160,10 @@ export interface GmpManagerInterface extends Interface {
158160
TransceiverStructs.NttManagerMessageStruct
159161
]
160162
): string;
163+
encodeFunctionData(
164+
functionFragment: "getKnownChains",
165+
values?: undefined
166+
): string;
161167
encodeFunctionData(
162168
functionFragment: "getMigratesImmutables",
163169
values?: undefined
@@ -227,6 +233,10 @@ export interface GmpManagerInterface extends Interface {
227233
functionFragment: "quoteDeliveryPrice",
228234
values: [BigNumberish, BytesLike]
229235
): string;
236+
encodeFunctionData(
237+
functionFragment: "registerKnownChain",
238+
values: [BigNumberish, BytesLike]
239+
): string;
230240
encodeFunctionData(
231241
functionFragment: "removeReceiveTransceiverForChain",
232242
values: [BigNumberish, AddressLike]
@@ -302,6 +312,10 @@ export interface GmpManagerInterface extends Interface {
302312
): Result;
303313
decodeFunctionResult(functionFragment: "chainId", data: BytesLike): Result;
304314
decodeFunctionResult(functionFragment: "executeMsg", data: BytesLike): Result;
315+
decodeFunctionResult(
316+
functionFragment: "getKnownChains",
317+
data: BytesLike
318+
): Result;
305319
decodeFunctionResult(
306320
functionFragment: "getMigratesImmutables",
307321
data: BytesLike
@@ -365,6 +379,10 @@ export interface GmpManagerInterface extends Interface {
365379
functionFragment: "quoteDeliveryPrice",
366380
data: BytesLike
367381
): Result;
382+
decodeFunctionResult(
383+
functionFragment: "registerKnownChain",
384+
data: BytesLike
385+
): Result;
368386
decodeFunctionResult(
369387
functionFragment: "removeReceiveTransceiverForChain",
370388
data: BytesLike
@@ -808,6 +826,8 @@ export interface GmpManager extends BaseContract {
808826
"nonpayable"
809827
>;
810828

829+
getKnownChains: TypedContractMethod<[], [bigint[]], "view">;
830+
811831
getMigratesImmutables: TypedContractMethod<[], [boolean], "view">;
812832

813833
getPeer: TypedContractMethod<
@@ -898,6 +918,12 @@ export interface GmpManager extends BaseContract {
898918
"view"
899919
>;
900920

921+
registerKnownChain: TypedContractMethod<
922+
[peerChainId: BigNumberish, peerAddress: BytesLike],
923+
[void],
924+
"nonpayable"
925+
>;
926+
901927
removeReceiveTransceiverForChain: TypedContractMethod<
902928
[sourceChain: BigNumberish, transceiver: AddressLike],
903929
[void],
@@ -1019,6 +1045,9 @@ export interface GmpManager extends BaseContract {
10191045
[void],
10201046
"nonpayable"
10211047
>;
1048+
getFunction(
1049+
nameOrSignature: "getKnownChains"
1050+
): TypedContractMethod<[], [bigint[]], "view">;
10221051
getFunction(
10231052
nameOrSignature: "getMigratesImmutables"
10241053
): TypedContractMethod<[], [boolean], "view">;
@@ -1114,6 +1143,13 @@ export interface GmpManager extends BaseContract {
11141143
[[bigint[], bigint]],
11151144
"view"
11161145
>;
1146+
getFunction(
1147+
nameOrSignature: "registerKnownChain"
1148+
): TypedContractMethod<
1149+
[peerChainId: BigNumberish, peerAddress: BytesLike],
1150+
[void],
1151+
"nonpayable"
1152+
>;
11171153
getFunction(
11181154
nameOrSignature: "removeReceiveTransceiverForChain"
11191155
): TypedContractMethod<

evm/ts/src/ethers-contracts/multiTokenNtt/1_1_0/MultiTokenNtt.sol/MultiTokenNtt.ts

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -99,34 +99,6 @@ export declare namespace Peers {
9999
};
100100
}
101101

102-
export declare namespace ISignatureTransfer {
103-
export type TokenPermissionsStruct = {
104-
token: AddressLike;
105-
amount: BigNumberish;
106-
};
107-
108-
export type TokenPermissionsStructOutput = [token: string, amount: bigint] & {
109-
token: string;
110-
amount: bigint;
111-
};
112-
113-
export type PermitTransferFromStruct = {
114-
permitted: ISignatureTransfer.TokenPermissionsStruct;
115-
nonce: BigNumberish;
116-
deadline: BigNumberish;
117-
};
118-
119-
export type PermitTransferFromStructOutput = [
120-
permitted: ISignatureTransfer.TokenPermissionsStructOutput,
121-
nonce: bigint,
122-
deadline: bigint
123-
] & {
124-
permitted: ISignatureTransfer.TokenPermissionsStructOutput;
125-
nonce: bigint;
126-
deadline: bigint;
127-
};
128-
}
129-
130102
export declare namespace MultiTokenNtt {
131103
export type TransferArgsStruct = {
132104
token: AddressLike;
@@ -136,9 +108,6 @@ export declare namespace MultiTokenNtt {
136108
refundAddress: BytesLike;
137109
shouldQueue: boolean;
138110
transceiverInstructions: BytesLike;
139-
permit: ISignatureTransfer.PermitTransferFromStruct;
140-
permitOwner: AddressLike;
141-
permitSignature: BytesLike;
142111
additionalPayload: BytesLike;
143112
};
144113

@@ -150,9 +119,6 @@ export declare namespace MultiTokenNtt {
150119
refundAddress: string,
151120
shouldQueue: boolean,
152121
transceiverInstructions: string,
153-
permit: ISignatureTransfer.PermitTransferFromStructOutput,
154-
permitOwner: string,
155-
permitSignature: string,
156122
additionalPayload: string
157123
] & {
158124
token: string;
@@ -162,9 +128,6 @@ export declare namespace MultiTokenNtt {
162128
refundAddress: string;
163129
shouldQueue: boolean;
164130
transceiverInstructions: string;
165-
permit: ISignatureTransfer.PermitTransferFromStructOutput;
166-
permitOwner: string;
167-
permitSignature: string;
168131
additionalPayload: string;
169132
};
170133

@@ -201,7 +164,6 @@ export interface MultiTokenNttInterface extends Interface {
201164
getFunction(
202165
nameOrSignature:
203166
| "NTT_MANAGER_VERSION"
204-
| "PERMIT2"
205167
| "WETH"
206168
| "cancelOutboundQueuedTransfer"
207169
| "completeInboundQueuedTransfer"
@@ -264,7 +226,6 @@ export interface MultiTokenNttInterface extends Interface {
264226
functionFragment: "NTT_MANAGER_VERSION",
265227
values?: undefined
266228
): string;
267-
encodeFunctionData(functionFragment: "PERMIT2", values?: undefined): string;
268229
encodeFunctionData(functionFragment: "WETH", values?: undefined): string;
269230
encodeFunctionData(
270231
functionFragment: "cancelOutboundQueuedTransfer",
@@ -389,7 +350,6 @@ export interface MultiTokenNttInterface extends Interface {
389350
functionFragment: "NTT_MANAGER_VERSION",
390351
data: BytesLike
391352
): Result;
392-
decodeFunctionResult(functionFragment: "PERMIT2", data: BytesLike): Result;
393353
decodeFunctionResult(functionFragment: "WETH", data: BytesLike): Result;
394354
decodeFunctionResult(
395355
functionFragment: "cancelOutboundQueuedTransfer",
@@ -808,8 +768,6 @@ export interface MultiTokenNtt extends BaseContract {
808768

809769
NTT_MANAGER_VERSION: TypedContractMethod<[], [string], "view">;
810770

811-
PERMIT2: TypedContractMethod<[], [string], "view">;
812-
813771
WETH: TypedContractMethod<[], [string], "view">;
814772

815773
cancelOutboundQueuedTransfer: TypedContractMethod<
@@ -971,9 +929,6 @@ export interface MultiTokenNtt extends BaseContract {
971929
getFunction(
972930
nameOrSignature: "NTT_MANAGER_VERSION"
973931
): TypedContractMethod<[], [string], "view">;
974-
getFunction(
975-
nameOrSignature: "PERMIT2"
976-
): TypedContractMethod<[], [string], "view">;
977932
getFunction(
978933
nameOrSignature: "WETH"
979934
): TypedContractMethod<[], [string], "view">;

evm/ts/src/ethers-contracts/multiTokenNtt/1_1_0/factories/GmpManager.sol/GmpManager__factory.ts

Lines changed: 32 additions & 1 deletion
Large diffs are not rendered by default.

evm/ts/src/ethers-contracts/multiTokenNtt/1_1_0/factories/MultiTokenNtt.sol/MultiTokenNtt__factory.ts

Lines changed: 1 addition & 72 deletions
Large diffs are not rendered by default.

evm/ts/src/multiTokenNtt.ts

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
Chain,
33
Network,
4+
encoding,
45
nativeChainIds,
56
toChain,
67
toChainId,
@@ -44,7 +45,6 @@ import {
4445
MultiTokenNttManagerBindings,
4546
} from "./multiTokenNttBindings.js";
4647
import { getAxelarGasFee } from "./axelar.js";
47-
import { encoding } from "@wormhole-foundation/sdk-base";
4848

4949
export class EvmMultiTokenNtt<N extends Network, C extends EvmChains>
5050
implements MultiTokenNtt<N, C>
@@ -252,26 +252,20 @@ export class EvmMultiTokenNtt<N extends Network, C extends EvmChains>
252252
case "wormhole":
253253
return {
254254
index: transceiver.index,
255-
payload: new Uint8Array([1]), // skipRelay = true
255+
payload: new Uint8Array([1]), // disable standard relayer
256256
};
257257
case "axelar": {
258-
let gasFee = 0n;
259-
try {
260-
gasFee = await getAxelarGasFee(
261-
this.network,
262-
this.chain,
263-
dstChain,
264-
gasLimit
265-
);
266-
console.log(`Fetched axelar gas fee: ${gasFee} wei`);
267-
} catch (e) {
268-
// If we fail to fetch the gas fee, then use 0 as a fallback.
269-
// The Axelar relay should fail and the track() method will
270-
// surface a RelayFailedError. We don't want to fail the entire
271-
// transfer just because we couldn't fetch the gas fee quote.
272-
gasFee = 100000000000000n; // 0.0001 ETH
273-
console.error(`Failed to fetch axelar gas fee: ${e}`);
274-
}
258+
// If we fail to fetch the gas fee, then use 0 as a fallback.
259+
// The Axelar relay should fail and the track() method will
260+
// surface a RelayFailedError. We don't want to fail the entire
261+
// transfer just because we couldn't fetch the gas fee quote.
262+
const gasFee = await getAxelarGasFee(
263+
this.network,
264+
this.chain,
265+
dstChain,
266+
gasLimit
267+
).catch(() => 0n);
268+
console.log("gas fee", gasFee);
275269
return {
276270
index: transceiver.index,
277271
payload: encoding.bignum.toBytes(gasFee, 32),
@@ -374,16 +368,6 @@ export class EvmMultiTokenNtt<N extends Network, C extends EvmChains>
374368
transceiverInstructions: Ntt.encodeTransceiverInstructions(
375369
transceiverInstructions
376370
),
377-
permit: {
378-
permitted: {
379-
token: token.toString(),
380-
amount: 0n,
381-
},
382-
nonce: 0n,
383-
deadline: 0n,
384-
},
385-
permitOwner: ethers.ZeroAddress,
386-
permitSignature: "0x",
387371
additionalPayload: "0x",
388372
};
389373

evm/ts/src/multiTokenNttWithExecutor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ const multiTokenNttWithExecutorAddresses: Partial<
3030
Record<Network, Partial<Record<EvmChains, string>>>
3131
> = {
3232
Testnet: {
33-
Sepolia: "0x63a193Fd7BE29632a6b32a2285807CEB2d9AC1B7",
34-
Monad: "0x38415a872F5A38187C8007c02DbD4Ce1782725d5",
33+
Sepolia: "0x70b1CD25Aa1DEbEf2BCa0eDbc11228C5EB4dAD0F",
34+
Monad: "0xFEA937F7124E19124671f1685671d3f04a9Af4E4",
3535
},
3636
};
3737

sdk/examples/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const recoverTxids: TransactionId[] = [
6262
console.log("Source txs", txids);
6363

6464
const vaa = await wh.getVaa(
65-
txids[txids.length - 1]!.txid,
65+
txids[txids.length - 1]!,
6666
"Ntt:WormholeTransfer",
6767
25 * 60 * 1000
6868
);

0 commit comments

Comments
 (0)