@layerzerolabs/lz-v2-stellar-sdk 0.2.121 → 0.2.122

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.
Files changed (67) hide show
  1. package/.turbo/turbo-build.log +235 -1
  2. package/.turbo/turbo-lint.log +8 -0
  3. package/.turbo/turbo-test.log +41 -1361
  4. package/dist/generated/dvn.d.ts +2 -2
  5. package/dist/generated/dvn.js +2 -2
  6. package/dist/generated/endpoint.d.ts +2 -2
  7. package/dist/generated/endpoint.js +2 -2
  8. package/dist/generated/executor.d.ts +3 -3
  9. package/dist/generated/executor.d.ts.map +1 -1
  10. package/dist/generated/executor.js +3 -3
  11. package/dist/generated/executor.js.map +1 -1
  12. package/dist/generated/price_feed.d.ts +2 -2
  13. package/dist/generated/price_feed.js +2 -2
  14. package/dist/generated/sml.d.ts +2 -2
  15. package/dist/generated/sml.js +2 -2
  16. package/dist/generated/uln302.d.ts +2 -2
  17. package/dist/generated/uln302.js +2 -2
  18. package/dist/index.d.ts +0 -3
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +0 -4
  21. package/dist/index.js.map +1 -1
  22. package/package.json +13 -12
  23. package/rust-toolchain.toml +4 -0
  24. package/src/index.ts +0 -5
  25. package/test/suites/constants.ts +30 -51
  26. package/test/suites/deploy.ts +13 -273
  27. package/test/suites/globalSetup.ts +3 -602
  28. package/test/upgrader.test.ts +1 -0
  29. package/test/utils.ts +11 -658
  30. package/ts-bindings-gen.toml +59 -0
  31. package/dist/generated/counter.d.ts +0 -1253
  32. package/dist/generated/counter.d.ts.map +0 -1
  33. package/dist/generated/counter.js +0 -391
  34. package/dist/generated/counter.js.map +0 -1
  35. package/dist/generated/oft.d.ts +0 -1638
  36. package/dist/generated/oft.d.ts.map +0 -1
  37. package/dist/generated/oft.js +0 -463
  38. package/dist/generated/oft.js.map +0 -1
  39. package/dist/generated/sac_manager.d.ts +0 -567
  40. package/dist/generated/sac_manager.d.ts.map +0 -1
  41. package/dist/generated/sac_manager.js +0 -198
  42. package/dist/generated/sac_manager.js.map +0 -1
  43. package/src/generated/bml.ts +0 -672
  44. package/src/generated/counter.ts +0 -1208
  45. package/src/generated/dvn.ts +0 -1508
  46. package/src/generated/dvn_fee_lib.ts +0 -595
  47. package/src/generated/endpoint.ts +0 -1181
  48. package/src/generated/executor.ts +0 -1521
  49. package/src/generated/executor_fee_lib.ts +0 -1027
  50. package/src/generated/executor_helper.ts +0 -833
  51. package/src/generated/layerzero_view.ts +0 -1119
  52. package/src/generated/oft.ts +0 -1609
  53. package/src/generated/price_feed.ts +0 -793
  54. package/src/generated/sac_manager.ts +0 -555
  55. package/src/generated/sml.ts +0 -921
  56. package/src/generated/treasury.ts +0 -887
  57. package/src/generated/uln302.ts +0 -1224
  58. package/src/generated/upgrader.ts +0 -276
  59. package/test/counter-sml.test.ts +0 -480
  60. package/test/counter-uln.test.ts +0 -584
  61. package/test/oft-sml.test.ts +0 -750
  62. package/test/sac-manager.test.ts +0 -464
  63. package/test/secp256k1.ts +0 -59
  64. package/test/suites/dummyContractClient.ts +0 -168
  65. package/test/suites/localnet.ts +0 -192
  66. package/test/suites/scan.ts +0 -202
  67. package/turbo.json +0 -15
@@ -1,604 +1,5 @@
1
- import { Keypair, rpc } from '@stellar/stellar-sdk';
2
- import { readFileSync } from 'fs';
3
- import path from 'path';
4
- import type { GlobalSetupContext } from 'vitest/node';
1
+ import { createLocalnetOnlyGlobalSetup } from '@layerzerolabs/test-utils-stellar';
5
2
 
6
- import { getFullyQualifiedRepoRootPath } from '@layerzerolabs/common-node-utils';
3
+ import { env } from './constants.js';
7
4
 
8
- import { Client as DvnClient } from '../../src/generated/dvn.js';
9
- import { Client as DvnFeeLibClient } from '../../src/generated/dvn_fee_lib.js';
10
- import { Client as EndpointClient } from '../../src/generated/endpoint.js';
11
- import { Client as ExecutorClient } from '../../src/generated/executor.js';
12
- import { Client as ExecutorFeeLibClient } from '../../src/generated/executor_fee_lib.js';
13
- import { Client as ExecutorHelperClient } from '../../src/generated/executor_helper.js';
14
- import { Client as PriceFeedClient } from '../../src/generated/price_feed.js';
15
- import { Client as SMLClient } from '../../src/generated/sml.js';
16
- import { Client as TreasuryClient } from '../../src/generated/treasury.js';
17
- import { Client as Uln302Client } from '../../src/generated/uln302.js';
18
- import { createClient } from '../utils.js';
19
- import {
20
- CHAIN_B_DEPLOYER,
21
- DEFAULT_DEPLOYER,
22
- DVN_SIGNER,
23
- DVN_VID,
24
- EID_A,
25
- EID_B,
26
- EXECUTOR_ADMIN,
27
- NATIVE_TOKEN_ADDRESS,
28
- RPC_URL,
29
- ZRO_TOKEN_ADDRESS,
30
- } from './constants.js';
31
- import { deployContract, uploadWasm } from './deploy.js';
32
- import { startStellarLocalnet, stopStellarLocalnet } from './localnet.js';
33
-
34
- /**
35
- * Addresses for a single chain's protocol contracts
36
- */
37
- export interface ChainAddresses {
38
- eid: number;
39
- endpointV2: string;
40
- uln302: string;
41
- sml: string;
42
- treasury: string;
43
- executor: string;
44
- executorHelper: string;
45
- executorFeeLib: string;
46
- priceFeed: string;
47
- dvnFeeLib: string;
48
- dvn: string;
49
- }
50
-
51
- /**
52
- * Clients for a single chain's protocol contracts
53
- */
54
- interface ChainClients {
55
- endpointClient: EndpointClient;
56
- uln302Client: Uln302Client;
57
- smlClient: SMLClient;
58
- treasuryClient: TreasuryClient;
59
- executorClient: ExecutorClient;
60
- executorHelperClient: ExecutorHelperClient;
61
- executorFeeLibClient: ExecutorFeeLibClient;
62
- priceFeedClient: PriceFeedClient;
63
- dvnFeeLibClient: DvnFeeLibClient;
64
- dvnClient: DvnClient;
65
- }
66
-
67
- /**
68
- * Complete chain setup with addresses and clients
69
- */
70
- interface ChainSetup {
71
- addresses: ChainAddresses;
72
- clients: ChainClients;
73
- }
74
-
75
- // Declare the injection key type for vitest
76
- declare module 'vitest' {
77
- export interface ProvidedContext {
78
- chainA: ChainAddresses;
79
- chainB: ChainAddresses;
80
- }
81
- }
82
-
83
- interface WasmHashes {
84
- endpoint: string;
85
- treasury: string;
86
- uln302: string;
87
- sml: string;
88
- priceFeed: string;
89
- executorFeeLib: string;
90
- dvnFeeLib: string;
91
- dvn: string;
92
- executorHelper: string;
93
- executor: string;
94
- }
95
-
96
- /**
97
- * Upload all protocol WASM files once and return their hashes.
98
- */
99
- async function uploadAllWasms(wasmDir: string): Promise<WasmHashes> {
100
- const server = new rpc.Server(RPC_URL, { allowHttp: true });
101
-
102
- const wasmFiles = {
103
- endpoint: 'endpoint_v2.wasm',
104
- treasury: 'treasury.wasm',
105
- uln302: 'uln302.wasm',
106
- sml: 'simple_message_lib.wasm',
107
- priceFeed: 'price_feed.wasm',
108
- executorFeeLib: 'executor_fee_lib.wasm',
109
- dvnFeeLib: 'dvn_fee_lib.wasm',
110
- dvn: 'dvn.wasm',
111
- executorHelper: 'executor_helper.wasm',
112
- executor: 'executor.wasm',
113
- };
114
-
115
- const hashes: Record<string, string> = {};
116
- for (const [name, file] of Object.entries(wasmFiles)) {
117
- const wasmBuffer = readFileSync(path.join(wasmDir, file));
118
- console.log(`📤 Uploading ${name} WASM (${(wasmBuffer.length / 1024).toFixed(1)} KB)...`);
119
- hashes[name] = await uploadWasm(wasmBuffer, DEFAULT_DEPLOYER, server);
120
- }
121
-
122
- return hashes as unknown as WasmHashes;
123
- }
124
-
125
- /**
126
- * Deploy all protocol contracts for a single chain using pre-uploaded WASM hashes.
127
- * The deployer pays gas; contract ownership is always DEFAULT_DEPLOYER.
128
- */
129
- async function deployChainContracts(
130
- eid: number,
131
- chainLabel: string,
132
- deployer: Keypair,
133
- wasmDir: string,
134
- wasmHashes: WasmHashes,
135
- ): Promise<ChainAddresses> {
136
- const addresses: ChainAddresses = {
137
- eid,
138
- endpointV2: '',
139
- uln302: '',
140
- sml: '',
141
- treasury: '',
142
- executor: '',
143
- executorHelper: '',
144
- executorFeeLib: '',
145
- priceFeed: '',
146
- dvnFeeLib: '',
147
- dvn: '',
148
- };
149
-
150
- // 1. Deploy Endpoint
151
- console.log(`🚀 [${chainLabel}] Deploying Endpoint (EID: ${eid})...`);
152
- const deployedEndpoint = await deployContract<EndpointClient>(
153
- EndpointClient,
154
- path.join(wasmDir, 'endpoint_v2.wasm'),
155
- {
156
- eid: eid,
157
- owner: DEFAULT_DEPLOYER.publicKey(),
158
- native_token: NATIVE_TOKEN_ADDRESS,
159
- },
160
- deployer,
161
- { wasmHash: wasmHashes.endpoint },
162
- );
163
- addresses.endpointV2 = deployedEndpoint.options.contractId;
164
- console.log(`✅ [${chainLabel}] Endpoint deployed:`, addresses.endpointV2);
165
-
166
- // 2. Deploy Treasury
167
- console.log(`🚀 [${chainLabel}] Deploying Treasury...`);
168
- const deployedTreasury = await deployContract<TreasuryClient>(
169
- TreasuryClient,
170
- path.join(wasmDir, 'treasury.wasm'),
171
- { owner: DEFAULT_DEPLOYER.publicKey() },
172
- deployer,
173
- { wasmHash: wasmHashes.treasury },
174
- );
175
- addresses.treasury = deployedTreasury.options.contractId;
176
- console.log(`✅ [${chainLabel}] Treasury deployed:`, addresses.treasury);
177
-
178
- // 3. Deploy ULN302
179
- console.log(`🚀 [${chainLabel}] Deploying ULN302...`);
180
- const deployedUln302 = await deployContract<Uln302Client>(
181
- Uln302Client,
182
- path.join(wasmDir, 'uln302.wasm'),
183
- {
184
- owner: DEFAULT_DEPLOYER.publicKey(),
185
- endpoint: addresses.endpointV2,
186
- treasury: addresses.treasury,
187
- },
188
- deployer,
189
- { wasmHash: wasmHashes.uln302 },
190
- );
191
- addresses.uln302 = deployedUln302.options.contractId;
192
- console.log(`✅ [${chainLabel}] ULN302 deployed:`, addresses.uln302);
193
-
194
- // 4. Deploy SML (SimpleMessageLib)
195
- console.log(`🚀 [${chainLabel}] Deploying SimpleMessageLib...`);
196
- const deployedSml = await deployContract<SMLClient>(
197
- SMLClient,
198
- path.join(wasmDir, 'simple_message_lib.wasm'),
199
- {
200
- owner: DEFAULT_DEPLOYER.publicKey(),
201
- endpoint: addresses.endpointV2,
202
- fee_recipient: DEFAULT_DEPLOYER.publicKey(),
203
- },
204
- deployer,
205
- { wasmHash: wasmHashes.sml },
206
- );
207
- addresses.sml = deployedSml.options.contractId;
208
- console.log(`✅ [${chainLabel}] SimpleMessageLib deployed:`, addresses.sml);
209
-
210
- // 5. Deploy Price Feed
211
- console.log(`🚀 [${chainLabel}] Deploying Price Feed...`);
212
- const deployedPriceFeed = await deployContract<PriceFeedClient>(
213
- PriceFeedClient,
214
- path.join(wasmDir, 'price_feed.wasm'),
215
- {
216
- owner: DEFAULT_DEPLOYER.publicKey(),
217
- price_updater: DEFAULT_DEPLOYER.publicKey(),
218
- },
219
- deployer,
220
- { wasmHash: wasmHashes.priceFeed },
221
- );
222
- addresses.priceFeed = deployedPriceFeed.options.contractId;
223
- console.log(`✅ [${chainLabel}] Price Feed deployed:`, addresses.priceFeed);
224
-
225
- // 6. Deploy Executor Fee Lib
226
- console.log(`🚀 [${chainLabel}] Deploying Executor Fee Lib...`);
227
- const deployedExecutorFeeLib = await deployContract<ExecutorFeeLibClient>(
228
- ExecutorFeeLibClient,
229
- path.join(wasmDir, 'executor_fee_lib.wasm'),
230
- { owner: DEFAULT_DEPLOYER.publicKey() },
231
- deployer,
232
- { wasmHash: wasmHashes.executorFeeLib },
233
- );
234
- addresses.executorFeeLib = deployedExecutorFeeLib.options.contractId;
235
- console.log(`✅ [${chainLabel}] Executor Fee Lib deployed:`, addresses.executorFeeLib);
236
-
237
- // 7. Deploy DVN Fee Lib
238
- console.log(`🚀 [${chainLabel}] Deploying DVN Fee Lib...`);
239
- const deployedDvnFeeLib = await deployContract<DvnFeeLibClient>(
240
- DvnFeeLibClient,
241
- path.join(wasmDir, 'dvn_fee_lib.wasm'),
242
- { owner: DEFAULT_DEPLOYER.publicKey() },
243
- deployer,
244
- { wasmHash: wasmHashes.dvnFeeLib },
245
- );
246
- addresses.dvnFeeLib = deployedDvnFeeLib.options.contractId;
247
- console.log(`✅ [${chainLabel}] DVN Fee Lib deployed:`, addresses.dvnFeeLib);
248
-
249
- // 8. Deploy DVN (same signer for both chains)
250
- console.log(`🚀 [${chainLabel}] Deploying DVN...`);
251
- const deployedDvn = await deployContract<DvnClient>(
252
- DvnClient,
253
- path.join(wasmDir, 'dvn.wasm'),
254
- {
255
- vid: DVN_VID,
256
- signers: [DVN_SIGNER.ethAddress],
257
- threshold: 1,
258
- admins: [DEFAULT_DEPLOYER.publicKey()],
259
- supported_msglibs: [addresses.uln302],
260
- price_feed: addresses.priceFeed,
261
- default_multiplier_bps: 10000,
262
- worker_fee_lib: addresses.dvnFeeLib,
263
- deposit_address: DEFAULT_DEPLOYER.publicKey(),
264
- },
265
- deployer,
266
- { wasmHash: wasmHashes.dvn },
267
- );
268
- addresses.dvn = deployedDvn.options.contractId;
269
- console.log(`✅ [${chainLabel}] DVN deployed:`, addresses.dvn);
270
-
271
- // 9. Deploy Executor Helper
272
- console.log(`🚀 [${chainLabel}] Deploying Executor Helper...`);
273
- const deployedExecutorHelper = await deployContract<ExecutorHelperClient>(
274
- ExecutorHelperClient,
275
- path.join(wasmDir, 'executor_helper.wasm'),
276
- undefined,
277
- deployer,
278
- { wasmHash: wasmHashes.executorHelper },
279
- );
280
- addresses.executorHelper = deployedExecutorHelper.options.contractId;
281
- console.log(`✅ [${chainLabel}] Executor Helper deployed:`, addresses.executorHelper);
282
-
283
- // 10. Deploy Executor (supports both ULN302 and SML)
284
- console.log(`🚀 [${chainLabel}] Deploying Executor...`);
285
- const deployedExecutor = await deployContract<ExecutorClient>(
286
- ExecutorClient,
287
- path.join(wasmDir, 'executor.wasm'),
288
- {
289
- owner: DEFAULT_DEPLOYER.publicKey(),
290
- endpoint: addresses.endpointV2,
291
- admins: [EXECUTOR_ADMIN.publicKey(), DEFAULT_DEPLOYER.publicKey()],
292
- message_libs: [addresses.uln302, addresses.sml],
293
- price_feed: addresses.priceFeed,
294
- default_multiplier_bps: 10000,
295
- worker_fee_lib: addresses.executorFeeLib,
296
- deposit_address: DEFAULT_DEPLOYER.publicKey(),
297
- },
298
- deployer,
299
- { wasmHash: wasmHashes.executor },
300
- );
301
- addresses.executor = deployedExecutor.options.contractId;
302
- console.log(`✅ [${chainLabel}] Executor deployed:`, addresses.executor);
303
-
304
- return addresses;
305
- }
306
-
307
- /**
308
- * Register executor helper and create owner-signed clients for a chain.
309
- * Must be called sequentially (uses DEFAULT_DEPLOYER for signing).
310
- */
311
- async function initChainClients(
312
- addresses: ChainAddresses,
313
- chainLabel: string,
314
- ): Promise<ChainSetup> {
315
- // Register Executor Helper with Executor (needs owner-signed client)
316
- console.log(`🚀 [${chainLabel}] Registering Executor Helper with Executor...`);
317
- const executorClient = createClient(ExecutorClient, addresses.executor);
318
- await (
319
- await executorClient.set_executor_helper({
320
- helper: addresses.executorHelper,
321
- allowed_functions: ['execute', 'compose'],
322
- })
323
- ).signAndSend();
324
- console.log(`✅ [${chainLabel}] Executor Helper registered`);
325
-
326
- const clients: ChainClients = {
327
- endpointClient: createClient(EndpointClient, addresses.endpointV2),
328
- uln302Client: createClient(Uln302Client, addresses.uln302),
329
- smlClient: createClient(SMLClient, addresses.sml),
330
- treasuryClient: createClient(TreasuryClient, addresses.treasury),
331
- executorClient,
332
- executorHelperClient: createClient(ExecutorHelperClient, addresses.executorHelper),
333
- executorFeeLibClient: createClient(ExecutorFeeLibClient, addresses.executorFeeLib),
334
- priceFeedClient: createClient(PriceFeedClient, addresses.priceFeed),
335
- dvnFeeLibClient: createClient(DvnFeeLibClient, addresses.dvnFeeLib),
336
- dvnClient: createClient(DvnClient, addresses.dvn),
337
- };
338
-
339
- return { addresses, clients };
340
- }
341
-
342
- /**
343
- * Wire a single chain's protocol contracts for cross-chain communication
344
- *
345
- * @param chain - The chain to wire (this chain)
346
- * @param otherChain - The other chain (for cross-references)
347
- * @param chainLabel - Label for logging
348
- */
349
- async function wireChainContracts(
350
- chain: ChainSetup,
351
- otherChain: ChainSetup,
352
- chainLabel: string,
353
- ): Promise<void> {
354
- const { addresses, clients } = chain;
355
- const { endpointClient, uln302Client, priceFeedClient, executorClient, dvnClient } = clients;
356
-
357
- const thisEid = addresses.eid;
358
- const otherEid = otherChain.addresses.eid;
359
-
360
- console.log(
361
- `\n🔗 [${chainLabel}] Wiring protocol contracts (EID: ${thisEid} ↔ ${otherEid})...`,
362
- );
363
-
364
- // Register libraries
365
- await (await endpointClient.register_library({ new_lib: addresses.uln302 })).signAndSend();
366
- await (await endpointClient.register_library({ new_lib: addresses.sml })).signAndSend();
367
- console.log(`✅ [${chainLabel}] Libraries registered (ULN302 + SML)`);
368
-
369
- // Set ZRO token
370
- await (await endpointClient.set_zro({ zro: ZRO_TOKEN_ADDRESS })).signAndSend();
371
- console.log(`✅ [${chainLabel}] ZRO token set`);
372
-
373
- // ========================================================================
374
- // Configure for SENDING to the other chain (dst_eid = otherEid)
375
- // ========================================================================
376
-
377
- // ULN302 executor config for sending to other chain
378
- await (
379
- await uln302Client.set_default_executor_configs({
380
- params: [
381
- {
382
- dst_eid: otherEid,
383
- config: { executor: addresses.executor, max_message_size: 10000 },
384
- },
385
- ],
386
- })
387
- ).signAndSend();
388
- console.log(`✅ [${chainLabel}] ULN302 executor config set for dst_eid=${otherEid}`);
389
-
390
- // ULN302 send config: when sending to otherEid, use THIS chain's DVN for fee quoting
391
- // (The DVN needs dst_config for the destination EID to calculate fees)
392
- await (
393
- await uln302Client.set_default_send_uln_configs({
394
- params: [
395
- {
396
- eid: otherEid,
397
- config: {
398
- confirmations: 1n,
399
- required_dvns: [addresses.dvn], // THIS chain's DVN (has dst_config for otherEid)
400
- optional_dvns: [],
401
- optional_dvn_threshold: 0,
402
- },
403
- },
404
- ],
405
- })
406
- ).signAndSend();
407
- console.log(
408
- `✅ [${chainLabel}] ULN302 send config set for eid=${otherEid} (DVN: ${addresses.dvn})`,
409
- );
410
-
411
- // ========================================================================
412
- // Configure for RECEIVING from the other chain (src_eid = otherEid)
413
- // ========================================================================
414
-
415
- // ULN302 receive config: when receiving from otherEid, THIS chain's DVN verifies
416
- await (
417
- await uln302Client.set_default_receive_uln_configs({
418
- params: [
419
- {
420
- eid: otherEid,
421
- config: {
422
- confirmations: 1n,
423
- required_dvns: [addresses.dvn], // THIS chain's DVN verifies incoming
424
- optional_dvns: [],
425
- optional_dvn_threshold: 0,
426
- },
427
- },
428
- ],
429
- })
430
- ).signAndSend();
431
- console.log(
432
- `✅ [${chainLabel}] ULN302 receive config set for eid=${otherEid} (DVN: ${addresses.dvn})`,
433
- );
434
-
435
- // Set default send/receive libraries for the other chain
436
- await (
437
- await endpointClient.set_default_send_library({
438
- dst_eid: otherEid,
439
- new_lib: addresses.uln302,
440
- })
441
- ).signAndSend();
442
- await (
443
- await endpointClient.set_default_receive_library({
444
- src_eid: otherEid,
445
- new_lib: addresses.uln302,
446
- grace_period: 0n,
447
- })
448
- ).signAndSend();
449
- console.log(`✅ [${chainLabel}] Default libraries set to ULN302 for eid=${otherEid}`);
450
-
451
- // ========================================================================
452
- // Configure Price Feed for both chains
453
- // ========================================================================
454
-
455
- await (
456
- await priceFeedClient.set_price_ratio_denominator({ denominator: 100000000000000000000n })
457
- ).signAndSend();
458
- await (
459
- await priceFeedClient.set_native_token_price_usd({
460
- price_updater: DEFAULT_DEPLOYER.publicKey(),
461
- native_token_price_usd: 1000000000000000000n,
462
- })
463
- ).signAndSend();
464
-
465
- // Set prices for the other chain
466
- const NORMALIZED_OTHER_EID = otherEid % 30000;
467
- await (
468
- await priceFeedClient.set_price({
469
- price_updater: DEFAULT_DEPLOYER.publicKey(),
470
- prices: [
471
- {
472
- eid: NORMALIZED_OTHER_EID,
473
- price: {
474
- gas_per_byte: 1,
475
- gas_price_in_unit: 1n,
476
- price_ratio: 100000000000000000000n,
477
- },
478
- },
479
- ],
480
- })
481
- ).signAndSend();
482
- console.log(`✅ [${chainLabel}] Price Feed configured for eid=${otherEid}`);
483
-
484
- // ========================================================================
485
- // Configure Executor for sending to other chain
486
- // ========================================================================
487
-
488
- await (
489
- await executorClient.set_dst_config({
490
- admin: DEFAULT_DEPLOYER.publicKey(),
491
- params: [
492
- {
493
- dst_eid: otherEid,
494
- dst_config: {
495
- floor_margin_usd: 0n,
496
- lz_compose_base_gas: 50000n,
497
- lz_receive_base_gas: 100000n,
498
- multiplier_bps: 10000,
499
- native_cap: 1000000000000n,
500
- },
501
- },
502
- ],
503
- })
504
- ).signAndSend();
505
- console.log(`✅ [${chainLabel}] Executor configured for dst_eid=${otherEid}`);
506
-
507
- // ========================================================================
508
- // Configure DVN for verifying packets going to other chain
509
- // ========================================================================
510
-
511
- await (
512
- await dvnClient.set_dst_config({
513
- admin: DEFAULT_DEPLOYER.publicKey(),
514
- params: [
515
- {
516
- dst_eid: otherEid,
517
- config: {
518
- floor_margin_usd: 0n,
519
- gas: 100000n,
520
- multiplier_bps: 10000,
521
- },
522
- },
523
- ],
524
- })
525
- ).signAndSend();
526
- console.log(`✅ [${chainLabel}] DVN configured for dst_eid=${otherEid}`);
527
-
528
- console.log(`🎉 [${chainLabel}] Protocol wiring complete!`);
529
- }
530
-
531
- /**
532
- * Vitest Global Setup - runs ONCE before all test files
533
- * Deploys two complete protocol stacks (Chain A and Chain B) for cross-chain testing
534
- */
535
- export default async function globalSetup({
536
- provide,
537
- }: GlobalSetupContext): Promise<() => Promise<void>> {
538
- console.log('\n========================================');
539
- console.log('🌐 GLOBAL SETUP: Starting Stellar Localnet');
540
- console.log('========================================\n');
541
-
542
- await startStellarLocalnet();
543
-
544
- const repoRoot = await getFullyQualifiedRepoRootPath();
545
- const wasmDir = path.join(
546
- repoRoot,
547
- 'contracts',
548
- 'protocol',
549
- 'stellar',
550
- 'target',
551
- 'wasm32v1-none',
552
- 'release',
553
- );
554
-
555
- console.log('\n========================================');
556
- console.log('📤 GLOBAL SETUP: Uploading WASM (once)');
557
- console.log('========================================\n');
558
-
559
- const wasmHashes = await uploadAllWasms(wasmDir);
560
-
561
- console.log('\n========================================');
562
- console.log('📦 GLOBAL SETUP: Deploying Protocol Contracts (Two Chains in Parallel)');
563
- console.log('========================================\n');
564
-
565
- // Deploy both chains in parallel (each uses its own deployer key)
566
- const [addressesA, addressesB] = await Promise.all([
567
- deployChainContracts(EID_A, 'Chain A', DEFAULT_DEPLOYER, wasmDir, wasmHashes),
568
- deployChainContracts(EID_B, 'Chain B', CHAIN_B_DEPLOYER, wasmDir, wasmHashes),
569
- ]);
570
-
571
- // Register executor helpers and create clients sequentially (uses DEFAULT_DEPLOYER)
572
- const chainA = await initChainClients(addressesA, 'Chain A');
573
- const chainB = await initChainClients(addressesB, 'Chain B');
574
-
575
- console.log('\n========================================');
576
- console.log('🔗 GLOBAL SETUP: Wiring Protocol Contracts (Cross-Chain)');
577
- console.log('========================================\n');
578
-
579
- // Wire Chain A to communicate with Chain B
580
- await wireChainContracts(chainA, chainB, 'Chain A');
581
-
582
- // Wire Chain B to communicate with Chain A
583
- await wireChainContracts(chainB, chainA, 'Chain B');
584
-
585
- // Provide addresses for both chains to tests
586
- provide('chainA', chainA.addresses);
587
- provide('chainB', chainB.addresses);
588
- console.log('\n✅ Chain addresses provided to tests (in-memory)');
589
- console.log(' Chain A (EID ' + EID_A + '):', chainA.addresses.endpointV2);
590
- console.log(' Chain B (EID ' + EID_B + '):', chainB.addresses.endpointV2);
591
-
592
- console.log('\n========================================');
593
- console.log('✅ GLOBAL SETUP COMPLETE (Two-Chain Cross-Chain Ready)');
594
- console.log('========================================\n');
595
-
596
- // Return teardown function
597
- return async () => {
598
- console.log('\n========================================');
599
- console.log('🛑 GLOBAL TEARDOWN: Stopping Stellar Localnet');
600
- console.log('========================================\n');
601
-
602
- await stopStellarLocalnet();
603
- };
604
- }
5
+ export default createLocalnetOnlyGlobalSetup(env);
@@ -33,6 +33,7 @@ describe('Upgrader Contract Testing', async () => {
33
33
  'contracts',
34
34
  'protocol',
35
35
  'stellar',
36
+ 'contracts',
36
37
  'target',
37
38
  'wasm32v1-none',
38
39
  'release',