@layerzerolabs/lz-solana-sdk-v2 3.0.15 → 3.0.17

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/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 bytes = require('@ethersproject/bytes');
6
- var keccak256 = require('@ethersproject/keccak256');
7
- var invariant4 = require('tiny-invariant');
8
- var address = require('@ethersproject/address');
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 sha2 = require('@ethersproject/sha2');
14
+ var base58 = require('bs58');
19
15
 
20
16
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
21
17
 
@@ -39,30 +35,24 @@ function _interopNamespace(e) {
39
35
 
40
36
  var web314__namespace = /*#__PURE__*/_interopNamespace(web314);
41
37
  var BN__default = /*#__PURE__*/_interopDefault(BN);
42
- var invariant4__default = /*#__PURE__*/_interopDefault(invariant4);
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) {
54
- if (typeof require !== "undefined")
55
- return require.apply(this, arguments);
49
+ if (typeof require !== "undefined") return require.apply(this, arguments);
56
50
  throw Error('Dynamic require of "' + x + '" is not supported');
57
51
  });
58
52
  var __export = (target, all) => {
59
53
  for (var name in all)
60
54
  __defProp(target, name, { get: all[name], enumerable: true });
61
55
  };
62
- var __publicField = (obj, key, value) => {
63
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
64
- return value;
65
- };
66
56
  var ENDPOINT_SEED = "Endpoint";
67
57
  var MESSAGE_LIB_SEED = "MessageLib";
68
58
  var SEND_LIBRARY_CONFIG_SEED = "SendLibraryConfig";
@@ -91,12 +81,28 @@ var PEER_SEED = "Peer";
91
81
  var MINT_SEED = "Mint";
92
82
  var ENFORCED_OPTIONS_SEED = "EnforcedOptions";
93
83
  var EndpointPDADeriver = class {
84
+ /**
85
+ * Creates an instance of the EndpointPDADeriver class.
86
+ *
87
+ * @param {PublicKey} program - The program public key.
88
+ */
94
89
  constructor(program) {
95
90
  this.program = program;
96
91
  }
92
+ /**
93
+ * Derives the setting address.
94
+ *
95
+ * @returns {[PublicKey, number]} The derived address and bump seed.
96
+ */
97
97
  setting() {
98
98
  return web314.PublicKey.findProgramAddressSync([Buffer.from(ENDPOINT_SEED, "utf8")], this.program);
99
99
  }
100
+ /**
101
+ * Derives the default send library configuration address.
102
+ *
103
+ * @param {number} dstEndpointId - The destination endpoint ID.
104
+ * @returns {[PublicKey, number]} The derived address and bump seed.
105
+ */
100
106
  defaultSendLibraryConfig(dstEndpointId) {
101
107
  return web314.PublicKey.findProgramAddressSync(
102
108
  [
@@ -107,6 +113,13 @@ var EndpointPDADeriver = class {
107
113
  this.program
108
114
  );
109
115
  }
116
+ /**
117
+ * Derives the send library configuration address.
118
+ *
119
+ * @param {PublicKey} sender - The sender public key.
120
+ * @param {number} dstEndpointId - The destination endpoint ID.
121
+ * @returns {[PublicKey, number]} The derived address and bump seed.
122
+ */
110
123
  sendLibraryConfig(sender, dstEndpointId) {
111
124
  return web314.PublicKey.findProgramAddressSync(
112
125
  [
@@ -119,7 +132,10 @@ var EndpointPDADeriver = class {
119
132
  );
120
133
  }
121
134
  /**
122
- * @param messageLibrary PDA(derive by message lib program)
135
+ * Derives the message library information address.
136
+ *
137
+ * @param {PublicKey} messageLibrary - The message library public key, PDA(derive by message lib program)
138
+ * @returns {[PublicKey, number]} The derived address and bump seed.
123
139
  */
124
140
  messageLibraryInfo(messageLibrary) {
125
141
  return web314.PublicKey.findProgramAddressSync(
@@ -127,6 +143,12 @@ var EndpointPDADeriver = class {
127
143
  this.program
128
144
  );
129
145
  }
146
+ /**
147
+ * Derives the default receive library configuration address.
148
+ *
149
+ * @param {number} srcEndpointId - The source endpoint ID.
150
+ * @returns {[PublicKey, number]} The derived address and bump seed.
151
+ */
130
152
  defaultReceiveLibraryConfig(srcEndpointId) {
131
153
  return web314.PublicKey.findProgramAddressSync(
132
154
  [
@@ -137,6 +159,13 @@ var EndpointPDADeriver = class {
137
159
  this.program
138
160
  );
139
161
  }
162
+ /**
163
+ * Derives the receive library configuration address.
164
+ *
165
+ * @param {PublicKey} receiver - The receiver public key.
166
+ * @param {number} srcEndpointId - The source endpoint ID.
167
+ * @returns {[PublicKey, number]} The derived address and bump seed.
168
+ */
140
169
  receiveLibraryConfig(receiver, srcEndpointId) {
141
170
  return web314.PublicKey.findProgramAddressSync(
142
171
  [
@@ -161,9 +190,12 @@ var EndpointPDADeriver = class {
161
190
  );
162
191
  }
163
192
  /**
164
- * @param localOapp
165
- * @param remoteChainId
166
- * @param remoteOapp
193
+ * Derives the nonce address.
194
+ *
195
+ * @param {PublicKey} localOapp - The local OApp public key.
196
+ * @param {number} remoteChainId - The remote chain ID.
197
+ * @param {Uint8Array} remoteOapp - The remote OApp address.
198
+ * @returns {[PublicKey, number]} The derived address and bump seed.
167
199
  */
168
200
  nonce(localOapp, remoteChainId, remoteOapp) {
169
201
  return web314.PublicKey.findProgramAddressSync(
@@ -177,6 +209,14 @@ var EndpointPDADeriver = class {
177
209
  this.program
178
210
  );
179
211
  }
212
+ /**
213
+ * Derives the pending nonce address.
214
+ *
215
+ * @param {PublicKey} localOapp - The local OApp public key.
216
+ * @param {number} remoteChainId - The remote chain ID.
217
+ * @param {Uint8Array} remoteOapp - The remote OApp address.
218
+ * @returns {[PublicKey, number]} The derived address and bump seed.
219
+ */
180
220
  pendingNonce(localOapp, remoteChainId, remoteOapp) {
181
221
  return web314.PublicKey.findProgramAddressSync(
182
222
  [
@@ -188,19 +228,23 @@ var EndpointPDADeriver = class {
188
228
  this.program
189
229
  );
190
230
  }
231
+ /**
232
+ * Derives the OApp registry address.
233
+ *
234
+ * @param {PublicKey} localOapp - The local OApp public key.
235
+ * @returns {[PublicKey, number]} The derived address and bump seed.
236
+ */
191
237
  oappRegistry(localOapp) {
192
238
  return web314.PublicKey.findProgramAddressSync([Buffer.from(OAPP_SEED, "utf8"), localOapp.toBytes()], this.program);
193
239
  }
194
- /***
195
- * @param receiver
196
- * @param srcEid
197
- * @param sender
198
- * @param nonce
199
- * @param payloadHash
200
- * @srcChainId u32 to Uint8Array([0,0,0,0])
201
- * @sender [u8; 32] sender Address
202
- * @nonce u64 to Uint8Array([0,0,0,0,0,0,0,0])
203
- * @payloadHash [u8; 32]
240
+ /**
241
+ * Derives the payload hash address.
242
+ *
243
+ * @param {PublicKey} receiver - The receiver public key.
244
+ * @param {number} srcEid - The source endpoint ID.
245
+ * @param {Uint8Array} sender - The sender address.
246
+ * @param {number} nonce - The nonce.
247
+ * @returns {[PublicKey, number]} The derived address and bump seed.
204
248
  */
205
249
  payloadHash(receiver, srcEid, sender, nonce) {
206
250
  return web314.PublicKey.findProgramAddressSync(
@@ -214,6 +258,16 @@ var EndpointPDADeriver = class {
214
258
  this.program
215
259
  );
216
260
  }
261
+ /**
262
+ * Derives the composed message address.
263
+ *
264
+ * @param {PublicKey} from - The sender public key.
265
+ * @param {Uint8Array} guid - The GUID.
266
+ * @param {number} index - The index.
267
+ * @param {PublicKey} to - The receiver public key.
268
+ * @param {Uint8Array} messageHash - The message hash.
269
+ * @returns {[PublicKey, number]} The derived address and bump seed.
270
+ */
217
271
  composedMessage(from, guid, index, to, messageHash) {
218
272
  return web314.PublicKey.findProgramAddressSync(
219
273
  [
@@ -229,18 +283,42 @@ var EndpointPDADeriver = class {
229
283
  }
230
284
  };
231
285
  var MessageLibPDADeriver = class {
286
+ /**
287
+ * Creates an instance of the MessageLibPDADeriver class.
288
+ *
289
+ * @param {PublicKey} program - The program public key.
290
+ */
232
291
  constructor(program) {
233
292
  this.program = program;
234
293
  }
294
+ /**
295
+ * Derives the message library address.
296
+ *
297
+ * @returns {[PublicKey, number]} The derived address and bump seed.
298
+ */
235
299
  messageLib() {
236
300
  return web314.PublicKey.findProgramAddressSync([Buffer.from(MESSAGE_LIB_SEED, "utf8")], this.program);
237
301
  }
302
+ /**
303
+ * Derives the send configuration address.
304
+ *
305
+ * @param {number} eid - The endpoint ID.
306
+ * @param {PublicKey} oapp - The OApp public key.
307
+ * @returns {[PublicKey, number]} The derived address and bump seed.
308
+ */
238
309
  sendConfig(eid, oapp) {
239
310
  return web314.PublicKey.findProgramAddressSync(
240
311
  [Buffer.from(SEND_CONFIG_SEED, "utf8"), new BN__default.default(eid).toArrayLike(Buffer, "be", 4), oapp.toBuffer()],
241
312
  this.program
242
313
  );
243
314
  }
315
+ /**
316
+ * Derives the receive configuration address.
317
+ *
318
+ * @param {number} eid - The endpoint ID.
319
+ * @param {PublicKey} oapp - The OApp public key.
320
+ * @returns {[PublicKey, number]} The derived address and bump seed.
321
+ */
244
322
  receiveConfig(eid, oapp) {
245
323
  return web314.PublicKey.findProgramAddressSync(
246
324
  [Buffer.from(RECEIVE_CONFIG_SEED, "utf8"), new BN__default.default(eid).toArrayLike(Buffer, "be", 4), oapp.toBuffer()],
@@ -249,36 +327,79 @@ var MessageLibPDADeriver = class {
249
327
  }
250
328
  };
251
329
  var UlnPDADeriver = class extends MessageLibPDADeriver {
330
+ /**
331
+ * Derives the setting address.
332
+ *
333
+ * @returns {[PublicKey, number]} The derived address and bump seed.
334
+ */
252
335
  setting() {
253
336
  return web314.PublicKey.findProgramAddressSync([Buffer.from(ULN_SEED, "utf8")], this.program);
254
337
  }
338
+ /**
339
+ * Derives the configuration address.
340
+ *
341
+ * @param {number} eid - The endpoint ID.
342
+ * @returns {[PublicKey, number]} The derived address and bump seed.
343
+ */
255
344
  config(eid) {
256
345
  return web314.PublicKey.findProgramAddressSync(
257
346
  [Buffer.from(ULN_CONFIG_SEED, "utf8"), new BN__default.default(eid).toArrayLike(Buffer, "be", 4)],
258
347
  this.program
259
348
  );
260
349
  }
350
+ /**
351
+ * Derives the default send configuration address.
352
+ *
353
+ * @param {number} eid - The endpoint ID.
354
+ * @returns {[PublicKey, number]} The derived address and bump seed.
355
+ */
261
356
  defaultSendConfig(eid) {
262
357
  return web314.PublicKey.findProgramAddressSync(
263
358
  [Buffer.from(SEND_CONFIG_SEED, "utf8"), new BN__default.default(eid).toArrayLike(Buffer, "be", 4)],
264
359
  this.program
265
360
  );
266
361
  }
362
+ /**
363
+ * Derives the default receive configuration address.
364
+ *
365
+ * @param {number} eid - The endpoint ID.
366
+ * @returns {[PublicKey, number]} The derived address and bump seed.
367
+ */
267
368
  defaultReceiveConfig(eid) {
268
369
  return web314.PublicKey.findProgramAddressSync(
269
370
  [Buffer.from(RECEIVE_CONFIG_SEED, "utf8"), new BN__default.default(eid).toArrayLike(Buffer, "be", 4)],
270
371
  this.program
271
372
  );
272
373
  }
374
+ /**
375
+ * Derives the options address.
376
+ *
377
+ * @param {number} eit - The endpoint ID.
378
+ * @returns {[PublicKey, number]} The derived address and bump seed.
379
+ */
273
380
  options(eit) {
274
381
  return web314.PublicKey.findProgramAddressSync(
275
382
  [Buffer.from(OPTIONS_SEED, "utf8"), new BN__default.default(eit).toArrayLike(Buffer, "be", 4)],
276
383
  this.program
277
384
  );
278
385
  }
386
+ /**
387
+ * Derives the worker configuration address.
388
+ *
389
+ * @param {PublicKey} worker - The worker public key.
390
+ * @returns {[PublicKey, number]} The derived address and bump seed.
391
+ */
279
392
  workerConfig(worker) {
280
393
  return web314.PublicKey.findProgramAddressSync([Buffer.from(WORKER_SEED, "utf8"), worker.toBuffer()], this.program);
281
394
  }
395
+ /**
396
+ * Derives the confirmations address.
397
+ *
398
+ * @param {Uint8Array} headerHash - The header hash.
399
+ * @param {Uint8Array} payloadHash - The payload hash.
400
+ * @param {PublicKey} dvn - The DVN public key.
401
+ * @returns {[PublicKey, number]} The derived address and bump seed.
402
+ */
282
403
  confirmations(headerHash, payloadHash, dvn) {
283
404
  return web314.PublicKey.findProgramAddressSync(
284
405
  [Buffer.from(CONFIRMATIONS_SEED, "utf8"), headerHash, payloadHash, dvn.toBytes()],
@@ -287,18 +408,39 @@ var UlnPDADeriver = class extends MessageLibPDADeriver {
287
408
  }
288
409
  };
289
410
  var OAppBasePDADeriver = class {
411
+ /**
412
+ * Creates an instance of the OAppBasePDADeriver class.
413
+ *
414
+ * @param {PublicKey} program - The program public key.
415
+ */
290
416
  constructor(program) {
291
417
  this.program = program;
292
418
  }
419
+ /**
420
+ * Derives the remote address.
421
+ *
422
+ * @param {number} dstChainId - The destination chain ID.
423
+ * @returns {[PublicKey, number]} The derived address and bump seed.
424
+ */
293
425
  remote(dstChainId) {
294
426
  return web314.PublicKey.findProgramAddressSync(
295
427
  [Buffer.from(REMOTE_SEED), new BN__default.default(dstChainId).toArrayLike(Buffer, "be", 4)],
296
428
  this.program
297
429
  );
298
430
  }
431
+ /**
432
+ * Derives the LzReceive types accounts address.
433
+ *
434
+ * @returns {[PublicKey, number]} The derived address and bump seed.
435
+ */
299
436
  lzReceiveTypesAccounts() {
300
437
  return web314.PublicKey.findProgramAddressSync([Buffer.from(LZ_RECEIVE_TYPES_SEED, "utf8")], this.program);
301
438
  }
439
+ /**
440
+ * Derives the LzCompose types accounts address.
441
+ *
442
+ * @returns {[PublicKey, number]} The derived address and bump seed.
443
+ */
302
444
  lzComposeTypesAccounts() {
303
445
  return web314.PublicKey.findProgramAddressSync([Buffer.from(LZ_COMPOSE_TYPES_SEED, "utf8")], this.program);
304
446
  }
@@ -307,36 +449,82 @@ var DVNDeriver = class {
307
449
  constructor(program) {
308
450
  this.program = program;
309
451
  }
452
+ /**
453
+ * Derives the authority address.
454
+ *
455
+ * @returns {[PublicKey, number]} The derived address and bump seed.
456
+ */
310
457
  authority() {
311
458
  return web314.PublicKey.findProgramAddressSync([Buffer.from("dvn", "utf8")], this.program);
312
459
  }
460
+ /**
461
+ * Derives the configuration address.
462
+ *
463
+ * @returns {[PublicKey, number]} The derived address and bump seed.
464
+ */
313
465
  config() {
314
466
  return web314.PublicKey.findProgramAddressSync([Buffer.from(DVN_CONFIG_SEED, "utf8")], this.program);
315
467
  }
468
+ /**
469
+ * Derives the execute hash address.
470
+ *
471
+ * @param {Buffer} digestHash - The digest hash.
472
+ * @returns {[PublicKey, number]} The derived address and bump seed.
473
+ */
316
474
  executeHash(digestHash) {
317
475
  return web314.PublicKey.findProgramAddressSync([Buffer.from("ExecuteHash", "utf8"), digestHash], this.program);
318
476
  }
319
477
  };
320
478
  var EventPDADeriver = class {
479
+ /**
480
+ * Creates an instance of the EventPDADeriver class.
481
+ *
482
+ * @param {PublicKey} program - The program public key.
483
+ */
321
484
  constructor(program) {
322
485
  this.program = program;
323
486
  }
487
+ /**
488
+ * Derives the event authority PDA.
489
+ *
490
+ * @returns {[PublicKey, number]} The event authority PDA and bump seed.
491
+ */
324
492
  eventAuthority() {
325
493
  return web314.PublicKey.findProgramAddressSync([Buffer.from(EVENT_SEED, "utf8")], this.program);
326
494
  }
327
495
  };
328
496
  var ExecutorPDADeriver = class {
497
+ /**
498
+ * Creates an instance of the ExecutorPDADeriver class.
499
+ *
500
+ * @param {PublicKey} program - The program public key.
501
+ */
329
502
  constructor(program) {
330
503
  this.program = program;
331
504
  }
505
+ /**
506
+ * Derives the executor configuration PDA.
507
+ *
508
+ * @returns {[PublicKey, number]} The executor configuration PDA and bump seed.
509
+ */
332
510
  config() {
333
511
  return web314.PublicKey.findProgramAddressSync([Buffer.from(EXECUTOR_CONFIG_SEED, "utf8")], this.program);
334
512
  }
335
513
  };
336
514
  var PriceFeedPDADeriver = class {
515
+ /**
516
+ * Creates an instance of the PriceFeedPDADeriver class.
517
+ *
518
+ * @param {PublicKey} program - The program public key.
519
+ */
337
520
  constructor(program) {
338
521
  this.program = program;
339
522
  }
523
+ /**
524
+ * Derives the price feed PDA.
525
+ *
526
+ * @returns {[PublicKey, number]} The price feed PDA and bump seed.
527
+ */
340
528
  priceFeed() {
341
529
  return web314.PublicKey.findProgramAddressSync([Buffer.from(PRICE_FEED_SEED, "utf8")], this.program);
342
530
  }
@@ -355,138 +543,6 @@ __export(endpoint_exports, {
355
543
  instructions: () => instructions_exports,
356
544
  types: () => types_exports
357
545
  });
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
546
 
491
547
  // src/generated/endpoint/accounts/index.ts
492
548
  var accounts_exports = {};
@@ -5865,6 +5921,11 @@ var sendLibrarySetEventBeet = new beet159__namespace.BeetArgsStruct(
5865
5921
  var EventEmitDiscriminator = "e445a52e51cb9a1d";
5866
5922
  var DefaultMessageLib = web314.PublicKey.default;
5867
5923
  var Endpoint = class {
5924
+ /**
5925
+ * Creates an instance of the Endpoint class.
5926
+ *
5927
+ * @param {PublicKey} program - The program public key.
5928
+ */
5868
5929
  constructor(program) {
5869
5930
  this.program = program;
5870
5931
  this.deriver = new EndpointPDADeriver(program);
@@ -5872,7 +5933,12 @@ var Endpoint = class {
5872
5933
  this.eventAuthorityPDA = eventAuthorityPDA;
5873
5934
  }
5874
5935
  /**
5875
- * init endpoint settings, including eid, admin, it also registers the blocked message lib
5936
+ * Initializes the endpoint settings, including eid and admin, and registers the blocked message library.
5937
+ *
5938
+ * @param {number} endpointId - The endpoint ID.
5939
+ * @param {PublicKey} payer - The payer public key.
5940
+ * @param {PublicKey} admin - The admin public key.
5941
+ * @returns {TransactionInstruction} The transaction instruction.
5876
5942
  */
5877
5943
  initEndpoint(endpointId, payer, admin) {
5878
5944
  const [settingPDA] = this.deriver.setting();
@@ -5891,8 +5957,14 @@ var Endpoint = class {
5891
5957
  );
5892
5958
  }
5893
5959
  // async initOrUpdateConfig(connection:Connection,)
5894
- /***
5960
+ /**
5961
+ * Registers a library.
5895
5962
  * call this function after endpoint initialized. Only admin can call this function.
5963
+ *
5964
+ * @param {PublicKey} admin - The admin public key.
5965
+ * @param {PublicKey} messageLibProgram - The message library program public key.
5966
+ * @param {types.MessageLibType} [libType=types.MessageLibType.SendAndReceive] - The library type.
5967
+ * @returns {TransactionInstruction} The transaction instruction.
5896
5968
  */
5897
5969
  registerLibrary(admin, messageLibProgram, libType = 2 /* SendAndReceive */) {
5898
5970
  const [msgLibPda] = new MessageLibPDADeriver(messageLibProgram).messageLib();
@@ -5915,6 +5987,16 @@ var Endpoint = class {
5915
5987
  this.program
5916
5988
  );
5917
5989
  }
5990
+ /**
5991
+ * Sets the default send library.
5992
+ *
5993
+ * @param {Connection} connection - The connection to the Solana cluster.
5994
+ * @param {PublicKey} admin - The admin public key.
5995
+ * @param {PublicKey} messageLibProgram - The message library program public key.
5996
+ * @param {number} dstEid - The destination endpoint ID.
5997
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
5998
+ * @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
5999
+ */
5918
6000
  async setDefaultSendLibrary(connection, admin, messageLibProgram, dstEid, commitmentOrConfig) {
5919
6001
  const [msgLib] = new MessageLibPDADeriver(messageLibProgram).messageLib();
5920
6002
  const [defaultSendLibConfig] = this.deriver.defaultSendLibraryConfig(dstEid);
@@ -5967,6 +6049,16 @@ var Endpoint = class {
5967
6049
  );
5968
6050
  }
5969
6051
  }
6052
+ /**
6053
+ * Sets the default receive library.
6054
+ *
6055
+ * @param {Connection} connection - The connection to the Solana cluster.
6056
+ * @param {PublicKey} admin - The admin public key.
6057
+ * @param {PublicKey} messageLibProgram - The message library program public key.
6058
+ * @param {number} srcEid - The source endpoint ID.
6059
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
6060
+ * @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
6061
+ */
5970
6062
  async setDefaultReceiveLibrary(connection, admin, messageLibProgram, srcEid, commitmentOrConfig) {
5971
6063
  const [msgLib] = new MessageLibPDADeriver(messageLibProgram).messageLib();
5972
6064
  const [defaultReceiveLibConfig] = this.deriver.defaultReceiveLibraryConfig(srcEid);
@@ -6021,6 +6113,16 @@ var Endpoint = class {
6021
6113
  );
6022
6114
  }
6023
6115
  }
6116
+ /**
6117
+ * Initializes the OApp configuration.
6118
+ *
6119
+ * @param {PublicKey} delegate - The delegate public key.
6120
+ * @param {MessageLibInterface} msgLibSDK - The message library SDK.
6121
+ * @param {PublicKey} payer - The payer public key.
6122
+ * @param {PublicKey} oappID - The OApp ID public key.
6123
+ * @param {number} eid - The endpoint ID.
6124
+ * @returns {TransactionInstruction} The transaction instruction.
6125
+ */
6024
6126
  initOAppConfig(delegate, msgLibSDK, payer, oappID, eid) {
6025
6127
  const [msgLib] = new MessageLibPDADeriver(msgLibSDK.program).messageLib();
6026
6128
  const [oappRegistry] = this.deriver.oappRegistry(oappID);
@@ -6043,6 +6145,15 @@ var Endpoint = class {
6043
6145
  this.program
6044
6146
  );
6045
6147
  }
6148
+ /**
6149
+ * Initializes the OApp nonce.
6150
+ *
6151
+ * @param {PublicKey} delegate - The delegate public key.
6152
+ * @param {number} dstEid - The destination endpoint ID.
6153
+ * @param {PublicKey} oappIDPDA - The OApp ID PDA.
6154
+ * @param {Uint8Array} remoteOappAddr - The remote OApp address.
6155
+ * @returns {TransactionInstruction} The transaction instruction.
6156
+ */
6046
6157
  initOAppNonce(delegate, dstEid, oappIDPDA2, remoteOappAddr) {
6047
6158
  const [nonce] = this.deriver.nonce(oappIDPDA2, dstEid, remoteOappAddr);
6048
6159
  const [pendingNonce] = this.deriver.pendingNonce(oappIDPDA2, dstEid, remoteOappAddr);
@@ -6064,6 +6175,14 @@ var Endpoint = class {
6064
6175
  this.program
6065
6176
  );
6066
6177
  }
6178
+ /**
6179
+ * Initializes the send library.
6180
+ *
6181
+ * @param {PublicKey} delegate - The delegate public key.
6182
+ * @param {PublicKey} sender - The sender public key.
6183
+ * @param {number} dstEid - The destination endpoint ID.
6184
+ * @returns {TransactionInstruction} The transaction instruction.
6185
+ */
6067
6186
  initSendLibrary(delegate, sender, dstEid) {
6068
6187
  const [oappRegistry] = this.deriver.oappRegistry(sender);
6069
6188
  const [sendLibraryConfig] = this.deriver.sendLibraryConfig(sender, dstEid);
@@ -6082,6 +6201,15 @@ var Endpoint = class {
6082
6201
  this.program
6083
6202
  );
6084
6203
  }
6204
+ /**
6205
+ * Sets the send library.
6206
+ *
6207
+ * @param {PublicKey} oappAdmin - The OApp admin public key.
6208
+ * @param {PublicKey} oappIDPDA - The OApp ID PDA.
6209
+ * @param {PublicKey} newSendLibProgram - The new send library program public key.
6210
+ * @param {number} dstEid - The destination endpoint ID.
6211
+ * @returns {TransactionInstruction} The transaction instruction.
6212
+ */
6085
6213
  setSendLibrary(oappAdmin, oappIDPDA2, newSendLibProgram, dstEid) {
6086
6214
  const [newSendLib] = new MessageLibPDADeriver(newSendLibProgram).messageLib();
6087
6215
  const [sendLibraryConfig] = this.deriver.sendLibraryConfig(oappIDPDA2, dstEid);
@@ -6107,6 +6235,14 @@ var Endpoint = class {
6107
6235
  );
6108
6236
  return ix;
6109
6237
  }
6238
+ /**
6239
+ * Initializes the receive library.
6240
+ *
6241
+ * @param {PublicKey} delegate - The delegate public key.
6242
+ * @param {PublicKey} receiver - The receiver public key.
6243
+ * @param {number} srcEid - The source endpoint ID.
6244
+ * @returns {TransactionInstruction} The transaction instruction.
6245
+ */
6110
6246
  initReceiveLibrary(delegate, receiver, srcEid) {
6111
6247
  const [oappRegistry] = this.deriver.oappRegistry(receiver);
6112
6248
  const [receiveLibraryConfig] = this.deriver.receiveLibraryConfig(receiver, srcEid);
@@ -6125,6 +6261,16 @@ var Endpoint = class {
6125
6261
  this.program
6126
6262
  );
6127
6263
  }
6264
+ /**
6265
+ * Sets the receive library.
6266
+ *
6267
+ * @param {PublicKey} oappAdmin - The OApp admin public key.
6268
+ * @param {PublicKey} oappIDPDA - The OApp ID PDA.
6269
+ * @param {PublicKey} newReceiveLibProgram - The new receive library program public key.
6270
+ * @param {number} srcEid - The source endpoint ID.
6271
+ * @param {bigint | number} [gracePeriod] - The grace period.
6272
+ * @returns {TransactionInstruction} The transaction instruction.
6273
+ */
6128
6274
  setReceiveLibrary(oappAdmin, oappIDPDA2, newReceiveLibProgram, srcEid, gracePeriod) {
6129
6275
  const [newReceiveLib] = new MessageLibPDADeriver(newReceiveLibProgram).messageLib();
6130
6276
  const [receiveLibraryConfig] = this.deriver.receiveLibraryConfig(oappIDPDA2, srcEid);
@@ -6151,6 +6297,21 @@ var Endpoint = class {
6151
6297
  );
6152
6298
  return ix;
6153
6299
  }
6300
+ /**
6301
+ * Sets the OApp configuration.
6302
+ *
6303
+ * @param {Connection} connection - The connection to the Solana cluster.
6304
+ * @param {PublicKey} oappDelegate - The OApp delegate public key.
6305
+ * @param {PublicKey} oappID - The OApp ID public key.
6306
+ * @param {PublicKey} msgLibProgram - The message library program public key.
6307
+ * @param {number} eid - The endpoint ID.
6308
+ * @param {object} config - The configuration object.
6309
+ * @param {SetConfigType} config.configType - The configuration type.
6310
+ * @param {UlnProgram.types.ExecutorConfig | UlnProgram.types.UlnConfig} config.value - The configuration value.
6311
+ * @param {Commitment} [commitment='confirmed'] - The commitment level.
6312
+ * @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
6313
+ * @throws {Error} If the message library version is unsupported.
6314
+ */
6154
6315
  async setOappConfig(connection, oappDelegate, oappID, msgLibProgram, eid, config, commitment = "confirmed") {
6155
6316
  const [msgLib] = new MessageLibPDADeriver(msgLibProgram).messageLib();
6156
6317
  const [msgLibInfo] = this.deriver.messageLibraryInfo(msgLib);
@@ -6188,7 +6349,9 @@ var Endpoint = class {
6188
6349
  return ix;
6189
6350
  }
6190
6351
  /// send a simulated transaction to the endpoint to get the fee for sending a message
6191
- /***
6352
+ /**
6353
+ *
6354
+ * Gets the account metadata for the CPI (Cross-Program Invocation) of the quote instruction.
6192
6355
  *
6193
6356
  * caculate the fee for sending a message with ULN:
6194
6357
  * 1. executorFee: feeForGas + feeForOptionType
@@ -6199,11 +6362,18 @@ var Endpoint = class {
6199
6362
  *
6200
6363
  * The priceRatioDenominator is 10^20
6201
6364
  * totalFee = executorFee + oracleFee * numOracles(requiredOracles + optionalOracles)
6365
+ *
6366
+ * @param {Connection} connection - The connection to the Solana cluster.
6367
+ * @param {PublicKey} payer - The payer public key.
6368
+ * @param {PacketPath} path - The packet path.
6369
+ * @param {MessageLibInterface} msgLibProgram - The message library program.
6370
+ * @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
6371
+ * @throws {Error} If the default send library is not initialized or the message library is blocked.
6202
6372
  */
6203
6373
  async getQuoteIXAccountMetaForCPI(connection, payer, path, msgLibProgram) {
6204
6374
  const { sender: sender_, dstEid, receiver: receiver_ } = path;
6205
- const sender = new web314.PublicKey(bytes.arrayify(sender_));
6206
- const receiver = addressToBytes32(receiver_);
6375
+ const sender = new web314.PublicKey(lzUtilities.arrayify(sender_));
6376
+ const receiver = lzV2Utilities.addressToBytes32(receiver_);
6207
6377
  const sendLibInfo = await this.getSendLibrary(connection, sender, dstEid);
6208
6378
  if (!sendLibInfo?.programId) {
6209
6379
  throw new Error("default send library not initialized or blocked message lib");
@@ -6237,13 +6407,21 @@ var Endpoint = class {
6237
6407
  ].concat(accounts)
6238
6408
  );
6239
6409
  }
6240
- /***
6241
- * Get the account meta of the send instruction for CPI(Cross-Program Invocation )
6410
+ /**
6411
+ * Gets the account metadata for the CPI (Cross-Program Invocation) of the send instruction.
6412
+ *
6413
+ * @param {Connection} connection - The connection to the Solana cluster.
6414
+ * @param {PublicKey} payer - The payer public key.
6415
+ * @param {PacketPath} path - The packet path.
6416
+ * @param {MessageLibInterface} msgLibProgram - The message library program.
6417
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
6418
+ * @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
6419
+ * @throws {Error} If the default send library is not initialized or the message library is blocked.
6242
6420
  */
6243
6421
  async getSendIXAccountMetaForCPI(connection, payer, path, msgLibProgram, commitmentOrConfig) {
6244
6422
  const { sender: sender_, dstEid, receiver: receiver_ } = path;
6245
- const sender = new web314.PublicKey(bytes.arrayify(sender_));
6246
- const receiver = addressToBytes32(receiver_);
6423
+ const sender = new web314.PublicKey(lzUtilities.arrayify(sender_));
6424
+ const receiver = lzV2Utilities.addressToBytes32(receiver_);
6247
6425
  const info = await this.getSendLibrary(connection, sender, dstEid, commitmentOrConfig);
6248
6426
  if (!info?.programId) {
6249
6427
  throw new Error("default send library not initialized or blocked message lib");
@@ -6282,8 +6460,18 @@ var Endpoint = class {
6282
6460
  }
6283
6461
  ].concat(accounts);
6284
6462
  }
6463
+ /**
6464
+ * Skips a message.
6465
+ *
6466
+ * @param {PublicKey} payer - The payer public key.
6467
+ * @param {PublicKey} sender - The sender public key.
6468
+ * @param {PublicKey} receiver - The receiver public key.
6469
+ * @param {number} srcEid - The source endpoint ID.
6470
+ * @param {string} nonce - The nonce.
6471
+ * @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
6472
+ */
6285
6473
  async skip(payer, sender, receiver, srcEid, nonce) {
6286
- const [nonceAccount] = this.deriver.nonce(receiver, srcEid, addressToBytes32(sender.toBase58()));
6474
+ const [nonceAccount] = this.deriver.nonce(receiver, srcEid, lzV2Utilities.addressToBytes32(sender.toBase58()));
6287
6475
  const [payloadHash] = this.deriver.payloadHash(receiver, srcEid, sender.toBytes(), parseInt(nonce));
6288
6476
  const [pendingInboundNonce] = this.deriver.pendingNonce(receiver, srcEid, sender.toBytes());
6289
6477
  const [oAppRegistry] = web314.PublicKey.findProgramAddressSync(
@@ -6313,8 +6501,20 @@ var Endpoint = class {
6313
6501
  );
6314
6502
  return Promise.resolve(ix);
6315
6503
  }
6504
+ /**
6505
+ * Initializes the verification process.
6506
+ *
6507
+ * @param {Connection} connection - The connection to the Solana cluster.
6508
+ * @param {PublicKey} payer - The payer public key.
6509
+ * @param {PublicKey} sender - The sender public key.
6510
+ * @param {PublicKey} receiver - The receiver public key.
6511
+ * @param {number} srcEid - The source endpoint ID.
6512
+ * @param {string} nonce - The nonce.
6513
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
6514
+ * @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
6515
+ */
6316
6516
  async initVerify(connection, payer, sender, receiver, srcEid, nonce, commitmentOrConfig) {
6317
- const [nonceAccount] = this.deriver.nonce(receiver, srcEid, addressToBytes32(sender.toBase58()));
6517
+ const [nonceAccount] = this.deriver.nonce(receiver, srcEid, lzV2Utilities.addressToBytes32(sender.toBase58()));
6318
6518
  const [payloadHash] = this.deriver.payloadHash(receiver, srcEid, sender.toBytes(), parseInt(nonce));
6319
6519
  const payloadHashInfo = await connection.getAccountInfo(payloadHash, commitmentOrConfig);
6320
6520
  if (payloadHashInfo) {
@@ -6337,10 +6537,17 @@ var Endpoint = class {
6337
6537
  this.program
6338
6538
  );
6339
6539
  }
6540
+ /**
6541
+ * Gets the account metadata for the CPI (Cross-Program Invocation) of the verify instruction.
6542
+ *
6543
+ * @param {PacketV1Codec} packet - The packet.
6544
+ * @param {PublicKey} receiveLibrary - The receive library public key.
6545
+ * @returns {AccountMeta[]} An array of account metadata.
6546
+ */
6340
6547
  getVerifyIXAccountMetaForCPI(packet, receiveLibrary) {
6341
6548
  const receiver = new web314.PublicKey(Buffer.from(packet.receiver().slice(2), "hex"));
6342
6549
  const srcEid = packet.srcEid();
6343
- const sender = addressToBytes32(packet.sender());
6550
+ const sender = lzV2Utilities.addressToBytes32(packet.sender());
6344
6551
  const [payloadHash] = this.deriver.payloadHash(receiver, srcEid, sender, parseInt(packet.nonce()));
6345
6552
  const [defaultReceiveLibraryConfig] = this.deriver.defaultReceiveLibraryConfig(srcEid);
6346
6553
  const [receiveLibraryConfig] = this.deriver.receiveLibraryConfig(receiver, srcEid);
@@ -6532,6 +6739,13 @@ var Endpoint = class {
6532
6739
  // } as AccountMeta,
6533
6740
  // ].concat(ix.keys)
6534
6741
  // }
6742
+ /**
6743
+ * Gets the account metadata for the CPI (Cross-Program Invocation) of the register OApp instruction.
6744
+ *
6745
+ * @param {PublicKey} payer - The payer public key.
6746
+ * @param {PublicKey} oapp - The OApp public key.
6747
+ * @returns {AccountMeta[]} An array of account metadata.
6748
+ */
6535
6749
  getRegisterOappIxAccountMetaForCPI(payer, oapp) {
6536
6750
  const [oappRegistry] = this.deriver.oappRegistry(oapp);
6537
6751
  const eventAuthority = this.eventAuthorityPDA;
@@ -6556,6 +6770,15 @@ var Endpoint = class {
6556
6770
  }
6557
6771
  ].concat(keys);
6558
6772
  }
6773
+ /**
6774
+ * Gets the account metadata for the CPI (Cross-Program Invocation) of the skip instruction.
6775
+ *
6776
+ * @param {PublicKey} receiver - The receiver public key.
6777
+ * @param {Uint8Array} sender - The sender address.
6778
+ * @param {number} srcEid - The source endpoint ID.
6779
+ * @param {number} nonce - The nonce.
6780
+ * @returns {AccountMeta[]} An array of account metadata.
6781
+ */
6559
6782
  getSkipIxAccountMetaForCPI(receiver, sender, srcEid, nonce) {
6560
6783
  const [noncePDA] = this.deriver.nonce(receiver, srcEid, sender);
6561
6784
  const [pendingNonce] = this.deriver.pendingNonce(receiver, srcEid, sender);
@@ -6585,6 +6808,15 @@ var Endpoint = class {
6585
6808
  }
6586
6809
  ].concat(keys);
6587
6810
  }
6811
+ /**
6812
+ * Checks if the given message library program is the default send library.
6813
+ *
6814
+ * @param {Connection} connection - The connection to the Solana cluster.
6815
+ * @param {PublicKey} messageLibProgram - The message library program public key.
6816
+ * @param {number} dstEid - The destination endpoint ID.
6817
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
6818
+ * @returns {Promise<boolean>} A promise that resolves to true if the message library program is the default send library, false otherwise.
6819
+ */
6588
6820
  async isDefaultSendLibrary(connection, messageLibProgram, dstEid, commitmentOrConfig) {
6589
6821
  const [msgLib] = new MessageLibPDADeriver(messageLibProgram).messageLib();
6590
6822
  const info = await this.getDefaultSendLibrary(connection, dstEid, commitmentOrConfig);
@@ -6593,6 +6825,15 @@ var Endpoint = class {
6593
6825
  }
6594
6826
  return false;
6595
6827
  }
6828
+ /**
6829
+ * Checks if the given message library program is the default receive library.
6830
+ *
6831
+ * @param {Connection} connection - The connection to the Solana cluster.
6832
+ * @param {PublicKey} messageLibProgram - The message library program public key.
6833
+ * @param {number} srcEid - The source endpoint ID.
6834
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
6835
+ * @returns {Promise<boolean>} A promise that resolves to true if the message library program is the default receive library, false otherwise.
6836
+ */
6596
6837
  async isDefaultReceiveLibrary(connection, messageLibProgram, srcEid, commitmentOrConfig) {
6597
6838
  const [msgLib] = new MessageLibPDADeriver(messageLibProgram).messageLib();
6598
6839
  const info = await this.getDefaultReceiveLibrary(connection, srcEid, commitmentOrConfig);
@@ -6602,6 +6843,13 @@ var Endpoint = class {
6602
6843
  return false;
6603
6844
  }
6604
6845
  // all of below functions are retrieving accounts state
6846
+ /**
6847
+ * Gets the endpoint settings.
6848
+ *
6849
+ * @param {Connection} connection - The connection to the Solana cluster.
6850
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
6851
+ * @returns {Promise<EndpointSettings | null>} A promise that resolves to the endpoint settings or null if not found.
6852
+ */
6605
6853
  async getSetting(connection, commitmentOrConfig) {
6606
6854
  const [setting] = this.deriver.setting();
6607
6855
  try {
@@ -6611,8 +6859,12 @@ var Endpoint = class {
6611
6859
  }
6612
6860
  }
6613
6861
  /**
6862
+ * Gets the message library information.
6614
6863
  *
6615
- * @param messageLib It is a PDA of the message library program
6864
+ * @param {Connection} connection - The connection to the Solana cluster.
6865
+ * @param {PublicKey} messageLibProgram - The message library program public key, It is a PDA of the message library program
6866
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
6867
+ * @returns {Promise<MessageLibInfo | null>} A promise that resolves to the message library information or null if not found.
6616
6868
  */
6617
6869
  async getMessageLibInfo(connection, messageLibProgram, commitmentOrConfig) {
6618
6870
  const [msgLib] = new MessageLibPDADeriver(messageLibProgram).messageLib();
@@ -6623,6 +6875,14 @@ var Endpoint = class {
6623
6875
  return null;
6624
6876
  }
6625
6877
  }
6878
+ /**
6879
+ * Gets the default receive library.
6880
+ *
6881
+ * @param {Connection} connection - The connection to the Solana cluster.
6882
+ * @param {number} srcEid - The source endpoint ID.
6883
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
6884
+ * @returns {Promise<{ msgLib: PublicKey; owner?: PublicKey } | null>} A promise that resolves to the default receive library or null if not found.
6885
+ */
6626
6886
  async getDefaultReceiveLibrary(connection, srcEid, commitmentOrConfig) {
6627
6887
  const [defaultReceiveLibConfig] = this.deriver.defaultReceiveLibraryConfig(srcEid);
6628
6888
  try {
@@ -6645,6 +6905,14 @@ var Endpoint = class {
6645
6905
  return null;
6646
6906
  }
6647
6907
  }
6908
+ /**
6909
+ * Gets the default send library.
6910
+ *
6911
+ * @param {Connection} connection - The connection to the Solana cluster.
6912
+ * @param {number} dstEid - The destination endpoint ID.
6913
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
6914
+ * @returns {Promise<{ msgLib: PublicKey; owner?: PublicKey } | null>} A promise that resolves to the default send library or null if not found.
6915
+ */
6648
6916
  async getDefaultSendLibrary(connection, dstEid, commitmentOrConfig) {
6649
6917
  const [defaultSendLibConfig] = this.deriver.defaultSendLibraryConfig(dstEid);
6650
6918
  try {
@@ -6668,8 +6936,13 @@ var Endpoint = class {
6668
6936
  }
6669
6937
  }
6670
6938
  /**
6671
- * get app configured send library
6672
- * 2 RPC calls
6939
+ * Gets the configured send library for the app.
6940
+ *
6941
+ * @param {Connection} connection - The connection to the Solana cluster.
6942
+ * @param {PublicKey} oappPda - The OApp PDA.
6943
+ * @param {number} dstEid - The destination endpoint ID.
6944
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig='confirmed'] - The commitment level or account info configuration.
6945
+ * @returns {Promise<{ msgLib: PublicKey; programId?: PublicKey; isDefault: boolean } | null>} A promise that resolves to the configured send library or null if not found.
6673
6946
  */
6674
6947
  async getSendLibrary(connection, oappPda, dstEid, commitmentOrConfig = "confirmed") {
6675
6948
  const [sendLibConfig] = this.deriver.sendLibraryConfig(oappPda, dstEid);
@@ -6702,7 +6975,13 @@ var Endpoint = class {
6702
6975
  }
6703
6976
  }
6704
6977
  /**
6705
- * get app configured receive library
6978
+ * Gets the configured receive library for the app.
6979
+ *
6980
+ * @param {Connection} connection - The connection to the Solana cluster.
6981
+ * @param {PublicKey} oappPda - The OApp PDA.
6982
+ * @param {number} srcEid - The source endpoint ID.
6983
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
6984
+ * @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
6985
  */
6707
6986
  async getReceiveLibrary(connection, oappPda, srcEid, commitmentOrConfig) {
6708
6987
  const [receiveLibConfig] = this.deriver.receiveLibraryConfig(oappPda, srcEid);
@@ -6738,7 +7017,7 @@ var Endpoint = class {
6738
7017
  };
6739
7018
  }
6740
7019
  const messageLibInfo = await connection.getAccountInfo(info.messageLib, commitmentOrConfig);
6741
- invariant4__default.default(messageLibInfo, "messageLibInfo should not be null");
7020
+ invariant3__default.default(messageLibInfo, "messageLibInfo should not be null");
6742
7021
  const { timeout } = info;
6743
7022
  if (timeout) {
6744
7023
  return {
@@ -6751,6 +7030,18 @@ var Endpoint = class {
6751
7030
  return { programId: messageLibInfo.owner, msgLib: info.messageLib, isDefault: false, timeout: null };
6752
7031
  }
6753
7032
  // rename to a more generic name
7033
+ /**
7034
+ * Gets the inbound payload hash.
7035
+ *
7036
+ * @param {Connection} connection - The connection to the Solana cluster.
7037
+ * @param {PublicKey} receiver - The receiver public key.
7038
+ * @param {number} srcEid - The source endpoint ID.
7039
+ * @param {Uint8Array} sender - The sender address.
7040
+ * @param {number} nonce - The nonce.
7041
+ * @param {Uint8Array} _payloadHash - The payload hash.
7042
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
7043
+ * @returns {Promise<PayloadHash | null>} A promise that resolves to the payload hash or null if not found.
7044
+ */
6754
7045
  async getInboundPayloadHash(connection, receiver, srcEid, sender, nonce, _payloadHash, commitmentOrConfig) {
6755
7046
  const [payloadHashPDA] = this.deriver.payloadHash(receiver, srcEid, sender, nonce);
6756
7047
  const accountInfo = await connection.getAccountInfo(payloadHashPDA, commitmentOrConfig);
@@ -6759,8 +7050,17 @@ var Endpoint = class {
6759
7050
  }
6760
7051
  return PayloadHash.fromAccountInfo(accountInfo, 0)[0];
6761
7052
  }
7053
+ /**
7054
+ * Gets the composed message state.
7055
+ *
7056
+ * @param {Connection} connection - The connection to the Solana cluster.
7057
+ * @param {PublicKey} from - The sender public key.
7058
+ * @param {types.SendComposeParams} params - The send compose parameters.
7059
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
7060
+ * @returns {Promise<ComposeMessageState | null>} A promise that resolves to the composed message state or null if not found.
7061
+ */
6762
7062
  async getComposedMessageState(connection, from, params, commitmentOrConfig) {
6763
- const message = bytes.arrayify(keccak256.keccak256(params.message));
7063
+ const message = lzFoundation.keccak_256(params.message);
6764
7064
  const [composedMessagePDA] = this.deriver.composedMessage(
6765
7065
  from,
6766
7066
  Uint8Array.from(params.guid),
@@ -6774,6 +7074,16 @@ var Endpoint = class {
6774
7074
  }
6775
7075
  return ComposeMessageState.fromAccountInfo(accountInfo, 0)[0];
6776
7076
  }
7077
+ /**
7078
+ * Gets the nonce.
7079
+ *
7080
+ * @param {Connection} connection - The connection to the Solana cluster.
7081
+ * @param {PublicKey} oappIDPDA - The OApp ID PDA.
7082
+ * @param {number} remoteEid - The remote endpoint ID.
7083
+ * @param {Uint8Array} remoteOappAddr - The remote OApp address.
7084
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
7085
+ * @returns {Promise<accounts.Nonce | null>} A promise that resolves to the nonce or null if not found.
7086
+ */
6777
7087
  async getNonce(connection, oappIDPDA2, remoteEid, remoteOappAddr, commitmentOrConfig) {
6778
7088
  const [nonce] = this.deriver.nonce(oappIDPDA2, remoteEid, remoteOappAddr);
6779
7089
  try {
@@ -6782,6 +7092,16 @@ var Endpoint = class {
6782
7092
  return null;
6783
7093
  }
6784
7094
  }
7095
+ /**
7096
+ * Gets the pending inbound nonce.
7097
+ *
7098
+ * @param {Connection} connection - The connection to the Solana cluster.
7099
+ * @param {PublicKey} oappIDPDA - The OApp ID PDA.
7100
+ * @param {number} remoteEid - The remote endpoint ID.
7101
+ * @param {Uint8Array} remoteOappAddr - The remote OApp address.
7102
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
7103
+ * @returns {Promise<accounts.PendingInboundNonce | null>} A promise that resolves to the pending inbound nonce or null if not found.
7104
+ */
6785
7105
  async getPendingInboundNonce(connection, oappIDPDA2, remoteEid, remoteOappAddr, commitmentOrConfig) {
6786
7106
  const [nonce] = this.deriver.pendingNonce(oappIDPDA2, remoteEid, remoteOappAddr);
6787
7107
  try {
@@ -6790,12 +7110,30 @@ var Endpoint = class {
6790
7110
  return null;
6791
7111
  }
6792
7112
  }
7113
+ /**
7114
+ * Gets the message library version.
7115
+ *
7116
+ * @param {Connection} connection - The connection to the Solana cluster.
7117
+ * @param {PublicKey} payer - The payer public key.
7118
+ * @param {PublicKey} messageLibProgram - The message library program public key.
7119
+ * @param {Commitment} [commitment='confirmed'] - The commitment level.
7120
+ * @returns {Promise<Version | null>} A promise that resolves to the version or null if not found.
7121
+ */
6793
7122
  async getMessageLibVersion(connection, payer, messageLibProgram, commitment = "confirmed") {
6794
7123
  const ix = simple_message_lib_exports.instructions.createVersionInstruction(messageLibProgram);
6795
7124
  const simulateResp = await simulateTransaction(connection, [ix], messageLibProgram, payer, commitment);
6796
7125
  const version = simple_message_lib_exports.types.versionBeet.read(simulateResp, 0);
6797
7126
  return version;
6798
7127
  }
7128
+ /**
7129
+ * Transfers the admin role to a new admin.
7130
+ *
7131
+ * @param {Connection} connection - The connection to the Solana cluster.
7132
+ * @param {PublicKey} admin - The current admin public key.
7133
+ * @param {PublicKey} newAdmin - The new admin public key.
7134
+ * @param {Commitment} [commitment='confirmed'] - The commitment level.
7135
+ * @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
7136
+ */
6799
7137
  async transferAdmin(connection, admin, newAdmin, commitment = "confirmed") {
6800
7138
  const [settingPDA] = this.deriver.setting();
6801
7139
  const endpointSettings = await EndpointSettings.fromAccountAddress(connection, settingPDA, commitment);
@@ -8742,10 +9080,27 @@ var PROGRAM_ID2 = new web314.PublicKey(PROGRAM_ADDRESS2);
8742
9080
 
8743
9081
  // src/simple-message-lib.ts
8744
9082
  var SimpleMessageLib = class {
9083
+ /**
9084
+ * Creates an instance of the SimpleMessageLib class.
9085
+ *
9086
+ * @param {PublicKey} program - The program public key.
9087
+ */
8745
9088
  constructor(program) {
8746
9089
  this.program = program;
8747
9090
  this.deriver = new MessageLibPDADeriver(program);
8748
9091
  }
9092
+ /**
9093
+ * Initializes the SimpleMessageLib.
9094
+ *
9095
+ * @param {PublicKey} endpointProgram - The endpoint program public key.
9096
+ * @param {PublicKey} payer - The payer public key.
9097
+ * @param {PublicKey} admin - The admin public key.
9098
+ * @param {number} eid - The endpoint ID.
9099
+ * @param {number} nativeFee - The native fee.
9100
+ * @param {number} [lzTokenFee=0] - The LayerZero token fee.
9101
+ *
9102
+ * @returns {TransactionInstruction} The transaction instruction.
9103
+ */
8749
9104
  initSimpleMessageLib(endpointProgram, payer, admin, eid, nativeFee, lzTokenFee = 0) {
8750
9105
  const [messageLibPda] = this.deriver.messageLib();
8751
9106
  const [endpointAuth] = new EndpointPDADeriver(endpointProgram).messageLibraryInfo(messageLibPda);
@@ -8767,6 +9122,14 @@ var SimpleMessageLib = class {
8767
9122
  this.program
8768
9123
  );
8769
9124
  }
9125
+ /**
9126
+ * Sets the whitelist caller.
9127
+ *
9128
+ * @param {PublicKey} admin - The admin public key.
9129
+ * @param {PublicKey} newCaller - The new caller public key.
9130
+ *
9131
+ * @returns {TransactionInstruction} The transaction instruction.
9132
+ */
8770
9133
  setWhitelistCaller(admin, newCaller) {
8771
9134
  const [messageLibPDA] = this.deriver.messageLib();
8772
9135
  return createSetWlCallerInstruction(
@@ -8782,6 +9145,15 @@ var SimpleMessageLib = class {
8782
9145
  this.program
8783
9146
  );
8784
9147
  }
9148
+ /**
9149
+ * Checks if a caller is whitelisted.
9150
+ *
9151
+ * @param {Connection} connection - The connection object.
9152
+ * @param {PublicKey} caller - The caller public key.
9153
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment or config.
9154
+ *
9155
+ * @returns {Promise<boolean>} A promise that resolves to true if the caller is whitelisted, false otherwise.
9156
+ */
8785
9157
  async isWhiteListed(connection, caller, commitmentOrConfig) {
8786
9158
  try {
8787
9159
  const exceptedCaller = await this.getWhiteListCaller(connection, commitmentOrConfig);
@@ -8790,6 +9162,14 @@ var SimpleMessageLib = class {
8790
9162
  return false;
8791
9163
  }
8792
9164
  }
9165
+ /**
9166
+ * Gets the whitelisted caller.
9167
+ *
9168
+ * @param {Connection} connection - The connection object.
9169
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment or config.
9170
+ *
9171
+ * @returns {Promise<PublicKey>} A promise that resolves to the whitelisted caller public key.
9172
+ */
8793
9173
  async getWhiteListCaller(connection, commitmentOrConfig) {
8794
9174
  const [messageLibPDA] = this.deriver.messageLib();
8795
9175
  const messageLibInfo = await MessageLib.fromAccountAddress(
@@ -8799,8 +9179,18 @@ var SimpleMessageLib = class {
8799
9179
  );
8800
9180
  return messageLibInfo.wlCaller;
8801
9181
  }
9182
+ /**
9183
+ * Validates a packet.
9184
+ *
9185
+ * @param {Connection} _connection - The connection object.
9186
+ * @param {PublicKey} endpointProgram - The endpoint program public key.
9187
+ * @param {PublicKey} payer - The payer public key.
9188
+ * @param {Uint8Array} encodedPacket - The encoded packet.
9189
+ *
9190
+ * @returns {TransactionInstruction} The transaction instruction.
9191
+ */
8802
9192
  validatePacket(_connection, endpointProgram, payer, encodedPacket) {
8803
- const packet = PacketV1Codec.fromBytes(encodedPacket);
9193
+ const packet = lzV2Utilities.PacketV1Codec.fromBytes(encodedPacket);
8804
9194
  const [receiveLibrary] = this.deriver.messageLib();
8805
9195
  const endpoint = new endpoint_exports.Endpoint(endpointProgram);
8806
9196
  return createValidatePacketInstruction(
@@ -8815,8 +9205,14 @@ var SimpleMessageLib = class {
8815
9205
  this.program
8816
9206
  );
8817
9207
  }
8818
- /***
8819
- * Get the account meta of the send instruction for CPI(Cross-Program Invocation )
9208
+ /**
9209
+ * Gets the account meta of the send instruction for CPI (Cross-Program Invocation).
9210
+ *
9211
+ * @param {Connection} _connection - The connection object.
9212
+ * @param {PublicKey} payer - The payer public key.
9213
+ * @param {PacketPath} _path - The packet path.
9214
+ *
9215
+ * @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account meta.
8820
9216
  */
8821
9217
  async getSendIXAccountMetaForCPI(_connection, payer, _path) {
8822
9218
  const [msgLib] = this.deriver.messageLib();
@@ -8836,6 +9232,16 @@ var SimpleMessageLib = class {
8836
9232
  });
8837
9233
  return Promise.resolve(cpiAccounts.slice(1));
8838
9234
  }
9235
+ /**
9236
+ * Gets the account meta of the quote instruction for CPI (Cross-Program Invocation).
9237
+ *
9238
+ * @param {Connection} _connection - The connection object.
9239
+ * @param {PublicKey} _payer - The payer public key.
9240
+ * @param {PacketPath} _path - The packet path.
9241
+ * @param {Commitment} [commitment] - The commitment.
9242
+ *
9243
+ * @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account meta.
9244
+ */
8839
9245
  async getQuoteIXAccountMetaForCPI(_connection, _payer, _path, _commitment) {
8840
9246
  const [msgLib] = this.deriver.messageLib();
8841
9247
  const keys = createQuoteInstructionAccounts2(
@@ -8848,8 +9254,14 @@ var SimpleMessageLib = class {
8848
9254
  );
8849
9255
  return Promise.resolve(keys.slice(1));
8850
9256
  }
8851
- /***
8852
- * Get the account meta of the send instruction for CPI(Cross-Program Invocation )
9257
+ /**
9258
+ * Gets the account meta of the init config instruction for CPI (Cross-Program Invocation).
9259
+ *
9260
+ * @param {PublicKey} payer - The payer public key.
9261
+ * @param {PublicKey} oappID - The oapp ID public key.
9262
+ * @param {number} eid - The endpoint ID.
9263
+ *
9264
+ * @returns {AccountMeta[]} An array of account meta.
8853
9265
  */
8854
9266
  getInitConfigIXAccountMetaForCPI(payer, oappID, eid) {
8855
9267
  const [sendConfig] = this.deriver.sendConfig(eid, oappID);
@@ -8873,6 +9285,15 @@ var SimpleMessageLib = class {
8873
9285
  });
8874
9286
  return keys.slice(1);
8875
9287
  }
9288
+ /**
9289
+ * Gets the account meta of the set config instruction for CPI (Cross-Program Invocation).
9290
+ *
9291
+ * @param {PublicKey} endpointProgram - The endpoint program public key.
9292
+ * @param {PublicKey} oappID - The oapp ID public key.
9293
+ * @param {number} eid - The endpoint ID.
9294
+ *
9295
+ * @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account meta.
9296
+ */
8876
9297
  async getSetConfigIXAccountMetaForCPI(endpointProgram, oappID, eid) {
8877
9298
  const [sendConfig] = this.deriver.sendConfig(eid, oappID);
8878
9299
  const [receiveConfig] = this.deriver.receiveConfig(eid, oappID);
@@ -10750,9 +11171,21 @@ var SolanaSignerExt = class _SolanaSignerExt {
10750
11171
  constructor(signers) {
10751
11172
  this.signers = signers;
10752
11173
  }
11174
+ /**
11175
+ * Creates an instance of the SolanaSignerExt class.
11176
+ *
11177
+ * @param {HashSigner[]} signers - The signers.
11178
+ * @returns {SolanaSignerExt} The SolanaSignerExt instance.
11179
+ */
10753
11180
  static from(signers) {
10754
11181
  return new _SolanaSignerExt(signers);
10755
11182
  }
11183
+ /**
11184
+ * Signs a message.
11185
+ *
11186
+ * @param {Buffer} message - The message to sign.
11187
+ * @returns {Promise<{ signature: Uint8Array; recoveryId: number }[]>} A promise that resolves to an array of signature objects.
11188
+ */
10756
11189
  async sign(message) {
10757
11190
  return Promise.all(
10758
11191
  this.signers.map(async (s) => {
@@ -10763,12 +11196,27 @@ var SolanaSignerExt = class _SolanaSignerExt {
10763
11196
  }
10764
11197
  };
10765
11198
  var DVN = class {
11199
+ /**
11200
+ * Creates an instance of the DVN class.
11201
+ *
11202
+ * @param {PublicKey} programId - The program ID.
11203
+ * @param {EndpointId} [endpointId=EndpointId.SOLANA_V2_SANDBOX] - The endpoint ID.
11204
+ */
10766
11205
  constructor(programId, endpointId = lzDefinitions.EndpointId.SOLANA_V2_SANDBOX) {
10767
11206
  this.programId = programId;
10768
11207
  this.dvnDeriver = new DVNDeriver(programId);
10769
11208
  this.vid = endpointId % 3e4;
10770
11209
  this.eventAuthority = new EventPDADeriver(programId).eventAuthority()[0];
10771
11210
  }
11211
+ /**
11212
+ * Initializes the DVN.
11213
+ *
11214
+ * @param {Connection} connection - The connection.
11215
+ * @param {PublicKey} payer - The payer.
11216
+ * @param {InitDvnParams} params - The initialization parameters.
11217
+ * @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
11218
+ * @throws {Error} If the DVN is already initialized.
11219
+ */
10772
11220
  async initDVN(connection, payer, params) {
10773
11221
  const [config] = this.dvnDeriver.config();
10774
11222
  const info = await connection.getAccountInfo(config);
@@ -10786,6 +11234,14 @@ var DVN = class {
10786
11234
  this.programId
10787
11235
  );
10788
11236
  }
11237
+ /**
11238
+ * Gets the digest for a transaction.
11239
+ *
11240
+ * @param {number} vid - The validator ID.
11241
+ * @param {TransactionInstruction} instruction - The transaction instruction.
11242
+ * @param {number} expiration - The expiration time.
11243
+ * @returns {types.ExecuteTransactionDigest} The transaction digest.
11244
+ */
10789
11245
  getDigest(vid, instruction, expiration) {
10790
11246
  return {
10791
11247
  vid,
@@ -10801,15 +11257,39 @@ var DVN = class {
10801
11257
  expiration
10802
11258
  };
10803
11259
  }
11260
+ /**
11261
+ * Gets the execute hash for a given hash bytes.
11262
+ *
11263
+ * @param {Buffer} hashBytes - The hash bytes.
11264
+ * @returns {PublicKey} The execute hash.
11265
+ */
10804
11266
  getExecuteHash(hashBytes) {
10805
11267
  const [executeHash] = this.dvnDeriver.executeHash(hashBytes);
10806
11268
  return executeHash;
10807
11269
  }
11270
+ /**
11271
+ * Gets the hash bytes for a given digest.
11272
+ *
11273
+ * @param {types.ExecuteTransactionDigest} digest - The transaction digest.
11274
+ * @returns {Buffer} The hash bytes.
11275
+ */
10808
11276
  getHashBytes(digest) {
10809
11277
  const [digestBytes] = executeTransactionDigestBeet.serialize(digest);
10810
- const hash = keccak256.keccak256(digestBytes);
10811
- return Buffer.from(hash.slice(2), "hex");
11278
+ const hash = lzFoundation.keccak_256(digestBytes);
11279
+ return Buffer.from(hash);
10812
11280
  }
11281
+ /**
11282
+ * Invokes a transaction.
11283
+ *
11284
+ * @param {Connection} connection - The connection.
11285
+ * @param {number} vid - The validator ID.
11286
+ * @param {PublicKey} payer - The payer.
11287
+ * @param {TransactionInstruction} instruction - The transaction instruction.
11288
+ * @param {number} expiration - The expiration time.
11289
+ * @param {SignFunc} sign - The sign function.
11290
+ * @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
11291
+ * @throws {Error} If the DVN is not initialized.
11292
+ */
10813
11293
  async invoke(connection, vid, payer, instruction, expiration, sign) {
10814
11294
  const configState = await this.getConfigState(connection, "confirmed");
10815
11295
  if (!configState) {
@@ -10851,6 +11331,12 @@ var DVN = class {
10851
11331
  this.programId
10852
11332
  );
10853
11333
  }
11334
+ /**
11335
+ * Creates a transaction instruction to set the quorum.
11336
+ *
11337
+ * @param {number} quorum - The quorum.
11338
+ * @returns {TransactionInstruction} The transaction instruction.
11339
+ */
10854
11340
  createSetQuorumInstruction(quorum) {
10855
11341
  const params = {
10856
11342
  fields: [quorum],
@@ -10865,6 +11351,12 @@ var DVN = class {
10865
11351
  data: buffer
10866
11352
  });
10867
11353
  }
11354
+ /**
11355
+ * Creates a transaction instruction to set the admins.
11356
+ *
11357
+ * @param {PublicKey[]} admins - The admin public keys.
11358
+ * @returns {TransactionInstruction} The transaction instruction.
11359
+ */
10868
11360
  createSetAdminsInstruction(admins) {
10869
11361
  const params = {
10870
11362
  fields: [admins],
@@ -10879,6 +11371,12 @@ var DVN = class {
10879
11371
  data: buffer
10880
11372
  });
10881
11373
  }
11374
+ /**
11375
+ * Creates a transaction instruction to set the signers.
11376
+ *
11377
+ * @param {Uint8Array[]} signers - The signer public keys.
11378
+ * @returns {TransactionInstruction} The transaction instruction.
11379
+ */
10882
11380
  createSetSignersInstruction(signers) {
10883
11381
  const params = {
10884
11382
  fields: [signers.map((s) => Array.from(s))],
@@ -10893,6 +11391,12 @@ var DVN = class {
10893
11391
  data: buffer
10894
11392
  });
10895
11393
  }
11394
+ /**
11395
+ * Creates a transaction instruction to set the allowlist.
11396
+ *
11397
+ * @param {PublicKey[]} allowlist - The allowlist public keys.
11398
+ * @returns {TransactionInstruction} The transaction instruction.
11399
+ */
10896
11400
  createSetAllowlistInstruction(allowlist) {
10897
11401
  const params = {
10898
11402
  fields: [allowlist],
@@ -10907,6 +11411,12 @@ var DVN = class {
10907
11411
  data: buffer
10908
11412
  });
10909
11413
  }
11414
+ /**
11415
+ * Creates a transaction instruction to set the denylist.
11416
+ *
11417
+ * @param {PublicKey[]} denylist - The denylist public keys.
11418
+ * @returns {TransactionInstruction} The transaction instruction.
11419
+ */
10910
11420
  createSetDenylistInstruction(denylist) {
10911
11421
  const params = {
10912
11422
  fields: [denylist],
@@ -10921,6 +11431,12 @@ var DVN = class {
10921
11431
  data: buffer
10922
11432
  });
10923
11433
  }
11434
+ /**
11435
+ * Creates a transaction instruction to set the pause state.
11436
+ *
11437
+ * @param {boolean} pause - The pause state.
11438
+ * @returns {TransactionInstruction} The transaction instruction.
11439
+ */
10924
11440
  createSetPauseInstruction(pause) {
10925
11441
  const params = {
10926
11442
  fields: [pause],
@@ -10935,6 +11451,13 @@ var DVN = class {
10935
11451
  data: buffer
10936
11452
  });
10937
11453
  }
11454
+ /**
11455
+ * Creates a transaction instruction to set the default multiplier basis points.
11456
+ *
11457
+ * @param {PublicKey} admin - The admin public key.
11458
+ * @param {number} defaultMultiplierBps - The default multiplier basis points.
11459
+ * @returns {TransactionInstruction} The transaction instruction.
11460
+ */
10938
11461
  createSetDefaultMultiplierBpsInstruction(admin, defaultMultiplierBps) {
10939
11462
  const [configAccount] = this.dvnDeriver.config();
10940
11463
  return createSetConfigInstruction3(
@@ -10955,6 +11478,13 @@ var DVN = class {
10955
11478
  this.programId
10956
11479
  );
10957
11480
  }
11481
+ /**
11482
+ * Creates a transaction instruction to change the admins.
11483
+ *
11484
+ * @param {PublicKey} admin - The admin public key.
11485
+ * @param {PublicKey[]} admins - The new admin public keys.
11486
+ * @returns {TransactionInstruction} The transaction instruction.
11487
+ */
10958
11488
  createChangeAdminsInstruction(admin, admins) {
10959
11489
  const [configAccount] = this.dvnDeriver.config();
10960
11490
  return createSetConfigInstruction3(
@@ -10975,6 +11505,13 @@ var DVN = class {
10975
11505
  this.programId
10976
11506
  );
10977
11507
  }
11508
+ /**
11509
+ * Creates a transaction instruction to set the destination configurations.
11510
+ *
11511
+ * @param {PublicKey} admin - The admin public key.
11512
+ * @param {types.DstConfig[]} dstConfigs - The destination configurations.
11513
+ * @returns {TransactionInstruction} The transaction instruction.
11514
+ */
10978
11515
  createSetDstConfigInstruction(admin, dstConfigs) {
10979
11516
  const [configAccount] = this.dvnDeriver.config();
10980
11517
  return createSetConfigInstruction3(
@@ -10995,6 +11532,13 @@ var DVN = class {
10995
11532
  this.programId
10996
11533
  );
10997
11534
  }
11535
+ /**
11536
+ * Creates a transaction instruction to remove the destination configurations.
11537
+ *
11538
+ * @param {PublicKey} admin - The admin public key.
11539
+ * @param {number[]} removeEids - The endpoint IDs to remove.
11540
+ * @returns {TransactionInstruction} The transaction instruction.
11541
+ */
10998
11542
  createRemoveDstConfigInstruction(admin, removeEids) {
10999
11543
  const [configAccount] = this.dvnDeriver.config();
11000
11544
  return createSetConfigInstruction3(
@@ -11015,6 +11559,12 @@ var DVN = class {
11015
11559
  this.programId
11016
11560
  );
11017
11561
  }
11562
+ /**
11563
+ * Creates a transaction instruction to set the message libraries.
11564
+ *
11565
+ * @param {PublicKey[]} msglibPrograms - The message library public keys.
11566
+ * @returns {TransactionInstruction} The transaction instruction.
11567
+ */
11018
11568
  createSetMsgLibsInstruction(msglibPrograms) {
11019
11569
  const params = {
11020
11570
  fields: [msglibPrograms],
@@ -11029,13 +11579,34 @@ var DVN = class {
11029
11579
  data: buffer
11030
11580
  });
11031
11581
  }
11582
+ /**
11583
+ * Gets the expiration time.
11584
+ *
11585
+ * @returns {number} The expiration time.
11586
+ */
11032
11587
  _getExpiration() {
11033
11588
  return (/* @__PURE__ */ new Date()).getTime() / 1e3 + 120;
11034
11589
  }
11590
+ /**
11591
+ * Sets the message libraries.
11592
+ *
11593
+ * @param {Connection} connection - The connection.
11594
+ * @param {PublicKey} payer - The payer.
11595
+ * @param {PublicKey[]} msgLibs - The message library public keys.
11596
+ * @param {SignFunc} sign - The sign function.
11597
+ * @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
11598
+ */
11035
11599
  async setMsgLibs(connection, payer, msgLibs, sign) {
11036
11600
  const expiration = this._getExpiration();
11037
11601
  return this.invoke(connection, this.vid, payer, this.createSetMsgLibsInstruction(msgLibs), expiration, sign);
11038
11602
  }
11603
+ /**
11604
+ * Creates a transaction instruction to set the price feed.
11605
+ *
11606
+ * @param {PublicKey} admin - The admin public key.
11607
+ * @param {PublicKey} priceFeedProgram - The price feed program public key.
11608
+ * @returns {TransactionInstruction} The transaction instruction.
11609
+ */
11039
11610
  createSetPriceFeedInstruction(admin, priceFeedProgram) {
11040
11611
  const [configAccount] = this.dvnDeriver.config();
11041
11612
  const [priceFeedPda] = new PriceFeedPDADeriver(priceFeedProgram).priceFeed();
@@ -11057,6 +11628,14 @@ var DVN = class {
11057
11628
  this.programId
11058
11629
  );
11059
11630
  }
11631
+ /**
11632
+ * Gets the account metadata for the CPI (Cross-Program Invocation) of the quote instruction.
11633
+ *
11634
+ * @param {PublicKey} priceFeedConfig - The price feed configuration public key.
11635
+ * @param {PublicKey} priceFeedProgram - The price feed program public key.
11636
+ * @param {boolean} payment - Indicates if payment is required.
11637
+ * @returns {AccountMeta[]} An array of account metadata.
11638
+ */
11060
11639
  getQuoteIXAccountMetaForCPI(priceFeedConfig, priceFeedProgram, payment) {
11061
11640
  const [config] = this.dvnDeriver.config();
11062
11641
  const keys = createQuoteDvnInstructionAccounts(
@@ -11078,6 +11657,13 @@ var DVN = class {
11078
11657
  }
11079
11658
  ].concat(keys);
11080
11659
  }
11660
+ /**
11661
+ * Gets the configuration state.
11662
+ *
11663
+ * @param {Connection} connection - The connection to the Solana cluster.
11664
+ * @param {Commitment | GetAccountInfoConfig} [commitment='confirmed'] - The commitment level or account info configuration.
11665
+ * @returns {Promise<accounts.DvnConfig | null>} A promise that resolves to the configuration state or null if not found.
11666
+ */
11081
11667
  async getConfigState(connection, commitment = "confirmed") {
11082
11668
  const [config] = this.dvnDeriver.config();
11083
11669
  try {
@@ -12649,8 +13235,8 @@ var treasurySetEventBeet = new beet159__namespace.FixableBeetArgsStruct(
12649
13235
  function getEventDiscriminator(event) {
12650
13236
  const hash = crypto__default.default.createHash("sha256");
12651
13237
  hash.update(`event:${event}`);
12652
- const sha2562 = hash.digest("hex");
12653
- return sha2562.slice(0, 16);
13238
+ const sha256 = hash.digest("hex");
13239
+ return sha256.slice(0, 16);
12654
13240
  }
12655
13241
  async function extractSentPacketEventByTxHash(connection, program, signature, commitment, unsafeParseErr = false) {
12656
13242
  const events = await extractEventFromTransactionSignature(
@@ -12661,8 +13247,7 @@ async function extractSentPacketEventByTxHash(connection, program, signature, co
12661
13247
  commitment,
12662
13248
  unsafeParseErr
12663
13249
  );
12664
- if (!events)
12665
- return null;
13250
+ if (!events) return null;
12666
13251
  return events;
12667
13252
  }
12668
13253
  async function extractVerifiedPacketEventByTxHash(connection, program, signature, commitment, unsafeParseErr = false) {
@@ -12674,8 +13259,7 @@ async function extractVerifiedPacketEventByTxHash(connection, program, signature
12674
13259
  commitment,
12675
13260
  unsafeParseErr
12676
13261
  );
12677
- if (!events)
12678
- return null;
13262
+ if (!events) return null;
12679
13263
  return events;
12680
13264
  }
12681
13265
  async function extractReceivedPacketEventByTxHash(connection, program, signature, commitment, unsafeParseErr = false) {
@@ -12687,8 +13271,7 @@ async function extractReceivedPacketEventByTxHash(connection, program, signature
12687
13271
  commitment,
12688
13272
  unsafeParseErr
12689
13273
  );
12690
- if (!events)
12691
- return null;
13274
+ if (!events) return null;
12692
13275
  return events;
12693
13276
  }
12694
13277
  async function extractComposeSentEventByTxHash(connection, program, signature, commitment, unsafeParseErr = false) {
@@ -12700,8 +13283,7 @@ async function extractComposeSentEventByTxHash(connection, program, signature, c
12700
13283
  commitment,
12701
13284
  unsafeParseErr
12702
13285
  );
12703
- if (!events)
12704
- return null;
13286
+ if (!events) return null;
12705
13287
  return events;
12706
13288
  }
12707
13289
  async function extractComposeDeliveredEventByTxHash(connection, program, signature, commitment, unsafeParseErr = false) {
@@ -12713,8 +13295,7 @@ async function extractComposeDeliveredEventByTxHash(connection, program, signatu
12713
13295
  commitment,
12714
13296
  unsafeParseErr
12715
13297
  );
12716
- if (!events)
12717
- return null;
13298
+ if (!events) return null;
12718
13299
  return events;
12719
13300
  }
12720
13301
  async function extractWorkerFeePaidEventByTxHash(connection, program, signature, commitment, unsafeParseErr = false) {
@@ -12726,14 +13307,12 @@ async function extractWorkerFeePaidEventByTxHash(connection, program, signature,
12726
13307
  commitment,
12727
13308
  unsafeParseErr
12728
13309
  );
12729
- if (!events)
12730
- return null;
13310
+ if (!events) return null;
12731
13311
  return events;
12732
13312
  }
12733
13313
  async function extractEventFromTransactionSignature(connection, program, signature, eventBeet, commitment, unsafeParseErr = false) {
12734
13314
  const tx = typeof signature === "string" ? await connection.getParsedTransaction(signature, commitment) : signature;
12735
- if (tx == null)
12736
- return null;
13315
+ if (tx == null) return null;
12737
13316
  const events = new Array();
12738
13317
  if (tx.meta?.err !== null && !unsafeParseErr) {
12739
13318
  return null;
@@ -12880,7 +13459,7 @@ async function buildVersionedTransaction(connection, payerKey, instructions, com
12880
13459
  );
12881
13460
  }
12882
13461
  function instructionDiscriminator(method) {
12883
- return Buffer.from(sha2.sha256(Buffer.from(`global:${method}`)).substring(2), "hex").subarray(0, 8);
13462
+ return Buffer.from(lzFoundation.sha2_256(Buffer.from(`global:${method}`))).subarray(0, 8);
12884
13463
  }
12885
13464
  async function simulateTransaction(connection, instructions, programId, payer, commitment = "confirmed", blockhash, lookupTableAddress) {
12886
13465
  const tx = await buildVersionedTransaction(
@@ -12904,12 +13483,12 @@ async function simulateTransaction(connection, instructions, programId, payer, c
12904
13483
  // src/recevie.ts
12905
13484
  async function lzReceive(connection, payer, packet, callerParams = Uint8Array.from([0, 0]), commitmentOrConfig = "confirmed") {
12906
13485
  const { message: message_, sender, srcEid, guid, receiver: receiver_ } = packet;
12907
- const receiver = new web314.PublicKey(addressToBytes32(receiver_));
12908
- const message = bytes.arrayify(message_);
13486
+ const receiver = new web314.PublicKey(lzV2Utilities.addressToBytes32(receiver_));
13487
+ const message = lzUtilities.arrayify(message_);
12909
13488
  const params = {
12910
13489
  srcEid,
12911
- sender: Array.from(bytes.arrayify(sender)),
12912
- guid: Array.from(bytes.arrayify(guid)),
13490
+ sender: Array.from(lzUtilities.arrayify(sender)),
13491
+ guid: Array.from(lzUtilities.arrayify(guid)),
12913
13492
  message,
12914
13493
  callerParams,
12915
13494
  nonce: parseInt(packet.nonce)
@@ -13028,8 +13607,7 @@ function retrieveAccountFromSimulatedResp(resp, payer) {
13028
13607
  const results = fixedBeet.read(resp, 0);
13029
13608
  return results.map((r) => {
13030
13609
  if (r.pubkey.toBase58() == web314.PublicKey.default.toBase58() && r.isSigner) {
13031
- if (!payer)
13032
- throw new Error("payer is required");
13610
+ if (!payer) throw new Error("payer is required");
13033
13611
  return {
13034
13612
  pubkey: payer,
13035
13613
  isSigner: true,
@@ -13321,11 +13899,28 @@ var PROGRAM_ID4 = new web314.PublicKey(PROGRAM_ADDRESS4);
13321
13899
 
13322
13900
  // src/executor.ts
13323
13901
  var Executor = class {
13902
+ /**
13903
+ * Creates an instance of the Executor class.
13904
+ *
13905
+ * @param {PublicKey} program - The program public key.
13906
+ */
13324
13907
  constructor(program) {
13325
13908
  this.program = program;
13326
13909
  this.deriver = new ExecutorPDADeriver(this.program);
13327
13910
  }
13328
13911
  // owner methods
13912
+ /**
13913
+ * Initializes the executor.
13914
+ *
13915
+ * @param {PublicKey} payer - The payer public key.
13916
+ * @param {PublicKey} owner - The owner public key.
13917
+ * @param {PublicKey[]} admins - The admin public keys.
13918
+ * @param {PublicKey[]} executors - The executor public keys.
13919
+ * @param {PublicKey[]} msglibs - The message library public keys.
13920
+ * @param {PublicKey} priceFeed - The price feed public key.
13921
+ *
13922
+ * @returns {TransactionInstruction} The transaction instruction.
13923
+ */
13329
13924
  initExecutor(payer, owner, admins, executors, msglibs, priceFeed) {
13330
13925
  const [configAccount] = this.deriver.config();
13331
13926
  return createInitExecutorInstruction(
@@ -13345,6 +13940,14 @@ var Executor = class {
13345
13940
  this.program
13346
13941
  );
13347
13942
  }
13943
+ /**
13944
+ * Sets the owner.
13945
+ *
13946
+ * @param {PublicKey} owner - The current owner public key.
13947
+ * @param {PublicKey} newOwner - The new owner public key.
13948
+ *
13949
+ * @returns {TransactionInstruction} The transaction instruction.
13950
+ */
13348
13951
  setOwner(owner, newOwner) {
13349
13952
  const [configAccount] = this.deriver.config();
13350
13953
  return createOwnerSetConfigInstruction(
@@ -13361,6 +13964,14 @@ var Executor = class {
13361
13964
  this.program
13362
13965
  );
13363
13966
  }
13967
+ /**
13968
+ * Sets the admins.
13969
+ *
13970
+ * @param {PublicKey} owner - The owner public key.
13971
+ * @param {PublicKey[]} admins - The admin public keys.
13972
+ *
13973
+ * @returns {TransactionInstruction} The transaction instruction.
13974
+ */
13364
13975
  setAdmins(owner, admins) {
13365
13976
  const [configAccount] = this.deriver.config();
13366
13977
  return createOwnerSetConfigInstruction(
@@ -13377,6 +13988,14 @@ var Executor = class {
13377
13988
  this.program
13378
13989
  );
13379
13990
  }
13991
+ /**
13992
+ * Sets the allow list.
13993
+ *
13994
+ * @param {PublicKey} owner - The owner public key.
13995
+ * @param {PublicKey[]} allowlist - The allow list public keys.
13996
+ *
13997
+ * @returns {TransactionInstruction} The transaction instruction.
13998
+ */
13380
13999
  setAllowList(owner, allowlist) {
13381
14000
  const [configAccount] = this.deriver.config();
13382
14001
  return createOwnerSetConfigInstruction(
@@ -13393,6 +14012,14 @@ var Executor = class {
13393
14012
  this.program
13394
14013
  );
13395
14014
  }
14015
+ /**
14016
+ * Sets the deny list.
14017
+ *
14018
+ * @param {PublicKey} owner - The owner public key.
14019
+ * @param {PublicKey[]} denylist - The deny list public keys.
14020
+ *
14021
+ * @returns {TransactionInstruction} The transaction instruction.
14022
+ */
13396
14023
  setDenyList(owner, denylist) {
13397
14024
  const [configAccount] = this.deriver.config();
13398
14025
  return createOwnerSetConfigInstruction(
@@ -13409,6 +14036,14 @@ var Executor = class {
13409
14036
  this.program
13410
14037
  );
13411
14038
  }
14039
+ /**
14040
+ * Sets the paused state.
14041
+ *
14042
+ * @param {PublicKey} owner - The owner public key.
14043
+ * @param {boolean} paused - The paused state.
14044
+ *
14045
+ * @returns {TransactionInstruction} The transaction instruction.
14046
+ */
13412
14047
  setPaused(owner, paused) {
13413
14048
  const [configAccount] = this.deriver.config();
13414
14049
  return createOwnerSetConfigInstruction(
@@ -13425,6 +14060,14 @@ var Executor = class {
13425
14060
  this.program
13426
14061
  );
13427
14062
  }
14063
+ /**
14064
+ * Sets the executors.
14065
+ *
14066
+ * @param {PublicKey} owner - The owner public key.
14067
+ * @param {PublicKey[]} executors - The executor public keys.
14068
+ *
14069
+ * @returns {TransactionInstruction} The transaction instruction.
14070
+ */
13428
14071
  setExecutors(owner, executors) {
13429
14072
  const [configAccount] = this.deriver.config();
13430
14073
  return createOwnerSetConfigInstruction(
@@ -13441,6 +14084,14 @@ var Executor = class {
13441
14084
  this.program
13442
14085
  );
13443
14086
  }
14087
+ /**
14088
+ * Sets the message libraries by programs.
14089
+ *
14090
+ * @param {PublicKey} owner - The owner public key.
14091
+ * @param {PublicKey[]} msglibPrograms - The message library program public keys.
14092
+ *
14093
+ * @returns {TransactionInstruction} The transaction instruction.
14094
+ */
13444
14095
  setMsglibByPrograms(owner, msglibPrograms) {
13445
14096
  this.deriver.config();
13446
14097
  const msglibPdas = msglibPrograms.map((program) => {
@@ -13448,6 +14099,14 @@ var Executor = class {
13448
14099
  });
13449
14100
  return this.setMsglibByPDAs(owner, msglibPdas);
13450
14101
  }
14102
+ /**
14103
+ * Sets the message libraries by PDAs.
14104
+ *
14105
+ * @param {PublicKey} owner - The owner public key.
14106
+ * @param {PublicKey[]} msglibPDAs - The message library PDA public keys.
14107
+ *
14108
+ * @returns {TransactionInstruction} The transaction instruction.
14109
+ */
13451
14110
  setMsglibByPDAs(owner, msglibPDAs) {
13452
14111
  const [configAccount] = this.deriver.config();
13453
14112
  return createOwnerSetConfigInstruction(
@@ -13465,6 +14124,14 @@ var Executor = class {
13465
14124
  );
13466
14125
  }
13467
14126
  // admin methods
14127
+ /**
14128
+ * Sets the default multiplier BPS.
14129
+ *
14130
+ * @param {PublicKey} admin - The admin public key.
14131
+ * @param {number} defaultMultiplierBps - The default multiplier BPS.
14132
+ *
14133
+ * @returns {TransactionInstruction} The transaction instruction.
14134
+ */
13468
14135
  setDefaultMultiplierBps(admin, defaultMultiplierBps) {
13469
14136
  const [configAccount] = this.deriver.config();
13470
14137
  return createAdminSetConfigInstruction(
@@ -13481,6 +14148,14 @@ var Executor = class {
13481
14148
  this.program
13482
14149
  );
13483
14150
  }
14151
+ /**
14152
+ * Sets the destination configurations.
14153
+ *
14154
+ * @param {PublicKey} admin - The admin public key.
14155
+ * @param {types.DstConfig[]} dstConfigs - The destination configurations.
14156
+ *
14157
+ * @returns {TransactionInstruction} The transaction instruction.
14158
+ */
13484
14159
  setDstConfig(admin, dstConfigs) {
13485
14160
  const [configAccount] = this.deriver.config();
13486
14161
  return createAdminSetConfigInstruction(
@@ -13497,6 +14172,14 @@ var Executor = class {
13497
14172
  this.program
13498
14173
  );
13499
14174
  }
14175
+ /**
14176
+ * Sets the price feed.
14177
+ *
14178
+ * @param {PublicKey} admin - The admin public key.
14179
+ * @param {PublicKey} priceFeedProgram - The price feed program public key.
14180
+ *
14181
+ * @returns {TransactionInstruction} The transaction instruction.
14182
+ */
13500
14183
  setPriceFeed(admin, priceFeedProgram) {
13501
14184
  const [configAccount] = this.deriver.config();
13502
14185
  const [priceFeed] = new PriceFeedPDADeriver(priceFeedProgram).priceFeed();
@@ -13514,6 +14197,14 @@ var Executor = class {
13514
14197
  this.program
13515
14198
  );
13516
14199
  }
14200
+ /**
14201
+ * Gets the executor configuration.
14202
+ *
14203
+ * @param {Connection} connection - The connection.
14204
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment or configuration.
14205
+ *
14206
+ * @returns {Promise<accounts.ExecutorConfig | null>} A promise that resolves to the executor configuration or null.
14207
+ */
13517
14208
  async getExecutorConfig(connection, commitmentOrConfig) {
13518
14209
  const [configAccount] = this.deriver.config();
13519
14210
  try {
@@ -13527,6 +14218,15 @@ var Executor = class {
13527
14218
  return null;
13528
14219
  }
13529
14220
  }
14221
+ /**
14222
+ * Gets the quote instruction account meta for CPI.
14223
+ *
14224
+ * @param {PublicKey} priceFeedConfig - The price feed configuration public key.
14225
+ * @param {PublicKey} priceFeedProgram - The price feed program public key.
14226
+ * @param {boolean} payment - Whether payment is required.
14227
+ *
14228
+ * @returns {AccountMeta[]} The account meta array.
14229
+ */
13530
14230
  getQuoteIXAccountMetaForCPI(priceFeedConfig, priceFeedProgram, payment) {
13531
14231
  const [config] = this.deriver.config();
13532
14232
  const ixAccounts = createQuoteExecutorInstructionAccounts(
@@ -13548,15 +14248,29 @@ var Executor = class {
13548
14248
  }
13549
14249
  ].concat(ixAccounts);
13550
14250
  }
14251
+ /**
14252
+ * Executes a transaction.
14253
+ *
14254
+ * @param {Connection} connection - The connection.
14255
+ * @param {PublicKey} executor - The executor public key.
14256
+ * @param {PublicKey} endpointProgram - The endpoint program public key.
14257
+ * @param {Packet} packet - The packet.
14258
+ * @param {Uint8Array} extraData - The extra data.
14259
+ * @param {BN} [value] - The value.
14260
+ * @param {number} [computeUnits] - The compute units.
14261
+ * @param {Commitment} [commitmentOrConfig] - The commitment or configuration.
14262
+ *
14263
+ * @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
14264
+ */
13551
14265
  async execute(connection, executor, endpointProgram, packet, extraData, value = new BN__default.default(0), computeUnits = 2e5, commitmentOrConfig) {
13552
14266
  const [config] = this.deriver.config();
13553
14267
  const endpointEventDeriver = new EventPDADeriver(endpointProgram);
13554
14268
  const executorEventDeriver = new EventPDADeriver(this.program);
13555
14269
  const { message: message_, sender, srcEid, guid, receiver: receiver_, nonce } = packet;
13556
- const receiver = new web314.PublicKey(addressToBytes32(receiver_));
14270
+ const receiver = new web314.PublicKey(lzV2Utilities.addressToBytes32(receiver_));
13557
14271
  const receiverInfo = await connection.getParsedAccountInfo(receiver, commitmentOrConfig);
13558
14272
  const receiverProgram = new web314.PublicKey(receiverInfo.value.owner);
13559
- const message = bytes.arrayify(message_);
14273
+ const message = lzUtilities.arrayify(message_);
13560
14274
  const accounts = await getLzReceiveAccounts(
13561
14275
  connection,
13562
14276
  executor,
@@ -13564,8 +14278,8 @@ var Executor = class {
13564
14278
  receiverProgram,
13565
14279
  {
13566
14280
  srcEid,
13567
- sender: Array.from(bytes.arrayify(sender)),
13568
- guid: Array.from(bytes.arrayify(guid)),
14281
+ sender: Array.from(lzUtilities.arrayify(sender)),
14282
+ guid: Array.from(lzUtilities.arrayify(guid)),
13569
14283
  message,
13570
14284
  callerParams: extraData,
13571
14285
  nonce: parseInt(packet.nonce)
@@ -13594,9 +14308,9 @@ var Executor = class {
13594
14308
  receiver,
13595
14309
  lzReceive: {
13596
14310
  srcEid,
13597
- sender: Array.from(bytes.arrayify(sender)),
14311
+ sender: Array.from(lzUtilities.arrayify(sender)),
13598
14312
  nonce: parseInt(nonce),
13599
- guid: Array.from(bytes.arrayify(guid)),
14313
+ guid: Array.from(lzUtilities.arrayify(guid)),
13600
14314
  message,
13601
14315
  extraData
13602
14316
  },
@@ -13607,6 +14321,20 @@ var Executor = class {
13607
14321
  this.program
13608
14322
  );
13609
14323
  }
14324
+ /**
14325
+ * Composes a transaction.
14326
+ *
14327
+ * @param {Connection} connection - The connection.
14328
+ * @param {PublicKey} executor - The executor public key.
14329
+ * @param {PublicKey} endpointProgram - The endpoint program public key.
14330
+ * @param {ComposeSentEvent} event - The compose sent event.
14331
+ * @param {Uint8Array} extraData - The extra data.
14332
+ * @param {BN} [value] - The value.
14333
+ * @param {number} [computeUnits] - The compute units.
14334
+ * @param {Commitment} [commitmentOrConfig] - The commitment or configuration.
14335
+ *
14336
+ * @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
14337
+ */
13610
14338
  async compose(connection, executor, endpointProgram, event, extraData, value = new BN__default.default(0), computeUnits = 4e5, commitmentOrConfig) {
13611
14339
  const [config] = this.deriver.config();
13612
14340
  const endpointEventDeriver = new EventPDADeriver(endpointProgram);
@@ -16469,12 +17197,26 @@ var PROGRAM_ID5 = new web314.PublicKey(PROGRAM_ADDRESS5);
16469
17197
 
16470
17198
  // src/uln.ts
16471
17199
  var Uln = class {
17200
+ /**
17201
+ * Creates an instance of the Uln class.
17202
+ *
17203
+ * @param {PublicKey} program - The program public key.
17204
+ */
16472
17205
  constructor(program) {
16473
17206
  this.program = program;
16474
17207
  this.deriver = new UlnPDADeriver(program);
16475
17208
  const [eventAuthorityPDA] = new EventPDADeriver(program).eventAuthority();
16476
17209
  this.eventAuthorityPDA = eventAuthorityPDA;
16477
17210
  }
17211
+ /**
17212
+ * Initializes the ULN.
17213
+ *
17214
+ * @param {PublicKey} endpointProgram - The endpoint program public key.
17215
+ * @param {PublicKey} payer - The payer public key.
17216
+ * @param {PublicKey} admin - The admin public key.
17217
+ * @param {number} eid - The endpoint ID.
17218
+ * @returns {TransactionInstruction} The transaction instruction.
17219
+ */
16478
17220
  initUln(endpointProgram, payer, admin, eid) {
16479
17221
  const [setting] = this.deriver.setting();
16480
17222
  const [msgLib] = this.deriver.messageLib();
@@ -16496,7 +17238,17 @@ var Uln = class {
16496
17238
  );
16497
17239
  }
16498
17240
  /**
17241
+ * Initializes or updates the default configuration.
16499
17242
  * before calling this function, you should call initUln to initialize the uln
17243
+ *
17244
+ * @param {Connection} connection - The connection to the Solana cluster.
17245
+ * @param {PublicKey} admin - The admin public key.
17246
+ * @param {number} eid - The endpoint ID.
17247
+ * @param {types.UlnConfig} sendUlnConfig - The send ULN configuration.
17248
+ * @param {types.UlnConfig} receiveUlnConfig - The receive ULN configuration.
17249
+ * @param {types.ExecutorConfig} executorConfig - The executor configuration.
17250
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
17251
+ * @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
16500
17252
  */
16501
17253
  async initOrUpdateDefaultConfig(connection, admin, eid, sendUlnConfig, receiveUlnConfig, executorConfig, commitmentOrConfig) {
16502
17254
  const [setting] = this.deriver.setting();
@@ -16547,7 +17299,18 @@ var Uln = class {
16547
17299
  }
16548
17300
  // msg_lib -> msg_lib_program ->
16549
17301
  /**
17302
+ * Sets the treasury.
16550
17303
  * before calling this function, you should call initUln to initialize the uln
17304
+ *
17305
+ * @param {PublicKey} admin - The admin public key.
17306
+ * @param {object} treasury - The treasury object.
17307
+ * @param {PublicKey} treasury.admin - The treasury admin public key.
17308
+ * @param {PublicKey} treasury.nativeReceiver - The native receiver public key.
17309
+ * @param {number} treasury.nativeFeeBps - The native fee basis points.
17310
+ * @param {object} treasury.lzToken - The LZ token object.
17311
+ * @param {PublicKey} treasury.lzToken.receiver - The LZ token receiver public key.
17312
+ * @param {number} treasury.lzToken.fee - The LZ token fee.
17313
+ * @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
16551
17314
  */
16552
17315
  async setTreasury(admin, treasury) {
16553
17316
  const [setting] = this.deriver.setting();
@@ -16567,6 +17330,16 @@ var Uln = class {
16567
17330
  );
16568
17331
  return Promise.resolve(ix);
16569
17332
  }
17333
+ /**
17334
+ * Transfers the admin role to a new admin.
17335
+ *
17336
+ * @param {Connection} connection - The connection to the Solana cluster.
17337
+ * @param {PublicKey} admin - The current admin public key.
17338
+ * @param {PublicKey} newAdmin - The new admin public key.
17339
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
17340
+ * @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
17341
+ * @throws {Error} If the ULN is not initialized.
17342
+ */
16570
17343
  async transferAdmin(connection, admin, newAdmin, commitmentOrConfig) {
16571
17344
  const [setting] = this.deriver.setting();
16572
17345
  const info = await connection.getAccountInfo(setting, commitmentOrConfig);
@@ -16589,19 +17362,17 @@ var Uln = class {
16589
17362
  );
16590
17363
  }
16591
17364
  /**
17365
+ * Gets the account metadata for the CPI (Cross-Program Invocation) of the quote instruction.
16592
17366
  *
16593
- * @param connection
16594
- *
16595
- * @param sender the oApp PDA
16596
- * @param sendLibraryAuthority
16597
- * @param dstEid
16598
- * @param payInLzToken
16599
- * @param commitment
16600
- * @returns
17367
+ * @param {Connection} connection - The connection to the Solana cluster.
17368
+ * @param {PublicKey} _payer - The payer public key.
17369
+ * @param {PacketPath} path - The packet path.
17370
+ * @param {Commitment} [commitment] - The commitment level.
17371
+ * @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
16601
17372
  */
16602
17373
  async getQuoteIXAccountMetaForCPI(connection, _payer, path, commitment) {
16603
17374
  const { sender: sender_, dstEid } = path;
16604
- const sender = new web314.PublicKey(bytes.arrayify(sender_));
17375
+ const sender = new web314.PublicKey(lzUtilities.arrayify(sender_));
16605
17376
  const [defaultSendConfig] = this.deriver.defaultSendConfig(dstEid);
16606
17377
  const [sendConfig] = this.deriver.sendConfig(dstEid, sender);
16607
17378
  const [setting] = this.deriver.setting();
@@ -16619,12 +17390,18 @@ var Uln = class {
16619
17390
  );
16620
17391
  return accounts.slice(1);
16621
17392
  }
16622
- /***
16623
- * Get the account meta of the send instruction for CPI(Cross-Program Invocation )
17393
+ /**
17394
+ * Gets the account metadata for the CPI (Cross-Program Invocation) of the send instruction.
17395
+ *
17396
+ * @param {Connection} connection - The connection to the Solana cluster.
17397
+ * @param {PublicKey} payer - The payer public key.
17398
+ * @param {PacketPath} path - The packet path.
17399
+ * @param {Commitment} [commitment='confirmed'] - The commitment level.
17400
+ * @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
16624
17401
  */
16625
17402
  async getSendIXAccountMetaForCPI(connection, payer, path, commitment = "confirmed") {
16626
17403
  const { sender: sender_, dstEid } = path;
16627
- const sender = new web314.PublicKey(bytes.arrayify(sender_));
17404
+ const sender = new web314.PublicKey(lzUtilities.arrayify(sender_));
16628
17405
  const [sendConfig] = this.deriver.sendConfig(dstEid, sender);
16629
17406
  const [defaultSendConfig] = this.deriver.defaultSendConfig(dstEid);
16630
17407
  const [setting] = this.deriver.setting();
@@ -16658,6 +17435,16 @@ var Uln = class {
16658
17435
  return accounts.slice(1);
16659
17436
  }
16660
17437
  // 3 RPC requests
17438
+ /**
17439
+ * Gets the remaining accounts for the send instruction.
17440
+ *
17441
+ * @param {Connection} connection - The connection to the Solana cluster.
17442
+ * @param {PublicKey} sender - The sender public key.
17443
+ * @param {number} dstEid - The destination endpoint ID.
17444
+ * @param {boolean} payment - Indicates if payment is required.
17445
+ * @param {Commitment | GetAccountInfoConfig} [commitment='confirmed'] - The commitment level or account info configuration.
17446
+ * @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
17447
+ */
16661
17448
  async getSendIxRemainingAccounts(connection, sender, dstEid, payment, commitment = "confirmed") {
16662
17449
  const { executor, dvns } = await this.getWorkers(connection, sender, dstEid, commitment);
16663
17450
  const priceFeeds = new Array();
@@ -16668,7 +17455,7 @@ var Uln = class {
16668
17455
  });
16669
17456
  const priceFeedInfos = await connection.getMultipleAccountsInfo(priceFeeds, commitment);
16670
17457
  const priceFeedDict = priceFeedInfos.reduce((acc, info, i) => {
16671
- invariant4__default.default(info, `priceFeed:${priceFeeds[i].toBase58()} not initialized`);
17458
+ invariant3__default.default(info, `priceFeed:${priceFeeds[i].toBase58()} not initialized`);
16672
17459
  acc.set(priceFeeds[i].toBase58(), info.owner);
16673
17460
  return acc;
16674
17461
  }, /* @__PURE__ */ new Map());
@@ -16688,9 +17475,15 @@ var Uln = class {
16688
17475
  });
16689
17476
  return executorAccounts.concat(dvnAccounts.flat());
16690
17477
  }
16691
- /***
16692
- * Get all workers(executor&DVN)
17478
+ /**
17479
+ * Gets all workers (executor and DVN).
16693
17480
  * 2 RPC requests
17481
+ *
17482
+ * @param {Connection} connection - The connection to the Solana cluster.
17483
+ * @param {PublicKey} sender - The sender public key.
17484
+ * @param {number} eid - The endpoint ID.
17485
+ * @param {Commitment | GetAccountInfoConfig} [commitment='confirmed'] - The commitment level or account info configuration.
17486
+ * @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
17487
  */
16695
17488
  async getWorkers(connection, sender, eid, commitment = "confirmed") {
16696
17489
  const [defaultSendConfig] = this.deriver.defaultSendConfig(eid);
@@ -16699,7 +17492,7 @@ var Uln = class {
16699
17492
  [defaultSendConfig, sendConfig],
16700
17493
  commitment
16701
17494
  );
16702
- invariant4__default.default(defaultSendConfigBuf, "defaultSendConfig not initialized");
17495
+ invariant3__default.default(defaultSendConfigBuf, "defaultSendConfig not initialized");
16703
17496
  const [defaultSendConfigState] = SendConfig.fromAccountInfo(defaultSendConfigBuf);
16704
17497
  let {
16705
17498
  executor,
@@ -16724,14 +17517,14 @@ var Uln = class {
16724
17517
  [executor.executor, ...dvns],
16725
17518
  commitment
16726
17519
  );
16727
- invariant4__default.default(executorBuf, `executor:${executor.executor.toBase58()} not initialized`);
17520
+ invariant3__default.default(executorBuf, `executor:${executor.executor.toBase58()} not initialized`);
16728
17521
  return {
16729
17522
  executor: {
16730
17523
  config: accounts_exports4.ExecutorConfig.fromAccountInfo(executorBuf)[0],
16731
17524
  owner: executorBuf.owner
16732
17525
  },
16733
17526
  dvns: dvnBuf.map((dvn, i) => {
16734
- invariant4__default.default(dvn, `dvn:${dvns[i].toBase58()} not initialized`);
17527
+ invariant3__default.default(dvn, `dvn:${dvns[i].toBase58()} not initialized`);
16735
17528
  return {
16736
17529
  config: accounts_exports3.DvnConfig.fromAccountInfo(dvn)[0],
16737
17530
  owner: dvn.owner
@@ -16739,8 +17532,18 @@ var Uln = class {
16739
17532
  })
16740
17533
  };
16741
17534
  }
17535
+ /**
17536
+ * Initializes the verification process.
17537
+ *
17538
+ * @param {Connection} connection - The connection to the Solana cluster.
17539
+ * @param {PublicKey} payer - The payer public key.
17540
+ * @param {PublicKey} dvn - The DVN public key.
17541
+ * @param {Uint8Array} packetBytes - The packet bytes.
17542
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
17543
+ * @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
17544
+ */
16742
17545
  async initVerify(connection, payer, dvn, packetBytes, commitmentOrConfig) {
16743
- const packet = PacketV1Codec.fromBytes(packetBytes);
17546
+ const packet = lzV2Utilities.PacketV1Codec.fromBytes(packetBytes);
16744
17547
  const headerHash = packet.headerHash();
16745
17548
  const headerHashBytes = Uint8Array.from(Buffer.from(headerHash.slice(2), "hex"));
16746
17549
  const payloadHash = packet.payloadHash();
@@ -16765,8 +17568,16 @@ var Uln = class {
16765
17568
  this.program
16766
17569
  );
16767
17570
  }
17571
+ /**
17572
+ * Verifies the packet.
17573
+ *
17574
+ * @param {PublicKey} dvn - The DVN public key.
17575
+ * @param {Uint8Array} packetBytes - The packet bytes.
17576
+ * @param {number | string} confirmations - The number of confirmations.
17577
+ * @returns {TransactionInstruction} The transaction instruction.
17578
+ */
16768
17579
  verify(dvn, packetBytes, confirmations) {
16769
- const packet = PacketV1Codec.fromBytes(packetBytes);
17580
+ const packet = lzV2Utilities.PacketV1Codec.fromBytes(packetBytes);
16770
17581
  const headerHash = packet.headerHash();
16771
17582
  const headerHashBytes = Uint8Array.from(Buffer.from(headerHash.slice(2), "hex"));
16772
17583
  const payloadHash = packet.payloadHash();
@@ -16789,8 +17600,16 @@ var Uln = class {
16789
17600
  this.program
16790
17601
  );
16791
17602
  }
17603
+ /**
17604
+ * Closes the verification process.
17605
+ *
17606
+ * @param {PublicKey} dvn - The DVN public key.
17607
+ * @param {PublicKey} receiver - The receiver public key.
17608
+ * @param {Uint8Array} packetBytes - The packet bytes.
17609
+ * @returns {TransactionInstruction} The transaction instruction.
17610
+ */
16792
17611
  closeVerify(dvn, receiver, packetBytes) {
16793
- const packet = PacketV1Codec.fromBytes(packetBytes);
17612
+ const packet = lzV2Utilities.PacketV1Codec.fromBytes(packetBytes);
16794
17613
  const headerHash = packet.headerHash();
16795
17614
  const headerHashBytes = Uint8Array.from(Buffer.from(headerHash.slice(2), "hex"));
16796
17615
  const payloadHash = packet.payloadHash();
@@ -16811,16 +17630,26 @@ var Uln = class {
16811
17630
  this.program
16812
17631
  );
16813
17632
  }
17633
+ /**
17634
+ * Checks if the DVN is verified.
17635
+ *
17636
+ * @param {Connection} connection - The connection to the Solana cluster.
17637
+ * @param {PublicKey} endpointProgram - The endpoint program public key.
17638
+ * @param {PublicKey} dvn - The DVN public key.
17639
+ * @param {Uint8Array} packetBytes - The packet bytes.
17640
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig='confirmed'] - The commitment level or account info configuration.
17641
+ * @returns {Promise<boolean>} A promise that resolves to true if the DVN is verified, false otherwise.
17642
+ */
16814
17643
  async isDvnVerified(connection, endpointProgram, dvn, packetBytes, commitmentOrConfig = "confirmed") {
16815
- const packet = PacketV1Codec.fromBytes(packetBytes);
17644
+ const packet = lzV2Utilities.PacketV1Codec.fromBytes(packetBytes);
16816
17645
  const headerHash = packet.headerHash();
16817
17646
  const headerHashBytes = Uint8Array.from(Buffer.from(headerHash.slice(2), "hex"));
16818
17647
  const payloadHash = packet.payloadHash();
16819
17648
  const payloadHashBytes = Uint8Array.from(Buffer.from(payloadHash.slice(2), "hex"));
16820
17649
  const [confirmationsPDA] = this.deriver.confirmations(headerHashBytes, payloadHashBytes, dvn);
16821
17650
  const endpoint = new endpoint_exports.Endpoint(endpointProgram);
16822
- const receiver = new web314.PublicKey(bytes.arrayify(packet.receiver()));
16823
- const sender = bytes.arrayify(packet.sender());
17651
+ const receiver = new web314.PublicKey(lzUtilities.arrayify(packet.receiver()));
17652
+ const sender = lzUtilities.arrayify(packet.sender());
16824
17653
  const nonce = await endpoint.getNonce(connection, receiver, packet.srcEid(), sender, commitmentOrConfig);
16825
17654
  const pendingNonce = await endpoint.getPendingInboundNonce(
16826
17655
  connection,
@@ -16853,11 +17682,19 @@ var Uln = class {
16853
17682
  return false;
16854
17683
  }
16855
17684
  }
17685
+ /**
17686
+ * Commits the verification process.
17687
+ *
17688
+ * @param {Connection} connection - The connection to the Solana cluster.
17689
+ * @param {PublicKey} endpointProgram - The endpoint program public key.
17690
+ * @param {Uint8Array} packetBytes - The packet bytes.
17691
+ * @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
17692
+ */
16856
17693
  async commitVerification(connection, endpointProgram, packetBytes) {
16857
- const packet = PacketV1Codec.fromBytes(packetBytes);
17694
+ const packet = lzV2Utilities.PacketV1Codec.fromBytes(packetBytes);
16858
17695
  const payloadHash = packet.payloadHash();
16859
17696
  const srcEid = packet.srcEid();
16860
- const receiver = new web314.PublicKey(bytes.arrayify(packet.receiver()));
17697
+ const receiver = new web314.PublicKey(lzUtilities.arrayify(packet.receiver()));
16861
17698
  const payloadHashBytes = Uint8Array.from(Buffer.from(payloadHash.slice(2), "hex"));
16862
17699
  const [defaultReceiveConfig] = this.deriver.defaultReceiveConfig(srcEid);
16863
17700
  const [receiveConfig] = this.deriver.receiveConfig(srcEid, receiver);
@@ -16885,15 +17722,20 @@ var Uln = class {
16885
17722
  },
16886
17723
  {
16887
17724
  params: {
16888
- packetHeader: Array.from(bytes.arrayify(packet.header())),
17725
+ packetHeader: Array.from(lzUtilities.arrayify(packet.header())),
16889
17726
  payloadHash: Array.from(payloadHashBytes)
16890
17727
  }
16891
17728
  },
16892
17729
  this.program
16893
17730
  );
16894
17731
  }
16895
- /***
16896
- * Get the account meta of the send instruction for CPI(Cross-Program Invocation )
17732
+ /**
17733
+ * Gets the account metadata for the CPI (Cross-Program Invocation) of the init config instruction.
17734
+ *
17735
+ * @param {PublicKey} payer - The payer public key.
17736
+ * @param {PublicKey} oappID - The OApp ID public key.
17737
+ * @param {number} eid - The endpoint ID.
17738
+ * @returns {AccountMeta[]} An array of account metadata.
16897
17739
  */
16898
17740
  getInitConfigIXAccountMetaForCPI(payer, oappID, eid) {
16899
17741
  const [sendConfig] = this.deriver.sendConfig(eid, oappID);
@@ -16917,6 +17759,14 @@ var Uln = class {
16917
17759
  });
16918
17760
  return accounts.slice(1);
16919
17761
  }
17762
+ /**
17763
+ * Constructs the set config data.
17764
+ *
17765
+ * @param {SetConfigType} configType - The configuration type.
17766
+ * @param {types.ExecutorConfig | types.UlnConfig} configData - The configuration data.
17767
+ * @returns {Uint8Array} The constructed set config data.
17768
+ * @throws {Error} If the configuration type is invalid.
17769
+ */
16920
17770
  static constructSetConfigData(configType, configData) {
16921
17771
  switch (configType) {
16922
17772
  case 1 /* EXECUTOR */: {
@@ -16933,8 +17783,12 @@ var Uln = class {
16933
17783
  }
16934
17784
  }
16935
17785
  /**
16936
- * @param oappID the oApp PDA
17786
+ * Gets the account metadata for the CPI (Cross-Program Invocation) of the set config instruction.
16937
17787
  *
17788
+ * @param {PublicKey} endpointProgram - The endpoint program public key.
17789
+ * @param {PublicKey} oappID - The OApp ID public key.
17790
+ * @param {number} eid - The endpoint ID.
17791
+ * @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
16938
17792
  */
16939
17793
  async getSetConfigIXAccountMetaForCPI(endpointProgram, oappID, eid) {
16940
17794
  const [sendConfig] = this.deriver.sendConfig(eid, oappID);
@@ -16961,6 +17815,13 @@ var Uln = class {
16961
17815
  }
16962
17816
  //
16963
17817
  // all of below functions are retrieving accounts state
17818
+ /**
17819
+ * Gets the ULN settings.
17820
+ *
17821
+ * @param {Connection} connection - The connection to the Solana cluster.
17822
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
17823
+ * @returns {Promise<accounts.UlnSettings | null>} A promise that resolves to the ULN settings or null if not found.
17824
+ */
16964
17825
  async getSetting(connection, commitmentOrConfig) {
16965
17826
  const [setting] = this.deriver.setting();
16966
17827
  try {
@@ -16969,6 +17830,14 @@ var Uln = class {
16969
17830
  return null;
16970
17831
  }
16971
17832
  }
17833
+ /**
17834
+ * Gets the default send configuration state.
17835
+ *
17836
+ * @param {Connection} connection - The connection to the Solana cluster.
17837
+ * @param {number} eid - The endpoint ID.
17838
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
17839
+ * @returns {Promise<accounts.SendConfig | null>} A promise that resolves to the default send configuration state or null if not found.
17840
+ */
16972
17841
  async getDefaultSendConfigState(connection, eid, commitmentOrConfig) {
16973
17842
  const [config] = this.deriver.defaultSendConfig(eid);
16974
17843
  try {
@@ -16977,6 +17846,15 @@ var Uln = class {
16977
17846
  return null;
16978
17847
  }
16979
17848
  }
17849
+ /**
17850
+ * Gets the send configuration state.
17851
+ *
17852
+ * @param {Connection} connection - The connection to the Solana cluster.
17853
+ * @param {PublicKey} sender - The sender public key.
17854
+ * @param {number} eid - The endpoint ID.
17855
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
17856
+ * @returns {Promise<accounts.SendConfig | null>} A promise that resolves to the send configuration state or null if not found.
17857
+ */
16980
17858
  async getSendConfigState(connection, sender, eid, commitmentOrConfig) {
16981
17859
  const [config] = this.deriver.sendConfig(eid, sender);
16982
17860
  try {
@@ -16985,6 +17863,14 @@ var Uln = class {
16985
17863
  return null;
16986
17864
  }
16987
17865
  }
17866
+ /**
17867
+ * Gets the default receive configuration state.
17868
+ *
17869
+ * @param {Connection} connection - The connection to the Solana cluster.
17870
+ * @param {number} eid - The endpoint ID.
17871
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
17872
+ * @returns {Promise<accounts.ReceiveConfig | null>} A promise that resolves to the default receive configuration state or null if not found.
17873
+ */
16988
17874
  async getDefaultReceiveConfigState(connection, eid, commitmentOrConfig) {
16989
17875
  const [config] = this.deriver.defaultReceiveConfig(eid);
16990
17876
  try {
@@ -16993,6 +17879,15 @@ var Uln = class {
16993
17879
  return null;
16994
17880
  }
16995
17881
  }
17882
+ /**
17883
+ * Gets the receive configuration state.
17884
+ *
17885
+ * @param {Connection} connection - The connection to the Solana cluster.
17886
+ * @param {PublicKey} receiver - The receiver public key.
17887
+ * @param {number} eid - The endpoint ID.
17888
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
17889
+ * @returns {Promise<accounts.ReceiveConfig | null>} A promise that resolves to the receive configuration state or null if not found.
17890
+ */
16996
17891
  async getReceiveConfigState(connection, receiver, eid, commitmentOrConfig) {
16997
17892
  const [config] = this.deriver.receiveConfig(eid, receiver);
16998
17893
  try {
@@ -17001,6 +17896,16 @@ var Uln = class {
17001
17896
  return null;
17002
17897
  }
17003
17898
  }
17899
+ /**
17900
+ * Gets the final receive configuration state.
17901
+ *
17902
+ * @param {Connection} connection - The connection to the Solana cluster.
17903
+ * @param {PublicKey} receiver - The receiver public key.
17904
+ * @param {number} eid - The endpoint ID.
17905
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig='confirmed'] - The commitment level or account info configuration.
17906
+ * @returns {Promise<accounts.ReceiveConfig>} A promise that resolves to the final receive configuration state.
17907
+ * @throws {Error} If no DVN is found.
17908
+ */
17004
17909
  async getFinalReceiveConfigState(connection, receiver, eid, commitmentOrConfig = "confirmed") {
17005
17910
  const NIL_CONFIRMATIONS = "18446744073709551615";
17006
17911
  const NIL_DVN_COUNT = "255";
@@ -17832,10 +18737,26 @@ var PROGRAM_ID6 = new web314.PublicKey(PROGRAM_ADDRESS6);
17832
18737
 
17833
18738
  // src/pricefeed.ts
17834
18739
  var PriceFeed2 = class {
18740
+ /**
18741
+ * Creates an instance of the PriceFeed class.
18742
+ *
18743
+ * @param {PublicKey} program - The public key of the program.
18744
+ */
17835
18745
  constructor(program) {
17836
18746
  this.program = program;
17837
18747
  this.deriver = new PriceFeedPDADeriver(this.program);
17838
18748
  }
18749
+ /**
18750
+ * Initializes the price feed.
18751
+ *
18752
+ * @param {Connection} connection - The Solana connection object.
18753
+ * @param {PublicKey} payer - The public key of the payer.
18754
+ * @param {PublicKey} admin - The public key of the admin.
18755
+ * @param {PublicKey[]} updaters - The list of public keys of the updaters.
18756
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - Optional commitment or configuration.
18757
+ *
18758
+ * @returns {Promise<TransactionInstruction>} The transaction instruction.
18759
+ */
17839
18760
  async initPriceFeed(connection, payer, admin, updaters, commitmentOrConfig) {
17840
18761
  const [priceFeed] = this.deriver.priceFeed();
17841
18762
  const info = await connection.getAccountInfo(priceFeed, commitmentOrConfig);
@@ -17856,6 +18777,16 @@ var PriceFeed2 = class {
17856
18777
  this.program
17857
18778
  );
17858
18779
  }
18780
+ /**
18781
+ * Sets the price feed.
18782
+ *
18783
+ * @param {PublicKey} admin - The public key of the admin.
18784
+ * @param {PublicKey[]} updaters - The list of public keys of the updaters.
18785
+ * @param {bignum} priceRatioDenominator - The price ratio denominator.
18786
+ * @param {number} arbitrumCompressionPercent - The Arbitrum compression percentage.
18787
+ *
18788
+ * @returns {TransactionInstruction} The transaction instruction.
18789
+ */
17859
18790
  setPriceFeed(admin, updaters, priceRatioDenominator, arbitrumCompressionPercent) {
17860
18791
  const [priceFeed] = this.deriver.priceFeed();
17861
18792
  return createSetPriceFeedInstruction(
@@ -17873,6 +18804,18 @@ var PriceFeed2 = class {
17873
18804
  this.program
17874
18805
  );
17875
18806
  }
18807
+ /**
18808
+ * Sets the price.
18809
+ *
18810
+ * @param {PublicKey} updater - The public key of the updater.
18811
+ * @param {number} dstEid - The destination EID.
18812
+ * @param {bignum} priceRatio - The price ratio.
18813
+ * @param {bignum} gasPriceInUnit - The gas price in unit.
18814
+ * @param {number} gasPerByte - The gas per byte.
18815
+ * @param {types.ModelType | null} modelType - The model type.
18816
+ *
18817
+ * @returns {TransactionInstruction} The transaction instruction.
18818
+ */
17876
18819
  setPrice(updater, dstEid, priceRatio, gasPriceInUnit, gasPerByte, modelType) {
17877
18820
  const EID_MODULUS = 3e4;
17878
18821
  dstEid = dstEid % EID_MODULUS;
@@ -17896,6 +18839,14 @@ var PriceFeed2 = class {
17896
18839
  this.program
17897
18840
  );
17898
18841
  }
18842
+ /**
18843
+ * Sets the SOL price.
18844
+ *
18845
+ * @param {PublicKey} updater - The public key of the updater.
18846
+ * @param {bignum | null} nativeTokenPriceUsd - The native token price in USD.
18847
+ *
18848
+ * @returns {TransactionInstruction} The transaction instruction.
18849
+ */
17899
18850
  setSolPrice(updater, nativeTokenPriceUsd) {
17900
18851
  const [priceFeed] = this.deriver.priceFeed();
17901
18852
  return createSetSolPriceInstruction(
@@ -17911,6 +18862,14 @@ var PriceFeed2 = class {
17911
18862
  this.program
17912
18863
  );
17913
18864
  }
18865
+ /**
18866
+ * Transfers the admin role.
18867
+ *
18868
+ * @param {PublicKey} admin - The public key of the current admin.
18869
+ * @param {PublicKey} newAdmin - The public key of the new admin.
18870
+ *
18871
+ * @returns {TransactionInstruction} The transaction instruction.
18872
+ */
17914
18873
  transferAdmin(admin, newAdmin) {
17915
18874
  const [priceFeed] = this.deriver.priceFeed();
17916
18875
  return createTransferAdminInstruction4(
@@ -17926,6 +18885,14 @@ var PriceFeed2 = class {
17926
18885
  this.program
17927
18886
  );
17928
18887
  }
18888
+ /**
18889
+ * Retrieves the price feed account.
18890
+ *
18891
+ * @param {Connection} connection - The Solana connection object.
18892
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - Optional commitment or configuration.
18893
+ *
18894
+ * @returns {Promise<accounts.PriceFeed | null>} The price feed account or null if not found.
18895
+ */
17929
18896
  async getPriceFeed(connection, commitmentOrConfig) {
17930
18897
  const [priceFeed] = this.deriver.priceFeed();
17931
18898
  try {
@@ -17958,19 +18925,52 @@ function deriveLzComposeTypesAccountsPDA(program, oappId) {
17958
18925
  return web314.PublicKey.findProgramAddressSync([Buffer.from(LZ_COMPOSE_TYPES_SEED, "utf8")], program);
17959
18926
  }
17960
18927
  var BaseOApp = class {
18928
+ /**
18929
+ * Creates an instance of the BaseOApp class.
18930
+ *
18931
+ * @param {PublicKey} program - The program public key.
18932
+ */
17961
18933
  constructor(program) {
17962
18934
  this.program = program;
17963
18935
  this.oappBaseDeriver = new OAppBasePDADeriver(program);
17964
18936
  }
18937
+ /**
18938
+ * Queries the ID PDA info.
18939
+ *
18940
+ * @param {Connection} connection - The connection.
18941
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment or config.
18942
+ * @returns {Promise<AccountInfo<Buffer> | null>} The account info.
18943
+ */
17965
18944
  async queryIDPDAInfo(connection, commitmentOrConfig) {
17966
18945
  return this.queryPDAInfo(connection, this.idPDA()[0], commitmentOrConfig);
17967
18946
  }
18947
+ /**
18948
+ * Queries the PDA info.
18949
+ *
18950
+ * @param {Connection} connection - The connection.
18951
+ * @param {PublicKey} pda - The PDA public key.
18952
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment or config.
18953
+ * @returns {Promise<AccountInfo<Buffer> | null>} The account info.
18954
+ */
17968
18955
  async queryPDAInfo(connection, pda, commitmentOrConfig) {
17969
18956
  return connection.getAccountInfo(pda, commitmentOrConfig);
17970
18957
  }
18958
+ /**
18959
+ * Gets the ID PDA.
18960
+ *
18961
+ * @returns {[PublicKey, number]} The ID PDA and bump.
18962
+ */
17971
18963
  idPDA() {
17972
18964
  return oappIDPDA(this.program);
17973
18965
  }
18966
+ /**
18967
+ * Gets the remote.
18968
+ *
18969
+ * @param {Connection} connection - The connection.
18970
+ * @param {number} dstEid - The destination endpoint ID.
18971
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment or config.
18972
+ * @returns {Promise<Uint8Array | null>} The remote data.
18973
+ */
17974
18974
  async getRemote(connection, dstEid, commitmentOrConfig) {
17975
18975
  const [remotePDA] = this.oappBaseDeriver.remote(dstEid);
17976
18976
  const info = await this.queryPDAInfo(connection, remotePDA, commitmentOrConfig);
@@ -18072,6 +19072,13 @@ function createVersionInstructionAccounts3(programId) {
18072
19072
  var PROGRAM_ADDRESS7 = "2XrYqmhBMPJgDsb4SVbjV1PnJBprurd5bzRCkHwiFCJB";
18073
19073
  var PROGRAM_ID7 = new web314.PublicKey(PROGRAM_ADDRESS7);
18074
19074
  var SendHelper = class {
19075
+ /**
19076
+ * Creates an instance of the SendHelper class.
19077
+ *
19078
+ * @param {PublicKey} [endpointProgram=EndpointProgram.PROGRAM_ID] - The endpoint program public key.
19079
+ * @param {PublicKey} [ulnProgram=UlnProgram.PROGRAM_ID] - The ULN program public key.
19080
+ * @param {PublicKey} [simpleMsgLibProgram=SimpleMessageLibProgram.PROGRAM_ID] - The simple message library program public key.
19081
+ */
18075
19082
  constructor(endpointProgram = endpoint_exports.PROGRAM_ID, ulnProgram = uln_exports.PROGRAM_ID, simpleMsgLibProgram = simple_message_lib_exports.PROGRAM_ID) {
18076
19083
  this.endpointProgram = endpointProgram;
18077
19084
  this.ulnProgram = ulnProgram;
@@ -18081,6 +19088,14 @@ var SendHelper = class {
18081
19088
  this.uln = new uln_exports.Uln(ulnProgram);
18082
19089
  this.simpleMsgLib = new simple_message_lib_exports.SimpleMessageLib(simpleMsgLibProgram);
18083
19090
  }
19091
+ /**
19092
+ * Fetches multiple account information.
19093
+ *
19094
+ * @param {Connection} connection - The connection to the Solana cluster.
19095
+ * @param {PublicKey[]} keys - The public keys of the accounts.
19096
+ * @param {Commitment | GetAccountInfoConfig} [commitment] - The commitment level or account info configuration.
19097
+ * @returns {Promise<(AccountInfo<Buffer> | null)[]>} A promise that resolves to an array of account information.
19098
+ */
18084
19099
  async getMultipleAccountsInfo(connection, keys, commitment) {
18085
19100
  const missingKeys = keys.filter((key) => !this.accounts.has(key.toBase58()));
18086
19101
  if (missingKeys.length > 0) {
@@ -18091,6 +19106,17 @@ var SendHelper = class {
18091
19106
  }
18092
19107
  return keys.map((key) => this.accounts.get(key.toBase58()));
18093
19108
  }
19109
+ /**
19110
+ * Gets the account metadata for the quote instruction.
19111
+ *
19112
+ * @param {Connection} connection - The connection to the Solana cluster.
19113
+ * @param {PublicKey} payer - The payer public key.
19114
+ * @param {PublicKey} sender - The sender public key.
19115
+ * @param {number} dstEid - The destination endpoint ID.
19116
+ * @param {string} receiver - The receiver address.
19117
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig='confirmed'] - The commitment level or account info configuration.
19118
+ * @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
19119
+ */
18094
19120
  async getQuoteAccounts(connection, payer, sender, dstEid, receiver, commitmentOrConfig = "confirmed") {
18095
19121
  const [sendLibConfig] = this.endpoint.deriver.sendLibraryConfig(sender, dstEid);
18096
19122
  const [defaultSendLibConfig] = this.endpoint.deriver.defaultSendLibraryConfig(dstEid);
@@ -18110,7 +19136,7 @@ var SendHelper = class {
18110
19136
  [sendLibConfig, defaultSendLibConfig, simpleMsgLib, uln, ulnDefaultSendConfig, ulnSendConfig],
18111
19137
  commitmentOrConfig
18112
19138
  );
18113
- invariant4__default.default(defaultSendLibConfigBuf && sendLibConfigBuf, "endpoint send library not initialized");
19139
+ invariant3__default.default(defaultSendLibConfigBuf && sendLibConfigBuf, "endpoint send library not initialized");
18114
19140
  const [sendLibConfigInfo] = endpoint_exports.accounts.SendLibraryConfig.fromAccountInfo(sendLibConfigBuf, 0);
18115
19141
  const [defaultSendLibConfigInfo] = endpoint_exports.accounts.SendLibraryConfig.fromAccountInfo(
18116
19142
  defaultSendLibConfigBuf,
@@ -18149,14 +19175,16 @@ var SendHelper = class {
18149
19175
  );
18150
19176
  }
18151
19177
  /**
18152
- * @param connection
18153
- * @param payer
18154
- * @param sender the PDA of the oApp
18155
- * @param dstEid the destination endpoint id
18156
- * @param receiver the remote peer's address
18157
- * @param commitmentOrConfig
18158
- * 1 or 3(1+2) RPC calls
18159
- * */
19178
+ * Gets the account metadata for the send instruction.
19179
+ *
19180
+ * @param {Connection} connection - The connection to the Solana cluster.
19181
+ * @param {PublicKey} payer - The payer public key.
19182
+ * @param {PublicKey} sender - The sender public key.
19183
+ * @param {number} dstEid - The destination endpoint ID.
19184
+ * @param {string} receiver - The receiver address.
19185
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig='confirmed'] - The commitment level or account info configuration.
19186
+ * @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
19187
+ */
18160
19188
  async getSendAccounts(connection, payer, sender, dstEid, receiver, commitmentOrConfig = "confirmed") {
18161
19189
  const [sendLibConfig] = this.endpoint.deriver.sendLibraryConfig(sender, dstEid);
18162
19190
  const [defaultSendLibConfig] = this.endpoint.deriver.defaultSendLibraryConfig(dstEid);
@@ -18176,7 +19204,7 @@ var SendHelper = class {
18176
19204
  [sendLibConfig, defaultSendLibConfig, simpleMsgLib, uln, ulnDefaultSendConfig, ulnSendConfig],
18177
19205
  commitmentOrConfig
18178
19206
  );
18179
- invariant4__default.default(defaultSendLibConfigBuf && sendLibConfigBuf, "endpoint send library not initialized");
19207
+ invariant3__default.default(defaultSendLibConfigBuf && sendLibConfigBuf, "endpoint send library not initialized");
18180
19208
  const [sendLibConfigInfo] = endpoint_exports.accounts.SendLibraryConfig.fromAccountInfo(sendLibConfigBuf, 0);
18181
19209
  const [defaultSendLibConfigInfo] = endpoint_exports.accounts.SendLibraryConfig.fromAccountInfo(
18182
19210
  defaultSendLibConfigBuf,
@@ -18214,11 +19242,22 @@ var SendHelper = class {
18214
19242
  )
18215
19243
  );
18216
19244
  }
19245
+ /**
19246
+ * Gets the account metadata for the endpoint.
19247
+ *
19248
+ * @param {PublicKey} msgLibProgram - The message library program public key.
19249
+ * @param {PublicKey} msgLib - The message library public key.
19250
+ * @param {PublicKey} sender - The sender public key.
19251
+ * @param {number} dstEid - The destination endpoint ID.
19252
+ * @param {string} receiver - The receiver address.
19253
+ * @param {QuoteOrSend} quoteOrSend - The quote or send action.
19254
+ * @returns {AccountMeta[]} An array of account metadata.
19255
+ */
18217
19256
  getEndpointAccounts(msgLibProgram, msgLib, sender, dstEid, receiver, quoteOrSend) {
18218
19257
  const [sendLibraryConfig] = this.endpoint.deriver.sendLibraryConfig(sender, dstEid);
18219
19258
  const [defaultSendLibraryConfig] = this.endpoint.deriver.defaultSendLibraryConfig(dstEid);
18220
19259
  const [sendLibraryInfo] = this.endpoint.deriver.messageLibraryInfo(msgLib);
18221
- const [nonce] = this.endpoint.deriver.nonce(sender, dstEid, addressToBytes32(receiver));
19260
+ const [nonce] = this.endpoint.deriver.nonce(sender, dstEid, lzV2Utilities.addressToBytes32(receiver));
18222
19261
  let accounts;
18223
19262
  if (quoteOrSend === 0 /* Quote */) {
18224
19263
  accounts = endpoint_exports.instructions.createQuoteInstructionAccounts(
@@ -18260,6 +19299,13 @@ var SendHelper = class {
18260
19299
  }
18261
19300
  ].concat(accounts);
18262
19301
  }
19302
+ /**
19303
+ * Gets the account metadata for the simple message library.
19304
+ *
19305
+ * @param {PublicKey} payer - The payer public key.
19306
+ * @param {QuoteOrSend} quoteOrSend - The quote or send action.
19307
+ * @returns {AccountMeta[]} An array of account metadata.
19308
+ */
18263
19309
  getSimpleMsgLibAccounts(payer, quoteOrSend) {
18264
19310
  const [msgLib] = this.simpleMsgLib.deriver.messageLib();
18265
19311
  let accounts;
@@ -18290,9 +19336,20 @@ var SendHelper = class {
18290
19336
  });
18291
19337
  return accounts.slice(1);
18292
19338
  }
18293
- // 2 RPC calls
19339
+ /**
19340
+ * Gets the account metadata for the ULN.
19341
+ *
19342
+ * @param {Connection} connection - The connection to the Solana cluster.
19343
+ * @param {PublicKey} payer - The payer public key.
19344
+ * @param {KeyedAccountInfo} ulnInfo - The ULN account information.
19345
+ * @param {KeyedAccountInfo} ulnDefaultSendConfigInfo - The ULN default send configuration account information.
19346
+ * @param {KeyedAccountInfo} ulnSendConfigInfo - The ULN send configuration account information.
19347
+ * @param {QuoteOrSend} quoteOrSend - The quote or send action.
19348
+ * @param {Commitment | GetAccountInfoConfig} [commitment] - The commitment level or account info configuration.
19349
+ * @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
19350
+ */
18294
19351
  async getUlnAccounts(connection, payer, ulnInfo, ulnDefaultSendConfigInfo, ulnSendConfigInfo, quoteOrSend, commitment) {
18295
- invariant4__default.default(ulnInfo.accountInfo && ulnDefaultSendConfigInfo.accountInfo, "uln send library not initialized");
19352
+ invariant3__default.default(ulnInfo.accountInfo && ulnDefaultSendConfigInfo.accountInfo, "uln send library not initialized");
18296
19353
  const [ulnState] = uln_exports.accounts.UlnSettings.fromAccountInfo(ulnInfo.accountInfo, 0);
18297
19354
  const [defaultSendConfigState] = uln_exports.accounts.SendConfig.fromAccountInfo(
18298
19355
  ulnDefaultSendConfigInfo.accountInfo,
@@ -18322,7 +19379,7 @@ var SendHelper = class {
18322
19379
  [executor.executor, ...dvnsKey],
18323
19380
  commitment
18324
19381
  );
18325
- invariant4__default.default(executorBuf, `executor:${executor.executor.toBase58()} not initialized`);
19382
+ invariant3__default.default(executorBuf, `executor:${executor.executor.toBase58()} not initialized`);
18326
19383
  let executorAccounts, dvnAccounts;
18327
19384
  {
18328
19385
  const executor2 = {
@@ -18330,7 +19387,7 @@ var SendHelper = class {
18330
19387
  owner: executorBuf.owner
18331
19388
  };
18332
19389
  const dvns = dvnBuf.map((dvn, i) => {
18333
- invariant4__default.default(dvn, `dvn:${dvnsKey[i].toBase58()} not initialized`);
19390
+ invariant3__default.default(dvn, `dvn:${dvnsKey[i].toBase58()} not initialized`);
18334
19391
  return {
18335
19392
  config: accounts_exports3.DvnConfig.fromAccountInfo(dvn)[0],
18336
19393
  owner: dvn.owner
@@ -18342,7 +19399,7 @@ var SendHelper = class {
18342
19399
  });
18343
19400
  const priceFeedInfos = await this.getMultipleAccountsInfo(connection, priceFeeds, commitment);
18344
19401
  priceFeedInfos.forEach((info, i) => {
18345
- invariant4__default.default(info, `priceFeed:${priceFeeds[i].toBase58()} not initialized`);
19402
+ invariant3__default.default(info, `priceFeed:${priceFeeds[i].toBase58()} not initialized`);
18346
19403
  });
18347
19404
  executorAccounts = new Executor(executor2.owner).getQuoteIXAccountMetaForCPI(
18348
19405
  executor2.config.priceFeed,
@@ -19940,6 +20997,9 @@ var types = [
19940
20997
 
19941
20998
  // src/index.ts
19942
20999
  var IdlTypes = {
21000
+ /**
21001
+ * The endpoint types.
21002
+ */
19943
21003
  endpoint: types
19944
21004
  };
19945
21005
  var SetConfigType2 = /* @__PURE__ */ ((SetConfigType3) => {
@@ -20040,5 +21100,5 @@ exports.oappIDPDA = oappIDPDA;
20040
21100
  exports.simulateTransaction = simulateTransaction;
20041
21101
  exports.txWithAddressLookupTable = txWithAddressLookupTable;
20042
21102
  exports.txWithNonce = txWithNonce;
20043
- //# sourceMappingURL=out.js.map
21103
+ //# sourceMappingURL=index.cjs.map
20044
21104
  //# sourceMappingURL=index.cjs.map