@veridex/sdk 1.1.6 → 1.1.7
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/{EVMClient-CTOtNY8I.d.mts → EVMClient-DqDiFak8.d.mts} +1 -1
- package/dist/auth/prepareAuth.d.mts +5 -4
- package/dist/auth/prepareAuth.js +57 -1415
- package/dist/auth/prepareAuth.js.map +1 -1
- package/dist/auth/prepareAuth.mjs +17 -96
- package/dist/auth/prepareAuth.mjs.map +1 -1
- package/dist/chains/aptos/index.d.mts +1 -1
- package/dist/chains/aptos/index.js +11 -33
- package/dist/chains/aptos/index.js.map +1 -1
- package/dist/chains/aptos/index.mjs +2 -2
- package/dist/chains/avalanche/index.d.mts +2 -2
- package/dist/chains/avalanche/index.js +19 -115
- package/dist/chains/avalanche/index.js.map +1 -1
- package/dist/chains/avalanche/index.mjs +3 -3
- package/dist/chains/evm/index.d.mts +3 -3
- package/dist/chains/evm/index.js +19 -115
- package/dist/chains/evm/index.js.map +1 -1
- package/dist/chains/evm/index.mjs +2 -2
- package/dist/chains/solana/index.d.mts +1 -1
- package/dist/chains/solana/index.js +11 -33
- package/dist/chains/solana/index.js.map +1 -1
- package/dist/chains/solana/index.mjs +2 -2
- package/dist/chains/stacks/index.d.mts +1 -1
- package/dist/chains/stacks/index.js +11 -38
- package/dist/chains/stacks/index.js.map +1 -1
- package/dist/chains/stacks/index.mjs +2 -2
- package/dist/chains/starknet/index.d.mts +36 -2
- package/dist/chains/starknet/index.js +208 -37
- package/dist/chains/starknet/index.js.map +1 -1
- package/dist/chains/starknet/index.mjs +9 -4
- package/dist/chains/sui/index.d.mts +1 -1
- package/dist/chains/sui/index.js +11 -27
- package/dist/chains/sui/index.js.map +1 -1
- package/dist/chains/sui/index.mjs +2 -2
- package/dist/{chunk-ZNIVNPGF.mjs → chunk-3PCAVZUZ.mjs} +173 -37
- package/dist/chunk-3PCAVZUZ.mjs.map +1 -0
- package/dist/{chunk-DQOW3G7M.mjs → chunk-6BINP4RT.mjs} +48 -9
- package/dist/{chunk-DQOW3G7M.mjs.map → chunk-6BINP4RT.mjs.map} +1 -1
- package/dist/{chunk-7KN6Y4GX.mjs → chunk-AK5HWYX4.mjs} +12 -40
- package/dist/chunk-AK5HWYX4.mjs.map +1 -0
- package/dist/{chunk-QVTADARB.mjs → chunk-FPSCAGYS.mjs} +12 -35
- package/dist/chunk-FPSCAGYS.mjs.map +1 -0
- package/dist/{chunk-USVZH4QC.mjs → chunk-H3WRT6Y4.mjs} +20 -117
- package/dist/chunk-H3WRT6Y4.mjs.map +1 -0
- package/dist/{chunk-GXJUY2SC.mjs → chunk-MNH22BM2.mjs} +12 -35
- package/dist/chunk-MNH22BM2.mjs.map +1 -0
- package/dist/chunk-N42LPFPJ.mjs +177 -0
- package/dist/chunk-N42LPFPJ.mjs.map +1 -0
- package/dist/{chunk-D57UJ4L5.mjs → chunk-NKSRF45N.mjs} +12 -29
- package/dist/chunk-NKSRF45N.mjs.map +1 -0
- package/dist/{chunk-2CALEUER.mjs → chunk-SKZLZFE2.mjs} +5 -58
- package/dist/chunk-SKZLZFE2.mjs.map +1 -0
- package/dist/{chunk-NVRAQPSF.mjs → chunk-UF5NWMSQ.mjs} +20 -4
- package/dist/chunk-UF5NWMSQ.mjs.map +1 -0
- package/dist/chunk-WC4X3MAO.mjs +58 -0
- package/dist/chunk-WC4X3MAO.mjs.map +1 -0
- package/dist/{chunk-5FH67KLG.mjs → chunk-XHDOSV2F.mjs} +2 -2
- package/dist/{index-9ercn1sa.d.mts → index-D1nb2JV9.d.mts} +1 -1
- package/dist/index-qyOqd8tx.d.mts +517 -0
- package/dist/index.d.mts +27 -364
- package/dist/index.js +2316 -2473
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +978 -51
- package/dist/index.mjs.map +1 -1
- package/dist/passkey.mjs +2 -1
- package/dist/payload.d.mts +22 -28
- package/dist/payload.js +50 -9
- package/dist/payload.js.map +1 -1
- package/dist/payload.mjs +7 -3
- package/dist/platform/index.d.mts +3 -0
- package/dist/platform/index.js +216 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/platform/index.mjs +21 -0
- package/dist/platform/index.mjs.map +1 -0
- package/dist/{portfolio-W2FQ2G3O.mjs → portfolio-MLP2JIFK.mjs} +2 -3
- package/dist/queries/index.mjs +324 -10
- package/dist/queries/index.mjs.map +1 -1
- package/dist/{types-DQ5dtU9x.d.mts → types-CdlEbixV.d.mts} +11 -1
- package/package.json +7 -1
- package/dist/chunk-2CALEUER.mjs.map +0 -1
- package/dist/chunk-72ZA3OYQ.mjs +0 -20
- package/dist/chunk-72ZA3OYQ.mjs.map +0 -1
- package/dist/chunk-7KN6Y4GX.mjs.map +0 -1
- package/dist/chunk-D57UJ4L5.mjs.map +0 -1
- package/dist/chunk-GXJUY2SC.mjs.map +0 -1
- package/dist/chunk-NVRAQPSF.mjs.map +0 -1
- package/dist/chunk-QVTADARB.mjs.map +0 -1
- package/dist/chunk-USVZH4QC.mjs.map +0 -1
- package/dist/chunk-XDIIFIW6.mjs +0 -330
- package/dist/chunk-XDIIFIW6.mjs.map +0 -1
- package/dist/chunk-ZNIVNPGF.mjs.map +0 -1
- package/dist/chunk-ZXMTPBSP.mjs +0 -857
- package/dist/chunk-ZXMTPBSP.mjs.map +0 -1
- /package/dist/{chunk-5FH67KLG.mjs.map → chunk-XHDOSV2F.mjs.map} +0 -0
- /package/dist/{portfolio-W2FQ2G3O.mjs.map → portfolio-MLP2JIFK.mjs.map} +0 -0
package/dist/auth/prepareAuth.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/auth/prepareAuth.ts
|
|
@@ -33,7 +23,6 @@ __export(prepareAuth_exports, {
|
|
|
33
23
|
authenticateAndPrepare: () => authenticateAndPrepare
|
|
34
24
|
});
|
|
35
25
|
module.exports = __toCommonJS(prepareAuth_exports);
|
|
36
|
-
var import_ethers5 = require("ethers");
|
|
37
26
|
|
|
38
27
|
// src/core/PasskeyManager.ts
|
|
39
28
|
var import_browser = require("@simplewebauthn/browser");
|
|
@@ -46,255 +35,6 @@ var import_ethers = require("ethers");
|
|
|
46
35
|
var ACTION_TRANSFER = 1;
|
|
47
36
|
var ACTION_EXECUTE = 2;
|
|
48
37
|
var ACTION_BRIDGE = 4;
|
|
49
|
-
var TESTNET_CHAINS = {
|
|
50
|
-
baseSepolia: {
|
|
51
|
-
name: "Base Sepolia",
|
|
52
|
-
chainId: 84532,
|
|
53
|
-
wormholeChainId: 10004,
|
|
54
|
-
rpcUrl: "https://sepolia.base.org",
|
|
55
|
-
explorerUrl: "https://sepolia.basescan.org",
|
|
56
|
-
isEvm: true,
|
|
57
|
-
contracts: {
|
|
58
|
-
hub: "0xD5D29b6EaeE6FF4b765e704298a7e48D22607059",
|
|
59
|
-
vaultFactory: "0xb25b73D5FeD5693dcd1Bb78f8e33387B59A022EC",
|
|
60
|
-
vaultImplementation: "0x2CB8397df988c1880d9e5cFfF65bfC22D7D90EE6",
|
|
61
|
-
wormholeCoreBridge: "0x79A1027a6A159502049F10906D333EC57E95F083",
|
|
62
|
-
tokenBridge: "0x86F55A04690fd7815A3D802bD587e83eA888B239"
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
ethereumSepolia: {
|
|
66
|
-
name: "Ethereum Sepolia",
|
|
67
|
-
chainId: 11155111,
|
|
68
|
-
wormholeChainId: 10002,
|
|
69
|
-
rpcUrl: "https://ethereum-sepolia-rpc.publicnode.com",
|
|
70
|
-
explorerUrl: "https://sepolia.etherscan.io",
|
|
71
|
-
isEvm: true,
|
|
72
|
-
contracts: {
|
|
73
|
-
vaultFactory: "0x265c10763B4d16AD970bC3d7670c645e37f63AF4",
|
|
74
|
-
vaultImplementation: "0x942426C94652ebC48f4f404928016B95ADb1DA25",
|
|
75
|
-
wormholeCoreBridge: "0x4a8bc80Ed5a4067f1CCf107057b8270E0cC11A78",
|
|
76
|
-
tokenBridge: "0xDB5492265f6038831E89f495670FF909aDe94bd9"
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
optimismSepolia: {
|
|
80
|
-
name: "Optimism Sepolia",
|
|
81
|
-
chainId: 11155420,
|
|
82
|
-
wormholeChainId: 10005,
|
|
83
|
-
rpcUrl: "https://sepolia.optimism.io",
|
|
84
|
-
explorerUrl: "https://sepolia-optimism.etherscan.io",
|
|
85
|
-
isEvm: true,
|
|
86
|
-
contracts: {
|
|
87
|
-
vaultFactory: "0x3c5e4aCdC8Cd53ae5ae603B4c511885191fBb868",
|
|
88
|
-
vaultImplementation: "0xA45dBF322c5A3028687fEEB161603d3BCe02e119",
|
|
89
|
-
wormholeCoreBridge: "0x31377888146f3253211EFEf5c676D41ECe7D58Fe",
|
|
90
|
-
tokenBridge: "0x99737Ec4B815d816c49A385943baf0380e75c0Ac"
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
arbitrumSepolia: {
|
|
94
|
-
name: "Arbitrum Sepolia",
|
|
95
|
-
chainId: 421614,
|
|
96
|
-
wormholeChainId: 10003,
|
|
97
|
-
rpcUrl: "https://sepolia-rollup.arbitrum.io/rpc",
|
|
98
|
-
explorerUrl: "https://sepolia.arbiscan.io",
|
|
99
|
-
isEvm: true,
|
|
100
|
-
contracts: {
|
|
101
|
-
vaultFactory: "0xB9C3e6bad3c6f26956be4a4bb5a366376Fd3045D",
|
|
102
|
-
vaultImplementation: "0x8601881b94B68B09b485f407317686103d3CB681",
|
|
103
|
-
wormholeCoreBridge: "0x6b9C8671cdDC8dEab9c719bB87cBd3e782bA6a35",
|
|
104
|
-
tokenBridge: "0xC7A204bDBFe983FCD8d8E61D02b475D4073fF97e"
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
monadTestnet: {
|
|
108
|
-
name: "Monad Testnet",
|
|
109
|
-
chainId: 10143,
|
|
110
|
-
wormholeChainId: 10048,
|
|
111
|
-
rpcUrl: "https://testnet-rpc.monad.xyz",
|
|
112
|
-
explorerUrl: "https://testnet.monadexplorer.com",
|
|
113
|
-
isEvm: true,
|
|
114
|
-
contracts: {
|
|
115
|
-
vaultFactory: "0xbE9B9c39956448DA75Ac97E5e3dE17e34171660A",
|
|
116
|
-
vaultImplementation: "0x500853DCc54Fd1A707ec9d443032Bb7748f426d3",
|
|
117
|
-
wormholeCoreBridge: "0xBB73cB66C26740F31d1FabDC6b7A46a038A300dd",
|
|
118
|
-
tokenBridge: "0x0000000000000000000000000000000000000000"
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
avalancheFuji: {
|
|
122
|
-
name: "Avalanche Fuji",
|
|
123
|
-
chainId: 43113,
|
|
124
|
-
wormholeChainId: 6,
|
|
125
|
-
rpcUrl: "https://api.avax-test.network/ext/bc/C/rpc",
|
|
126
|
-
explorerUrl: "https://testnet.snowtrace.io",
|
|
127
|
-
isEvm: true,
|
|
128
|
-
contracts: {
|
|
129
|
-
vaultFactory: "0x9e9716442e908A9b61F11432cC38024DD390cd2a",
|
|
130
|
-
vaultImplementation: "0xE0b9919ffDf3415355Db369C8FfA5Dd4e000052c",
|
|
131
|
-
wormholeCoreBridge: "0x7bbcE28e64B3F8b84d876Ab298393c38ad7aac4C",
|
|
132
|
-
tokenBridge: "0x61E44E506Ca5659E6c0bba9b678586fA2d729756"
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
polygonAmoy: {
|
|
136
|
-
name: "Polygon Amoy",
|
|
137
|
-
chainId: 80002,
|
|
138
|
-
wormholeChainId: 10007,
|
|
139
|
-
rpcUrl: "https://rpc-amoy.polygon.technology",
|
|
140
|
-
explorerUrl: "https://amoy.polygonscan.com",
|
|
141
|
-
isEvm: true,
|
|
142
|
-
contracts: {
|
|
143
|
-
vaultFactory: "0x07F608AFf6d63b68029488b726d895c4Bb593038",
|
|
144
|
-
vaultImplementation: "0xD66153fccFB6731fB6c4944FbD607ba86A76a1f6",
|
|
145
|
-
wormholeCoreBridge: "0x6b9C8671cdDC8dEab9c719bB87cBd3e782bA6a35",
|
|
146
|
-
tokenBridge: "0xC7A204bDBFe983FCD8d8E61D02b475D4073fF97e"
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
solanaDevnet: {
|
|
150
|
-
name: "Solana Devnet",
|
|
151
|
-
chainId: 0,
|
|
152
|
-
wormholeChainId: 1,
|
|
153
|
-
rpcUrl: "https://api.devnet.solana.com",
|
|
154
|
-
explorerUrl: "https://explorer.solana.com",
|
|
155
|
-
isEvm: false,
|
|
156
|
-
contracts: {
|
|
157
|
-
hub: "64ZZBdmGd1YT6Fok7PELvAdfoXyR4PHxHnRqHNqZHJ13",
|
|
158
|
-
wormholeCoreBridge: "3u8hJUVTA4jH1wYAyUur7FFZVQ8H635K3tSHHF4ssjQ5",
|
|
159
|
-
tokenBridge: "DZnkkTmCiFWfYTfT41X3Rd1kDgozqzxWaHqsw6W4x2oe"
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
aptosTestnet: {
|
|
163
|
-
name: "Aptos Testnet",
|
|
164
|
-
chainId: 0,
|
|
165
|
-
wormholeChainId: 22,
|
|
166
|
-
rpcUrl: "https://fullnode.testnet.aptoslabs.com/v1",
|
|
167
|
-
explorerUrl: "https://explorer.aptoslabs.com",
|
|
168
|
-
isEvm: false,
|
|
169
|
-
contracts: {
|
|
170
|
-
hub: "0x9e8641143245ab8b93af1417a1fbc698d40fd351a25f6c17e4210e59bf82c9c7",
|
|
171
|
-
wormholeCoreBridge: "0x5bc11445584a763c1fa7ed39081f1b920954da14e04b32440cba863d03e19625",
|
|
172
|
-
tokenBridge: "0x576410486a2da45eee6c949c995670112ddf2fbeedab20350d506328eefc9d4f"
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
suiTestnet: {
|
|
176
|
-
name: "Sui Testnet",
|
|
177
|
-
chainId: 0,
|
|
178
|
-
wormholeChainId: 21,
|
|
179
|
-
rpcUrl: "https://fullnode.testnet.sui.io:443",
|
|
180
|
-
explorerUrl: "https://suiscan.xyz/testnet",
|
|
181
|
-
isEvm: false,
|
|
182
|
-
contracts: {
|
|
183
|
-
hub: "0xaf36d8bc349883b23e78b00a342a656c799319508600583eaee9121ffaa7f5f7",
|
|
184
|
-
wormholeCoreBridge: "0x31358d198147da50db32eda2562951d53973a0c0ad5ed738e9b17d88b213d790"
|
|
185
|
-
}
|
|
186
|
-
},
|
|
187
|
-
starknetSepolia: {
|
|
188
|
-
name: "Starknet Sepolia",
|
|
189
|
-
chainId: 0,
|
|
190
|
-
wormholeChainId: 50001,
|
|
191
|
-
rpcUrl: "https://starknet-sepolia-rpc.publicnode.com",
|
|
192
|
-
explorerUrl: "https://sepolia.starkscan.co",
|
|
193
|
-
isEvm: false,
|
|
194
|
-
contracts: {
|
|
195
|
-
hub: "0x7bb7cbe7d82e910b296611b582035a207343431f98bdd7b692bddfdd6f28737",
|
|
196
|
-
wormholeCoreBridge: "0x30d2e7f26dc75819cfddcd7caa26a76b681d5918f219c99060c42ce1e3f69e4"
|
|
197
|
-
},
|
|
198
|
-
hubChainId: 10004
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
var MAINNET_CHAINS = {
|
|
202
|
-
ethereum: {
|
|
203
|
-
name: "Ethereum",
|
|
204
|
-
chainId: 1,
|
|
205
|
-
wormholeChainId: 2,
|
|
206
|
-
rpcUrl: "https://eth.llamarpc.com",
|
|
207
|
-
explorerUrl: "https://etherscan.io",
|
|
208
|
-
isEvm: true,
|
|
209
|
-
contracts: {
|
|
210
|
-
wormholeCoreBridge: "0x98f3c9e6E3fAce36bAAd05FE09d375Ef1464288B",
|
|
211
|
-
tokenBridge: "0x3ee18B2214AFF97000D974cf647E7C347E8fa585"
|
|
212
|
-
}
|
|
213
|
-
},
|
|
214
|
-
base: {
|
|
215
|
-
name: "Base",
|
|
216
|
-
chainId: 8453,
|
|
217
|
-
wormholeChainId: 30,
|
|
218
|
-
rpcUrl: "https://mainnet.base.org",
|
|
219
|
-
explorerUrl: "https://basescan.org",
|
|
220
|
-
isEvm: true,
|
|
221
|
-
contracts: {
|
|
222
|
-
wormholeCoreBridge: "0xbebdb6C8ddC678FfA9f8748f85C815C556Dd8ac6",
|
|
223
|
-
tokenBridge: "0x8d2de8d2f73F1F4cAB472AC9A881C9b123C79627"
|
|
224
|
-
}
|
|
225
|
-
},
|
|
226
|
-
optimism: {
|
|
227
|
-
name: "Optimism",
|
|
228
|
-
chainId: 10,
|
|
229
|
-
wormholeChainId: 24,
|
|
230
|
-
rpcUrl: "https://mainnet.optimism.io",
|
|
231
|
-
explorerUrl: "https://optimistic.etherscan.io",
|
|
232
|
-
isEvm: true,
|
|
233
|
-
contracts: {
|
|
234
|
-
wormholeCoreBridge: "0xEe91C335eab126dF5fDB3797EA9d6aD93aeC9722",
|
|
235
|
-
tokenBridge: "0x1D68124e65faFC907325e3EDbF8c4d84499DAa8b"
|
|
236
|
-
}
|
|
237
|
-
},
|
|
238
|
-
arbitrum: {
|
|
239
|
-
name: "Arbitrum",
|
|
240
|
-
chainId: 42161,
|
|
241
|
-
wormholeChainId: 23,
|
|
242
|
-
rpcUrl: "https://arb1.arbitrum.io/rpc",
|
|
243
|
-
explorerUrl: "https://arbiscan.io",
|
|
244
|
-
isEvm: true,
|
|
245
|
-
contracts: {
|
|
246
|
-
wormholeCoreBridge: "0xa5f208e072434bC67592E4C49C1B991BA79BCA46",
|
|
247
|
-
tokenBridge: "0x0b2402144Bb366A632D14B83F244D2e0e21bD39c"
|
|
248
|
-
}
|
|
249
|
-
},
|
|
250
|
-
polygon: {
|
|
251
|
-
name: "Polygon",
|
|
252
|
-
chainId: 137,
|
|
253
|
-
wormholeChainId: 5,
|
|
254
|
-
rpcUrl: "https://polygon-rpc.com",
|
|
255
|
-
explorerUrl: "https://polygonscan.com",
|
|
256
|
-
isEvm: true,
|
|
257
|
-
contracts: {
|
|
258
|
-
wormholeCoreBridge: "0x7A4B5a56256163F07b2C80A7cA55aBE66c4ec4d7",
|
|
259
|
-
tokenBridge: "0x5a58505a96D1dbf8dF91cB21B54419FC36e93fdE"
|
|
260
|
-
}
|
|
261
|
-
},
|
|
262
|
-
solana: {
|
|
263
|
-
name: "Solana",
|
|
264
|
-
chainId: 0,
|
|
265
|
-
wormholeChainId: 1,
|
|
266
|
-
rpcUrl: "https://api.mainnet-beta.solana.com",
|
|
267
|
-
explorerUrl: "https://explorer.solana.com",
|
|
268
|
-
isEvm: false,
|
|
269
|
-
contracts: {
|
|
270
|
-
wormholeCoreBridge: "worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth",
|
|
271
|
-
tokenBridge: "wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb"
|
|
272
|
-
}
|
|
273
|
-
},
|
|
274
|
-
aptos: {
|
|
275
|
-
name: "Aptos",
|
|
276
|
-
chainId: 0,
|
|
277
|
-
wormholeChainId: 22,
|
|
278
|
-
rpcUrl: "https://fullnode.mainnet.aptoslabs.com/v1",
|
|
279
|
-
explorerUrl: "https://explorer.aptoslabs.com",
|
|
280
|
-
isEvm: false,
|
|
281
|
-
contracts: {
|
|
282
|
-
wormholeCoreBridge: "0x5bc11445584a763c1fa7ed39081f1b920954da14e04b32440cba863d03e19625",
|
|
283
|
-
tokenBridge: "0x576410486a2da45eee6c949c995670112ddf2fbeedab20350d506328eefc9d4f"
|
|
284
|
-
}
|
|
285
|
-
},
|
|
286
|
-
sui: {
|
|
287
|
-
name: "Sui",
|
|
288
|
-
chainId: 0,
|
|
289
|
-
wormholeChainId: 21,
|
|
290
|
-
rpcUrl: "https://fullnode.mainnet.sui.io:443",
|
|
291
|
-
explorerUrl: "https://suiscan.xyz/mainnet",
|
|
292
|
-
isEvm: false,
|
|
293
|
-
contracts: {
|
|
294
|
-
wormholeCoreBridge: "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c"
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
};
|
|
298
38
|
|
|
299
39
|
// src/utils.ts
|
|
300
40
|
function base64URLEncode(buffer) {
|
|
@@ -1352,1105 +1092,55 @@ function padTo32Bytes(address) {
|
|
|
1352
1092
|
}
|
|
1353
1093
|
return "0x" + hex.padStart(64, "0");
|
|
1354
1094
|
}
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1095
|
+
var HUB_NONCE_DOMAIN = 0;
|
|
1096
|
+
var TIER_T2_AUTHORITATIVE = 3;
|
|
1097
|
+
var CHALLENGE_DOMAIN = import_ethers3.ethers.sha256(import_ethers3.ethers.toUtf8Bytes("veridex.challenge.v1"));
|
|
1098
|
+
function buildCanonicalChallenge(input) {
|
|
1099
|
+
if (!Number.isInteger(input.veridexChainId) || input.veridexChainId <= 0 || input.veridexChainId > 4294967295) {
|
|
1100
|
+
throw new Error("veridexChainId must be an integer between 1 and 4294967295");
|
|
1101
|
+
}
|
|
1102
|
+
if (!Number.isInteger(input.minTier) || input.minTier < 0 || input.minTier > TIER_T2_AUTHORITATIVE) {
|
|
1103
|
+
throw new Error("minTier must be an integer between 0 and 3");
|
|
1104
|
+
}
|
|
1105
|
+
if (input.nonce < 0n || input.nonce > 0xffffffffffffffffn) {
|
|
1106
|
+
throw new Error("nonce must fit in uint64");
|
|
1107
|
+
}
|
|
1108
|
+
const executor = import_ethers3.ethers.hexlify(import_ethers3.ethers.zeroPadValue(input.executor, 32));
|
|
1109
|
+
if (executor === import_ethers3.ethers.ZeroHash) {
|
|
1110
|
+
throw new Error("executor must not be zero");
|
|
1111
|
+
}
|
|
1112
|
+
const preimage = import_ethers3.ethers.solidityPacked(
|
|
1113
|
+
["bytes32", "uint8", "uint8", "uint32", "bytes32", "uint32", "uint64", "bytes32"],
|
|
1114
|
+
[
|
|
1115
|
+
CHALLENGE_DOMAIN,
|
|
1116
|
+
1,
|
|
1117
|
+
input.minTier,
|
|
1118
|
+
input.veridexChainId,
|
|
1119
|
+
executor,
|
|
1120
|
+
HUB_NONCE_DOMAIN,
|
|
1121
|
+
input.nonce,
|
|
1122
|
+
input.actionHash
|
|
1123
|
+
]
|
|
1359
1124
|
);
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
const packed = createGaslessMessageHash(targetChain, actionPayload, nonce, hubChainId);
|
|
1363
|
-
return import_ethers3.ethers.getBytes(packed);
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
// src/queries/hubState.ts
|
|
1367
|
-
var import_axios = __toESM(require("axios"));
|
|
1368
|
-
var import_buffer = require("buffer");
|
|
1369
|
-
var import_ethers4 = require("ethers");
|
|
1370
|
-
var import_wormhole_query_sdk = require("@wormhole-foundation/wormhole-query-sdk");
|
|
1371
|
-
|
|
1372
|
-
// src/queries/constants.ts
|
|
1373
|
-
var WORMHOLE_QUERY_PROXY_URLS = {
|
|
1374
|
-
mainnet: "https://query.wormhole.com/v1/query",
|
|
1375
|
-
testnet: "https://testnet.query.wormhole.com/v1/query"
|
|
1376
|
-
};
|
|
1377
|
-
|
|
1378
|
-
// src/queries/hubState.ts
|
|
1379
|
-
var QueryHubStateError = class extends Error {
|
|
1380
|
-
code;
|
|
1381
|
-
cause;
|
|
1382
|
-
constructor(code, message, cause) {
|
|
1383
|
-
super(message);
|
|
1384
|
-
this.name = "QueryHubStateError";
|
|
1385
|
-
this.code = code;
|
|
1386
|
-
this.cause = cause;
|
|
1387
|
-
}
|
|
1388
|
-
};
|
|
1389
|
-
function resolveNetwork(options) {
|
|
1390
|
-
if (options?.network) return options.network;
|
|
1391
|
-
const envCandidates = [
|
|
1392
|
-
globalThis?.process?.env?.NEXT_PUBLIC_VERIDEX_NETWORK,
|
|
1393
|
-
globalThis?.process?.env?.VERIDEX_NETWORK,
|
|
1394
|
-
globalThis?.process?.env?.NEXT_PUBLIC_WORMHOLE_NETWORK,
|
|
1395
|
-
globalThis?.process?.env?.WORMHOLE_NETWORK
|
|
1396
|
-
].filter(Boolean);
|
|
1397
|
-
const env = envCandidates[0]?.toLowerCase();
|
|
1398
|
-
if (env === "mainnet" || env === "testnet") return env;
|
|
1399
|
-
return "testnet";
|
|
1400
|
-
}
|
|
1401
|
-
function concatBytes(parts) {
|
|
1402
|
-
const total = parts.reduce((sum, p) => sum + p.length, 0);
|
|
1403
|
-
const out = new Uint8Array(total);
|
|
1404
|
-
let offset = 0;
|
|
1405
|
-
for (const p of parts) {
|
|
1406
|
-
out.set(p, offset);
|
|
1407
|
-
offset += p.length;
|
|
1408
|
-
}
|
|
1409
|
-
return out;
|
|
1410
|
-
}
|
|
1411
|
-
function signaturesToProofBytes(signatures) {
|
|
1412
|
-
const chunks = [];
|
|
1413
|
-
for (const sig of signatures) {
|
|
1414
|
-
if (typeof sig !== "string" || sig.length !== 132 || !/^[0-9a-fA-F]+$/.test(sig)) {
|
|
1415
|
-
throw new QueryHubStateError(
|
|
1416
|
-
"PROXY_RESPONSE_INVALID",
|
|
1417
|
-
`Invalid guardian signature format (expected 132 hex chars): ${String(sig)}`
|
|
1418
|
-
);
|
|
1419
|
-
}
|
|
1420
|
-
chunks.push((0, import_wormhole_query_sdk.hexToUint8Array)(`0x${sig}`));
|
|
1421
|
-
}
|
|
1422
|
-
return concatBytes(chunks);
|
|
1423
|
-
}
|
|
1424
|
-
function decodeQueryBytes(bytes) {
|
|
1425
|
-
if (typeof bytes !== "string" || bytes.length === 0) {
|
|
1426
|
-
throw new QueryHubStateError("PROXY_RESPONSE_INVALID", "Missing query response bytes");
|
|
1427
|
-
}
|
|
1428
|
-
if ((0, import_wormhole_query_sdk.isValidHexString)(bytes)) {
|
|
1429
|
-
return (0, import_wormhole_query_sdk.hexToUint8Array)(bytes);
|
|
1430
|
-
}
|
|
1431
|
-
try {
|
|
1432
|
-
if (typeof atob === "function") {
|
|
1433
|
-
const raw = atob(bytes);
|
|
1434
|
-
const arr = new Uint8Array(raw.length);
|
|
1435
|
-
for (let i = 0; i < raw.length; i++) arr[i] = raw.charCodeAt(i);
|
|
1436
|
-
return arr;
|
|
1437
|
-
}
|
|
1438
|
-
} catch {
|
|
1439
|
-
}
|
|
1440
|
-
try {
|
|
1441
|
-
return new Uint8Array(import_buffer.Buffer.from(bytes, "base64"));
|
|
1442
|
-
} catch (cause) {
|
|
1443
|
-
throw new QueryHubStateError("PROXY_RESPONSE_INVALID", "Unrecognized query response bytes encoding", cause);
|
|
1444
|
-
}
|
|
1445
|
-
}
|
|
1446
|
-
function sleep(ms) {
|
|
1447
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
1448
|
-
}
|
|
1449
|
-
async function withExponentialBackoff(fn, maxAttempts) {
|
|
1450
|
-
let attempt = 0;
|
|
1451
|
-
let lastError;
|
|
1452
|
-
while (attempt < maxAttempts) {
|
|
1453
|
-
try {
|
|
1454
|
-
return await fn();
|
|
1455
|
-
} catch (err) {
|
|
1456
|
-
lastError = err;
|
|
1457
|
-
attempt += 1;
|
|
1458
|
-
if (attempt >= maxAttempts) break;
|
|
1459
|
-
const baseMs = 250;
|
|
1460
|
-
const backoffMs = Math.min(5e3, baseMs * 2 ** (attempt - 1));
|
|
1461
|
-
const jitterMs = Math.floor(Math.random() * 100);
|
|
1462
|
-
await sleep(backoffMs + jitterMs);
|
|
1463
|
-
}
|
|
1464
|
-
}
|
|
1465
|
-
throw lastError;
|
|
1466
|
-
}
|
|
1467
|
-
function getHubConfig(network) {
|
|
1468
|
-
if (network === "testnet") {
|
|
1469
|
-
const baseSepolia = TESTNET_CHAINS.baseSepolia;
|
|
1470
|
-
if (!baseSepolia?.contracts?.hub) {
|
|
1471
|
-
throw new QueryHubStateError("MISSING_HUB_ADDRESS", "Missing Base Sepolia hub address in SDK constants");
|
|
1472
|
-
}
|
|
1473
|
-
return {
|
|
1474
|
-
wormholeChainId: baseSepolia.wormholeChainId,
|
|
1475
|
-
hubAddress: baseSepolia.contracts.hub,
|
|
1476
|
-
endpoint: WORMHOLE_QUERY_PROXY_URLS.testnet,
|
|
1477
|
-
rpcUrl: baseSepolia.rpcUrl
|
|
1478
|
-
};
|
|
1479
|
-
}
|
|
1480
|
-
if (network === "mainnet") {
|
|
1481
|
-
const base = MAINNET_CHAINS.base;
|
|
1482
|
-
const hubAddress = base?.contracts?.hub;
|
|
1483
|
-
if (!hubAddress) {
|
|
1484
|
-
throw new QueryHubStateError(
|
|
1485
|
-
"MISSING_HUB_ADDRESS",
|
|
1486
|
-
"Missing mainnet hub address in SDK constants (MAINNET_CHAINS.base.contracts.hub)"
|
|
1487
|
-
);
|
|
1488
|
-
}
|
|
1489
|
-
return {
|
|
1490
|
-
wormholeChainId: base.wormholeChainId,
|
|
1491
|
-
hubAddress,
|
|
1492
|
-
endpoint: WORMHOLE_QUERY_PROXY_URLS.mainnet,
|
|
1493
|
-
rpcUrl: base.rpcUrl
|
|
1494
|
-
};
|
|
1495
|
-
}
|
|
1496
|
-
throw new QueryHubStateError("UNSUPPORTED_NETWORK", `Unsupported network: ${network}`);
|
|
1497
|
-
}
|
|
1498
|
-
function encodeHubCalls(hubAddress, userKeyHash) {
|
|
1499
|
-
const nonceAbiCandidates = [
|
|
1500
|
-
"function getUserNonce(bytes32 userKeyHash) view returns (uint256)",
|
|
1501
|
-
"function userNonces(bytes32 userKeyHash) view returns (uint256)",
|
|
1502
|
-
"function getNonceByHash(bytes32 userKeyHash) view returns (uint256)"
|
|
1503
|
-
];
|
|
1504
|
-
const registeredAbiCandidates = [
|
|
1505
|
-
"function registeredKeys(bytes32 userKeyHash) view returns (bool)",
|
|
1506
|
-
"function isKeyRegisteredByHash(bytes32 userKeyHash) view returns (bool)"
|
|
1507
|
-
];
|
|
1508
|
-
const actionHashAbiCandidates = [
|
|
1509
|
-
"function getUserLastActionHash(bytes32 userKeyHash) view returns (bytes32)",
|
|
1510
|
-
"function userLastActionHash(bytes32 userKeyHash) view returns (bytes32)"
|
|
1511
|
-
];
|
|
1512
|
-
const iface = new import_ethers4.ethers.Interface([
|
|
1513
|
-
...nonceAbiCandidates,
|
|
1514
|
-
...registeredAbiCandidates,
|
|
1515
|
-
...actionHashAbiCandidates
|
|
1516
|
-
]);
|
|
1517
|
-
const nonceFnNames = ["getUserNonce", "userNonces", "getNonceByHash"];
|
|
1518
|
-
const regFnNames = ["registeredKeys", "isKeyRegisteredByHash"];
|
|
1519
|
-
const actionHashFnNames = ["getUserLastActionHash", "userLastActionHash"];
|
|
1520
|
-
return [
|
|
1521
|
-
...nonceFnNames.map((fn) => ({
|
|
1522
|
-
to: hubAddress,
|
|
1523
|
-
data: iface.encodeFunctionData(fn, [userKeyHash])
|
|
1524
|
-
})),
|
|
1525
|
-
...regFnNames.map((fn) => ({
|
|
1526
|
-
to: hubAddress,
|
|
1527
|
-
data: iface.encodeFunctionData(fn, [userKeyHash])
|
|
1528
|
-
})),
|
|
1529
|
-
...actionHashFnNames.map((fn) => ({
|
|
1530
|
-
to: hubAddress,
|
|
1531
|
-
data: iface.encodeFunctionData(fn, [userKeyHash])
|
|
1532
|
-
}))
|
|
1533
|
-
];
|
|
1534
|
-
}
|
|
1535
|
-
function decodeFirstNonce(results) {
|
|
1536
|
-
const candidates = [
|
|
1537
|
-
"function getUserNonce(bytes32 userKeyHash) view returns (uint256)",
|
|
1538
|
-
"function userNonces(bytes32 userKeyHash) view returns (uint256)",
|
|
1539
|
-
"function getNonceByHash(bytes32 userKeyHash) view returns (uint256)"
|
|
1540
|
-
];
|
|
1541
|
-
const iface = new import_ethers4.ethers.Interface(candidates);
|
|
1542
|
-
const fnNames = ["getUserNonce", "userNonces", "getNonceByHash"];
|
|
1543
|
-
for (let idx = 0; idx < fnNames.length; idx++) {
|
|
1544
|
-
const fnName = fnNames[idx];
|
|
1545
|
-
try {
|
|
1546
|
-
const data = results[idx];
|
|
1547
|
-
if (!data || data === "0x") continue;
|
|
1548
|
-
const decoded = iface.decodeFunctionResult(fnName, data);
|
|
1549
|
-
return decoded[0];
|
|
1550
|
-
} catch {
|
|
1551
|
-
}
|
|
1552
|
-
}
|
|
1553
|
-
throw new QueryHubStateError("QUERY_RESPONSE_INVALID", "Unable to decode user nonce from query response");
|
|
1554
|
-
}
|
|
1555
|
-
function decodeFirstIsRegistered(results) {
|
|
1556
|
-
const nonceCandidateCount = 3;
|
|
1557
|
-
const candidates = [
|
|
1558
|
-
"function registeredKeys(bytes32 userKeyHash) view returns (bool)",
|
|
1559
|
-
"function isKeyRegisteredByHash(bytes32 userKeyHash) view returns (bool)"
|
|
1560
|
-
];
|
|
1561
|
-
const iface = new import_ethers4.ethers.Interface(candidates);
|
|
1562
|
-
const fnNames = ["registeredKeys", "isKeyRegisteredByHash"];
|
|
1563
|
-
for (let i = 0; i < fnNames.length; i++) {
|
|
1564
|
-
const fnName = fnNames[i];
|
|
1565
|
-
try {
|
|
1566
|
-
const data = results[nonceCandidateCount + i];
|
|
1567
|
-
if (!data || data === "0x") continue;
|
|
1568
|
-
const decoded = iface.decodeFunctionResult(fnName, data);
|
|
1569
|
-
return Boolean(decoded[0]);
|
|
1570
|
-
} catch {
|
|
1571
|
-
}
|
|
1572
|
-
}
|
|
1573
|
-
return false;
|
|
1574
|
-
}
|
|
1575
|
-
function decodeLastActionHash(results) {
|
|
1576
|
-
const nonceCandidateCount = 3;
|
|
1577
|
-
const registeredCandidateCount = 2;
|
|
1578
|
-
const actionHashOffset = nonceCandidateCount + registeredCandidateCount;
|
|
1579
|
-
const candidates = [
|
|
1580
|
-
"function getUserLastActionHash(bytes32 userKeyHash) view returns (bytes32)",
|
|
1581
|
-
"function userLastActionHash(bytes32 userKeyHash) view returns (bytes32)"
|
|
1582
|
-
];
|
|
1583
|
-
const iface = new import_ethers4.ethers.Interface(candidates);
|
|
1584
|
-
const fnNames = ["getUserLastActionHash", "userLastActionHash"];
|
|
1585
|
-
for (let i = 0; i < fnNames.length; i++) {
|
|
1586
|
-
const fnName = fnNames[i];
|
|
1587
|
-
try {
|
|
1588
|
-
const data = results[actionHashOffset + i];
|
|
1589
|
-
if (!data || data === "0x") continue;
|
|
1590
|
-
const decoded = iface.decodeFunctionResult(fnName, data);
|
|
1591
|
-
return decoded[0];
|
|
1592
|
-
} catch {
|
|
1593
|
-
}
|
|
1594
|
-
}
|
|
1595
|
-
return import_ethers4.ethers.ZeroHash;
|
|
1596
|
-
}
|
|
1597
|
-
async function queryHubState(userKeyHash, apiKey, options) {
|
|
1598
|
-
if (typeof userKeyHash !== "string" || userKeyHash.length === 0) {
|
|
1599
|
-
throw new QueryHubStateError("INVALID_ARGUMENT", "userKeyHash is required");
|
|
1600
|
-
}
|
|
1601
|
-
if (!(0, import_wormhole_query_sdk.isValidHexString)(userKeyHash) || (0, import_wormhole_query_sdk.hexToUint8Array)(userKeyHash).length !== 32) {
|
|
1602
|
-
throw new QueryHubStateError("INVALID_ARGUMENT", "userKeyHash must be a 32-byte hex string");
|
|
1603
|
-
}
|
|
1604
|
-
if (typeof apiKey !== "string" || apiKey.length === 0) {
|
|
1605
|
-
throw new QueryHubStateError("INVALID_ARGUMENT", "apiKey is required");
|
|
1606
|
-
}
|
|
1607
|
-
const network = resolveNetwork(options);
|
|
1608
|
-
const maxAgeSeconds = options?.maxAge ?? 60;
|
|
1609
|
-
const maxAttempts = options?.maxAttempts ?? 4;
|
|
1610
|
-
const { wormholeChainId, hubAddress, endpoint, rpcUrl } = getHubConfig(network);
|
|
1611
|
-
const provider = new import_ethers4.ethers.JsonRpcProvider(rpcUrl);
|
|
1612
|
-
const callData = encodeHubCalls(hubAddress, userKeyHash);
|
|
1613
|
-
const doFetch = async () => {
|
|
1614
|
-
try {
|
|
1615
|
-
const latestBlock = await provider.getBlockNumber();
|
|
1616
|
-
const blockTag = Math.max(0, latestBlock - 2);
|
|
1617
|
-
const request = new import_wormhole_query_sdk.QueryRequest(Date.now() & 4294967295, [
|
|
1618
|
-
new import_wormhole_query_sdk.PerChainQueryRequest(wormholeChainId, new import_wormhole_query_sdk.EthCallQueryRequest(blockTag, callData))
|
|
1619
|
-
]);
|
|
1620
|
-
const requestHex = import_buffer.Buffer.from(request.serialize()).toString("hex");
|
|
1621
|
-
const response = await import_axios.default.post(
|
|
1622
|
-
endpoint,
|
|
1623
|
-
{ bytes: requestHex },
|
|
1624
|
-
{
|
|
1625
|
-
headers: {
|
|
1626
|
-
"X-API-Key": apiKey,
|
|
1627
|
-
"Content-Type": "application/json"
|
|
1628
|
-
},
|
|
1629
|
-
timeout: 1e4
|
|
1630
|
-
}
|
|
1631
|
-
);
|
|
1632
|
-
const data = response.data;
|
|
1633
|
-
const signatures = data?.signatures;
|
|
1634
|
-
const bytes = data?.bytes;
|
|
1635
|
-
if (!Array.isArray(signatures) || typeof bytes !== "string") {
|
|
1636
|
-
throw new QueryHubStateError("PROXY_RESPONSE_INVALID", "Query Proxy response missing signatures/bytes");
|
|
1637
|
-
}
|
|
1638
|
-
const proof = signaturesToProofBytes(signatures);
|
|
1639
|
-
const queryBytes = decodeQueryBytes(bytes);
|
|
1640
|
-
const parsed = import_wormhole_query_sdk.QueryResponse.from(queryBytes);
|
|
1641
|
-
const perChain = parsed.responses.find((r) => r.chainId === wormholeChainId);
|
|
1642
|
-
if (!perChain) {
|
|
1643
|
-
throw new QueryHubStateError("QUERY_RESPONSE_INVALID", "Missing per-chain response for hub chain");
|
|
1644
|
-
}
|
|
1645
|
-
const chainResp = import_wormhole_query_sdk.EthCallQueryResponse.from(perChain.response.serialize());
|
|
1646
|
-
const blockTime = Number(chainResp.blockTime);
|
|
1647
|
-
const nowSeconds = Math.floor(Date.now() / 1e3);
|
|
1648
|
-
if (nowSeconds - blockTime > maxAgeSeconds) {
|
|
1649
|
-
throw new QueryHubStateError(
|
|
1650
|
-
"ATTESTATION_STALE",
|
|
1651
|
-
`Guardian attestation is stale (blockTime=${blockTime}, now=${nowSeconds}, maxAge=${maxAgeSeconds}s)`
|
|
1652
|
-
);
|
|
1653
|
-
}
|
|
1654
|
-
const nonce = decodeFirstNonce(chainResp.results);
|
|
1655
|
-
const isRegistered = decodeFirstIsRegistered(chainResp.results);
|
|
1656
|
-
const lastActionHash = decodeLastActionHash(chainResp.results);
|
|
1657
|
-
return {
|
|
1658
|
-
nonce,
|
|
1659
|
-
isRegistered,
|
|
1660
|
-
blockTime,
|
|
1661
|
-
proof,
|
|
1662
|
-
lastActionHash
|
|
1663
|
-
};
|
|
1664
|
-
} catch (err) {
|
|
1665
|
-
if (err instanceof QueryHubStateError) throw err;
|
|
1666
|
-
if (import_axios.default.isAxiosError(err)) {
|
|
1667
|
-
const ax = err;
|
|
1668
|
-
const status = ax.response?.status;
|
|
1669
|
-
const statusText = ax.response?.statusText;
|
|
1670
|
-
const details = typeof ax.response?.data === "string" ? ax.response?.data : void 0;
|
|
1671
|
-
throw new QueryHubStateError(
|
|
1672
|
-
"PROXY_HTTP_ERROR",
|
|
1673
|
-
`Query Proxy request failed${status ? ` (${status} ${statusText ?? ""})` : ""}${details ? `: ${details}` : ""}`,
|
|
1674
|
-
err
|
|
1675
|
-
);
|
|
1676
|
-
}
|
|
1677
|
-
throw new QueryHubStateError("PROXY_HTTP_ERROR", "Query Proxy request failed", err);
|
|
1678
|
-
}
|
|
1679
|
-
};
|
|
1680
|
-
return await withExponentialBackoff(doFetch, maxAttempts);
|
|
1681
|
-
}
|
|
1682
|
-
|
|
1683
|
-
// src/featureFlags.ts
|
|
1684
|
-
var DEFAULT_FLAGS = {
|
|
1685
|
-
multiHub: false,
|
|
1686
|
-
primaryHub: "base"
|
|
1687
|
-
};
|
|
1688
|
-
var _flags = { ...DEFAULT_FLAGS };
|
|
1689
|
-
function getEffectivePrimaryHub() {
|
|
1690
|
-
if (!_flags.multiHub) {
|
|
1691
|
-
return "base";
|
|
1125
|
+
if (import_ethers3.ethers.dataLength(preimage) !== 114) {
|
|
1126
|
+
throw new Error("canonical challenge preimage must be 114 bytes");
|
|
1692
1127
|
}
|
|
1693
|
-
return
|
|
1128
|
+
return import_ethers3.ethers.getBytes(import_ethers3.ethers.sha256(preimage));
|
|
1694
1129
|
}
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
name: "Base Sepolia",
|
|
1707
|
-
chainId: 84532,
|
|
1708
|
-
wormholeChainId: 10004,
|
|
1709
|
-
rpcUrl: "https://sepolia.base.org",
|
|
1710
|
-
explorerUrl: "https://sepolia.basescan.org",
|
|
1711
|
-
isEvm: true,
|
|
1712
|
-
contracts: {
|
|
1713
|
-
hub: "0xD5D29b6EaeE6FF4b765e704298a7e48D22607059",
|
|
1714
|
-
vaultFactory: "0xb25b73D5FeD5693dcd1Bb78f8e33387B59A022EC",
|
|
1715
|
-
vaultImplementation: "0x2CB8397df988c1880d9e5cFfF65bfC22D7D90EE6",
|
|
1716
|
-
wormholeCoreBridge: "0x79A1027a6A159502049F10906D333EC57E95F083",
|
|
1717
|
-
tokenBridge: "0x86F55A04690fd7815A3D802bD587e83eA888B239"
|
|
1718
|
-
}
|
|
1719
|
-
},
|
|
1720
|
-
mainnet: {
|
|
1721
|
-
name: "Base",
|
|
1722
|
-
chainId: 8453,
|
|
1723
|
-
wormholeChainId: 30,
|
|
1724
|
-
rpcUrl: "https://mainnet.base.org",
|
|
1725
|
-
explorerUrl: "https://basescan.org",
|
|
1726
|
-
isEvm: true,
|
|
1727
|
-
contracts: {
|
|
1728
|
-
// TODO: Deploy mainnet contracts
|
|
1729
|
-
wormholeCoreBridge: "0xbebdb6C8ddC678FfA9f8748f85C815C556Dd8ac6",
|
|
1730
|
-
tokenBridge: "0x8d2de8d2f73F1F4cAB472AC9A881C9b123C79627"
|
|
1731
|
-
}
|
|
1732
|
-
}
|
|
1733
|
-
},
|
|
1734
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
1735
|
-
// OPTIMISM - Secondary Hub / Spoke
|
|
1736
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
1737
|
-
optimism: {
|
|
1738
|
-
displayName: "Optimism",
|
|
1739
|
-
type: "evm",
|
|
1740
|
-
canBeHub: true,
|
|
1741
|
-
testnet: {
|
|
1742
|
-
name: "Optimism Sepolia",
|
|
1743
|
-
chainId: 11155420,
|
|
1744
|
-
wormholeChainId: 10005,
|
|
1745
|
-
rpcUrl: "https://sepolia.optimism.io",
|
|
1746
|
-
explorerUrl: "https://sepolia-optimism.etherscan.io",
|
|
1747
|
-
isEvm: true,
|
|
1748
|
-
contracts: {
|
|
1749
|
-
vaultFactory: "0x3c5e4aCdC8Cd53ae5ae603B4c511885191fBb868",
|
|
1750
|
-
vaultImplementation: "0xA45dBF322c5A3028687fEEB161603d3BCe02e119",
|
|
1751
|
-
wormholeCoreBridge: "0x31377888146f3253211EFEf5c676D41ECe7D58Fe",
|
|
1752
|
-
tokenBridge: "0x99737Ec4B815d816c49A385943baf0380e75c0Ac"
|
|
1753
|
-
}
|
|
1754
|
-
},
|
|
1755
|
-
mainnet: {
|
|
1756
|
-
name: "Optimism",
|
|
1757
|
-
chainId: 10,
|
|
1758
|
-
wormholeChainId: 24,
|
|
1759
|
-
rpcUrl: "https://mainnet.optimism.io",
|
|
1760
|
-
explorerUrl: "https://optimistic.etherscan.io",
|
|
1761
|
-
isEvm: true,
|
|
1762
|
-
contracts: {
|
|
1763
|
-
wormholeCoreBridge: "0xEe91C335eab126dF5fDB3797EA9d6aD93aeC9722",
|
|
1764
|
-
tokenBridge: "0x1D68124e65faFC907325e3EDbF8c4d84499DAa8b"
|
|
1765
|
-
}
|
|
1766
|
-
}
|
|
1767
|
-
},
|
|
1768
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
1769
|
-
// ARBITRUM
|
|
1770
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
1771
|
-
arbitrum: {
|
|
1772
|
-
displayName: "Arbitrum",
|
|
1773
|
-
type: "evm",
|
|
1774
|
-
canBeHub: true,
|
|
1775
|
-
testnet: {
|
|
1776
|
-
name: "Arbitrum Sepolia",
|
|
1777
|
-
chainId: 421614,
|
|
1778
|
-
wormholeChainId: 10003,
|
|
1779
|
-
rpcUrl: "https://sepolia-rollup.arbitrum.io/rpc",
|
|
1780
|
-
explorerUrl: "https://sepolia.arbiscan.io",
|
|
1781
|
-
isEvm: true,
|
|
1782
|
-
contracts: {
|
|
1783
|
-
vaultFactory: "0xB9C3e6bad3c6f26956be4a4bb5a366376Fd3045D",
|
|
1784
|
-
vaultImplementation: "0x8601881b94B68B09b485f407317686103d3CB681",
|
|
1785
|
-
wormholeCoreBridge: "0x6b9C8671cdDC8dEab9c719bB87cBd3e782bA6a35",
|
|
1786
|
-
tokenBridge: "0xC7A204bDBFe983FCD8d8E61D02b475D4073fF97e"
|
|
1787
|
-
}
|
|
1788
|
-
},
|
|
1789
|
-
mainnet: {
|
|
1790
|
-
name: "Arbitrum",
|
|
1791
|
-
chainId: 42161,
|
|
1792
|
-
wormholeChainId: 23,
|
|
1793
|
-
rpcUrl: "https://arb1.arbitrum.io/rpc",
|
|
1794
|
-
explorerUrl: "https://arbiscan.io",
|
|
1795
|
-
isEvm: true,
|
|
1796
|
-
contracts: {
|
|
1797
|
-
wormholeCoreBridge: "0xa5f208e072434bC67592E4C49C1B991BA79BCA46",
|
|
1798
|
-
tokenBridge: "0x0b2402144Bb366A632D14B83F244D2e0e21bD39c"
|
|
1799
|
-
}
|
|
1800
|
-
}
|
|
1801
|
-
},
|
|
1802
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
1803
|
-
// ETHEREUM
|
|
1804
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
1805
|
-
ethereum: {
|
|
1806
|
-
displayName: "Ethereum",
|
|
1807
|
-
type: "evm",
|
|
1808
|
-
canBeHub: false,
|
|
1809
|
-
testnet: {
|
|
1810
|
-
name: "Sepolia",
|
|
1811
|
-
chainId: 11155111,
|
|
1812
|
-
wormholeChainId: 10002,
|
|
1813
|
-
rpcUrl: "https://ethereum-sepolia-rpc.publicnode.com",
|
|
1814
|
-
explorerUrl: "https://sepolia.etherscan.io",
|
|
1815
|
-
isEvm: true,
|
|
1816
|
-
contracts: {
|
|
1817
|
-
vaultFactory: "0x265c10763B4d16AD970bC3d7670c645e37f63AF4",
|
|
1818
|
-
vaultImplementation: "0x942426C94652ebC48f4f404928016B95ADb1DA25",
|
|
1819
|
-
wormholeCoreBridge: "0x4a8bc80Ed5a4067f1CCf107057b8270E0cC11A78",
|
|
1820
|
-
tokenBridge: "0xDB5492265f6038831E89f495670FF909aDe94bd9"
|
|
1821
|
-
}
|
|
1822
|
-
},
|
|
1823
|
-
mainnet: {
|
|
1824
|
-
name: "Ethereum",
|
|
1825
|
-
chainId: 1,
|
|
1826
|
-
wormholeChainId: 2,
|
|
1827
|
-
rpcUrl: "https://eth.llamarpc.com",
|
|
1828
|
-
explorerUrl: "https://etherscan.io",
|
|
1829
|
-
isEvm: true,
|
|
1830
|
-
contracts: {
|
|
1831
|
-
wormholeCoreBridge: "0x98f3c9e6E3fAce36bAAd05FE09d375Ef1464288B",
|
|
1832
|
-
tokenBridge: "0x3ee18B2214AFF97000D974cf647E7C347E8fa585"
|
|
1833
|
-
}
|
|
1834
|
-
}
|
|
1835
|
-
},
|
|
1836
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
1837
|
-
// POLYGON
|
|
1838
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
1839
|
-
polygon: {
|
|
1840
|
-
displayName: "Polygon",
|
|
1841
|
-
type: "evm",
|
|
1842
|
-
canBeHub: false,
|
|
1843
|
-
testnet: {
|
|
1844
|
-
name: "Polygon Amoy",
|
|
1845
|
-
chainId: 80002,
|
|
1846
|
-
wormholeChainId: 10007,
|
|
1847
|
-
rpcUrl: "https://rpc-amoy.polygon.technology",
|
|
1848
|
-
explorerUrl: "https://amoy.polygonscan.com",
|
|
1849
|
-
isEvm: true,
|
|
1850
|
-
contracts: {
|
|
1851
|
-
wormholeCoreBridge: "0x0CBE91CF822c73C2315FB05100C2F714765d5c20",
|
|
1852
|
-
tokenBridge: "0x0290FB167208Af455bB137780163b7B7a9a10C16"
|
|
1853
|
-
}
|
|
1854
|
-
},
|
|
1855
|
-
mainnet: {
|
|
1856
|
-
name: "Polygon",
|
|
1857
|
-
chainId: 137,
|
|
1858
|
-
wormholeChainId: 5,
|
|
1859
|
-
rpcUrl: "https://polygon-rpc.com",
|
|
1860
|
-
explorerUrl: "https://polygonscan.com",
|
|
1861
|
-
isEvm: true,
|
|
1862
|
-
contracts: {
|
|
1863
|
-
wormholeCoreBridge: "0x7A4B5a56256163F07b2C80A7cA55aBE66c4ec4d7",
|
|
1864
|
-
tokenBridge: "0x5a58505a96D1dbf8dF91cB21B54419FC36e93fdE"
|
|
1865
|
-
}
|
|
1866
|
-
}
|
|
1867
|
-
},
|
|
1868
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
1869
|
-
// BSC
|
|
1870
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
1871
|
-
bsc: {
|
|
1872
|
-
displayName: "BNB Chain",
|
|
1873
|
-
type: "evm",
|
|
1874
|
-
canBeHub: false,
|
|
1875
|
-
testnet: {
|
|
1876
|
-
name: "BSC Testnet",
|
|
1877
|
-
chainId: 97,
|
|
1878
|
-
wormholeChainId: 4,
|
|
1879
|
-
rpcUrl: "https://data-seed-prebsc-1-s1.binance.org:8545",
|
|
1880
|
-
explorerUrl: "https://testnet.bscscan.com",
|
|
1881
|
-
isEvm: true,
|
|
1882
|
-
contracts: {
|
|
1883
|
-
wormholeCoreBridge: "0x68605AD7b15c732a30b1BbC62BE8F2A509D74b4D",
|
|
1884
|
-
tokenBridge: "0x9dcF9D205C9De35334D646BeE44b2D2859712A09"
|
|
1885
|
-
}
|
|
1886
|
-
},
|
|
1887
|
-
mainnet: {
|
|
1888
|
-
name: "BNB Chain",
|
|
1889
|
-
chainId: 56,
|
|
1890
|
-
wormholeChainId: 4,
|
|
1891
|
-
rpcUrl: "https://bsc-dataseed.binance.org",
|
|
1892
|
-
explorerUrl: "https://bscscan.com",
|
|
1893
|
-
isEvm: true,
|
|
1894
|
-
contracts: {
|
|
1895
|
-
wormholeCoreBridge: "0x98f3c9e6E3fAce36bAAd05FE09d375Ef1464288B",
|
|
1896
|
-
tokenBridge: "0xB6F6D86a8f9879A9c87f643768d9efc38c1Da6E7"
|
|
1897
|
-
}
|
|
1898
|
-
}
|
|
1899
|
-
},
|
|
1900
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
1901
|
-
// AVALANCHE — ACP-204 Native P-256 + ICM Teleporter + Hub-Capable
|
|
1902
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
1903
|
-
avalanche: {
|
|
1904
|
-
displayName: "Avalanche",
|
|
1905
|
-
type: "evm",
|
|
1906
|
-
canBeHub: true,
|
|
1907
|
-
// ACP-204 provides native P-256 at 0x0100 (6,900 gas)
|
|
1908
|
-
testnet: {
|
|
1909
|
-
name: "Avalanche Fuji",
|
|
1910
|
-
chainId: 43113,
|
|
1911
|
-
wormholeChainId: 6,
|
|
1912
|
-
rpcUrl: "https://api.avax-test.network/ext/bc/C/rpc",
|
|
1913
|
-
explorerUrl: "https://testnet.snowtrace.io",
|
|
1914
|
-
isEvm: true,
|
|
1915
|
-
contracts: {
|
|
1916
|
-
// Veridex Hub (deployed via deploy-avalanche.ts)
|
|
1917
|
-
hub: "",
|
|
1918
|
-
// No Hub on Fuji — Hub is on Base Sepolia
|
|
1919
|
-
vaultFactory: "0x9e9716442e908A9b61F11432cC38024DD390cd2a",
|
|
1920
|
-
vaultImplementation: "0xE0b9919ffDf3415355Db369C8FfA5Dd4e000052c",
|
|
1921
|
-
// Wormhole bridges (canonical Fuji addresses)
|
|
1922
|
-
wormholeCoreBridge: "0x7bbcE28e64B3F8b84d876Ab298393c38ad7aac4C",
|
|
1923
|
-
tokenBridge: "0x61E44E506Ca5659E6c0bba9b678586fA2d729756",
|
|
1924
|
-
// Avalanche-specific: ACP-204 P-256 verifier wrapper
|
|
1925
|
-
p256Verifier: "0xB5d29EA1E2e90A24D6506E2a6a269506a12974CC",
|
|
1926
|
-
// Avalanche-specific: ICM Spoke for cross-L1 session bridging
|
|
1927
|
-
icmSpoke: "0x9fCFC608086539A69839EfA9628884dB75ac07D0",
|
|
1928
|
-
// Chainlink price feeds (Fuji testnet)
|
|
1929
|
-
chainlinkAvaxUsd: "0x5498BB86BC934c8D34FDA08E81D444153d0D06aD",
|
|
1930
|
-
chainlinkUsdcUsd: "0x7898AcCC83587C3C55116c5230C17a6Cd9C71bad",
|
|
1931
|
-
chainlinkUsdtUsd: "0x7898AcCC83587C3C55116c5230C17a6Cd9C71bad"
|
|
1932
|
-
},
|
|
1933
|
-
hubChainId: 10004
|
|
1934
|
-
// Base Sepolia (primary Hub)
|
|
1935
|
-
},
|
|
1936
|
-
mainnet: {
|
|
1937
|
-
name: "Avalanche",
|
|
1938
|
-
chainId: 43114,
|
|
1939
|
-
wormholeChainId: 6,
|
|
1940
|
-
rpcUrl: "https://api.avax.network/ext/bc/C/rpc",
|
|
1941
|
-
explorerUrl: "https://snowtrace.io",
|
|
1942
|
-
isEvm: true,
|
|
1943
|
-
contracts: {
|
|
1944
|
-
wormholeCoreBridge: "0x54a8e5f9c4CbA08F9943965859F6c34eAF03E26c",
|
|
1945
|
-
tokenBridge: "0x0e082F06FF657D94310cB8cE8B0D9a04541d8052",
|
|
1946
|
-
// Chainlink price feeds (Avalanche mainnet)
|
|
1947
|
-
chainlinkAvaxUsd: "0x0A77230d17318075983913bC2145DB16C7366156",
|
|
1948
|
-
chainlinkUsdcUsd: "0xF096872672F44d6EBA71458D74fe67F9a77a23B9",
|
|
1949
|
-
chainlinkUsdtUsd: "0xEBE676ee90Fe1112671f19b6B7459bC678B67e8a"
|
|
1950
|
-
}
|
|
1951
|
-
}
|
|
1952
|
-
},
|
|
1953
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
1954
|
-
// SCROLL
|
|
1955
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
1956
|
-
scroll: {
|
|
1957
|
-
displayName: "Scroll",
|
|
1958
|
-
type: "evm",
|
|
1959
|
-
canBeHub: false,
|
|
1960
|
-
testnet: {
|
|
1961
|
-
name: "Scroll Sepolia",
|
|
1962
|
-
chainId: 534351,
|
|
1963
|
-
wormholeChainId: 34,
|
|
1964
|
-
rpcUrl: "https://sepolia-rpc.scroll.io",
|
|
1965
|
-
explorerUrl: "https://sepolia.scrollscan.com",
|
|
1966
|
-
isEvm: true,
|
|
1967
|
-
contracts: {
|
|
1968
|
-
wormholeCoreBridge: "0x055F47F1250012C6B20c436570a76e52c17Af2D5",
|
|
1969
|
-
tokenBridge: "0x22427d90B7dA3fA4642F7025A854c7254E4e45BF"
|
|
1970
|
-
}
|
|
1971
|
-
},
|
|
1972
|
-
mainnet: {
|
|
1973
|
-
name: "Scroll",
|
|
1974
|
-
chainId: 534352,
|
|
1975
|
-
wormholeChainId: 34,
|
|
1976
|
-
rpcUrl: "https://rpc.scroll.io",
|
|
1977
|
-
explorerUrl: "https://scrollscan.com",
|
|
1978
|
-
isEvm: true,
|
|
1979
|
-
contracts: {
|
|
1980
|
-
wormholeCoreBridge: "0xbebdb6C8ddC678FfA9f8748f85C815C556Dd8ac6",
|
|
1981
|
-
tokenBridge: "0x24850c6f61C438823F01B7A3BF2B89B72174Fa9d"
|
|
1982
|
-
}
|
|
1983
|
-
}
|
|
1984
|
-
},
|
|
1985
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
1986
|
-
// BLAST
|
|
1987
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
1988
|
-
blast: {
|
|
1989
|
-
displayName: "Blast",
|
|
1990
|
-
type: "evm",
|
|
1991
|
-
canBeHub: false,
|
|
1992
|
-
testnet: {
|
|
1993
|
-
name: "Blast Sepolia",
|
|
1994
|
-
chainId: 168587773,
|
|
1995
|
-
wormholeChainId: 36,
|
|
1996
|
-
rpcUrl: "https://sepolia.blast.io",
|
|
1997
|
-
explorerUrl: "https://sepolia.blastscan.io",
|
|
1998
|
-
isEvm: true,
|
|
1999
|
-
contracts: {
|
|
2000
|
-
wormholeCoreBridge: "0x473e002D7add6fB67a4964F13bFd61280Ca46886",
|
|
2001
|
-
tokenBridge: "0x430855B4D43b8AEB9D2B9869B74d58dda79C0dB2"
|
|
2002
|
-
}
|
|
2003
|
-
},
|
|
2004
|
-
mainnet: {
|
|
2005
|
-
name: "Blast",
|
|
2006
|
-
chainId: 81457,
|
|
2007
|
-
wormholeChainId: 36,
|
|
2008
|
-
rpcUrl: "https://rpc.blast.io",
|
|
2009
|
-
explorerUrl: "https://blastscan.io",
|
|
2010
|
-
isEvm: true,
|
|
2011
|
-
contracts: {
|
|
2012
|
-
wormholeCoreBridge: "0xbebdb6C8ddC678FfA9f8748f85C815C556Dd8ac6",
|
|
2013
|
-
tokenBridge: "0x24850c6f61C438823F01B7A3BF2B89B72174Fa9d"
|
|
2014
|
-
}
|
|
2015
|
-
}
|
|
2016
|
-
},
|
|
2017
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
2018
|
-
// MANTLE
|
|
2019
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
2020
|
-
mantle: {
|
|
2021
|
-
displayName: "Mantle",
|
|
2022
|
-
type: "evm",
|
|
2023
|
-
canBeHub: false,
|
|
2024
|
-
testnet: {
|
|
2025
|
-
name: "Mantle Sepolia",
|
|
2026
|
-
chainId: 5003,
|
|
2027
|
-
wormholeChainId: 35,
|
|
2028
|
-
rpcUrl: "https://rpc.sepolia.mantle.xyz",
|
|
2029
|
-
explorerUrl: "https://sepolia.mantlescan.xyz",
|
|
2030
|
-
isEvm: true,
|
|
2031
|
-
contracts: {
|
|
2032
|
-
wormholeCoreBridge: "0x376428e7f26D5867e69201b275553C45B09EE090",
|
|
2033
|
-
tokenBridge: "0x75Bfa155a9D7A3714b0861c8a8aF0C4633c45b5D"
|
|
2034
|
-
}
|
|
2035
|
-
},
|
|
2036
|
-
mainnet: {
|
|
2037
|
-
name: "Mantle",
|
|
2038
|
-
chainId: 5e3,
|
|
2039
|
-
wormholeChainId: 35,
|
|
2040
|
-
rpcUrl: "https://rpc.mantle.xyz",
|
|
2041
|
-
explorerUrl: "https://mantlescan.xyz",
|
|
2042
|
-
isEvm: true,
|
|
2043
|
-
contracts: {
|
|
2044
|
-
wormholeCoreBridge: "0xbebdb6C8ddC678FfA9f8748f85C815C556Dd8ac6",
|
|
2045
|
-
tokenBridge: "0x24850c6f61C438823F01B7A3BF2B89B72174Fa9d"
|
|
2046
|
-
}
|
|
2047
|
-
}
|
|
2048
|
-
},
|
|
2049
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
2050
|
-
// FANTOM
|
|
2051
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
2052
|
-
fantom: {
|
|
2053
|
-
displayName: "Fantom",
|
|
2054
|
-
type: "evm",
|
|
2055
|
-
canBeHub: false,
|
|
2056
|
-
testnet: {
|
|
2057
|
-
name: "Fantom Testnet",
|
|
2058
|
-
chainId: 4002,
|
|
2059
|
-
wormholeChainId: 10,
|
|
2060
|
-
rpcUrl: "https://rpc.testnet.fantom.network",
|
|
2061
|
-
explorerUrl: "https://testnet.ftmscan.com",
|
|
2062
|
-
isEvm: true,
|
|
2063
|
-
contracts: {
|
|
2064
|
-
wormholeCoreBridge: "0x1BB3B4119b7BA9dfad76B0545fb3F531383c3bB7",
|
|
2065
|
-
tokenBridge: "0x599CEa2204B4FaECd584Ab1F2b6aCA137a0afbE8"
|
|
2066
|
-
}
|
|
2067
|
-
},
|
|
2068
|
-
mainnet: {
|
|
2069
|
-
name: "Fantom",
|
|
2070
|
-
chainId: 250,
|
|
2071
|
-
wormholeChainId: 10,
|
|
2072
|
-
rpcUrl: "https://rpcapi.fantom.network",
|
|
2073
|
-
explorerUrl: "https://ftmscan.com",
|
|
2074
|
-
isEvm: true,
|
|
2075
|
-
contracts: {
|
|
2076
|
-
wormholeCoreBridge: "0x126783A6Cb203a3E35344528B26ca3a0489a1485",
|
|
2077
|
-
tokenBridge: "0x7C9Fc5741288cDFdD83CeB07f3ea7e22618D79D2"
|
|
2078
|
-
}
|
|
2079
|
-
}
|
|
2080
|
-
},
|
|
2081
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
2082
|
-
// CELO
|
|
2083
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
2084
|
-
celo: {
|
|
2085
|
-
displayName: "Celo",
|
|
2086
|
-
type: "evm",
|
|
2087
|
-
canBeHub: false,
|
|
2088
|
-
testnet: {
|
|
2089
|
-
name: "Celo Alfajores",
|
|
2090
|
-
chainId: 44787,
|
|
2091
|
-
wormholeChainId: 14,
|
|
2092
|
-
rpcUrl: "https://alfajores-forno.celo-testnet.org",
|
|
2093
|
-
explorerUrl: "https://alfajores.celoscan.io",
|
|
2094
|
-
isEvm: true,
|
|
2095
|
-
contracts: {
|
|
2096
|
-
wormholeCoreBridge: "0x88505117CA88e7dd2eC6EA1E13f0948db2D50D56",
|
|
2097
|
-
tokenBridge: "0x05ca6037eC51F8b712eD2E6Fa72219FEaE74E153"
|
|
2098
|
-
}
|
|
2099
|
-
},
|
|
2100
|
-
mainnet: {
|
|
2101
|
-
name: "Celo",
|
|
2102
|
-
chainId: 42220,
|
|
2103
|
-
wormholeChainId: 14,
|
|
2104
|
-
rpcUrl: "https://forno.celo.org",
|
|
2105
|
-
explorerUrl: "https://celoscan.io",
|
|
2106
|
-
isEvm: true,
|
|
2107
|
-
contracts: {
|
|
2108
|
-
wormholeCoreBridge: "0xa321448d90d4e5b0A732867c18eA198e75CAC48E",
|
|
2109
|
-
tokenBridge: "0x796Dff6D74F3E27060B71255Fe517BFb23C93eed"
|
|
2110
|
-
}
|
|
2111
|
-
}
|
|
2112
|
-
},
|
|
2113
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
2114
|
-
// MOONBEAM
|
|
2115
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
2116
|
-
moonbeam: {
|
|
2117
|
-
displayName: "Moonbeam",
|
|
2118
|
-
type: "evm",
|
|
2119
|
-
canBeHub: false,
|
|
2120
|
-
testnet: {
|
|
2121
|
-
name: "Moonbase Alpha",
|
|
2122
|
-
chainId: 1287,
|
|
2123
|
-
wormholeChainId: 16,
|
|
2124
|
-
rpcUrl: "https://rpc.api.moonbase.moonbeam.network",
|
|
2125
|
-
explorerUrl: "https://moonbase.moonscan.io",
|
|
2126
|
-
isEvm: true,
|
|
2127
|
-
contracts: {
|
|
2128
|
-
wormholeCoreBridge: "0xa5B7D85a8f27dd7907dc8FdC21FA5657D5E2F901",
|
|
2129
|
-
tokenBridge: "0xbc976D4b9D57E57c3cA52e1Fd136C45FF7955A96"
|
|
2130
|
-
}
|
|
2131
|
-
},
|
|
2132
|
-
mainnet: {
|
|
2133
|
-
name: "Moonbeam",
|
|
2134
|
-
chainId: 1284,
|
|
2135
|
-
wormholeChainId: 16,
|
|
2136
|
-
rpcUrl: "https://rpc.api.moonbeam.network",
|
|
2137
|
-
explorerUrl: "https://moonscan.io",
|
|
2138
|
-
isEvm: true,
|
|
2139
|
-
contracts: {
|
|
2140
|
-
wormholeCoreBridge: "0xC8e2b0cD52Cf01b0Ce87d389Daa3d414d4cE29f3",
|
|
2141
|
-
tokenBridge: "0xb1731c586ca89a23809861c6103F0b96B3F57D92"
|
|
2142
|
-
}
|
|
2143
|
-
}
|
|
2144
|
-
},
|
|
2145
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
2146
|
-
// MONAD - High-Performance L1 with EIP-7951 P256 + Agent Gateway
|
|
2147
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
2148
|
-
monad: {
|
|
2149
|
-
displayName: "Monad",
|
|
2150
|
-
type: "evm",
|
|
2151
|
-
canBeHub: true,
|
|
2152
|
-
// Has native P-256 precompile (EIP-7951)
|
|
2153
|
-
testnet: {
|
|
2154
|
-
name: "Monad Testnet",
|
|
2155
|
-
chainId: 10143,
|
|
2156
|
-
wormholeChainId: 10048,
|
|
2157
|
-
rpcUrl: "https://testnet-rpc.monad.xyz",
|
|
2158
|
-
explorerUrl: "https://testnet.monadvision.com",
|
|
2159
|
-
isEvm: true,
|
|
2160
|
-
contracts: {
|
|
2161
|
-
vaultFactory: "0x50F2c37584823A6cc293bd0d7647D558d05CA4C1",
|
|
2162
|
-
vaultImplementation: "0x53d4D3943d0E524836f0B1955AbB216449F538fF",
|
|
2163
|
-
wormholeCoreBridge: "0xBB73cB66C26740F31d1FabDC6b7A46a038A300dd",
|
|
2164
|
-
// Agent Gateway contracts
|
|
2165
|
-
serviceDirectory: "0x2d20f29E1f5B24294B3F125B47f2a22a7012a35E"
|
|
2166
|
-
},
|
|
2167
|
-
hubChainId: 10004
|
|
2168
|
-
// Base Sepolia
|
|
2169
|
-
},
|
|
2170
|
-
mainnet: {
|
|
2171
|
-
name: "Monad",
|
|
2172
|
-
chainId: 143,
|
|
2173
|
-
wormholeChainId: 0,
|
|
2174
|
-
// TBD
|
|
2175
|
-
rpcUrl: "https://rpc.monad.xyz",
|
|
2176
|
-
explorerUrl: "https://monadscan.com",
|
|
2177
|
-
isEvm: true,
|
|
2178
|
-
contracts: {
|
|
2179
|
-
wormholeCoreBridge: "0x194B123c5E96B9b2E49763619985790Dc241CAC0",
|
|
2180
|
-
tokenBridge: "0x0B2719cdA2F10595369e6673ceA3Ee2EDFa13BA7"
|
|
2181
|
-
}
|
|
2182
|
-
}
|
|
2183
|
-
},
|
|
2184
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
2185
|
-
// SEI
|
|
2186
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
2187
|
-
sei: {
|
|
2188
|
-
displayName: "Sei",
|
|
2189
|
-
type: "evm",
|
|
2190
|
-
canBeHub: false,
|
|
2191
|
-
testnet: {
|
|
2192
|
-
name: "Sei Atlantic-2",
|
|
2193
|
-
chainId: 1328,
|
|
2194
|
-
wormholeChainId: 40,
|
|
2195
|
-
rpcUrl: "https://evm-rpc-testnet.sei-apis.com",
|
|
2196
|
-
explorerUrl: "https://seitrace.com/?chain=atlantic-2",
|
|
2197
|
-
isEvm: true,
|
|
2198
|
-
contracts: {
|
|
2199
|
-
vaultFactory: "0x07F608AFf6d63b68029488b726d895c4Bb593038",
|
|
2200
|
-
vaultImplementation: "0xD66153fccFB6731fB6c4944FbD607ba86A76a1f6",
|
|
2201
|
-
wormholeCoreBridge: "0x0000000000000000000000000000000000000000"
|
|
2202
|
-
}
|
|
2203
|
-
},
|
|
2204
|
-
mainnet: {
|
|
2205
|
-
name: "Sei",
|
|
2206
|
-
chainId: 1329,
|
|
2207
|
-
wormholeChainId: 32,
|
|
2208
|
-
rpcUrl: "https://evm-rpc.sei-apis.com",
|
|
2209
|
-
explorerUrl: "https://seitrace.com",
|
|
2210
|
-
isEvm: true,
|
|
2211
|
-
contracts: {
|
|
2212
|
-
wormholeCoreBridge: "0x0000000000000000000000000000000000000000"
|
|
2213
|
-
}
|
|
2214
|
-
}
|
|
2215
|
-
},
|
|
2216
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
2217
|
-
// SOLANA
|
|
2218
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
2219
|
-
solana: {
|
|
2220
|
-
displayName: "Solana",
|
|
2221
|
-
type: "solana",
|
|
2222
|
-
canBeHub: false,
|
|
2223
|
-
testnet: {
|
|
2224
|
-
name: "Solana Devnet",
|
|
2225
|
-
chainId: 0,
|
|
2226
|
-
wormholeChainId: 1,
|
|
2227
|
-
rpcUrl: "https://api.devnet.solana.com",
|
|
2228
|
-
explorerUrl: "https://explorer.solana.com",
|
|
2229
|
-
isEvm: false,
|
|
2230
|
-
contracts: {
|
|
2231
|
-
hub: "64ZZBdmGd1YT6Fok7PELvAdfoXyR4PHxHnRqHNqZHJ13",
|
|
2232
|
-
wormholeCoreBridge: "3u8hJUVTA4jH1wYAyUur7FFZVQ8H635K3tSHHF4ssjQ5",
|
|
2233
|
-
tokenBridge: "DZnkkTmCiFWfYTfT41X3Rd1kDgozqzxWaHqsw6W4x2oe"
|
|
2234
|
-
}
|
|
2235
|
-
},
|
|
2236
|
-
mainnet: {
|
|
2237
|
-
name: "Solana",
|
|
2238
|
-
chainId: 0,
|
|
2239
|
-
wormholeChainId: 1,
|
|
2240
|
-
rpcUrl: "https://api.mainnet-beta.solana.com",
|
|
2241
|
-
explorerUrl: "https://explorer.solana.com",
|
|
2242
|
-
isEvm: false,
|
|
2243
|
-
contracts: {
|
|
2244
|
-
wormholeCoreBridge: "worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth",
|
|
2245
|
-
tokenBridge: "wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb"
|
|
2246
|
-
}
|
|
2247
|
-
}
|
|
2248
|
-
},
|
|
2249
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
2250
|
-
// APTOS
|
|
2251
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
2252
|
-
aptos: {
|
|
2253
|
-
displayName: "Aptos",
|
|
2254
|
-
type: "aptos",
|
|
2255
|
-
canBeHub: false,
|
|
2256
|
-
testnet: {
|
|
2257
|
-
name: "Aptos Testnet",
|
|
2258
|
-
chainId: 0,
|
|
2259
|
-
wormholeChainId: 22,
|
|
2260
|
-
rpcUrl: "https://fullnode.testnet.aptoslabs.com/v1",
|
|
2261
|
-
explorerUrl: "https://explorer.aptoslabs.com",
|
|
2262
|
-
isEvm: false,
|
|
2263
|
-
contracts: {
|
|
2264
|
-
hub: "0x9e8641143245ab8b93af1417a1fbc698d40fd351a25f6c17e4210e59bf82c9c7",
|
|
2265
|
-
wormholeCoreBridge: "0x5bc11445584a763c1fa7ed39081f1b920954da14e04b32440cba863d03e19625",
|
|
2266
|
-
tokenBridge: "0x576410486a2da45eee6c949c995670112ddf2fbeedab20350d506328eefc9d4f"
|
|
2267
|
-
}
|
|
2268
|
-
},
|
|
2269
|
-
mainnet: {
|
|
2270
|
-
name: "Aptos",
|
|
2271
|
-
chainId: 0,
|
|
2272
|
-
wormholeChainId: 22,
|
|
2273
|
-
rpcUrl: "https://fullnode.mainnet.aptoslabs.com/v1",
|
|
2274
|
-
explorerUrl: "https://explorer.aptoslabs.com",
|
|
2275
|
-
isEvm: false,
|
|
2276
|
-
contracts: {
|
|
2277
|
-
wormholeCoreBridge: "0x5bc11445584a763c1fa7ed39081f1b920954da14e04b32440cba863d03e19625",
|
|
2278
|
-
tokenBridge: "0x576410486a2da45eee6c949c995670112ddf2fbeedab20350d506328eefc9d4f"
|
|
2279
|
-
}
|
|
2280
|
-
}
|
|
2281
|
-
},
|
|
2282
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
2283
|
-
// SUI
|
|
2284
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
2285
|
-
sui: {
|
|
2286
|
-
displayName: "Sui",
|
|
2287
|
-
type: "sui",
|
|
2288
|
-
canBeHub: false,
|
|
2289
|
-
testnet: {
|
|
2290
|
-
name: "Sui Testnet",
|
|
2291
|
-
chainId: 0,
|
|
2292
|
-
wormholeChainId: 21,
|
|
2293
|
-
rpcUrl: "https://fullnode.testnet.sui.io:443",
|
|
2294
|
-
explorerUrl: "https://suiscan.xyz/testnet",
|
|
2295
|
-
isEvm: false,
|
|
2296
|
-
contracts: {
|
|
2297
|
-
hub: "0xaf36d8bc349883b23e78b00a342a656c799319508600583eaee9121ffaa7f5f7",
|
|
2298
|
-
wormholeCoreBridge: "0x31358d198147da50db32eda2562951d53973a0c0ad5ed738e9b17d88b213d790"
|
|
2299
|
-
}
|
|
2300
|
-
},
|
|
2301
|
-
mainnet: {
|
|
2302
|
-
name: "Sui",
|
|
2303
|
-
chainId: 0,
|
|
2304
|
-
wormholeChainId: 21,
|
|
2305
|
-
rpcUrl: "https://fullnode.mainnet.sui.io:443",
|
|
2306
|
-
explorerUrl: "https://suiscan.xyz/mainnet",
|
|
2307
|
-
isEvm: false,
|
|
2308
|
-
contracts: {
|
|
2309
|
-
wormholeCoreBridge: "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c"
|
|
2310
|
-
}
|
|
2311
|
-
}
|
|
2312
|
-
},
|
|
2313
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
2314
|
-
// STARKNET
|
|
2315
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
2316
|
-
starknet: {
|
|
2317
|
-
displayName: "Starknet",
|
|
2318
|
-
type: "starknet",
|
|
2319
|
-
canBeHub: false,
|
|
2320
|
-
testnet: {
|
|
2321
|
-
name: "Starknet Sepolia",
|
|
2322
|
-
chainId: 0,
|
|
2323
|
-
wormholeChainId: 50001,
|
|
2324
|
-
// Custom bridge (non-Wormhole)
|
|
2325
|
-
rpcUrl: "https://starknet-sepolia-rpc.publicnode.com",
|
|
2326
|
-
explorerUrl: "https://sepolia.starkscan.co",
|
|
2327
|
-
isEvm: false,
|
|
2328
|
-
contracts: {
|
|
2329
|
-
hub: "0x7bb7cbe7d82e910b296611b582035a207343431f98bdd7b692bddfdd6f28737",
|
|
2330
|
-
wormholeCoreBridge: "0x30d2e7f26dc75819cfddcd7caa26a76b681d5918f219c99060c42ce1e3f69e4"
|
|
2331
|
-
},
|
|
2332
|
-
hubChainId: 10004
|
|
2333
|
-
// Base Sepolia
|
|
2334
|
-
},
|
|
2335
|
-
mainnet: {
|
|
2336
|
-
name: "Starknet",
|
|
2337
|
-
chainId: 0,
|
|
2338
|
-
wormholeChainId: 50001,
|
|
2339
|
-
rpcUrl: "https://starknet-mainnet.public.blastapi.io/rpc/v0_7",
|
|
2340
|
-
explorerUrl: "https://starkscan.co",
|
|
2341
|
-
isEvm: false,
|
|
2342
|
-
contracts: {
|
|
2343
|
-
// TODO: Deploy mainnet contracts
|
|
2344
|
-
wormholeCoreBridge: ""
|
|
2345
|
-
}
|
|
2346
|
-
}
|
|
2347
|
-
},
|
|
2348
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
2349
|
-
// STACKS
|
|
2350
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
2351
|
-
stacks: {
|
|
2352
|
-
displayName: "Stacks",
|
|
2353
|
-
type: "stacks",
|
|
2354
|
-
canBeHub: false,
|
|
2355
|
-
testnet: {
|
|
2356
|
-
name: "Stacks Testnet",
|
|
2357
|
-
chainId: 2147483648,
|
|
2358
|
-
// CAIP-2: stacks:2147483648
|
|
2359
|
-
wormholeChainId: 60,
|
|
2360
|
-
// Official Wormhole chain ID for Stacks
|
|
2361
|
-
rpcUrl: "https://api.testnet.hiro.so",
|
|
2362
|
-
explorerUrl: "https://explorer.hiro.so/?chain=testnet",
|
|
2363
|
-
isEvm: false,
|
|
2364
|
-
contracts: {
|
|
2365
|
-
// Spoke contract: identity + session management
|
|
2366
|
-
hub: "STWJ9E8J5NPKB4MT1378G6XWNFGAKRY1E6D6PYSM.veridex-spoke",
|
|
2367
|
-
// Vault contract: STX/sBTC custody
|
|
2368
|
-
vaultFactory: "STWJ9E8J5NPKB4MT1378G6XWNFGAKRY1E6D6PYSM.veridex-vault",
|
|
2369
|
-
wormholeCoreBridge: "",
|
|
2370
|
-
// Phase 2: Wormhole integration contracts
|
|
2371
|
-
wormholeVerifier: "STWJ9E8J5NPKB4MT1378G6XWNFGAKRY1E6D6PYSM.veridex-wormhole-verifier",
|
|
2372
|
-
vaultVaa: "STWJ9E8J5NPKB4MT1378G6XWNFGAKRY1E6D6PYSM.veridex-vault-vaa"
|
|
2373
|
-
},
|
|
2374
|
-
hubChainId: 10004
|
|
2375
|
-
// Base Sepolia
|
|
2376
|
-
},
|
|
2377
|
-
mainnet: {
|
|
2378
|
-
name: "Stacks",
|
|
2379
|
-
chainId: 1,
|
|
2380
|
-
// CAIP-2: stacks:1
|
|
2381
|
-
wormholeChainId: 60,
|
|
2382
|
-
rpcUrl: "https://api.hiro.so",
|
|
2383
|
-
explorerUrl: "https://explorer.hiro.so",
|
|
2384
|
-
isEvm: false,
|
|
2385
|
-
contracts: {
|
|
2386
|
-
// TODO: Deploy mainnet contracts
|
|
2387
|
-
wormholeCoreBridge: ""
|
|
2388
|
-
}
|
|
2389
|
-
}
|
|
2390
|
-
},
|
|
2391
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
2392
|
-
// NEAR
|
|
2393
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
2394
|
-
near: {
|
|
2395
|
-
displayName: "Near",
|
|
2396
|
-
type: "near",
|
|
2397
|
-
canBeHub: false,
|
|
2398
|
-
testnet: {
|
|
2399
|
-
name: "Near Testnet",
|
|
2400
|
-
chainId: 0,
|
|
2401
|
-
wormholeChainId: 15,
|
|
2402
|
-
rpcUrl: "https://rpc.testnet.near.org",
|
|
2403
|
-
explorerUrl: "https://explorer.testnet.near.org",
|
|
2404
|
-
isEvm: false,
|
|
2405
|
-
contracts: {
|
|
2406
|
-
wormholeCoreBridge: "wormhole.wormhole.testnet",
|
|
2407
|
-
tokenBridge: "token.wormhole.testnet"
|
|
2408
|
-
}
|
|
2409
|
-
},
|
|
2410
|
-
mainnet: {
|
|
2411
|
-
name: "Near",
|
|
2412
|
-
chainId: 0,
|
|
2413
|
-
wormholeChainId: 15,
|
|
2414
|
-
rpcUrl: "https://rpc.mainnet.near.org",
|
|
2415
|
-
explorerUrl: "https://explorer.near.org",
|
|
2416
|
-
isEvm: false,
|
|
2417
|
-
contracts: {
|
|
2418
|
-
wormholeCoreBridge: "contract.wormhole_crypto.near",
|
|
2419
|
-
tokenBridge: "contract.portalbridge.near"
|
|
2420
|
-
}
|
|
2421
|
-
}
|
|
2422
|
-
}
|
|
2423
|
-
};
|
|
2424
|
-
function getDefaultHub(network = "testnet") {
|
|
2425
|
-
const primary = getEffectivePrimaryHub();
|
|
2426
|
-
return CHAIN_PRESETS[primary][network];
|
|
1130
|
+
function buildGaslessChallenge(input) {
|
|
1131
|
+
if (!Number.isInteger(input.targetChain) || input.targetChain < 0 || input.targetChain > 65535) {
|
|
1132
|
+
throw new Error("targetChain must fit in uint16");
|
|
1133
|
+
}
|
|
1134
|
+
return buildCanonicalChallenge({
|
|
1135
|
+
veridexChainId: input.veridexChainId,
|
|
1136
|
+
executor: input.executor,
|
|
1137
|
+
minTier: input.minTier,
|
|
1138
|
+
nonce: input.nonce,
|
|
1139
|
+
actionHash: import_ethers3.ethers.keccak256(input.actionPayload)
|
|
1140
|
+
});
|
|
2427
1141
|
}
|
|
2428
1142
|
|
|
2429
1143
|
// src/auth/prepareAuth.ts
|
|
2430
|
-
function resolveNetwork2() {
|
|
2431
|
-
const envCandidates = [
|
|
2432
|
-
globalThis?.process?.env?.NEXT_PUBLIC_VERIDEX_NETWORK,
|
|
2433
|
-
globalThis?.process?.env?.VERIDEX_NETWORK,
|
|
2434
|
-
globalThis?.process?.env?.NEXT_PUBLIC_WORMHOLE_NETWORK,
|
|
2435
|
-
globalThis?.process?.env?.WORMHOLE_NETWORK
|
|
2436
|
-
].filter(Boolean);
|
|
2437
|
-
const env = envCandidates[0]?.toLowerCase();
|
|
2438
|
-
if (env === "mainnet" || env === "testnet") return env;
|
|
2439
|
-
return "testnet";
|
|
2440
|
-
}
|
|
2441
|
-
function getHubChainId(network) {
|
|
2442
|
-
return getDefaultHub(network).wormholeChainId;
|
|
2443
|
-
}
|
|
2444
|
-
function getHubRpcUrl(network) {
|
|
2445
|
-
return getDefaultHub(network).rpcUrl;
|
|
2446
|
-
}
|
|
2447
|
-
function getHubAddress(network) {
|
|
2448
|
-
const hub = getDefaultHub(network).contracts.hub;
|
|
2449
|
-
if (!hub) {
|
|
2450
|
-
throw new Error("Hub address missing in SDK constants");
|
|
2451
|
-
}
|
|
2452
|
-
return hub;
|
|
2453
|
-
}
|
|
2454
1144
|
function encodeActionPayload(action, targetChain) {
|
|
2455
1145
|
if (action.token !== void 0 && action.recipient !== void 0) {
|
|
2456
1146
|
const a2 = action;
|
|
@@ -2463,68 +1153,21 @@ function encodeActionPayload(action, targetChain) {
|
|
|
2463
1153
|
const a = action;
|
|
2464
1154
|
return encodeBridgeAction(a.token, a.amount, targetChain, a.recipient);
|
|
2465
1155
|
}
|
|
2466
|
-
async function fetchNonceViaRpc(userKeyHash, network) {
|
|
2467
|
-
const rpcUrl = getHubRpcUrl(network);
|
|
2468
|
-
const hubAddress = getHubAddress(network);
|
|
2469
|
-
const provider = new import_ethers5.ethers.JsonRpcProvider(rpcUrl);
|
|
2470
|
-
const hubIface = new import_ethers5.ethers.Interface([
|
|
2471
|
-
"function getNonce(bytes32 userKeyHash) external view returns (uint256)",
|
|
2472
|
-
"function userNonces(bytes32 userKeyHash) external view returns (uint256)"
|
|
2473
|
-
]);
|
|
2474
|
-
const calls = [
|
|
2475
|
-
async () => {
|
|
2476
|
-
const data = hubIface.encodeFunctionData("getNonce", [userKeyHash]);
|
|
2477
|
-
const res = await provider.call({ to: hubAddress, data });
|
|
2478
|
-
const decoded = hubIface.decodeFunctionResult("getNonce", res);
|
|
2479
|
-
return decoded[0];
|
|
2480
|
-
},
|
|
2481
|
-
async () => {
|
|
2482
|
-
const data = hubIface.encodeFunctionData("userNonces", [userKeyHash]);
|
|
2483
|
-
const res = await provider.call({ to: hubAddress, data });
|
|
2484
|
-
const decoded = hubIface.decodeFunctionResult("userNonces", res);
|
|
2485
|
-
return decoded[0];
|
|
2486
|
-
}
|
|
2487
|
-
];
|
|
2488
|
-
let lastErr;
|
|
2489
|
-
for (const fn of calls) {
|
|
2490
|
-
try {
|
|
2491
|
-
return await fn();
|
|
2492
|
-
} catch (e) {
|
|
2493
|
-
lastErr = e;
|
|
2494
|
-
}
|
|
2495
|
-
}
|
|
2496
|
-
throw lastErr instanceof Error ? lastErr : new Error(String(lastErr));
|
|
2497
|
-
}
|
|
2498
1156
|
function toHex32(value) {
|
|
2499
1157
|
return "0x" + value.toString(16).padStart(64, "0");
|
|
2500
1158
|
}
|
|
2501
|
-
async function authenticateAndPrepare(userParams
|
|
2502
|
-
const network = resolveNetwork2();
|
|
2503
|
-
const hubChainId = getHubChainId(network);
|
|
1159
|
+
async function authenticateAndPrepare(userParams) {
|
|
2504
1160
|
const actionPayload = userParams.actionPayload ?? (userParams.action ? encodeActionPayload(userParams.action, userParams.targetChain) : void 0);
|
|
2505
1161
|
if (!actionPayload) {
|
|
2506
1162
|
throw new Error("Missing action payload: provide either actionPayload or action");
|
|
2507
1163
|
}
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
}
|
|
2516
|
-
const state = await queryHubState(userParams.credential.keyHash, apiKey, { network, maxAge: 60 });
|
|
2517
|
-
if (!state.isRegistered) {
|
|
2518
|
-
throw new Error("Passkey is not registered on Hub");
|
|
2519
|
-
}
|
|
2520
|
-
nonce = state.nonce;
|
|
2521
|
-
queryProof = state.proof;
|
|
2522
|
-
} catch {
|
|
2523
|
-
nonce = await fetchNonceViaRpc(userParams.credential.keyHash, network);
|
|
2524
|
-
queryProof = new Uint8Array();
|
|
2525
|
-
}
|
|
2526
|
-
const queryLatencyMs = Date.now() - queryStart;
|
|
2527
|
-
const challenge = buildGaslessChallenge(userParams.targetChain, actionPayload, nonce, hubChainId);
|
|
1164
|
+
const nonce = userParams.nonce;
|
|
1165
|
+
const queryProof = new Uint8Array();
|
|
1166
|
+
const challenge = buildGaslessChallenge({
|
|
1167
|
+
...userParams.destination,
|
|
1168
|
+
actionPayload,
|
|
1169
|
+
nonce
|
|
1170
|
+
});
|
|
2528
1171
|
const passkey = new PasskeyManager();
|
|
2529
1172
|
passkey.setCredential(userParams.credential);
|
|
2530
1173
|
const signature = await passkey.sign(challenge);
|
|
@@ -2538,19 +1181,18 @@ async function authenticateAndPrepare(userParams, apiKey) {
|
|
|
2538
1181
|
publicKeyX: toHex32(userParams.credential.publicKeyX),
|
|
2539
1182
|
publicKeyY: toHex32(userParams.credential.publicKeyY),
|
|
2540
1183
|
targetChain: userParams.targetChain,
|
|
1184
|
+
veridexChainId: userParams.destination.veridexChainId,
|
|
1185
|
+
executor: userParams.destination.executor,
|
|
1186
|
+
minTier: userParams.destination.minTier,
|
|
2541
1187
|
actionPayload,
|
|
2542
|
-
nonce:
|
|
1188
|
+
nonce: nonce.toString()
|
|
2543
1189
|
};
|
|
2544
|
-
if (queryProof.length) {
|
|
2545
|
-
requestBody.queryProof = import_ethers5.ethers.hexlify(queryProof);
|
|
2546
|
-
}
|
|
2547
1190
|
const serializedTx = new TextEncoder().encode(JSON.stringify(requestBody));
|
|
2548
|
-
const estimatedLatency = queryProof.length ? Math.max(250, queryLatencyMs) : Math.max(800, queryLatencyMs);
|
|
2549
1191
|
return {
|
|
2550
1192
|
serializedTx,
|
|
2551
1193
|
queryProof,
|
|
2552
|
-
estimatedLatency,
|
|
2553
|
-
fallbackAvailable
|
|
1194
|
+
estimatedLatency: 0,
|
|
1195
|
+
fallbackAvailable: false
|
|
2554
1196
|
};
|
|
2555
1197
|
}
|
|
2556
1198
|
// Annotate the CommonJS export names for ESM import in node:
|