@humanode-hyperlane/cli 0.0.0-stage → 30.0.0-humanode.1
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/LICENSE.md +193 -0
- package/README.md +149 -2
- package/bundle/100.index.js +1453 -0
- package/bundle/12.index.js +91 -0
- package/bundle/172.index.js +3065 -0
- package/bundle/213.index.js +901 -0
- package/bundle/214.index.js +5017 -0
- package/bundle/306.index.js +1037 -0
- package/bundle/30fb121a258f7502fa97.js +214 -0
- package/bundle/467.index.js +222 -0
- package/bundle/485.index.js +85430 -0
- package/bundle/515.index.js +5191 -0
- package/bundle/544.index.js +792 -0
- package/bundle/617.index.js +1612 -0
- package/bundle/660.index.js +223 -0
- package/bundle/688.index.js +232 -0
- package/bundle/756.index.js +8595 -0
- package/bundle/824.index.js +385 -0
- package/bundle/95.index.js +264 -0
- package/bundle/aleo_wasm.wasm +0 -0
- package/bundle/aleo_wasm1.wasm +0 -0
- package/bundle/file.js +12 -0
- package/bundle/index.js +4 -0
- package/bundle/package.json +3 -0
- package/bundle/prebuilds/linux-x64/node.napi.node +0 -0
- package/bundle/worker-pipeline.js +38 -0
- package/bundle/worker.js +54 -0
- package/bundle/worker1.js +171 -0
- package/bundle/worker2.js +14180 -0
- package/bundle/worker3.js +14180 -0
- package/examples/aleo/core-config.yaml +19 -0
- package/examples/ccip/ccip-warp-route.yaml +26 -0
- package/examples/ccip/multi-chain-ccip-warp-route.yaml +81 -0
- package/examples/chain-config.yaml +42 -0
- package/examples/contract-artifacts.yaml +20 -0
- package/examples/core-config.yaml +19 -0
- package/examples/cosmosnative/core-config.yaml +20 -0
- package/examples/cosmosnative/warp-route-deployment.yaml +21 -0
- package/examples/crosschain/README.md +31 -0
- package/examples/crosschain/cosmosnative/core-config.yaml +69 -0
- package/examples/crosschain/ethereum/core-config.yaml +70 -0
- package/examples/crosschain/radix/core-config.yaml +96 -0
- package/examples/fork/file-transactions.yaml +5 -0
- package/examples/fork/timelock-testing.yaml +36 -0
- package/examples/fork/warp-route-update.yaml +100 -0
- package/examples/hooks.yaml +70 -0
- package/examples/ism-advanced.yaml +33 -0
- package/examples/ism.yaml +13 -0
- package/examples/radix/core-config.yaml +29 -0
- package/examples/sealevel/core-config-apply.yaml +7 -0
- package/examples/sealevel/core-config.yaml +12 -0
- package/examples/starknet/core-config.yaml +20 -0
- package/examples/submit/strategy/file-strategy.yaml +8 -0
- package/examples/submit/strategy/gnosis-chain-strategy.yaml +10 -0
- package/examples/submit/strategy/gnosis-chain-tx-builder-strategy.yaml +6 -0
- package/examples/submit/strategy/gnosis-strategy-avalanche.yaml +4 -0
- package/examples/submit/strategy/gnosis-tx-builder-ica-strategy.yaml +20 -0
- package/examples/submit/strategy/ica-timelock-strategy.yaml +15 -0
- package/examples/submit/strategy/impersonated-account-strategy.yaml +4 -0
- package/examples/submit/strategy/json-rpc-chain-strategy.yaml +8 -0
- package/examples/submit/strategy/json-rpc-ica-strategy.yaml +13 -0
- package/examples/submit/strategy/json-rpc-strategy.yaml +3 -0
- package/examples/submit/strategy/json-rpc-timelock-strategy.yaml +17 -0
- package/examples/submit/strategy/starknet-json-rpc-chain-strategy.yaml +11 -0
- package/examples/submit/transactions/anvil-transactions.yaml +10 -0
- package/examples/submit/transactions/avalanche-transactions.json +8 -0
- package/examples/submit/transactions/sepolia-transactions.json +8 -0
- package/examples/tron-core-config.yaml +18 -0
- package/examples/warp-route-deployment.yaml +21 -0
- package/package.json +110 -3
|
@@ -0,0 +1,3065 @@
|
|
|
1
|
+
export const id = 172;
|
|
2
|
+
export const ids = [172];
|
|
3
|
+
export const modules = {
|
|
4
|
+
|
|
5
|
+
/***/ 21172:
|
|
6
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// EXPORTS
|
|
10
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
11
|
+
StarknetProtocolProvider: () => (/* reexport */ StarknetProtocolProvider)
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// UNUSED EXPORTS: StarknetHookArtifactManager, StarknetIsmArtifactManager, StarknetMailboxArtifactManager, StarknetProvider, StarknetSigner, StarknetValidatorAnnounceArtifactManager, StarknetWarpArtifactManager
|
|
15
|
+
|
|
16
|
+
// EXTERNAL MODULE: ../utils/dist/validation.js
|
|
17
|
+
var validation = __webpack_require__(21387);
|
|
18
|
+
// EXTERNAL MODULE: ../provider-sdk/dist/index.js + 3 modules
|
|
19
|
+
var dist = __webpack_require__(71280);
|
|
20
|
+
// EXTERNAL MODULE: ../provider-sdk/dist/hook.js
|
|
21
|
+
var hook = __webpack_require__(77230);
|
|
22
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/starknet@7.6.4/node_modules/starknet/dist/index.mjs + 41 modules
|
|
23
|
+
var starknet_dist = __webpack_require__(98954);
|
|
24
|
+
// EXTERNAL MODULE: ../../starknet/dist/index.js + 199 modules
|
|
25
|
+
var starknet_dist_0 = __webpack_require__(17821);
|
|
26
|
+
// EXTERNAL MODULE: ../utils/dist/addresses.js
|
|
27
|
+
var addresses = __webpack_require__(93142);
|
|
28
|
+
// EXTERNAL MODULE: ../utils/dist/typeof.js
|
|
29
|
+
var dist_typeof = __webpack_require__(73689);
|
|
30
|
+
// EXTERNAL MODULE: ../utils/dist/logging.js
|
|
31
|
+
var logging = __webpack_require__(94523);
|
|
32
|
+
;// CONCATENATED MODULE: ../starknet-sdk/dist/contracts.js
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
function isObjectRecord(value) {
|
|
37
|
+
return !!value && typeof value === 'object';
|
|
38
|
+
}
|
|
39
|
+
function getContractAbi(contract) {
|
|
40
|
+
const abi = Reflect.get(contract, 'abi');
|
|
41
|
+
return Array.isArray(abi) ? abi : undefined;
|
|
42
|
+
}
|
|
43
|
+
function abiEntryHasMethod(entry, method) {
|
|
44
|
+
if (!isObjectRecord(entry))
|
|
45
|
+
return false;
|
|
46
|
+
if (entry['name'] === method)
|
|
47
|
+
return true;
|
|
48
|
+
const items = entry['items'];
|
|
49
|
+
return Array.isArray(items)
|
|
50
|
+
? items.some((nestedEntry) => abiEntryHasMethod(nestedEntry, method))
|
|
51
|
+
: false;
|
|
52
|
+
}
|
|
53
|
+
function hasAbiMethod(contract, method) {
|
|
54
|
+
const abi = getContractAbi(contract);
|
|
55
|
+
if (!abi)
|
|
56
|
+
return true;
|
|
57
|
+
return abi.some((entry) => abiEntryHasMethod(entry, method));
|
|
58
|
+
}
|
|
59
|
+
function isUint256Like(value) {
|
|
60
|
+
if (!isObjectRecord(value))
|
|
61
|
+
return false;
|
|
62
|
+
const low = value['low'];
|
|
63
|
+
const high = value['high'];
|
|
64
|
+
const isNumberish = (v) => typeof v === 'string' || typeof v === 'number' || typeof v === 'bigint';
|
|
65
|
+
return isNumberish(low) && isNumberish(high);
|
|
66
|
+
}
|
|
67
|
+
function describeUnknown(value) {
|
|
68
|
+
if (typeof value === 'string' ||
|
|
69
|
+
typeof value === 'number' ||
|
|
70
|
+
typeof value === 'bigint' ||
|
|
71
|
+
typeof value === 'boolean') {
|
|
72
|
+
return String(value);
|
|
73
|
+
}
|
|
74
|
+
if (isObjectRecord(value)) {
|
|
75
|
+
if ('value' in value)
|
|
76
|
+
return describeUnknown(value['value']);
|
|
77
|
+
try {
|
|
78
|
+
return JSON.stringify(value);
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return '';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return '';
|
|
85
|
+
}
|
|
86
|
+
function isPopulatedInvokeTx(value) {
|
|
87
|
+
if (!isObjectRecord(value))
|
|
88
|
+
return false;
|
|
89
|
+
return ('contractAddress' in value &&
|
|
90
|
+
typeof value['entrypoint'] === 'string' &&
|
|
91
|
+
(!('calldata' in value) || Array.isArray(value['calldata'])));
|
|
92
|
+
}
|
|
93
|
+
var StarknetContractName;
|
|
94
|
+
(function (StarknetContractName) {
|
|
95
|
+
StarknetContractName["MAILBOX"] = "mailbox";
|
|
96
|
+
StarknetContractName["MESSAGE_ID_MULTISIG_ISM"] = "messageid_multisig_ism";
|
|
97
|
+
StarknetContractName["MERKLE_ROOT_MULTISIG_ISM"] = "merkleroot_multisig_ism";
|
|
98
|
+
StarknetContractName["ROUTING_ISM"] = "domain_routing_ism";
|
|
99
|
+
StarknetContractName["NOOP_ISM"] = "noop_ism";
|
|
100
|
+
StarknetContractName["HOOK"] = "hook";
|
|
101
|
+
StarknetContractName["MERKLE_TREE_HOOK"] = "merkle_tree_hook";
|
|
102
|
+
StarknetContractName["PROTOCOL_FEE"] = "protocol_fee";
|
|
103
|
+
StarknetContractName["VALIDATOR_ANNOUNCE"] = "validator_announce";
|
|
104
|
+
StarknetContractName["HYP_ERC20"] = "HypErc20";
|
|
105
|
+
StarknetContractName["HYP_ERC20_COLLATERAL"] = "HypErc20Collateral";
|
|
106
|
+
StarknetContractName["HYP_NATIVE"] = "HypNative";
|
|
107
|
+
StarknetContractName["ETHER"] = "Ether";
|
|
108
|
+
})(StarknetContractName || (StarknetContractName = {}));
|
|
109
|
+
const STARKNET_DEFAULT_FEE_TOKEN_ADDRESSES = {
|
|
110
|
+
starknet: '0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d',
|
|
111
|
+
starknetsepolia: '0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d',
|
|
112
|
+
paradex: '0x7348407ebad690fec0cc8597e87dc16ef7b269a655ff72587dafff83d462be2',
|
|
113
|
+
paradexsepolia: '0x06f373b346561036d98ea10fb3e60d2f459c872b1933b50b21fe6ef4fda3b75e',
|
|
114
|
+
};
|
|
115
|
+
function getStarknetContract(contractName, address, providerOrAccount, contractType = starknet_dist_0/* ContractType */.h$.CONTRACT) {
|
|
116
|
+
const { abi } = (0,starknet_dist_0/* getCompiledContract */.wm)(contractName, contractType);
|
|
117
|
+
return new starknet_dist/* Contract */.NZ(abi, normalizeStarknetAddressSafe(address), providerOrAccount);
|
|
118
|
+
}
|
|
119
|
+
function normalizeStarknetAddressSafe(value) {
|
|
120
|
+
if (typeof value === 'string') {
|
|
121
|
+
if ((0,addresses/* isZeroishAddress */.Hi)(value))
|
|
122
|
+
return addresses/* ZERO_ADDRESS_HEX_32 */.qx;
|
|
123
|
+
return (0,starknet_dist/* addAddressPadding */.N6)((0,addresses/* ensure0x */.Ho)((0,addresses/* normalizeAddressStarknet */.sf)(value)));
|
|
124
|
+
}
|
|
125
|
+
if (typeof value === 'number' || typeof value === 'bigint') {
|
|
126
|
+
return (0,starknet_dist/* addAddressPadding */.N6)((0,addresses/* ensure0x */.Ho)(BigInt(value).toString(16)));
|
|
127
|
+
}
|
|
128
|
+
if (isObjectRecord(value)) {
|
|
129
|
+
if (isUint256Like(value)) {
|
|
130
|
+
return (0,starknet_dist/* addAddressPadding */.N6)((0,addresses/* ensure0x */.Ho)(starknet_dist/* uint256 */.iN.uint256ToBN(value).toString(16)));
|
|
131
|
+
}
|
|
132
|
+
if ('value' in value) {
|
|
133
|
+
return normalizeStarknetAddressSafe(value['value']);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
throw new Error(`Unable to normalize Starknet address: ${describeUnknown(value) || '[unsupported value]'}`);
|
|
137
|
+
}
|
|
138
|
+
function addressToEvmAddress(value) {
|
|
139
|
+
return (0,addresses/* bytes32ToAddress */.ov)(normalizeStarknetAddressSafe(value));
|
|
140
|
+
}
|
|
141
|
+
async function callContract(contract, method, args = []) {
|
|
142
|
+
(0,validation/* assert */.v)(hasAbiMethod(contract, method), `Unable to call ${method} on contract ${contract.address}: method not found in ABI`);
|
|
143
|
+
const fn = Reflect.get(contract, method);
|
|
144
|
+
if (typeof fn === 'function')
|
|
145
|
+
return Reflect.apply(fn, contract, args);
|
|
146
|
+
const call = Reflect.get(contract, 'call');
|
|
147
|
+
if (typeof call === 'function') {
|
|
148
|
+
const callArgs = args;
|
|
149
|
+
return Reflect.apply(call, contract, [method, callArgs]);
|
|
150
|
+
}
|
|
151
|
+
throw new Error(`Unable to call ${method} on contract ${contract.address}`);
|
|
152
|
+
}
|
|
153
|
+
async function populateInvokeTx(contract, method, args = []) {
|
|
154
|
+
(0,validation/* assert */.v)(hasAbiMethod(contract, method), `Unable to populate ${method} on contract ${contract.address}: method not found in ABI`);
|
|
155
|
+
const populateTransaction = Reflect.get(contract, 'populateTransaction');
|
|
156
|
+
const populated = isObjectRecord(populateTransaction) &&
|
|
157
|
+
typeof populateTransaction[method] === 'function'
|
|
158
|
+
? populateTransaction[method]
|
|
159
|
+
: undefined;
|
|
160
|
+
if (typeof populated === 'function') {
|
|
161
|
+
const tx = await populated(...args);
|
|
162
|
+
if (isPopulatedInvokeTx(tx)) {
|
|
163
|
+
return {
|
|
164
|
+
kind: 'invoke',
|
|
165
|
+
contractAddress: normalizeStarknetAddressSafe(tx.contractAddress),
|
|
166
|
+
entrypoint: tx.entrypoint,
|
|
167
|
+
calldata: tx.calldata ?? [],
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const abi = getContractAbi(contract);
|
|
172
|
+
return {
|
|
173
|
+
kind: 'invoke',
|
|
174
|
+
contractAddress: normalizeStarknetAddressSafe(contract.address),
|
|
175
|
+
entrypoint: method,
|
|
176
|
+
calldata: abi ? new starknet_dist/* CallData */.fP(abi).compile(method, args) : args,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function extractEnumVariant(value) {
|
|
180
|
+
if (value === null || value === undefined)
|
|
181
|
+
return '';
|
|
182
|
+
if (value instanceof starknet_dist/* CairoCustomEnum */.bv) {
|
|
183
|
+
return value.activeVariant();
|
|
184
|
+
}
|
|
185
|
+
if (isObjectRecord(value) &&
|
|
186
|
+
'activeVariant' in value &&
|
|
187
|
+
typeof value['activeVariant'] === 'function') {
|
|
188
|
+
return value['activeVariant']();
|
|
189
|
+
}
|
|
190
|
+
if (typeof value === 'string')
|
|
191
|
+
return value;
|
|
192
|
+
if (typeof value === 'number' || typeof value === 'bigint') {
|
|
193
|
+
return value.toString();
|
|
194
|
+
}
|
|
195
|
+
if (isObjectRecord(value)) {
|
|
196
|
+
const entries = Object.entries(value);
|
|
197
|
+
if (entries.length === 1) {
|
|
198
|
+
const [entry] = entries;
|
|
199
|
+
if (entry)
|
|
200
|
+
return entry[0];
|
|
201
|
+
}
|
|
202
|
+
for (const [key, nested] of entries) {
|
|
203
|
+
if (nested !== undefined && nested !== null) {
|
|
204
|
+
return key;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return describeUnknown(value);
|
|
209
|
+
}
|
|
210
|
+
function toNumber(value) {
|
|
211
|
+
if (typeof value === 'number') {
|
|
212
|
+
(0,validation/* assert */.v)(Number.isSafeInteger(value), `Unable to coerce value to safe integer: ${value}`);
|
|
213
|
+
return value;
|
|
214
|
+
}
|
|
215
|
+
if (typeof value === 'bigint') {
|
|
216
|
+
(0,validation/* assert */.v)(value <= BigInt(Number.MAX_SAFE_INTEGER) &&
|
|
217
|
+
value >= BigInt(Number.MIN_SAFE_INTEGER), `Unable to coerce value to safe integer: ${value}`);
|
|
218
|
+
return Number(value);
|
|
219
|
+
}
|
|
220
|
+
if (typeof value === 'string') {
|
|
221
|
+
const parsed = Number(value);
|
|
222
|
+
(0,validation/* assert */.v)(Number.isSafeInteger(parsed), `Unable to coerce value to safe integer: ${value}`);
|
|
223
|
+
return parsed;
|
|
224
|
+
}
|
|
225
|
+
if (isObjectRecord(value) && 'value' in value) {
|
|
226
|
+
return toNumber(value['value']);
|
|
227
|
+
}
|
|
228
|
+
throw new Error(`Unable to coerce value to number: ${describeUnknown(value) || '[unsupported value]'}`);
|
|
229
|
+
}
|
|
230
|
+
function toBigInt(value) {
|
|
231
|
+
if (typeof value === 'bigint')
|
|
232
|
+
return value;
|
|
233
|
+
if (typeof value === 'number')
|
|
234
|
+
return BigInt(value);
|
|
235
|
+
if (typeof value === 'string')
|
|
236
|
+
return BigInt(value);
|
|
237
|
+
if (isObjectRecord(value)) {
|
|
238
|
+
if (isUint256Like(value)) {
|
|
239
|
+
return starknet_dist/* uint256 */.iN.uint256ToBN(value);
|
|
240
|
+
}
|
|
241
|
+
if ('value' in value)
|
|
242
|
+
return toBigInt(value['value']);
|
|
243
|
+
}
|
|
244
|
+
throw new Error(`Unable to coerce value to bigint: ${describeUnknown(value) || '[unsupported value]'}`);
|
|
245
|
+
}
|
|
246
|
+
function getFeeTokenAddress(params) {
|
|
247
|
+
if (params.nativeDenom && !(0,addresses/* isZeroishAddress */.Hi)(params.nativeDenom)) {
|
|
248
|
+
return normalizeStarknetAddressSafe(params.nativeDenom);
|
|
249
|
+
}
|
|
250
|
+
const token = STARKNET_DEFAULT_FEE_TOKEN_ADDRESSES[params.chainName];
|
|
251
|
+
(0,validation/* assert */.v)(token, `Missing Starknet fee token for chain ${params.chainName}`);
|
|
252
|
+
return normalizeStarknetAddressSafe(token);
|
|
253
|
+
}
|
|
254
|
+
function normalizeRoutersAddress(value) {
|
|
255
|
+
if (isUint256Like(value)) {
|
|
256
|
+
return normalizeStarknetAddressSafe(starknet_dist/* num */.bu.toHex(starknet_dist/* uint256 */.iN.uint256ToBN(value)));
|
|
257
|
+
}
|
|
258
|
+
return normalizeStarknetAddressSafe(value);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Creates a Contract instance using the on-chain ABI fetched from the provider.
|
|
262
|
+
* If the contract is a proxy, resolves the implementation class ABI so
|
|
263
|
+
* starknet.js parses responses with the correct types.
|
|
264
|
+
*
|
|
265
|
+
* Handles both Cairo 1 proxies (`get_implementation` returning a struct)
|
|
266
|
+
* and Cairo 0 proxies (`implementation` returning a felt).
|
|
267
|
+
*/
|
|
268
|
+
async function getOnChainStarknetContract(provider, address) {
|
|
269
|
+
const normalized = normalizeStarknetAddressSafe(address);
|
|
270
|
+
const { abi } = await provider.getClassAt(normalized);
|
|
271
|
+
const contract = new starknet_dist/* Contract */.NZ(abi, normalized, provider);
|
|
272
|
+
const implHash = await resolveImplementationHash(contract);
|
|
273
|
+
if ((0,dist_typeof/* isNullish */.u)(implHash) || implHash === 0n)
|
|
274
|
+
return contract;
|
|
275
|
+
const implClass = await provider.getClassByHash(`0x${implHash.toString(16)}`);
|
|
276
|
+
return new starknet_dist/* Contract */.NZ(implClass.abi, normalized, provider);
|
|
277
|
+
}
|
|
278
|
+
async function resolveImplementationHash(contract) {
|
|
279
|
+
try {
|
|
280
|
+
// Cairo 1 proxy pattern
|
|
281
|
+
if (hasAbiMethod(contract, 'get_implementation')) {
|
|
282
|
+
return coerceClassHash(await callContract(contract, 'get_implementation'));
|
|
283
|
+
}
|
|
284
|
+
// Cairo 0 proxy pattern
|
|
285
|
+
if (hasAbiMethod(contract, 'implementation')) {
|
|
286
|
+
return coerceClassHash(await callContract(contract, 'implementation'));
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
catch (error) {
|
|
290
|
+
logging/* rootLogger */.Jk.warn({ address: contract.address, error }, 'Proxy resolution failed; falling back to contract own ABI');
|
|
291
|
+
}
|
|
292
|
+
return undefined;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Coerces a proxy implementation call result to a bigint class hash.
|
|
296
|
+
* Handles both direct values (bigint/string) and single-field structs
|
|
297
|
+
* returned by Cairo 0 (e.g. `{ implementation_hash_: bigint }`).
|
|
298
|
+
*/
|
|
299
|
+
function coerceClassHash(value) {
|
|
300
|
+
if (typeof value === 'bigint')
|
|
301
|
+
return value;
|
|
302
|
+
if (typeof value === 'string')
|
|
303
|
+
return BigInt(value);
|
|
304
|
+
if (typeof value === 'number')
|
|
305
|
+
return BigInt(value);
|
|
306
|
+
if (isObjectRecord(value)) {
|
|
307
|
+
const values = Object.values(value);
|
|
308
|
+
if (values.length === 1)
|
|
309
|
+
return coerceClassHash(values[0]);
|
|
310
|
+
}
|
|
311
|
+
return toBigInt(value);
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Determines whether a storage read error should trigger a fallback
|
|
315
|
+
* to contract call-based reading. Some Starknet chains (e.g. Paradex)
|
|
316
|
+
* have privacy enabled that disallows direct storage reads.
|
|
317
|
+
*/
|
|
318
|
+
/** JSON-RPC error codes that indicate storage reads are unavailable. */
|
|
319
|
+
const STORAGE_READ_FALLBACK_CODES = new Set([-32601, -32000]);
|
|
320
|
+
/** Error message fragments (lowercase) that indicate storage reads are unavailable. */
|
|
321
|
+
const STORAGE_READ_FALLBACK_MESSAGES = [
|
|
322
|
+
'method not found',
|
|
323
|
+
'method not allowed',
|
|
324
|
+
'not supported',
|
|
325
|
+
'unsupported',
|
|
326
|
+
'not implemented',
|
|
327
|
+
];
|
|
328
|
+
function shouldFallbackStorageRead(error) {
|
|
329
|
+
const code = error && typeof error === 'object' ? Reflect.get(error, 'code') : undefined;
|
|
330
|
+
if (STORAGE_READ_FALLBACK_CODES.has(code))
|
|
331
|
+
return true;
|
|
332
|
+
const message = error instanceof Error
|
|
333
|
+
? error.message
|
|
334
|
+
: typeof error === 'string'
|
|
335
|
+
? error
|
|
336
|
+
: String(error && typeof error === 'object'
|
|
337
|
+
? Reflect.get(error, 'message')
|
|
338
|
+
: error);
|
|
339
|
+
const normalizedMessage = message.toLowerCase();
|
|
340
|
+
return STORAGE_READ_FALLBACK_MESSAGES.some((fragment) => normalizedMessage.includes(fragment));
|
|
341
|
+
}
|
|
342
|
+
//# sourceMappingURL=contracts.js.map
|
|
343
|
+
;// CONCATENATED MODULE: ../starknet-sdk/dist/clients/provider.js
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
let tokenTypeByClassHash;
|
|
350
|
+
function getTokenTypeByClassHash() {
|
|
351
|
+
if (tokenTypeByClassHash) {
|
|
352
|
+
return tokenTypeByClassHash;
|
|
353
|
+
}
|
|
354
|
+
const entries = [
|
|
355
|
+
[
|
|
356
|
+
starknet_dist/* hash */.tW.computeContractClassHash((0,starknet_dist_0/* getCompiledContract */.wm)(StarknetContractName.HYP_ERC20, starknet_dist_0/* ContractType */.h$.TOKEN)),
|
|
357
|
+
dist/* AltVM.TokenType */.bx.ks.synthetic,
|
|
358
|
+
],
|
|
359
|
+
[
|
|
360
|
+
starknet_dist/* hash */.tW.computeContractClassHash((0,starknet_dist_0/* getCompiledContract */.wm)(StarknetContractName.HYP_ERC20_COLLATERAL, starknet_dist_0/* ContractType */.h$.TOKEN)),
|
|
361
|
+
dist/* AltVM.TokenType */.bx.ks.collateral,
|
|
362
|
+
],
|
|
363
|
+
[
|
|
364
|
+
starknet_dist/* hash */.tW.computeContractClassHash((0,starknet_dist_0/* getCompiledContract */.wm)(StarknetContractName.HYP_NATIVE, starknet_dist_0/* ContractType */.h$.TOKEN)),
|
|
365
|
+
dist/* AltVM.TokenType */.bx.ks.native,
|
|
366
|
+
],
|
|
367
|
+
];
|
|
368
|
+
tokenTypeByClassHash = new Map(entries.map(([classHash, tokenType]) => [
|
|
369
|
+
BigInt(classHash).toString(),
|
|
370
|
+
tokenType,
|
|
371
|
+
]));
|
|
372
|
+
return tokenTypeByClassHash;
|
|
373
|
+
}
|
|
374
|
+
function isProbeMiss(error) {
|
|
375
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
376
|
+
return [
|
|
377
|
+
'entry point',
|
|
378
|
+
'entrypoint',
|
|
379
|
+
'viewable method not found in abi',
|
|
380
|
+
'not found in abi',
|
|
381
|
+
'not found in contract',
|
|
382
|
+
'invalid message selector',
|
|
383
|
+
].some((needle) => message.toLowerCase().includes(needle));
|
|
384
|
+
}
|
|
385
|
+
class StarknetProvider {
|
|
386
|
+
provider;
|
|
387
|
+
metadata;
|
|
388
|
+
rpcUrls;
|
|
389
|
+
static connect(rpcUrls, _chainId, extraParams) {
|
|
390
|
+
(0,validation/* assert */.v)(extraParams?.metadata, 'metadata missing for Starknet provider');
|
|
391
|
+
const metadata = extraParams.metadata;
|
|
392
|
+
(0,validation/* assert */.v)(rpcUrls.length > 0, 'at least one rpc url is required');
|
|
393
|
+
const provider = new starknet_dist/* RpcProvider */.bd({ nodeUrl: rpcUrls[0] });
|
|
394
|
+
return new StarknetProvider(provider, metadata, rpcUrls);
|
|
395
|
+
}
|
|
396
|
+
constructor(provider, metadata, rpcUrls) {
|
|
397
|
+
this.provider = provider;
|
|
398
|
+
this.metadata = metadata;
|
|
399
|
+
this.rpcUrls = rpcUrls;
|
|
400
|
+
}
|
|
401
|
+
getRawProvider() {
|
|
402
|
+
return this.provider;
|
|
403
|
+
}
|
|
404
|
+
withContract(name, address, providerOrAccount, contractType) {
|
|
405
|
+
return getStarknetContract(name, address, providerOrAccount ?? this.provider, contractType);
|
|
406
|
+
}
|
|
407
|
+
get accountAddress() {
|
|
408
|
+
throw new Error('StarknetProvider has no signer account');
|
|
409
|
+
}
|
|
410
|
+
get feeTokenAddress() {
|
|
411
|
+
return getFeeTokenAddress({
|
|
412
|
+
chainName: this.metadata.name,
|
|
413
|
+
nativeDenom: this.metadata.nativeToken?.denom,
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
parseString(value) {
|
|
417
|
+
if (typeof value === 'string')
|
|
418
|
+
return value;
|
|
419
|
+
if (typeof value === 'number' || typeof value === 'bigint') {
|
|
420
|
+
try {
|
|
421
|
+
return starknet_dist/* shortString */.Gm.decodeShortString((0,addresses/* ensure0x */.Ho)(BigInt(value).toString(16)));
|
|
422
|
+
}
|
|
423
|
+
catch {
|
|
424
|
+
return value.toString();
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
if (value && typeof value === 'object') {
|
|
428
|
+
if ('value' in value)
|
|
429
|
+
return this.parseString(value.value);
|
|
430
|
+
const toStringFn = Reflect.get(value, 'toString');
|
|
431
|
+
if (typeof toStringFn === 'function' &&
|
|
432
|
+
toStringFn !== Object.prototype.toString) {
|
|
433
|
+
const parsed = Reflect.apply(toStringFn, value, []);
|
|
434
|
+
if (typeof parsed === 'string' && parsed !== '[object Object]') {
|
|
435
|
+
return parsed;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
return '';
|
|
440
|
+
}
|
|
441
|
+
async populateInvokeCall(contract, method, args = []) {
|
|
442
|
+
const tx = await populateInvokeTx(contract, method, args);
|
|
443
|
+
(0,validation/* assert */.v)(tx.kind === 'invoke', 'Expected invoke Starknet transaction');
|
|
444
|
+
return {
|
|
445
|
+
contractAddress: normalizeStarknetAddressSafe(tx.contractAddress),
|
|
446
|
+
entrypoint: tx.entrypoint,
|
|
447
|
+
calldata: tx.calldata,
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
unwrapBalance(value) {
|
|
451
|
+
if (value && typeof value === 'object' && 'balance' in value) {
|
|
452
|
+
return value.balance;
|
|
453
|
+
}
|
|
454
|
+
return value;
|
|
455
|
+
}
|
|
456
|
+
async determineTokenType(tokenAddress) {
|
|
457
|
+
const address = normalizeStarknetAddressSafe(tokenAddress);
|
|
458
|
+
const classHash = await this.provider.getClassHashAt(address);
|
|
459
|
+
const tokenType = getTokenTypeByClassHash().get(BigInt(classHash).toString());
|
|
460
|
+
if (tokenType)
|
|
461
|
+
return tokenType;
|
|
462
|
+
try {
|
|
463
|
+
const collateral = this.withContract(StarknetContractName.HYP_ERC20_COLLATERAL, address, this.provider, starknet_dist_0/* ContractType */.h$.TOKEN);
|
|
464
|
+
await callContract(collateral, 'get_wrapped_token');
|
|
465
|
+
return dist/* AltVM.TokenType */.bx.ks.collateral;
|
|
466
|
+
}
|
|
467
|
+
catch (error) {
|
|
468
|
+
if (!isProbeMiss(error))
|
|
469
|
+
throw error;
|
|
470
|
+
}
|
|
471
|
+
try {
|
|
472
|
+
const native = this.withContract(StarknetContractName.HYP_NATIVE, address, this.provider, starknet_dist_0/* ContractType */.h$.TOKEN);
|
|
473
|
+
await callContract(native, 'native_token');
|
|
474
|
+
return dist/* AltVM.TokenType */.bx.ks.native;
|
|
475
|
+
}
|
|
476
|
+
catch (error) {
|
|
477
|
+
if (!isProbeMiss(error))
|
|
478
|
+
throw error;
|
|
479
|
+
}
|
|
480
|
+
return dist/* AltVM.TokenType */.bx.ks.synthetic;
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Reads ERC20 metadata by fetching the contract's own ABI from chain,
|
|
484
|
+
* so starknet.js parses responses correctly regardless of whether
|
|
485
|
+
* the contract uses felt252 (Cairo 0) or ByteArray (Cairo 1).
|
|
486
|
+
*/
|
|
487
|
+
async getTokenMetadata(tokenAddress) {
|
|
488
|
+
const nativeToken = this.metadata.nativeToken;
|
|
489
|
+
if (nativeToken?.denom &&
|
|
490
|
+
normalizeStarknetAddressSafe(tokenAddress) ===
|
|
491
|
+
normalizeStarknetAddressSafe(nativeToken.denom)) {
|
|
492
|
+
return {
|
|
493
|
+
name: nativeToken.name,
|
|
494
|
+
symbol: nativeToken.symbol,
|
|
495
|
+
decimals: nativeToken.decimals ?? 18,
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
const address = normalizeStarknetAddressSafe(tokenAddress);
|
|
499
|
+
const token = await getOnChainStarknetContract(this.provider, address);
|
|
500
|
+
const [name, symbol, decimals] = await Promise.all([
|
|
501
|
+
callContract(token, 'name'),
|
|
502
|
+
callContract(token, 'symbol'),
|
|
503
|
+
callContract(token, 'decimals'),
|
|
504
|
+
]);
|
|
505
|
+
return {
|
|
506
|
+
name: this.parseString(name),
|
|
507
|
+
symbol: this.parseString(symbol),
|
|
508
|
+
decimals: toNumber(decimals),
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
parseHookVariant(variant) {
|
|
512
|
+
const upper = variant.toUpperCase();
|
|
513
|
+
if (upper.includes('MERKLE_TREE'))
|
|
514
|
+
return dist/* AltVM.HookType */.bx.WD.MERKLE_TREE;
|
|
515
|
+
if (upper.includes('PROTOCOL_FEE'))
|
|
516
|
+
return dist/* AltVM.HookType */.bx.WD.PROTOCOL_FEE;
|
|
517
|
+
if (upper.includes('INTERCHAIN_GAS_PAYMASTER')) {
|
|
518
|
+
return dist/* AltVM.HookType */.bx.WD.INTERCHAIN_GAS_PAYMASTER;
|
|
519
|
+
}
|
|
520
|
+
return dist/* AltVM.HookType */.bx.WD.CUSTOM;
|
|
521
|
+
}
|
|
522
|
+
parseIsmVariant(variant) {
|
|
523
|
+
const upper = variant.toUpperCase();
|
|
524
|
+
if (upper.includes('TEST') ||
|
|
525
|
+
upper.includes('NOOP') ||
|
|
526
|
+
upper.includes('NULL') ||
|
|
527
|
+
upper.includes('UNUSED')) {
|
|
528
|
+
return dist/* AltVM.IsmType */.bx.GO.TEST_ISM;
|
|
529
|
+
}
|
|
530
|
+
if (upper.includes('MERKLE_ROOT_MULTISIG')) {
|
|
531
|
+
return dist/* AltVM.IsmType */.bx.GO.MERKLE_ROOT_MULTISIG;
|
|
532
|
+
}
|
|
533
|
+
if (upper.includes('MESSAGE_ID_MULTISIG')) {
|
|
534
|
+
return dist/* AltVM.IsmType */.bx.GO.MESSAGE_ID_MULTISIG;
|
|
535
|
+
}
|
|
536
|
+
if (upper.includes('ROUTING')) {
|
|
537
|
+
return dist/* AltVM.IsmType */.bx.GO.ROUTING;
|
|
538
|
+
}
|
|
539
|
+
return dist/* AltVM.IsmType */.bx.GO.CUSTOM;
|
|
540
|
+
}
|
|
541
|
+
// ### QUERY BASE ###
|
|
542
|
+
async isHealthy() {
|
|
543
|
+
try {
|
|
544
|
+
await this.provider.getBlockNumber();
|
|
545
|
+
return true;
|
|
546
|
+
}
|
|
547
|
+
catch {
|
|
548
|
+
return false;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
getRpcUrls() {
|
|
552
|
+
return this.rpcUrls;
|
|
553
|
+
}
|
|
554
|
+
async getHeight() {
|
|
555
|
+
return this.provider.getBlockNumber();
|
|
556
|
+
}
|
|
557
|
+
async getBalance(req) {
|
|
558
|
+
const tokenAddress = req.denom
|
|
559
|
+
? normalizeStarknetAddressSafe(req.denom)
|
|
560
|
+
: this.feeTokenAddress;
|
|
561
|
+
const token = this.withContract(StarknetContractName.ETHER, tokenAddress, this.provider, starknet_dist_0/* ContractType */.h$.TOKEN);
|
|
562
|
+
let balance;
|
|
563
|
+
try {
|
|
564
|
+
balance = await callContract(token, 'balanceOf', [
|
|
565
|
+
normalizeStarknetAddressSafe(req.address),
|
|
566
|
+
]);
|
|
567
|
+
}
|
|
568
|
+
catch (error) {
|
|
569
|
+
if (!isProbeMiss(error))
|
|
570
|
+
throw error;
|
|
571
|
+
balance = await callContract(token, 'balance_of', [
|
|
572
|
+
normalizeStarknetAddressSafe(req.address),
|
|
573
|
+
]);
|
|
574
|
+
}
|
|
575
|
+
return toBigInt(this.unwrapBalance(balance));
|
|
576
|
+
}
|
|
577
|
+
async getTotalSupply(req) {
|
|
578
|
+
const tokenAddress = req.denom
|
|
579
|
+
? normalizeStarknetAddressSafe(req.denom)
|
|
580
|
+
: this.feeTokenAddress;
|
|
581
|
+
const token = this.withContract(StarknetContractName.ETHER, tokenAddress, this.provider, starknet_dist_0/* ContractType */.h$.TOKEN);
|
|
582
|
+
return toBigInt(await callContract(token, 'total_supply'));
|
|
583
|
+
}
|
|
584
|
+
async estimateTransactionFee(_req) {
|
|
585
|
+
throw new Error('Starknet transaction fee estimation is unsupported without an account-backed signer');
|
|
586
|
+
}
|
|
587
|
+
// ### QUERY CORE ###
|
|
588
|
+
async getMailbox(req) {
|
|
589
|
+
const mailbox = this.withContract(StarknetContractName.MAILBOX, req.mailboxAddress);
|
|
590
|
+
const [owner, localDomain, defaultIsm, defaultHook, requiredHook, nonce] = await Promise.all([
|
|
591
|
+
callContract(mailbox, 'owner'),
|
|
592
|
+
callContract(mailbox, 'get_local_domain'),
|
|
593
|
+
callContract(mailbox, 'get_default_ism'),
|
|
594
|
+
callContract(mailbox, 'get_default_hook'),
|
|
595
|
+
callContract(mailbox, 'get_required_hook'),
|
|
596
|
+
callContract(mailbox, 'nonce'),
|
|
597
|
+
]);
|
|
598
|
+
return {
|
|
599
|
+
address: normalizeStarknetAddressSafe(req.mailboxAddress),
|
|
600
|
+
owner: normalizeStarknetAddressSafe(owner),
|
|
601
|
+
localDomain: toNumber(localDomain),
|
|
602
|
+
defaultIsm: normalizeStarknetAddressSafe(defaultIsm),
|
|
603
|
+
defaultHook: normalizeStarknetAddressSafe(defaultHook),
|
|
604
|
+
requiredHook: normalizeStarknetAddressSafe(requiredHook),
|
|
605
|
+
nonce: toNumber(nonce),
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
async isMessageDelivered(req) {
|
|
609
|
+
const mailbox = this.withContract(StarknetContractName.MAILBOX, req.mailboxAddress);
|
|
610
|
+
const delivered = await callContract(mailbox, 'delivered', [req.messageId]);
|
|
611
|
+
if (typeof delivered === 'boolean')
|
|
612
|
+
return delivered;
|
|
613
|
+
return toBigInt(delivered) !== 0n;
|
|
614
|
+
}
|
|
615
|
+
async getIsmType(req) {
|
|
616
|
+
try {
|
|
617
|
+
const ism = this.withContract(StarknetContractName.MERKLE_ROOT_MULTISIG_ISM, req.ismAddress);
|
|
618
|
+
const moduleType = await callContract(ism, 'module_type');
|
|
619
|
+
return this.parseIsmVariant(extractEnumVariant(moduleType));
|
|
620
|
+
}
|
|
621
|
+
catch (error) {
|
|
622
|
+
if (!isProbeMiss(error))
|
|
623
|
+
throw error;
|
|
624
|
+
return dist/* AltVM.IsmType */.bx.GO.CUSTOM;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
async getMessageIdMultisigIsm(req) {
|
|
628
|
+
const ism = this.withContract(StarknetContractName.MESSAGE_ID_MULTISIG_ISM, req.ismAddress);
|
|
629
|
+
const [validators, threshold] = await Promise.all([
|
|
630
|
+
callContract(ism, 'get_validators'),
|
|
631
|
+
callContract(ism, 'get_threshold'),
|
|
632
|
+
]);
|
|
633
|
+
(0,validation/* assert */.v)(Array.isArray(validators), 'Expected Starknet validators array');
|
|
634
|
+
return {
|
|
635
|
+
address: normalizeStarknetAddressSafe(req.ismAddress),
|
|
636
|
+
threshold: toNumber(threshold),
|
|
637
|
+
validators: validators.map((v) => addressToEvmAddress(v)),
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
async getMerkleRootMultisigIsm(req) {
|
|
641
|
+
const ism = this.withContract(StarknetContractName.MERKLE_ROOT_MULTISIG_ISM, req.ismAddress);
|
|
642
|
+
const [validators, threshold] = await Promise.all([
|
|
643
|
+
callContract(ism, 'get_validators'),
|
|
644
|
+
callContract(ism, 'get_threshold'),
|
|
645
|
+
]);
|
|
646
|
+
(0,validation/* assert */.v)(Array.isArray(validators), 'Expected Starknet validators array');
|
|
647
|
+
return {
|
|
648
|
+
address: normalizeStarknetAddressSafe(req.ismAddress),
|
|
649
|
+
threshold: toNumber(threshold),
|
|
650
|
+
validators: validators.map((v) => addressToEvmAddress(v)),
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
async getRoutingIsm(req) {
|
|
654
|
+
const ism = this.withContract(StarknetContractName.ROUTING_ISM, req.ismAddress);
|
|
655
|
+
const [owner, domains] = await Promise.all([
|
|
656
|
+
callContract(ism, 'owner'),
|
|
657
|
+
callContract(ism, 'domains'),
|
|
658
|
+
]);
|
|
659
|
+
(0,validation/* assert */.v)(Array.isArray(domains), 'Expected Starknet routing domains array');
|
|
660
|
+
const routes = await Promise.all(domains.map(async (domainId) => {
|
|
661
|
+
const routeAddress = await callContract(ism, 'module', [domainId]);
|
|
662
|
+
return {
|
|
663
|
+
domainId: toNumber(domainId),
|
|
664
|
+
ismAddress: normalizeStarknetAddressSafe(routeAddress),
|
|
665
|
+
};
|
|
666
|
+
}));
|
|
667
|
+
return {
|
|
668
|
+
address: normalizeStarknetAddressSafe(req.ismAddress),
|
|
669
|
+
owner: normalizeStarknetAddressSafe(owner),
|
|
670
|
+
routes,
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
async getNoopIsm(req) {
|
|
674
|
+
return { address: normalizeStarknetAddressSafe(req.ismAddress) };
|
|
675
|
+
}
|
|
676
|
+
async getHookType(req) {
|
|
677
|
+
try {
|
|
678
|
+
const hook = this.withContract(StarknetContractName.HOOK, req.hookAddress);
|
|
679
|
+
const hookType = await callContract(hook, 'hook_type');
|
|
680
|
+
return this.parseHookVariant(extractEnumVariant(hookType));
|
|
681
|
+
}
|
|
682
|
+
catch (error) {
|
|
683
|
+
if (!isProbeMiss(error))
|
|
684
|
+
throw error;
|
|
685
|
+
return dist/* AltVM.HookType */.bx.WD.CUSTOM;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
async getInterchainGasPaymasterHook(_req) {
|
|
689
|
+
throw new Error('interchainGasPaymaster hook type is unsupported on Starknet; use protocolFee hook type');
|
|
690
|
+
}
|
|
691
|
+
async getMerkleTreeHook(req) {
|
|
692
|
+
return { address: normalizeStarknetAddressSafe(req.hookAddress) };
|
|
693
|
+
}
|
|
694
|
+
async getNoopHook(req) {
|
|
695
|
+
return { address: normalizeStarknetAddressSafe(req.hookAddress) };
|
|
696
|
+
}
|
|
697
|
+
// ### QUERY WARP ###
|
|
698
|
+
async getToken(req) {
|
|
699
|
+
const tokenAddress = normalizeStarknetAddressSafe(req.tokenAddress);
|
|
700
|
+
const token = this.withContract(StarknetContractName.HYP_ERC20, tokenAddress, this.provider, starknet_dist_0/* ContractType */.h$.TOKEN);
|
|
701
|
+
const tokenType = await this.determineTokenType(tokenAddress);
|
|
702
|
+
const [owner, mailboxAddress, ismAddress, hookAddress] = await Promise.all([
|
|
703
|
+
callContract(token, 'owner'),
|
|
704
|
+
callContract(token, 'mailbox'),
|
|
705
|
+
callContract(token, 'interchain_security_module'),
|
|
706
|
+
callContract(token, 'get_hook'),
|
|
707
|
+
]);
|
|
708
|
+
let denom = tokenAddress;
|
|
709
|
+
let name = '';
|
|
710
|
+
let symbol = '';
|
|
711
|
+
let decimals = this.metadata.nativeToken?.decimals ?? 18;
|
|
712
|
+
try {
|
|
713
|
+
const metadata = await this.getTokenMetadata(tokenAddress);
|
|
714
|
+
name = metadata.name;
|
|
715
|
+
symbol = metadata.symbol;
|
|
716
|
+
decimals = metadata.decimals;
|
|
717
|
+
}
|
|
718
|
+
catch (error) {
|
|
719
|
+
if (!isProbeMiss(error))
|
|
720
|
+
throw error;
|
|
721
|
+
}
|
|
722
|
+
if (tokenType === dist/* AltVM.TokenType */.bx.ks.collateral) {
|
|
723
|
+
const collateral = this.withContract(StarknetContractName.HYP_ERC20_COLLATERAL, tokenAddress, this.provider, starknet_dist_0/* ContractType */.h$.TOKEN);
|
|
724
|
+
const wrapped = await callContract(collateral, 'get_wrapped_token');
|
|
725
|
+
denom = normalizeStarknetAddressSafe(wrapped);
|
|
726
|
+
try {
|
|
727
|
+
const wrappedMeta = await this.getTokenMetadata(denom);
|
|
728
|
+
name = wrappedMeta.name;
|
|
729
|
+
symbol = wrappedMeta.symbol;
|
|
730
|
+
decimals = wrappedMeta.decimals;
|
|
731
|
+
}
|
|
732
|
+
catch (error) {
|
|
733
|
+
if (!isProbeMiss(error))
|
|
734
|
+
throw error;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
else if (tokenType === dist/* AltVM.TokenType */.bx.ks.native) {
|
|
738
|
+
const native = this.withContract(StarknetContractName.HYP_NATIVE, tokenAddress, this.provider, starknet_dist_0/* ContractType */.h$.TOKEN);
|
|
739
|
+
try {
|
|
740
|
+
const nativeTokenAddress = await callContract(native, 'native_token');
|
|
741
|
+
denom = normalizeStarknetAddressSafe(nativeTokenAddress);
|
|
742
|
+
}
|
|
743
|
+
catch (error) {
|
|
744
|
+
if (!isProbeMiss(error))
|
|
745
|
+
throw error;
|
|
746
|
+
denom = this.metadata.nativeToken?.denom ?? this.feeTokenAddress;
|
|
747
|
+
}
|
|
748
|
+
name = this.metadata.nativeToken?.name ?? name;
|
|
749
|
+
symbol = this.metadata.nativeToken?.symbol ?? symbol;
|
|
750
|
+
decimals = this.metadata.nativeToken?.decimals ?? decimals;
|
|
751
|
+
}
|
|
752
|
+
return {
|
|
753
|
+
address: tokenAddress,
|
|
754
|
+
owner: normalizeStarknetAddressSafe(owner),
|
|
755
|
+
tokenType,
|
|
756
|
+
mailboxAddress: normalizeStarknetAddressSafe(mailboxAddress),
|
|
757
|
+
ismAddress: normalizeStarknetAddressSafe(ismAddress),
|
|
758
|
+
hookAddress: normalizeStarknetAddressSafe(hookAddress),
|
|
759
|
+
denom,
|
|
760
|
+
name,
|
|
761
|
+
symbol,
|
|
762
|
+
decimals,
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
async getRemoteRouters(req) {
|
|
766
|
+
const token = this.withContract(StarknetContractName.HYP_ERC20, req.tokenAddress, this.provider, starknet_dist_0/* ContractType */.h$.TOKEN);
|
|
767
|
+
const domains = await callContract(token, 'domains');
|
|
768
|
+
(0,validation/* assert */.v)(Array.isArray(domains), 'Expected Starknet token domains array');
|
|
769
|
+
const remoteRouters = await Promise.all(domains.map(async (domainId) => {
|
|
770
|
+
const domain = toNumber(domainId);
|
|
771
|
+
const [routerAddress, gas] = await Promise.all([
|
|
772
|
+
callContract(token, 'routers', [domainId]),
|
|
773
|
+
callContract(token, 'destination_gas', [domainId]).catch(() => 0),
|
|
774
|
+
]);
|
|
775
|
+
return {
|
|
776
|
+
receiverDomainId: domain,
|
|
777
|
+
receiverAddress: normalizeRoutersAddress(routerAddress),
|
|
778
|
+
gas: toBigInt(gas).toString(),
|
|
779
|
+
};
|
|
780
|
+
}));
|
|
781
|
+
return {
|
|
782
|
+
address: normalizeStarknetAddressSafe(req.tokenAddress),
|
|
783
|
+
remoteRouters,
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
async getBridgedSupply(req) {
|
|
787
|
+
const tokenInfo = await this.getToken({ tokenAddress: req.tokenAddress });
|
|
788
|
+
const token = this.withContract(StarknetContractName.HYP_ERC20, req.tokenAddress, this.provider, starknet_dist_0/* ContractType */.h$.TOKEN);
|
|
789
|
+
if (tokenInfo.tokenType === dist/* AltVM.TokenType */.bx.ks.synthetic) {
|
|
790
|
+
return toBigInt(await callContract(token, 'total_supply'));
|
|
791
|
+
}
|
|
792
|
+
return this.getBalance({
|
|
793
|
+
address: req.tokenAddress,
|
|
794
|
+
denom: tokenInfo.denom,
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
async quoteRemoteTransfer(req) {
|
|
798
|
+
const token = this.withContract(StarknetContractName.HYP_ERC20, req.tokenAddress, this.provider, starknet_dist_0/* ContractType */.h$.TOKEN);
|
|
799
|
+
const quote = await callContract(token, 'quote_gas_payment', [
|
|
800
|
+
req.destinationDomainId,
|
|
801
|
+
]);
|
|
802
|
+
return {
|
|
803
|
+
denom: this.feeTokenAddress,
|
|
804
|
+
amount: toBigInt(quote),
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
// ### GET CORE TXS ###
|
|
808
|
+
async getCreateMailboxTransaction(req) {
|
|
809
|
+
return {
|
|
810
|
+
kind: 'deploy',
|
|
811
|
+
contractName: StarknetContractName.MAILBOX,
|
|
812
|
+
constructorArgs: [
|
|
813
|
+
req.domainId,
|
|
814
|
+
normalizeStarknetAddressSafe(req.signer),
|
|
815
|
+
normalizeStarknetAddressSafe(req.defaultIsmAddress ?? addresses/* ZERO_ADDRESS_HEX_32 */.qx),
|
|
816
|
+
normalizeStarknetAddressSafe(req.defaultHookAddress ?? addresses/* ZERO_ADDRESS_HEX_32 */.qx),
|
|
817
|
+
normalizeStarknetAddressSafe(req.requiredHookAddress ?? addresses/* ZERO_ADDRESS_HEX_32 */.qx),
|
|
818
|
+
],
|
|
819
|
+
};
|
|
820
|
+
}
|
|
821
|
+
async getSetDefaultIsmTransaction(req) {
|
|
822
|
+
const mailbox = this.withContract(StarknetContractName.MAILBOX, req.mailboxAddress);
|
|
823
|
+
return populateInvokeTx(mailbox, 'set_default_ism', [
|
|
824
|
+
normalizeStarknetAddressSafe(req.ismAddress),
|
|
825
|
+
]);
|
|
826
|
+
}
|
|
827
|
+
async getSetDefaultHookTransaction(req) {
|
|
828
|
+
const mailbox = this.withContract(StarknetContractName.MAILBOX, req.mailboxAddress);
|
|
829
|
+
return populateInvokeTx(mailbox, 'set_default_hook', [
|
|
830
|
+
normalizeStarknetAddressSafe(req.hookAddress),
|
|
831
|
+
]);
|
|
832
|
+
}
|
|
833
|
+
async getSetRequiredHookTransaction(req) {
|
|
834
|
+
const mailbox = this.withContract(StarknetContractName.MAILBOX, req.mailboxAddress);
|
|
835
|
+
return populateInvokeTx(mailbox, 'set_required_hook', [
|
|
836
|
+
normalizeStarknetAddressSafe(req.hookAddress),
|
|
837
|
+
]);
|
|
838
|
+
}
|
|
839
|
+
async getSetMailboxOwnerTransaction(req) {
|
|
840
|
+
const mailbox = this.withContract(StarknetContractName.MAILBOX, req.mailboxAddress);
|
|
841
|
+
return populateInvokeTx(mailbox, 'transfer_ownership', [
|
|
842
|
+
normalizeStarknetAddressSafe(req.newOwner),
|
|
843
|
+
]);
|
|
844
|
+
}
|
|
845
|
+
async getCreateMerkleRootMultisigIsmTransaction(req) {
|
|
846
|
+
return {
|
|
847
|
+
kind: 'deploy',
|
|
848
|
+
contractName: StarknetContractName.MERKLE_ROOT_MULTISIG_ISM,
|
|
849
|
+
constructorArgs: [
|
|
850
|
+
normalizeStarknetAddressSafe(req.signer),
|
|
851
|
+
req.validators.map((validator) => (0,addresses/* addressToBytes32 */.In)(validator)),
|
|
852
|
+
req.threshold,
|
|
853
|
+
],
|
|
854
|
+
};
|
|
855
|
+
}
|
|
856
|
+
async getCreateMessageIdMultisigIsmTransaction(req) {
|
|
857
|
+
return {
|
|
858
|
+
kind: 'deploy',
|
|
859
|
+
contractName: StarknetContractName.MESSAGE_ID_MULTISIG_ISM,
|
|
860
|
+
constructorArgs: [
|
|
861
|
+
normalizeStarknetAddressSafe(req.signer),
|
|
862
|
+
req.validators.map((validator) => (0,addresses/* addressToBytes32 */.In)(validator)),
|
|
863
|
+
req.threshold,
|
|
864
|
+
],
|
|
865
|
+
};
|
|
866
|
+
}
|
|
867
|
+
async getCreateRoutingIsmTransaction(req) {
|
|
868
|
+
return {
|
|
869
|
+
kind: 'deploy',
|
|
870
|
+
contractName: StarknetContractName.ROUTING_ISM,
|
|
871
|
+
constructorArgs: [normalizeStarknetAddressSafe(req.signer)],
|
|
872
|
+
};
|
|
873
|
+
}
|
|
874
|
+
async getSetRoutingIsmRouteTransaction(req) {
|
|
875
|
+
const routing = this.withContract(StarknetContractName.ROUTING_ISM, req.ismAddress);
|
|
876
|
+
return populateInvokeTx(routing, 'set', [
|
|
877
|
+
req.route.domainId,
|
|
878
|
+
normalizeStarknetAddressSafe(req.route.ismAddress),
|
|
879
|
+
]);
|
|
880
|
+
}
|
|
881
|
+
async getRemoveRoutingIsmRouteTransaction(req) {
|
|
882
|
+
const routing = this.withContract(StarknetContractName.ROUTING_ISM, req.ismAddress);
|
|
883
|
+
return populateInvokeTx(routing, 'remove', [req.domainId]);
|
|
884
|
+
}
|
|
885
|
+
async getSetRoutingIsmOwnerTransaction(req) {
|
|
886
|
+
const routing = this.withContract(StarknetContractName.ROUTING_ISM, req.ismAddress);
|
|
887
|
+
return populateInvokeTx(routing, 'transfer_ownership', [
|
|
888
|
+
normalizeStarknetAddressSafe(req.newOwner),
|
|
889
|
+
]);
|
|
890
|
+
}
|
|
891
|
+
async getCreateNoopIsmTransaction(_req) {
|
|
892
|
+
return {
|
|
893
|
+
kind: 'deploy',
|
|
894
|
+
contractName: StarknetContractName.NOOP_ISM,
|
|
895
|
+
constructorArgs: [],
|
|
896
|
+
};
|
|
897
|
+
}
|
|
898
|
+
async getCreateMerkleTreeHookTransaction(req) {
|
|
899
|
+
return {
|
|
900
|
+
kind: 'deploy',
|
|
901
|
+
contractName: StarknetContractName.MERKLE_TREE_HOOK,
|
|
902
|
+
constructorArgs: [
|
|
903
|
+
normalizeStarknetAddressSafe(req.mailboxAddress),
|
|
904
|
+
normalizeStarknetAddressSafe(req.signer),
|
|
905
|
+
],
|
|
906
|
+
};
|
|
907
|
+
}
|
|
908
|
+
async getCreateInterchainGasPaymasterHookTransaction(_req) {
|
|
909
|
+
throw new Error('interchainGasPaymaster hook type is unsupported on Starknet; use protocolFee hook type');
|
|
910
|
+
}
|
|
911
|
+
async getSetInterchainGasPaymasterHookOwnerTransaction(_req) {
|
|
912
|
+
throw new Error('interchainGasPaymaster hook type is unsupported on Starknet; use protocolFee hook type');
|
|
913
|
+
}
|
|
914
|
+
async getSetDestinationGasConfigTransaction(_req) {
|
|
915
|
+
throw new Error('interchainGasPaymaster hook type is unsupported on Starknet');
|
|
916
|
+
}
|
|
917
|
+
async getRemoveDestinationGasConfigTransaction(_req) {
|
|
918
|
+
throw new Error('interchainGasPaymaster hook type is unsupported on Starknet');
|
|
919
|
+
}
|
|
920
|
+
async getCreateNoopHookTransaction(_req) {
|
|
921
|
+
return {
|
|
922
|
+
kind: 'deploy',
|
|
923
|
+
contractName: StarknetContractName.HOOK,
|
|
924
|
+
constructorArgs: [],
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
async getCreateValidatorAnnounceTransaction(req) {
|
|
928
|
+
return {
|
|
929
|
+
kind: 'deploy',
|
|
930
|
+
contractName: StarknetContractName.VALIDATOR_ANNOUNCE,
|
|
931
|
+
constructorArgs: [
|
|
932
|
+
normalizeStarknetAddressSafe(req.mailboxAddress),
|
|
933
|
+
normalizeStarknetAddressSafe(req.signer),
|
|
934
|
+
],
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
async getCreateProxyAdminTransaction(_req) {
|
|
938
|
+
throw new Error('Proxy admin unsupported on Starknet');
|
|
939
|
+
}
|
|
940
|
+
async getSetProxyAdminOwnerTransaction(_req) {
|
|
941
|
+
throw new Error('Proxy admin unsupported on Starknet');
|
|
942
|
+
}
|
|
943
|
+
// ### GET WARP TXS ###
|
|
944
|
+
async getCreateNativeTokenTransaction(req) {
|
|
945
|
+
const mailbox = await this.getMailbox({
|
|
946
|
+
mailboxAddress: req.mailboxAddress,
|
|
947
|
+
});
|
|
948
|
+
return {
|
|
949
|
+
kind: 'deploy',
|
|
950
|
+
contractName: StarknetContractName.HYP_NATIVE,
|
|
951
|
+
contractType: starknet_dist_0/* ContractType */.h$.TOKEN,
|
|
952
|
+
constructorArgs: [
|
|
953
|
+
normalizeStarknetAddressSafe(req.mailboxAddress),
|
|
954
|
+
this.feeTokenAddress,
|
|
955
|
+
normalizeStarknetAddressSafe(mailbox.defaultHook),
|
|
956
|
+
normalizeStarknetAddressSafe(mailbox.defaultIsm),
|
|
957
|
+
normalizeStarknetAddressSafe(req.signer),
|
|
958
|
+
],
|
|
959
|
+
};
|
|
960
|
+
}
|
|
961
|
+
async getCreateCollateralTokenTransaction(req) {
|
|
962
|
+
const mailbox = await this.getMailbox({
|
|
963
|
+
mailboxAddress: req.mailboxAddress,
|
|
964
|
+
});
|
|
965
|
+
return {
|
|
966
|
+
kind: 'deploy',
|
|
967
|
+
contractName: StarknetContractName.HYP_ERC20_COLLATERAL,
|
|
968
|
+
contractType: starknet_dist_0/* ContractType */.h$.TOKEN,
|
|
969
|
+
constructorArgs: [
|
|
970
|
+
normalizeStarknetAddressSafe(req.mailboxAddress),
|
|
971
|
+
normalizeStarknetAddressSafe(req.collateralDenom),
|
|
972
|
+
normalizeStarknetAddressSafe(req.signer),
|
|
973
|
+
normalizeStarknetAddressSafe(mailbox.defaultHook),
|
|
974
|
+
normalizeStarknetAddressSafe(mailbox.defaultIsm),
|
|
975
|
+
],
|
|
976
|
+
};
|
|
977
|
+
}
|
|
978
|
+
async getCreateSyntheticTokenTransaction(req) {
|
|
979
|
+
const mailbox = await this.getMailbox({
|
|
980
|
+
mailboxAddress: req.mailboxAddress,
|
|
981
|
+
});
|
|
982
|
+
return {
|
|
983
|
+
kind: 'deploy',
|
|
984
|
+
contractName: StarknetContractName.HYP_ERC20,
|
|
985
|
+
contractType: starknet_dist_0/* ContractType */.h$.TOKEN,
|
|
986
|
+
constructorArgs: [
|
|
987
|
+
req.decimals,
|
|
988
|
+
normalizeStarknetAddressSafe(req.mailboxAddress),
|
|
989
|
+
0,
|
|
990
|
+
req.name,
|
|
991
|
+
req.denom,
|
|
992
|
+
normalizeStarknetAddressSafe(mailbox.defaultHook),
|
|
993
|
+
normalizeStarknetAddressSafe(mailbox.defaultIsm),
|
|
994
|
+
normalizeStarknetAddressSafe(req.signer),
|
|
995
|
+
],
|
|
996
|
+
};
|
|
997
|
+
}
|
|
998
|
+
async getSetTokenOwnerTransaction(req) {
|
|
999
|
+
const token = this.withContract(StarknetContractName.HYP_ERC20, req.tokenAddress, this.provider, starknet_dist_0/* ContractType */.h$.TOKEN);
|
|
1000
|
+
return populateInvokeTx(token, 'transfer_ownership', [
|
|
1001
|
+
normalizeStarknetAddressSafe(req.newOwner),
|
|
1002
|
+
]);
|
|
1003
|
+
}
|
|
1004
|
+
async getSetTokenIsmTransaction(req) {
|
|
1005
|
+
const token = this.withContract(StarknetContractName.HYP_ERC20, req.tokenAddress, this.provider, starknet_dist_0/* ContractType */.h$.TOKEN);
|
|
1006
|
+
return populateInvokeTx(token, 'set_interchain_security_module', [
|
|
1007
|
+
normalizeStarknetAddressSafe(req.ismAddress ?? addresses/* ZERO_ADDRESS_HEX_32 */.qx),
|
|
1008
|
+
]);
|
|
1009
|
+
}
|
|
1010
|
+
async getSetTokenHookTransaction(req) {
|
|
1011
|
+
const token = this.withContract(StarknetContractName.HYP_ERC20, req.tokenAddress, this.provider, starknet_dist_0/* ContractType */.h$.TOKEN);
|
|
1012
|
+
return populateInvokeTx(token, 'set_hook', [
|
|
1013
|
+
normalizeStarknetAddressSafe(req.hookAddress ?? addresses/* ZERO_ADDRESS_HEX_32 */.qx),
|
|
1014
|
+
]);
|
|
1015
|
+
}
|
|
1016
|
+
async getEnrollRemoteRouterTransaction(req) {
|
|
1017
|
+
const token = this.withContract(StarknetContractName.HYP_ERC20, req.tokenAddress, this.provider, starknet_dist_0/* ContractType */.h$.TOKEN);
|
|
1018
|
+
const receiverAddress = (0,addresses/* isZeroishAddress */.Hi)(req.remoteRouter.receiverAddress)
|
|
1019
|
+
? addresses/* ZERO_ADDRESS_HEX_32 */.qx
|
|
1020
|
+
: (0,addresses/* ensure0x */.Ho)(req.remoteRouter.receiverAddress);
|
|
1021
|
+
const noneOption = new starknet_dist/* CairoOption */.ci(starknet_dist/* CairoOptionVariant */.RV.None);
|
|
1022
|
+
const domainOption = new starknet_dist/* CairoOption */.ci(starknet_dist/* CairoOptionVariant */.RV.Some, req.remoteRouter.receiverDomainId);
|
|
1023
|
+
const gasOption = new starknet_dist/* CairoOption */.ci(starknet_dist/* CairoOptionVariant */.RV.Some, req.remoteRouter.gas);
|
|
1024
|
+
const [enrollCall, gasCall] = await Promise.all([
|
|
1025
|
+
this.populateInvokeCall(token, 'enroll_remote_router', [
|
|
1026
|
+
req.remoteRouter.receiverDomainId,
|
|
1027
|
+
receiverAddress,
|
|
1028
|
+
]),
|
|
1029
|
+
this.populateInvokeCall(token, 'set_destination_gas', [
|
|
1030
|
+
noneOption,
|
|
1031
|
+
domainOption,
|
|
1032
|
+
gasOption,
|
|
1033
|
+
]),
|
|
1034
|
+
]);
|
|
1035
|
+
return {
|
|
1036
|
+
kind: 'invoke',
|
|
1037
|
+
contractAddress: enrollCall.contractAddress,
|
|
1038
|
+
entrypoint: enrollCall.entrypoint,
|
|
1039
|
+
calldata: enrollCall.calldata,
|
|
1040
|
+
calls: [enrollCall, gasCall],
|
|
1041
|
+
};
|
|
1042
|
+
}
|
|
1043
|
+
async getUnenrollRemoteRouterTransaction(req) {
|
|
1044
|
+
const token = this.withContract(StarknetContractName.HYP_ERC20, req.tokenAddress, this.provider, starknet_dist_0/* ContractType */.h$.TOKEN);
|
|
1045
|
+
return populateInvokeTx(token, 'unenroll_remote_router', [
|
|
1046
|
+
req.receiverDomainId,
|
|
1047
|
+
]);
|
|
1048
|
+
}
|
|
1049
|
+
async getTransferTransaction(req) {
|
|
1050
|
+
const denom = req.denom
|
|
1051
|
+
? normalizeStarknetAddressSafe(req.denom)
|
|
1052
|
+
: this.feeTokenAddress;
|
|
1053
|
+
const token = this.withContract(StarknetContractName.ETHER, denom, this.provider, starknet_dist_0/* ContractType */.h$.TOKEN);
|
|
1054
|
+
return populateInvokeTx(token, 'transfer', [
|
|
1055
|
+
normalizeStarknetAddressSafe(req.recipient),
|
|
1056
|
+
req.amount,
|
|
1057
|
+
]);
|
|
1058
|
+
}
|
|
1059
|
+
async getRemoteTransferTransaction(req) {
|
|
1060
|
+
return this.buildRemoteTransferTransaction(req);
|
|
1061
|
+
}
|
|
1062
|
+
async buildRemoteTransferTransaction(req, tokenInfo) {
|
|
1063
|
+
if (req.customHookAddress || req.customHookMetadata) {
|
|
1064
|
+
throw new Error('Custom hook metadata/addresses are unsupported for Starknet transfer_remote in provider-sdk');
|
|
1065
|
+
}
|
|
1066
|
+
const tokenType = tokenInfo?.tokenType ?? (await this.determineTokenType(req.tokenAddress));
|
|
1067
|
+
const token = this.withContract(StarknetContractName.HYP_ERC20, req.tokenAddress, this.provider, starknet_dist_0/* ContractType */.h$.TOKEN);
|
|
1068
|
+
const noneOption = new starknet_dist/* CairoOption */.ci(starknet_dist/* CairoOptionVariant */.RV.None);
|
|
1069
|
+
let value;
|
|
1070
|
+
if (tokenType === dist/* AltVM.TokenType */.bx.ks.native) {
|
|
1071
|
+
value = toBigInt(req.amount) + toBigInt(req.maxFee.amount);
|
|
1072
|
+
}
|
|
1073
|
+
else if (tokenType === dist/* AltVM.TokenType */.bx.ks.collateral) {
|
|
1074
|
+
value = toBigInt(req.maxFee.amount);
|
|
1075
|
+
}
|
|
1076
|
+
else {
|
|
1077
|
+
value = toBigInt(req.maxFee.amount);
|
|
1078
|
+
}
|
|
1079
|
+
return populateInvokeTx(token, 'transfer_remote', [
|
|
1080
|
+
req.destinationDomainId,
|
|
1081
|
+
(0,addresses/* addressToBytes32 */.In)(req.recipient),
|
|
1082
|
+
req.amount,
|
|
1083
|
+
value,
|
|
1084
|
+
noneOption,
|
|
1085
|
+
noneOption,
|
|
1086
|
+
]);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
//# sourceMappingURL=provider.js.map
|
|
1090
|
+
;// CONCATENATED MODULE: ../starknet-sdk/dist/clients/signer.js
|
|
1091
|
+
|
|
1092
|
+
|
|
1093
|
+
|
|
1094
|
+
|
|
1095
|
+
|
|
1096
|
+
|
|
1097
|
+
class StarknetSigner extends StarknetProvider {
|
|
1098
|
+
signerAddress;
|
|
1099
|
+
static readStringField(value, key) {
|
|
1100
|
+
if (!value || typeof value !== 'object')
|
|
1101
|
+
return undefined;
|
|
1102
|
+
const candidate = Reflect.get(value, key);
|
|
1103
|
+
return typeof candidate === 'string' ? candidate : undefined;
|
|
1104
|
+
}
|
|
1105
|
+
static async connectWithSigner(rpcUrls, privateKey, extraParams) {
|
|
1106
|
+
(0,validation/* assert */.v)(extraParams?.metadata, 'metadata missing for Starknet signer');
|
|
1107
|
+
const metadata = extraParams.metadata;
|
|
1108
|
+
const accountAddress = extraParams.accountAddress;
|
|
1109
|
+
(0,validation/* assert */.v)(accountAddress, 'accountAddress missing for Starknet signer');
|
|
1110
|
+
(0,validation/* assert */.v)(privateKey, 'private key missing for Starknet signer');
|
|
1111
|
+
const provider = StarknetProvider.connect(rpcUrls, metadata.chainId, {
|
|
1112
|
+
metadata,
|
|
1113
|
+
});
|
|
1114
|
+
return new StarknetSigner(provider.getRawProvider(), metadata, rpcUrls, normalizeStarknetAddressSafe(accountAddress), privateKey);
|
|
1115
|
+
}
|
|
1116
|
+
account;
|
|
1117
|
+
constructor(provider, metadata, rpcUrls, signerAddress, privateKey) {
|
|
1118
|
+
super(provider, metadata, rpcUrls);
|
|
1119
|
+
this.signerAddress = signerAddress;
|
|
1120
|
+
this.account = new starknet_dist/* Account */.gD(provider, signerAddress, privateKey);
|
|
1121
|
+
}
|
|
1122
|
+
get accountAddress() {
|
|
1123
|
+
return this.signerAddress;
|
|
1124
|
+
}
|
|
1125
|
+
getSignerAddress() {
|
|
1126
|
+
return this.signerAddress;
|
|
1127
|
+
}
|
|
1128
|
+
supportsTransactionBatching() {
|
|
1129
|
+
return true;
|
|
1130
|
+
}
|
|
1131
|
+
async transactionToPrintableJson(transaction) {
|
|
1132
|
+
return transaction;
|
|
1133
|
+
}
|
|
1134
|
+
assertSuccessfulReceipt(transactionHash, receipt) {
|
|
1135
|
+
if (receipt.isSuccess())
|
|
1136
|
+
return;
|
|
1137
|
+
if (receipt.isReverted()) {
|
|
1138
|
+
const receiptValue = receipt.value;
|
|
1139
|
+
const revertReason = typeof receiptValue === 'object' &&
|
|
1140
|
+
typeof Reflect.get(receiptValue, 'revert_reason') === 'string'
|
|
1141
|
+
? Reflect.get(receiptValue, 'revert_reason')
|
|
1142
|
+
: undefined;
|
|
1143
|
+
const details = typeof revertReason === 'string' && revertReason.length > 0
|
|
1144
|
+
? `: ${revertReason}`
|
|
1145
|
+
: '';
|
|
1146
|
+
(0,validation/* assert */.v)(false, `Starknet transaction ${transactionHash} reverted${details}`);
|
|
1147
|
+
}
|
|
1148
|
+
if (receipt.isError()) {
|
|
1149
|
+
(0,validation/* assert */.v)(false, `Starknet transaction ${transactionHash} failed: ${receipt.value.message}`);
|
|
1150
|
+
}
|
|
1151
|
+
(0,validation/* assert */.v)(false, `Starknet transaction ${transactionHash} failed with status ${receipt.statusReceipt}`);
|
|
1152
|
+
}
|
|
1153
|
+
async deployContract(params) {
|
|
1154
|
+
const compiledContract = (0,starknet_dist_0/* getCompiledContract */.wm)(params.contractName, params.contractType);
|
|
1155
|
+
const compiledClassHash = (0,starknet_dist_0/* getCompiledClassHash */.mU)(params.contractName, params.contractType);
|
|
1156
|
+
const contractArtifact = (0,starknet_dist_0/* getContractArtifact */.tt)(params.contractName, params.contractType);
|
|
1157
|
+
(0,validation/* assert */.v)(contractArtifact.compiled_contract_class, `Missing compiled_contract_class for Starknet contract ${params.contractName}`);
|
|
1158
|
+
(0,validation/* assert */.v)(compiledClassHash, `Missing compiledClassHash for Starknet contract ${params.contractName}`);
|
|
1159
|
+
const hasConstructor = compiledContract.abi.some((item) => item.type === 'constructor');
|
|
1160
|
+
const constructorCalldata = hasConstructor
|
|
1161
|
+
? new starknet_dist/* CallData */.fP(compiledContract.abi).compile('constructor', params.constructorArgs)
|
|
1162
|
+
: undefined;
|
|
1163
|
+
const factory = new starknet_dist/* ContractFactory */.PM({
|
|
1164
|
+
compiledContract,
|
|
1165
|
+
casm: contractArtifact.compiled_contract_class,
|
|
1166
|
+
compiledClassHash,
|
|
1167
|
+
account: this.account,
|
|
1168
|
+
});
|
|
1169
|
+
const deployment = constructorCalldata === undefined
|
|
1170
|
+
? await factory.deploy()
|
|
1171
|
+
: await factory.deploy(constructorCalldata);
|
|
1172
|
+
const transactionHash = deployment.deployTransactionHash ??
|
|
1173
|
+
StarknetSigner.readStringField(deployment, 'transaction_hash');
|
|
1174
|
+
(0,validation/* assert */.v)(transactionHash, 'missing Starknet deploy transaction hash');
|
|
1175
|
+
const rawAddress = deployment.address ||
|
|
1176
|
+
StarknetSigner.readStringField(deployment, 'contract_address');
|
|
1177
|
+
(0,validation/* assert */.v)(rawAddress, 'missing Starknet deploy contract address');
|
|
1178
|
+
const address = normalizeStarknetAddressSafe(rawAddress);
|
|
1179
|
+
const receipt = await this.account.waitForTransaction(transactionHash);
|
|
1180
|
+
this.assertSuccessfulReceipt(transactionHash, receipt);
|
|
1181
|
+
return {
|
|
1182
|
+
transactionHash,
|
|
1183
|
+
contractAddress: address,
|
|
1184
|
+
receipt,
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1187
|
+
async sendAndConfirmTransaction(transaction) {
|
|
1188
|
+
if (transaction.kind === 'deploy') {
|
|
1189
|
+
const deployed = await this.deployContract({
|
|
1190
|
+
contractName: transaction.contractName,
|
|
1191
|
+
constructorArgs: transaction.constructorArgs,
|
|
1192
|
+
contractType: transaction.contractType,
|
|
1193
|
+
});
|
|
1194
|
+
return {
|
|
1195
|
+
transactionHash: deployed.transactionHash,
|
|
1196
|
+
contractAddress: deployed.contractAddress,
|
|
1197
|
+
receipt: deployed.receipt,
|
|
1198
|
+
};
|
|
1199
|
+
}
|
|
1200
|
+
const calls = transaction.calls ?? [
|
|
1201
|
+
{
|
|
1202
|
+
contractAddress: transaction.contractAddress,
|
|
1203
|
+
entrypoint: transaction.entrypoint,
|
|
1204
|
+
calldata: transaction.calldata,
|
|
1205
|
+
},
|
|
1206
|
+
];
|
|
1207
|
+
const response = await this.account.execute(calls);
|
|
1208
|
+
const transactionHash = response.transaction_hash;
|
|
1209
|
+
const receipt = await this.account.waitForTransaction(transactionHash);
|
|
1210
|
+
this.assertSuccessfulReceipt(transactionHash, receipt);
|
|
1211
|
+
return { transactionHash, receipt };
|
|
1212
|
+
}
|
|
1213
|
+
async sendAndConfirmBatchTransactions(transactions) {
|
|
1214
|
+
const hasDeploy = transactions.some((tx) => tx.kind === 'deploy');
|
|
1215
|
+
if (hasDeploy) {
|
|
1216
|
+
throw new Error('Batch transactions with deploy operations are unsupported on Starknet signer');
|
|
1217
|
+
}
|
|
1218
|
+
const invokeTransactions = transactions.filter((tx) => tx.kind === 'invoke');
|
|
1219
|
+
(0,validation/* assert */.v)(invokeTransactions.length === transactions.length, 'Batch transactions with non-invoke operations are unsupported on Starknet signer');
|
|
1220
|
+
const calls = invokeTransactions.flatMap((invoke) => invoke.calls ?? [
|
|
1221
|
+
{
|
|
1222
|
+
contractAddress: invoke.contractAddress,
|
|
1223
|
+
entrypoint: invoke.entrypoint,
|
|
1224
|
+
calldata: invoke.calldata,
|
|
1225
|
+
},
|
|
1226
|
+
]);
|
|
1227
|
+
const response = await this.account.execute(calls);
|
|
1228
|
+
const transactionHash = response.transaction_hash;
|
|
1229
|
+
const receipt = await this.account.waitForTransaction(transactionHash);
|
|
1230
|
+
this.assertSuccessfulReceipt(transactionHash, receipt);
|
|
1231
|
+
return { transactionHash, receipt };
|
|
1232
|
+
}
|
|
1233
|
+
// ### TX CORE ###
|
|
1234
|
+
async estimateTransactionFee(req) {
|
|
1235
|
+
(0,validation/* assert */.v)(req.transaction.kind === 'invoke', 'Starknet transaction fee estimation only supports invoke transactions');
|
|
1236
|
+
const calls = req.transaction.calls ?? [
|
|
1237
|
+
{
|
|
1238
|
+
contractAddress: req.transaction.contractAddress,
|
|
1239
|
+
entrypoint: req.transaction.entrypoint,
|
|
1240
|
+
calldata: req.transaction.calldata,
|
|
1241
|
+
},
|
|
1242
|
+
];
|
|
1243
|
+
const estimate = await this.account.estimateInvokeFee(calls);
|
|
1244
|
+
const gasUnits = estimate.l1_gas_consumed +
|
|
1245
|
+
estimate.l1_data_gas_consumed +
|
|
1246
|
+
(estimate.l2_gas_consumed ?? 0n);
|
|
1247
|
+
return {
|
|
1248
|
+
gasUnits,
|
|
1249
|
+
gasPrice: Number(estimate.l1_gas_price),
|
|
1250
|
+
fee: estimate.overall_fee,
|
|
1251
|
+
};
|
|
1252
|
+
}
|
|
1253
|
+
async createMailbox(req) {
|
|
1254
|
+
if (req.proxyAdminAddress) {
|
|
1255
|
+
throw new Error('Proxy admin unsupported on Starknet');
|
|
1256
|
+
}
|
|
1257
|
+
const defaultIsmAddress = req.defaultIsmAddress ?? (await this.createNoopIsm({})).ismAddress;
|
|
1258
|
+
const defaultHookAddress = req.defaultHookAddress ??
|
|
1259
|
+
(await this.createNoopHook({
|
|
1260
|
+
// Hook deployment currently ignores mailboxAddress on Starknet.
|
|
1261
|
+
mailboxAddress: this.signerAddress,
|
|
1262
|
+
})).hookAddress;
|
|
1263
|
+
// Keep required hooks opt-in. Auto-deploying a noop required hook would
|
|
1264
|
+
// change mailbox semantics for callers that intentionally leave it unset.
|
|
1265
|
+
const requiredHookAddress = req.requiredHookAddress;
|
|
1266
|
+
const tx = await this.getCreateMailboxTransaction({
|
|
1267
|
+
signer: this.signerAddress,
|
|
1268
|
+
...req,
|
|
1269
|
+
defaultIsmAddress,
|
|
1270
|
+
defaultHookAddress,
|
|
1271
|
+
requiredHookAddress,
|
|
1272
|
+
});
|
|
1273
|
+
const receipt = await this.sendAndConfirmTransaction(tx);
|
|
1274
|
+
(0,validation/* assert */.v)(receipt.contractAddress, 'failed to get Starknet mailbox address');
|
|
1275
|
+
return { mailboxAddress: receipt.contractAddress };
|
|
1276
|
+
}
|
|
1277
|
+
async setDefaultIsm(req) {
|
|
1278
|
+
const tx = await this.getSetDefaultIsmTransaction({
|
|
1279
|
+
signer: this.signerAddress,
|
|
1280
|
+
...req,
|
|
1281
|
+
});
|
|
1282
|
+
await this.sendAndConfirmTransaction(tx);
|
|
1283
|
+
return { ismAddress: req.ismAddress };
|
|
1284
|
+
}
|
|
1285
|
+
async setDefaultHook(req) {
|
|
1286
|
+
const tx = await this.getSetDefaultHookTransaction({
|
|
1287
|
+
signer: this.signerAddress,
|
|
1288
|
+
...req,
|
|
1289
|
+
});
|
|
1290
|
+
await this.sendAndConfirmTransaction(tx);
|
|
1291
|
+
return { hookAddress: req.hookAddress };
|
|
1292
|
+
}
|
|
1293
|
+
async setRequiredHook(req) {
|
|
1294
|
+
const tx = await this.getSetRequiredHookTransaction({
|
|
1295
|
+
signer: this.signerAddress,
|
|
1296
|
+
...req,
|
|
1297
|
+
});
|
|
1298
|
+
await this.sendAndConfirmTransaction(tx);
|
|
1299
|
+
return { hookAddress: req.hookAddress };
|
|
1300
|
+
}
|
|
1301
|
+
async setMailboxOwner(req) {
|
|
1302
|
+
const tx = await this.getSetMailboxOwnerTransaction({
|
|
1303
|
+
signer: this.signerAddress,
|
|
1304
|
+
...req,
|
|
1305
|
+
});
|
|
1306
|
+
await this.sendAndConfirmTransaction(tx);
|
|
1307
|
+
return { newOwner: req.newOwner };
|
|
1308
|
+
}
|
|
1309
|
+
async createMerkleRootMultisigIsm(req) {
|
|
1310
|
+
const tx = await this.getCreateMerkleRootMultisigIsmTransaction({
|
|
1311
|
+
signer: this.signerAddress,
|
|
1312
|
+
...req,
|
|
1313
|
+
});
|
|
1314
|
+
const receipt = await this.sendAndConfirmTransaction(tx);
|
|
1315
|
+
(0,validation/* assert */.v)(receipt.contractAddress, 'failed to get Starknet ISM address');
|
|
1316
|
+
return { ismAddress: receipt.contractAddress };
|
|
1317
|
+
}
|
|
1318
|
+
async createMessageIdMultisigIsm(req) {
|
|
1319
|
+
const tx = await this.getCreateMessageIdMultisigIsmTransaction({
|
|
1320
|
+
signer: this.signerAddress,
|
|
1321
|
+
...req,
|
|
1322
|
+
});
|
|
1323
|
+
const receipt = await this.sendAndConfirmTransaction(tx);
|
|
1324
|
+
(0,validation/* assert */.v)(receipt.contractAddress, 'failed to get Starknet ISM address');
|
|
1325
|
+
return { ismAddress: receipt.contractAddress };
|
|
1326
|
+
}
|
|
1327
|
+
async createRoutingIsm(req) {
|
|
1328
|
+
const tx = await this.getCreateRoutingIsmTransaction({
|
|
1329
|
+
signer: this.signerAddress,
|
|
1330
|
+
...req,
|
|
1331
|
+
});
|
|
1332
|
+
const receipt = await this.sendAndConfirmTransaction(tx);
|
|
1333
|
+
const ismAddress = receipt.contractAddress;
|
|
1334
|
+
(0,validation/* assert */.v)(ismAddress, 'failed to get Starknet routing ISM address');
|
|
1335
|
+
if (req.routes.length > 0) {
|
|
1336
|
+
const routeTxs = await Promise.all(req.routes.map(async (route) => this.getSetRoutingIsmRouteTransaction({
|
|
1337
|
+
signer: this.signerAddress,
|
|
1338
|
+
ismAddress,
|
|
1339
|
+
route,
|
|
1340
|
+
})));
|
|
1341
|
+
await this.sendAndConfirmBatchTransactions(routeTxs);
|
|
1342
|
+
}
|
|
1343
|
+
return { ismAddress };
|
|
1344
|
+
}
|
|
1345
|
+
async setRoutingIsmRoute(req) {
|
|
1346
|
+
const tx = await this.getSetRoutingIsmRouteTransaction({
|
|
1347
|
+
signer: this.signerAddress,
|
|
1348
|
+
...req,
|
|
1349
|
+
});
|
|
1350
|
+
await this.sendAndConfirmTransaction(tx);
|
|
1351
|
+
return { route: req.route };
|
|
1352
|
+
}
|
|
1353
|
+
async removeRoutingIsmRoute(req) {
|
|
1354
|
+
const tx = await this.getRemoveRoutingIsmRouteTransaction({
|
|
1355
|
+
signer: this.signerAddress,
|
|
1356
|
+
...req,
|
|
1357
|
+
});
|
|
1358
|
+
await this.sendAndConfirmTransaction(tx);
|
|
1359
|
+
return { domainId: req.domainId };
|
|
1360
|
+
}
|
|
1361
|
+
async setRoutingIsmOwner(req) {
|
|
1362
|
+
const tx = await this.getSetRoutingIsmOwnerTransaction({
|
|
1363
|
+
signer: this.signerAddress,
|
|
1364
|
+
...req,
|
|
1365
|
+
});
|
|
1366
|
+
await this.sendAndConfirmTransaction(tx);
|
|
1367
|
+
return { newOwner: req.newOwner };
|
|
1368
|
+
}
|
|
1369
|
+
async createNoopIsm(req) {
|
|
1370
|
+
const tx = await this.getCreateNoopIsmTransaction({
|
|
1371
|
+
signer: this.signerAddress,
|
|
1372
|
+
...req,
|
|
1373
|
+
});
|
|
1374
|
+
const receipt = await this.sendAndConfirmTransaction(tx);
|
|
1375
|
+
(0,validation/* assert */.v)(receipt.contractAddress, 'failed to get Starknet noop ISM address');
|
|
1376
|
+
return { ismAddress: receipt.contractAddress };
|
|
1377
|
+
}
|
|
1378
|
+
async createMerkleTreeHook(req) {
|
|
1379
|
+
const tx = await this.getCreateMerkleTreeHookTransaction({
|
|
1380
|
+
signer: this.signerAddress,
|
|
1381
|
+
...req,
|
|
1382
|
+
});
|
|
1383
|
+
const receipt = await this.sendAndConfirmTransaction(tx);
|
|
1384
|
+
(0,validation/* assert */.v)(receipt.contractAddress, 'failed to get Starknet hook address');
|
|
1385
|
+
return { hookAddress: receipt.contractAddress };
|
|
1386
|
+
}
|
|
1387
|
+
async createInterchainGasPaymasterHook(req) {
|
|
1388
|
+
const tx = await this.getCreateInterchainGasPaymasterHookTransaction({
|
|
1389
|
+
signer: this.signerAddress,
|
|
1390
|
+
...req,
|
|
1391
|
+
});
|
|
1392
|
+
const receipt = await this.sendAndConfirmTransaction(tx);
|
|
1393
|
+
(0,validation/* assert */.v)(receipt.contractAddress, 'failed to get Starknet interchainGasPaymaster hook');
|
|
1394
|
+
return { hookAddress: receipt.contractAddress };
|
|
1395
|
+
}
|
|
1396
|
+
async setInterchainGasPaymasterHookOwner(req) {
|
|
1397
|
+
const tx = await this.getSetInterchainGasPaymasterHookOwnerTransaction({
|
|
1398
|
+
signer: this.signerAddress,
|
|
1399
|
+
...req,
|
|
1400
|
+
});
|
|
1401
|
+
await this.sendAndConfirmTransaction(tx);
|
|
1402
|
+
return { newOwner: req.newOwner };
|
|
1403
|
+
}
|
|
1404
|
+
async setDestinationGasConfig(req) {
|
|
1405
|
+
const tx = await this.getSetDestinationGasConfigTransaction({
|
|
1406
|
+
signer: this.signerAddress,
|
|
1407
|
+
...req,
|
|
1408
|
+
});
|
|
1409
|
+
await this.sendAndConfirmTransaction(tx);
|
|
1410
|
+
return { destinationGasConfig: req.destinationGasConfig };
|
|
1411
|
+
}
|
|
1412
|
+
async removeDestinationGasConfig(req) {
|
|
1413
|
+
const tx = await this.getRemoveDestinationGasConfigTransaction({
|
|
1414
|
+
signer: this.signerAddress,
|
|
1415
|
+
...req,
|
|
1416
|
+
});
|
|
1417
|
+
await this.sendAndConfirmTransaction(tx);
|
|
1418
|
+
return { remoteDomainId: req.remoteDomainId };
|
|
1419
|
+
}
|
|
1420
|
+
async createNoopHook(req) {
|
|
1421
|
+
const tx = await this.getCreateNoopHookTransaction({
|
|
1422
|
+
signer: this.signerAddress,
|
|
1423
|
+
...req,
|
|
1424
|
+
});
|
|
1425
|
+
const receipt = await this.sendAndConfirmTransaction(tx);
|
|
1426
|
+
(0,validation/* assert */.v)(receipt.contractAddress, 'failed to get Starknet noop hook');
|
|
1427
|
+
return { hookAddress: receipt.contractAddress };
|
|
1428
|
+
}
|
|
1429
|
+
async createValidatorAnnounce(req) {
|
|
1430
|
+
const tx = await this.getCreateValidatorAnnounceTransaction({
|
|
1431
|
+
signer: this.signerAddress,
|
|
1432
|
+
...req,
|
|
1433
|
+
});
|
|
1434
|
+
const receipt = await this.sendAndConfirmTransaction(tx);
|
|
1435
|
+
(0,validation/* assert */.v)(receipt.contractAddress, 'failed to get Starknet validator announce address');
|
|
1436
|
+
return { validatorAnnounceId: receipt.contractAddress };
|
|
1437
|
+
}
|
|
1438
|
+
async createProxyAdmin(_req) {
|
|
1439
|
+
throw new Error('Proxy admin unsupported on Starknet');
|
|
1440
|
+
}
|
|
1441
|
+
async setProxyAdminOwner(_req) {
|
|
1442
|
+
throw new Error('Proxy admin unsupported on Starknet');
|
|
1443
|
+
}
|
|
1444
|
+
// ### TX WARP ###
|
|
1445
|
+
async createNativeToken(req) {
|
|
1446
|
+
if (req.proxyAdminAddress) {
|
|
1447
|
+
throw new Error('Proxy admin unsupported on Starknet');
|
|
1448
|
+
}
|
|
1449
|
+
const tx = await this.getCreateNativeTokenTransaction({
|
|
1450
|
+
signer: this.signerAddress,
|
|
1451
|
+
...req,
|
|
1452
|
+
});
|
|
1453
|
+
const receipt = await this.sendAndConfirmTransaction(tx);
|
|
1454
|
+
(0,validation/* assert */.v)(receipt.contractAddress, 'failed to get Starknet warp token');
|
|
1455
|
+
return { tokenAddress: receipt.contractAddress };
|
|
1456
|
+
}
|
|
1457
|
+
async createCollateralToken(req) {
|
|
1458
|
+
if (req.proxyAdminAddress) {
|
|
1459
|
+
throw new Error('Proxy admin unsupported on Starknet');
|
|
1460
|
+
}
|
|
1461
|
+
const tx = await this.getCreateCollateralTokenTransaction({
|
|
1462
|
+
signer: this.signerAddress,
|
|
1463
|
+
...req,
|
|
1464
|
+
});
|
|
1465
|
+
const receipt = await this.sendAndConfirmTransaction(tx);
|
|
1466
|
+
(0,validation/* assert */.v)(receipt.contractAddress, 'failed to get Starknet warp token');
|
|
1467
|
+
return { tokenAddress: receipt.contractAddress };
|
|
1468
|
+
}
|
|
1469
|
+
async createSyntheticToken(req) {
|
|
1470
|
+
if (req.proxyAdminAddress) {
|
|
1471
|
+
throw new Error('Proxy admin unsupported on Starknet');
|
|
1472
|
+
}
|
|
1473
|
+
const tx = await this.getCreateSyntheticTokenTransaction({
|
|
1474
|
+
signer: this.signerAddress,
|
|
1475
|
+
...req,
|
|
1476
|
+
});
|
|
1477
|
+
const receipt = await this.sendAndConfirmTransaction(tx);
|
|
1478
|
+
(0,validation/* assert */.v)(receipt.contractAddress, 'failed to get Starknet warp token');
|
|
1479
|
+
return { tokenAddress: receipt.contractAddress };
|
|
1480
|
+
}
|
|
1481
|
+
async setTokenOwner(req) {
|
|
1482
|
+
const tx = await this.getSetTokenOwnerTransaction({
|
|
1483
|
+
signer: this.signerAddress,
|
|
1484
|
+
...req,
|
|
1485
|
+
});
|
|
1486
|
+
await this.sendAndConfirmTransaction(tx);
|
|
1487
|
+
return { newOwner: req.newOwner };
|
|
1488
|
+
}
|
|
1489
|
+
async setTokenIsm(req) {
|
|
1490
|
+
const tx = await this.getSetTokenIsmTransaction({
|
|
1491
|
+
signer: this.signerAddress,
|
|
1492
|
+
...req,
|
|
1493
|
+
});
|
|
1494
|
+
await this.sendAndConfirmTransaction(tx);
|
|
1495
|
+
return { ismAddress: req.ismAddress ?? addresses/* ZERO_ADDRESS_HEX_32 */.qx };
|
|
1496
|
+
}
|
|
1497
|
+
async setTokenHook(req) {
|
|
1498
|
+
const tx = await this.getSetTokenHookTransaction({
|
|
1499
|
+
signer: this.signerAddress,
|
|
1500
|
+
...req,
|
|
1501
|
+
});
|
|
1502
|
+
await this.sendAndConfirmTransaction(tx);
|
|
1503
|
+
return { hookAddress: req.hookAddress ?? addresses/* ZERO_ADDRESS_HEX_32 */.qx };
|
|
1504
|
+
}
|
|
1505
|
+
async enrollRemoteRouter(req) {
|
|
1506
|
+
const tx = await this.getEnrollRemoteRouterTransaction({
|
|
1507
|
+
signer: this.signerAddress,
|
|
1508
|
+
...req,
|
|
1509
|
+
});
|
|
1510
|
+
await this.sendAndConfirmTransaction(tx);
|
|
1511
|
+
return { receiverDomainId: req.remoteRouter.receiverDomainId };
|
|
1512
|
+
}
|
|
1513
|
+
async unenrollRemoteRouter(req) {
|
|
1514
|
+
const tx = await this.getUnenrollRemoteRouterTransaction({
|
|
1515
|
+
signer: this.signerAddress,
|
|
1516
|
+
...req,
|
|
1517
|
+
});
|
|
1518
|
+
await this.sendAndConfirmTransaction(tx);
|
|
1519
|
+
return { receiverDomainId: req.receiverDomainId };
|
|
1520
|
+
}
|
|
1521
|
+
async transfer(req) {
|
|
1522
|
+
const tx = await this.getTransferTransaction({
|
|
1523
|
+
signer: this.signerAddress,
|
|
1524
|
+
...req,
|
|
1525
|
+
});
|
|
1526
|
+
await this.sendAndConfirmTransaction(tx);
|
|
1527
|
+
return { recipient: req.recipient };
|
|
1528
|
+
}
|
|
1529
|
+
async remoteTransfer(req) {
|
|
1530
|
+
const token = await this.getToken({ tokenAddress: req.tokenAddress });
|
|
1531
|
+
const tokenType = token.tokenType;
|
|
1532
|
+
const tx = await this.buildRemoteTransferTransaction({
|
|
1533
|
+
signer: this.signerAddress,
|
|
1534
|
+
...req,
|
|
1535
|
+
}, token);
|
|
1536
|
+
const batchedTxs = [];
|
|
1537
|
+
if (tokenType === dist/* AltVM.TokenType */.bx.ks.native) {
|
|
1538
|
+
const nativeToken = getStarknetContract(StarknetContractName.ETHER, token.denom, this.provider, starknet_dist_0/* ContractType */.h$.TOKEN);
|
|
1539
|
+
batchedTxs.push(await populateInvokeTx(nativeToken, 'approve', [
|
|
1540
|
+
normalizeStarknetAddressSafe(req.tokenAddress),
|
|
1541
|
+
toBigInt(req.amount) + toBigInt(req.maxFee.amount),
|
|
1542
|
+
]));
|
|
1543
|
+
}
|
|
1544
|
+
else if (tokenType === dist/* AltVM.TokenType */.bx.ks.collateral) {
|
|
1545
|
+
const collateralToken = getStarknetContract(StarknetContractName.ETHER, token.denom, this.provider, starknet_dist_0/* ContractType */.h$.TOKEN);
|
|
1546
|
+
const collateralDenom = normalizeStarknetAddressSafe(token.denom);
|
|
1547
|
+
const feeDenom = normalizeStarknetAddressSafe(req.maxFee.denom);
|
|
1548
|
+
const approvalAmount = collateralDenom === feeDenom
|
|
1549
|
+
? toBigInt(req.amount) + toBigInt(req.maxFee.amount)
|
|
1550
|
+
: toBigInt(req.amount);
|
|
1551
|
+
batchedTxs.push(await populateInvokeTx(collateralToken, 'approve', [
|
|
1552
|
+
normalizeStarknetAddressSafe(req.tokenAddress),
|
|
1553
|
+
approvalAmount,
|
|
1554
|
+
]));
|
|
1555
|
+
}
|
|
1556
|
+
const usesSharedCollateralAndFeeToken = tokenType === dist/* AltVM.TokenType */.bx.ks.collateral &&
|
|
1557
|
+
normalizeStarknetAddressSafe(token.denom) ===
|
|
1558
|
+
normalizeStarknetAddressSafe(req.maxFee.denom);
|
|
1559
|
+
if (tokenType !== dist/* AltVM.TokenType */.bx.ks.native &&
|
|
1560
|
+
!usesSharedCollateralAndFeeToken) {
|
|
1561
|
+
const feeToken = getStarknetContract(StarknetContractName.ETHER, req.maxFee.denom, this.provider, starknet_dist_0/* ContractType */.h$.TOKEN);
|
|
1562
|
+
batchedTxs.push(await populateInvokeTx(feeToken, 'approve', [
|
|
1563
|
+
normalizeStarknetAddressSafe(req.tokenAddress),
|
|
1564
|
+
toBigInt(req.maxFee.amount),
|
|
1565
|
+
]));
|
|
1566
|
+
}
|
|
1567
|
+
if (batchedTxs.length > 0) {
|
|
1568
|
+
await this.sendAndConfirmBatchTransactions([...batchedTxs, tx]);
|
|
1569
|
+
}
|
|
1570
|
+
else {
|
|
1571
|
+
await this.sendAndConfirmTransaction(tx);
|
|
1572
|
+
}
|
|
1573
|
+
return { tokenAddress: req.tokenAddress };
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
//# sourceMappingURL=signer.js.map
|
|
1577
|
+
;// CONCATENATED MODULE: ../starknet-sdk/dist/hook/interchain-gas-paymaster-hook-artifact-manager.js
|
|
1578
|
+
|
|
1579
|
+
|
|
1580
|
+
function createStarknetInterchainGasPaymasterHookReader() {
|
|
1581
|
+
return {
|
|
1582
|
+
read: async () => {
|
|
1583
|
+
return (0,hook/* throwUnsupportedHookType */.DD)(dist/* AltVM.HookType */.bx.WD.INTERCHAIN_GAS_PAYMASTER, 'Starknet');
|
|
1584
|
+
},
|
|
1585
|
+
};
|
|
1586
|
+
}
|
|
1587
|
+
function createStarknetInterchainGasPaymasterHookWriter() {
|
|
1588
|
+
return {
|
|
1589
|
+
read: async () => {
|
|
1590
|
+
return (0,hook/* throwUnsupportedHookType */.DD)(dist/* AltVM.HookType */.bx.WD.INTERCHAIN_GAS_PAYMASTER, 'Starknet');
|
|
1591
|
+
},
|
|
1592
|
+
create: async () => {
|
|
1593
|
+
return (0,hook/* throwUnsupportedHookType */.DD)(dist/* AltVM.HookType */.bx.WD.INTERCHAIN_GAS_PAYMASTER, 'Starknet');
|
|
1594
|
+
},
|
|
1595
|
+
update: async () => {
|
|
1596
|
+
return (0,hook/* throwUnsupportedHookType */.DD)(dist/* AltVM.HookType */.bx.WD.INTERCHAIN_GAS_PAYMASTER, 'Starknet');
|
|
1597
|
+
},
|
|
1598
|
+
};
|
|
1599
|
+
}
|
|
1600
|
+
//# sourceMappingURL=interchain-gas-paymaster-hook-artifact-manager.js.map
|
|
1601
|
+
// EXTERNAL MODULE: ../provider-sdk/dist/artifact.js
|
|
1602
|
+
var dist_artifact = __webpack_require__(4287);
|
|
1603
|
+
;// CONCATENATED MODULE: ../starknet-sdk/dist/hook/merkle-tree-hook-artifact-manager.js
|
|
1604
|
+
|
|
1605
|
+
|
|
1606
|
+
|
|
1607
|
+
|
|
1608
|
+
class StarknetMerkleTreeHookReader {
|
|
1609
|
+
async read(address) {
|
|
1610
|
+
return {
|
|
1611
|
+
artifactState: dist_artifact/* ArtifactState */.O2.DEPLOYED,
|
|
1612
|
+
config: { type: dist/* AltVM.HookType */.bx.WD.MERKLE_TREE },
|
|
1613
|
+
deployed: { address: normalizeStarknetAddressSafe(address) },
|
|
1614
|
+
};
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
class StarknetMerkleTreeHookWriter extends StarknetMerkleTreeHookReader {
|
|
1618
|
+
signer;
|
|
1619
|
+
mailboxAddress;
|
|
1620
|
+
constructor(signer, mailboxAddress) {
|
|
1621
|
+
super();
|
|
1622
|
+
this.signer = signer;
|
|
1623
|
+
this.mailboxAddress = mailboxAddress;
|
|
1624
|
+
}
|
|
1625
|
+
async create(artifact) {
|
|
1626
|
+
const tx = await this.signer.getCreateMerkleTreeHookTransaction({
|
|
1627
|
+
signer: this.signer.getSignerAddress(),
|
|
1628
|
+
mailboxAddress: this.mailboxAddress,
|
|
1629
|
+
});
|
|
1630
|
+
const receipt = await this.signer.sendAndConfirmTransaction(tx);
|
|
1631
|
+
const hookAddress = receipt.contractAddress;
|
|
1632
|
+
(0,validation/* assert */.v)(hookAddress, 'failed to deploy Starknet merkle tree hook');
|
|
1633
|
+
return [
|
|
1634
|
+
{
|
|
1635
|
+
artifactState: dist_artifact/* ArtifactState */.O2.DEPLOYED,
|
|
1636
|
+
config: artifact.config,
|
|
1637
|
+
deployed: { address: hookAddress },
|
|
1638
|
+
},
|
|
1639
|
+
[receipt],
|
|
1640
|
+
];
|
|
1641
|
+
}
|
|
1642
|
+
async update(_artifact) {
|
|
1643
|
+
return [];
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
//# sourceMappingURL=merkle-tree-hook-artifact-manager.js.map
|
|
1647
|
+
;// CONCATENATED MODULE: ../starknet-sdk/dist/hook/protocol-fee-hook-artifact-manager.js
|
|
1648
|
+
|
|
1649
|
+
|
|
1650
|
+
|
|
1651
|
+
|
|
1652
|
+
const STARKNET_STORAGE_ADDRESS_BOUND = (1n << 251n) - 256n;
|
|
1653
|
+
const logger = logging/* rootLogger */.Jk.child({
|
|
1654
|
+
module: 'starknet-hook-artifact-manager',
|
|
1655
|
+
});
|
|
1656
|
+
const MAX_PROTOCOL_FEE_STORAGE_KEYS = [
|
|
1657
|
+
'max_protocol_fee',
|
|
1658
|
+
'_max_protocol_fee',
|
|
1659
|
+
].map((name) => starknet_dist/* hash */.tW.starknetKeccak(name) % STARKNET_STORAGE_ADDRESS_BOUND);
|
|
1660
|
+
async function readUint256Storage(provider, contractAddress, key) {
|
|
1661
|
+
try {
|
|
1662
|
+
const rawProvider = provider.getRawProvider();
|
|
1663
|
+
const [low, high] = await Promise.all([
|
|
1664
|
+
rawProvider.getStorageAt(contractAddress, `0x${key.toString(16)}`),
|
|
1665
|
+
rawProvider.getStorageAt(contractAddress, `0x${(key + 1n).toString(16)}`),
|
|
1666
|
+
]);
|
|
1667
|
+
return toBigInt(low) + (toBigInt(high) << 128n);
|
|
1668
|
+
}
|
|
1669
|
+
catch (error) {
|
|
1670
|
+
if (!shouldFallbackStorageRead(error)) {
|
|
1671
|
+
throw error;
|
|
1672
|
+
}
|
|
1673
|
+
logger.warn({
|
|
1674
|
+
contractAddress,
|
|
1675
|
+
key: `0x${key.toString(16)}`,
|
|
1676
|
+
error,
|
|
1677
|
+
}, 'Falling back to lossy Starknet protocolFee max read after unsupported storage lookup');
|
|
1678
|
+
return undefined;
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
async function readProtocolFeeMaxFromStorage(provider, contractAddress, protocolFee) {
|
|
1682
|
+
// Different Starknet contract builds have used different storage keys for
|
|
1683
|
+
// max_protocol_fee. Accept any candidate that is at least the live
|
|
1684
|
+
// protocolFee, prefer a single non-zero value over zero sentinels, and only
|
|
1685
|
+
// fall back to all candidates when multiple non-zero slots are populated.
|
|
1686
|
+
const candidates = (await Promise.all(MAX_PROTOCOL_FEE_STORAGE_KEYS.map(async (key) => readUint256Storage(provider, contractAddress, key)))).filter((value) => value !== undefined && value >= protocolFee);
|
|
1687
|
+
if (candidates.length === 0)
|
|
1688
|
+
return undefined;
|
|
1689
|
+
const nonZeroCandidates = candidates.filter((value) => value > 0n);
|
|
1690
|
+
const relevantCandidates = nonZeroCandidates.length === 1 ? nonZeroCandidates : candidates;
|
|
1691
|
+
const uniqueValues = [
|
|
1692
|
+
...new Set(relevantCandidates.map((value) => value.toString())),
|
|
1693
|
+
];
|
|
1694
|
+
if (uniqueValues.length === 1) {
|
|
1695
|
+
const uniqueValue = uniqueValues[0];
|
|
1696
|
+
(0,validation/* assert */.v)(!(0,dist_typeof/* isNullish */.u)(uniqueValue), 'Expected Starknet protocolFee storage read to yield one value');
|
|
1697
|
+
return BigInt(uniqueValue);
|
|
1698
|
+
}
|
|
1699
|
+
return undefined;
|
|
1700
|
+
}
|
|
1701
|
+
class StarknetProtocolFeeHookReader {
|
|
1702
|
+
chainMetadata;
|
|
1703
|
+
provider;
|
|
1704
|
+
constructor(chainMetadata, provider) {
|
|
1705
|
+
this.chainMetadata = chainMetadata;
|
|
1706
|
+
this.provider = provider;
|
|
1707
|
+
}
|
|
1708
|
+
async read(address) {
|
|
1709
|
+
const normalizedAddress = normalizeStarknetAddressSafe(address);
|
|
1710
|
+
const hook = getStarknetContract(StarknetContractName.PROTOCOL_FEE, normalizedAddress, this.provider.getRawProvider());
|
|
1711
|
+
const [owner, beneficiary, protocolFee] = await Promise.all([
|
|
1712
|
+
callContract(hook, 'owner'),
|
|
1713
|
+
callContract(hook, 'get_beneficiary'),
|
|
1714
|
+
callContract(hook, 'get_protocol_fee'),
|
|
1715
|
+
]);
|
|
1716
|
+
const ownerAddress = normalizeStarknetAddressSafe(owner);
|
|
1717
|
+
const beneficiaryAddress = normalizeStarknetAddressSafe(beneficiary);
|
|
1718
|
+
const protocolFeeAmount = toBigInt(protocolFee);
|
|
1719
|
+
const maxProtocolFee = await readProtocolFeeMaxFromStorage(this.provider, normalizedAddress, protocolFeeAmount);
|
|
1720
|
+
const config = {
|
|
1721
|
+
type: 'protocolFee',
|
|
1722
|
+
owner: ownerAddress,
|
|
1723
|
+
beneficiary: beneficiaryAddress,
|
|
1724
|
+
maxProtocolFee: (maxProtocolFee ?? protocolFeeAmount).toString(),
|
|
1725
|
+
protocolFee: protocolFeeAmount.toString(),
|
|
1726
|
+
};
|
|
1727
|
+
if ((0,dist_typeof/* isNullish */.u)(maxProtocolFee)) {
|
|
1728
|
+
// Starknet protocol_fee does not expose maxProtocolFee in its ABI.
|
|
1729
|
+
// If storage lookup is unavailable or ambiguous, mark the read config
|
|
1730
|
+
// as lossy so generic deploy logic can fail closed instead of silently
|
|
1731
|
+
// ignoring maxProtocolFee drift.
|
|
1732
|
+
Object.defineProperty(config, '__maxProtocolFeeUnknown', {
|
|
1733
|
+
enumerable: true,
|
|
1734
|
+
value: true,
|
|
1735
|
+
});
|
|
1736
|
+
}
|
|
1737
|
+
return {
|
|
1738
|
+
artifactState: dist_artifact/* ArtifactState */.O2.DEPLOYED,
|
|
1739
|
+
config,
|
|
1740
|
+
deployed: { address: normalizedAddress },
|
|
1741
|
+
};
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
class StarknetProtocolFeeHookWriter extends StarknetProtocolFeeHookReader {
|
|
1745
|
+
signer;
|
|
1746
|
+
constructor(chainMetadata, provider, signer) {
|
|
1747
|
+
super(chainMetadata, provider);
|
|
1748
|
+
this.signer = signer;
|
|
1749
|
+
}
|
|
1750
|
+
async create(artifact) {
|
|
1751
|
+
const tokenAddress = getFeeTokenAddress({
|
|
1752
|
+
chainName: this.chainMetadata.name,
|
|
1753
|
+
nativeDenom: this.chainMetadata.nativeToken?.denom,
|
|
1754
|
+
});
|
|
1755
|
+
const deployTx = {
|
|
1756
|
+
kind: 'deploy',
|
|
1757
|
+
contractName: StarknetContractName.PROTOCOL_FEE,
|
|
1758
|
+
constructorArgs: [
|
|
1759
|
+
artifact.config.maxProtocolFee,
|
|
1760
|
+
artifact.config.protocolFee,
|
|
1761
|
+
normalizeStarknetAddressSafe(artifact.config.beneficiary),
|
|
1762
|
+
normalizeStarknetAddressSafe(artifact.config.owner),
|
|
1763
|
+
tokenAddress,
|
|
1764
|
+
],
|
|
1765
|
+
};
|
|
1766
|
+
const receipt = await this.signer.sendAndConfirmTransaction(deployTx);
|
|
1767
|
+
(0,validation/* assert */.v)(receipt.contractAddress, 'failed to deploy Starknet protocol_fee hook');
|
|
1768
|
+
return [
|
|
1769
|
+
{
|
|
1770
|
+
artifactState: dist_artifact/* ArtifactState */.O2.DEPLOYED,
|
|
1771
|
+
config: artifact.config,
|
|
1772
|
+
deployed: {
|
|
1773
|
+
address: normalizeStarknetAddressSafe(receipt.contractAddress),
|
|
1774
|
+
},
|
|
1775
|
+
},
|
|
1776
|
+
[receipt],
|
|
1777
|
+
];
|
|
1778
|
+
}
|
|
1779
|
+
async update(artifact) {
|
|
1780
|
+
const current = await this.read(artifact.deployed.address);
|
|
1781
|
+
const maxProtocolFeeUnknown =
|
|
1782
|
+
// CAST: Reflect.get requires an object argument; protocolFee config is always an object here.
|
|
1783
|
+
Reflect.get(current.config, '__maxProtocolFeeUnknown') === true;
|
|
1784
|
+
(0,validation/* assert */.v)(!maxProtocolFeeUnknown, 'Cannot update Starknet protocolFee hook because the current maxProtocolFee is unreadable; redeploy required');
|
|
1785
|
+
(0,validation/* assert */.v)(current.config.maxProtocolFee === artifact.config.maxProtocolFee, 'Changing maxProtocolFee requires redeploying the Starknet protocolFee hook');
|
|
1786
|
+
const contractAddress = artifact.deployed.address;
|
|
1787
|
+
const contract = getStarknetContract(StarknetContractName.PROTOCOL_FEE, contractAddress, this.provider.getRawProvider());
|
|
1788
|
+
const txs = [];
|
|
1789
|
+
if (!(0,addresses/* eqAddressStarknet */.PD)(current.config.beneficiary, artifact.config.beneficiary)) {
|
|
1790
|
+
txs.push({
|
|
1791
|
+
annotation: `Updating protocol fee beneficiary for ${contractAddress}`,
|
|
1792
|
+
...(await populateInvokeTx(contract, 'set_beneficiary', [
|
|
1793
|
+
normalizeStarknetAddressSafe(artifact.config.beneficiary),
|
|
1794
|
+
])),
|
|
1795
|
+
});
|
|
1796
|
+
}
|
|
1797
|
+
if (current.config.protocolFee !== artifact.config.protocolFee) {
|
|
1798
|
+
txs.push({
|
|
1799
|
+
annotation: `Updating protocol fee amount for ${contractAddress}`,
|
|
1800
|
+
...(await populateInvokeTx(contract, 'set_protocol_fee', [
|
|
1801
|
+
artifact.config.protocolFee,
|
|
1802
|
+
])),
|
|
1803
|
+
});
|
|
1804
|
+
}
|
|
1805
|
+
if (!(0,addresses/* eqAddressStarknet */.PD)(current.config.owner, artifact.config.owner)) {
|
|
1806
|
+
txs.push({
|
|
1807
|
+
annotation: `Transferring protocol fee hook ownership for ${contractAddress}`,
|
|
1808
|
+
...(await populateInvokeTx(contract, 'transfer_ownership', [
|
|
1809
|
+
normalizeStarknetAddressSafe(artifact.config.owner),
|
|
1810
|
+
])),
|
|
1811
|
+
});
|
|
1812
|
+
}
|
|
1813
|
+
return txs;
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
//# sourceMappingURL=protocol-fee-hook-artifact-manager.js.map
|
|
1817
|
+
;// CONCATENATED MODULE: ../starknet-sdk/dist/hook/unknown-hook-artifact-manager.js
|
|
1818
|
+
|
|
1819
|
+
|
|
1820
|
+
class StarknetUnknownHookReader {
|
|
1821
|
+
async read(address) {
|
|
1822
|
+
return {
|
|
1823
|
+
artifactState: dist_artifact/* ArtifactState */.O2.DEPLOYED,
|
|
1824
|
+
config: { type: 'unknownHook' },
|
|
1825
|
+
deployed: { address: normalizeStarknetAddressSafe(address) },
|
|
1826
|
+
};
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
class StarknetUnknownHookWriter extends StarknetUnknownHookReader {
|
|
1830
|
+
async create(_artifact) {
|
|
1831
|
+
throw new Error('unknownHook artifacts are read-only on Starknet; deploy noop hooks via signer.createNoopHook');
|
|
1832
|
+
}
|
|
1833
|
+
async update(_artifact) {
|
|
1834
|
+
return [];
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
//# sourceMappingURL=unknown-hook-artifact-manager.js.map
|
|
1838
|
+
;// CONCATENATED MODULE: ../starknet-sdk/dist/hook/hook-artifact-manager.js
|
|
1839
|
+
|
|
1840
|
+
|
|
1841
|
+
|
|
1842
|
+
|
|
1843
|
+
|
|
1844
|
+
|
|
1845
|
+
|
|
1846
|
+
|
|
1847
|
+
|
|
1848
|
+
|
|
1849
|
+
class StarknetHookArtifactManager {
|
|
1850
|
+
chainMetadata;
|
|
1851
|
+
provider;
|
|
1852
|
+
mailboxAddress;
|
|
1853
|
+
constructor(chainMetadata, context) {
|
|
1854
|
+
this.chainMetadata = chainMetadata;
|
|
1855
|
+
this.provider = StarknetProvider.connect((chainMetadata.rpcUrls ?? []).map(({ http }) => http), chainMetadata.chainId, { metadata: chainMetadata });
|
|
1856
|
+
this.mailboxAddress = context?.mailbox
|
|
1857
|
+
? normalizeStarknetAddressSafe(context.mailbox)
|
|
1858
|
+
: '';
|
|
1859
|
+
}
|
|
1860
|
+
requireStarknetSigner(signer) {
|
|
1861
|
+
(0,validation/* assert */.v)(signer instanceof StarknetSigner, 'Expected StarknetSigner');
|
|
1862
|
+
return signer;
|
|
1863
|
+
}
|
|
1864
|
+
async readHook(address) {
|
|
1865
|
+
const hookType = await this.provider.getHookType({
|
|
1866
|
+
hookAddress: address,
|
|
1867
|
+
});
|
|
1868
|
+
switch (hookType) {
|
|
1869
|
+
case dist/* AltVM.HookType */.bx.WD.CUSTOM:
|
|
1870
|
+
return this.createReader('unknownHook').read(address);
|
|
1871
|
+
case dist/* AltVM.HookType */.bx.WD.MERKLE_TREE:
|
|
1872
|
+
return this.createReader(dist/* AltVM.HookType */.bx.WD.MERKLE_TREE).read(address);
|
|
1873
|
+
case dist/* AltVM.HookType */.bx.WD.PROTOCOL_FEE:
|
|
1874
|
+
return this.createReader(dist/* AltVM.HookType */.bx.WD.PROTOCOL_FEE).read(address);
|
|
1875
|
+
default:
|
|
1876
|
+
return (0,hook/* throwUnsupportedHookType */.DD)(hookType, 'Starknet');
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
createReader(type) {
|
|
1880
|
+
const readers = {
|
|
1881
|
+
merkleTreeHook: () => new StarknetMerkleTreeHookReader(),
|
|
1882
|
+
interchainGasPaymaster: () => createStarknetInterchainGasPaymasterHookReader(),
|
|
1883
|
+
protocolFee: () => new StarknetProtocolFeeHookReader(this.chainMetadata, this.provider),
|
|
1884
|
+
unknownHook: () => new StarknetUnknownHookReader(),
|
|
1885
|
+
};
|
|
1886
|
+
const readerFactory = readers[type];
|
|
1887
|
+
if (!readerFactory) {
|
|
1888
|
+
return (0,hook/* throwUnsupportedHookType */.DD)(type, 'Starknet');
|
|
1889
|
+
}
|
|
1890
|
+
return readerFactory();
|
|
1891
|
+
}
|
|
1892
|
+
createWriter(type, signer) {
|
|
1893
|
+
const starknetSigner = this.requireStarknetSigner(signer);
|
|
1894
|
+
(0,validation/* assert */.v)(this.mailboxAddress || type !== dist/* AltVM.HookType */.bx.WD.MERKLE_TREE, 'mailbox address required for Starknet merkle tree hook deployment');
|
|
1895
|
+
const writers = {
|
|
1896
|
+
merkleTreeHook: () => new StarknetMerkleTreeHookWriter(starknetSigner, this.mailboxAddress),
|
|
1897
|
+
interchainGasPaymaster: () => createStarknetInterchainGasPaymasterHookWriter(),
|
|
1898
|
+
protocolFee: () => new StarknetProtocolFeeHookWriter(this.chainMetadata, this.provider, starknetSigner),
|
|
1899
|
+
unknownHook: () => new StarknetUnknownHookWriter(),
|
|
1900
|
+
};
|
|
1901
|
+
const writerFactory = writers[type];
|
|
1902
|
+
if (!writerFactory) {
|
|
1903
|
+
return (0,hook/* throwUnsupportedHookType */.DD)(type, 'Starknet');
|
|
1904
|
+
}
|
|
1905
|
+
return writerFactory();
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
//# sourceMappingURL=hook-artifact-manager.js.map
|
|
1909
|
+
// EXTERNAL MODULE: ../provider-sdk/dist/ism.js
|
|
1910
|
+
var ism = __webpack_require__(96426);
|
|
1911
|
+
;// CONCATENATED MODULE: ../starknet-sdk/dist/ism/domain-routing-ism-artifact-manager.js
|
|
1912
|
+
|
|
1913
|
+
|
|
1914
|
+
|
|
1915
|
+
class StarknetRoutingIsmReader {
|
|
1916
|
+
provider;
|
|
1917
|
+
constructor(provider) {
|
|
1918
|
+
this.provider = provider;
|
|
1919
|
+
}
|
|
1920
|
+
async read(address) {
|
|
1921
|
+
const routing = await this.provider.getRoutingIsm({
|
|
1922
|
+
ismAddress: address,
|
|
1923
|
+
});
|
|
1924
|
+
const domains = {};
|
|
1925
|
+
for (const route of routing.routes) {
|
|
1926
|
+
domains[route.domainId] = {
|
|
1927
|
+
artifactState: dist_artifact/* ArtifactState */.O2.UNDERIVED,
|
|
1928
|
+
deployed: { address: route.ismAddress },
|
|
1929
|
+
};
|
|
1930
|
+
}
|
|
1931
|
+
return {
|
|
1932
|
+
artifactState: dist_artifact/* ArtifactState */.O2.DEPLOYED,
|
|
1933
|
+
config: {
|
|
1934
|
+
type: 'domainRoutingIsm',
|
|
1935
|
+
owner: routing.owner,
|
|
1936
|
+
domains,
|
|
1937
|
+
},
|
|
1938
|
+
deployed: { address: routing.address },
|
|
1939
|
+
};
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
class StarknetRoutingIsmWriter extends StarknetRoutingIsmReader {
|
|
1943
|
+
signer;
|
|
1944
|
+
constructor(provider, signer) {
|
|
1945
|
+
super(provider);
|
|
1946
|
+
this.signer = signer;
|
|
1947
|
+
}
|
|
1948
|
+
async create(artifact) {
|
|
1949
|
+
const routes = Object.entries(artifact.config.domains).map(([domainId, domainIsm]) => {
|
|
1950
|
+
(0,validation/* assert */.v)(!(0,dist_artifact/* isArtifactNew */.v_)(domainIsm), `Routing ISM domain ${domainId} must be deployed before Starknet raw routing deployment`);
|
|
1951
|
+
(0,validation/* assert */.v)((0,dist_artifact/* isArtifactUnderived */.l2)(domainIsm) || (0,dist_artifact/* isArtifactDeployed */.R)(domainIsm), `Routing ISM domain ${domainId} has invalid state`);
|
|
1952
|
+
return {
|
|
1953
|
+
domainId: Number(domainId),
|
|
1954
|
+
ismAddress: domainIsm.deployed.address,
|
|
1955
|
+
};
|
|
1956
|
+
});
|
|
1957
|
+
const receipts = [];
|
|
1958
|
+
const createTx = await this.signer.getCreateRoutingIsmTransaction({
|
|
1959
|
+
signer: this.signer.getSignerAddress(),
|
|
1960
|
+
routes,
|
|
1961
|
+
});
|
|
1962
|
+
const createReceipt = await this.signer.sendAndConfirmTransaction(createTx);
|
|
1963
|
+
receipts.push(createReceipt);
|
|
1964
|
+
const ismAddress = createReceipt.contractAddress;
|
|
1965
|
+
(0,validation/* assert */.v)(ismAddress, 'failed to get Starknet routing ISM address');
|
|
1966
|
+
for (const route of routes) {
|
|
1967
|
+
const tx = await this.signer.getSetRoutingIsmRouteTransaction({
|
|
1968
|
+
signer: this.signer.getSignerAddress(),
|
|
1969
|
+
ismAddress,
|
|
1970
|
+
route,
|
|
1971
|
+
});
|
|
1972
|
+
receipts.push(await this.signer.sendAndConfirmTransaction(tx));
|
|
1973
|
+
}
|
|
1974
|
+
if (!(0,addresses/* eqAddressStarknet */.PD)(artifact.config.owner, this.signer.getSignerAddress())) {
|
|
1975
|
+
const ownerTx = await this.signer.getSetRoutingIsmOwnerTransaction({
|
|
1976
|
+
signer: this.signer.getSignerAddress(),
|
|
1977
|
+
ismAddress,
|
|
1978
|
+
newOwner: artifact.config.owner,
|
|
1979
|
+
});
|
|
1980
|
+
receipts.push(await this.signer.sendAndConfirmTransaction(ownerTx));
|
|
1981
|
+
}
|
|
1982
|
+
return [
|
|
1983
|
+
{
|
|
1984
|
+
artifactState: dist_artifact/* ArtifactState */.O2.DEPLOYED,
|
|
1985
|
+
config: artifact.config,
|
|
1986
|
+
deployed: { address: ismAddress },
|
|
1987
|
+
},
|
|
1988
|
+
receipts,
|
|
1989
|
+
];
|
|
1990
|
+
}
|
|
1991
|
+
async update(artifact) {
|
|
1992
|
+
const current = await this.read(artifact.deployed.address);
|
|
1993
|
+
const expectedRoutes = Object.entries(artifact.config.domains).map(([domainId, domainIsm]) => {
|
|
1994
|
+
if ((0,dist_artifact/* isArtifactUnderived */.l2)(domainIsm) || (0,dist_artifact/* isArtifactDeployed */.R)(domainIsm)) {
|
|
1995
|
+
return {
|
|
1996
|
+
domainId: Number(domainId),
|
|
1997
|
+
ismAddress: normalizeStarknetAddressSafe(domainIsm.deployed.address),
|
|
1998
|
+
};
|
|
1999
|
+
}
|
|
2000
|
+
throw new Error(`Routing ISM domain ${domainId} has invalid state`);
|
|
2001
|
+
});
|
|
2002
|
+
const actualByDomain = new Map(Object.entries(current.config.domains).map(([domainId, domainIsm]) => [
|
|
2003
|
+
Number(domainId),
|
|
2004
|
+
normalizeStarknetAddressSafe(domainIsm.deployed.address),
|
|
2005
|
+
]));
|
|
2006
|
+
const expectedByDomain = new Map(expectedRoutes.map((route) => [route.domainId, route.ismAddress]));
|
|
2007
|
+
const updateTxs = [];
|
|
2008
|
+
for (const route of expectedRoutes) {
|
|
2009
|
+
const actualAddress = actualByDomain.get(route.domainId);
|
|
2010
|
+
if (!actualAddress ||
|
|
2011
|
+
!(0,addresses/* eqAddressStarknet */.PD)(actualAddress, route.ismAddress)) {
|
|
2012
|
+
updateTxs.push({
|
|
2013
|
+
annotation: `Setting routing ISM route ${route.domainId}`,
|
|
2014
|
+
...(await this.signer.getSetRoutingIsmRouteTransaction({
|
|
2015
|
+
signer: this.signer.getSignerAddress(),
|
|
2016
|
+
ismAddress: artifact.deployed.address,
|
|
2017
|
+
route,
|
|
2018
|
+
})),
|
|
2019
|
+
});
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
2022
|
+
for (const [domainId] of actualByDomain) {
|
|
2023
|
+
if (!expectedByDomain.has(domainId)) {
|
|
2024
|
+
updateTxs.push({
|
|
2025
|
+
annotation: `Removing routing ISM route ${domainId}`,
|
|
2026
|
+
...(await this.signer.getRemoveRoutingIsmRouteTransaction({
|
|
2027
|
+
signer: this.signer.getSignerAddress(),
|
|
2028
|
+
ismAddress: artifact.deployed.address,
|
|
2029
|
+
domainId,
|
|
2030
|
+
})),
|
|
2031
|
+
});
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
if (!(0,addresses/* eqAddressStarknet */.PD)(current.config.owner, artifact.config.owner)) {
|
|
2035
|
+
updateTxs.push({
|
|
2036
|
+
annotation: `Updating routing ISM owner`,
|
|
2037
|
+
...(await this.signer.getSetRoutingIsmOwnerTransaction({
|
|
2038
|
+
signer: this.signer.getSignerAddress(),
|
|
2039
|
+
ismAddress: artifact.deployed.address,
|
|
2040
|
+
newOwner: artifact.config.owner,
|
|
2041
|
+
})),
|
|
2042
|
+
});
|
|
2043
|
+
}
|
|
2044
|
+
return updateTxs;
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
//# sourceMappingURL=domain-routing-ism-artifact-manager.js.map
|
|
2048
|
+
;// CONCATENATED MODULE: ../starknet-sdk/dist/ism/merkle-root-multisig-ism-artifact-manager.js
|
|
2049
|
+
|
|
2050
|
+
|
|
2051
|
+
|
|
2052
|
+
class StarknetMerkleRootMultisigIsmReader {
|
|
2053
|
+
provider;
|
|
2054
|
+
constructor(provider) {
|
|
2055
|
+
this.provider = provider;
|
|
2056
|
+
}
|
|
2057
|
+
async read(address) {
|
|
2058
|
+
const ism = await this.provider.getMerkleRootMultisigIsm({
|
|
2059
|
+
ismAddress: address,
|
|
2060
|
+
});
|
|
2061
|
+
return {
|
|
2062
|
+
artifactState: dist_artifact/* ArtifactState */.O2.DEPLOYED,
|
|
2063
|
+
config: {
|
|
2064
|
+
type: dist/* AltVM.IsmType */.bx.GO.MERKLE_ROOT_MULTISIG,
|
|
2065
|
+
validators: ism.validators,
|
|
2066
|
+
threshold: ism.threshold,
|
|
2067
|
+
},
|
|
2068
|
+
deployed: { address: ism.address },
|
|
2069
|
+
};
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
class StarknetMerkleRootMultisigIsmWriter extends StarknetMerkleRootMultisigIsmReader {
|
|
2073
|
+
signer;
|
|
2074
|
+
constructor(provider, signer) {
|
|
2075
|
+
super(provider);
|
|
2076
|
+
this.signer = signer;
|
|
2077
|
+
}
|
|
2078
|
+
async create(artifact) {
|
|
2079
|
+
const tx = await this.signer.getCreateMerkleRootMultisigIsmTransaction({
|
|
2080
|
+
signer: this.signer.getSignerAddress(),
|
|
2081
|
+
validators: artifact.config.validators,
|
|
2082
|
+
threshold: artifact.config.threshold,
|
|
2083
|
+
});
|
|
2084
|
+
const receipt = await this.signer.sendAndConfirmTransaction(tx);
|
|
2085
|
+
const ismAddress = receipt.contractAddress;
|
|
2086
|
+
(0,validation/* assert */.v)(ismAddress, 'failed to deploy Starknet merkle root multisig ISM');
|
|
2087
|
+
return [
|
|
2088
|
+
{
|
|
2089
|
+
artifactState: dist_artifact/* ArtifactState */.O2.DEPLOYED,
|
|
2090
|
+
config: artifact.config,
|
|
2091
|
+
deployed: { address: ismAddress },
|
|
2092
|
+
},
|
|
2093
|
+
[receipt],
|
|
2094
|
+
];
|
|
2095
|
+
}
|
|
2096
|
+
async update(_artifact) {
|
|
2097
|
+
return [];
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
//# sourceMappingURL=merkle-root-multisig-ism-artifact-manager.js.map
|
|
2101
|
+
;// CONCATENATED MODULE: ../starknet-sdk/dist/ism/message-id-multisig-ism-artifact-manager.js
|
|
2102
|
+
|
|
2103
|
+
|
|
2104
|
+
|
|
2105
|
+
class StarknetMessageIdMultisigIsmReader {
|
|
2106
|
+
provider;
|
|
2107
|
+
constructor(provider) {
|
|
2108
|
+
this.provider = provider;
|
|
2109
|
+
}
|
|
2110
|
+
async read(address) {
|
|
2111
|
+
const ism = await this.provider.getMessageIdMultisigIsm({
|
|
2112
|
+
ismAddress: address,
|
|
2113
|
+
});
|
|
2114
|
+
return {
|
|
2115
|
+
artifactState: dist_artifact/* ArtifactState */.O2.DEPLOYED,
|
|
2116
|
+
config: {
|
|
2117
|
+
type: dist/* AltVM.IsmType */.bx.GO.MESSAGE_ID_MULTISIG,
|
|
2118
|
+
validators: ism.validators,
|
|
2119
|
+
threshold: ism.threshold,
|
|
2120
|
+
},
|
|
2121
|
+
deployed: { address: ism.address },
|
|
2122
|
+
};
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
class StarknetMessageIdMultisigIsmWriter extends StarknetMessageIdMultisigIsmReader {
|
|
2126
|
+
signer;
|
|
2127
|
+
constructor(provider, signer) {
|
|
2128
|
+
super(provider);
|
|
2129
|
+
this.signer = signer;
|
|
2130
|
+
}
|
|
2131
|
+
async create(artifact) {
|
|
2132
|
+
const tx = await this.signer.getCreateMessageIdMultisigIsmTransaction({
|
|
2133
|
+
signer: this.signer.getSignerAddress(),
|
|
2134
|
+
validators: artifact.config.validators,
|
|
2135
|
+
threshold: artifact.config.threshold,
|
|
2136
|
+
});
|
|
2137
|
+
const receipt = await this.signer.sendAndConfirmTransaction(tx);
|
|
2138
|
+
const ismAddress = receipt.contractAddress;
|
|
2139
|
+
(0,validation/* assert */.v)(ismAddress, 'failed to deploy Starknet message ID multisig ISM');
|
|
2140
|
+
return [
|
|
2141
|
+
{
|
|
2142
|
+
artifactState: dist_artifact/* ArtifactState */.O2.DEPLOYED,
|
|
2143
|
+
config: artifact.config,
|
|
2144
|
+
deployed: { address: ismAddress },
|
|
2145
|
+
},
|
|
2146
|
+
[receipt],
|
|
2147
|
+
];
|
|
2148
|
+
}
|
|
2149
|
+
async update(_artifact) {
|
|
2150
|
+
return [];
|
|
2151
|
+
}
|
|
2152
|
+
}
|
|
2153
|
+
//# sourceMappingURL=message-id-multisig-ism-artifact-manager.js.map
|
|
2154
|
+
;// CONCATENATED MODULE: ../starknet-sdk/dist/ism/test-ism-artifact-manager.js
|
|
2155
|
+
|
|
2156
|
+
|
|
2157
|
+
|
|
2158
|
+
class StarknetTestIsmReader {
|
|
2159
|
+
provider;
|
|
2160
|
+
constructor(provider) {
|
|
2161
|
+
this.provider = provider;
|
|
2162
|
+
}
|
|
2163
|
+
async read(address) {
|
|
2164
|
+
const noop = await this.provider.getNoopIsm({ ismAddress: address });
|
|
2165
|
+
return {
|
|
2166
|
+
artifactState: dist_artifact/* ArtifactState */.O2.DEPLOYED,
|
|
2167
|
+
config: { type: dist/* AltVM.IsmType */.bx.GO.TEST_ISM },
|
|
2168
|
+
deployed: { address: noop.address },
|
|
2169
|
+
};
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
class StarknetTestIsmWriter extends StarknetTestIsmReader {
|
|
2173
|
+
signer;
|
|
2174
|
+
constructor(provider, signer) {
|
|
2175
|
+
super(provider);
|
|
2176
|
+
this.signer = signer;
|
|
2177
|
+
}
|
|
2178
|
+
async create(artifact) {
|
|
2179
|
+
const tx = await this.signer.getCreateNoopIsmTransaction({
|
|
2180
|
+
signer: this.signer.getSignerAddress(),
|
|
2181
|
+
});
|
|
2182
|
+
const receipt = await this.signer.sendAndConfirmTransaction(tx);
|
|
2183
|
+
const ismAddress = receipt.contractAddress;
|
|
2184
|
+
(0,validation/* assert */.v)(ismAddress, 'failed to deploy Starknet noop ISM');
|
|
2185
|
+
return [
|
|
2186
|
+
{
|
|
2187
|
+
artifactState: dist_artifact/* ArtifactState */.O2.DEPLOYED,
|
|
2188
|
+
config: artifact.config,
|
|
2189
|
+
deployed: { address: ismAddress },
|
|
2190
|
+
},
|
|
2191
|
+
[receipt],
|
|
2192
|
+
];
|
|
2193
|
+
}
|
|
2194
|
+
async update(_artifact) {
|
|
2195
|
+
return [];
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2198
|
+
//# sourceMappingURL=test-ism-artifact-manager.js.map
|
|
2199
|
+
;// CONCATENATED MODULE: ../starknet-sdk/dist/ism/ism-artifact-manager.js
|
|
2200
|
+
|
|
2201
|
+
|
|
2202
|
+
|
|
2203
|
+
|
|
2204
|
+
|
|
2205
|
+
|
|
2206
|
+
|
|
2207
|
+
|
|
2208
|
+
|
|
2209
|
+
class StarknetIsmArtifactManager {
|
|
2210
|
+
provider;
|
|
2211
|
+
constructor(chainMetadata) {
|
|
2212
|
+
this.provider = StarknetProvider.connect((chainMetadata.rpcUrls ?? []).map(({ http }) => http), chainMetadata.chainId, { metadata: chainMetadata });
|
|
2213
|
+
}
|
|
2214
|
+
requireStarknetSigner(signer) {
|
|
2215
|
+
(0,validation/* assert */.v)(signer instanceof StarknetSigner, 'Expected StarknetSigner');
|
|
2216
|
+
return signer;
|
|
2217
|
+
}
|
|
2218
|
+
async readIsm(address) {
|
|
2219
|
+
const type = await this.provider.getIsmType({ ismAddress: address });
|
|
2220
|
+
if (type === dist/* AltVM.IsmType */.bx.GO.CUSTOM) {
|
|
2221
|
+
return this.createReader(dist/* AltVM.IsmType */.bx.GO.TEST_ISM).read(address);
|
|
2222
|
+
}
|
|
2223
|
+
const reader = this.createReader((0,ism/* altVMIsmTypeToProviderSdkType */.EJ)(type));
|
|
2224
|
+
return reader.read(address);
|
|
2225
|
+
}
|
|
2226
|
+
createReader(type) {
|
|
2227
|
+
const readers = {
|
|
2228
|
+
testIsm: () => new StarknetTestIsmReader(this.provider),
|
|
2229
|
+
merkleRootMultisigIsm: () => new StarknetMerkleRootMultisigIsmReader(this.provider),
|
|
2230
|
+
messageIdMultisigIsm: () => new StarknetMessageIdMultisigIsmReader(this.provider),
|
|
2231
|
+
domainRoutingIsm: () => new StarknetRoutingIsmReader(this.provider),
|
|
2232
|
+
};
|
|
2233
|
+
const readerFactory = readers[type];
|
|
2234
|
+
(0,validation/* assert */.v)(readerFactory, `Unsupported Starknet ISM type: ${type}`);
|
|
2235
|
+
return readerFactory();
|
|
2236
|
+
}
|
|
2237
|
+
createWriter(type, signer) {
|
|
2238
|
+
const writers = {
|
|
2239
|
+
testIsm: (starknetSigner) => new StarknetTestIsmWriter(this.provider, starknetSigner),
|
|
2240
|
+
merkleRootMultisigIsm: (starknetSigner) => new StarknetMerkleRootMultisigIsmWriter(this.provider, starknetSigner),
|
|
2241
|
+
messageIdMultisigIsm: (starknetSigner) => new StarknetMessageIdMultisigIsmWriter(this.provider, starknetSigner),
|
|
2242
|
+
domainRoutingIsm: (starknetSigner) => new StarknetRoutingIsmWriter(this.provider, starknetSigner),
|
|
2243
|
+
};
|
|
2244
|
+
const writer = writers[type];
|
|
2245
|
+
(0,validation/* assert */.v)(writer, `Unsupported Starknet ISM type: ${type}`);
|
|
2246
|
+
const starknetSigner = this.requireStarknetSigner(signer);
|
|
2247
|
+
return writer(starknetSigner);
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2250
|
+
//# sourceMappingURL=ism-artifact-manager.js.map
|
|
2251
|
+
;// CONCATENATED MODULE: ../starknet-sdk/dist/mailbox/mailbox-artifact-manager.js
|
|
2252
|
+
|
|
2253
|
+
|
|
2254
|
+
|
|
2255
|
+
|
|
2256
|
+
|
|
2257
|
+
class StarknetMailboxReader {
|
|
2258
|
+
provider;
|
|
2259
|
+
constructor(provider) {
|
|
2260
|
+
this.provider = provider;
|
|
2261
|
+
}
|
|
2262
|
+
async read(address) {
|
|
2263
|
+
const mailbox = await this.provider.getMailbox({
|
|
2264
|
+
mailboxAddress: address,
|
|
2265
|
+
});
|
|
2266
|
+
return {
|
|
2267
|
+
artifactState: dist_artifact/* ArtifactState */.O2.DEPLOYED,
|
|
2268
|
+
config: {
|
|
2269
|
+
owner: mailbox.owner,
|
|
2270
|
+
defaultIsm: {
|
|
2271
|
+
artifactState: dist_artifact/* ArtifactState */.O2.UNDERIVED,
|
|
2272
|
+
deployed: {
|
|
2273
|
+
address: normalizeStarknetAddressSafe(mailbox.defaultIsm),
|
|
2274
|
+
},
|
|
2275
|
+
},
|
|
2276
|
+
defaultHook: {
|
|
2277
|
+
artifactState: dist_artifact/* ArtifactState */.O2.UNDERIVED,
|
|
2278
|
+
deployed: {
|
|
2279
|
+
address: normalizeStarknetAddressSafe(mailbox.defaultHook),
|
|
2280
|
+
},
|
|
2281
|
+
},
|
|
2282
|
+
requiredHook: {
|
|
2283
|
+
artifactState: dist_artifact/* ArtifactState */.O2.UNDERIVED,
|
|
2284
|
+
deployed: {
|
|
2285
|
+
address: normalizeStarknetAddressSafe(mailbox.requiredHook),
|
|
2286
|
+
},
|
|
2287
|
+
},
|
|
2288
|
+
},
|
|
2289
|
+
deployed: {
|
|
2290
|
+
address: normalizeStarknetAddressSafe(mailbox.address),
|
|
2291
|
+
domainId: mailbox.localDomain,
|
|
2292
|
+
},
|
|
2293
|
+
};
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
2296
|
+
class StarknetMailboxWriter extends StarknetMailboxReader {
|
|
2297
|
+
signer;
|
|
2298
|
+
chainMetadata;
|
|
2299
|
+
constructor(provider, signer, chainMetadata) {
|
|
2300
|
+
super(provider);
|
|
2301
|
+
this.signer = signer;
|
|
2302
|
+
this.chainMetadata = chainMetadata;
|
|
2303
|
+
}
|
|
2304
|
+
getNestedAddress(nested) {
|
|
2305
|
+
return normalizeStarknetAddressSafe(nested.deployed.address);
|
|
2306
|
+
}
|
|
2307
|
+
async getInitialHookAddress(address, receipts, placeholderRef) {
|
|
2308
|
+
if (!(0,addresses/* isZeroishAddress */.Hi)(address)) {
|
|
2309
|
+
return normalizeStarknetAddressSafe(address);
|
|
2310
|
+
}
|
|
2311
|
+
if (!placeholderRef.address) {
|
|
2312
|
+
const tx = await this.signer.getCreateNoopHookTransaction({
|
|
2313
|
+
signer: this.signer.getSignerAddress(),
|
|
2314
|
+
mailboxAddress: '',
|
|
2315
|
+
});
|
|
2316
|
+
const receipt = await this.signer.sendAndConfirmTransaction(tx);
|
|
2317
|
+
receipts.push(receipt);
|
|
2318
|
+
(0,validation/* assert */.v)(receipt.contractAddress, 'failed to deploy placeholder Starknet noop hook');
|
|
2319
|
+
placeholderRef.address = normalizeStarknetAddressSafe(receipt.contractAddress);
|
|
2320
|
+
}
|
|
2321
|
+
return placeholderRef.address;
|
|
2322
|
+
}
|
|
2323
|
+
async create(artifact) {
|
|
2324
|
+
const defaultIsmAddress = this.getNestedAddress(artifact.config.defaultIsm);
|
|
2325
|
+
const receipts = [];
|
|
2326
|
+
const placeholderHookRef = {};
|
|
2327
|
+
const defaultHookAddress = await this.getInitialHookAddress(this.getNestedAddress(artifact.config.defaultHook), receipts, placeholderHookRef);
|
|
2328
|
+
const requiredHookAddress = await this.getInitialHookAddress(this.getNestedAddress(artifact.config.requiredHook), receipts, placeholderHookRef);
|
|
2329
|
+
const createTx = await this.signer.getCreateMailboxTransaction({
|
|
2330
|
+
signer: this.signer.getSignerAddress(),
|
|
2331
|
+
domainId: this.chainMetadata.domainId,
|
|
2332
|
+
defaultIsmAddress,
|
|
2333
|
+
defaultHookAddress,
|
|
2334
|
+
requiredHookAddress,
|
|
2335
|
+
proxyAdminAddress: undefined,
|
|
2336
|
+
});
|
|
2337
|
+
const createReceipt = await this.signer.sendAndConfirmTransaction(createTx);
|
|
2338
|
+
receipts.push(createReceipt);
|
|
2339
|
+
(0,validation/* assert */.v)(createReceipt.contractAddress, 'failed to deploy Starknet mailbox');
|
|
2340
|
+
const mailboxAddress = createReceipt.contractAddress;
|
|
2341
|
+
if (!(0,addresses/* eqAddressStarknet */.PD)(artifact.config.owner, this.signer.getSignerAddress())) {
|
|
2342
|
+
const tx = await this.signer.getSetMailboxOwnerTransaction({
|
|
2343
|
+
signer: this.signer.getSignerAddress(),
|
|
2344
|
+
mailboxAddress,
|
|
2345
|
+
newOwner: artifact.config.owner,
|
|
2346
|
+
});
|
|
2347
|
+
receipts.push(await this.signer.sendAndConfirmTransaction(tx));
|
|
2348
|
+
}
|
|
2349
|
+
return [
|
|
2350
|
+
{
|
|
2351
|
+
artifactState: dist_artifact/* ArtifactState */.O2.DEPLOYED,
|
|
2352
|
+
config: artifact.config,
|
|
2353
|
+
deployed: {
|
|
2354
|
+
address: normalizeStarknetAddressSafe(mailboxAddress),
|
|
2355
|
+
domainId: this.chainMetadata.domainId,
|
|
2356
|
+
},
|
|
2357
|
+
},
|
|
2358
|
+
receipts,
|
|
2359
|
+
];
|
|
2360
|
+
}
|
|
2361
|
+
async update(artifact) {
|
|
2362
|
+
const current = await this.read(artifact.deployed.address);
|
|
2363
|
+
const mailboxAddress = artifact.deployed.address;
|
|
2364
|
+
const updateTxs = [];
|
|
2365
|
+
const expectedDefaultIsm = this.getNestedAddress(artifact.config.defaultIsm);
|
|
2366
|
+
const expectedDefaultHook = this.getNestedAddress(artifact.config.defaultHook);
|
|
2367
|
+
const expectedRequiredHook = this.getNestedAddress(artifact.config.requiredHook);
|
|
2368
|
+
const currentDefaultIsm = this.getNestedAddress(current.config.defaultIsm);
|
|
2369
|
+
const currentDefaultHook = this.getNestedAddress(current.config.defaultHook);
|
|
2370
|
+
const currentRequiredHook = this.getNestedAddress(current.config.requiredHook);
|
|
2371
|
+
if (!(0,addresses/* eqAddressStarknet */.PD)(currentDefaultIsm, expectedDefaultIsm)) {
|
|
2372
|
+
updateTxs.push({
|
|
2373
|
+
annotation: `Setting mailbox default ISM`,
|
|
2374
|
+
...(await this.signer.getSetDefaultIsmTransaction({
|
|
2375
|
+
signer: this.signer.getSignerAddress(),
|
|
2376
|
+
mailboxAddress,
|
|
2377
|
+
ismAddress: expectedDefaultIsm,
|
|
2378
|
+
})),
|
|
2379
|
+
});
|
|
2380
|
+
}
|
|
2381
|
+
if (!(0,addresses/* eqAddressStarknet */.PD)(currentDefaultHook, expectedDefaultHook)) {
|
|
2382
|
+
updateTxs.push({
|
|
2383
|
+
annotation: `Setting mailbox default hook`,
|
|
2384
|
+
...(await this.signer.getSetDefaultHookTransaction({
|
|
2385
|
+
signer: this.signer.getSignerAddress(),
|
|
2386
|
+
mailboxAddress,
|
|
2387
|
+
hookAddress: expectedDefaultHook,
|
|
2388
|
+
})),
|
|
2389
|
+
});
|
|
2390
|
+
}
|
|
2391
|
+
if (!(0,addresses/* eqAddressStarknet */.PD)(currentRequiredHook, expectedRequiredHook)) {
|
|
2392
|
+
updateTxs.push({
|
|
2393
|
+
annotation: `Setting mailbox required hook`,
|
|
2394
|
+
...(await this.signer.getSetRequiredHookTransaction({
|
|
2395
|
+
signer: this.signer.getSignerAddress(),
|
|
2396
|
+
mailboxAddress,
|
|
2397
|
+
hookAddress: expectedRequiredHook,
|
|
2398
|
+
})),
|
|
2399
|
+
});
|
|
2400
|
+
}
|
|
2401
|
+
if (!(0,addresses/* eqAddressStarknet */.PD)(current.config.owner, artifact.config.owner)) {
|
|
2402
|
+
updateTxs.push({
|
|
2403
|
+
annotation: `Setting mailbox owner`,
|
|
2404
|
+
...(await this.signer.getSetMailboxOwnerTransaction({
|
|
2405
|
+
signer: this.signer.getSignerAddress(),
|
|
2406
|
+
mailboxAddress,
|
|
2407
|
+
newOwner: artifact.config.owner,
|
|
2408
|
+
})),
|
|
2409
|
+
});
|
|
2410
|
+
}
|
|
2411
|
+
return updateTxs;
|
|
2412
|
+
}
|
|
2413
|
+
}
|
|
2414
|
+
class StarknetMailboxArtifactManager {
|
|
2415
|
+
chainMetadata;
|
|
2416
|
+
provider;
|
|
2417
|
+
constructor(chainMetadata) {
|
|
2418
|
+
this.chainMetadata = chainMetadata;
|
|
2419
|
+
this.provider = StarknetProvider.connect((chainMetadata.rpcUrls ?? []).map(({ http }) => http), chainMetadata.chainId, { metadata: chainMetadata });
|
|
2420
|
+
}
|
|
2421
|
+
requireStarknetSigner(signer) {
|
|
2422
|
+
(0,validation/* assert */.v)(signer instanceof StarknetSigner, 'Expected StarknetSigner');
|
|
2423
|
+
return signer;
|
|
2424
|
+
}
|
|
2425
|
+
async readMailbox(address) {
|
|
2426
|
+
return this.createReader('mailbox').read(address);
|
|
2427
|
+
}
|
|
2428
|
+
createReader(type) {
|
|
2429
|
+
const readers = {
|
|
2430
|
+
mailbox: new StarknetMailboxReader(this.provider),
|
|
2431
|
+
};
|
|
2432
|
+
const reader = readers[type];
|
|
2433
|
+
(0,validation/* assert */.v)(reader, 'Unsupported Starknet mailbox type');
|
|
2434
|
+
return reader;
|
|
2435
|
+
}
|
|
2436
|
+
createWriter(type, signer) {
|
|
2437
|
+
const writerFactories = {
|
|
2438
|
+
mailbox: () => new StarknetMailboxWriter(this.provider, this.requireStarknetSigner(signer), this.chainMetadata),
|
|
2439
|
+
};
|
|
2440
|
+
const writerFactory = writerFactories[type];
|
|
2441
|
+
(0,validation/* assert */.v)(writerFactory, 'Unsupported Starknet mailbox type');
|
|
2442
|
+
return writerFactory();
|
|
2443
|
+
}
|
|
2444
|
+
}
|
|
2445
|
+
//# sourceMappingURL=mailbox-artifact-manager.js.map
|
|
2446
|
+
;// CONCATENATED MODULE: ../starknet-sdk/dist/validator-announce/validator-announce-artifact-manager.js
|
|
2447
|
+
|
|
2448
|
+
|
|
2449
|
+
|
|
2450
|
+
|
|
2451
|
+
|
|
2452
|
+
|
|
2453
|
+
const validator_announce_artifact_manager_STARKNET_STORAGE_ADDRESS_BOUND = (1n << 251n) - 256n;
|
|
2454
|
+
const validator_announce_artifact_manager_logger = logging/* rootLogger */.Jk.child({
|
|
2455
|
+
module: 'starknet-validator-announce-artifact-manager',
|
|
2456
|
+
});
|
|
2457
|
+
const MAILBOX_STORAGE_KEYS = ['mailbox', '_mailbox'].map((name) => starknet_dist/* hash */.tW.starknetKeccak(name) % validator_announce_artifact_manager_STARKNET_STORAGE_ADDRESS_BOUND);
|
|
2458
|
+
async function readStorageAddress(provider, contractAddress, key) {
|
|
2459
|
+
try {
|
|
2460
|
+
const value = await provider
|
|
2461
|
+
.getRawProvider()
|
|
2462
|
+
.getStorageAt(contractAddress, `0x${key.toString(16)}`);
|
|
2463
|
+
return (0,addresses/* isZeroishAddress */.Hi)(value)
|
|
2464
|
+
? undefined
|
|
2465
|
+
: normalizeStarknetAddressSafe(value);
|
|
2466
|
+
}
|
|
2467
|
+
catch (error) {
|
|
2468
|
+
if (!shouldFallbackStorageRead(error)) {
|
|
2469
|
+
throw error;
|
|
2470
|
+
}
|
|
2471
|
+
validator_announce_artifact_manager_logger.warn({
|
|
2472
|
+
contractAddress,
|
|
2473
|
+
key: `0x${key.toString(16)}`,
|
|
2474
|
+
error,
|
|
2475
|
+
}, 'Falling back to lossy Starknet validator announce mailbox read after unsupported storage lookup');
|
|
2476
|
+
return undefined;
|
|
2477
|
+
}
|
|
2478
|
+
}
|
|
2479
|
+
async function readMailboxAddressFromStorage(provider, contractAddress) {
|
|
2480
|
+
const candidates = (await Promise.all(MAILBOX_STORAGE_KEYS.map(async (key) => readStorageAddress(provider, contractAddress, key)))).filter((value) => Boolean(value));
|
|
2481
|
+
if (candidates.length === 0)
|
|
2482
|
+
return undefined;
|
|
2483
|
+
const uniqueCandidates = [
|
|
2484
|
+
...new Set(candidates.map((value) => normalizeStarknetAddressSafe(value))),
|
|
2485
|
+
];
|
|
2486
|
+
return uniqueCandidates.length === 1 ? uniqueCandidates[0] : undefined;
|
|
2487
|
+
}
|
|
2488
|
+
class StarknetValidatorAnnounceReader {
|
|
2489
|
+
provider;
|
|
2490
|
+
constructor(provider) {
|
|
2491
|
+
this.provider = provider;
|
|
2492
|
+
}
|
|
2493
|
+
async read(address) {
|
|
2494
|
+
const normalizedAddress = normalizeStarknetAddressSafe(address);
|
|
2495
|
+
const mailboxAddress = await readMailboxAddressFromStorage(this.provider, normalizedAddress);
|
|
2496
|
+
const config = {
|
|
2497
|
+
mailboxAddress: mailboxAddress ?? '',
|
|
2498
|
+
};
|
|
2499
|
+
if (!mailboxAddress) {
|
|
2500
|
+
validator_announce_artifact_manager_logger.warn({ validatorAnnounceAddress: normalizedAddress }, 'Read Starknet validator announce without mailboxAddress; storage lookup was unavailable or ambiguous');
|
|
2501
|
+
Object.defineProperty(config, '__mailboxAddressUnknown', {
|
|
2502
|
+
enumerable: true,
|
|
2503
|
+
value: true,
|
|
2504
|
+
});
|
|
2505
|
+
}
|
|
2506
|
+
return {
|
|
2507
|
+
artifactState: dist_artifact/* ArtifactState */.O2.DEPLOYED,
|
|
2508
|
+
config,
|
|
2509
|
+
deployed: {
|
|
2510
|
+
address: normalizedAddress,
|
|
2511
|
+
},
|
|
2512
|
+
};
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2515
|
+
class StarknetValidatorAnnounceWriter extends StarknetValidatorAnnounceReader {
|
|
2516
|
+
signer;
|
|
2517
|
+
constructor(provider, signer) {
|
|
2518
|
+
super(provider);
|
|
2519
|
+
this.signer = signer;
|
|
2520
|
+
}
|
|
2521
|
+
async create(artifact) {
|
|
2522
|
+
const tx = await this.signer.getCreateValidatorAnnounceTransaction({
|
|
2523
|
+
signer: this.signer.getSignerAddress(),
|
|
2524
|
+
mailboxAddress: artifact.config.mailboxAddress,
|
|
2525
|
+
});
|
|
2526
|
+
const receipt = await this.signer.sendAndConfirmTransaction(tx);
|
|
2527
|
+
const validatorAnnounceId = receipt.contractAddress;
|
|
2528
|
+
(0,validation/* assert */.v)(validatorAnnounceId, 'failed to get Starknet validator announce address');
|
|
2529
|
+
return [
|
|
2530
|
+
{
|
|
2531
|
+
artifactState: dist_artifact/* ArtifactState */.O2.DEPLOYED,
|
|
2532
|
+
config: artifact.config,
|
|
2533
|
+
deployed: {
|
|
2534
|
+
address: normalizeStarknetAddressSafe(validatorAnnounceId),
|
|
2535
|
+
},
|
|
2536
|
+
},
|
|
2537
|
+
[receipt],
|
|
2538
|
+
];
|
|
2539
|
+
}
|
|
2540
|
+
async update(_artifact) {
|
|
2541
|
+
return [];
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
class StarknetValidatorAnnounceArtifactManager {
|
|
2545
|
+
provider;
|
|
2546
|
+
constructor(chainMetadata) {
|
|
2547
|
+
this.provider = StarknetProvider.connect((chainMetadata.rpcUrls ?? []).map(({ http }) => http), chainMetadata.chainId, { metadata: chainMetadata });
|
|
2548
|
+
}
|
|
2549
|
+
requireStarknetSigner(signer) {
|
|
2550
|
+
(0,validation/* assert */.v)(signer instanceof StarknetSigner, 'Expected StarknetSigner');
|
|
2551
|
+
return signer;
|
|
2552
|
+
}
|
|
2553
|
+
async readValidatorAnnounce(address) {
|
|
2554
|
+
return this.createReader('validatorAnnounce').read(address);
|
|
2555
|
+
}
|
|
2556
|
+
createReader(type) {
|
|
2557
|
+
const readers = {
|
|
2558
|
+
validatorAnnounce: new StarknetValidatorAnnounceReader(this.provider),
|
|
2559
|
+
};
|
|
2560
|
+
const reader = readers[type];
|
|
2561
|
+
(0,validation/* assert */.v)(reader, 'Unsupported Starknet validator announce type');
|
|
2562
|
+
return reader;
|
|
2563
|
+
}
|
|
2564
|
+
createWriter(type, signer) {
|
|
2565
|
+
const writerFactories = {
|
|
2566
|
+
validatorAnnounce: () => new StarknetValidatorAnnounceWriter(this.provider, this.requireStarknetSigner(signer)),
|
|
2567
|
+
};
|
|
2568
|
+
const writerFactory = writerFactories[type];
|
|
2569
|
+
(0,validation/* assert */.v)(writerFactory, 'Unsupported Starknet validator announce type');
|
|
2570
|
+
return writerFactory();
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
//# sourceMappingURL=validator-announce-artifact-manager.js.map
|
|
2574
|
+
// EXTERNAL MODULE: ../provider-sdk/dist/warp.js
|
|
2575
|
+
var warp = __webpack_require__(17791);
|
|
2576
|
+
;// CONCATENATED MODULE: ../starknet-sdk/dist/warp/token-artifact-manager.js
|
|
2577
|
+
|
|
2578
|
+
|
|
2579
|
+
|
|
2580
|
+
|
|
2581
|
+
function normalizeGas(gas) {
|
|
2582
|
+
return BigInt(gas ?? '0').toString();
|
|
2583
|
+
}
|
|
2584
|
+
function getStarknetWarpType(tokenType) {
|
|
2585
|
+
if (tokenType === warp/* TokenType */.ks.native)
|
|
2586
|
+
return 'native';
|
|
2587
|
+
if (tokenType === warp/* TokenType */.ks.collateral)
|
|
2588
|
+
return 'collateral';
|
|
2589
|
+
if (tokenType === warp/* TokenType */.ks.synthetic)
|
|
2590
|
+
return 'synthetic';
|
|
2591
|
+
if (tokenType === warp/* TokenType */.ks.crossCollateral)
|
|
2592
|
+
return 'crossCollateral';
|
|
2593
|
+
throw new Error(`Unsupported Starknet warp token type: ${tokenType}`);
|
|
2594
|
+
}
|
|
2595
|
+
class StarknetWarpTokenReaderBase {
|
|
2596
|
+
provider;
|
|
2597
|
+
constructor(provider) {
|
|
2598
|
+
this.provider = provider;
|
|
2599
|
+
}
|
|
2600
|
+
async read(address) {
|
|
2601
|
+
const token = await this.provider.getToken({ tokenAddress: address });
|
|
2602
|
+
const remoteRouters = await this.provider.getRemoteRouters({
|
|
2603
|
+
tokenAddress: address,
|
|
2604
|
+
});
|
|
2605
|
+
const actualType = getStarknetWarpType(token.tokenType);
|
|
2606
|
+
(0,validation/* assert */.v)(actualType === this.tokenType, `Expected Starknet warp token ${address} to be ${this.tokenType}, got ${actualType}`);
|
|
2607
|
+
return {
|
|
2608
|
+
artifactState: dist_artifact/* ArtifactState */.O2.DEPLOYED,
|
|
2609
|
+
config: this.toConfig(token, remoteRouters),
|
|
2610
|
+
deployed: { address: normalizeStarknetAddressSafe(token.address) },
|
|
2611
|
+
};
|
|
2612
|
+
}
|
|
2613
|
+
baseConfig(token, remoteRouters) {
|
|
2614
|
+
const routers = {};
|
|
2615
|
+
const destinationGas = {};
|
|
2616
|
+
for (const remoteRouter of remoteRouters.remoteRouters) {
|
|
2617
|
+
routers[remoteRouter.receiverDomainId] = {
|
|
2618
|
+
address: normalizeStarknetAddressSafe(remoteRouter.receiverAddress),
|
|
2619
|
+
};
|
|
2620
|
+
destinationGas[remoteRouter.receiverDomainId] = normalizeGas(remoteRouter.gas);
|
|
2621
|
+
}
|
|
2622
|
+
return {
|
|
2623
|
+
owner: normalizeStarknetAddressSafe(token.owner),
|
|
2624
|
+
mailbox: normalizeStarknetAddressSafe(token.mailboxAddress),
|
|
2625
|
+
interchainSecurityModule: (0,dist_artifact/* addressToUnderivedArtifact */.Se)(token.ismAddress, normalizeStarknetAddressSafe),
|
|
2626
|
+
hook: (0,dist_artifact/* addressToUnderivedArtifact */.Se)(token.hookAddress, normalizeStarknetAddressSafe),
|
|
2627
|
+
remoteRouters: routers,
|
|
2628
|
+
destinationGas,
|
|
2629
|
+
};
|
|
2630
|
+
}
|
|
2631
|
+
}
|
|
2632
|
+
class StarknetWarpTokenWriterBase extends StarknetWarpTokenReaderBase {
|
|
2633
|
+
signer;
|
|
2634
|
+
constructor(provider, signer) {
|
|
2635
|
+
super(provider);
|
|
2636
|
+
this.signer = signer;
|
|
2637
|
+
}
|
|
2638
|
+
validateCreateConfig(config) {
|
|
2639
|
+
(0,validation/* assert */.v)(!config.scale, 'scale is unsupported for Starknet warp tokens');
|
|
2640
|
+
}
|
|
2641
|
+
validateUpdateConfig(current, expected) {
|
|
2642
|
+
(0,validation/* assert */.v)(!expected.scale, 'scale is unsupported for Starknet warp tokens');
|
|
2643
|
+
(0,validation/* assert */.v)((0,addresses/* eqAddressStarknet */.PD)(current.mailbox, expected.mailbox), `Cannot change Starknet warp token mailbox from ${current.mailbox} to ${expected.mailbox}`);
|
|
2644
|
+
}
|
|
2645
|
+
async create(artifact) {
|
|
2646
|
+
this.validateCreateConfig(artifact.config);
|
|
2647
|
+
this.assertNoOrphanDestinationGas(artifact.config);
|
|
2648
|
+
const receipts = [];
|
|
2649
|
+
const createReceipt = await this.createToken(artifact);
|
|
2650
|
+
receipts.push(createReceipt);
|
|
2651
|
+
(0,validation/* assert */.v)(createReceipt.contractAddress, 'failed to deploy Starknet warp token');
|
|
2652
|
+
const tokenAddress = createReceipt.contractAddress;
|
|
2653
|
+
receipts.push(...(await this.applyPostCreateConfig(tokenAddress, artifact.config, {
|
|
2654
|
+
owner: this.signer.getSignerAddress(),
|
|
2655
|
+
interchainSecurityModule: undefined,
|
|
2656
|
+
hook: undefined,
|
|
2657
|
+
remoteRouters: {},
|
|
2658
|
+
destinationGas: {},
|
|
2659
|
+
})));
|
|
2660
|
+
return [
|
|
2661
|
+
{
|
|
2662
|
+
artifactState: dist_artifact/* ArtifactState */.O2.DEPLOYED,
|
|
2663
|
+
config: artifact.config,
|
|
2664
|
+
deployed: { address: normalizeStarknetAddressSafe(tokenAddress) },
|
|
2665
|
+
},
|
|
2666
|
+
receipts,
|
|
2667
|
+
];
|
|
2668
|
+
}
|
|
2669
|
+
async update(artifact) {
|
|
2670
|
+
const current = await this.read(artifact.deployed.address);
|
|
2671
|
+
const expectedConfig = this.preserveUnsetHookAndIsm(current.config, artifact.config);
|
|
2672
|
+
this.validateUpdateConfig(current.config, expectedConfig);
|
|
2673
|
+
this.assertNoOrphanDestinationGas(expectedConfig);
|
|
2674
|
+
const txs = [];
|
|
2675
|
+
const tokenAddress = artifact.deployed.address;
|
|
2676
|
+
let ownerTx;
|
|
2677
|
+
const currentOwner = current.config.owner;
|
|
2678
|
+
if (!(0,addresses/* eqAddressStarknet */.PD)(currentOwner, expectedConfig.owner)) {
|
|
2679
|
+
ownerTx = {
|
|
2680
|
+
annotation: 'Setting warp token owner',
|
|
2681
|
+
...(await this.signer.getSetTokenOwnerTransaction({
|
|
2682
|
+
signer: this.signer.getSignerAddress(),
|
|
2683
|
+
tokenAddress,
|
|
2684
|
+
newOwner: expectedConfig.owner,
|
|
2685
|
+
})),
|
|
2686
|
+
};
|
|
2687
|
+
}
|
|
2688
|
+
const currentIsm = (0,dist_artifact/* artifactOnChainToAddress */.wM)(current.config.interchainSecurityModule, normalizeStarknetAddressSafe);
|
|
2689
|
+
const expectedIsm = (0,dist_artifact/* artifactOnChainToAddress */.wM)(expectedConfig.interchainSecurityModule, normalizeStarknetAddressSafe);
|
|
2690
|
+
if (!(0,addresses/* eqAddressStarknet */.PD)(currentIsm ?? addresses/* ZERO_ADDRESS_HEX_32 */.qx, expectedIsm ?? addresses/* ZERO_ADDRESS_HEX_32 */.qx)) {
|
|
2691
|
+
txs.push({
|
|
2692
|
+
annotation: 'Setting warp token ISM',
|
|
2693
|
+
...(await this.signer.getSetTokenIsmTransaction({
|
|
2694
|
+
signer: this.signer.getSignerAddress(),
|
|
2695
|
+
tokenAddress,
|
|
2696
|
+
ismAddress: expectedIsm,
|
|
2697
|
+
})),
|
|
2698
|
+
});
|
|
2699
|
+
}
|
|
2700
|
+
const currentHook = (0,dist_artifact/* artifactOnChainToAddress */.wM)(current.config.hook, normalizeStarknetAddressSafe);
|
|
2701
|
+
const expectedHook = (0,dist_artifact/* artifactOnChainToAddress */.wM)(expectedConfig.hook, normalizeStarknetAddressSafe);
|
|
2702
|
+
if (!(0,addresses/* eqAddressStarknet */.PD)(currentHook ?? addresses/* ZERO_ADDRESS_HEX_32 */.qx, expectedHook ?? addresses/* ZERO_ADDRESS_HEX_32 */.qx)) {
|
|
2703
|
+
txs.push({
|
|
2704
|
+
annotation: 'Setting warp token hook',
|
|
2705
|
+
...(await this.signer.getSetTokenHookTransaction({
|
|
2706
|
+
signer: this.signer.getSignerAddress(),
|
|
2707
|
+
tokenAddress,
|
|
2708
|
+
hookAddress: expectedHook,
|
|
2709
|
+
})),
|
|
2710
|
+
});
|
|
2711
|
+
}
|
|
2712
|
+
const routerUpdates = (0,warp/* computeRemoteRoutersUpdates */.aq)({
|
|
2713
|
+
remoteRouters: current.config.remoteRouters,
|
|
2714
|
+
destinationGas: current.config.destinationGas,
|
|
2715
|
+
}, {
|
|
2716
|
+
remoteRouters: expectedConfig.remoteRouters,
|
|
2717
|
+
destinationGas: expectedConfig.destinationGas,
|
|
2718
|
+
}, addresses/* eqAddressStarknet */.PD);
|
|
2719
|
+
for (const domain of routerUpdates.toUnenroll.sort((a, b) => a - b)) {
|
|
2720
|
+
txs.push({
|
|
2721
|
+
annotation: `Unenrolling remote router for domain ${domain}`,
|
|
2722
|
+
...(await this.signer.getUnenrollRemoteRouterTransaction({
|
|
2723
|
+
signer: this.signer.getSignerAddress(),
|
|
2724
|
+
tokenAddress,
|
|
2725
|
+
receiverDomainId: domain,
|
|
2726
|
+
})),
|
|
2727
|
+
});
|
|
2728
|
+
}
|
|
2729
|
+
for (const route of routerUpdates.toEnroll.sort((a, b) => a.domainId - b.domainId)) {
|
|
2730
|
+
txs.push({
|
|
2731
|
+
annotation: `Enrolling remote router for domain ${route.domainId}`,
|
|
2732
|
+
...(await this.signer.getEnrollRemoteRouterTransaction({
|
|
2733
|
+
signer: this.signer.getSignerAddress(),
|
|
2734
|
+
tokenAddress,
|
|
2735
|
+
remoteRouter: {
|
|
2736
|
+
receiverDomainId: route.domainId,
|
|
2737
|
+
receiverAddress: route.routerAddress,
|
|
2738
|
+
gas: normalizeGas(route.gas),
|
|
2739
|
+
},
|
|
2740
|
+
})),
|
|
2741
|
+
});
|
|
2742
|
+
}
|
|
2743
|
+
if (ownerTx) {
|
|
2744
|
+
txs.push(ownerTx);
|
|
2745
|
+
}
|
|
2746
|
+
return txs;
|
|
2747
|
+
}
|
|
2748
|
+
preserveUnsetHookAndIsm(current, expected) {
|
|
2749
|
+
const expectedIsm = (0,dist_artifact/* artifactOnChainToAddress */.wM)(expected.interchainSecurityModule, normalizeStarknetAddressSafe);
|
|
2750
|
+
const expectedHook = (0,dist_artifact/* artifactOnChainToAddress */.wM)(expected.hook, normalizeStarknetAddressSafe);
|
|
2751
|
+
return {
|
|
2752
|
+
...expected,
|
|
2753
|
+
interchainSecurityModule: (0,addresses/* isEmptyAddress */.Ae)(expectedIsm)
|
|
2754
|
+
? (0,dist_artifact/* addressToUnderivedArtifact */.Se)((0,dist_artifact/* artifactOnChainToAddress */.wM)(current.interchainSecurityModule, normalizeStarknetAddressSafe))
|
|
2755
|
+
: expected.interchainSecurityModule,
|
|
2756
|
+
hook: (0,addresses/* isEmptyAddress */.Ae)(expectedHook)
|
|
2757
|
+
? (0,dist_artifact/* addressToUnderivedArtifact */.Se)((0,dist_artifact/* artifactOnChainToAddress */.wM)(current.hook, normalizeStarknetAddressSafe))
|
|
2758
|
+
: expected.hook,
|
|
2759
|
+
};
|
|
2760
|
+
}
|
|
2761
|
+
assertNoOrphanDestinationGas(config) {
|
|
2762
|
+
for (const domain of Object.keys(config.destinationGas)) {
|
|
2763
|
+
(0,validation/* assert */.v)(config.remoteRouters[Number(domain)], `destinationGas for domain ${domain} requires a matching remote router on Starknet`);
|
|
2764
|
+
}
|
|
2765
|
+
}
|
|
2766
|
+
async applyPostCreateConfig(tokenAddress, expected, current) {
|
|
2767
|
+
const receipts = [];
|
|
2768
|
+
let ownerTx;
|
|
2769
|
+
const expectedIsm = (0,dist_artifact/* artifactOnChainToAddress */.wM)(expected.interchainSecurityModule, normalizeStarknetAddressSafe);
|
|
2770
|
+
if (expectedIsm) {
|
|
2771
|
+
const tx = await this.signer.getSetTokenIsmTransaction({
|
|
2772
|
+
signer: this.signer.getSignerAddress(),
|
|
2773
|
+
tokenAddress,
|
|
2774
|
+
ismAddress: expectedIsm,
|
|
2775
|
+
});
|
|
2776
|
+
receipts.push(await this.signer.sendAndConfirmTransaction(tx));
|
|
2777
|
+
}
|
|
2778
|
+
const expectedHook = (0,dist_artifact/* artifactOnChainToAddress */.wM)(expected.hook, normalizeStarknetAddressSafe);
|
|
2779
|
+
if (expectedHook) {
|
|
2780
|
+
const tx = await this.signer.getSetTokenHookTransaction({
|
|
2781
|
+
signer: this.signer.getSignerAddress(),
|
|
2782
|
+
tokenAddress,
|
|
2783
|
+
hookAddress: expectedHook,
|
|
2784
|
+
});
|
|
2785
|
+
receipts.push(await this.signer.sendAndConfirmTransaction(tx));
|
|
2786
|
+
}
|
|
2787
|
+
for (const domain of Object.keys(expected.remoteRouters)
|
|
2788
|
+
.map(Number)
|
|
2789
|
+
.sort((a, b) => a - b)) {
|
|
2790
|
+
const remoteRouter = expected.remoteRouters[domain];
|
|
2791
|
+
(0,validation/* assert */.v)(remoteRouter, `Missing remote router for Starknet domain ${domain}`);
|
|
2792
|
+
const tx = await this.signer.getEnrollRemoteRouterTransaction({
|
|
2793
|
+
signer: this.signer.getSignerAddress(),
|
|
2794
|
+
tokenAddress,
|
|
2795
|
+
remoteRouter: {
|
|
2796
|
+
receiverDomainId: domain,
|
|
2797
|
+
receiverAddress: remoteRouter.address,
|
|
2798
|
+
gas: normalizeGas(expected.destinationGas[domain]),
|
|
2799
|
+
},
|
|
2800
|
+
});
|
|
2801
|
+
receipts.push(await this.signer.sendAndConfirmTransaction(tx));
|
|
2802
|
+
}
|
|
2803
|
+
const currentOwner = current.owner;
|
|
2804
|
+
if (!(0,addresses/* eqAddressStarknet */.PD)(currentOwner, expected.owner)) {
|
|
2805
|
+
ownerTx = await this.signer.getSetTokenOwnerTransaction({
|
|
2806
|
+
signer: this.signer.getSignerAddress(),
|
|
2807
|
+
tokenAddress,
|
|
2808
|
+
newOwner: expected.owner,
|
|
2809
|
+
});
|
|
2810
|
+
}
|
|
2811
|
+
if (ownerTx) {
|
|
2812
|
+
receipts.push(await this.signer.sendAndConfirmTransaction(ownerTx));
|
|
2813
|
+
}
|
|
2814
|
+
return receipts;
|
|
2815
|
+
}
|
|
2816
|
+
}
|
|
2817
|
+
//# sourceMappingURL=token-artifact-manager.js.map
|
|
2818
|
+
;// CONCATENATED MODULE: ../starknet-sdk/dist/warp/collateral-token-artifact-manager.js
|
|
2819
|
+
|
|
2820
|
+
|
|
2821
|
+
|
|
2822
|
+
|
|
2823
|
+
class StarknetCollateralTokenReader extends StarknetWarpTokenReaderBase {
|
|
2824
|
+
tokenType = 'collateral';
|
|
2825
|
+
toConfig(token, remoteRouters) {
|
|
2826
|
+
return {
|
|
2827
|
+
type: warp/* TokenType */.ks.collateral,
|
|
2828
|
+
...this.baseConfig(token, remoteRouters),
|
|
2829
|
+
token: normalizeStarknetAddressSafe(token.denom),
|
|
2830
|
+
name: token.name,
|
|
2831
|
+
symbol: token.symbol,
|
|
2832
|
+
decimals: token.decimals,
|
|
2833
|
+
};
|
|
2834
|
+
}
|
|
2835
|
+
}
|
|
2836
|
+
class StarknetCollateralTokenWriter extends StarknetWarpTokenWriterBase {
|
|
2837
|
+
tokenType = 'collateral';
|
|
2838
|
+
toConfig(token, remoteRouters) {
|
|
2839
|
+
return {
|
|
2840
|
+
type: warp/* TokenType */.ks.collateral,
|
|
2841
|
+
...this.baseConfig(token, remoteRouters),
|
|
2842
|
+
token: normalizeStarknetAddressSafe(token.denom),
|
|
2843
|
+
name: token.name,
|
|
2844
|
+
symbol: token.symbol,
|
|
2845
|
+
decimals: token.decimals,
|
|
2846
|
+
};
|
|
2847
|
+
}
|
|
2848
|
+
async createToken(artifact) {
|
|
2849
|
+
const tx = await this.signer.getCreateCollateralTokenTransaction({
|
|
2850
|
+
signer: this.signer.getSignerAddress(),
|
|
2851
|
+
mailboxAddress: artifact.config.mailbox,
|
|
2852
|
+
collateralDenom: artifact.config.token,
|
|
2853
|
+
});
|
|
2854
|
+
return this.signer.sendAndConfirmTransaction(tx);
|
|
2855
|
+
}
|
|
2856
|
+
validateUpdateConfig(current, expected) {
|
|
2857
|
+
super.validateUpdateConfig(current, expected);
|
|
2858
|
+
(0,validation/* assert */.v)((0,addresses/* eqAddressStarknet */.PD)(current.token, expected.token), `Cannot change Starknet collateral token from ${current.token} to ${expected.token}`);
|
|
2859
|
+
}
|
|
2860
|
+
}
|
|
2861
|
+
//# sourceMappingURL=collateral-token-artifact-manager.js.map
|
|
2862
|
+
;// CONCATENATED MODULE: ../starknet-sdk/dist/warp/native-token-artifact-manager.js
|
|
2863
|
+
|
|
2864
|
+
|
|
2865
|
+
class StarknetNativeTokenReader extends StarknetWarpTokenReaderBase {
|
|
2866
|
+
tokenType = 'native';
|
|
2867
|
+
toConfig(token, remoteRouters) {
|
|
2868
|
+
return {
|
|
2869
|
+
type: warp/* TokenType */.ks.native,
|
|
2870
|
+
...this.baseConfig(token, remoteRouters),
|
|
2871
|
+
};
|
|
2872
|
+
}
|
|
2873
|
+
}
|
|
2874
|
+
class StarknetNativeTokenWriter extends StarknetWarpTokenWriterBase {
|
|
2875
|
+
tokenType = 'native';
|
|
2876
|
+
toConfig(token, remoteRouters) {
|
|
2877
|
+
return {
|
|
2878
|
+
type: warp/* TokenType */.ks.native,
|
|
2879
|
+
...this.baseConfig(token, remoteRouters),
|
|
2880
|
+
};
|
|
2881
|
+
}
|
|
2882
|
+
async createToken(artifact) {
|
|
2883
|
+
const tx = await this.signer.getCreateNativeTokenTransaction({
|
|
2884
|
+
signer: this.signer.getSignerAddress(),
|
|
2885
|
+
mailboxAddress: artifact.config.mailbox,
|
|
2886
|
+
});
|
|
2887
|
+
return this.signer.sendAndConfirmTransaction(tx);
|
|
2888
|
+
}
|
|
2889
|
+
}
|
|
2890
|
+
//# sourceMappingURL=native-token-artifact-manager.js.map
|
|
2891
|
+
;// CONCATENATED MODULE: ../starknet-sdk/dist/warp/synthetic-token-artifact-manager.js
|
|
2892
|
+
|
|
2893
|
+
|
|
2894
|
+
|
|
2895
|
+
class StarknetSyntheticTokenReader extends StarknetWarpTokenReaderBase {
|
|
2896
|
+
tokenType = 'synthetic';
|
|
2897
|
+
toConfig(token, remoteRouters) {
|
|
2898
|
+
return {
|
|
2899
|
+
type: warp/* TokenType */.ks.synthetic,
|
|
2900
|
+
...this.baseConfig(token, remoteRouters),
|
|
2901
|
+
name: token.name,
|
|
2902
|
+
symbol: token.symbol,
|
|
2903
|
+
decimals: token.decimals,
|
|
2904
|
+
};
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2907
|
+
class StarknetSyntheticTokenWriter extends StarknetWarpTokenWriterBase {
|
|
2908
|
+
tokenType = 'synthetic';
|
|
2909
|
+
toConfig(token, remoteRouters) {
|
|
2910
|
+
return {
|
|
2911
|
+
type: warp/* TokenType */.ks.synthetic,
|
|
2912
|
+
...this.baseConfig(token, remoteRouters),
|
|
2913
|
+
name: token.name,
|
|
2914
|
+
symbol: token.symbol,
|
|
2915
|
+
decimals: token.decimals,
|
|
2916
|
+
};
|
|
2917
|
+
}
|
|
2918
|
+
validateCreateConfig(config) {
|
|
2919
|
+
super.validateCreateConfig(config);
|
|
2920
|
+
(0,validation/* assert */.v)(!config.metadataUri, 'metadataUri is unsupported for Starknet synthetic warp tokens');
|
|
2921
|
+
}
|
|
2922
|
+
validateUpdateConfig(current, expected) {
|
|
2923
|
+
super.validateUpdateConfig(current, expected);
|
|
2924
|
+
(0,validation/* assert */.v)(current.name === expected.name, `Cannot change Starknet synthetic token name from ${current.name} to ${expected.name}`);
|
|
2925
|
+
(0,validation/* assert */.v)(current.symbol === expected.symbol, `Cannot change Starknet synthetic token symbol from ${current.symbol} to ${expected.symbol}`);
|
|
2926
|
+
(0,validation/* assert */.v)(current.decimals === expected.decimals, `Cannot change Starknet synthetic token decimals from ${current.decimals} to ${expected.decimals}`);
|
|
2927
|
+
(0,validation/* assert */.v)(!expected.metadataUri, 'metadataUri is unsupported for Starknet synthetic warp tokens');
|
|
2928
|
+
}
|
|
2929
|
+
async createToken(artifact) {
|
|
2930
|
+
const tx = await this.signer.getCreateSyntheticTokenTransaction({
|
|
2931
|
+
signer: this.signer.getSignerAddress(),
|
|
2932
|
+
mailboxAddress: artifact.config.mailbox,
|
|
2933
|
+
name: artifact.config.name,
|
|
2934
|
+
denom: artifact.config.symbol,
|
|
2935
|
+
decimals: artifact.config.decimals,
|
|
2936
|
+
});
|
|
2937
|
+
return this.signer.sendAndConfirmTransaction(tx);
|
|
2938
|
+
}
|
|
2939
|
+
}
|
|
2940
|
+
//# sourceMappingURL=synthetic-token-artifact-manager.js.map
|
|
2941
|
+
;// CONCATENATED MODULE: ../starknet-sdk/dist/warp/warp-artifact-manager.js
|
|
2942
|
+
|
|
2943
|
+
|
|
2944
|
+
|
|
2945
|
+
|
|
2946
|
+
|
|
2947
|
+
|
|
2948
|
+
|
|
2949
|
+
class StarknetWarpArtifactManager {
|
|
2950
|
+
provider;
|
|
2951
|
+
constructor(chainMetadata) {
|
|
2952
|
+
this.provider = StarknetProvider.connect((chainMetadata.rpcUrls ?? []).map(({ http }) => http), chainMetadata.chainId, { metadata: chainMetadata });
|
|
2953
|
+
}
|
|
2954
|
+
supportsHookUpdates() {
|
|
2955
|
+
return true;
|
|
2956
|
+
}
|
|
2957
|
+
async readWarpToken(address) {
|
|
2958
|
+
const token = await this.provider.getToken({ tokenAddress: address });
|
|
2959
|
+
return this.createReader(getStarknetWarpType(token.tokenType)).read(address);
|
|
2960
|
+
}
|
|
2961
|
+
createReader(type) {
|
|
2962
|
+
const readers = {
|
|
2963
|
+
native: new StarknetNativeTokenReader(this.provider),
|
|
2964
|
+
collateral: new StarknetCollateralTokenReader(this.provider),
|
|
2965
|
+
synthetic: new StarknetSyntheticTokenReader(this.provider),
|
|
2966
|
+
crossCollateral: {
|
|
2967
|
+
read: async () => {
|
|
2968
|
+
throw new Error('Cross-collateral tokens are not supported on Starknet');
|
|
2969
|
+
},
|
|
2970
|
+
},
|
|
2971
|
+
};
|
|
2972
|
+
return readers[type];
|
|
2973
|
+
}
|
|
2974
|
+
createWriter(type, signer) {
|
|
2975
|
+
(0,validation/* assert */.v)(signer instanceof StarknetSigner, 'Expected StarknetSigner');
|
|
2976
|
+
const writers = {
|
|
2977
|
+
native: new StarknetNativeTokenWriter(this.provider, signer),
|
|
2978
|
+
collateral: new StarknetCollateralTokenWriter(this.provider, signer),
|
|
2979
|
+
synthetic: new StarknetSyntheticTokenWriter(this.provider, signer),
|
|
2980
|
+
crossCollateral: {
|
|
2981
|
+
read: async () => {
|
|
2982
|
+
throw new Error('Cross-collateral tokens are not supported on Starknet');
|
|
2983
|
+
},
|
|
2984
|
+
create: async () => {
|
|
2985
|
+
throw new Error('Cross-collateral tokens are not supported on Starknet');
|
|
2986
|
+
},
|
|
2987
|
+
update: async () => {
|
|
2988
|
+
throw new Error('Cross-collateral tokens are not supported on Starknet');
|
|
2989
|
+
},
|
|
2990
|
+
},
|
|
2991
|
+
};
|
|
2992
|
+
return writers[type];
|
|
2993
|
+
}
|
|
2994
|
+
}
|
|
2995
|
+
//# sourceMappingURL=warp-artifact-manager.js.map
|
|
2996
|
+
;// CONCATENATED MODULE: ../starknet-sdk/dist/clients/protocol.js
|
|
2997
|
+
|
|
2998
|
+
|
|
2999
|
+
|
|
3000
|
+
|
|
3001
|
+
|
|
3002
|
+
|
|
3003
|
+
|
|
3004
|
+
|
|
3005
|
+
class StarknetProtocolProvider {
|
|
3006
|
+
async createProvider(chainMetadata) {
|
|
3007
|
+
const rpcUrls = (chainMetadata.rpcUrls ?? []).map(({ http }) => http);
|
|
3008
|
+
(0,validation/* assert */.v)(rpcUrls.length > 0, 'rpc urls undefined for Starknet');
|
|
3009
|
+
return StarknetProvider.connect(rpcUrls, chainMetadata.chainId, {
|
|
3010
|
+
metadata: chainMetadata,
|
|
3011
|
+
});
|
|
3012
|
+
}
|
|
3013
|
+
async createSigner(chainMetadata, config) {
|
|
3014
|
+
const rpcUrls = (chainMetadata.rpcUrls ?? []).map(({ http }) => http);
|
|
3015
|
+
(0,validation/* assert */.v)(rpcUrls.length > 0, 'rpc urls undefined for Starknet');
|
|
3016
|
+
(0,validation/* assert */.v)(config.privateKey, 'privateKey missing for Starknet signer');
|
|
3017
|
+
(0,validation/* assert */.v)(config.accountAddress, 'accountAddress missing for Starknet signer');
|
|
3018
|
+
return StarknetSigner.connectWithSigner(rpcUrls, config.privateKey, {
|
|
3019
|
+
metadata: chainMetadata,
|
|
3020
|
+
accountAddress: config.accountAddress,
|
|
3021
|
+
});
|
|
3022
|
+
}
|
|
3023
|
+
async createSubmitter(_chainMetadata, _config) {
|
|
3024
|
+
throw Error('Not implemented');
|
|
3025
|
+
}
|
|
3026
|
+
createIsmArtifactManager(chainMetadata) {
|
|
3027
|
+
return new StarknetIsmArtifactManager(chainMetadata);
|
|
3028
|
+
}
|
|
3029
|
+
createHookArtifactManager(chainMetadata, context) {
|
|
3030
|
+
return new StarknetHookArtifactManager(chainMetadata, context);
|
|
3031
|
+
}
|
|
3032
|
+
createWarpArtifactManager(chainMetadata, _context) {
|
|
3033
|
+
return new StarknetWarpArtifactManager(chainMetadata);
|
|
3034
|
+
}
|
|
3035
|
+
createMailboxArtifactManager(chainMetadata) {
|
|
3036
|
+
return new StarknetMailboxArtifactManager(chainMetadata);
|
|
3037
|
+
}
|
|
3038
|
+
createValidatorAnnounceArtifactManager(chainMetadata) {
|
|
3039
|
+
return new StarknetValidatorAnnounceArtifactManager(chainMetadata);
|
|
3040
|
+
}
|
|
3041
|
+
getMinGas() {
|
|
3042
|
+
return {
|
|
3043
|
+
CORE_DEPLOY_GAS: BigInt(1e9),
|
|
3044
|
+
WARP_DEPLOY_GAS: BigInt(3e8),
|
|
3045
|
+
TEST_SEND_GAS: BigInt(3e7),
|
|
3046
|
+
AVS_GAS: BigInt(3e8),
|
|
3047
|
+
ISM_DEPLOY_GAS: BigInt(5e7),
|
|
3048
|
+
};
|
|
3049
|
+
}
|
|
3050
|
+
}
|
|
3051
|
+
//# sourceMappingURL=protocol.js.map
|
|
3052
|
+
;// CONCATENATED MODULE: ../starknet-sdk/dist/index.js
|
|
3053
|
+
|
|
3054
|
+
|
|
3055
|
+
|
|
3056
|
+
|
|
3057
|
+
|
|
3058
|
+
|
|
3059
|
+
|
|
3060
|
+
|
|
3061
|
+
//# sourceMappingURL=index.js.map
|
|
3062
|
+
|
|
3063
|
+
/***/ })
|
|
3064
|
+
|
|
3065
|
+
};
|