@layerzerolabs/lz-v2-stellar-sdk 0.2.121 → 0.2.123
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/.turbo/turbo-build.log +235 -1
- package/.turbo/turbo-lint.log +8 -0
- package/.turbo/turbo-test.log +41 -1361
- package/dist/generated/dvn.d.ts +2 -2
- package/dist/generated/dvn.js +2 -2
- package/dist/generated/endpoint.d.ts +2 -2
- package/dist/generated/endpoint.js +2 -2
- package/dist/generated/executor.d.ts +3 -3
- package/dist/generated/executor.d.ts.map +1 -1
- package/dist/generated/executor.js +3 -3
- package/dist/generated/executor.js.map +1 -1
- package/dist/generated/price_feed.d.ts +2 -2
- package/dist/generated/price_feed.js +2 -2
- package/dist/generated/sml.d.ts +2 -2
- package/dist/generated/sml.js +2 -2
- package/dist/generated/uln302.d.ts +2 -2
- package/dist/generated/uln302.js +2 -2
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -4
- package/dist/index.js.map +1 -1
- package/package.json +13 -12
- package/rust-toolchain.toml +4 -0
- package/src/index.ts +0 -5
- package/test/suites/constants.ts +30 -51
- package/test/suites/deploy.ts +13 -273
- package/test/suites/globalSetup.ts +3 -602
- package/test/upgrader.test.ts +1 -0
- package/test/utils.ts +11 -658
- package/ts-bindings-gen.toml +59 -0
- package/dist/generated/counter.d.ts +0 -1253
- package/dist/generated/counter.d.ts.map +0 -1
- package/dist/generated/counter.js +0 -391
- package/dist/generated/counter.js.map +0 -1
- package/dist/generated/oft.d.ts +0 -1638
- package/dist/generated/oft.d.ts.map +0 -1
- package/dist/generated/oft.js +0 -463
- package/dist/generated/oft.js.map +0 -1
- package/dist/generated/sac_manager.d.ts +0 -567
- package/dist/generated/sac_manager.d.ts.map +0 -1
- package/dist/generated/sac_manager.js +0 -198
- package/dist/generated/sac_manager.js.map +0 -1
- package/src/generated/bml.ts +0 -672
- package/src/generated/counter.ts +0 -1208
- package/src/generated/dvn.ts +0 -1508
- package/src/generated/dvn_fee_lib.ts +0 -595
- package/src/generated/endpoint.ts +0 -1181
- package/src/generated/executor.ts +0 -1521
- package/src/generated/executor_fee_lib.ts +0 -1027
- package/src/generated/executor_helper.ts +0 -833
- package/src/generated/layerzero_view.ts +0 -1119
- package/src/generated/oft.ts +0 -1609
- package/src/generated/price_feed.ts +0 -793
- package/src/generated/sac_manager.ts +0 -555
- package/src/generated/sml.ts +0 -921
- package/src/generated/treasury.ts +0 -887
- package/src/generated/uln302.ts +0 -1224
- package/src/generated/upgrader.ts +0 -276
- package/test/counter-sml.test.ts +0 -480
- package/test/counter-uln.test.ts +0 -584
- package/test/oft-sml.test.ts +0 -750
- package/test/sac-manager.test.ts +0 -464
- package/test/secp256k1.ts +0 -59
- package/test/suites/dummyContractClient.ts +0 -168
- package/test/suites/localnet.ts +0 -192
- package/test/suites/scan.ts +0 -202
- package/turbo.json +0 -15
package/test/counter-sml.test.ts
DELETED
|
@@ -1,480 +0,0 @@
|
|
|
1
|
-
import { StrKey } from '@stellar/stellar-sdk';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { beforeAll, describe, expect, inject, it } from 'vitest';
|
|
4
|
-
|
|
5
|
-
import { getFullyQualifiedRepoRootPath } from '@layerzerolabs/common-node-utils';
|
|
6
|
-
import { Options, PacketSerializer, PacketV1Codec } from '@layerzerolabs/lz-v2-utilities';
|
|
7
|
-
|
|
8
|
-
import { Client as CounterClient } from '../src/generated/counter.js';
|
|
9
|
-
import { Client as EndpointClient } from '../src/generated/endpoint.js';
|
|
10
|
-
import { Client as ExecutorHelperClient } from '../src/generated/executor_helper.js';
|
|
11
|
-
import { Client as SMLClient } from '../src/generated/sml.js';
|
|
12
|
-
import {
|
|
13
|
-
DEFAULT_DEPLOYER,
|
|
14
|
-
EID_A,
|
|
15
|
-
EID_B,
|
|
16
|
-
EXECUTOR_ADMIN,
|
|
17
|
-
MSG_TYPE_ABA,
|
|
18
|
-
MSG_TYPE_VANILLA,
|
|
19
|
-
NETWORK_PASSPHRASE,
|
|
20
|
-
} from './suites/constants.js';
|
|
21
|
-
import { deployContract } from './suites/deploy.js';
|
|
22
|
-
import type { ChainAddresses } from './suites/globalSetup.js';
|
|
23
|
-
import { PacketSentEvent, scanPacketSentEvents } from './suites/scan.js';
|
|
24
|
-
import { assertTransactionSucceeded, createClient, signAndSendWithExecutorAuth } from './utils.js';
|
|
25
|
-
|
|
26
|
-
// Chain addresses (injected from globalSetup)
|
|
27
|
-
let chainA: ChainAddresses;
|
|
28
|
-
let chainB: ChainAddresses;
|
|
29
|
-
|
|
30
|
-
// Counter addresses (deployed per-chain)
|
|
31
|
-
let counterAAddress = '';
|
|
32
|
-
let counterBAddress = '';
|
|
33
|
-
|
|
34
|
-
// Chain A Clients
|
|
35
|
-
let endpointClientA: EndpointClient;
|
|
36
|
-
let smlClientA: SMLClient;
|
|
37
|
-
let counterClientA: CounterClient;
|
|
38
|
-
let executorHelperClientA: ExecutorHelperClient;
|
|
39
|
-
|
|
40
|
-
// Chain B Clients
|
|
41
|
-
let endpointClientB: EndpointClient;
|
|
42
|
-
let smlClientB: SMLClient;
|
|
43
|
-
let counterClientB: CounterClient;
|
|
44
|
-
let executorHelperClientB: ExecutorHelperClient;
|
|
45
|
-
|
|
46
|
-
describe('Counter Cross-Chain Testing (SML)', async () => {
|
|
47
|
-
const repoRoot = await getFullyQualifiedRepoRootPath();
|
|
48
|
-
const wasmDir = path.join(
|
|
49
|
-
repoRoot,
|
|
50
|
-
'contracts',
|
|
51
|
-
'protocol',
|
|
52
|
-
'stellar',
|
|
53
|
-
'target',
|
|
54
|
-
'wasm32v1-none',
|
|
55
|
-
'release',
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
const COUNTER_WASM_PATH = path.join(wasmDir, 'counter.wasm');
|
|
59
|
-
|
|
60
|
-
beforeAll(async () => {
|
|
61
|
-
// Inject chain addresses from globalSetup
|
|
62
|
-
chainA = inject('chainA');
|
|
63
|
-
chainB = inject('chainB');
|
|
64
|
-
|
|
65
|
-
console.log('\n📋 Chain A addresses (EID: ' + EID_A + ')');
|
|
66
|
-
console.log(' Endpoint:', chainA.endpointV2);
|
|
67
|
-
console.log(' SML:', chainA.sml);
|
|
68
|
-
console.log(' Executor:', chainA.executor);
|
|
69
|
-
|
|
70
|
-
console.log('\n📋 Chain B addresses (EID: ' + EID_B + ')');
|
|
71
|
-
console.log(' Endpoint:', chainB.endpointV2);
|
|
72
|
-
console.log(' SML:', chainB.sml);
|
|
73
|
-
console.log(' Executor:', chainB.executor);
|
|
74
|
-
|
|
75
|
-
// Create clients for Chain A protocol contracts
|
|
76
|
-
endpointClientA = createClient(EndpointClient, chainA.endpointV2);
|
|
77
|
-
smlClientA = createClient(SMLClient, chainA.sml);
|
|
78
|
-
executorHelperClientA = createClient(ExecutorHelperClient, chainA.executorHelper);
|
|
79
|
-
|
|
80
|
-
// Create clients for Chain B protocol contracts
|
|
81
|
-
endpointClientB = createClient(EndpointClient, chainB.endpointV2);
|
|
82
|
-
smlClientB = createClient(SMLClient, chainB.sml);
|
|
83
|
-
executorHelperClientB = createClient(ExecutorHelperClient, chainB.executorHelper);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
describe('Deploy Counters on Both Chains', () => {
|
|
87
|
-
it('Deploy Counter A on Chain A', async () => {
|
|
88
|
-
counterClientA = await deployContract<CounterClient>(
|
|
89
|
-
CounterClient,
|
|
90
|
-
COUNTER_WASM_PATH,
|
|
91
|
-
{
|
|
92
|
-
owner: DEFAULT_DEPLOYER.publicKey(),
|
|
93
|
-
endpoint: chainA.endpointV2,
|
|
94
|
-
delegate: DEFAULT_DEPLOYER.publicKey(),
|
|
95
|
-
},
|
|
96
|
-
DEFAULT_DEPLOYER,
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
counterAAddress = counterClientA.options.contractId;
|
|
100
|
-
console.log('✅ Counter A deployed on Chain A:', counterAAddress);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it('Deploy Counter B on Chain B', async () => {
|
|
104
|
-
counterClientB = await deployContract<CounterClient>(
|
|
105
|
-
CounterClient,
|
|
106
|
-
COUNTER_WASM_PATH,
|
|
107
|
-
{
|
|
108
|
-
owner: DEFAULT_DEPLOYER.publicKey(),
|
|
109
|
-
endpoint: chainB.endpointV2,
|
|
110
|
-
delegate: DEFAULT_DEPLOYER.publicKey(),
|
|
111
|
-
},
|
|
112
|
-
DEFAULT_DEPLOYER,
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
counterBAddress = counterClientB.options.contractId;
|
|
116
|
-
console.log('✅ Counter B deployed on Chain B:', counterBAddress);
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
describe('Wire Counters to use SML (Cross-Chain)', () => {
|
|
121
|
-
it('Set Counter A Send Library to SML (for sending to Chain B)', async () => {
|
|
122
|
-
const assembledTx = await endpointClientA.set_send_library({
|
|
123
|
-
caller: DEFAULT_DEPLOYER.publicKey(),
|
|
124
|
-
sender: counterAAddress,
|
|
125
|
-
dst_eid: EID_B,
|
|
126
|
-
new_lib: chainA.sml,
|
|
127
|
-
});
|
|
128
|
-
await assembledTx.signAndSend();
|
|
129
|
-
|
|
130
|
-
const { result: sendLib } = await endpointClientA.get_send_library({
|
|
131
|
-
sender: counterAAddress,
|
|
132
|
-
dst_eid: EID_B,
|
|
133
|
-
});
|
|
134
|
-
expect(sendLib.lib).toBe(chainA.sml);
|
|
135
|
-
console.log('✅ Counter A send library set to SML for EID_B');
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it('Set Counter A Receive Library to SML (for receiving from Chain B)', async () => {
|
|
139
|
-
const assembledTx = await endpointClientA.set_receive_library({
|
|
140
|
-
caller: DEFAULT_DEPLOYER.publicKey(),
|
|
141
|
-
receiver: counterAAddress,
|
|
142
|
-
src_eid: EID_B,
|
|
143
|
-
new_lib: chainA.sml,
|
|
144
|
-
grace_period: 0n,
|
|
145
|
-
});
|
|
146
|
-
await assembledTx.signAndSend();
|
|
147
|
-
|
|
148
|
-
const { result: receiveLib } = await endpointClientA.get_receive_library({
|
|
149
|
-
receiver: counterAAddress,
|
|
150
|
-
src_eid: EID_B,
|
|
151
|
-
});
|
|
152
|
-
expect(receiveLib.lib).toBe(chainA.sml);
|
|
153
|
-
console.log('✅ Counter A receive library set to SML for EID_B');
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it('Set Counter B Send Library to SML (for sending to Chain A)', async () => {
|
|
157
|
-
const assembledTx = await endpointClientB.set_send_library({
|
|
158
|
-
caller: DEFAULT_DEPLOYER.publicKey(),
|
|
159
|
-
sender: counterBAddress,
|
|
160
|
-
dst_eid: EID_A,
|
|
161
|
-
new_lib: chainB.sml,
|
|
162
|
-
});
|
|
163
|
-
await assembledTx.signAndSend();
|
|
164
|
-
|
|
165
|
-
const { result: sendLib } = await endpointClientB.get_send_library({
|
|
166
|
-
sender: counterBAddress,
|
|
167
|
-
dst_eid: EID_A,
|
|
168
|
-
});
|
|
169
|
-
expect(sendLib.lib).toBe(chainB.sml);
|
|
170
|
-
console.log('✅ Counter B send library set to SML for EID_A');
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
it('Set Counter B Receive Library to SML (for receiving from Chain A)', async () => {
|
|
174
|
-
const assembledTx = await endpointClientB.set_receive_library({
|
|
175
|
-
caller: DEFAULT_DEPLOYER.publicKey(),
|
|
176
|
-
receiver: counterBAddress,
|
|
177
|
-
src_eid: EID_A,
|
|
178
|
-
new_lib: chainB.sml,
|
|
179
|
-
grace_period: 0n,
|
|
180
|
-
});
|
|
181
|
-
await assembledTx.signAndSend();
|
|
182
|
-
|
|
183
|
-
const { result: receiveLib } = await endpointClientB.get_receive_library({
|
|
184
|
-
receiver: counterBAddress,
|
|
185
|
-
src_eid: EID_A,
|
|
186
|
-
});
|
|
187
|
-
expect(receiveLib.lib).toBe(chainB.sml);
|
|
188
|
-
console.log('✅ Counter B receive library set to SML for EID_A');
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
it('Set Counter A Peer to Counter B', async () => {
|
|
192
|
-
const peerBBytes = StrKey.decodeContract(counterBAddress);
|
|
193
|
-
|
|
194
|
-
const assembledTx = await counterClientA.set_peer({
|
|
195
|
-
eid: EID_B,
|
|
196
|
-
peer: Buffer.from(peerBBytes),
|
|
197
|
-
operator: DEFAULT_DEPLOYER.publicKey(),
|
|
198
|
-
});
|
|
199
|
-
await assembledTx.signAndSend();
|
|
200
|
-
|
|
201
|
-
const { result: peer } = await counterClientA.peer({
|
|
202
|
-
eid: EID_B,
|
|
203
|
-
});
|
|
204
|
-
expect(peer?.toString()).toBe(Buffer.from(peerBBytes).toString());
|
|
205
|
-
console.log('✅ Counter A peer set to Counter B for EID_B');
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
it('Set Counter B Peer to Counter A', async () => {
|
|
209
|
-
const peerABytes = StrKey.decodeContract(counterAAddress);
|
|
210
|
-
|
|
211
|
-
const assembledTx = await counterClientB.set_peer({
|
|
212
|
-
eid: EID_A,
|
|
213
|
-
peer: Buffer.from(peerABytes),
|
|
214
|
-
operator: DEFAULT_DEPLOYER.publicKey(),
|
|
215
|
-
});
|
|
216
|
-
await assembledTx.signAndSend();
|
|
217
|
-
|
|
218
|
-
const { result: peer } = await counterClientB.peer({
|
|
219
|
-
eid: EID_A,
|
|
220
|
-
});
|
|
221
|
-
expect(peer?.toString()).toBe(Buffer.from(peerABytes).toString());
|
|
222
|
-
console.log('✅ Counter B peer set to Counter A for EID_A');
|
|
223
|
-
});
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
describe('Cross-Chain ABA Messaging (A → B → A)', async () => {
|
|
227
|
-
let incrementLedger = 0;
|
|
228
|
-
let responseLedger = 0;
|
|
229
|
-
let packetSentEvent: PacketSentEvent;
|
|
230
|
-
let responsePacketSentEvent: PacketSentEvent;
|
|
231
|
-
let guid: Buffer;
|
|
232
|
-
let message: Buffer;
|
|
233
|
-
let responseGuid: Buffer;
|
|
234
|
-
let responseMessage: Buffer;
|
|
235
|
-
let abaReturnFee: bigint;
|
|
236
|
-
|
|
237
|
-
it('Counter A Increment (ABA) - sends to Chain B', async () => {
|
|
238
|
-
// Quote the return fee (for Counter B to send response back to Chain A)
|
|
239
|
-
const returnOptions = Options.newOptions().addExecutorLzReceiveOption(200000n, 0n);
|
|
240
|
-
|
|
241
|
-
const { result: returnFee } = await counterClientB.quote({
|
|
242
|
-
dst_eid: EID_A,
|
|
243
|
-
msg_type: MSG_TYPE_VANILLA,
|
|
244
|
-
options: Buffer.from(returnOptions.toBytes()),
|
|
245
|
-
pay_in_zro: false,
|
|
246
|
-
});
|
|
247
|
-
console.log('✅ Return fee for ABA (B→A):', returnFee);
|
|
248
|
-
|
|
249
|
-
// Add 1% buffer to the return fee
|
|
250
|
-
abaReturnFee = (returnFee.native_fee * 101n) / 100n;
|
|
251
|
-
|
|
252
|
-
// Build ABA options with lzReceive gas + value for return message fee
|
|
253
|
-
const abaOptions = Options.newOptions().addExecutorLzReceiveOption(
|
|
254
|
-
200000n,
|
|
255
|
-
abaReturnFee,
|
|
256
|
-
);
|
|
257
|
-
const optionsBuffer = Buffer.from(abaOptions.toBytes());
|
|
258
|
-
|
|
259
|
-
const { result: fee } = await counterClientA.quote({
|
|
260
|
-
dst_eid: EID_B,
|
|
261
|
-
msg_type: MSG_TYPE_ABA,
|
|
262
|
-
options: optionsBuffer,
|
|
263
|
-
pay_in_zro: true,
|
|
264
|
-
});
|
|
265
|
-
console.log('✅ ABA Fee (A→B):', fee);
|
|
266
|
-
|
|
267
|
-
const assembledTx = await counterClientA.increment({
|
|
268
|
-
caller: DEFAULT_DEPLOYER.publicKey(),
|
|
269
|
-
dst_eid: EID_B,
|
|
270
|
-
msg_type: MSG_TYPE_ABA,
|
|
271
|
-
options: optionsBuffer,
|
|
272
|
-
fee: fee,
|
|
273
|
-
});
|
|
274
|
-
const sentTx = await assembledTx.signAndSend();
|
|
275
|
-
|
|
276
|
-
const txResponse = sentTx.getTransactionResponse;
|
|
277
|
-
if (txResponse && 'ledger' in txResponse) {
|
|
278
|
-
incrementLedger = txResponse.ledger;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
const { result: outboundCount } = await counterClientA.outbound_count({
|
|
282
|
-
eid: EID_B,
|
|
283
|
-
});
|
|
284
|
-
expect(outboundCount).toBe(1n);
|
|
285
|
-
console.log('✅ Counter A incremented (ABA to B), outbound count:', outboundCount);
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
it('Scan PacketSent Events (A → B)', async () => {
|
|
289
|
-
const packetSentEvents = await scanPacketSentEvents(chainA.endpointV2, incrementLedger);
|
|
290
|
-
expect(packetSentEvents.length).toBeGreaterThan(0);
|
|
291
|
-
packetSentEvent = packetSentEvents[0];
|
|
292
|
-
console.log(
|
|
293
|
-
`✅ PacketSent events scanned from Chain A. Found ${packetSentEvents.length} events`,
|
|
294
|
-
);
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
it('Verify Counter Message on Chain B (via SML)', async () => {
|
|
298
|
-
const packet = PacketSerializer.deserialize(packetSentEvent.encoded_packet);
|
|
299
|
-
guid = Buffer.from(packet.guid.replace('0x', ''), 'hex');
|
|
300
|
-
message = Buffer.from(packet.message.replace('0x', ''), 'hex');
|
|
301
|
-
const codec = PacketV1Codec.from(packet);
|
|
302
|
-
const packetHeader = codec.header();
|
|
303
|
-
const payloadHash = codec.payloadHash();
|
|
304
|
-
|
|
305
|
-
// Validate on Chain B's SML
|
|
306
|
-
const assembledTx = await smlClientB.validate_packet({
|
|
307
|
-
header_bytes: Buffer.from(packetHeader.replace('0x', ''), 'hex'),
|
|
308
|
-
payload_hash: Buffer.from(payloadHash.replace('0x', ''), 'hex'),
|
|
309
|
-
});
|
|
310
|
-
await assembledTx.signAndSend();
|
|
311
|
-
console.log('✅ ABA request packet validated on Chain B');
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
it('Execute native_drop on Chain B', async () => {
|
|
315
|
-
const origin = {
|
|
316
|
-
nonce: 1n,
|
|
317
|
-
sender: Buffer.from(StrKey.decodeContract(counterAAddress)),
|
|
318
|
-
src_eid: EID_A,
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
const assembledTx = await executorHelperClientB.native_drop(
|
|
322
|
-
{
|
|
323
|
-
executor: chainB.executor,
|
|
324
|
-
admin: EXECUTOR_ADMIN.publicKey(),
|
|
325
|
-
origin,
|
|
326
|
-
dst_eid: EID_B,
|
|
327
|
-
oapp: counterBAddress,
|
|
328
|
-
params: [
|
|
329
|
-
{
|
|
330
|
-
receiver: counterBAddress,
|
|
331
|
-
amount: 100n,
|
|
332
|
-
},
|
|
333
|
-
],
|
|
334
|
-
},
|
|
335
|
-
{
|
|
336
|
-
simulate: false,
|
|
337
|
-
},
|
|
338
|
-
);
|
|
339
|
-
|
|
340
|
-
const txResult = await signAndSendWithExecutorAuth(
|
|
341
|
-
chainB.executor,
|
|
342
|
-
EXECUTOR_ADMIN,
|
|
343
|
-
assembledTx,
|
|
344
|
-
NETWORK_PASSPHRASE,
|
|
345
|
-
);
|
|
346
|
-
|
|
347
|
-
assertTransactionSucceeded(txResult, 'native_drop on Chain B');
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
it('Receive Counter Message on Chain B (ABA - triggers response to A)', async () => {
|
|
351
|
-
const origin = {
|
|
352
|
-
nonce: 1n,
|
|
353
|
-
sender: Buffer.from(StrKey.decodeContract(counterAAddress)),
|
|
354
|
-
src_eid: EID_A,
|
|
355
|
-
};
|
|
356
|
-
|
|
357
|
-
const assembledTx = await executorHelperClientB.execute(
|
|
358
|
-
{
|
|
359
|
-
executor: chainB.executor,
|
|
360
|
-
params: {
|
|
361
|
-
extra_data: Buffer.from([]),
|
|
362
|
-
gas_limit: 0n,
|
|
363
|
-
guid,
|
|
364
|
-
message,
|
|
365
|
-
origin,
|
|
366
|
-
receiver: counterBAddress,
|
|
367
|
-
value: abaReturnFee,
|
|
368
|
-
},
|
|
369
|
-
value_payer: EXECUTOR_ADMIN.publicKey(),
|
|
370
|
-
},
|
|
371
|
-
{
|
|
372
|
-
simulate: false,
|
|
373
|
-
},
|
|
374
|
-
);
|
|
375
|
-
|
|
376
|
-
const txResult = await signAndSendWithExecutorAuth(
|
|
377
|
-
chainB.executor,
|
|
378
|
-
EXECUTOR_ADMIN,
|
|
379
|
-
assembledTx,
|
|
380
|
-
NETWORK_PASSPHRASE,
|
|
381
|
-
);
|
|
382
|
-
|
|
383
|
-
assertTransactionSucceeded(txResult, 'LzReceive on Chain B (ABA)');
|
|
384
|
-
|
|
385
|
-
if ('ledger' in txResult) {
|
|
386
|
-
responseLedger = txResult.ledger;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
// Verify Counter B received the message
|
|
390
|
-
const { result: inboundCount } = await counterClientB.inbound_count({
|
|
391
|
-
eid: EID_A,
|
|
392
|
-
});
|
|
393
|
-
expect(inboundCount).toBe(1n);
|
|
394
|
-
|
|
395
|
-
// Verify Counter B sent the response back to Chain A
|
|
396
|
-
const { result: outboundCount } = await counterClientB.outbound_count({
|
|
397
|
-
eid: EID_A,
|
|
398
|
-
});
|
|
399
|
-
expect(outboundCount).toBe(1n);
|
|
400
|
-
console.log(
|
|
401
|
-
'✅ Counter B received ABA message and sent response, outbound count:',
|
|
402
|
-
outboundCount,
|
|
403
|
-
);
|
|
404
|
-
});
|
|
405
|
-
|
|
406
|
-
it('Scan ABA Response PacketSent Events (B → A)', async () => {
|
|
407
|
-
const packetSentEvents = await scanPacketSentEvents(chainB.endpointV2, responseLedger);
|
|
408
|
-
expect(packetSentEvents.length).toBeGreaterThan(0);
|
|
409
|
-
responsePacketSentEvent = packetSentEvents[0];
|
|
410
|
-
console.log(
|
|
411
|
-
`✅ ABA response PacketSent events scanned from Chain B. Found ${packetSentEvents.length} events`,
|
|
412
|
-
);
|
|
413
|
-
});
|
|
414
|
-
|
|
415
|
-
it('Verify ABA Response Message on Chain A (via SML)', async () => {
|
|
416
|
-
const packet = PacketSerializer.deserialize(responsePacketSentEvent.encoded_packet);
|
|
417
|
-
responseGuid = Buffer.from(packet.guid.replace('0x', ''), 'hex');
|
|
418
|
-
responseMessage = Buffer.from(packet.message.replace('0x', ''), 'hex');
|
|
419
|
-
const codec = PacketV1Codec.from(packet);
|
|
420
|
-
const packetHeader = codec.header();
|
|
421
|
-
const payloadHash = codec.payloadHash();
|
|
422
|
-
|
|
423
|
-
// Validate on Chain A's SML
|
|
424
|
-
const assembledTx = await smlClientA.validate_packet({
|
|
425
|
-
header_bytes: Buffer.from(packetHeader.replace('0x', ''), 'hex'),
|
|
426
|
-
payload_hash: Buffer.from(payloadHash.replace('0x', ''), 'hex'),
|
|
427
|
-
});
|
|
428
|
-
await assembledTx.signAndSend();
|
|
429
|
-
console.log('✅ ABA response packet validated on Chain A');
|
|
430
|
-
});
|
|
431
|
-
|
|
432
|
-
it('Receive ABA Response Message on Chain A', async () => {
|
|
433
|
-
const origin = {
|
|
434
|
-
nonce: 1n,
|
|
435
|
-
sender: Buffer.from(StrKey.decodeContract(counterBAddress)),
|
|
436
|
-
src_eid: EID_B,
|
|
437
|
-
};
|
|
438
|
-
|
|
439
|
-
// Execute on Chain A using Chain A's executor
|
|
440
|
-
const assembledTx = await executorHelperClientA.execute(
|
|
441
|
-
{
|
|
442
|
-
executor: chainA.executor,
|
|
443
|
-
params: {
|
|
444
|
-
extra_data: Buffer.from([]),
|
|
445
|
-
gas_limit: 0n,
|
|
446
|
-
guid: responseGuid,
|
|
447
|
-
message: responseMessage,
|
|
448
|
-
origin,
|
|
449
|
-
receiver: counterAAddress,
|
|
450
|
-
value: 10n,
|
|
451
|
-
},
|
|
452
|
-
value_payer: EXECUTOR_ADMIN.publicKey(),
|
|
453
|
-
},
|
|
454
|
-
{
|
|
455
|
-
simulate: false,
|
|
456
|
-
},
|
|
457
|
-
);
|
|
458
|
-
|
|
459
|
-
const txResult = await signAndSendWithExecutorAuth(
|
|
460
|
-
chainA.executor,
|
|
461
|
-
EXECUTOR_ADMIN,
|
|
462
|
-
assembledTx,
|
|
463
|
-
NETWORK_PASSPHRASE,
|
|
464
|
-
);
|
|
465
|
-
|
|
466
|
-
assertTransactionSucceeded(txResult, 'LzReceive on Chain A (ABA Response)');
|
|
467
|
-
|
|
468
|
-
// Verify Counter A received the response
|
|
469
|
-
const { result: inboundCount } = await counterClientA.inbound_count({
|
|
470
|
-
eid: EID_B,
|
|
471
|
-
});
|
|
472
|
-
expect(inboundCount).toBe(1n);
|
|
473
|
-
console.log('✅ Counter A received ABA response, inbound count:', inboundCount);
|
|
474
|
-
|
|
475
|
-
console.log('\n🎉 Cross-chain ABA round-trip completed successfully!');
|
|
476
|
-
console.log(' Request: Counter A (Chain A) → Counter B (Chain B) [ABA]');
|
|
477
|
-
console.log(' Response: Counter B (Chain B) → Counter A (Chain A) [Vanilla]');
|
|
478
|
-
});
|
|
479
|
-
});
|
|
480
|
-
});
|