@layerzerolabs/lz-solana-sdk-v2 3.0.14 → 3.0.16
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/CHANGELOG.md +24 -0
- package/README.md +132 -0
- package/deployments/solana-mainnet/dvn-paxos.json +9 -0
- package/deployments/solana-testnet/dvn-paxos.json +9 -0
- package/dist/index.cjs +1315 -246
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +1940 -62
- package/dist/index.d.ts +1940 -62
- package/dist/index.mjs +1283 -214
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -15
package/dist/index.cjs
CHANGED
|
@@ -2,20 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
var web314 = require('@solana/web3.js');
|
|
4
4
|
var BN = require('bn.js');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var base58 = require('bs58');
|
|
10
|
-
require('@ethersproject/abi');
|
|
11
|
-
var bignumber = require('@ethersproject/bignumber');
|
|
12
|
-
require('@ethersproject/solidity');
|
|
5
|
+
var invariant3 = require('tiny-invariant');
|
|
6
|
+
var lzFoundation = require('@layerzerolabs/lz-foundation');
|
|
7
|
+
var lzUtilities = require('@layerzerolabs/lz-utilities');
|
|
8
|
+
var lzV2Utilities = require('@layerzerolabs/lz-v2-utilities');
|
|
13
9
|
var beet159 = require('@metaplex-foundation/beet');
|
|
14
10
|
var beetSolana85 = require('@metaplex-foundation/beet-solana');
|
|
15
11
|
var splToken = require('@solana/spl-token');
|
|
16
12
|
var lzDefinitions = require('@layerzerolabs/lz-definitions');
|
|
17
13
|
var crypto = require('crypto');
|
|
18
|
-
var
|
|
14
|
+
var base58 = require('bs58');
|
|
19
15
|
|
|
20
16
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
17
|
|
|
@@ -39,15 +35,14 @@ function _interopNamespace(e) {
|
|
|
39
35
|
|
|
40
36
|
var web314__namespace = /*#__PURE__*/_interopNamespace(web314);
|
|
41
37
|
var BN__default = /*#__PURE__*/_interopDefault(BN);
|
|
42
|
-
var
|
|
43
|
-
var base58__default = /*#__PURE__*/_interopDefault(base58);
|
|
38
|
+
var invariant3__default = /*#__PURE__*/_interopDefault(invariant3);
|
|
44
39
|
var beet159__namespace = /*#__PURE__*/_interopNamespace(beet159);
|
|
45
40
|
var beetSolana85__namespace = /*#__PURE__*/_interopNamespace(beetSolana85);
|
|
46
41
|
var splToken__namespace = /*#__PURE__*/_interopNamespace(splToken);
|
|
47
42
|
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
43
|
+
var base58__default = /*#__PURE__*/_interopDefault(base58);
|
|
48
44
|
|
|
49
45
|
var __defProp = Object.defineProperty;
|
|
50
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
51
46
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
52
47
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
53
48
|
}) : x)(function(x) {
|
|
@@ -59,10 +54,6 @@ var __export = (target, all) => {
|
|
|
59
54
|
for (var name in all)
|
|
60
55
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
61
56
|
};
|
|
62
|
-
var __publicField = (obj, key, value) => {
|
|
63
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
64
|
-
return value;
|
|
65
|
-
};
|
|
66
57
|
var ENDPOINT_SEED = "Endpoint";
|
|
67
58
|
var MESSAGE_LIB_SEED = "MessageLib";
|
|
68
59
|
var SEND_LIBRARY_CONFIG_SEED = "SendLibraryConfig";
|
|
@@ -91,12 +82,28 @@ var PEER_SEED = "Peer";
|
|
|
91
82
|
var MINT_SEED = "Mint";
|
|
92
83
|
var ENFORCED_OPTIONS_SEED = "EnforcedOptions";
|
|
93
84
|
var EndpointPDADeriver = class {
|
|
85
|
+
/**
|
|
86
|
+
* Creates an instance of the EndpointPDADeriver class.
|
|
87
|
+
*
|
|
88
|
+
* @param {PublicKey} program - The program public key.
|
|
89
|
+
*/
|
|
94
90
|
constructor(program) {
|
|
95
91
|
this.program = program;
|
|
96
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Derives the setting address.
|
|
95
|
+
*
|
|
96
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
97
|
+
*/
|
|
97
98
|
setting() {
|
|
98
99
|
return web314.PublicKey.findProgramAddressSync([Buffer.from(ENDPOINT_SEED, "utf8")], this.program);
|
|
99
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Derives the default send library configuration address.
|
|
103
|
+
*
|
|
104
|
+
* @param {number} dstEndpointId - The destination endpoint ID.
|
|
105
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
106
|
+
*/
|
|
100
107
|
defaultSendLibraryConfig(dstEndpointId) {
|
|
101
108
|
return web314.PublicKey.findProgramAddressSync(
|
|
102
109
|
[
|
|
@@ -107,6 +114,13 @@ var EndpointPDADeriver = class {
|
|
|
107
114
|
this.program
|
|
108
115
|
);
|
|
109
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Derives the send library configuration address.
|
|
119
|
+
*
|
|
120
|
+
* @param {PublicKey} sender - The sender public key.
|
|
121
|
+
* @param {number} dstEndpointId - The destination endpoint ID.
|
|
122
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
123
|
+
*/
|
|
110
124
|
sendLibraryConfig(sender, dstEndpointId) {
|
|
111
125
|
return web314.PublicKey.findProgramAddressSync(
|
|
112
126
|
[
|
|
@@ -119,7 +133,10 @@ var EndpointPDADeriver = class {
|
|
|
119
133
|
);
|
|
120
134
|
}
|
|
121
135
|
/**
|
|
122
|
-
*
|
|
136
|
+
* Derives the message library information address.
|
|
137
|
+
*
|
|
138
|
+
* @param {PublicKey} messageLibrary - The message library public key, PDA(derive by message lib program)
|
|
139
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
123
140
|
*/
|
|
124
141
|
messageLibraryInfo(messageLibrary) {
|
|
125
142
|
return web314.PublicKey.findProgramAddressSync(
|
|
@@ -127,6 +144,12 @@ var EndpointPDADeriver = class {
|
|
|
127
144
|
this.program
|
|
128
145
|
);
|
|
129
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Derives the default receive library configuration address.
|
|
149
|
+
*
|
|
150
|
+
* @param {number} srcEndpointId - The source endpoint ID.
|
|
151
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
152
|
+
*/
|
|
130
153
|
defaultReceiveLibraryConfig(srcEndpointId) {
|
|
131
154
|
return web314.PublicKey.findProgramAddressSync(
|
|
132
155
|
[
|
|
@@ -137,6 +160,13 @@ var EndpointPDADeriver = class {
|
|
|
137
160
|
this.program
|
|
138
161
|
);
|
|
139
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Derives the receive library configuration address.
|
|
165
|
+
*
|
|
166
|
+
* @param {PublicKey} receiver - The receiver public key.
|
|
167
|
+
* @param {number} srcEndpointId - The source endpoint ID.
|
|
168
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
169
|
+
*/
|
|
140
170
|
receiveLibraryConfig(receiver, srcEndpointId) {
|
|
141
171
|
return web314.PublicKey.findProgramAddressSync(
|
|
142
172
|
[
|
|
@@ -161,9 +191,12 @@ var EndpointPDADeriver = class {
|
|
|
161
191
|
);
|
|
162
192
|
}
|
|
163
193
|
/**
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
* @param
|
|
194
|
+
* Derives the nonce address.
|
|
195
|
+
*
|
|
196
|
+
* @param {PublicKey} localOapp - The local OApp public key.
|
|
197
|
+
* @param {number} remoteChainId - The remote chain ID.
|
|
198
|
+
* @param {Uint8Array} remoteOapp - The remote OApp address.
|
|
199
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
167
200
|
*/
|
|
168
201
|
nonce(localOapp, remoteChainId, remoteOapp) {
|
|
169
202
|
return web314.PublicKey.findProgramAddressSync(
|
|
@@ -177,6 +210,14 @@ var EndpointPDADeriver = class {
|
|
|
177
210
|
this.program
|
|
178
211
|
);
|
|
179
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* Derives the pending nonce address.
|
|
215
|
+
*
|
|
216
|
+
* @param {PublicKey} localOapp - The local OApp public key.
|
|
217
|
+
* @param {number} remoteChainId - The remote chain ID.
|
|
218
|
+
* @param {Uint8Array} remoteOapp - The remote OApp address.
|
|
219
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
220
|
+
*/
|
|
180
221
|
pendingNonce(localOapp, remoteChainId, remoteOapp) {
|
|
181
222
|
return web314.PublicKey.findProgramAddressSync(
|
|
182
223
|
[
|
|
@@ -188,19 +229,23 @@ var EndpointPDADeriver = class {
|
|
|
188
229
|
this.program
|
|
189
230
|
);
|
|
190
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* Derives the OApp registry address.
|
|
234
|
+
*
|
|
235
|
+
* @param {PublicKey} localOapp - The local OApp public key.
|
|
236
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
237
|
+
*/
|
|
191
238
|
oappRegistry(localOapp) {
|
|
192
239
|
return web314.PublicKey.findProgramAddressSync([Buffer.from(OAPP_SEED, "utf8"), localOapp.toBytes()], this.program);
|
|
193
240
|
}
|
|
194
|
-
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
* @param
|
|
198
|
-
* @param
|
|
199
|
-
* @param
|
|
200
|
-
* @
|
|
201
|
-
* @
|
|
202
|
-
* @nonce u64 to Uint8Array([0,0,0,0,0,0,0,0])
|
|
203
|
-
* @payloadHash [u8; 32]
|
|
241
|
+
/**
|
|
242
|
+
* Derives the payload hash address.
|
|
243
|
+
*
|
|
244
|
+
* @param {PublicKey} receiver - The receiver public key.
|
|
245
|
+
* @param {number} srcEid - The source endpoint ID.
|
|
246
|
+
* @param {Uint8Array} sender - The sender address.
|
|
247
|
+
* @param {number} nonce - The nonce.
|
|
248
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
204
249
|
*/
|
|
205
250
|
payloadHash(receiver, srcEid, sender, nonce) {
|
|
206
251
|
return web314.PublicKey.findProgramAddressSync(
|
|
@@ -214,6 +259,16 @@ var EndpointPDADeriver = class {
|
|
|
214
259
|
this.program
|
|
215
260
|
);
|
|
216
261
|
}
|
|
262
|
+
/**
|
|
263
|
+
* Derives the composed message address.
|
|
264
|
+
*
|
|
265
|
+
* @param {PublicKey} from - The sender public key.
|
|
266
|
+
* @param {Uint8Array} guid - The GUID.
|
|
267
|
+
* @param {number} index - The index.
|
|
268
|
+
* @param {PublicKey} to - The receiver public key.
|
|
269
|
+
* @param {Uint8Array} messageHash - The message hash.
|
|
270
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
271
|
+
*/
|
|
217
272
|
composedMessage(from, guid, index, to, messageHash) {
|
|
218
273
|
return web314.PublicKey.findProgramAddressSync(
|
|
219
274
|
[
|
|
@@ -229,18 +284,42 @@ var EndpointPDADeriver = class {
|
|
|
229
284
|
}
|
|
230
285
|
};
|
|
231
286
|
var MessageLibPDADeriver = class {
|
|
287
|
+
/**
|
|
288
|
+
* Creates an instance of the MessageLibPDADeriver class.
|
|
289
|
+
*
|
|
290
|
+
* @param {PublicKey} program - The program public key.
|
|
291
|
+
*/
|
|
232
292
|
constructor(program) {
|
|
233
293
|
this.program = program;
|
|
234
294
|
}
|
|
295
|
+
/**
|
|
296
|
+
* Derives the message library address.
|
|
297
|
+
*
|
|
298
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
299
|
+
*/
|
|
235
300
|
messageLib() {
|
|
236
301
|
return web314.PublicKey.findProgramAddressSync([Buffer.from(MESSAGE_LIB_SEED, "utf8")], this.program);
|
|
237
302
|
}
|
|
303
|
+
/**
|
|
304
|
+
* Derives the send configuration address.
|
|
305
|
+
*
|
|
306
|
+
* @param {number} eid - The endpoint ID.
|
|
307
|
+
* @param {PublicKey} oapp - The OApp public key.
|
|
308
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
309
|
+
*/
|
|
238
310
|
sendConfig(eid, oapp) {
|
|
239
311
|
return web314.PublicKey.findProgramAddressSync(
|
|
240
312
|
[Buffer.from(SEND_CONFIG_SEED, "utf8"), new BN__default.default(eid).toArrayLike(Buffer, "be", 4), oapp.toBuffer()],
|
|
241
313
|
this.program
|
|
242
314
|
);
|
|
243
315
|
}
|
|
316
|
+
/**
|
|
317
|
+
* Derives the receive configuration address.
|
|
318
|
+
*
|
|
319
|
+
* @param {number} eid - The endpoint ID.
|
|
320
|
+
* @param {PublicKey} oapp - The OApp public key.
|
|
321
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
322
|
+
*/
|
|
244
323
|
receiveConfig(eid, oapp) {
|
|
245
324
|
return web314.PublicKey.findProgramAddressSync(
|
|
246
325
|
[Buffer.from(RECEIVE_CONFIG_SEED, "utf8"), new BN__default.default(eid).toArrayLike(Buffer, "be", 4), oapp.toBuffer()],
|
|
@@ -249,36 +328,79 @@ var MessageLibPDADeriver = class {
|
|
|
249
328
|
}
|
|
250
329
|
};
|
|
251
330
|
var UlnPDADeriver = class extends MessageLibPDADeriver {
|
|
331
|
+
/**
|
|
332
|
+
* Derives the setting address.
|
|
333
|
+
*
|
|
334
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
335
|
+
*/
|
|
252
336
|
setting() {
|
|
253
337
|
return web314.PublicKey.findProgramAddressSync([Buffer.from(ULN_SEED, "utf8")], this.program);
|
|
254
338
|
}
|
|
339
|
+
/**
|
|
340
|
+
* Derives the configuration address.
|
|
341
|
+
*
|
|
342
|
+
* @param {number} eid - The endpoint ID.
|
|
343
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
344
|
+
*/
|
|
255
345
|
config(eid) {
|
|
256
346
|
return web314.PublicKey.findProgramAddressSync(
|
|
257
347
|
[Buffer.from(ULN_CONFIG_SEED, "utf8"), new BN__default.default(eid).toArrayLike(Buffer, "be", 4)],
|
|
258
348
|
this.program
|
|
259
349
|
);
|
|
260
350
|
}
|
|
351
|
+
/**
|
|
352
|
+
* Derives the default send configuration address.
|
|
353
|
+
*
|
|
354
|
+
* @param {number} eid - The endpoint ID.
|
|
355
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
356
|
+
*/
|
|
261
357
|
defaultSendConfig(eid) {
|
|
262
358
|
return web314.PublicKey.findProgramAddressSync(
|
|
263
359
|
[Buffer.from(SEND_CONFIG_SEED, "utf8"), new BN__default.default(eid).toArrayLike(Buffer, "be", 4)],
|
|
264
360
|
this.program
|
|
265
361
|
);
|
|
266
362
|
}
|
|
363
|
+
/**
|
|
364
|
+
* Derives the default receive configuration address.
|
|
365
|
+
*
|
|
366
|
+
* @param {number} eid - The endpoint ID.
|
|
367
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
368
|
+
*/
|
|
267
369
|
defaultReceiveConfig(eid) {
|
|
268
370
|
return web314.PublicKey.findProgramAddressSync(
|
|
269
371
|
[Buffer.from(RECEIVE_CONFIG_SEED, "utf8"), new BN__default.default(eid).toArrayLike(Buffer, "be", 4)],
|
|
270
372
|
this.program
|
|
271
373
|
);
|
|
272
374
|
}
|
|
375
|
+
/**
|
|
376
|
+
* Derives the options address.
|
|
377
|
+
*
|
|
378
|
+
* @param {number} eit - The endpoint ID.
|
|
379
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
380
|
+
*/
|
|
273
381
|
options(eit) {
|
|
274
382
|
return web314.PublicKey.findProgramAddressSync(
|
|
275
383
|
[Buffer.from(OPTIONS_SEED, "utf8"), new BN__default.default(eit).toArrayLike(Buffer, "be", 4)],
|
|
276
384
|
this.program
|
|
277
385
|
);
|
|
278
386
|
}
|
|
387
|
+
/**
|
|
388
|
+
* Derives the worker configuration address.
|
|
389
|
+
*
|
|
390
|
+
* @param {PublicKey} worker - The worker public key.
|
|
391
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
392
|
+
*/
|
|
279
393
|
workerConfig(worker) {
|
|
280
394
|
return web314.PublicKey.findProgramAddressSync([Buffer.from(WORKER_SEED, "utf8"), worker.toBuffer()], this.program);
|
|
281
395
|
}
|
|
396
|
+
/**
|
|
397
|
+
* Derives the confirmations address.
|
|
398
|
+
*
|
|
399
|
+
* @param {Uint8Array} headerHash - The header hash.
|
|
400
|
+
* @param {Uint8Array} payloadHash - The payload hash.
|
|
401
|
+
* @param {PublicKey} dvn - The DVN public key.
|
|
402
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
403
|
+
*/
|
|
282
404
|
confirmations(headerHash, payloadHash, dvn) {
|
|
283
405
|
return web314.PublicKey.findProgramAddressSync(
|
|
284
406
|
[Buffer.from(CONFIRMATIONS_SEED, "utf8"), headerHash, payloadHash, dvn.toBytes()],
|
|
@@ -287,18 +409,39 @@ var UlnPDADeriver = class extends MessageLibPDADeriver {
|
|
|
287
409
|
}
|
|
288
410
|
};
|
|
289
411
|
var OAppBasePDADeriver = class {
|
|
412
|
+
/**
|
|
413
|
+
* Creates an instance of the OAppBasePDADeriver class.
|
|
414
|
+
*
|
|
415
|
+
* @param {PublicKey} program - The program public key.
|
|
416
|
+
*/
|
|
290
417
|
constructor(program) {
|
|
291
418
|
this.program = program;
|
|
292
419
|
}
|
|
420
|
+
/**
|
|
421
|
+
* Derives the remote address.
|
|
422
|
+
*
|
|
423
|
+
* @param {number} dstChainId - The destination chain ID.
|
|
424
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
425
|
+
*/
|
|
293
426
|
remote(dstChainId) {
|
|
294
427
|
return web314.PublicKey.findProgramAddressSync(
|
|
295
428
|
[Buffer.from(REMOTE_SEED), new BN__default.default(dstChainId).toArrayLike(Buffer, "be", 4)],
|
|
296
429
|
this.program
|
|
297
430
|
);
|
|
298
431
|
}
|
|
432
|
+
/**
|
|
433
|
+
* Derives the LzReceive types accounts address.
|
|
434
|
+
*
|
|
435
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
436
|
+
*/
|
|
299
437
|
lzReceiveTypesAccounts() {
|
|
300
438
|
return web314.PublicKey.findProgramAddressSync([Buffer.from(LZ_RECEIVE_TYPES_SEED, "utf8")], this.program);
|
|
301
439
|
}
|
|
440
|
+
/**
|
|
441
|
+
* Derives the LzCompose types accounts address.
|
|
442
|
+
*
|
|
443
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
444
|
+
*/
|
|
302
445
|
lzComposeTypesAccounts() {
|
|
303
446
|
return web314.PublicKey.findProgramAddressSync([Buffer.from(LZ_COMPOSE_TYPES_SEED, "utf8")], this.program);
|
|
304
447
|
}
|
|
@@ -307,36 +450,82 @@ var DVNDeriver = class {
|
|
|
307
450
|
constructor(program) {
|
|
308
451
|
this.program = program;
|
|
309
452
|
}
|
|
453
|
+
/**
|
|
454
|
+
* Derives the authority address.
|
|
455
|
+
*
|
|
456
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
457
|
+
*/
|
|
310
458
|
authority() {
|
|
311
459
|
return web314.PublicKey.findProgramAddressSync([Buffer.from("dvn", "utf8")], this.program);
|
|
312
460
|
}
|
|
461
|
+
/**
|
|
462
|
+
* Derives the configuration address.
|
|
463
|
+
*
|
|
464
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
465
|
+
*/
|
|
313
466
|
config() {
|
|
314
467
|
return web314.PublicKey.findProgramAddressSync([Buffer.from(DVN_CONFIG_SEED, "utf8")], this.program);
|
|
315
468
|
}
|
|
469
|
+
/**
|
|
470
|
+
* Derives the execute hash address.
|
|
471
|
+
*
|
|
472
|
+
* @param {Buffer} digestHash - The digest hash.
|
|
473
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
474
|
+
*/
|
|
316
475
|
executeHash(digestHash) {
|
|
317
476
|
return web314.PublicKey.findProgramAddressSync([Buffer.from("ExecuteHash", "utf8"), digestHash], this.program);
|
|
318
477
|
}
|
|
319
478
|
};
|
|
320
479
|
var EventPDADeriver = class {
|
|
480
|
+
/**
|
|
481
|
+
* Creates an instance of the EventPDADeriver class.
|
|
482
|
+
*
|
|
483
|
+
* @param {PublicKey} program - The program public key.
|
|
484
|
+
*/
|
|
321
485
|
constructor(program) {
|
|
322
486
|
this.program = program;
|
|
323
487
|
}
|
|
488
|
+
/**
|
|
489
|
+
* Derives the event authority PDA.
|
|
490
|
+
*
|
|
491
|
+
* @returns {[PublicKey, number]} The event authority PDA and bump seed.
|
|
492
|
+
*/
|
|
324
493
|
eventAuthority() {
|
|
325
494
|
return web314.PublicKey.findProgramAddressSync([Buffer.from(EVENT_SEED, "utf8")], this.program);
|
|
326
495
|
}
|
|
327
496
|
};
|
|
328
497
|
var ExecutorPDADeriver = class {
|
|
498
|
+
/**
|
|
499
|
+
* Creates an instance of the ExecutorPDADeriver class.
|
|
500
|
+
*
|
|
501
|
+
* @param {PublicKey} program - The program public key.
|
|
502
|
+
*/
|
|
329
503
|
constructor(program) {
|
|
330
504
|
this.program = program;
|
|
331
505
|
}
|
|
506
|
+
/**
|
|
507
|
+
* Derives the executor configuration PDA.
|
|
508
|
+
*
|
|
509
|
+
* @returns {[PublicKey, number]} The executor configuration PDA and bump seed.
|
|
510
|
+
*/
|
|
332
511
|
config() {
|
|
333
512
|
return web314.PublicKey.findProgramAddressSync([Buffer.from(EXECUTOR_CONFIG_SEED, "utf8")], this.program);
|
|
334
513
|
}
|
|
335
514
|
};
|
|
336
515
|
var PriceFeedPDADeriver = class {
|
|
516
|
+
/**
|
|
517
|
+
* Creates an instance of the PriceFeedPDADeriver class.
|
|
518
|
+
*
|
|
519
|
+
* @param {PublicKey} program - The program public key.
|
|
520
|
+
*/
|
|
337
521
|
constructor(program) {
|
|
338
522
|
this.program = program;
|
|
339
523
|
}
|
|
524
|
+
/**
|
|
525
|
+
* Derives the price feed PDA.
|
|
526
|
+
*
|
|
527
|
+
* @returns {[PublicKey, number]} The price feed PDA and bump seed.
|
|
528
|
+
*/
|
|
340
529
|
priceFeed() {
|
|
341
530
|
return web314.PublicKey.findProgramAddressSync([Buffer.from(PRICE_FEED_SEED, "utf8")], this.program);
|
|
342
531
|
}
|
|
@@ -355,138 +544,6 @@ __export(endpoint_exports, {
|
|
|
355
544
|
instructions: () => instructions_exports,
|
|
356
545
|
types: () => types_exports
|
|
357
546
|
});
|
|
358
|
-
function hexZeroPadTo32(addr) {
|
|
359
|
-
return bytes.hexZeroPad(addr, 32);
|
|
360
|
-
}
|
|
361
|
-
function bytes32ToEthAddress(bytes322) {
|
|
362
|
-
if (bytes322 instanceof Uint8Array) {
|
|
363
|
-
bytes322 = bytes.hexlify(bytes322);
|
|
364
|
-
}
|
|
365
|
-
return address.getAddress(bytes322.slice(-40));
|
|
366
|
-
}
|
|
367
|
-
function trim0x(str) {
|
|
368
|
-
return str.replace(/^0x/, "");
|
|
369
|
-
}
|
|
370
|
-
function addressToBytes32(address) {
|
|
371
|
-
if (isSolanaAddress(address)) {
|
|
372
|
-
return base58__default.default.decode(address);
|
|
373
|
-
} else if (address.startsWith("0x") && address.length <= 66) {
|
|
374
|
-
return bytes.arrayify(hexZeroPadTo32(address));
|
|
375
|
-
}
|
|
376
|
-
throw new Error("Invalid address");
|
|
377
|
-
}
|
|
378
|
-
var solanaAddressRegex = /^([1-9A-HJ-NP-Za-km-z]{32,44})$/;
|
|
379
|
-
function isSolanaAddress(address) {
|
|
380
|
-
return solanaAddressRegex.test(address);
|
|
381
|
-
}
|
|
382
|
-
bignumber.BigNumber.from("0xffffffffffffffffffffffffffffffff");
|
|
383
|
-
var PACKET_VERSION_OFFSET = 0;
|
|
384
|
-
var NONCE_OFFSET = 1;
|
|
385
|
-
var SRC_CHAIN_OFFSET = 9;
|
|
386
|
-
var SRC_ADDRESS_OFFSET = 13;
|
|
387
|
-
var DST_CHAIN_OFFSET = 45;
|
|
388
|
-
var DST_ADDRESS_OFFSET = 49;
|
|
389
|
-
var GUID_OFFSET = 81;
|
|
390
|
-
var MESSAGE_OFFSET = 113;
|
|
391
|
-
var PacketV1Codec = class _PacketV1Codec {
|
|
392
|
-
constructor(payloadEncoded) {
|
|
393
|
-
__publicField(this, "buffer");
|
|
394
|
-
this.buffer = Buffer.from(trim0x(payloadEncoded), "hex");
|
|
395
|
-
}
|
|
396
|
-
static from(payloadEncoded) {
|
|
397
|
-
return new _PacketV1Codec(payloadEncoded);
|
|
398
|
-
}
|
|
399
|
-
static fromBytes(payload) {
|
|
400
|
-
return new _PacketV1Codec("0x" + Buffer.from(payload).toString("hex"));
|
|
401
|
-
}
|
|
402
|
-
/**
|
|
403
|
-
* encode packet to hex string
|
|
404
|
-
*/
|
|
405
|
-
static encode(packet) {
|
|
406
|
-
const buff = this.encodeBytes(packet);
|
|
407
|
-
return "0x" + Buffer.from(buff).toString("hex");
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* encode packet to Uint8Array
|
|
411
|
-
* @param packet
|
|
412
|
-
*/
|
|
413
|
-
static encodeBytes(packet) {
|
|
414
|
-
const message = trim0x(packet.message);
|
|
415
|
-
const buffer = Buffer.alloc(MESSAGE_OFFSET + message.length / 2);
|
|
416
|
-
buffer.writeUInt8(packet.version, PACKET_VERSION_OFFSET);
|
|
417
|
-
buffer.writeBigUInt64BE(BigInt(packet.nonce), NONCE_OFFSET);
|
|
418
|
-
buffer.writeUInt32BE(packet.srcEid, SRC_CHAIN_OFFSET);
|
|
419
|
-
buffer.write(Buffer.from(addressToBytes32(packet.sender)).toString("hex"), SRC_ADDRESS_OFFSET, 32, "hex");
|
|
420
|
-
buffer.writeUInt32BE(packet.dstEid, DST_CHAIN_OFFSET);
|
|
421
|
-
buffer.write(Buffer.from(addressToBytes32(packet.receiver)).toString("hex"), DST_ADDRESS_OFFSET, 32, "hex");
|
|
422
|
-
buffer.write(trim0x(packet.guid), GUID_OFFSET, 32, "hex");
|
|
423
|
-
buffer.write(message, MESSAGE_OFFSET, message.length / 2, "hex");
|
|
424
|
-
return new Uint8Array(buffer);
|
|
425
|
-
}
|
|
426
|
-
version() {
|
|
427
|
-
return this.buffer.readUInt8(PACKET_VERSION_OFFSET);
|
|
428
|
-
}
|
|
429
|
-
nonce() {
|
|
430
|
-
return this.buffer.readBigUint64BE(NONCE_OFFSET).toString();
|
|
431
|
-
}
|
|
432
|
-
srcEid() {
|
|
433
|
-
return this.buffer.readUint32BE(SRC_CHAIN_OFFSET);
|
|
434
|
-
}
|
|
435
|
-
sender() {
|
|
436
|
-
return "0x" + this.buffer.slice(SRC_ADDRESS_OFFSET, DST_CHAIN_OFFSET).toString("hex");
|
|
437
|
-
}
|
|
438
|
-
senderAddressB20() {
|
|
439
|
-
return bytes32ToEthAddress(this.sender());
|
|
440
|
-
}
|
|
441
|
-
dstEid() {
|
|
442
|
-
return this.buffer.readUint32BE(DST_CHAIN_OFFSET);
|
|
443
|
-
}
|
|
444
|
-
receiver() {
|
|
445
|
-
return "0x" + this.buffer.slice(DST_ADDRESS_OFFSET, GUID_OFFSET).toString("hex");
|
|
446
|
-
}
|
|
447
|
-
receiverAddressB20() {
|
|
448
|
-
return bytes32ToEthAddress(this.receiver());
|
|
449
|
-
}
|
|
450
|
-
guid() {
|
|
451
|
-
return "0x" + this.buffer.slice(GUID_OFFSET, MESSAGE_OFFSET).toString("hex");
|
|
452
|
-
}
|
|
453
|
-
message() {
|
|
454
|
-
return "0x" + this.buffer.slice(MESSAGE_OFFSET).toString("hex");
|
|
455
|
-
}
|
|
456
|
-
payloadHash() {
|
|
457
|
-
return keccak256.keccak256(this.payload());
|
|
458
|
-
}
|
|
459
|
-
payload() {
|
|
460
|
-
return "0x" + this.buffer.slice(GUID_OFFSET).toString("hex");
|
|
461
|
-
}
|
|
462
|
-
header() {
|
|
463
|
-
return "0x" + this.buffer.slice(0, GUID_OFFSET).toString("hex");
|
|
464
|
-
}
|
|
465
|
-
headerHash() {
|
|
466
|
-
return keccak256.keccak256(this.header());
|
|
467
|
-
}
|
|
468
|
-
/**
|
|
469
|
-
* deserialize packet from hex string
|
|
470
|
-
* @deprecated use toPacket instead
|
|
471
|
-
*/
|
|
472
|
-
decode() {
|
|
473
|
-
return this.toPacket();
|
|
474
|
-
}
|
|
475
|
-
toPacket() {
|
|
476
|
-
return {
|
|
477
|
-
version: this.version(),
|
|
478
|
-
nonce: this.nonce(),
|
|
479
|
-
srcEid: this.srcEid(),
|
|
480
|
-
sender: this.sender(),
|
|
481
|
-
dstEid: this.dstEid(),
|
|
482
|
-
receiver: this.receiver(),
|
|
483
|
-
guid: this.guid(),
|
|
484
|
-
message: this.message(),
|
|
485
|
-
// derived
|
|
486
|
-
payload: this.payload()
|
|
487
|
-
};
|
|
488
|
-
}
|
|
489
|
-
};
|
|
490
547
|
|
|
491
548
|
// src/generated/endpoint/accounts/index.ts
|
|
492
549
|
var accounts_exports = {};
|
|
@@ -5865,6 +5922,11 @@ var sendLibrarySetEventBeet = new beet159__namespace.BeetArgsStruct(
|
|
|
5865
5922
|
var EventEmitDiscriminator = "e445a52e51cb9a1d";
|
|
5866
5923
|
var DefaultMessageLib = web314.PublicKey.default;
|
|
5867
5924
|
var Endpoint = class {
|
|
5925
|
+
/**
|
|
5926
|
+
* Creates an instance of the Endpoint class.
|
|
5927
|
+
*
|
|
5928
|
+
* @param {PublicKey} program - The program public key.
|
|
5929
|
+
*/
|
|
5868
5930
|
constructor(program) {
|
|
5869
5931
|
this.program = program;
|
|
5870
5932
|
this.deriver = new EndpointPDADeriver(program);
|
|
@@ -5872,7 +5934,12 @@ var Endpoint = class {
|
|
|
5872
5934
|
this.eventAuthorityPDA = eventAuthorityPDA;
|
|
5873
5935
|
}
|
|
5874
5936
|
/**
|
|
5875
|
-
*
|
|
5937
|
+
* Initializes the endpoint settings, including eid and admin, and registers the blocked message library.
|
|
5938
|
+
*
|
|
5939
|
+
* @param {number} endpointId - The endpoint ID.
|
|
5940
|
+
* @param {PublicKey} payer - The payer public key.
|
|
5941
|
+
* @param {PublicKey} admin - The admin public key.
|
|
5942
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
5876
5943
|
*/
|
|
5877
5944
|
initEndpoint(endpointId, payer, admin) {
|
|
5878
5945
|
const [settingPDA] = this.deriver.setting();
|
|
@@ -5891,8 +5958,14 @@ var Endpoint = class {
|
|
|
5891
5958
|
);
|
|
5892
5959
|
}
|
|
5893
5960
|
// async initOrUpdateConfig(connection:Connection,)
|
|
5894
|
-
|
|
5961
|
+
/**
|
|
5962
|
+
* Registers a library.
|
|
5895
5963
|
* call this function after endpoint initialized. Only admin can call this function.
|
|
5964
|
+
*
|
|
5965
|
+
* @param {PublicKey} admin - The admin public key.
|
|
5966
|
+
* @param {PublicKey} messageLibProgram - The message library program public key.
|
|
5967
|
+
* @param {types.MessageLibType} [libType=types.MessageLibType.SendAndReceive] - The library type.
|
|
5968
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
5896
5969
|
*/
|
|
5897
5970
|
registerLibrary(admin, messageLibProgram, libType = 2 /* SendAndReceive */) {
|
|
5898
5971
|
const [msgLibPda] = new MessageLibPDADeriver(messageLibProgram).messageLib();
|
|
@@ -5915,6 +5988,16 @@ var Endpoint = class {
|
|
|
5915
5988
|
this.program
|
|
5916
5989
|
);
|
|
5917
5990
|
}
|
|
5991
|
+
/**
|
|
5992
|
+
* Sets the default send library.
|
|
5993
|
+
*
|
|
5994
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
5995
|
+
* @param {PublicKey} admin - The admin public key.
|
|
5996
|
+
* @param {PublicKey} messageLibProgram - The message library program public key.
|
|
5997
|
+
* @param {number} dstEid - The destination endpoint ID.
|
|
5998
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
5999
|
+
* @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
|
|
6000
|
+
*/
|
|
5918
6001
|
async setDefaultSendLibrary(connection, admin, messageLibProgram, dstEid, commitmentOrConfig) {
|
|
5919
6002
|
const [msgLib] = new MessageLibPDADeriver(messageLibProgram).messageLib();
|
|
5920
6003
|
const [defaultSendLibConfig] = this.deriver.defaultSendLibraryConfig(dstEid);
|
|
@@ -5967,6 +6050,16 @@ var Endpoint = class {
|
|
|
5967
6050
|
);
|
|
5968
6051
|
}
|
|
5969
6052
|
}
|
|
6053
|
+
/**
|
|
6054
|
+
* Sets the default receive library.
|
|
6055
|
+
*
|
|
6056
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
6057
|
+
* @param {PublicKey} admin - The admin public key.
|
|
6058
|
+
* @param {PublicKey} messageLibProgram - The message library program public key.
|
|
6059
|
+
* @param {number} srcEid - The source endpoint ID.
|
|
6060
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
6061
|
+
* @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
|
|
6062
|
+
*/
|
|
5970
6063
|
async setDefaultReceiveLibrary(connection, admin, messageLibProgram, srcEid, commitmentOrConfig) {
|
|
5971
6064
|
const [msgLib] = new MessageLibPDADeriver(messageLibProgram).messageLib();
|
|
5972
6065
|
const [defaultReceiveLibConfig] = this.deriver.defaultReceiveLibraryConfig(srcEid);
|
|
@@ -6021,6 +6114,16 @@ var Endpoint = class {
|
|
|
6021
6114
|
);
|
|
6022
6115
|
}
|
|
6023
6116
|
}
|
|
6117
|
+
/**
|
|
6118
|
+
* Initializes the OApp configuration.
|
|
6119
|
+
*
|
|
6120
|
+
* @param {PublicKey} delegate - The delegate public key.
|
|
6121
|
+
* @param {MessageLibInterface} msgLibSDK - The message library SDK.
|
|
6122
|
+
* @param {PublicKey} payer - The payer public key.
|
|
6123
|
+
* @param {PublicKey} oappID - The OApp ID public key.
|
|
6124
|
+
* @param {number} eid - The endpoint ID.
|
|
6125
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
6126
|
+
*/
|
|
6024
6127
|
initOAppConfig(delegate, msgLibSDK, payer, oappID, eid) {
|
|
6025
6128
|
const [msgLib] = new MessageLibPDADeriver(msgLibSDK.program).messageLib();
|
|
6026
6129
|
const [oappRegistry] = this.deriver.oappRegistry(oappID);
|
|
@@ -6043,6 +6146,15 @@ var Endpoint = class {
|
|
|
6043
6146
|
this.program
|
|
6044
6147
|
);
|
|
6045
6148
|
}
|
|
6149
|
+
/**
|
|
6150
|
+
* Initializes the OApp nonce.
|
|
6151
|
+
*
|
|
6152
|
+
* @param {PublicKey} delegate - The delegate public key.
|
|
6153
|
+
* @param {number} dstEid - The destination endpoint ID.
|
|
6154
|
+
* @param {PublicKey} oappIDPDA - The OApp ID PDA.
|
|
6155
|
+
* @param {Uint8Array} remoteOappAddr - The remote OApp address.
|
|
6156
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
6157
|
+
*/
|
|
6046
6158
|
initOAppNonce(delegate, dstEid, oappIDPDA2, remoteOappAddr) {
|
|
6047
6159
|
const [nonce] = this.deriver.nonce(oappIDPDA2, dstEid, remoteOappAddr);
|
|
6048
6160
|
const [pendingNonce] = this.deriver.pendingNonce(oappIDPDA2, dstEid, remoteOappAddr);
|
|
@@ -6064,6 +6176,14 @@ var Endpoint = class {
|
|
|
6064
6176
|
this.program
|
|
6065
6177
|
);
|
|
6066
6178
|
}
|
|
6179
|
+
/**
|
|
6180
|
+
* Initializes the send library.
|
|
6181
|
+
*
|
|
6182
|
+
* @param {PublicKey} delegate - The delegate public key.
|
|
6183
|
+
* @param {PublicKey} sender - The sender public key.
|
|
6184
|
+
* @param {number} dstEid - The destination endpoint ID.
|
|
6185
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
6186
|
+
*/
|
|
6067
6187
|
initSendLibrary(delegate, sender, dstEid) {
|
|
6068
6188
|
const [oappRegistry] = this.deriver.oappRegistry(sender);
|
|
6069
6189
|
const [sendLibraryConfig] = this.deriver.sendLibraryConfig(sender, dstEid);
|
|
@@ -6082,6 +6202,15 @@ var Endpoint = class {
|
|
|
6082
6202
|
this.program
|
|
6083
6203
|
);
|
|
6084
6204
|
}
|
|
6205
|
+
/**
|
|
6206
|
+
* Sets the send library.
|
|
6207
|
+
*
|
|
6208
|
+
* @param {PublicKey} oappAdmin - The OApp admin public key.
|
|
6209
|
+
* @param {PublicKey} oappIDPDA - The OApp ID PDA.
|
|
6210
|
+
* @param {PublicKey} newSendLibProgram - The new send library program public key.
|
|
6211
|
+
* @param {number} dstEid - The destination endpoint ID.
|
|
6212
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
6213
|
+
*/
|
|
6085
6214
|
setSendLibrary(oappAdmin, oappIDPDA2, newSendLibProgram, dstEid) {
|
|
6086
6215
|
const [newSendLib] = new MessageLibPDADeriver(newSendLibProgram).messageLib();
|
|
6087
6216
|
const [sendLibraryConfig] = this.deriver.sendLibraryConfig(oappIDPDA2, dstEid);
|
|
@@ -6107,6 +6236,14 @@ var Endpoint = class {
|
|
|
6107
6236
|
);
|
|
6108
6237
|
return ix;
|
|
6109
6238
|
}
|
|
6239
|
+
/**
|
|
6240
|
+
* Initializes the receive library.
|
|
6241
|
+
*
|
|
6242
|
+
* @param {PublicKey} delegate - The delegate public key.
|
|
6243
|
+
* @param {PublicKey} receiver - The receiver public key.
|
|
6244
|
+
* @param {number} srcEid - The source endpoint ID.
|
|
6245
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
6246
|
+
*/
|
|
6110
6247
|
initReceiveLibrary(delegate, receiver, srcEid) {
|
|
6111
6248
|
const [oappRegistry] = this.deriver.oappRegistry(receiver);
|
|
6112
6249
|
const [receiveLibraryConfig] = this.deriver.receiveLibraryConfig(receiver, srcEid);
|
|
@@ -6125,6 +6262,16 @@ var Endpoint = class {
|
|
|
6125
6262
|
this.program
|
|
6126
6263
|
);
|
|
6127
6264
|
}
|
|
6265
|
+
/**
|
|
6266
|
+
* Sets the receive library.
|
|
6267
|
+
*
|
|
6268
|
+
* @param {PublicKey} oappAdmin - The OApp admin public key.
|
|
6269
|
+
* @param {PublicKey} oappIDPDA - The OApp ID PDA.
|
|
6270
|
+
* @param {PublicKey} newReceiveLibProgram - The new receive library program public key.
|
|
6271
|
+
* @param {number} srcEid - The source endpoint ID.
|
|
6272
|
+
* @param {bigint | number} [gracePeriod] - The grace period.
|
|
6273
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
6274
|
+
*/
|
|
6128
6275
|
setReceiveLibrary(oappAdmin, oappIDPDA2, newReceiveLibProgram, srcEid, gracePeriod) {
|
|
6129
6276
|
const [newReceiveLib] = new MessageLibPDADeriver(newReceiveLibProgram).messageLib();
|
|
6130
6277
|
const [receiveLibraryConfig] = this.deriver.receiveLibraryConfig(oappIDPDA2, srcEid);
|
|
@@ -6151,6 +6298,21 @@ var Endpoint = class {
|
|
|
6151
6298
|
);
|
|
6152
6299
|
return ix;
|
|
6153
6300
|
}
|
|
6301
|
+
/**
|
|
6302
|
+
* Sets the OApp configuration.
|
|
6303
|
+
*
|
|
6304
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
6305
|
+
* @param {PublicKey} oappDelegate - The OApp delegate public key.
|
|
6306
|
+
* @param {PublicKey} oappID - The OApp ID public key.
|
|
6307
|
+
* @param {PublicKey} msgLibProgram - The message library program public key.
|
|
6308
|
+
* @param {number} eid - The endpoint ID.
|
|
6309
|
+
* @param {object} config - The configuration object.
|
|
6310
|
+
* @param {SetConfigType} config.configType - The configuration type.
|
|
6311
|
+
* @param {UlnProgram.types.ExecutorConfig | UlnProgram.types.UlnConfig} config.value - The configuration value.
|
|
6312
|
+
* @param {Commitment} [commitment='confirmed'] - The commitment level.
|
|
6313
|
+
* @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
|
|
6314
|
+
* @throws {Error} If the message library version is unsupported.
|
|
6315
|
+
*/
|
|
6154
6316
|
async setOappConfig(connection, oappDelegate, oappID, msgLibProgram, eid, config, commitment = "confirmed") {
|
|
6155
6317
|
const [msgLib] = new MessageLibPDADeriver(msgLibProgram).messageLib();
|
|
6156
6318
|
const [msgLibInfo] = this.deriver.messageLibraryInfo(msgLib);
|
|
@@ -6188,7 +6350,9 @@ var Endpoint = class {
|
|
|
6188
6350
|
return ix;
|
|
6189
6351
|
}
|
|
6190
6352
|
/// send a simulated transaction to the endpoint to get the fee for sending a message
|
|
6191
|
-
|
|
6353
|
+
/**
|
|
6354
|
+
*
|
|
6355
|
+
* Gets the account metadata for the CPI (Cross-Program Invocation) of the quote instruction.
|
|
6192
6356
|
*
|
|
6193
6357
|
* caculate the fee for sending a message with ULN:
|
|
6194
6358
|
* 1. executorFee: feeForGas + feeForOptionType
|
|
@@ -6199,11 +6363,18 @@ var Endpoint = class {
|
|
|
6199
6363
|
*
|
|
6200
6364
|
* The priceRatioDenominator is 10^20
|
|
6201
6365
|
* totalFee = executorFee + oracleFee * numOracles(requiredOracles + optionalOracles)
|
|
6366
|
+
*
|
|
6367
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
6368
|
+
* @param {PublicKey} payer - The payer public key.
|
|
6369
|
+
* @param {PacketPath} path - The packet path.
|
|
6370
|
+
* @param {MessageLibInterface} msgLibProgram - The message library program.
|
|
6371
|
+
* @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
|
|
6372
|
+
* @throws {Error} If the default send library is not initialized or the message library is blocked.
|
|
6202
6373
|
*/
|
|
6203
6374
|
async getQuoteIXAccountMetaForCPI(connection, payer, path, msgLibProgram) {
|
|
6204
6375
|
const { sender: sender_, dstEid, receiver: receiver_ } = path;
|
|
6205
|
-
const sender = new web314.PublicKey(
|
|
6206
|
-
const receiver = addressToBytes32(receiver_);
|
|
6376
|
+
const sender = new web314.PublicKey(lzUtilities.arrayify(sender_));
|
|
6377
|
+
const receiver = lzV2Utilities.addressToBytes32(receiver_);
|
|
6207
6378
|
const sendLibInfo = await this.getSendLibrary(connection, sender, dstEid);
|
|
6208
6379
|
if (!sendLibInfo?.programId) {
|
|
6209
6380
|
throw new Error("default send library not initialized or blocked message lib");
|
|
@@ -6237,13 +6408,21 @@ var Endpoint = class {
|
|
|
6237
6408
|
].concat(accounts)
|
|
6238
6409
|
);
|
|
6239
6410
|
}
|
|
6240
|
-
|
|
6241
|
-
*
|
|
6411
|
+
/**
|
|
6412
|
+
* Gets the account metadata for the CPI (Cross-Program Invocation) of the send instruction.
|
|
6413
|
+
*
|
|
6414
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
6415
|
+
* @param {PublicKey} payer - The payer public key.
|
|
6416
|
+
* @param {PacketPath} path - The packet path.
|
|
6417
|
+
* @param {MessageLibInterface} msgLibProgram - The message library program.
|
|
6418
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
6419
|
+
* @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
|
|
6420
|
+
* @throws {Error} If the default send library is not initialized or the message library is blocked.
|
|
6242
6421
|
*/
|
|
6243
6422
|
async getSendIXAccountMetaForCPI(connection, payer, path, msgLibProgram, commitmentOrConfig) {
|
|
6244
6423
|
const { sender: sender_, dstEid, receiver: receiver_ } = path;
|
|
6245
|
-
const sender = new web314.PublicKey(
|
|
6246
|
-
const receiver = addressToBytes32(receiver_);
|
|
6424
|
+
const sender = new web314.PublicKey(lzUtilities.arrayify(sender_));
|
|
6425
|
+
const receiver = lzV2Utilities.addressToBytes32(receiver_);
|
|
6247
6426
|
const info = await this.getSendLibrary(connection, sender, dstEid, commitmentOrConfig);
|
|
6248
6427
|
if (!info?.programId) {
|
|
6249
6428
|
throw new Error("default send library not initialized or blocked message lib");
|
|
@@ -6282,8 +6461,18 @@ var Endpoint = class {
|
|
|
6282
6461
|
}
|
|
6283
6462
|
].concat(accounts);
|
|
6284
6463
|
}
|
|
6464
|
+
/**
|
|
6465
|
+
* Skips a message.
|
|
6466
|
+
*
|
|
6467
|
+
* @param {PublicKey} payer - The payer public key.
|
|
6468
|
+
* @param {PublicKey} sender - The sender public key.
|
|
6469
|
+
* @param {PublicKey} receiver - The receiver public key.
|
|
6470
|
+
* @param {number} srcEid - The source endpoint ID.
|
|
6471
|
+
* @param {string} nonce - The nonce.
|
|
6472
|
+
* @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
|
|
6473
|
+
*/
|
|
6285
6474
|
async skip(payer, sender, receiver, srcEid, nonce) {
|
|
6286
|
-
const [nonceAccount] = this.deriver.nonce(receiver, srcEid, addressToBytes32(sender.toBase58()));
|
|
6475
|
+
const [nonceAccount] = this.deriver.nonce(receiver, srcEid, lzV2Utilities.addressToBytes32(sender.toBase58()));
|
|
6287
6476
|
const [payloadHash] = this.deriver.payloadHash(receiver, srcEid, sender.toBytes(), parseInt(nonce));
|
|
6288
6477
|
const [pendingInboundNonce] = this.deriver.pendingNonce(receiver, srcEid, sender.toBytes());
|
|
6289
6478
|
const [oAppRegistry] = web314.PublicKey.findProgramAddressSync(
|
|
@@ -6313,8 +6502,20 @@ var Endpoint = class {
|
|
|
6313
6502
|
);
|
|
6314
6503
|
return Promise.resolve(ix);
|
|
6315
6504
|
}
|
|
6505
|
+
/**
|
|
6506
|
+
* Initializes the verification process.
|
|
6507
|
+
*
|
|
6508
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
6509
|
+
* @param {PublicKey} payer - The payer public key.
|
|
6510
|
+
* @param {PublicKey} sender - The sender public key.
|
|
6511
|
+
* @param {PublicKey} receiver - The receiver public key.
|
|
6512
|
+
* @param {number} srcEid - The source endpoint ID.
|
|
6513
|
+
* @param {string} nonce - The nonce.
|
|
6514
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
6515
|
+
* @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
|
|
6516
|
+
*/
|
|
6316
6517
|
async initVerify(connection, payer, sender, receiver, srcEid, nonce, commitmentOrConfig) {
|
|
6317
|
-
const [nonceAccount] = this.deriver.nonce(receiver, srcEid, addressToBytes32(sender.toBase58()));
|
|
6518
|
+
const [nonceAccount] = this.deriver.nonce(receiver, srcEid, lzV2Utilities.addressToBytes32(sender.toBase58()));
|
|
6318
6519
|
const [payloadHash] = this.deriver.payloadHash(receiver, srcEid, sender.toBytes(), parseInt(nonce));
|
|
6319
6520
|
const payloadHashInfo = await connection.getAccountInfo(payloadHash, commitmentOrConfig);
|
|
6320
6521
|
if (payloadHashInfo) {
|
|
@@ -6337,10 +6538,17 @@ var Endpoint = class {
|
|
|
6337
6538
|
this.program
|
|
6338
6539
|
);
|
|
6339
6540
|
}
|
|
6541
|
+
/**
|
|
6542
|
+
* Gets the account metadata for the CPI (Cross-Program Invocation) of the verify instruction.
|
|
6543
|
+
*
|
|
6544
|
+
* @param {PacketV1Codec} packet - The packet.
|
|
6545
|
+
* @param {PublicKey} receiveLibrary - The receive library public key.
|
|
6546
|
+
* @returns {AccountMeta[]} An array of account metadata.
|
|
6547
|
+
*/
|
|
6340
6548
|
getVerifyIXAccountMetaForCPI(packet, receiveLibrary) {
|
|
6341
6549
|
const receiver = new web314.PublicKey(Buffer.from(packet.receiver().slice(2), "hex"));
|
|
6342
6550
|
const srcEid = packet.srcEid();
|
|
6343
|
-
const sender = addressToBytes32(packet.sender());
|
|
6551
|
+
const sender = lzV2Utilities.addressToBytes32(packet.sender());
|
|
6344
6552
|
const [payloadHash] = this.deriver.payloadHash(receiver, srcEid, sender, parseInt(packet.nonce()));
|
|
6345
6553
|
const [defaultReceiveLibraryConfig] = this.deriver.defaultReceiveLibraryConfig(srcEid);
|
|
6346
6554
|
const [receiveLibraryConfig] = this.deriver.receiveLibraryConfig(receiver, srcEid);
|
|
@@ -6532,6 +6740,13 @@ var Endpoint = class {
|
|
|
6532
6740
|
// } as AccountMeta,
|
|
6533
6741
|
// ].concat(ix.keys)
|
|
6534
6742
|
// }
|
|
6743
|
+
/**
|
|
6744
|
+
* Gets the account metadata for the CPI (Cross-Program Invocation) of the register OApp instruction.
|
|
6745
|
+
*
|
|
6746
|
+
* @param {PublicKey} payer - The payer public key.
|
|
6747
|
+
* @param {PublicKey} oapp - The OApp public key.
|
|
6748
|
+
* @returns {AccountMeta[]} An array of account metadata.
|
|
6749
|
+
*/
|
|
6535
6750
|
getRegisterOappIxAccountMetaForCPI(payer, oapp) {
|
|
6536
6751
|
const [oappRegistry] = this.deriver.oappRegistry(oapp);
|
|
6537
6752
|
const eventAuthority = this.eventAuthorityPDA;
|
|
@@ -6556,6 +6771,15 @@ var Endpoint = class {
|
|
|
6556
6771
|
}
|
|
6557
6772
|
].concat(keys);
|
|
6558
6773
|
}
|
|
6774
|
+
/**
|
|
6775
|
+
* Gets the account metadata for the CPI (Cross-Program Invocation) of the skip instruction.
|
|
6776
|
+
*
|
|
6777
|
+
* @param {PublicKey} receiver - The receiver public key.
|
|
6778
|
+
* @param {Uint8Array} sender - The sender address.
|
|
6779
|
+
* @param {number} srcEid - The source endpoint ID.
|
|
6780
|
+
* @param {number} nonce - The nonce.
|
|
6781
|
+
* @returns {AccountMeta[]} An array of account metadata.
|
|
6782
|
+
*/
|
|
6559
6783
|
getSkipIxAccountMetaForCPI(receiver, sender, srcEid, nonce) {
|
|
6560
6784
|
const [noncePDA] = this.deriver.nonce(receiver, srcEid, sender);
|
|
6561
6785
|
const [pendingNonce] = this.deriver.pendingNonce(receiver, srcEid, sender);
|
|
@@ -6585,6 +6809,15 @@ var Endpoint = class {
|
|
|
6585
6809
|
}
|
|
6586
6810
|
].concat(keys);
|
|
6587
6811
|
}
|
|
6812
|
+
/**
|
|
6813
|
+
* Checks if the given message library program is the default send library.
|
|
6814
|
+
*
|
|
6815
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
6816
|
+
* @param {PublicKey} messageLibProgram - The message library program public key.
|
|
6817
|
+
* @param {number} dstEid - The destination endpoint ID.
|
|
6818
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
6819
|
+
* @returns {Promise<boolean>} A promise that resolves to true if the message library program is the default send library, false otherwise.
|
|
6820
|
+
*/
|
|
6588
6821
|
async isDefaultSendLibrary(connection, messageLibProgram, dstEid, commitmentOrConfig) {
|
|
6589
6822
|
const [msgLib] = new MessageLibPDADeriver(messageLibProgram).messageLib();
|
|
6590
6823
|
const info = await this.getDefaultSendLibrary(connection, dstEid, commitmentOrConfig);
|
|
@@ -6593,6 +6826,15 @@ var Endpoint = class {
|
|
|
6593
6826
|
}
|
|
6594
6827
|
return false;
|
|
6595
6828
|
}
|
|
6829
|
+
/**
|
|
6830
|
+
* Checks if the given message library program is the default receive library.
|
|
6831
|
+
*
|
|
6832
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
6833
|
+
* @param {PublicKey} messageLibProgram - The message library program public key.
|
|
6834
|
+
* @param {number} srcEid - The source endpoint ID.
|
|
6835
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
6836
|
+
* @returns {Promise<boolean>} A promise that resolves to true if the message library program is the default receive library, false otherwise.
|
|
6837
|
+
*/
|
|
6596
6838
|
async isDefaultReceiveLibrary(connection, messageLibProgram, srcEid, commitmentOrConfig) {
|
|
6597
6839
|
const [msgLib] = new MessageLibPDADeriver(messageLibProgram).messageLib();
|
|
6598
6840
|
const info = await this.getDefaultReceiveLibrary(connection, srcEid, commitmentOrConfig);
|
|
@@ -6602,6 +6844,13 @@ var Endpoint = class {
|
|
|
6602
6844
|
return false;
|
|
6603
6845
|
}
|
|
6604
6846
|
// all of below functions are retrieving accounts state
|
|
6847
|
+
/**
|
|
6848
|
+
* Gets the endpoint settings.
|
|
6849
|
+
*
|
|
6850
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
6851
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
6852
|
+
* @returns {Promise<EndpointSettings | null>} A promise that resolves to the endpoint settings or null if not found.
|
|
6853
|
+
*/
|
|
6605
6854
|
async getSetting(connection, commitmentOrConfig) {
|
|
6606
6855
|
const [setting] = this.deriver.setting();
|
|
6607
6856
|
try {
|
|
@@ -6611,8 +6860,12 @@ var Endpoint = class {
|
|
|
6611
6860
|
}
|
|
6612
6861
|
}
|
|
6613
6862
|
/**
|
|
6863
|
+
* Gets the message library information.
|
|
6614
6864
|
*
|
|
6615
|
-
* @param
|
|
6865
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
6866
|
+
* @param {PublicKey} messageLibProgram - The message library program public key, It is a PDA of the message library program
|
|
6867
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
6868
|
+
* @returns {Promise<MessageLibInfo | null>} A promise that resolves to the message library information or null if not found.
|
|
6616
6869
|
*/
|
|
6617
6870
|
async getMessageLibInfo(connection, messageLibProgram, commitmentOrConfig) {
|
|
6618
6871
|
const [msgLib] = new MessageLibPDADeriver(messageLibProgram).messageLib();
|
|
@@ -6623,6 +6876,14 @@ var Endpoint = class {
|
|
|
6623
6876
|
return null;
|
|
6624
6877
|
}
|
|
6625
6878
|
}
|
|
6879
|
+
/**
|
|
6880
|
+
* Gets the default receive library.
|
|
6881
|
+
*
|
|
6882
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
6883
|
+
* @param {number} srcEid - The source endpoint ID.
|
|
6884
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
6885
|
+
* @returns {Promise<{ msgLib: PublicKey; owner?: PublicKey } | null>} A promise that resolves to the default receive library or null if not found.
|
|
6886
|
+
*/
|
|
6626
6887
|
async getDefaultReceiveLibrary(connection, srcEid, commitmentOrConfig) {
|
|
6627
6888
|
const [defaultReceiveLibConfig] = this.deriver.defaultReceiveLibraryConfig(srcEid);
|
|
6628
6889
|
try {
|
|
@@ -6645,6 +6906,14 @@ var Endpoint = class {
|
|
|
6645
6906
|
return null;
|
|
6646
6907
|
}
|
|
6647
6908
|
}
|
|
6909
|
+
/**
|
|
6910
|
+
* Gets the default send library.
|
|
6911
|
+
*
|
|
6912
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
6913
|
+
* @param {number} dstEid - The destination endpoint ID.
|
|
6914
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
6915
|
+
* @returns {Promise<{ msgLib: PublicKey; owner?: PublicKey } | null>} A promise that resolves to the default send library or null if not found.
|
|
6916
|
+
*/
|
|
6648
6917
|
async getDefaultSendLibrary(connection, dstEid, commitmentOrConfig) {
|
|
6649
6918
|
const [defaultSendLibConfig] = this.deriver.defaultSendLibraryConfig(dstEid);
|
|
6650
6919
|
try {
|
|
@@ -6668,8 +6937,13 @@ var Endpoint = class {
|
|
|
6668
6937
|
}
|
|
6669
6938
|
}
|
|
6670
6939
|
/**
|
|
6671
|
-
*
|
|
6672
|
-
*
|
|
6940
|
+
* Gets the configured send library for the app.
|
|
6941
|
+
*
|
|
6942
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
6943
|
+
* @param {PublicKey} oappPda - The OApp PDA.
|
|
6944
|
+
* @param {number} dstEid - The destination endpoint ID.
|
|
6945
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig='confirmed'] - The commitment level or account info configuration.
|
|
6946
|
+
* @returns {Promise<{ msgLib: PublicKey; programId?: PublicKey; isDefault: boolean } | null>} A promise that resolves to the configured send library or null if not found.
|
|
6673
6947
|
*/
|
|
6674
6948
|
async getSendLibrary(connection, oappPda, dstEid, commitmentOrConfig = "confirmed") {
|
|
6675
6949
|
const [sendLibConfig] = this.deriver.sendLibraryConfig(oappPda, dstEid);
|
|
@@ -6702,7 +6976,13 @@ var Endpoint = class {
|
|
|
6702
6976
|
}
|
|
6703
6977
|
}
|
|
6704
6978
|
/**
|
|
6705
|
-
*
|
|
6979
|
+
* Gets the configured receive library for the app.
|
|
6980
|
+
*
|
|
6981
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
6982
|
+
* @param {PublicKey} oappPda - The OApp PDA.
|
|
6983
|
+
* @param {number} srcEid - The source endpoint ID.
|
|
6984
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
6985
|
+
* @returns {Promise<{ msgLib: PublicKey; programId?: PublicKey; isDefault: boolean; timeout: { msgLib: PublicKey; expiry: bigint } | null } | null>} A promise that resolves to the configured receive library or null if not found.
|
|
6706
6986
|
*/
|
|
6707
6987
|
async getReceiveLibrary(connection, oappPda, srcEid, commitmentOrConfig) {
|
|
6708
6988
|
const [receiveLibConfig] = this.deriver.receiveLibraryConfig(oappPda, srcEid);
|
|
@@ -6738,7 +7018,7 @@ var Endpoint = class {
|
|
|
6738
7018
|
};
|
|
6739
7019
|
}
|
|
6740
7020
|
const messageLibInfo = await connection.getAccountInfo(info.messageLib, commitmentOrConfig);
|
|
6741
|
-
|
|
7021
|
+
invariant3__default.default(messageLibInfo, "messageLibInfo should not be null");
|
|
6742
7022
|
const { timeout } = info;
|
|
6743
7023
|
if (timeout) {
|
|
6744
7024
|
return {
|
|
@@ -6751,6 +7031,18 @@ var Endpoint = class {
|
|
|
6751
7031
|
return { programId: messageLibInfo.owner, msgLib: info.messageLib, isDefault: false, timeout: null };
|
|
6752
7032
|
}
|
|
6753
7033
|
// rename to a more generic name
|
|
7034
|
+
/**
|
|
7035
|
+
* Gets the inbound payload hash.
|
|
7036
|
+
*
|
|
7037
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
7038
|
+
* @param {PublicKey} receiver - The receiver public key.
|
|
7039
|
+
* @param {number} srcEid - The source endpoint ID.
|
|
7040
|
+
* @param {Uint8Array} sender - The sender address.
|
|
7041
|
+
* @param {number} nonce - The nonce.
|
|
7042
|
+
* @param {Uint8Array} _payloadHash - The payload hash.
|
|
7043
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
7044
|
+
* @returns {Promise<PayloadHash | null>} A promise that resolves to the payload hash or null if not found.
|
|
7045
|
+
*/
|
|
6754
7046
|
async getInboundPayloadHash(connection, receiver, srcEid, sender, nonce, _payloadHash, commitmentOrConfig) {
|
|
6755
7047
|
const [payloadHashPDA] = this.deriver.payloadHash(receiver, srcEid, sender, nonce);
|
|
6756
7048
|
const accountInfo = await connection.getAccountInfo(payloadHashPDA, commitmentOrConfig);
|
|
@@ -6759,8 +7051,17 @@ var Endpoint = class {
|
|
|
6759
7051
|
}
|
|
6760
7052
|
return PayloadHash.fromAccountInfo(accountInfo, 0)[0];
|
|
6761
7053
|
}
|
|
7054
|
+
/**
|
|
7055
|
+
* Gets the composed message state.
|
|
7056
|
+
*
|
|
7057
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
7058
|
+
* @param {PublicKey} from - The sender public key.
|
|
7059
|
+
* @param {types.SendComposeParams} params - The send compose parameters.
|
|
7060
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
7061
|
+
* @returns {Promise<ComposeMessageState | null>} A promise that resolves to the composed message state or null if not found.
|
|
7062
|
+
*/
|
|
6762
7063
|
async getComposedMessageState(connection, from, params, commitmentOrConfig) {
|
|
6763
|
-
const message =
|
|
7064
|
+
const message = lzFoundation.keccak_256(params.message);
|
|
6764
7065
|
const [composedMessagePDA] = this.deriver.composedMessage(
|
|
6765
7066
|
from,
|
|
6766
7067
|
Uint8Array.from(params.guid),
|
|
@@ -6774,6 +7075,16 @@ var Endpoint = class {
|
|
|
6774
7075
|
}
|
|
6775
7076
|
return ComposeMessageState.fromAccountInfo(accountInfo, 0)[0];
|
|
6776
7077
|
}
|
|
7078
|
+
/**
|
|
7079
|
+
* Gets the nonce.
|
|
7080
|
+
*
|
|
7081
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
7082
|
+
* @param {PublicKey} oappIDPDA - The OApp ID PDA.
|
|
7083
|
+
* @param {number} remoteEid - The remote endpoint ID.
|
|
7084
|
+
* @param {Uint8Array} remoteOappAddr - The remote OApp address.
|
|
7085
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
7086
|
+
* @returns {Promise<accounts.Nonce | null>} A promise that resolves to the nonce or null if not found.
|
|
7087
|
+
*/
|
|
6777
7088
|
async getNonce(connection, oappIDPDA2, remoteEid, remoteOappAddr, commitmentOrConfig) {
|
|
6778
7089
|
const [nonce] = this.deriver.nonce(oappIDPDA2, remoteEid, remoteOappAddr);
|
|
6779
7090
|
try {
|
|
@@ -6782,6 +7093,16 @@ var Endpoint = class {
|
|
|
6782
7093
|
return null;
|
|
6783
7094
|
}
|
|
6784
7095
|
}
|
|
7096
|
+
/**
|
|
7097
|
+
* Gets the pending inbound nonce.
|
|
7098
|
+
*
|
|
7099
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
7100
|
+
* @param {PublicKey} oappIDPDA - The OApp ID PDA.
|
|
7101
|
+
* @param {number} remoteEid - The remote endpoint ID.
|
|
7102
|
+
* @param {Uint8Array} remoteOappAddr - The remote OApp address.
|
|
7103
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
7104
|
+
* @returns {Promise<accounts.PendingInboundNonce | null>} A promise that resolves to the pending inbound nonce or null if not found.
|
|
7105
|
+
*/
|
|
6785
7106
|
async getPendingInboundNonce(connection, oappIDPDA2, remoteEid, remoteOappAddr, commitmentOrConfig) {
|
|
6786
7107
|
const [nonce] = this.deriver.pendingNonce(oappIDPDA2, remoteEid, remoteOappAddr);
|
|
6787
7108
|
try {
|
|
@@ -6790,12 +7111,30 @@ var Endpoint = class {
|
|
|
6790
7111
|
return null;
|
|
6791
7112
|
}
|
|
6792
7113
|
}
|
|
7114
|
+
/**
|
|
7115
|
+
* Gets the message library version.
|
|
7116
|
+
*
|
|
7117
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
7118
|
+
* @param {PublicKey} payer - The payer public key.
|
|
7119
|
+
* @param {PublicKey} messageLibProgram - The message library program public key.
|
|
7120
|
+
* @param {Commitment} [commitment='confirmed'] - The commitment level.
|
|
7121
|
+
* @returns {Promise<Version | null>} A promise that resolves to the version or null if not found.
|
|
7122
|
+
*/
|
|
6793
7123
|
async getMessageLibVersion(connection, payer, messageLibProgram, commitment = "confirmed") {
|
|
6794
7124
|
const ix = simple_message_lib_exports.instructions.createVersionInstruction(messageLibProgram);
|
|
6795
7125
|
const simulateResp = await simulateTransaction(connection, [ix], messageLibProgram, payer, commitment);
|
|
6796
7126
|
const version = simple_message_lib_exports.types.versionBeet.read(simulateResp, 0);
|
|
6797
7127
|
return version;
|
|
6798
7128
|
}
|
|
7129
|
+
/**
|
|
7130
|
+
* Transfers the admin role to a new admin.
|
|
7131
|
+
*
|
|
7132
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
7133
|
+
* @param {PublicKey} admin - The current admin public key.
|
|
7134
|
+
* @param {PublicKey} newAdmin - The new admin public key.
|
|
7135
|
+
* @param {Commitment} [commitment='confirmed'] - The commitment level.
|
|
7136
|
+
* @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
|
|
7137
|
+
*/
|
|
6799
7138
|
async transferAdmin(connection, admin, newAdmin, commitment = "confirmed") {
|
|
6800
7139
|
const [settingPDA] = this.deriver.setting();
|
|
6801
7140
|
const endpointSettings = await EndpointSettings.fromAccountAddress(connection, settingPDA, commitment);
|
|
@@ -8742,10 +9081,27 @@ var PROGRAM_ID2 = new web314.PublicKey(PROGRAM_ADDRESS2);
|
|
|
8742
9081
|
|
|
8743
9082
|
// src/simple-message-lib.ts
|
|
8744
9083
|
var SimpleMessageLib = class {
|
|
9084
|
+
/**
|
|
9085
|
+
* Creates an instance of the SimpleMessageLib class.
|
|
9086
|
+
*
|
|
9087
|
+
* @param {PublicKey} program - The program public key.
|
|
9088
|
+
*/
|
|
8745
9089
|
constructor(program) {
|
|
8746
9090
|
this.program = program;
|
|
8747
9091
|
this.deriver = new MessageLibPDADeriver(program);
|
|
8748
9092
|
}
|
|
9093
|
+
/**
|
|
9094
|
+
* Initializes the SimpleMessageLib.
|
|
9095
|
+
*
|
|
9096
|
+
* @param {PublicKey} endpointProgram - The endpoint program public key.
|
|
9097
|
+
* @param {PublicKey} payer - The payer public key.
|
|
9098
|
+
* @param {PublicKey} admin - The admin public key.
|
|
9099
|
+
* @param {number} eid - The endpoint ID.
|
|
9100
|
+
* @param {number} nativeFee - The native fee.
|
|
9101
|
+
* @param {number} [lzTokenFee=0] - The LayerZero token fee.
|
|
9102
|
+
*
|
|
9103
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
9104
|
+
*/
|
|
8749
9105
|
initSimpleMessageLib(endpointProgram, payer, admin, eid, nativeFee, lzTokenFee = 0) {
|
|
8750
9106
|
const [messageLibPda] = this.deriver.messageLib();
|
|
8751
9107
|
const [endpointAuth] = new EndpointPDADeriver(endpointProgram).messageLibraryInfo(messageLibPda);
|
|
@@ -8767,6 +9123,14 @@ var SimpleMessageLib = class {
|
|
|
8767
9123
|
this.program
|
|
8768
9124
|
);
|
|
8769
9125
|
}
|
|
9126
|
+
/**
|
|
9127
|
+
* Sets the whitelist caller.
|
|
9128
|
+
*
|
|
9129
|
+
* @param {PublicKey} admin - The admin public key.
|
|
9130
|
+
* @param {PublicKey} newCaller - The new caller public key.
|
|
9131
|
+
*
|
|
9132
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
9133
|
+
*/
|
|
8770
9134
|
setWhitelistCaller(admin, newCaller) {
|
|
8771
9135
|
const [messageLibPDA] = this.deriver.messageLib();
|
|
8772
9136
|
return createSetWlCallerInstruction(
|
|
@@ -8782,6 +9146,15 @@ var SimpleMessageLib = class {
|
|
|
8782
9146
|
this.program
|
|
8783
9147
|
);
|
|
8784
9148
|
}
|
|
9149
|
+
/**
|
|
9150
|
+
* Checks if a caller is whitelisted.
|
|
9151
|
+
*
|
|
9152
|
+
* @param {Connection} connection - The connection object.
|
|
9153
|
+
* @param {PublicKey} caller - The caller public key.
|
|
9154
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment or config.
|
|
9155
|
+
*
|
|
9156
|
+
* @returns {Promise<boolean>} A promise that resolves to true if the caller is whitelisted, false otherwise.
|
|
9157
|
+
*/
|
|
8785
9158
|
async isWhiteListed(connection, caller, commitmentOrConfig) {
|
|
8786
9159
|
try {
|
|
8787
9160
|
const exceptedCaller = await this.getWhiteListCaller(connection, commitmentOrConfig);
|
|
@@ -8790,6 +9163,14 @@ var SimpleMessageLib = class {
|
|
|
8790
9163
|
return false;
|
|
8791
9164
|
}
|
|
8792
9165
|
}
|
|
9166
|
+
/**
|
|
9167
|
+
* Gets the whitelisted caller.
|
|
9168
|
+
*
|
|
9169
|
+
* @param {Connection} connection - The connection object.
|
|
9170
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment or config.
|
|
9171
|
+
*
|
|
9172
|
+
* @returns {Promise<PublicKey>} A promise that resolves to the whitelisted caller public key.
|
|
9173
|
+
*/
|
|
8793
9174
|
async getWhiteListCaller(connection, commitmentOrConfig) {
|
|
8794
9175
|
const [messageLibPDA] = this.deriver.messageLib();
|
|
8795
9176
|
const messageLibInfo = await MessageLib.fromAccountAddress(
|
|
@@ -8799,8 +9180,18 @@ var SimpleMessageLib = class {
|
|
|
8799
9180
|
);
|
|
8800
9181
|
return messageLibInfo.wlCaller;
|
|
8801
9182
|
}
|
|
9183
|
+
/**
|
|
9184
|
+
* Validates a packet.
|
|
9185
|
+
*
|
|
9186
|
+
* @param {Connection} _connection - The connection object.
|
|
9187
|
+
* @param {PublicKey} endpointProgram - The endpoint program public key.
|
|
9188
|
+
* @param {PublicKey} payer - The payer public key.
|
|
9189
|
+
* @param {Uint8Array} encodedPacket - The encoded packet.
|
|
9190
|
+
*
|
|
9191
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
9192
|
+
*/
|
|
8802
9193
|
validatePacket(_connection, endpointProgram, payer, encodedPacket) {
|
|
8803
|
-
const packet = PacketV1Codec.fromBytes(encodedPacket);
|
|
9194
|
+
const packet = lzV2Utilities.PacketV1Codec.fromBytes(encodedPacket);
|
|
8804
9195
|
const [receiveLibrary] = this.deriver.messageLib();
|
|
8805
9196
|
const endpoint = new endpoint_exports.Endpoint(endpointProgram);
|
|
8806
9197
|
return createValidatePacketInstruction(
|
|
@@ -8815,8 +9206,14 @@ var SimpleMessageLib = class {
|
|
|
8815
9206
|
this.program
|
|
8816
9207
|
);
|
|
8817
9208
|
}
|
|
8818
|
-
|
|
8819
|
-
*
|
|
9209
|
+
/**
|
|
9210
|
+
* Gets the account meta of the send instruction for CPI (Cross-Program Invocation).
|
|
9211
|
+
*
|
|
9212
|
+
* @param {Connection} _connection - The connection object.
|
|
9213
|
+
* @param {PublicKey} payer - The payer public key.
|
|
9214
|
+
* @param {PacketPath} _path - The packet path.
|
|
9215
|
+
*
|
|
9216
|
+
* @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account meta.
|
|
8820
9217
|
*/
|
|
8821
9218
|
async getSendIXAccountMetaForCPI(_connection, payer, _path) {
|
|
8822
9219
|
const [msgLib] = this.deriver.messageLib();
|
|
@@ -8836,6 +9233,16 @@ var SimpleMessageLib = class {
|
|
|
8836
9233
|
});
|
|
8837
9234
|
return Promise.resolve(cpiAccounts.slice(1));
|
|
8838
9235
|
}
|
|
9236
|
+
/**
|
|
9237
|
+
* Gets the account meta of the quote instruction for CPI (Cross-Program Invocation).
|
|
9238
|
+
*
|
|
9239
|
+
* @param {Connection} _connection - The connection object.
|
|
9240
|
+
* @param {PublicKey} _payer - The payer public key.
|
|
9241
|
+
* @param {PacketPath} _path - The packet path.
|
|
9242
|
+
* @param {Commitment} [commitment] - The commitment.
|
|
9243
|
+
*
|
|
9244
|
+
* @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account meta.
|
|
9245
|
+
*/
|
|
8839
9246
|
async getQuoteIXAccountMetaForCPI(_connection, _payer, _path, _commitment) {
|
|
8840
9247
|
const [msgLib] = this.deriver.messageLib();
|
|
8841
9248
|
const keys = createQuoteInstructionAccounts2(
|
|
@@ -8848,8 +9255,14 @@ var SimpleMessageLib = class {
|
|
|
8848
9255
|
);
|
|
8849
9256
|
return Promise.resolve(keys.slice(1));
|
|
8850
9257
|
}
|
|
8851
|
-
|
|
8852
|
-
*
|
|
9258
|
+
/**
|
|
9259
|
+
* Gets the account meta of the init config instruction for CPI (Cross-Program Invocation).
|
|
9260
|
+
*
|
|
9261
|
+
* @param {PublicKey} payer - The payer public key.
|
|
9262
|
+
* @param {PublicKey} oappID - The oapp ID public key.
|
|
9263
|
+
* @param {number} eid - The endpoint ID.
|
|
9264
|
+
*
|
|
9265
|
+
* @returns {AccountMeta[]} An array of account meta.
|
|
8853
9266
|
*/
|
|
8854
9267
|
getInitConfigIXAccountMetaForCPI(payer, oappID, eid) {
|
|
8855
9268
|
const [sendConfig] = this.deriver.sendConfig(eid, oappID);
|
|
@@ -8873,6 +9286,15 @@ var SimpleMessageLib = class {
|
|
|
8873
9286
|
});
|
|
8874
9287
|
return keys.slice(1);
|
|
8875
9288
|
}
|
|
9289
|
+
/**
|
|
9290
|
+
* Gets the account meta of the set config instruction for CPI (Cross-Program Invocation).
|
|
9291
|
+
*
|
|
9292
|
+
* @param {PublicKey} endpointProgram - The endpoint program public key.
|
|
9293
|
+
* @param {PublicKey} oappID - The oapp ID public key.
|
|
9294
|
+
* @param {number} eid - The endpoint ID.
|
|
9295
|
+
*
|
|
9296
|
+
* @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account meta.
|
|
9297
|
+
*/
|
|
8876
9298
|
async getSetConfigIXAccountMetaForCPI(endpointProgram, oappID, eid) {
|
|
8877
9299
|
const [sendConfig] = this.deriver.sendConfig(eid, oappID);
|
|
8878
9300
|
const [receiveConfig] = this.deriver.receiveConfig(eid, oappID);
|
|
@@ -10750,9 +11172,21 @@ var SolanaSignerExt = class _SolanaSignerExt {
|
|
|
10750
11172
|
constructor(signers) {
|
|
10751
11173
|
this.signers = signers;
|
|
10752
11174
|
}
|
|
11175
|
+
/**
|
|
11176
|
+
* Creates an instance of the SolanaSignerExt class.
|
|
11177
|
+
*
|
|
11178
|
+
* @param {HashSigner[]} signers - The signers.
|
|
11179
|
+
* @returns {SolanaSignerExt} The SolanaSignerExt instance.
|
|
11180
|
+
*/
|
|
10753
11181
|
static from(signers) {
|
|
10754
11182
|
return new _SolanaSignerExt(signers);
|
|
10755
11183
|
}
|
|
11184
|
+
/**
|
|
11185
|
+
* Signs a message.
|
|
11186
|
+
*
|
|
11187
|
+
* @param {Buffer} message - The message to sign.
|
|
11188
|
+
* @returns {Promise<{ signature: Uint8Array; recoveryId: number }[]>} A promise that resolves to an array of signature objects.
|
|
11189
|
+
*/
|
|
10756
11190
|
async sign(message) {
|
|
10757
11191
|
return Promise.all(
|
|
10758
11192
|
this.signers.map(async (s) => {
|
|
@@ -10763,12 +11197,27 @@ var SolanaSignerExt = class _SolanaSignerExt {
|
|
|
10763
11197
|
}
|
|
10764
11198
|
};
|
|
10765
11199
|
var DVN = class {
|
|
11200
|
+
/**
|
|
11201
|
+
* Creates an instance of the DVN class.
|
|
11202
|
+
*
|
|
11203
|
+
* @param {PublicKey} programId - The program ID.
|
|
11204
|
+
* @param {EndpointId} [endpointId=EndpointId.SOLANA_V2_SANDBOX] - The endpoint ID.
|
|
11205
|
+
*/
|
|
10766
11206
|
constructor(programId, endpointId = lzDefinitions.EndpointId.SOLANA_V2_SANDBOX) {
|
|
10767
11207
|
this.programId = programId;
|
|
10768
11208
|
this.dvnDeriver = new DVNDeriver(programId);
|
|
10769
11209
|
this.vid = endpointId % 3e4;
|
|
10770
11210
|
this.eventAuthority = new EventPDADeriver(programId).eventAuthority()[0];
|
|
10771
11211
|
}
|
|
11212
|
+
/**
|
|
11213
|
+
* Initializes the DVN.
|
|
11214
|
+
*
|
|
11215
|
+
* @param {Connection} connection - The connection.
|
|
11216
|
+
* @param {PublicKey} payer - The payer.
|
|
11217
|
+
* @param {InitDvnParams} params - The initialization parameters.
|
|
11218
|
+
* @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
|
|
11219
|
+
* @throws {Error} If the DVN is already initialized.
|
|
11220
|
+
*/
|
|
10772
11221
|
async initDVN(connection, payer, params) {
|
|
10773
11222
|
const [config] = this.dvnDeriver.config();
|
|
10774
11223
|
const info = await connection.getAccountInfo(config);
|
|
@@ -10786,6 +11235,14 @@ var DVN = class {
|
|
|
10786
11235
|
this.programId
|
|
10787
11236
|
);
|
|
10788
11237
|
}
|
|
11238
|
+
/**
|
|
11239
|
+
* Gets the digest for a transaction.
|
|
11240
|
+
*
|
|
11241
|
+
* @param {number} vid - The validator ID.
|
|
11242
|
+
* @param {TransactionInstruction} instruction - The transaction instruction.
|
|
11243
|
+
* @param {number} expiration - The expiration time.
|
|
11244
|
+
* @returns {types.ExecuteTransactionDigest} The transaction digest.
|
|
11245
|
+
*/
|
|
10789
11246
|
getDigest(vid, instruction, expiration) {
|
|
10790
11247
|
return {
|
|
10791
11248
|
vid,
|
|
@@ -10801,15 +11258,39 @@ var DVN = class {
|
|
|
10801
11258
|
expiration
|
|
10802
11259
|
};
|
|
10803
11260
|
}
|
|
11261
|
+
/**
|
|
11262
|
+
* Gets the execute hash for a given hash bytes.
|
|
11263
|
+
*
|
|
11264
|
+
* @param {Buffer} hashBytes - The hash bytes.
|
|
11265
|
+
* @returns {PublicKey} The execute hash.
|
|
11266
|
+
*/
|
|
10804
11267
|
getExecuteHash(hashBytes) {
|
|
10805
11268
|
const [executeHash] = this.dvnDeriver.executeHash(hashBytes);
|
|
10806
11269
|
return executeHash;
|
|
10807
11270
|
}
|
|
11271
|
+
/**
|
|
11272
|
+
* Gets the hash bytes for a given digest.
|
|
11273
|
+
*
|
|
11274
|
+
* @param {types.ExecuteTransactionDigest} digest - The transaction digest.
|
|
11275
|
+
* @returns {Buffer} The hash bytes.
|
|
11276
|
+
*/
|
|
10808
11277
|
getHashBytes(digest) {
|
|
10809
11278
|
const [digestBytes] = executeTransactionDigestBeet.serialize(digest);
|
|
10810
|
-
const hash =
|
|
10811
|
-
return Buffer.from(hash
|
|
11279
|
+
const hash = lzFoundation.keccak_256(digestBytes);
|
|
11280
|
+
return Buffer.from(hash);
|
|
10812
11281
|
}
|
|
11282
|
+
/**
|
|
11283
|
+
* Invokes a transaction.
|
|
11284
|
+
*
|
|
11285
|
+
* @param {Connection} connection - The connection.
|
|
11286
|
+
* @param {number} vid - The validator ID.
|
|
11287
|
+
* @param {PublicKey} payer - The payer.
|
|
11288
|
+
* @param {TransactionInstruction} instruction - The transaction instruction.
|
|
11289
|
+
* @param {number} expiration - The expiration time.
|
|
11290
|
+
* @param {SignFunc} sign - The sign function.
|
|
11291
|
+
* @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
|
|
11292
|
+
* @throws {Error} If the DVN is not initialized.
|
|
11293
|
+
*/
|
|
10813
11294
|
async invoke(connection, vid, payer, instruction, expiration, sign) {
|
|
10814
11295
|
const configState = await this.getConfigState(connection, "confirmed");
|
|
10815
11296
|
if (!configState) {
|
|
@@ -10851,6 +11332,12 @@ var DVN = class {
|
|
|
10851
11332
|
this.programId
|
|
10852
11333
|
);
|
|
10853
11334
|
}
|
|
11335
|
+
/**
|
|
11336
|
+
* Creates a transaction instruction to set the quorum.
|
|
11337
|
+
*
|
|
11338
|
+
* @param {number} quorum - The quorum.
|
|
11339
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
11340
|
+
*/
|
|
10854
11341
|
createSetQuorumInstruction(quorum) {
|
|
10855
11342
|
const params = {
|
|
10856
11343
|
fields: [quorum],
|
|
@@ -10865,6 +11352,12 @@ var DVN = class {
|
|
|
10865
11352
|
data: buffer
|
|
10866
11353
|
});
|
|
10867
11354
|
}
|
|
11355
|
+
/**
|
|
11356
|
+
* Creates a transaction instruction to set the admins.
|
|
11357
|
+
*
|
|
11358
|
+
* @param {PublicKey[]} admins - The admin public keys.
|
|
11359
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
11360
|
+
*/
|
|
10868
11361
|
createSetAdminsInstruction(admins) {
|
|
10869
11362
|
const params = {
|
|
10870
11363
|
fields: [admins],
|
|
@@ -10879,6 +11372,12 @@ var DVN = class {
|
|
|
10879
11372
|
data: buffer
|
|
10880
11373
|
});
|
|
10881
11374
|
}
|
|
11375
|
+
/**
|
|
11376
|
+
* Creates a transaction instruction to set the signers.
|
|
11377
|
+
*
|
|
11378
|
+
* @param {Uint8Array[]} signers - The signer public keys.
|
|
11379
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
11380
|
+
*/
|
|
10882
11381
|
createSetSignersInstruction(signers) {
|
|
10883
11382
|
const params = {
|
|
10884
11383
|
fields: [signers.map((s) => Array.from(s))],
|
|
@@ -10893,6 +11392,12 @@ var DVN = class {
|
|
|
10893
11392
|
data: buffer
|
|
10894
11393
|
});
|
|
10895
11394
|
}
|
|
11395
|
+
/**
|
|
11396
|
+
* Creates a transaction instruction to set the allowlist.
|
|
11397
|
+
*
|
|
11398
|
+
* @param {PublicKey[]} allowlist - The allowlist public keys.
|
|
11399
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
11400
|
+
*/
|
|
10896
11401
|
createSetAllowlistInstruction(allowlist) {
|
|
10897
11402
|
const params = {
|
|
10898
11403
|
fields: [allowlist],
|
|
@@ -10907,6 +11412,12 @@ var DVN = class {
|
|
|
10907
11412
|
data: buffer
|
|
10908
11413
|
});
|
|
10909
11414
|
}
|
|
11415
|
+
/**
|
|
11416
|
+
* Creates a transaction instruction to set the denylist.
|
|
11417
|
+
*
|
|
11418
|
+
* @param {PublicKey[]} denylist - The denylist public keys.
|
|
11419
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
11420
|
+
*/
|
|
10910
11421
|
createSetDenylistInstruction(denylist) {
|
|
10911
11422
|
const params = {
|
|
10912
11423
|
fields: [denylist],
|
|
@@ -10921,6 +11432,12 @@ var DVN = class {
|
|
|
10921
11432
|
data: buffer
|
|
10922
11433
|
});
|
|
10923
11434
|
}
|
|
11435
|
+
/**
|
|
11436
|
+
* Creates a transaction instruction to set the pause state.
|
|
11437
|
+
*
|
|
11438
|
+
* @param {boolean} pause - The pause state.
|
|
11439
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
11440
|
+
*/
|
|
10924
11441
|
createSetPauseInstruction(pause) {
|
|
10925
11442
|
const params = {
|
|
10926
11443
|
fields: [pause],
|
|
@@ -10935,6 +11452,13 @@ var DVN = class {
|
|
|
10935
11452
|
data: buffer
|
|
10936
11453
|
});
|
|
10937
11454
|
}
|
|
11455
|
+
/**
|
|
11456
|
+
* Creates a transaction instruction to set the default multiplier basis points.
|
|
11457
|
+
*
|
|
11458
|
+
* @param {PublicKey} admin - The admin public key.
|
|
11459
|
+
* @param {number} defaultMultiplierBps - The default multiplier basis points.
|
|
11460
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
11461
|
+
*/
|
|
10938
11462
|
createSetDefaultMultiplierBpsInstruction(admin, defaultMultiplierBps) {
|
|
10939
11463
|
const [configAccount] = this.dvnDeriver.config();
|
|
10940
11464
|
return createSetConfigInstruction3(
|
|
@@ -10955,6 +11479,13 @@ var DVN = class {
|
|
|
10955
11479
|
this.programId
|
|
10956
11480
|
);
|
|
10957
11481
|
}
|
|
11482
|
+
/**
|
|
11483
|
+
* Creates a transaction instruction to change the admins.
|
|
11484
|
+
*
|
|
11485
|
+
* @param {PublicKey} admin - The admin public key.
|
|
11486
|
+
* @param {PublicKey[]} admins - The new admin public keys.
|
|
11487
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
11488
|
+
*/
|
|
10958
11489
|
createChangeAdminsInstruction(admin, admins) {
|
|
10959
11490
|
const [configAccount] = this.dvnDeriver.config();
|
|
10960
11491
|
return createSetConfigInstruction3(
|
|
@@ -10975,6 +11506,13 @@ var DVN = class {
|
|
|
10975
11506
|
this.programId
|
|
10976
11507
|
);
|
|
10977
11508
|
}
|
|
11509
|
+
/**
|
|
11510
|
+
* Creates a transaction instruction to set the destination configurations.
|
|
11511
|
+
*
|
|
11512
|
+
* @param {PublicKey} admin - The admin public key.
|
|
11513
|
+
* @param {types.DstConfig[]} dstConfigs - The destination configurations.
|
|
11514
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
11515
|
+
*/
|
|
10978
11516
|
createSetDstConfigInstruction(admin, dstConfigs) {
|
|
10979
11517
|
const [configAccount] = this.dvnDeriver.config();
|
|
10980
11518
|
return createSetConfigInstruction3(
|
|
@@ -10995,6 +11533,13 @@ var DVN = class {
|
|
|
10995
11533
|
this.programId
|
|
10996
11534
|
);
|
|
10997
11535
|
}
|
|
11536
|
+
/**
|
|
11537
|
+
* Creates a transaction instruction to remove the destination configurations.
|
|
11538
|
+
*
|
|
11539
|
+
* @param {PublicKey} admin - The admin public key.
|
|
11540
|
+
* @param {number[]} removeEids - The endpoint IDs to remove.
|
|
11541
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
11542
|
+
*/
|
|
10998
11543
|
createRemoveDstConfigInstruction(admin, removeEids) {
|
|
10999
11544
|
const [configAccount] = this.dvnDeriver.config();
|
|
11000
11545
|
return createSetConfigInstruction3(
|
|
@@ -11015,6 +11560,12 @@ var DVN = class {
|
|
|
11015
11560
|
this.programId
|
|
11016
11561
|
);
|
|
11017
11562
|
}
|
|
11563
|
+
/**
|
|
11564
|
+
* Creates a transaction instruction to set the message libraries.
|
|
11565
|
+
*
|
|
11566
|
+
* @param {PublicKey[]} msglibPrograms - The message library public keys.
|
|
11567
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
11568
|
+
*/
|
|
11018
11569
|
createSetMsgLibsInstruction(msglibPrograms) {
|
|
11019
11570
|
const params = {
|
|
11020
11571
|
fields: [msglibPrograms],
|
|
@@ -11029,13 +11580,34 @@ var DVN = class {
|
|
|
11029
11580
|
data: buffer
|
|
11030
11581
|
});
|
|
11031
11582
|
}
|
|
11583
|
+
/**
|
|
11584
|
+
* Gets the expiration time.
|
|
11585
|
+
*
|
|
11586
|
+
* @returns {number} The expiration time.
|
|
11587
|
+
*/
|
|
11032
11588
|
_getExpiration() {
|
|
11033
11589
|
return (/* @__PURE__ */ new Date()).getTime() / 1e3 + 120;
|
|
11034
11590
|
}
|
|
11591
|
+
/**
|
|
11592
|
+
* Sets the message libraries.
|
|
11593
|
+
*
|
|
11594
|
+
* @param {Connection} connection - The connection.
|
|
11595
|
+
* @param {PublicKey} payer - The payer.
|
|
11596
|
+
* @param {PublicKey[]} msgLibs - The message library public keys.
|
|
11597
|
+
* @param {SignFunc} sign - The sign function.
|
|
11598
|
+
* @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
|
|
11599
|
+
*/
|
|
11035
11600
|
async setMsgLibs(connection, payer, msgLibs, sign) {
|
|
11036
11601
|
const expiration = this._getExpiration();
|
|
11037
11602
|
return this.invoke(connection, this.vid, payer, this.createSetMsgLibsInstruction(msgLibs), expiration, sign);
|
|
11038
11603
|
}
|
|
11604
|
+
/**
|
|
11605
|
+
* Creates a transaction instruction to set the price feed.
|
|
11606
|
+
*
|
|
11607
|
+
* @param {PublicKey} admin - The admin public key.
|
|
11608
|
+
* @param {PublicKey} priceFeedProgram - The price feed program public key.
|
|
11609
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
11610
|
+
*/
|
|
11039
11611
|
createSetPriceFeedInstruction(admin, priceFeedProgram) {
|
|
11040
11612
|
const [configAccount] = this.dvnDeriver.config();
|
|
11041
11613
|
const [priceFeedPda] = new PriceFeedPDADeriver(priceFeedProgram).priceFeed();
|
|
@@ -11057,6 +11629,14 @@ var DVN = class {
|
|
|
11057
11629
|
this.programId
|
|
11058
11630
|
);
|
|
11059
11631
|
}
|
|
11632
|
+
/**
|
|
11633
|
+
* Gets the account metadata for the CPI (Cross-Program Invocation) of the quote instruction.
|
|
11634
|
+
*
|
|
11635
|
+
* @param {PublicKey} priceFeedConfig - The price feed configuration public key.
|
|
11636
|
+
* @param {PublicKey} priceFeedProgram - The price feed program public key.
|
|
11637
|
+
* @param {boolean} payment - Indicates if payment is required.
|
|
11638
|
+
* @returns {AccountMeta[]} An array of account metadata.
|
|
11639
|
+
*/
|
|
11060
11640
|
getQuoteIXAccountMetaForCPI(priceFeedConfig, priceFeedProgram, payment) {
|
|
11061
11641
|
const [config] = this.dvnDeriver.config();
|
|
11062
11642
|
const keys = createQuoteDvnInstructionAccounts(
|
|
@@ -11078,6 +11658,13 @@ var DVN = class {
|
|
|
11078
11658
|
}
|
|
11079
11659
|
].concat(keys);
|
|
11080
11660
|
}
|
|
11661
|
+
/**
|
|
11662
|
+
* Gets the configuration state.
|
|
11663
|
+
*
|
|
11664
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
11665
|
+
* @param {Commitment | GetAccountInfoConfig} [commitment='confirmed'] - The commitment level or account info configuration.
|
|
11666
|
+
* @returns {Promise<accounts.DvnConfig | null>} A promise that resolves to the configuration state or null if not found.
|
|
11667
|
+
*/
|
|
11081
11668
|
async getConfigState(connection, commitment = "confirmed") {
|
|
11082
11669
|
const [config] = this.dvnDeriver.config();
|
|
11083
11670
|
try {
|
|
@@ -12649,8 +13236,8 @@ var treasurySetEventBeet = new beet159__namespace.FixableBeetArgsStruct(
|
|
|
12649
13236
|
function getEventDiscriminator(event) {
|
|
12650
13237
|
const hash = crypto__default.default.createHash("sha256");
|
|
12651
13238
|
hash.update(`event:${event}`);
|
|
12652
|
-
const
|
|
12653
|
-
return
|
|
13239
|
+
const sha256 = hash.digest("hex");
|
|
13240
|
+
return sha256.slice(0, 16);
|
|
12654
13241
|
}
|
|
12655
13242
|
async function extractSentPacketEventByTxHash(connection, program, signature, commitment, unsafeParseErr = false) {
|
|
12656
13243
|
const events = await extractEventFromTransactionSignature(
|
|
@@ -12880,7 +13467,7 @@ async function buildVersionedTransaction(connection, payerKey, instructions, com
|
|
|
12880
13467
|
);
|
|
12881
13468
|
}
|
|
12882
13469
|
function instructionDiscriminator(method) {
|
|
12883
|
-
return Buffer.from(
|
|
13470
|
+
return Buffer.from(lzFoundation.sha2_256(Buffer.from(`global:${method}`))).subarray(0, 8);
|
|
12884
13471
|
}
|
|
12885
13472
|
async function simulateTransaction(connection, instructions, programId, payer, commitment = "confirmed", blockhash, lookupTableAddress) {
|
|
12886
13473
|
const tx = await buildVersionedTransaction(
|
|
@@ -12904,12 +13491,12 @@ async function simulateTransaction(connection, instructions, programId, payer, c
|
|
|
12904
13491
|
// src/recevie.ts
|
|
12905
13492
|
async function lzReceive(connection, payer, packet, callerParams = Uint8Array.from([0, 0]), commitmentOrConfig = "confirmed") {
|
|
12906
13493
|
const { message: message_, sender, srcEid, guid, receiver: receiver_ } = packet;
|
|
12907
|
-
const receiver = new web314.PublicKey(addressToBytes32(receiver_));
|
|
12908
|
-
const message =
|
|
13494
|
+
const receiver = new web314.PublicKey(lzV2Utilities.addressToBytes32(receiver_));
|
|
13495
|
+
const message = lzUtilities.arrayify(message_);
|
|
12909
13496
|
const params = {
|
|
12910
13497
|
srcEid,
|
|
12911
|
-
sender: Array.from(
|
|
12912
|
-
guid: Array.from(
|
|
13498
|
+
sender: Array.from(lzUtilities.arrayify(sender)),
|
|
13499
|
+
guid: Array.from(lzUtilities.arrayify(guid)),
|
|
12913
13500
|
message,
|
|
12914
13501
|
callerParams,
|
|
12915
13502
|
nonce: parseInt(packet.nonce)
|
|
@@ -13321,11 +13908,28 @@ var PROGRAM_ID4 = new web314.PublicKey(PROGRAM_ADDRESS4);
|
|
|
13321
13908
|
|
|
13322
13909
|
// src/executor.ts
|
|
13323
13910
|
var Executor = class {
|
|
13911
|
+
/**
|
|
13912
|
+
* Creates an instance of the Executor class.
|
|
13913
|
+
*
|
|
13914
|
+
* @param {PublicKey} program - The program public key.
|
|
13915
|
+
*/
|
|
13324
13916
|
constructor(program) {
|
|
13325
13917
|
this.program = program;
|
|
13326
13918
|
this.deriver = new ExecutorPDADeriver(this.program);
|
|
13327
13919
|
}
|
|
13328
13920
|
// owner methods
|
|
13921
|
+
/**
|
|
13922
|
+
* Initializes the executor.
|
|
13923
|
+
*
|
|
13924
|
+
* @param {PublicKey} payer - The payer public key.
|
|
13925
|
+
* @param {PublicKey} owner - The owner public key.
|
|
13926
|
+
* @param {PublicKey[]} admins - The admin public keys.
|
|
13927
|
+
* @param {PublicKey[]} executors - The executor public keys.
|
|
13928
|
+
* @param {PublicKey[]} msglibs - The message library public keys.
|
|
13929
|
+
* @param {PublicKey} priceFeed - The price feed public key.
|
|
13930
|
+
*
|
|
13931
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
13932
|
+
*/
|
|
13329
13933
|
initExecutor(payer, owner, admins, executors, msglibs, priceFeed) {
|
|
13330
13934
|
const [configAccount] = this.deriver.config();
|
|
13331
13935
|
return createInitExecutorInstruction(
|
|
@@ -13345,6 +13949,14 @@ var Executor = class {
|
|
|
13345
13949
|
this.program
|
|
13346
13950
|
);
|
|
13347
13951
|
}
|
|
13952
|
+
/**
|
|
13953
|
+
* Sets the owner.
|
|
13954
|
+
*
|
|
13955
|
+
* @param {PublicKey} owner - The current owner public key.
|
|
13956
|
+
* @param {PublicKey} newOwner - The new owner public key.
|
|
13957
|
+
*
|
|
13958
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
13959
|
+
*/
|
|
13348
13960
|
setOwner(owner, newOwner) {
|
|
13349
13961
|
const [configAccount] = this.deriver.config();
|
|
13350
13962
|
return createOwnerSetConfigInstruction(
|
|
@@ -13361,6 +13973,14 @@ var Executor = class {
|
|
|
13361
13973
|
this.program
|
|
13362
13974
|
);
|
|
13363
13975
|
}
|
|
13976
|
+
/**
|
|
13977
|
+
* Sets the admins.
|
|
13978
|
+
*
|
|
13979
|
+
* @param {PublicKey} owner - The owner public key.
|
|
13980
|
+
* @param {PublicKey[]} admins - The admin public keys.
|
|
13981
|
+
*
|
|
13982
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
13983
|
+
*/
|
|
13364
13984
|
setAdmins(owner, admins) {
|
|
13365
13985
|
const [configAccount] = this.deriver.config();
|
|
13366
13986
|
return createOwnerSetConfigInstruction(
|
|
@@ -13377,6 +13997,14 @@ var Executor = class {
|
|
|
13377
13997
|
this.program
|
|
13378
13998
|
);
|
|
13379
13999
|
}
|
|
14000
|
+
/**
|
|
14001
|
+
* Sets the allow list.
|
|
14002
|
+
*
|
|
14003
|
+
* @param {PublicKey} owner - The owner public key.
|
|
14004
|
+
* @param {PublicKey[]} allowlist - The allow list public keys.
|
|
14005
|
+
*
|
|
14006
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
14007
|
+
*/
|
|
13380
14008
|
setAllowList(owner, allowlist) {
|
|
13381
14009
|
const [configAccount] = this.deriver.config();
|
|
13382
14010
|
return createOwnerSetConfigInstruction(
|
|
@@ -13393,6 +14021,14 @@ var Executor = class {
|
|
|
13393
14021
|
this.program
|
|
13394
14022
|
);
|
|
13395
14023
|
}
|
|
14024
|
+
/**
|
|
14025
|
+
* Sets the deny list.
|
|
14026
|
+
*
|
|
14027
|
+
* @param {PublicKey} owner - The owner public key.
|
|
14028
|
+
* @param {PublicKey[]} denylist - The deny list public keys.
|
|
14029
|
+
*
|
|
14030
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
14031
|
+
*/
|
|
13396
14032
|
setDenyList(owner, denylist) {
|
|
13397
14033
|
const [configAccount] = this.deriver.config();
|
|
13398
14034
|
return createOwnerSetConfigInstruction(
|
|
@@ -13409,6 +14045,14 @@ var Executor = class {
|
|
|
13409
14045
|
this.program
|
|
13410
14046
|
);
|
|
13411
14047
|
}
|
|
14048
|
+
/**
|
|
14049
|
+
* Sets the paused state.
|
|
14050
|
+
*
|
|
14051
|
+
* @param {PublicKey} owner - The owner public key.
|
|
14052
|
+
* @param {boolean} paused - The paused state.
|
|
14053
|
+
*
|
|
14054
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
14055
|
+
*/
|
|
13412
14056
|
setPaused(owner, paused) {
|
|
13413
14057
|
const [configAccount] = this.deriver.config();
|
|
13414
14058
|
return createOwnerSetConfigInstruction(
|
|
@@ -13425,6 +14069,14 @@ var Executor = class {
|
|
|
13425
14069
|
this.program
|
|
13426
14070
|
);
|
|
13427
14071
|
}
|
|
14072
|
+
/**
|
|
14073
|
+
* Sets the executors.
|
|
14074
|
+
*
|
|
14075
|
+
* @param {PublicKey} owner - The owner public key.
|
|
14076
|
+
* @param {PublicKey[]} executors - The executor public keys.
|
|
14077
|
+
*
|
|
14078
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
14079
|
+
*/
|
|
13428
14080
|
setExecutors(owner, executors) {
|
|
13429
14081
|
const [configAccount] = this.deriver.config();
|
|
13430
14082
|
return createOwnerSetConfigInstruction(
|
|
@@ -13441,6 +14093,14 @@ var Executor = class {
|
|
|
13441
14093
|
this.program
|
|
13442
14094
|
);
|
|
13443
14095
|
}
|
|
14096
|
+
/**
|
|
14097
|
+
* Sets the message libraries by programs.
|
|
14098
|
+
*
|
|
14099
|
+
* @param {PublicKey} owner - The owner public key.
|
|
14100
|
+
* @param {PublicKey[]} msglibPrograms - The message library program public keys.
|
|
14101
|
+
*
|
|
14102
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
14103
|
+
*/
|
|
13444
14104
|
setMsglibByPrograms(owner, msglibPrograms) {
|
|
13445
14105
|
this.deriver.config();
|
|
13446
14106
|
const msglibPdas = msglibPrograms.map((program) => {
|
|
@@ -13448,6 +14108,14 @@ var Executor = class {
|
|
|
13448
14108
|
});
|
|
13449
14109
|
return this.setMsglibByPDAs(owner, msglibPdas);
|
|
13450
14110
|
}
|
|
14111
|
+
/**
|
|
14112
|
+
* Sets the message libraries by PDAs.
|
|
14113
|
+
*
|
|
14114
|
+
* @param {PublicKey} owner - The owner public key.
|
|
14115
|
+
* @param {PublicKey[]} msglibPDAs - The message library PDA public keys.
|
|
14116
|
+
*
|
|
14117
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
14118
|
+
*/
|
|
13451
14119
|
setMsglibByPDAs(owner, msglibPDAs) {
|
|
13452
14120
|
const [configAccount] = this.deriver.config();
|
|
13453
14121
|
return createOwnerSetConfigInstruction(
|
|
@@ -13465,6 +14133,14 @@ var Executor = class {
|
|
|
13465
14133
|
);
|
|
13466
14134
|
}
|
|
13467
14135
|
// admin methods
|
|
14136
|
+
/**
|
|
14137
|
+
* Sets the default multiplier BPS.
|
|
14138
|
+
*
|
|
14139
|
+
* @param {PublicKey} admin - The admin public key.
|
|
14140
|
+
* @param {number} defaultMultiplierBps - The default multiplier BPS.
|
|
14141
|
+
*
|
|
14142
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
14143
|
+
*/
|
|
13468
14144
|
setDefaultMultiplierBps(admin, defaultMultiplierBps) {
|
|
13469
14145
|
const [configAccount] = this.deriver.config();
|
|
13470
14146
|
return createAdminSetConfigInstruction(
|
|
@@ -13481,6 +14157,14 @@ var Executor = class {
|
|
|
13481
14157
|
this.program
|
|
13482
14158
|
);
|
|
13483
14159
|
}
|
|
14160
|
+
/**
|
|
14161
|
+
* Sets the destination configurations.
|
|
14162
|
+
*
|
|
14163
|
+
* @param {PublicKey} admin - The admin public key.
|
|
14164
|
+
* @param {types.DstConfig[]} dstConfigs - The destination configurations.
|
|
14165
|
+
*
|
|
14166
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
14167
|
+
*/
|
|
13484
14168
|
setDstConfig(admin, dstConfigs) {
|
|
13485
14169
|
const [configAccount] = this.deriver.config();
|
|
13486
14170
|
return createAdminSetConfigInstruction(
|
|
@@ -13497,6 +14181,14 @@ var Executor = class {
|
|
|
13497
14181
|
this.program
|
|
13498
14182
|
);
|
|
13499
14183
|
}
|
|
14184
|
+
/**
|
|
14185
|
+
* Sets the price feed.
|
|
14186
|
+
*
|
|
14187
|
+
* @param {PublicKey} admin - The admin public key.
|
|
14188
|
+
* @param {PublicKey} priceFeedProgram - The price feed program public key.
|
|
14189
|
+
*
|
|
14190
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
14191
|
+
*/
|
|
13500
14192
|
setPriceFeed(admin, priceFeedProgram) {
|
|
13501
14193
|
const [configAccount] = this.deriver.config();
|
|
13502
14194
|
const [priceFeed] = new PriceFeedPDADeriver(priceFeedProgram).priceFeed();
|
|
@@ -13514,6 +14206,14 @@ var Executor = class {
|
|
|
13514
14206
|
this.program
|
|
13515
14207
|
);
|
|
13516
14208
|
}
|
|
14209
|
+
/**
|
|
14210
|
+
* Gets the executor configuration.
|
|
14211
|
+
*
|
|
14212
|
+
* @param {Connection} connection - The connection.
|
|
14213
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment or configuration.
|
|
14214
|
+
*
|
|
14215
|
+
* @returns {Promise<accounts.ExecutorConfig | null>} A promise that resolves to the executor configuration or null.
|
|
14216
|
+
*/
|
|
13517
14217
|
async getExecutorConfig(connection, commitmentOrConfig) {
|
|
13518
14218
|
const [configAccount] = this.deriver.config();
|
|
13519
14219
|
try {
|
|
@@ -13527,6 +14227,15 @@ var Executor = class {
|
|
|
13527
14227
|
return null;
|
|
13528
14228
|
}
|
|
13529
14229
|
}
|
|
14230
|
+
/**
|
|
14231
|
+
* Gets the quote instruction account meta for CPI.
|
|
14232
|
+
*
|
|
14233
|
+
* @param {PublicKey} priceFeedConfig - The price feed configuration public key.
|
|
14234
|
+
* @param {PublicKey} priceFeedProgram - The price feed program public key.
|
|
14235
|
+
* @param {boolean} payment - Whether payment is required.
|
|
14236
|
+
*
|
|
14237
|
+
* @returns {AccountMeta[]} The account meta array.
|
|
14238
|
+
*/
|
|
13530
14239
|
getQuoteIXAccountMetaForCPI(priceFeedConfig, priceFeedProgram, payment) {
|
|
13531
14240
|
const [config] = this.deriver.config();
|
|
13532
14241
|
const ixAccounts = createQuoteExecutorInstructionAccounts(
|
|
@@ -13548,15 +14257,29 @@ var Executor = class {
|
|
|
13548
14257
|
}
|
|
13549
14258
|
].concat(ixAccounts);
|
|
13550
14259
|
}
|
|
14260
|
+
/**
|
|
14261
|
+
* Executes a transaction.
|
|
14262
|
+
*
|
|
14263
|
+
* @param {Connection} connection - The connection.
|
|
14264
|
+
* @param {PublicKey} executor - The executor public key.
|
|
14265
|
+
* @param {PublicKey} endpointProgram - The endpoint program public key.
|
|
14266
|
+
* @param {Packet} packet - The packet.
|
|
14267
|
+
* @param {Uint8Array} extraData - The extra data.
|
|
14268
|
+
* @param {BN} [value] - The value.
|
|
14269
|
+
* @param {number} [computeUnits] - The compute units.
|
|
14270
|
+
* @param {Commitment} [commitmentOrConfig] - The commitment or configuration.
|
|
14271
|
+
*
|
|
14272
|
+
* @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
|
|
14273
|
+
*/
|
|
13551
14274
|
async execute(connection, executor, endpointProgram, packet, extraData, value = new BN__default.default(0), computeUnits = 2e5, commitmentOrConfig) {
|
|
13552
14275
|
const [config] = this.deriver.config();
|
|
13553
14276
|
const endpointEventDeriver = new EventPDADeriver(endpointProgram);
|
|
13554
14277
|
const executorEventDeriver = new EventPDADeriver(this.program);
|
|
13555
14278
|
const { message: message_, sender, srcEid, guid, receiver: receiver_, nonce } = packet;
|
|
13556
|
-
const receiver = new web314.PublicKey(addressToBytes32(receiver_));
|
|
14279
|
+
const receiver = new web314.PublicKey(lzV2Utilities.addressToBytes32(receiver_));
|
|
13557
14280
|
const receiverInfo = await connection.getParsedAccountInfo(receiver, commitmentOrConfig);
|
|
13558
14281
|
const receiverProgram = new web314.PublicKey(receiverInfo.value.owner);
|
|
13559
|
-
const message =
|
|
14282
|
+
const message = lzUtilities.arrayify(message_);
|
|
13560
14283
|
const accounts = await getLzReceiveAccounts(
|
|
13561
14284
|
connection,
|
|
13562
14285
|
executor,
|
|
@@ -13564,8 +14287,8 @@ var Executor = class {
|
|
|
13564
14287
|
receiverProgram,
|
|
13565
14288
|
{
|
|
13566
14289
|
srcEid,
|
|
13567
|
-
sender: Array.from(
|
|
13568
|
-
guid: Array.from(
|
|
14290
|
+
sender: Array.from(lzUtilities.arrayify(sender)),
|
|
14291
|
+
guid: Array.from(lzUtilities.arrayify(guid)),
|
|
13569
14292
|
message,
|
|
13570
14293
|
callerParams: extraData,
|
|
13571
14294
|
nonce: parseInt(packet.nonce)
|
|
@@ -13594,9 +14317,9 @@ var Executor = class {
|
|
|
13594
14317
|
receiver,
|
|
13595
14318
|
lzReceive: {
|
|
13596
14319
|
srcEid,
|
|
13597
|
-
sender: Array.from(
|
|
14320
|
+
sender: Array.from(lzUtilities.arrayify(sender)),
|
|
13598
14321
|
nonce: parseInt(nonce),
|
|
13599
|
-
guid: Array.from(
|
|
14322
|
+
guid: Array.from(lzUtilities.arrayify(guid)),
|
|
13600
14323
|
message,
|
|
13601
14324
|
extraData
|
|
13602
14325
|
},
|
|
@@ -13607,6 +14330,20 @@ var Executor = class {
|
|
|
13607
14330
|
this.program
|
|
13608
14331
|
);
|
|
13609
14332
|
}
|
|
14333
|
+
/**
|
|
14334
|
+
* Composes a transaction.
|
|
14335
|
+
*
|
|
14336
|
+
* @param {Connection} connection - The connection.
|
|
14337
|
+
* @param {PublicKey} executor - The executor public key.
|
|
14338
|
+
* @param {PublicKey} endpointProgram - The endpoint program public key.
|
|
14339
|
+
* @param {ComposeSentEvent} event - The compose sent event.
|
|
14340
|
+
* @param {Uint8Array} extraData - The extra data.
|
|
14341
|
+
* @param {BN} [value] - The value.
|
|
14342
|
+
* @param {number} [computeUnits] - The compute units.
|
|
14343
|
+
* @param {Commitment} [commitmentOrConfig] - The commitment or configuration.
|
|
14344
|
+
*
|
|
14345
|
+
* @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
|
|
14346
|
+
*/
|
|
13610
14347
|
async compose(connection, executor, endpointProgram, event, extraData, value = new BN__default.default(0), computeUnits = 4e5, commitmentOrConfig) {
|
|
13611
14348
|
const [config] = this.deriver.config();
|
|
13612
14349
|
const endpointEventDeriver = new EventPDADeriver(endpointProgram);
|
|
@@ -16469,12 +17206,26 @@ var PROGRAM_ID5 = new web314.PublicKey(PROGRAM_ADDRESS5);
|
|
|
16469
17206
|
|
|
16470
17207
|
// src/uln.ts
|
|
16471
17208
|
var Uln = class {
|
|
17209
|
+
/**
|
|
17210
|
+
* Creates an instance of the Uln class.
|
|
17211
|
+
*
|
|
17212
|
+
* @param {PublicKey} program - The program public key.
|
|
17213
|
+
*/
|
|
16472
17214
|
constructor(program) {
|
|
16473
17215
|
this.program = program;
|
|
16474
17216
|
this.deriver = new UlnPDADeriver(program);
|
|
16475
17217
|
const [eventAuthorityPDA] = new EventPDADeriver(program).eventAuthority();
|
|
16476
17218
|
this.eventAuthorityPDA = eventAuthorityPDA;
|
|
16477
17219
|
}
|
|
17220
|
+
/**
|
|
17221
|
+
* Initializes the ULN.
|
|
17222
|
+
*
|
|
17223
|
+
* @param {PublicKey} endpointProgram - The endpoint program public key.
|
|
17224
|
+
* @param {PublicKey} payer - The payer public key.
|
|
17225
|
+
* @param {PublicKey} admin - The admin public key.
|
|
17226
|
+
* @param {number} eid - The endpoint ID.
|
|
17227
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
17228
|
+
*/
|
|
16478
17229
|
initUln(endpointProgram, payer, admin, eid) {
|
|
16479
17230
|
const [setting] = this.deriver.setting();
|
|
16480
17231
|
const [msgLib] = this.deriver.messageLib();
|
|
@@ -16496,7 +17247,17 @@ var Uln = class {
|
|
|
16496
17247
|
);
|
|
16497
17248
|
}
|
|
16498
17249
|
/**
|
|
17250
|
+
* Initializes or updates the default configuration.
|
|
16499
17251
|
* before calling this function, you should call initUln to initialize the uln
|
|
17252
|
+
*
|
|
17253
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17254
|
+
* @param {PublicKey} admin - The admin public key.
|
|
17255
|
+
* @param {number} eid - The endpoint ID.
|
|
17256
|
+
* @param {types.UlnConfig} sendUlnConfig - The send ULN configuration.
|
|
17257
|
+
* @param {types.UlnConfig} receiveUlnConfig - The receive ULN configuration.
|
|
17258
|
+
* @param {types.ExecutorConfig} executorConfig - The executor configuration.
|
|
17259
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
17260
|
+
* @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
|
|
16500
17261
|
*/
|
|
16501
17262
|
async initOrUpdateDefaultConfig(connection, admin, eid, sendUlnConfig, receiveUlnConfig, executorConfig, commitmentOrConfig) {
|
|
16502
17263
|
const [setting] = this.deriver.setting();
|
|
@@ -16547,7 +17308,18 @@ var Uln = class {
|
|
|
16547
17308
|
}
|
|
16548
17309
|
// msg_lib -> msg_lib_program ->
|
|
16549
17310
|
/**
|
|
17311
|
+
* Sets the treasury.
|
|
16550
17312
|
* before calling this function, you should call initUln to initialize the uln
|
|
17313
|
+
*
|
|
17314
|
+
* @param {PublicKey} admin - The admin public key.
|
|
17315
|
+
* @param {object} treasury - The treasury object.
|
|
17316
|
+
* @param {PublicKey} treasury.admin - The treasury admin public key.
|
|
17317
|
+
* @param {PublicKey} treasury.nativeReceiver - The native receiver public key.
|
|
17318
|
+
* @param {number} treasury.nativeFeeBps - The native fee basis points.
|
|
17319
|
+
* @param {object} treasury.lzToken - The LZ token object.
|
|
17320
|
+
* @param {PublicKey} treasury.lzToken.receiver - The LZ token receiver public key.
|
|
17321
|
+
* @param {number} treasury.lzToken.fee - The LZ token fee.
|
|
17322
|
+
* @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
|
|
16551
17323
|
*/
|
|
16552
17324
|
async setTreasury(admin, treasury) {
|
|
16553
17325
|
const [setting] = this.deriver.setting();
|
|
@@ -16567,6 +17339,16 @@ var Uln = class {
|
|
|
16567
17339
|
);
|
|
16568
17340
|
return Promise.resolve(ix);
|
|
16569
17341
|
}
|
|
17342
|
+
/**
|
|
17343
|
+
* Transfers the admin role to a new admin.
|
|
17344
|
+
*
|
|
17345
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17346
|
+
* @param {PublicKey} admin - The current admin public key.
|
|
17347
|
+
* @param {PublicKey} newAdmin - The new admin public key.
|
|
17348
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
17349
|
+
* @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
|
|
17350
|
+
* @throws {Error} If the ULN is not initialized.
|
|
17351
|
+
*/
|
|
16570
17352
|
async transferAdmin(connection, admin, newAdmin, commitmentOrConfig) {
|
|
16571
17353
|
const [setting] = this.deriver.setting();
|
|
16572
17354
|
const info = await connection.getAccountInfo(setting, commitmentOrConfig);
|
|
@@ -16589,19 +17371,17 @@ var Uln = class {
|
|
|
16589
17371
|
);
|
|
16590
17372
|
}
|
|
16591
17373
|
/**
|
|
17374
|
+
* Gets the account metadata for the CPI (Cross-Program Invocation) of the quote instruction.
|
|
16592
17375
|
*
|
|
16593
|
-
* @param connection
|
|
16594
|
-
*
|
|
16595
|
-
* @param
|
|
16596
|
-
* @param
|
|
16597
|
-
* @
|
|
16598
|
-
* @param payInLzToken
|
|
16599
|
-
* @param commitment
|
|
16600
|
-
* @returns
|
|
17376
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17377
|
+
* @param {PublicKey} _payer - The payer public key.
|
|
17378
|
+
* @param {PacketPath} path - The packet path.
|
|
17379
|
+
* @param {Commitment} [commitment] - The commitment level.
|
|
17380
|
+
* @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
|
|
16601
17381
|
*/
|
|
16602
17382
|
async getQuoteIXAccountMetaForCPI(connection, _payer, path, commitment) {
|
|
16603
17383
|
const { sender: sender_, dstEid } = path;
|
|
16604
|
-
const sender = new web314.PublicKey(
|
|
17384
|
+
const sender = new web314.PublicKey(lzUtilities.arrayify(sender_));
|
|
16605
17385
|
const [defaultSendConfig] = this.deriver.defaultSendConfig(dstEid);
|
|
16606
17386
|
const [sendConfig] = this.deriver.sendConfig(dstEid, sender);
|
|
16607
17387
|
const [setting] = this.deriver.setting();
|
|
@@ -16619,12 +17399,18 @@ var Uln = class {
|
|
|
16619
17399
|
);
|
|
16620
17400
|
return accounts.slice(1);
|
|
16621
17401
|
}
|
|
16622
|
-
|
|
16623
|
-
*
|
|
17402
|
+
/**
|
|
17403
|
+
* Gets the account metadata for the CPI (Cross-Program Invocation) of the send instruction.
|
|
17404
|
+
*
|
|
17405
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17406
|
+
* @param {PublicKey} payer - The payer public key.
|
|
17407
|
+
* @param {PacketPath} path - The packet path.
|
|
17408
|
+
* @param {Commitment} [commitment='confirmed'] - The commitment level.
|
|
17409
|
+
* @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
|
|
16624
17410
|
*/
|
|
16625
17411
|
async getSendIXAccountMetaForCPI(connection, payer, path, commitment = "confirmed") {
|
|
16626
17412
|
const { sender: sender_, dstEid } = path;
|
|
16627
|
-
const sender = new web314.PublicKey(
|
|
17413
|
+
const sender = new web314.PublicKey(lzUtilities.arrayify(sender_));
|
|
16628
17414
|
const [sendConfig] = this.deriver.sendConfig(dstEid, sender);
|
|
16629
17415
|
const [defaultSendConfig] = this.deriver.defaultSendConfig(dstEid);
|
|
16630
17416
|
const [setting] = this.deriver.setting();
|
|
@@ -16658,6 +17444,16 @@ var Uln = class {
|
|
|
16658
17444
|
return accounts.slice(1);
|
|
16659
17445
|
}
|
|
16660
17446
|
// 3 RPC requests
|
|
17447
|
+
/**
|
|
17448
|
+
* Gets the remaining accounts for the send instruction.
|
|
17449
|
+
*
|
|
17450
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17451
|
+
* @param {PublicKey} sender - The sender public key.
|
|
17452
|
+
* @param {number} dstEid - The destination endpoint ID.
|
|
17453
|
+
* @param {boolean} payment - Indicates if payment is required.
|
|
17454
|
+
* @param {Commitment | GetAccountInfoConfig} [commitment='confirmed'] - The commitment level or account info configuration.
|
|
17455
|
+
* @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
|
|
17456
|
+
*/
|
|
16661
17457
|
async getSendIxRemainingAccounts(connection, sender, dstEid, payment, commitment = "confirmed") {
|
|
16662
17458
|
const { executor, dvns } = await this.getWorkers(connection, sender, dstEid, commitment);
|
|
16663
17459
|
const priceFeeds = new Array();
|
|
@@ -16668,7 +17464,7 @@ var Uln = class {
|
|
|
16668
17464
|
});
|
|
16669
17465
|
const priceFeedInfos = await connection.getMultipleAccountsInfo(priceFeeds, commitment);
|
|
16670
17466
|
const priceFeedDict = priceFeedInfos.reduce((acc, info, i) => {
|
|
16671
|
-
|
|
17467
|
+
invariant3__default.default(info, `priceFeed:${priceFeeds[i].toBase58()} not initialized`);
|
|
16672
17468
|
acc.set(priceFeeds[i].toBase58(), info.owner);
|
|
16673
17469
|
return acc;
|
|
16674
17470
|
}, /* @__PURE__ */ new Map());
|
|
@@ -16688,9 +17484,15 @@ var Uln = class {
|
|
|
16688
17484
|
});
|
|
16689
17485
|
return executorAccounts.concat(dvnAccounts.flat());
|
|
16690
17486
|
}
|
|
16691
|
-
|
|
16692
|
-
*
|
|
17487
|
+
/**
|
|
17488
|
+
* Gets all workers (executor and DVN).
|
|
16693
17489
|
* 2 RPC requests
|
|
17490
|
+
*
|
|
17491
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17492
|
+
* @param {PublicKey} sender - The sender public key.
|
|
17493
|
+
* @param {number} eid - The endpoint ID.
|
|
17494
|
+
* @param {Commitment | GetAccountInfoConfig} [commitment='confirmed'] - The commitment level or account info configuration.
|
|
17495
|
+
* @returns {Promise<{ executor: { config: ExecutorAccounts.ExecutorConfig; owner: PublicKey }; dvns: { config: DvnAccounts.DvnConfig; owner: PublicKey }[] }>} A promise that resolves to an object containing the executor and DVN configurations.
|
|
16694
17496
|
*/
|
|
16695
17497
|
async getWorkers(connection, sender, eid, commitment = "confirmed") {
|
|
16696
17498
|
const [defaultSendConfig] = this.deriver.defaultSendConfig(eid);
|
|
@@ -16699,7 +17501,7 @@ var Uln = class {
|
|
|
16699
17501
|
[defaultSendConfig, sendConfig],
|
|
16700
17502
|
commitment
|
|
16701
17503
|
);
|
|
16702
|
-
|
|
17504
|
+
invariant3__default.default(defaultSendConfigBuf, "defaultSendConfig not initialized");
|
|
16703
17505
|
const [defaultSendConfigState] = SendConfig.fromAccountInfo(defaultSendConfigBuf);
|
|
16704
17506
|
let {
|
|
16705
17507
|
executor,
|
|
@@ -16724,14 +17526,14 @@ var Uln = class {
|
|
|
16724
17526
|
[executor.executor, ...dvns],
|
|
16725
17527
|
commitment
|
|
16726
17528
|
);
|
|
16727
|
-
|
|
17529
|
+
invariant3__default.default(executorBuf, `executor:${executor.executor.toBase58()} not initialized`);
|
|
16728
17530
|
return {
|
|
16729
17531
|
executor: {
|
|
16730
17532
|
config: accounts_exports4.ExecutorConfig.fromAccountInfo(executorBuf)[0],
|
|
16731
17533
|
owner: executorBuf.owner
|
|
16732
17534
|
},
|
|
16733
17535
|
dvns: dvnBuf.map((dvn, i) => {
|
|
16734
|
-
|
|
17536
|
+
invariant3__default.default(dvn, `dvn:${dvns[i].toBase58()} not initialized`);
|
|
16735
17537
|
return {
|
|
16736
17538
|
config: accounts_exports3.DvnConfig.fromAccountInfo(dvn)[0],
|
|
16737
17539
|
owner: dvn.owner
|
|
@@ -16739,8 +17541,18 @@ var Uln = class {
|
|
|
16739
17541
|
})
|
|
16740
17542
|
};
|
|
16741
17543
|
}
|
|
17544
|
+
/**
|
|
17545
|
+
* Initializes the verification process.
|
|
17546
|
+
*
|
|
17547
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17548
|
+
* @param {PublicKey} payer - The payer public key.
|
|
17549
|
+
* @param {PublicKey} dvn - The DVN public key.
|
|
17550
|
+
* @param {Uint8Array} packetBytes - The packet bytes.
|
|
17551
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
17552
|
+
* @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
|
|
17553
|
+
*/
|
|
16742
17554
|
async initVerify(connection, payer, dvn, packetBytes, commitmentOrConfig) {
|
|
16743
|
-
const packet = PacketV1Codec.fromBytes(packetBytes);
|
|
17555
|
+
const packet = lzV2Utilities.PacketV1Codec.fromBytes(packetBytes);
|
|
16744
17556
|
const headerHash = packet.headerHash();
|
|
16745
17557
|
const headerHashBytes = Uint8Array.from(Buffer.from(headerHash.slice(2), "hex"));
|
|
16746
17558
|
const payloadHash = packet.payloadHash();
|
|
@@ -16765,8 +17577,16 @@ var Uln = class {
|
|
|
16765
17577
|
this.program
|
|
16766
17578
|
);
|
|
16767
17579
|
}
|
|
17580
|
+
/**
|
|
17581
|
+
* Verifies the packet.
|
|
17582
|
+
*
|
|
17583
|
+
* @param {PublicKey} dvn - The DVN public key.
|
|
17584
|
+
* @param {Uint8Array} packetBytes - The packet bytes.
|
|
17585
|
+
* @param {number | string} confirmations - The number of confirmations.
|
|
17586
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
17587
|
+
*/
|
|
16768
17588
|
verify(dvn, packetBytes, confirmations) {
|
|
16769
|
-
const packet = PacketV1Codec.fromBytes(packetBytes);
|
|
17589
|
+
const packet = lzV2Utilities.PacketV1Codec.fromBytes(packetBytes);
|
|
16770
17590
|
const headerHash = packet.headerHash();
|
|
16771
17591
|
const headerHashBytes = Uint8Array.from(Buffer.from(headerHash.slice(2), "hex"));
|
|
16772
17592
|
const payloadHash = packet.payloadHash();
|
|
@@ -16789,8 +17609,16 @@ var Uln = class {
|
|
|
16789
17609
|
this.program
|
|
16790
17610
|
);
|
|
16791
17611
|
}
|
|
17612
|
+
/**
|
|
17613
|
+
* Closes the verification process.
|
|
17614
|
+
*
|
|
17615
|
+
* @param {PublicKey} dvn - The DVN public key.
|
|
17616
|
+
* @param {PublicKey} receiver - The receiver public key.
|
|
17617
|
+
* @param {Uint8Array} packetBytes - The packet bytes.
|
|
17618
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
17619
|
+
*/
|
|
16792
17620
|
closeVerify(dvn, receiver, packetBytes) {
|
|
16793
|
-
const packet = PacketV1Codec.fromBytes(packetBytes);
|
|
17621
|
+
const packet = lzV2Utilities.PacketV1Codec.fromBytes(packetBytes);
|
|
16794
17622
|
const headerHash = packet.headerHash();
|
|
16795
17623
|
const headerHashBytes = Uint8Array.from(Buffer.from(headerHash.slice(2), "hex"));
|
|
16796
17624
|
const payloadHash = packet.payloadHash();
|
|
@@ -16811,16 +17639,26 @@ var Uln = class {
|
|
|
16811
17639
|
this.program
|
|
16812
17640
|
);
|
|
16813
17641
|
}
|
|
17642
|
+
/**
|
|
17643
|
+
* Checks if the DVN is verified.
|
|
17644
|
+
*
|
|
17645
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17646
|
+
* @param {PublicKey} endpointProgram - The endpoint program public key.
|
|
17647
|
+
* @param {PublicKey} dvn - The DVN public key.
|
|
17648
|
+
* @param {Uint8Array} packetBytes - The packet bytes.
|
|
17649
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig='confirmed'] - The commitment level or account info configuration.
|
|
17650
|
+
* @returns {Promise<boolean>} A promise that resolves to true if the DVN is verified, false otherwise.
|
|
17651
|
+
*/
|
|
16814
17652
|
async isDvnVerified(connection, endpointProgram, dvn, packetBytes, commitmentOrConfig = "confirmed") {
|
|
16815
|
-
const packet = PacketV1Codec.fromBytes(packetBytes);
|
|
17653
|
+
const packet = lzV2Utilities.PacketV1Codec.fromBytes(packetBytes);
|
|
16816
17654
|
const headerHash = packet.headerHash();
|
|
16817
17655
|
const headerHashBytes = Uint8Array.from(Buffer.from(headerHash.slice(2), "hex"));
|
|
16818
17656
|
const payloadHash = packet.payloadHash();
|
|
16819
17657
|
const payloadHashBytes = Uint8Array.from(Buffer.from(payloadHash.slice(2), "hex"));
|
|
16820
17658
|
const [confirmationsPDA] = this.deriver.confirmations(headerHashBytes, payloadHashBytes, dvn);
|
|
16821
17659
|
const endpoint = new endpoint_exports.Endpoint(endpointProgram);
|
|
16822
|
-
const receiver = new web314.PublicKey(
|
|
16823
|
-
const sender =
|
|
17660
|
+
const receiver = new web314.PublicKey(lzUtilities.arrayify(packet.receiver()));
|
|
17661
|
+
const sender = lzUtilities.arrayify(packet.sender());
|
|
16824
17662
|
const nonce = await endpoint.getNonce(connection, receiver, packet.srcEid(), sender, commitmentOrConfig);
|
|
16825
17663
|
const pendingNonce = await endpoint.getPendingInboundNonce(
|
|
16826
17664
|
connection,
|
|
@@ -16853,11 +17691,19 @@ var Uln = class {
|
|
|
16853
17691
|
return false;
|
|
16854
17692
|
}
|
|
16855
17693
|
}
|
|
17694
|
+
/**
|
|
17695
|
+
* Commits the verification process.
|
|
17696
|
+
*
|
|
17697
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17698
|
+
* @param {PublicKey} endpointProgram - The endpoint program public key.
|
|
17699
|
+
* @param {Uint8Array} packetBytes - The packet bytes.
|
|
17700
|
+
* @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
|
|
17701
|
+
*/
|
|
16856
17702
|
async commitVerification(connection, endpointProgram, packetBytes) {
|
|
16857
|
-
const packet = PacketV1Codec.fromBytes(packetBytes);
|
|
17703
|
+
const packet = lzV2Utilities.PacketV1Codec.fromBytes(packetBytes);
|
|
16858
17704
|
const payloadHash = packet.payloadHash();
|
|
16859
17705
|
const srcEid = packet.srcEid();
|
|
16860
|
-
const receiver = new web314.PublicKey(
|
|
17706
|
+
const receiver = new web314.PublicKey(lzUtilities.arrayify(packet.receiver()));
|
|
16861
17707
|
const payloadHashBytes = Uint8Array.from(Buffer.from(payloadHash.slice(2), "hex"));
|
|
16862
17708
|
const [defaultReceiveConfig] = this.deriver.defaultReceiveConfig(srcEid);
|
|
16863
17709
|
const [receiveConfig] = this.deriver.receiveConfig(srcEid, receiver);
|
|
@@ -16885,15 +17731,20 @@ var Uln = class {
|
|
|
16885
17731
|
},
|
|
16886
17732
|
{
|
|
16887
17733
|
params: {
|
|
16888
|
-
packetHeader: Array.from(
|
|
17734
|
+
packetHeader: Array.from(lzUtilities.arrayify(packet.header())),
|
|
16889
17735
|
payloadHash: Array.from(payloadHashBytes)
|
|
16890
17736
|
}
|
|
16891
17737
|
},
|
|
16892
17738
|
this.program
|
|
16893
17739
|
);
|
|
16894
17740
|
}
|
|
16895
|
-
|
|
16896
|
-
*
|
|
17741
|
+
/**
|
|
17742
|
+
* Gets the account metadata for the CPI (Cross-Program Invocation) of the init config instruction.
|
|
17743
|
+
*
|
|
17744
|
+
* @param {PublicKey} payer - The payer public key.
|
|
17745
|
+
* @param {PublicKey} oappID - The OApp ID public key.
|
|
17746
|
+
* @param {number} eid - The endpoint ID.
|
|
17747
|
+
* @returns {AccountMeta[]} An array of account metadata.
|
|
16897
17748
|
*/
|
|
16898
17749
|
getInitConfigIXAccountMetaForCPI(payer, oappID, eid) {
|
|
16899
17750
|
const [sendConfig] = this.deriver.sendConfig(eid, oappID);
|
|
@@ -16917,6 +17768,14 @@ var Uln = class {
|
|
|
16917
17768
|
});
|
|
16918
17769
|
return accounts.slice(1);
|
|
16919
17770
|
}
|
|
17771
|
+
/**
|
|
17772
|
+
* Constructs the set config data.
|
|
17773
|
+
*
|
|
17774
|
+
* @param {SetConfigType} configType - The configuration type.
|
|
17775
|
+
* @param {types.ExecutorConfig | types.UlnConfig} configData - The configuration data.
|
|
17776
|
+
* @returns {Uint8Array} The constructed set config data.
|
|
17777
|
+
* @throws {Error} If the configuration type is invalid.
|
|
17778
|
+
*/
|
|
16920
17779
|
static constructSetConfigData(configType, configData) {
|
|
16921
17780
|
switch (configType) {
|
|
16922
17781
|
case 1 /* EXECUTOR */: {
|
|
@@ -16933,8 +17792,12 @@ var Uln = class {
|
|
|
16933
17792
|
}
|
|
16934
17793
|
}
|
|
16935
17794
|
/**
|
|
16936
|
-
*
|
|
17795
|
+
* Gets the account metadata for the CPI (Cross-Program Invocation) of the set config instruction.
|
|
16937
17796
|
*
|
|
17797
|
+
* @param {PublicKey} endpointProgram - The endpoint program public key.
|
|
17798
|
+
* @param {PublicKey} oappID - The OApp ID public key.
|
|
17799
|
+
* @param {number} eid - The endpoint ID.
|
|
17800
|
+
* @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
|
|
16938
17801
|
*/
|
|
16939
17802
|
async getSetConfigIXAccountMetaForCPI(endpointProgram, oappID, eid) {
|
|
16940
17803
|
const [sendConfig] = this.deriver.sendConfig(eid, oappID);
|
|
@@ -16961,6 +17824,13 @@ var Uln = class {
|
|
|
16961
17824
|
}
|
|
16962
17825
|
//
|
|
16963
17826
|
// all of below functions are retrieving accounts state
|
|
17827
|
+
/**
|
|
17828
|
+
* Gets the ULN settings.
|
|
17829
|
+
*
|
|
17830
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17831
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
17832
|
+
* @returns {Promise<accounts.UlnSettings | null>} A promise that resolves to the ULN settings or null if not found.
|
|
17833
|
+
*/
|
|
16964
17834
|
async getSetting(connection, commitmentOrConfig) {
|
|
16965
17835
|
const [setting] = this.deriver.setting();
|
|
16966
17836
|
try {
|
|
@@ -16969,6 +17839,14 @@ var Uln = class {
|
|
|
16969
17839
|
return null;
|
|
16970
17840
|
}
|
|
16971
17841
|
}
|
|
17842
|
+
/**
|
|
17843
|
+
* Gets the default send configuration state.
|
|
17844
|
+
*
|
|
17845
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17846
|
+
* @param {number} eid - The endpoint ID.
|
|
17847
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
17848
|
+
* @returns {Promise<accounts.SendConfig | null>} A promise that resolves to the default send configuration state or null if not found.
|
|
17849
|
+
*/
|
|
16972
17850
|
async getDefaultSendConfigState(connection, eid, commitmentOrConfig) {
|
|
16973
17851
|
const [config] = this.deriver.defaultSendConfig(eid);
|
|
16974
17852
|
try {
|
|
@@ -16977,6 +17855,15 @@ var Uln = class {
|
|
|
16977
17855
|
return null;
|
|
16978
17856
|
}
|
|
16979
17857
|
}
|
|
17858
|
+
/**
|
|
17859
|
+
* Gets the send configuration state.
|
|
17860
|
+
*
|
|
17861
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17862
|
+
* @param {PublicKey} sender - The sender public key.
|
|
17863
|
+
* @param {number} eid - The endpoint ID.
|
|
17864
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
17865
|
+
* @returns {Promise<accounts.SendConfig | null>} A promise that resolves to the send configuration state or null if not found.
|
|
17866
|
+
*/
|
|
16980
17867
|
async getSendConfigState(connection, sender, eid, commitmentOrConfig) {
|
|
16981
17868
|
const [config] = this.deriver.sendConfig(eid, sender);
|
|
16982
17869
|
try {
|
|
@@ -16985,6 +17872,14 @@ var Uln = class {
|
|
|
16985
17872
|
return null;
|
|
16986
17873
|
}
|
|
16987
17874
|
}
|
|
17875
|
+
/**
|
|
17876
|
+
* Gets the default receive configuration state.
|
|
17877
|
+
*
|
|
17878
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17879
|
+
* @param {number} eid - The endpoint ID.
|
|
17880
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
17881
|
+
* @returns {Promise<accounts.ReceiveConfig | null>} A promise that resolves to the default receive configuration state or null if not found.
|
|
17882
|
+
*/
|
|
16988
17883
|
async getDefaultReceiveConfigState(connection, eid, commitmentOrConfig) {
|
|
16989
17884
|
const [config] = this.deriver.defaultReceiveConfig(eid);
|
|
16990
17885
|
try {
|
|
@@ -16993,6 +17888,15 @@ var Uln = class {
|
|
|
16993
17888
|
return null;
|
|
16994
17889
|
}
|
|
16995
17890
|
}
|
|
17891
|
+
/**
|
|
17892
|
+
* Gets the receive configuration state.
|
|
17893
|
+
*
|
|
17894
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17895
|
+
* @param {PublicKey} receiver - The receiver public key.
|
|
17896
|
+
* @param {number} eid - The endpoint ID.
|
|
17897
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
17898
|
+
* @returns {Promise<accounts.ReceiveConfig | null>} A promise that resolves to the receive configuration state or null if not found.
|
|
17899
|
+
*/
|
|
16996
17900
|
async getReceiveConfigState(connection, receiver, eid, commitmentOrConfig) {
|
|
16997
17901
|
const [config] = this.deriver.receiveConfig(eid, receiver);
|
|
16998
17902
|
try {
|
|
@@ -17001,6 +17905,16 @@ var Uln = class {
|
|
|
17001
17905
|
return null;
|
|
17002
17906
|
}
|
|
17003
17907
|
}
|
|
17908
|
+
/**
|
|
17909
|
+
* Gets the final receive configuration state.
|
|
17910
|
+
*
|
|
17911
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17912
|
+
* @param {PublicKey} receiver - The receiver public key.
|
|
17913
|
+
* @param {number} eid - The endpoint ID.
|
|
17914
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig='confirmed'] - The commitment level or account info configuration.
|
|
17915
|
+
* @returns {Promise<accounts.ReceiveConfig>} A promise that resolves to the final receive configuration state.
|
|
17916
|
+
* @throws {Error} If no DVN is found.
|
|
17917
|
+
*/
|
|
17004
17918
|
async getFinalReceiveConfigState(connection, receiver, eid, commitmentOrConfig = "confirmed") {
|
|
17005
17919
|
const NIL_CONFIRMATIONS = "18446744073709551615";
|
|
17006
17920
|
const NIL_DVN_COUNT = "255";
|
|
@@ -17832,10 +18746,26 @@ var PROGRAM_ID6 = new web314.PublicKey(PROGRAM_ADDRESS6);
|
|
|
17832
18746
|
|
|
17833
18747
|
// src/pricefeed.ts
|
|
17834
18748
|
var PriceFeed2 = class {
|
|
18749
|
+
/**
|
|
18750
|
+
* Creates an instance of the PriceFeed class.
|
|
18751
|
+
*
|
|
18752
|
+
* @param {PublicKey} program - The public key of the program.
|
|
18753
|
+
*/
|
|
17835
18754
|
constructor(program) {
|
|
17836
18755
|
this.program = program;
|
|
17837
18756
|
this.deriver = new PriceFeedPDADeriver(this.program);
|
|
17838
18757
|
}
|
|
18758
|
+
/**
|
|
18759
|
+
* Initializes the price feed.
|
|
18760
|
+
*
|
|
18761
|
+
* @param {Connection} connection - The Solana connection object.
|
|
18762
|
+
* @param {PublicKey} payer - The public key of the payer.
|
|
18763
|
+
* @param {PublicKey} admin - The public key of the admin.
|
|
18764
|
+
* @param {PublicKey[]} updaters - The list of public keys of the updaters.
|
|
18765
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - Optional commitment or configuration.
|
|
18766
|
+
*
|
|
18767
|
+
* @returns {Promise<TransactionInstruction>} The transaction instruction.
|
|
18768
|
+
*/
|
|
17839
18769
|
async initPriceFeed(connection, payer, admin, updaters, commitmentOrConfig) {
|
|
17840
18770
|
const [priceFeed] = this.deriver.priceFeed();
|
|
17841
18771
|
const info = await connection.getAccountInfo(priceFeed, commitmentOrConfig);
|
|
@@ -17856,6 +18786,16 @@ var PriceFeed2 = class {
|
|
|
17856
18786
|
this.program
|
|
17857
18787
|
);
|
|
17858
18788
|
}
|
|
18789
|
+
/**
|
|
18790
|
+
* Sets the price feed.
|
|
18791
|
+
*
|
|
18792
|
+
* @param {PublicKey} admin - The public key of the admin.
|
|
18793
|
+
* @param {PublicKey[]} updaters - The list of public keys of the updaters.
|
|
18794
|
+
* @param {bignum} priceRatioDenominator - The price ratio denominator.
|
|
18795
|
+
* @param {number} arbitrumCompressionPercent - The Arbitrum compression percentage.
|
|
18796
|
+
*
|
|
18797
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
18798
|
+
*/
|
|
17859
18799
|
setPriceFeed(admin, updaters, priceRatioDenominator, arbitrumCompressionPercent) {
|
|
17860
18800
|
const [priceFeed] = this.deriver.priceFeed();
|
|
17861
18801
|
return createSetPriceFeedInstruction(
|
|
@@ -17873,6 +18813,18 @@ var PriceFeed2 = class {
|
|
|
17873
18813
|
this.program
|
|
17874
18814
|
);
|
|
17875
18815
|
}
|
|
18816
|
+
/**
|
|
18817
|
+
* Sets the price.
|
|
18818
|
+
*
|
|
18819
|
+
* @param {PublicKey} updater - The public key of the updater.
|
|
18820
|
+
* @param {number} dstEid - The destination EID.
|
|
18821
|
+
* @param {bignum} priceRatio - The price ratio.
|
|
18822
|
+
* @param {bignum} gasPriceInUnit - The gas price in unit.
|
|
18823
|
+
* @param {number} gasPerByte - The gas per byte.
|
|
18824
|
+
* @param {types.ModelType | null} modelType - The model type.
|
|
18825
|
+
*
|
|
18826
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
18827
|
+
*/
|
|
17876
18828
|
setPrice(updater, dstEid, priceRatio, gasPriceInUnit, gasPerByte, modelType) {
|
|
17877
18829
|
const EID_MODULUS = 3e4;
|
|
17878
18830
|
dstEid = dstEid % EID_MODULUS;
|
|
@@ -17896,6 +18848,14 @@ var PriceFeed2 = class {
|
|
|
17896
18848
|
this.program
|
|
17897
18849
|
);
|
|
17898
18850
|
}
|
|
18851
|
+
/**
|
|
18852
|
+
* Sets the SOL price.
|
|
18853
|
+
*
|
|
18854
|
+
* @param {PublicKey} updater - The public key of the updater.
|
|
18855
|
+
* @param {bignum | null} nativeTokenPriceUsd - The native token price in USD.
|
|
18856
|
+
*
|
|
18857
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
18858
|
+
*/
|
|
17899
18859
|
setSolPrice(updater, nativeTokenPriceUsd) {
|
|
17900
18860
|
const [priceFeed] = this.deriver.priceFeed();
|
|
17901
18861
|
return createSetSolPriceInstruction(
|
|
@@ -17911,6 +18871,14 @@ var PriceFeed2 = class {
|
|
|
17911
18871
|
this.program
|
|
17912
18872
|
);
|
|
17913
18873
|
}
|
|
18874
|
+
/**
|
|
18875
|
+
* Transfers the admin role.
|
|
18876
|
+
*
|
|
18877
|
+
* @param {PublicKey} admin - The public key of the current admin.
|
|
18878
|
+
* @param {PublicKey} newAdmin - The public key of the new admin.
|
|
18879
|
+
*
|
|
18880
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
18881
|
+
*/
|
|
17914
18882
|
transferAdmin(admin, newAdmin) {
|
|
17915
18883
|
const [priceFeed] = this.deriver.priceFeed();
|
|
17916
18884
|
return createTransferAdminInstruction4(
|
|
@@ -17926,6 +18894,14 @@ var PriceFeed2 = class {
|
|
|
17926
18894
|
this.program
|
|
17927
18895
|
);
|
|
17928
18896
|
}
|
|
18897
|
+
/**
|
|
18898
|
+
* Retrieves the price feed account.
|
|
18899
|
+
*
|
|
18900
|
+
* @param {Connection} connection - The Solana connection object.
|
|
18901
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - Optional commitment or configuration.
|
|
18902
|
+
*
|
|
18903
|
+
* @returns {Promise<accounts.PriceFeed | null>} The price feed account or null if not found.
|
|
18904
|
+
*/
|
|
17929
18905
|
async getPriceFeed(connection, commitmentOrConfig) {
|
|
17930
18906
|
const [priceFeed] = this.deriver.priceFeed();
|
|
17931
18907
|
try {
|
|
@@ -17958,19 +18934,52 @@ function deriveLzComposeTypesAccountsPDA(program, oappId) {
|
|
|
17958
18934
|
return web314.PublicKey.findProgramAddressSync([Buffer.from(LZ_COMPOSE_TYPES_SEED, "utf8")], program);
|
|
17959
18935
|
}
|
|
17960
18936
|
var BaseOApp = class {
|
|
18937
|
+
/**
|
|
18938
|
+
* Creates an instance of the BaseOApp class.
|
|
18939
|
+
*
|
|
18940
|
+
* @param {PublicKey} program - The program public key.
|
|
18941
|
+
*/
|
|
17961
18942
|
constructor(program) {
|
|
17962
18943
|
this.program = program;
|
|
17963
18944
|
this.oappBaseDeriver = new OAppBasePDADeriver(program);
|
|
17964
18945
|
}
|
|
18946
|
+
/**
|
|
18947
|
+
* Queries the ID PDA info.
|
|
18948
|
+
*
|
|
18949
|
+
* @param {Connection} connection - The connection.
|
|
18950
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment or config.
|
|
18951
|
+
* @returns {Promise<AccountInfo<Buffer> | null>} The account info.
|
|
18952
|
+
*/
|
|
17965
18953
|
async queryIDPDAInfo(connection, commitmentOrConfig) {
|
|
17966
18954
|
return this.queryPDAInfo(connection, this.idPDA()[0], commitmentOrConfig);
|
|
17967
18955
|
}
|
|
18956
|
+
/**
|
|
18957
|
+
* Queries the PDA info.
|
|
18958
|
+
*
|
|
18959
|
+
* @param {Connection} connection - The connection.
|
|
18960
|
+
* @param {PublicKey} pda - The PDA public key.
|
|
18961
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment or config.
|
|
18962
|
+
* @returns {Promise<AccountInfo<Buffer> | null>} The account info.
|
|
18963
|
+
*/
|
|
17968
18964
|
async queryPDAInfo(connection, pda, commitmentOrConfig) {
|
|
17969
18965
|
return connection.getAccountInfo(pda, commitmentOrConfig);
|
|
17970
18966
|
}
|
|
18967
|
+
/**
|
|
18968
|
+
* Gets the ID PDA.
|
|
18969
|
+
*
|
|
18970
|
+
* @returns {[PublicKey, number]} The ID PDA and bump.
|
|
18971
|
+
*/
|
|
17971
18972
|
idPDA() {
|
|
17972
18973
|
return oappIDPDA(this.program);
|
|
17973
18974
|
}
|
|
18975
|
+
/**
|
|
18976
|
+
* Gets the remote.
|
|
18977
|
+
*
|
|
18978
|
+
* @param {Connection} connection - The connection.
|
|
18979
|
+
* @param {number} dstEid - The destination endpoint ID.
|
|
18980
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment or config.
|
|
18981
|
+
* @returns {Promise<Uint8Array | null>} The remote data.
|
|
18982
|
+
*/
|
|
17974
18983
|
async getRemote(connection, dstEid, commitmentOrConfig) {
|
|
17975
18984
|
const [remotePDA] = this.oappBaseDeriver.remote(dstEid);
|
|
17976
18985
|
const info = await this.queryPDAInfo(connection, remotePDA, commitmentOrConfig);
|
|
@@ -18072,6 +19081,13 @@ function createVersionInstructionAccounts3(programId) {
|
|
|
18072
19081
|
var PROGRAM_ADDRESS7 = "2XrYqmhBMPJgDsb4SVbjV1PnJBprurd5bzRCkHwiFCJB";
|
|
18073
19082
|
var PROGRAM_ID7 = new web314.PublicKey(PROGRAM_ADDRESS7);
|
|
18074
19083
|
var SendHelper = class {
|
|
19084
|
+
/**
|
|
19085
|
+
* Creates an instance of the SendHelper class.
|
|
19086
|
+
*
|
|
19087
|
+
* @param {PublicKey} [endpointProgram=EndpointProgram.PROGRAM_ID] - The endpoint program public key.
|
|
19088
|
+
* @param {PublicKey} [ulnProgram=UlnProgram.PROGRAM_ID] - The ULN program public key.
|
|
19089
|
+
* @param {PublicKey} [simpleMsgLibProgram=SimpleMessageLibProgram.PROGRAM_ID] - The simple message library program public key.
|
|
19090
|
+
*/
|
|
18075
19091
|
constructor(endpointProgram = endpoint_exports.PROGRAM_ID, ulnProgram = uln_exports.PROGRAM_ID, simpleMsgLibProgram = simple_message_lib_exports.PROGRAM_ID) {
|
|
18076
19092
|
this.endpointProgram = endpointProgram;
|
|
18077
19093
|
this.ulnProgram = ulnProgram;
|
|
@@ -18081,6 +19097,14 @@ var SendHelper = class {
|
|
|
18081
19097
|
this.uln = new uln_exports.Uln(ulnProgram);
|
|
18082
19098
|
this.simpleMsgLib = new simple_message_lib_exports.SimpleMessageLib(simpleMsgLibProgram);
|
|
18083
19099
|
}
|
|
19100
|
+
/**
|
|
19101
|
+
* Fetches multiple account information.
|
|
19102
|
+
*
|
|
19103
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
19104
|
+
* @param {PublicKey[]} keys - The public keys of the accounts.
|
|
19105
|
+
* @param {Commitment | GetAccountInfoConfig} [commitment] - The commitment level or account info configuration.
|
|
19106
|
+
* @returns {Promise<(AccountInfo<Buffer> | null)[]>} A promise that resolves to an array of account information.
|
|
19107
|
+
*/
|
|
18084
19108
|
async getMultipleAccountsInfo(connection, keys, commitment) {
|
|
18085
19109
|
const missingKeys = keys.filter((key) => !this.accounts.has(key.toBase58()));
|
|
18086
19110
|
if (missingKeys.length > 0) {
|
|
@@ -18091,6 +19115,17 @@ var SendHelper = class {
|
|
|
18091
19115
|
}
|
|
18092
19116
|
return keys.map((key) => this.accounts.get(key.toBase58()));
|
|
18093
19117
|
}
|
|
19118
|
+
/**
|
|
19119
|
+
* Gets the account metadata for the quote instruction.
|
|
19120
|
+
*
|
|
19121
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
19122
|
+
* @param {PublicKey} payer - The payer public key.
|
|
19123
|
+
* @param {PublicKey} sender - The sender public key.
|
|
19124
|
+
* @param {number} dstEid - The destination endpoint ID.
|
|
19125
|
+
* @param {string} receiver - The receiver address.
|
|
19126
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig='confirmed'] - The commitment level or account info configuration.
|
|
19127
|
+
* @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
|
|
19128
|
+
*/
|
|
18094
19129
|
async getQuoteAccounts(connection, payer, sender, dstEid, receiver, commitmentOrConfig = "confirmed") {
|
|
18095
19130
|
const [sendLibConfig] = this.endpoint.deriver.sendLibraryConfig(sender, dstEid);
|
|
18096
19131
|
const [defaultSendLibConfig] = this.endpoint.deriver.defaultSendLibraryConfig(dstEid);
|
|
@@ -18110,7 +19145,7 @@ var SendHelper = class {
|
|
|
18110
19145
|
[sendLibConfig, defaultSendLibConfig, simpleMsgLib, uln, ulnDefaultSendConfig, ulnSendConfig],
|
|
18111
19146
|
commitmentOrConfig
|
|
18112
19147
|
);
|
|
18113
|
-
|
|
19148
|
+
invariant3__default.default(defaultSendLibConfigBuf && sendLibConfigBuf, "endpoint send library not initialized");
|
|
18114
19149
|
const [sendLibConfigInfo] = endpoint_exports.accounts.SendLibraryConfig.fromAccountInfo(sendLibConfigBuf, 0);
|
|
18115
19150
|
const [defaultSendLibConfigInfo] = endpoint_exports.accounts.SendLibraryConfig.fromAccountInfo(
|
|
18116
19151
|
defaultSendLibConfigBuf,
|
|
@@ -18149,14 +19184,16 @@ var SendHelper = class {
|
|
|
18149
19184
|
);
|
|
18150
19185
|
}
|
|
18151
19186
|
/**
|
|
18152
|
-
*
|
|
18153
|
-
*
|
|
18154
|
-
* @param
|
|
18155
|
-
* @param
|
|
18156
|
-
* @param
|
|
18157
|
-
* @param
|
|
18158
|
-
*
|
|
18159
|
-
*
|
|
19187
|
+
* Gets the account metadata for the send instruction.
|
|
19188
|
+
*
|
|
19189
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
19190
|
+
* @param {PublicKey} payer - The payer public key.
|
|
19191
|
+
* @param {PublicKey} sender - The sender public key.
|
|
19192
|
+
* @param {number} dstEid - The destination endpoint ID.
|
|
19193
|
+
* @param {string} receiver - The receiver address.
|
|
19194
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig='confirmed'] - The commitment level or account info configuration.
|
|
19195
|
+
* @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
|
|
19196
|
+
*/
|
|
18160
19197
|
async getSendAccounts(connection, payer, sender, dstEid, receiver, commitmentOrConfig = "confirmed") {
|
|
18161
19198
|
const [sendLibConfig] = this.endpoint.deriver.sendLibraryConfig(sender, dstEid);
|
|
18162
19199
|
const [defaultSendLibConfig] = this.endpoint.deriver.defaultSendLibraryConfig(dstEid);
|
|
@@ -18176,7 +19213,7 @@ var SendHelper = class {
|
|
|
18176
19213
|
[sendLibConfig, defaultSendLibConfig, simpleMsgLib, uln, ulnDefaultSendConfig, ulnSendConfig],
|
|
18177
19214
|
commitmentOrConfig
|
|
18178
19215
|
);
|
|
18179
|
-
|
|
19216
|
+
invariant3__default.default(defaultSendLibConfigBuf && sendLibConfigBuf, "endpoint send library not initialized");
|
|
18180
19217
|
const [sendLibConfigInfo] = endpoint_exports.accounts.SendLibraryConfig.fromAccountInfo(sendLibConfigBuf, 0);
|
|
18181
19218
|
const [defaultSendLibConfigInfo] = endpoint_exports.accounts.SendLibraryConfig.fromAccountInfo(
|
|
18182
19219
|
defaultSendLibConfigBuf,
|
|
@@ -18214,11 +19251,22 @@ var SendHelper = class {
|
|
|
18214
19251
|
)
|
|
18215
19252
|
);
|
|
18216
19253
|
}
|
|
19254
|
+
/**
|
|
19255
|
+
* Gets the account metadata for the endpoint.
|
|
19256
|
+
*
|
|
19257
|
+
* @param {PublicKey} msgLibProgram - The message library program public key.
|
|
19258
|
+
* @param {PublicKey} msgLib - The message library public key.
|
|
19259
|
+
* @param {PublicKey} sender - The sender public key.
|
|
19260
|
+
* @param {number} dstEid - The destination endpoint ID.
|
|
19261
|
+
* @param {string} receiver - The receiver address.
|
|
19262
|
+
* @param {QuoteOrSend} quoteOrSend - The quote or send action.
|
|
19263
|
+
* @returns {AccountMeta[]} An array of account metadata.
|
|
19264
|
+
*/
|
|
18217
19265
|
getEndpointAccounts(msgLibProgram, msgLib, sender, dstEid, receiver, quoteOrSend) {
|
|
18218
19266
|
const [sendLibraryConfig] = this.endpoint.deriver.sendLibraryConfig(sender, dstEid);
|
|
18219
19267
|
const [defaultSendLibraryConfig] = this.endpoint.deriver.defaultSendLibraryConfig(dstEid);
|
|
18220
19268
|
const [sendLibraryInfo] = this.endpoint.deriver.messageLibraryInfo(msgLib);
|
|
18221
|
-
const [nonce] = this.endpoint.deriver.nonce(sender, dstEid, addressToBytes32(receiver));
|
|
19269
|
+
const [nonce] = this.endpoint.deriver.nonce(sender, dstEid, lzV2Utilities.addressToBytes32(receiver));
|
|
18222
19270
|
let accounts;
|
|
18223
19271
|
if (quoteOrSend === 0 /* Quote */) {
|
|
18224
19272
|
accounts = endpoint_exports.instructions.createQuoteInstructionAccounts(
|
|
@@ -18260,6 +19308,13 @@ var SendHelper = class {
|
|
|
18260
19308
|
}
|
|
18261
19309
|
].concat(accounts);
|
|
18262
19310
|
}
|
|
19311
|
+
/**
|
|
19312
|
+
* Gets the account metadata for the simple message library.
|
|
19313
|
+
*
|
|
19314
|
+
* @param {PublicKey} payer - The payer public key.
|
|
19315
|
+
* @param {QuoteOrSend} quoteOrSend - The quote or send action.
|
|
19316
|
+
* @returns {AccountMeta[]} An array of account metadata.
|
|
19317
|
+
*/
|
|
18263
19318
|
getSimpleMsgLibAccounts(payer, quoteOrSend) {
|
|
18264
19319
|
const [msgLib] = this.simpleMsgLib.deriver.messageLib();
|
|
18265
19320
|
let accounts;
|
|
@@ -18290,9 +19345,20 @@ var SendHelper = class {
|
|
|
18290
19345
|
});
|
|
18291
19346
|
return accounts.slice(1);
|
|
18292
19347
|
}
|
|
18293
|
-
|
|
19348
|
+
/**
|
|
19349
|
+
* Gets the account metadata for the ULN.
|
|
19350
|
+
*
|
|
19351
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
19352
|
+
* @param {PublicKey} payer - The payer public key.
|
|
19353
|
+
* @param {KeyedAccountInfo} ulnInfo - The ULN account information.
|
|
19354
|
+
* @param {KeyedAccountInfo} ulnDefaultSendConfigInfo - The ULN default send configuration account information.
|
|
19355
|
+
* @param {KeyedAccountInfo} ulnSendConfigInfo - The ULN send configuration account information.
|
|
19356
|
+
* @param {QuoteOrSend} quoteOrSend - The quote or send action.
|
|
19357
|
+
* @param {Commitment | GetAccountInfoConfig} [commitment] - The commitment level or account info configuration.
|
|
19358
|
+
* @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
|
|
19359
|
+
*/
|
|
18294
19360
|
async getUlnAccounts(connection, payer, ulnInfo, ulnDefaultSendConfigInfo, ulnSendConfigInfo, quoteOrSend, commitment) {
|
|
18295
|
-
|
|
19361
|
+
invariant3__default.default(ulnInfo.accountInfo && ulnDefaultSendConfigInfo.accountInfo, "uln send library not initialized");
|
|
18296
19362
|
const [ulnState] = uln_exports.accounts.UlnSettings.fromAccountInfo(ulnInfo.accountInfo, 0);
|
|
18297
19363
|
const [defaultSendConfigState] = uln_exports.accounts.SendConfig.fromAccountInfo(
|
|
18298
19364
|
ulnDefaultSendConfigInfo.accountInfo,
|
|
@@ -18322,7 +19388,7 @@ var SendHelper = class {
|
|
|
18322
19388
|
[executor.executor, ...dvnsKey],
|
|
18323
19389
|
commitment
|
|
18324
19390
|
);
|
|
18325
|
-
|
|
19391
|
+
invariant3__default.default(executorBuf, `executor:${executor.executor.toBase58()} not initialized`);
|
|
18326
19392
|
let executorAccounts, dvnAccounts;
|
|
18327
19393
|
{
|
|
18328
19394
|
const executor2 = {
|
|
@@ -18330,7 +19396,7 @@ var SendHelper = class {
|
|
|
18330
19396
|
owner: executorBuf.owner
|
|
18331
19397
|
};
|
|
18332
19398
|
const dvns = dvnBuf.map((dvn, i) => {
|
|
18333
|
-
|
|
19399
|
+
invariant3__default.default(dvn, `dvn:${dvnsKey[i].toBase58()} not initialized`);
|
|
18334
19400
|
return {
|
|
18335
19401
|
config: accounts_exports3.DvnConfig.fromAccountInfo(dvn)[0],
|
|
18336
19402
|
owner: dvn.owner
|
|
@@ -18342,7 +19408,7 @@ var SendHelper = class {
|
|
|
18342
19408
|
});
|
|
18343
19409
|
const priceFeedInfos = await this.getMultipleAccountsInfo(connection, priceFeeds, commitment);
|
|
18344
19410
|
priceFeedInfos.forEach((info, i) => {
|
|
18345
|
-
|
|
19411
|
+
invariant3__default.default(info, `priceFeed:${priceFeeds[i].toBase58()} not initialized`);
|
|
18346
19412
|
});
|
|
18347
19413
|
executorAccounts = new Executor(executor2.owner).getQuoteIXAccountMetaForCPI(
|
|
18348
19414
|
executor2.config.priceFeed,
|
|
@@ -19940,6 +21006,9 @@ var types = [
|
|
|
19940
21006
|
|
|
19941
21007
|
// src/index.ts
|
|
19942
21008
|
var IdlTypes = {
|
|
21009
|
+
/**
|
|
21010
|
+
* The endpoint types.
|
|
21011
|
+
*/
|
|
19943
21012
|
endpoint: types
|
|
19944
21013
|
};
|
|
19945
21014
|
var SetConfigType2 = /* @__PURE__ */ ((SetConfigType3) => {
|