@layerzerolabs/lz-v2-stellar-sdk 0.2.13 ā 0.2.18
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 +1 -0
- package/.turbo/turbo-test.log +1009 -0
- package/dist/generated/bml.d.ts +104 -37
- package/dist/generated/bml.js +83 -42
- package/dist/generated/counter.d.ts +334 -175
- package/dist/generated/counter.js +109 -63
- package/dist/generated/dvn.d.ts +1985 -0
- package/dist/generated/dvn.js +326 -0
- package/dist/generated/dvn_fee_lib.d.ts +690 -0
- package/dist/generated/dvn_fee_lib.js +163 -0
- package/dist/generated/endpoint.d.ts +155 -46
- package/dist/generated/endpoint.js +93 -50
- package/dist/generated/executor.d.ts +1841 -0
- package/dist/generated/executor.js +312 -0
- package/dist/generated/executor_fee_lib.d.ts +1083 -0
- package/dist/generated/executor_fee_lib.js +255 -0
- package/dist/generated/executor_helper.d.ts +981 -0
- package/dist/generated/executor_helper.js +236 -0
- package/dist/generated/oft_std.d.ts +1722 -0
- package/dist/generated/oft_std.js +316 -0
- package/dist/generated/price_feed.d.ts +1077 -0
- package/dist/generated/price_feed.js +210 -0
- package/dist/generated/sml.d.ts +171 -56
- package/dist/generated/sml.js +111 -62
- package/dist/generated/treasury.d.ts +896 -0
- package/dist/generated/treasury.js +219 -0
- package/dist/generated/uln302.d.ts +175 -75
- package/dist/generated/uln302.js +126 -82
- package/dist/generated/upgrader.d.ts +70 -0
- package/dist/generated/upgrader.js +19 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +14 -0
- package/dist/wasm/blocked-message-lib.d.ts +1 -0
- package/dist/wasm/blocked-message-lib.js +2 -0
- package/dist/wasm/counter.d.ts +1 -0
- package/dist/wasm/counter.js +2 -0
- package/dist/wasm/dvn-fee-lib.d.ts +1 -0
- package/dist/wasm/dvn-fee-lib.js +2 -0
- package/dist/wasm/dvn.d.ts +1 -0
- package/dist/wasm/dvn.js +2 -0
- package/dist/wasm/endpoint-v2.d.ts +1 -0
- package/dist/wasm/endpoint-v2.js +2 -0
- package/dist/wasm/executor-fee-lib.d.ts +1 -0
- package/dist/wasm/executor-fee-lib.js +2 -0
- package/dist/wasm/executor-helper.d.ts +1 -0
- package/dist/wasm/executor-helper.js +2 -0
- package/dist/wasm/executor.d.ts +1 -0
- package/dist/wasm/executor.js +2 -0
- package/dist/wasm/layerzero-views.d.ts +1 -0
- package/dist/wasm/layerzero-views.js +2 -0
- package/dist/wasm/oft-std.d.ts +1 -0
- package/dist/wasm/oft-std.js +2 -0
- package/dist/wasm/price-feed.d.ts +1 -0
- package/dist/wasm/price-feed.js +2 -0
- package/dist/wasm/simple-message-lib.d.ts +1 -0
- package/dist/wasm/simple-message-lib.js +2 -0
- package/dist/wasm/treasury.d.ts +1 -0
- package/dist/wasm/treasury.js +2 -0
- package/dist/wasm/uln302.d.ts +1 -0
- package/dist/wasm/uln302.js +2 -0
- package/dist/wasm/upgrader.d.ts +1 -0
- package/dist/wasm/upgrader.js +2 -0
- package/dist/wasm.d.ts +15 -0
- package/dist/wasm.js +15 -0
- package/package.json +12 -9
- package/src/generated/bml.ts +117 -66
- package/src/generated/counter.ts +338 -191
- package/src/generated/dvn.ts +2036 -0
- package/src/generated/dvn_fee_lib.ts +693 -0
- package/src/generated/endpoint.ts +177 -80
- package/src/generated/executor.ts +228 -127
- package/src/generated/executor_fee_lib.ts +1072 -0
- package/src/generated/executor_helper.ts +163 -57
- package/src/generated/oft_std.ts +800 -246
- package/src/generated/price_feed.ts +1108 -0
- package/src/generated/sml.ts +194 -91
- package/src/generated/treasury.ts +943 -0
- package/src/generated/uln302.ts +211 -113
- package/src/generated/upgrader.ts +102 -0
- package/src/index.ts +17 -0
- package/src/wasm/blocked-message-lib.ts +2 -0
- package/src/wasm/counter.ts +2 -0
- package/src/wasm/dvn-fee-lib.ts +2 -0
- package/src/wasm/dvn.ts +2 -0
- package/src/wasm/endpoint-v2.ts +2 -0
- package/src/wasm/executor-fee-lib.ts +2 -0
- package/src/wasm/executor-helper.ts +2 -0
- package/src/wasm/executor.ts +2 -0
- package/src/wasm/layerzero-views.ts +2 -0
- package/src/wasm/oft-std.ts +2 -0
- package/src/wasm/price-feed.ts +2 -0
- package/src/wasm/simple-message-lib.ts +2 -0
- package/src/wasm/treasury.ts +2 -0
- package/src/wasm/uln302.ts +2 -0
- package/src/wasm/upgrader.ts +2 -0
- package/src/wasm.ts +15 -0
- package/test/counter-sml.test.ts +376 -0
- package/test/counter-uln.test.ts +493 -0
- package/test/{oft.test.ts ā oft-sml.test.ts} +187 -323
- package/test/suites/constants.ts +22 -2
- package/test/suites/dummyContractClient.ts +169 -0
- package/test/suites/globalSetup.ts +450 -0
- package/test/suites/localnet.ts +23 -6
- package/test/upgrader.test.ts +300 -0
- package/test/utils.ts +558 -85
- package/vitest.config.ts +21 -0
- package/test/index.test.ts +0 -376
|
@@ -2,102 +2,56 @@ import {
|
|
|
2
2
|
Address,
|
|
3
3
|
Asset,
|
|
4
4
|
BASE_FEE,
|
|
5
|
-
Contract,
|
|
6
5
|
Keypair,
|
|
7
|
-
nativeToScVal,
|
|
8
6
|
Operation,
|
|
9
7
|
rpc,
|
|
10
|
-
scValToNative,
|
|
11
8
|
StrKey,
|
|
12
9
|
TransactionBuilder,
|
|
13
10
|
} from '@stellar/stellar-sdk';
|
|
14
11
|
import path from 'path';
|
|
15
|
-
import {
|
|
16
|
-
import { $ } from 'zx';
|
|
12
|
+
import { beforeAll, describe, expect, inject, it } from 'vitest';
|
|
17
13
|
|
|
18
14
|
import { getFullyQualifiedRepoRootPath } from '@layerzerolabs/common-node-utils';
|
|
19
15
|
import { PacketSerializer, PacketV1Codec } from '@layerzerolabs/lz-v2-utilities';
|
|
20
16
|
|
|
21
17
|
import { Client as EndpointClient } from '../src/generated/endpoint';
|
|
22
|
-
import { Client as ExecutorClient } from '../src/generated/executor';
|
|
23
18
|
import { Client as ExecutorHelperClient } from '../src/generated/executor_helper';
|
|
24
|
-
import { Client as OFTStdClient, SendParam } from '../src/generated/oft_std';
|
|
19
|
+
import { Client as OFTStdClient, OFTMode, SendParam } from '../src/generated/oft_std';
|
|
25
20
|
import { Client as SMLClient } from '../src/generated/sml';
|
|
26
21
|
import {
|
|
27
22
|
DEFAULT_DEPLOYER,
|
|
28
23
|
EID,
|
|
29
|
-
|
|
24
|
+
EXECUTOR_ADMIN,
|
|
30
25
|
NETWORK_PASSPHRASE,
|
|
31
26
|
RPC_URL,
|
|
32
|
-
ZRO_TOKEN_ADDRESS,
|
|
33
27
|
} from './suites/constants';
|
|
34
28
|
import { deployAssetSac, deployContract } from './suites/deploy';
|
|
35
|
-
import { fundAccount
|
|
29
|
+
import { fundAccount } from './suites/localnet';
|
|
36
30
|
import { PacketSentEvent, scanPacketSentEvents } from './suites/scan';
|
|
37
|
-
import {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// Build the balance call
|
|
47
|
-
const balanceOp = tokenContract.call(
|
|
48
|
-
'balance',
|
|
49
|
-
nativeToScVal(Address.fromString(accountAddress), { type: 'address' }),
|
|
50
|
-
);
|
|
31
|
+
import {
|
|
32
|
+
assertTransactionSucceeded,
|
|
33
|
+
createClient,
|
|
34
|
+
getTokenBalance,
|
|
35
|
+
signAndSendWithExecutorAuth,
|
|
36
|
+
} from './utils';
|
|
37
|
+
|
|
38
|
+
// Protocol addresses (will be injected from globalSetup in beforeAll)
|
|
39
|
+
let protocolAddresses: ReturnType<typeof inject<'protocolAddresses'>>;
|
|
51
40
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
})
|
|
57
|
-
.addOperation(balanceOp)
|
|
58
|
-
.setTimeout(30)
|
|
59
|
-
.build();
|
|
60
|
-
|
|
61
|
-
const simulated = await server.simulateTransaction(tx);
|
|
62
|
-
if (rpc.Api.isSimulationError(simulated)) {
|
|
63
|
-
throw new Error(`Balance query failed: ${JSON.stringify(simulated)}`);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Extract result from simulation
|
|
67
|
-
const result = (simulated as rpc.Api.SimulateTransactionSuccessResponse).result;
|
|
68
|
-
if (result?.retval) {
|
|
69
|
-
return scValToNative(result.retval) as bigint;
|
|
70
|
-
}
|
|
71
|
-
return 0n;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
$.verbose = true;
|
|
75
|
-
$.stdio = ['inherit', 'pipe', process.stderr];
|
|
76
|
-
|
|
77
|
-
// Contract addresses
|
|
78
|
-
const CONTRACT_ADDRESSES = {
|
|
79
|
-
endpointV2: '',
|
|
80
|
-
sml: '',
|
|
81
|
-
executor: '',
|
|
82
|
-
executorHelper: '',
|
|
83
|
-
oftToken: '', // The SAC for OFT token
|
|
84
|
-
lockUnlockOft: '',
|
|
85
|
-
mintBurnOft: '',
|
|
86
|
-
};
|
|
41
|
+
// OFT-specific addresses
|
|
42
|
+
let oftTokenAddress = '';
|
|
43
|
+
let lockUnlockOftAddress = '';
|
|
44
|
+
let mintBurnOftAddress = '';
|
|
87
45
|
|
|
88
46
|
// Clients
|
|
89
47
|
let endpointClient: EndpointClient;
|
|
90
48
|
let smlClient: SMLClient;
|
|
91
|
-
let executorClient: ExecutorClient;
|
|
92
49
|
let executorHelperClient: ExecutorHelperClient;
|
|
93
50
|
let lockUnlockOftClient: OFTStdClient;
|
|
94
51
|
let mintBurnOftClient: OFTStdClient;
|
|
95
52
|
|
|
96
53
|
// Test accounts
|
|
97
|
-
const EXECUTOR_ADMIN = Keypair.random();
|
|
98
54
|
const TOKEN_ISSUER = Keypair.random();
|
|
99
|
-
// Use DEFAULT_DEPLOYER as SENDER (same pattern as Counter test)
|
|
100
|
-
// The deployer has proper signing setup with the contract clients
|
|
101
55
|
|
|
102
56
|
// Recipients for each direction
|
|
103
57
|
const RECIPIENT_A = Keypair.random(); // Receives tokens in Lock/Unlock -> Mint/Burn direction
|
|
@@ -114,7 +68,7 @@ const SEND_AMOUNT = 100_0000000n; // 100 tokens in local decimals (7 decimals)
|
|
|
114
68
|
|
|
115
69
|
// NOTE: run `stellar contract build` before running the test
|
|
116
70
|
|
|
117
|
-
describe('OFT E2E Testing with SAC', async () => {
|
|
71
|
+
describe('OFT E2E Testing with SAC (SML)', async () => {
|
|
118
72
|
const repoRoot = await getFullyQualifiedRepoRootPath();
|
|
119
73
|
const wasmDir = path.join(
|
|
120
74
|
repoRoot,
|
|
@@ -126,99 +80,33 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
126
80
|
'release',
|
|
127
81
|
);
|
|
128
82
|
|
|
129
|
-
const ENDPOINT_WASM_PATH = path.join(wasmDir, 'endpoint_v2.wasm');
|
|
130
|
-
const SML_WASM_PATH = path.join(wasmDir, 'simple_message_lib.wasm');
|
|
131
|
-
const EXECUTOR_WASM_PATH = path.join(wasmDir, 'executor.wasm');
|
|
132
|
-
const EXECUTOR_HELPER_WASM_PATH = path.join(wasmDir, 'executor_helper.wasm');
|
|
133
83
|
const OFT_STD_WASM_PATH = path.join(wasmDir, 'oft_std.wasm');
|
|
134
84
|
|
|
135
85
|
beforeAll(async () => {
|
|
136
|
-
|
|
86
|
+
// Inject protocol addresses from globalSetup
|
|
87
|
+
protocolAddresses = inject('protocolAddresses');
|
|
88
|
+
|
|
89
|
+
console.log('\nš Protocol addresses injected from globalSetup');
|
|
90
|
+
console.log(' Endpoint:', protocolAddresses.endpointV2);
|
|
91
|
+
console.log(' SML:', protocolAddresses.sml);
|
|
92
|
+
console.log(' Executor:', protocolAddresses.executor);
|
|
93
|
+
console.log(' Executor Helper:', protocolAddresses.executorHelper);
|
|
94
|
+
|
|
95
|
+
// Create clients for protocol contracts
|
|
96
|
+
endpointClient = createClient(EndpointClient, protocolAddresses.endpointV2);
|
|
97
|
+
smlClient = createClient(SMLClient, protocolAddresses.sml);
|
|
98
|
+
executorHelperClient = createClient(ExecutorHelperClient, protocolAddresses.executorHelper);
|
|
99
|
+
|
|
137
100
|
// Fund test accounts
|
|
138
|
-
await fundAccount(EXECUTOR_ADMIN.publicKey());
|
|
139
101
|
await fundAccount(TOKEN_ISSUER.publicKey());
|
|
140
102
|
await fundAccount(RECIPIENT_A.publicKey());
|
|
141
103
|
await fundAccount(RECIPIENT_B.publicKey());
|
|
142
104
|
|
|
143
105
|
// Create the OFT asset (TOKEN_ISSUER is the issuer)
|
|
144
106
|
OFT_ASSET = new Asset(OFT_TOKEN_CODE, TOKEN_ISSUER.publicKey());
|
|
145
|
-
}, 120000); // 2 minute timeout for setup
|
|
146
|
-
|
|
147
|
-
afterAll(async () => {
|
|
148
|
-
await stopStellarLocalnet();
|
|
149
107
|
});
|
|
150
108
|
|
|
151
|
-
describe('
|
|
152
|
-
it('Deploy Endpoint', async () => {
|
|
153
|
-
endpointClient = await deployContract<EndpointClient>(
|
|
154
|
-
EndpointClient,
|
|
155
|
-
ENDPOINT_WASM_PATH,
|
|
156
|
-
{
|
|
157
|
-
eid: EID,
|
|
158
|
-
owner: DEFAULT_DEPLOYER.publicKey(),
|
|
159
|
-
native_token: NATIVE_TOKEN_ADDRESS,
|
|
160
|
-
},
|
|
161
|
-
DEFAULT_DEPLOYER,
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
CONTRACT_ADDRESSES.endpointV2 = endpointClient.options.contractId;
|
|
165
|
-
console.log('ā
Endpoint deployed:', CONTRACT_ADDRESSES.endpointV2);
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it('Deploy SimpleMessageLib', async () => {
|
|
169
|
-
smlClient = await deployContract<SMLClient>(
|
|
170
|
-
SMLClient,
|
|
171
|
-
SML_WASM_PATH,
|
|
172
|
-
{
|
|
173
|
-
owner: DEFAULT_DEPLOYER.publicKey(),
|
|
174
|
-
endpoint: CONTRACT_ADDRESSES.endpointV2,
|
|
175
|
-
fee_recipient: DEFAULT_DEPLOYER.publicKey(),
|
|
176
|
-
},
|
|
177
|
-
DEFAULT_DEPLOYER,
|
|
178
|
-
);
|
|
179
|
-
|
|
180
|
-
CONTRACT_ADDRESSES.sml = smlClient.options.contractId;
|
|
181
|
-
console.log('ā
SimpleMessageLib deployed:', CONTRACT_ADDRESSES.sml);
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
it('Deploy Executor Helper', async () => {
|
|
185
|
-
executorHelperClient = await deployContract<ExecutorHelperClient>(
|
|
186
|
-
ExecutorHelperClient,
|
|
187
|
-
EXECUTOR_HELPER_WASM_PATH,
|
|
188
|
-
undefined,
|
|
189
|
-
DEFAULT_DEPLOYER,
|
|
190
|
-
);
|
|
191
|
-
CONTRACT_ADDRESSES.executorHelper = executorHelperClient.options.contractId;
|
|
192
|
-
console.log('ā
Executor Helper deployed:', CONTRACT_ADDRESSES.executorHelper);
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it('Deploy Executor', async () => {
|
|
196
|
-
const whitelist = [
|
|
197
|
-
{ contract: CONTRACT_ADDRESSES.executorHelper, fn_name: 'native_drop_and_execute' },
|
|
198
|
-
{ contract: CONTRACT_ADDRESSES.executorHelper, fn_name: 'execute' },
|
|
199
|
-
{ contract: CONTRACT_ADDRESSES.executorHelper, fn_name: 'compose' },
|
|
200
|
-
{ contract: CONTRACT_ADDRESSES.executorHelper, fn_name: 'native_drop' },
|
|
201
|
-
];
|
|
202
|
-
|
|
203
|
-
executorClient = await deployContract<ExecutorClient>(
|
|
204
|
-
ExecutorClient,
|
|
205
|
-
EXECUTOR_WASM_PATH,
|
|
206
|
-
{
|
|
207
|
-
owner: DEFAULT_DEPLOYER.publicKey(),
|
|
208
|
-
endpoint: CONTRACT_ADDRESSES.endpointV2,
|
|
209
|
-
whitelist,
|
|
210
|
-
admins: [EXECUTOR_ADMIN.publicKey()],
|
|
211
|
-
message_libs: [CONTRACT_ADDRESSES.sml],
|
|
212
|
-
// FIXME: Add price feed
|
|
213
|
-
price_feed: CONTRACT_ADDRESSES.endpointV2,
|
|
214
|
-
default_multiplier_bps: 10000,
|
|
215
|
-
},
|
|
216
|
-
DEFAULT_DEPLOYER,
|
|
217
|
-
);
|
|
218
|
-
CONTRACT_ADDRESSES.executor = executorClient.options.contractId;
|
|
219
|
-
console.log('ā
Executor deployed:', CONTRACT_ADDRESSES.executor);
|
|
220
|
-
});
|
|
221
|
-
|
|
109
|
+
describe('Deploy OFT Contracts', () => {
|
|
222
110
|
it('Deploy OFT Token SAC', async () => {
|
|
223
111
|
const server = new rpc.Server(RPC_URL, { allowHttp: true });
|
|
224
112
|
|
|
@@ -272,8 +160,8 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
272
160
|
console.log('ā
OFT token issued to DEFAULT_DEPLOYER');
|
|
273
161
|
|
|
274
162
|
// Step 2: Deploy the SAC for the OFT token
|
|
275
|
-
|
|
276
|
-
console.log('ā
OFT Token SAC deployed:',
|
|
163
|
+
oftTokenAddress = await deployAssetSac(OFT_ASSET);
|
|
164
|
+
console.log('ā
OFT Token SAC deployed:', oftTokenAddress);
|
|
277
165
|
});
|
|
278
166
|
|
|
279
167
|
it('Deploy Lock/Unlock OFT', async () => {
|
|
@@ -281,22 +169,22 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
281
169
|
OFTStdClient,
|
|
282
170
|
OFT_STD_WASM_PATH,
|
|
283
171
|
{
|
|
284
|
-
token:
|
|
172
|
+
token: oftTokenAddress,
|
|
285
173
|
owner: DEFAULT_DEPLOYER.publicKey(),
|
|
286
|
-
endpoint:
|
|
174
|
+
endpoint: protocolAddresses.endpointV2,
|
|
287
175
|
delegate: DEFAULT_DEPLOYER.publicKey(),
|
|
288
176
|
shared_decimals: SHARED_DECIMALS,
|
|
289
|
-
|
|
177
|
+
mode: OFTMode.LockUnlock, // Lock/Unlock mode
|
|
290
178
|
},
|
|
291
179
|
DEFAULT_DEPLOYER,
|
|
292
180
|
);
|
|
293
181
|
|
|
294
|
-
|
|
295
|
-
console.log('ā
Lock/Unlock OFT deployed:',
|
|
182
|
+
lockUnlockOftAddress = lockUnlockOftClient.options.contractId;
|
|
183
|
+
console.log('ā
Lock/Unlock OFT deployed:', lockUnlockOftAddress);
|
|
296
184
|
|
|
297
185
|
// Verify it's in lock/unlock mode
|
|
298
|
-
const { result:
|
|
299
|
-
expect(
|
|
186
|
+
const { result: mode } = await lockUnlockOftClient.mode();
|
|
187
|
+
expect(mode).toEqual(OFTMode.LockUnlock);
|
|
300
188
|
});
|
|
301
189
|
|
|
302
190
|
it('Deploy Mint/Burn OFT', async () => {
|
|
@@ -304,91 +192,102 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
304
192
|
OFTStdClient,
|
|
305
193
|
OFT_STD_WASM_PATH,
|
|
306
194
|
{
|
|
307
|
-
token:
|
|
195
|
+
token: oftTokenAddress,
|
|
308
196
|
owner: DEFAULT_DEPLOYER.publicKey(),
|
|
309
|
-
endpoint:
|
|
197
|
+
endpoint: protocolAddresses.endpointV2,
|
|
310
198
|
delegate: DEFAULT_DEPLOYER.publicKey(),
|
|
311
199
|
shared_decimals: SHARED_DECIMALS,
|
|
312
|
-
|
|
200
|
+
mode: OFTMode.MintBurn, // Mint/Burn mode
|
|
313
201
|
},
|
|
314
202
|
DEFAULT_DEPLOYER,
|
|
315
203
|
);
|
|
316
204
|
|
|
317
|
-
|
|
318
|
-
console.log('ā
Mint/Burn OFT deployed:',
|
|
205
|
+
mintBurnOftAddress = mintBurnOftClient.options.contractId;
|
|
206
|
+
console.log('ā
Mint/Burn OFT deployed:', mintBurnOftAddress);
|
|
319
207
|
|
|
320
208
|
// Verify it's in mint/burn mode
|
|
321
|
-
const { result:
|
|
322
|
-
expect(
|
|
209
|
+
const { result: mode } = await mintBurnOftClient.mode();
|
|
210
|
+
expect(mode).toEqual(OFTMode.MintBurn);
|
|
323
211
|
});
|
|
212
|
+
});
|
|
324
213
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
214
|
+
describe('Wire OFT Contracts to use SML', () => {
|
|
215
|
+
it('Set Lock/Unlock OFT Send Library to SML', async () => {
|
|
216
|
+
const assembledTx = await endpointClient.set_send_library({
|
|
217
|
+
caller: DEFAULT_DEPLOYER.publicKey(),
|
|
218
|
+
sender: lockUnlockOftAddress,
|
|
219
|
+
dst_eid: EID,
|
|
220
|
+
new_lib: protocolAddresses.sml,
|
|
221
|
+
});
|
|
222
|
+
await assembledTx.signAndSend();
|
|
223
|
+
|
|
224
|
+
const { result: sendLib } = await endpointClient.get_send_library({
|
|
225
|
+
sender: lockUnlockOftAddress,
|
|
226
|
+
dst_eid: EID,
|
|
227
|
+
});
|
|
228
|
+
expect(sendLib.lib).toBe(protocolAddresses.sml);
|
|
229
|
+
expect(sendLib.is_default).toBe(false);
|
|
230
|
+
console.log('ā
Lock/Unlock OFT send library set to SML');
|
|
334
231
|
});
|
|
335
|
-
});
|
|
336
232
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
233
|
+
it('Set Lock/Unlock OFT Receive Library to SML', async () => {
|
|
234
|
+
const assembledTx = await endpointClient.set_receive_library({
|
|
235
|
+
caller: DEFAULT_DEPLOYER.publicKey(),
|
|
236
|
+
receiver: lockUnlockOftAddress,
|
|
237
|
+
src_eid: EID,
|
|
238
|
+
new_lib: protocolAddresses.sml,
|
|
239
|
+
grace_period: 0n,
|
|
341
240
|
});
|
|
342
241
|
await assembledTx.signAndSend();
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
242
|
+
|
|
243
|
+
const { result: receiveLib } = await endpointClient.get_receive_library({
|
|
244
|
+
receiver: lockUnlockOftAddress,
|
|
245
|
+
src_eid: EID,
|
|
346
246
|
});
|
|
347
|
-
expect(
|
|
348
|
-
expect(
|
|
349
|
-
console.log('ā
|
|
247
|
+
expect(receiveLib.lib).toBe(protocolAddresses.sml);
|
|
248
|
+
expect(receiveLib.is_default).toBe(false);
|
|
249
|
+
console.log('ā
Lock/Unlock OFT receive library set to SML');
|
|
350
250
|
});
|
|
351
251
|
|
|
352
|
-
it('Set
|
|
353
|
-
const assembledTx = await endpointClient.
|
|
252
|
+
it('Set Mint/Burn OFT Send Library to SML', async () => {
|
|
253
|
+
const assembledTx = await endpointClient.set_send_library({
|
|
254
|
+
caller: DEFAULT_DEPLOYER.publicKey(),
|
|
255
|
+
sender: mintBurnOftAddress,
|
|
354
256
|
dst_eid: EID,
|
|
355
|
-
new_lib:
|
|
257
|
+
new_lib: protocolAddresses.sml,
|
|
356
258
|
});
|
|
357
259
|
await assembledTx.signAndSend();
|
|
358
|
-
|
|
260
|
+
|
|
261
|
+
const { result: sendLib } = await endpointClient.get_send_library({
|
|
262
|
+
sender: mintBurnOftAddress,
|
|
359
263
|
dst_eid: EID,
|
|
360
264
|
});
|
|
361
|
-
expect(
|
|
362
|
-
|
|
265
|
+
expect(sendLib.lib).toBe(protocolAddresses.sml);
|
|
266
|
+
expect(sendLib.is_default).toBe(false);
|
|
267
|
+
console.log('ā
Mint/Burn OFT send library set to SML');
|
|
363
268
|
});
|
|
364
269
|
|
|
365
|
-
it('Set
|
|
366
|
-
const assembledTx = await endpointClient.
|
|
270
|
+
it('Set Mint/Burn OFT Receive Library to SML', async () => {
|
|
271
|
+
const assembledTx = await endpointClient.set_receive_library({
|
|
272
|
+
caller: DEFAULT_DEPLOYER.publicKey(),
|
|
273
|
+
receiver: mintBurnOftAddress,
|
|
367
274
|
src_eid: EID,
|
|
368
|
-
new_lib:
|
|
275
|
+
new_lib: protocolAddresses.sml,
|
|
369
276
|
grace_period: 0n,
|
|
370
277
|
});
|
|
371
278
|
await assembledTx.signAndSend();
|
|
372
|
-
const { result: defaultReceiveLib } = await endpointClient.default_receive_library({
|
|
373
|
-
src_eid: EID,
|
|
374
|
-
});
|
|
375
|
-
expect(defaultReceiveLib).toBe(CONTRACT_ADDRESSES.sml);
|
|
376
|
-
console.log('ā
Default receive library set');
|
|
377
|
-
});
|
|
378
279
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
280
|
+
const { result: receiveLib } = await endpointClient.get_receive_library({
|
|
281
|
+
receiver: mintBurnOftAddress,
|
|
282
|
+
src_eid: EID,
|
|
382
283
|
});
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
expect(newZroToken).toBe(ZRO_TOKEN_ADDRESS);
|
|
387
|
-
console.log('ā
ZRO token set:', ZRO_TOKEN_ADDRESS);
|
|
284
|
+
expect(receiveLib.lib).toBe(protocolAddresses.sml);
|
|
285
|
+
expect(receiveLib.is_default).toBe(false);
|
|
286
|
+
console.log('ā
Mint/Burn OFT receive library set to SML');
|
|
388
287
|
});
|
|
389
288
|
|
|
390
289
|
it('Set Lock/Unlock OFT Peer (to Mint/Burn OFT)', async () => {
|
|
391
|
-
const mintBurnPeerBytes = StrKey.decodeContract(
|
|
290
|
+
const mintBurnPeerBytes = StrKey.decodeContract(mintBurnOftAddress);
|
|
392
291
|
|
|
393
292
|
const assembledTx = await lockUnlockOftClient.set_peer({
|
|
394
293
|
eid: EID,
|
|
@@ -404,7 +303,7 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
404
303
|
});
|
|
405
304
|
|
|
406
305
|
it('Set Mint/Burn OFT Peer (to Lock/Unlock OFT)', async () => {
|
|
407
|
-
const lockUnlockPeerBytes = StrKey.decodeContract(
|
|
306
|
+
const lockUnlockPeerBytes = StrKey.decodeContract(lockUnlockOftAddress);
|
|
408
307
|
|
|
409
308
|
const assembledTx = await mintBurnOftClient.set_peer({
|
|
410
309
|
eid: EID,
|
|
@@ -421,26 +320,19 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
421
320
|
|
|
422
321
|
it('Set SAC Admin to Mint/Burn OFT (for minting)', async () => {
|
|
423
322
|
// The Mint/Burn OFT needs to be the admin of the SAC to mint tokens
|
|
424
|
-
// Use the SAC's set_admin function
|
|
425
323
|
const server = new rpc.Server(RPC_URL, { allowHttp: true });
|
|
426
324
|
|
|
427
|
-
// Build set_admin transaction
|
|
428
|
-
// SAC's set_admin function requires the current admin (TOKEN_ISSUER) to sign
|
|
429
325
|
const account = await server.getAccount(TOKEN_ISSUER.publicKey());
|
|
430
326
|
|
|
431
|
-
// Build the invokeContract operation for SAC's set_admin
|
|
432
327
|
const setAdminTx = new TransactionBuilder(account, {
|
|
433
328
|
fee: BASE_FEE,
|
|
434
329
|
networkPassphrase: NETWORK_PASSPHRASE,
|
|
435
330
|
})
|
|
436
331
|
.addOperation(
|
|
437
332
|
Operation.invokeContractFunction({
|
|
438
|
-
contract:
|
|
333
|
+
contract: oftTokenAddress,
|
|
439
334
|
function: 'set_admin',
|
|
440
|
-
args: [
|
|
441
|
-
// new_admin: Address
|
|
442
|
-
Address.fromString(CONTRACT_ADDRESSES.mintBurnOft).toScVal(),
|
|
443
|
-
],
|
|
335
|
+
args: [Address.fromString(mintBurnOftAddress).toScVal()],
|
|
444
336
|
}),
|
|
445
337
|
)
|
|
446
338
|
.setTimeout(30)
|
|
@@ -473,39 +365,35 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
473
365
|
let message: Buffer;
|
|
474
366
|
|
|
475
367
|
it('Verify initial balances', async () => {
|
|
476
|
-
|
|
477
|
-
const senderBalance = await getSacBalance(
|
|
478
|
-
CONTRACT_ADDRESSES.oftToken,
|
|
368
|
+
const senderBalance = await getTokenBalance(
|
|
479
369
|
DEFAULT_DEPLOYER.publicKey(),
|
|
370
|
+
oftTokenAddress,
|
|
480
371
|
);
|
|
481
372
|
console.log('š Initial Balances:');
|
|
482
373
|
console.log(` - Sender (DEFAULT_DEPLOYER): ${senderBalance} (expected: 10000000000)`);
|
|
483
374
|
|
|
484
|
-
|
|
485
|
-
const recipientABalance = await getSacBalance(
|
|
486
|
-
CONTRACT_ADDRESSES.oftToken,
|
|
375
|
+
const recipientABalance = await getTokenBalance(
|
|
487
376
|
RECIPIENT_A.publicKey(),
|
|
377
|
+
oftTokenAddress,
|
|
488
378
|
);
|
|
489
379
|
console.log(` - RECIPIENT_A: ${recipientABalance} (expected: 0)`);
|
|
490
380
|
|
|
491
|
-
expect(senderBalance).toBe(10000000000n);
|
|
381
|
+
expect(senderBalance).toBe(10000000000n);
|
|
492
382
|
expect(recipientABalance).toBe(0n);
|
|
493
383
|
});
|
|
494
384
|
|
|
495
385
|
it('Quote OFT send', async () => {
|
|
496
|
-
// Build SendParam - send to RECIPIENT_A
|
|
497
386
|
const receiverBytes = StrKey.decodeEd25519PublicKey(RECIPIENT_A.publicKey());
|
|
498
387
|
const sendParam: SendParam = {
|
|
499
388
|
dst_eid: EID,
|
|
500
389
|
to: Buffer.from(receiverBytes),
|
|
501
390
|
amount_ld: SEND_AMOUNT,
|
|
502
|
-
min_amount_ld: SEND_AMOUNT,
|
|
391
|
+
min_amount_ld: SEND_AMOUNT,
|
|
503
392
|
extra_options: Buffer.from([]),
|
|
504
393
|
compose_msg: Buffer.from([]),
|
|
505
394
|
oft_cmd: Buffer.from([]),
|
|
506
395
|
};
|
|
507
396
|
|
|
508
|
-
// Quote OFT
|
|
509
397
|
const { result: quoteResult } = await lockUnlockOftClient.quote_oft({
|
|
510
398
|
send_param: sendParam,
|
|
511
399
|
});
|
|
@@ -519,7 +407,6 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
519
407
|
});
|
|
520
408
|
|
|
521
409
|
it('Send tokens (Lock/Unlock -> Mint/Burn)', async () => {
|
|
522
|
-
// Build SendParam - send to RECIPIENT_A
|
|
523
410
|
const receiverBytes = StrKey.decodeEd25519PublicKey(RECIPIENT_A.publicKey());
|
|
524
411
|
const sendParam: SendParam = {
|
|
525
412
|
dst_eid: EID,
|
|
@@ -531,7 +418,6 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
531
418
|
oft_cmd: Buffer.from([]),
|
|
532
419
|
};
|
|
533
420
|
|
|
534
|
-
// Quote send fee (pay in ZRO like Counter test does)
|
|
535
421
|
const { result: fee } = await lockUnlockOftClient.quote_send({
|
|
536
422
|
sender: DEFAULT_DEPLOYER.publicKey(),
|
|
537
423
|
send_param: sendParam,
|
|
@@ -539,7 +425,6 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
539
425
|
});
|
|
540
426
|
console.log('š Messaging Fee:', fee);
|
|
541
427
|
|
|
542
|
-
// Send tokens
|
|
543
428
|
const assembledTx = await lockUnlockOftClient.send({
|
|
544
429
|
sender: DEFAULT_DEPLOYER.publicKey(),
|
|
545
430
|
send_param: sendParam,
|
|
@@ -547,22 +432,22 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
547
432
|
refund_address: DEFAULT_DEPLOYER.publicKey(),
|
|
548
433
|
});
|
|
549
434
|
|
|
550
|
-
// Sign and send
|
|
551
435
|
const sentTx = await assembledTx.signAndSend();
|
|
552
436
|
|
|
553
|
-
// Extract ledger number
|
|
554
437
|
const txResponse = sentTx.getTransactionResponse;
|
|
555
438
|
if (txResponse && 'ledger' in txResponse) {
|
|
556
439
|
sendLedger = txResponse.ledger;
|
|
557
440
|
}
|
|
558
441
|
|
|
559
|
-
|
|
442
|
+
if (txResponse) {
|
|
443
|
+
assertTransactionSucceeded(txResponse, 'OFT Send');
|
|
444
|
+
}
|
|
560
445
|
console.log('ā
Tokens sent, ledger:', sendLedger);
|
|
561
446
|
});
|
|
562
447
|
|
|
563
448
|
it('Scan PacketSent events', async () => {
|
|
564
449
|
const packetSentEvents = await scanPacketSentEvents(
|
|
565
|
-
|
|
450
|
+
protocolAddresses.endpointV2,
|
|
566
451
|
sendLedger,
|
|
567
452
|
);
|
|
568
453
|
expect(packetSentEvents.length).toBeGreaterThan(0);
|
|
@@ -587,64 +472,56 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
587
472
|
});
|
|
588
473
|
|
|
589
474
|
it('Receive tokens (mint on Mint/Burn OFT)', async () => {
|
|
590
|
-
const lockUnlockPeerBytes = StrKey.decodeContract(
|
|
475
|
+
const lockUnlockPeerBytes = StrKey.decodeContract(lockUnlockOftAddress);
|
|
591
476
|
const origin = {
|
|
592
477
|
nonce: 1n,
|
|
593
478
|
sender: Buffer.from(lockUnlockPeerBytes),
|
|
594
479
|
src_eid: EID,
|
|
595
480
|
};
|
|
596
481
|
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
origin,
|
|
611
|
-
receiver: CONTRACT_ADDRESSES.mintBurnOft,
|
|
612
|
-
value: 0n,
|
|
482
|
+
const assembledTx = await executorHelperClient.execute(
|
|
483
|
+
{
|
|
484
|
+
executor: protocolAddresses.executor,
|
|
485
|
+
params: {
|
|
486
|
+
extra_data: Buffer.from([]),
|
|
487
|
+
gas_limit: 0n,
|
|
488
|
+
guid,
|
|
489
|
+
message,
|
|
490
|
+
origin,
|
|
491
|
+
receiver: mintBurnOftAddress,
|
|
492
|
+
value: 0n,
|
|
493
|
+
},
|
|
494
|
+
value_payer: EXECUTOR_ADMIN.publicKey(),
|
|
613
495
|
},
|
|
614
|
-
|
|
496
|
+
{
|
|
497
|
+
simulate: false,
|
|
498
|
+
},
|
|
499
|
+
);
|
|
615
500
|
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
CONTRACT_ADDRESSES.executor,
|
|
501
|
+
const txResult = await signAndSendWithExecutorAuth(
|
|
502
|
+
protocolAddresses.executor,
|
|
619
503
|
EXECUTOR_ADMIN,
|
|
620
504
|
assembledTx,
|
|
621
505
|
NETWORK_PASSPHRASE,
|
|
622
506
|
);
|
|
623
507
|
|
|
624
|
-
|
|
625
|
-
const sentTx = await assembledTx.signAndSend();
|
|
626
|
-
assertTransactionsSucceeded(sentTx, 'LzReceive (Mint)');
|
|
508
|
+
assertTransactionSucceeded(txResult, 'LzReceive (Mint)');
|
|
627
509
|
|
|
628
510
|
console.log('ā
Tokens received and minted on Mint/Burn OFT');
|
|
629
511
|
});
|
|
630
512
|
|
|
631
513
|
it('Verify balances after forward send', async () => {
|
|
632
|
-
|
|
633
|
-
// - Sender (DEFAULT_DEPLOYER): 1000 - 100 = 900 tokens
|
|
634
|
-
// - Lock/Unlock OFT contract: holds 100 locked tokens
|
|
635
|
-
// - RECIPIENT_A: received 100 minted tokens
|
|
636
|
-
|
|
637
|
-
const senderBalance = await getSacBalance(
|
|
638
|
-
CONTRACT_ADDRESSES.oftToken,
|
|
514
|
+
const senderBalance = await getTokenBalance(
|
|
639
515
|
DEFAULT_DEPLOYER.publicKey(),
|
|
516
|
+
oftTokenAddress,
|
|
640
517
|
);
|
|
641
|
-
const lockUnlockOftBalance = await
|
|
642
|
-
|
|
643
|
-
|
|
518
|
+
const lockUnlockOftBalance = await getTokenBalance(
|
|
519
|
+
lockUnlockOftAddress,
|
|
520
|
+
oftTokenAddress,
|
|
644
521
|
);
|
|
645
|
-
const recipientABalance = await
|
|
646
|
-
CONTRACT_ADDRESSES.oftToken,
|
|
522
|
+
const recipientABalance = await getTokenBalance(
|
|
647
523
|
RECIPIENT_A.publicKey(),
|
|
524
|
+
oftTokenAddress,
|
|
648
525
|
);
|
|
649
526
|
|
|
650
527
|
console.log('š Balances after forward send:');
|
|
@@ -654,9 +531,9 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
654
531
|
);
|
|
655
532
|
console.log(` - RECIPIENT_A (minted): ${recipientABalance} (expected: 1000000000)`);
|
|
656
533
|
|
|
657
|
-
expect(senderBalance).toBe(9000000000n);
|
|
658
|
-
expect(lockUnlockOftBalance).toBe(1000000000n);
|
|
659
|
-
expect(recipientABalance).toBe(1000000000n);
|
|
534
|
+
expect(senderBalance).toBe(9000000000n);
|
|
535
|
+
expect(lockUnlockOftBalance).toBe(1000000000n);
|
|
536
|
+
expect(recipientABalance).toBe(1000000000n);
|
|
660
537
|
});
|
|
661
538
|
});
|
|
662
539
|
|
|
@@ -665,10 +542,9 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
665
542
|
let packetSentEvent: PacketSentEvent;
|
|
666
543
|
let guid: Buffer;
|
|
667
544
|
let message: Buffer;
|
|
668
|
-
const REVERSE_SEND_AMOUNT = 50_0000000n;
|
|
545
|
+
const REVERSE_SEND_AMOUNT = 50_0000000n;
|
|
669
546
|
|
|
670
547
|
it('Quote OFT send (reverse)', async () => {
|
|
671
|
-
// Send to RECIPIENT_B
|
|
672
548
|
const receiverBytes = StrKey.decodeEd25519PublicKey(RECIPIENT_B.publicKey());
|
|
673
549
|
const sendParam: SendParam = {
|
|
674
550
|
dst_eid: EID,
|
|
@@ -693,7 +569,6 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
693
569
|
});
|
|
694
570
|
|
|
695
571
|
it('Send tokens (Mint/Burn -> Lock/Unlock)', async () => {
|
|
696
|
-
// DEFAULT_DEPLOYER sends via Mint/Burn OFT to RECIPIENT_B
|
|
697
572
|
const receiverBytes = StrKey.decodeEd25519PublicKey(RECIPIENT_B.publicKey());
|
|
698
573
|
const sendParam: SendParam = {
|
|
699
574
|
dst_eid: EID,
|
|
@@ -705,7 +580,6 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
705
580
|
oft_cmd: Buffer.from([]),
|
|
706
581
|
};
|
|
707
582
|
|
|
708
|
-
// Quote send fee (pay in ZRO like Counter test does)
|
|
709
583
|
const { result: fee } = await mintBurnOftClient.quote_send({
|
|
710
584
|
sender: DEFAULT_DEPLOYER.publicKey(),
|
|
711
585
|
send_param: sendParam,
|
|
@@ -713,7 +587,6 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
713
587
|
});
|
|
714
588
|
console.log('š Reverse Messaging Fee:', fee);
|
|
715
589
|
|
|
716
|
-
// Send tokens
|
|
717
590
|
const assembledTx = await mintBurnOftClient.send({
|
|
718
591
|
sender: DEFAULT_DEPLOYER.publicKey(),
|
|
719
592
|
send_param: sendParam,
|
|
@@ -721,22 +594,22 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
721
594
|
refund_address: DEFAULT_DEPLOYER.publicKey(),
|
|
722
595
|
});
|
|
723
596
|
|
|
724
|
-
// Sign and send
|
|
725
597
|
const sentTx = await assembledTx.signAndSend();
|
|
726
598
|
|
|
727
|
-
// Extract ledger number
|
|
728
599
|
const txResponse = sentTx.getTransactionResponse;
|
|
729
600
|
if (txResponse && 'ledger' in txResponse) {
|
|
730
601
|
sendLedger = txResponse.ledger;
|
|
731
602
|
}
|
|
732
603
|
|
|
733
|
-
|
|
604
|
+
if (txResponse) {
|
|
605
|
+
assertTransactionSucceeded(txResponse, 'OFT Reverse Send');
|
|
606
|
+
}
|
|
734
607
|
console.log('ā
Tokens sent (reverse), ledger:', sendLedger);
|
|
735
608
|
});
|
|
736
609
|
|
|
737
610
|
it('Scan PacketSent events (reverse)', async () => {
|
|
738
611
|
const packetSentEvents = await scanPacketSentEvents(
|
|
739
|
-
|
|
612
|
+
protocolAddresses.endpointV2,
|
|
740
613
|
sendLedger,
|
|
741
614
|
);
|
|
742
615
|
expect(packetSentEvents.length).toBeGreaterThan(0);
|
|
@@ -763,69 +636,60 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
763
636
|
});
|
|
764
637
|
|
|
765
638
|
it('Receive tokens (unlock on Lock/Unlock OFT)', async () => {
|
|
766
|
-
const mintBurnPeerBytes = StrKey.decodeContract(
|
|
639
|
+
const mintBurnPeerBytes = StrKey.decodeContract(mintBurnOftAddress);
|
|
767
640
|
const origin = {
|
|
768
641
|
nonce: 1n,
|
|
769
642
|
sender: Buffer.from(mintBurnPeerBytes),
|
|
770
643
|
src_eid: EID,
|
|
771
644
|
};
|
|
772
645
|
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
origin,
|
|
787
|
-
receiver: CONTRACT_ADDRESSES.lockUnlockOft,
|
|
788
|
-
value: 0n,
|
|
646
|
+
const assembledTx = await executorHelperClient.execute(
|
|
647
|
+
{
|
|
648
|
+
executor: protocolAddresses.executor,
|
|
649
|
+
params: {
|
|
650
|
+
extra_data: Buffer.from([]),
|
|
651
|
+
gas_limit: 0n,
|
|
652
|
+
guid,
|
|
653
|
+
message,
|
|
654
|
+
origin,
|
|
655
|
+
receiver: lockUnlockOftAddress,
|
|
656
|
+
value: 0n,
|
|
657
|
+
},
|
|
658
|
+
value_payer: EXECUTOR_ADMIN.publicKey(),
|
|
789
659
|
},
|
|
790
|
-
|
|
660
|
+
{
|
|
661
|
+
simulate: false,
|
|
662
|
+
},
|
|
663
|
+
);
|
|
791
664
|
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
CONTRACT_ADDRESSES.executor,
|
|
665
|
+
const txResult = await signAndSendWithExecutorAuth(
|
|
666
|
+
protocolAddresses.executor,
|
|
795
667
|
EXECUTOR_ADMIN,
|
|
796
668
|
assembledTx,
|
|
797
669
|
NETWORK_PASSPHRASE,
|
|
798
670
|
);
|
|
799
671
|
|
|
800
|
-
|
|
801
|
-
const sentTx = await assembledTx.signAndSend();
|
|
802
|
-
assertTransactionsSucceeded(sentTx, 'LzReceive (Unlock)');
|
|
672
|
+
assertTransactionSucceeded(txResult, 'LzReceive (Unlock)');
|
|
803
673
|
|
|
804
674
|
console.log('ā
Tokens received and unlocked on Lock/Unlock OFT');
|
|
805
675
|
});
|
|
806
676
|
|
|
807
677
|
it('Verify final balances', async () => {
|
|
808
|
-
|
|
809
|
-
// - DEFAULT_DEPLOYER: started with 1000, sent 100 (locked), sent 50 (burned) = 850
|
|
810
|
-
// - Lock/Unlock OFT: locked 100, unlocked 50 = 50 held
|
|
811
|
-
// - RECIPIENT_A: received 100 (minted)
|
|
812
|
-
// - RECIPIENT_B: received 50 (unlocked)
|
|
813
|
-
|
|
814
|
-
const senderBalance = await getSacBalance(
|
|
815
|
-
CONTRACT_ADDRESSES.oftToken,
|
|
678
|
+
const senderBalance = await getTokenBalance(
|
|
816
679
|
DEFAULT_DEPLOYER.publicKey(),
|
|
680
|
+
oftTokenAddress,
|
|
817
681
|
);
|
|
818
|
-
const lockUnlockOftBalance = await
|
|
819
|
-
|
|
820
|
-
|
|
682
|
+
const lockUnlockOftBalance = await getTokenBalance(
|
|
683
|
+
lockUnlockOftAddress,
|
|
684
|
+
oftTokenAddress,
|
|
821
685
|
);
|
|
822
|
-
const recipientABalance = await
|
|
823
|
-
CONTRACT_ADDRESSES.oftToken,
|
|
686
|
+
const recipientABalance = await getTokenBalance(
|
|
824
687
|
RECIPIENT_A.publicKey(),
|
|
688
|
+
oftTokenAddress,
|
|
825
689
|
);
|
|
826
|
-
const recipientBBalance = await
|
|
827
|
-
CONTRACT_ADDRESSES.oftToken,
|
|
690
|
+
const recipientBBalance = await getTokenBalance(
|
|
828
691
|
RECIPIENT_B.publicKey(),
|
|
692
|
+
oftTokenAddress,
|
|
829
693
|
);
|
|
830
694
|
|
|
831
695
|
console.log('\nš Final Balance Summary:');
|
|
@@ -836,10 +700,10 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
836
700
|
console.log(` - RECIPIENT_A (minted): ${recipientABalance} (expected: 1000000000)`);
|
|
837
701
|
console.log(` - RECIPIENT_B (unlocked): ${recipientBBalance} (expected: 500000000)`);
|
|
838
702
|
|
|
839
|
-
expect(senderBalance).toBe(8500000000n);
|
|
840
|
-
expect(lockUnlockOftBalance).toBe(500000000n);
|
|
841
|
-
expect(recipientABalance).toBe(1000000000n);
|
|
842
|
-
expect(recipientBBalance).toBe(500000000n);
|
|
703
|
+
expect(senderBalance).toBe(8500000000n);
|
|
704
|
+
expect(lockUnlockOftBalance).toBe(500000000n);
|
|
705
|
+
expect(recipientABalance).toBe(1000000000n);
|
|
706
|
+
expect(recipientBBalance).toBe(500000000n);
|
|
843
707
|
|
|
844
708
|
console.log('ā
OFT E2E test completed successfully!');
|
|
845
709
|
});
|