@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.mjs CHANGED
@@ -1,39 +1,29 @@
1
1
  import * as web314 from '@solana/web3.js';
2
2
  import { PublicKey, TransactionInstruction, AddressLookupTableProgram, VersionedTransaction, TransactionMessage, Keypair, NONCE_ACCOUNT_LENGTH, Transaction, SystemProgram, NonceAccount } from '@solana/web3.js';
3
3
  import BN from 'bn.js';
4
- import { arrayify, hexZeroPad, hexlify } from '@ethersproject/bytes';
5
- import { keccak256 } from '@ethersproject/keccak256';
6
- import invariant4 from 'tiny-invariant';
7
- import { getAddress } from '@ethersproject/address';
8
- import base58 from 'bs58';
9
- import '@ethersproject/abi';
10
- import { BigNumber } from '@ethersproject/bignumber';
11
- import '@ethersproject/solidity';
4
+ import invariant3 from 'tiny-invariant';
5
+ import { keccak_256, sha2_256 } from '@layerzerolabs/lz-foundation';
6
+ import { arrayify } from '@layerzerolabs/lz-utilities';
7
+ import { addressToBytes32, PacketV1Codec } from '@layerzerolabs/lz-v2-utilities';
12
8
  import * as beet159 from '@metaplex-foundation/beet';
13
9
  import { uniformFixedSizeArray, u8, FixableBeetArgsStruct, u32, u64, bytes, u16, BeetArgsStruct, bool, array } from '@metaplex-foundation/beet';
14
10
  import * as beetSolana85 from '@metaplex-foundation/beet-solana';
15
11
  import * as splToken from '@solana/spl-token';
16
12
  import { Environment, EndpointId } from '@layerzerolabs/lz-definitions';
17
13
  import crypto from 'crypto';
18
- import { sha256 } from '@ethersproject/sha2';
14
+ import base58 from 'bs58';
19
15
 
20
16
  var __defProp = Object.defineProperty;
21
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
22
17
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
23
18
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
24
19
  }) : x)(function(x) {
25
- if (typeof require !== "undefined")
26
- return require.apply(this, arguments);
20
+ if (typeof require !== "undefined") return require.apply(this, arguments);
27
21
  throw Error('Dynamic require of "' + x + '" is not supported');
28
22
  });
29
23
  var __export = (target, all) => {
30
24
  for (var name in all)
31
25
  __defProp(target, name, { get: all[name], enumerable: true });
32
26
  };
33
- var __publicField = (obj, key, value) => {
34
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
35
- return value;
36
- };
37
27
  var ENDPOINT_SEED = "Endpoint";
38
28
  var MESSAGE_LIB_SEED = "MessageLib";
39
29
  var SEND_LIBRARY_CONFIG_SEED = "SendLibraryConfig";
@@ -62,12 +52,28 @@ var PEER_SEED = "Peer";
62
52
  var MINT_SEED = "Mint";
63
53
  var ENFORCED_OPTIONS_SEED = "EnforcedOptions";
64
54
  var EndpointPDADeriver = class {
55
+ /**
56
+ * Creates an instance of the EndpointPDADeriver class.
57
+ *
58
+ * @param {PublicKey} program - The program public key.
59
+ */
65
60
  constructor(program) {
66
61
  this.program = program;
67
62
  }
63
+ /**
64
+ * Derives the setting address.
65
+ *
66
+ * @returns {[PublicKey, number]} The derived address and bump seed.
67
+ */
68
68
  setting() {
69
69
  return PublicKey.findProgramAddressSync([Buffer.from(ENDPOINT_SEED, "utf8")], this.program);
70
70
  }
71
+ /**
72
+ * Derives the default send library configuration address.
73
+ *
74
+ * @param {number} dstEndpointId - The destination endpoint ID.
75
+ * @returns {[PublicKey, number]} The derived address and bump seed.
76
+ */
71
77
  defaultSendLibraryConfig(dstEndpointId) {
72
78
  return PublicKey.findProgramAddressSync(
73
79
  [
@@ -78,6 +84,13 @@ var EndpointPDADeriver = class {
78
84
  this.program
79
85
  );
80
86
  }
87
+ /**
88
+ * Derives the send library configuration address.
89
+ *
90
+ * @param {PublicKey} sender - The sender public key.
91
+ * @param {number} dstEndpointId - The destination endpoint ID.
92
+ * @returns {[PublicKey, number]} The derived address and bump seed.
93
+ */
81
94
  sendLibraryConfig(sender, dstEndpointId) {
82
95
  return PublicKey.findProgramAddressSync(
83
96
  [
@@ -90,7 +103,10 @@ var EndpointPDADeriver = class {
90
103
  );
91
104
  }
92
105
  /**
93
- * @param messageLibrary PDA(derive by message lib program)
106
+ * Derives the message library information address.
107
+ *
108
+ * @param {PublicKey} messageLibrary - The message library public key, PDA(derive by message lib program)
109
+ * @returns {[PublicKey, number]} The derived address and bump seed.
94
110
  */
95
111
  messageLibraryInfo(messageLibrary) {
96
112
  return PublicKey.findProgramAddressSync(
@@ -98,6 +114,12 @@ var EndpointPDADeriver = class {
98
114
  this.program
99
115
  );
100
116
  }
117
+ /**
118
+ * Derives the default receive library configuration address.
119
+ *
120
+ * @param {number} srcEndpointId - The source endpoint ID.
121
+ * @returns {[PublicKey, number]} The derived address and bump seed.
122
+ */
101
123
  defaultReceiveLibraryConfig(srcEndpointId) {
102
124
  return PublicKey.findProgramAddressSync(
103
125
  [
@@ -108,6 +130,13 @@ var EndpointPDADeriver = class {
108
130
  this.program
109
131
  );
110
132
  }
133
+ /**
134
+ * Derives the receive library configuration address.
135
+ *
136
+ * @param {PublicKey} receiver - The receiver public key.
137
+ * @param {number} srcEndpointId - The source endpoint ID.
138
+ * @returns {[PublicKey, number]} The derived address and bump seed.
139
+ */
111
140
  receiveLibraryConfig(receiver, srcEndpointId) {
112
141
  return PublicKey.findProgramAddressSync(
113
142
  [
@@ -132,9 +161,12 @@ var EndpointPDADeriver = class {
132
161
  );
133
162
  }
134
163
  /**
135
- * @param localOapp
136
- * @param remoteChainId
137
- * @param remoteOapp
164
+ * Derives the nonce address.
165
+ *
166
+ * @param {PublicKey} localOapp - The local OApp public key.
167
+ * @param {number} remoteChainId - The remote chain ID.
168
+ * @param {Uint8Array} remoteOapp - The remote OApp address.
169
+ * @returns {[PublicKey, number]} The derived address and bump seed.
138
170
  */
139
171
  nonce(localOapp, remoteChainId, remoteOapp) {
140
172
  return PublicKey.findProgramAddressSync(
@@ -148,6 +180,14 @@ var EndpointPDADeriver = class {
148
180
  this.program
149
181
  );
150
182
  }
183
+ /**
184
+ * Derives the pending nonce address.
185
+ *
186
+ * @param {PublicKey} localOapp - The local OApp public key.
187
+ * @param {number} remoteChainId - The remote chain ID.
188
+ * @param {Uint8Array} remoteOapp - The remote OApp address.
189
+ * @returns {[PublicKey, number]} The derived address and bump seed.
190
+ */
151
191
  pendingNonce(localOapp, remoteChainId, remoteOapp) {
152
192
  return PublicKey.findProgramAddressSync(
153
193
  [
@@ -159,19 +199,23 @@ var EndpointPDADeriver = class {
159
199
  this.program
160
200
  );
161
201
  }
202
+ /**
203
+ * Derives the OApp registry address.
204
+ *
205
+ * @param {PublicKey} localOapp - The local OApp public key.
206
+ * @returns {[PublicKey, number]} The derived address and bump seed.
207
+ */
162
208
  oappRegistry(localOapp) {
163
209
  return PublicKey.findProgramAddressSync([Buffer.from(OAPP_SEED, "utf8"), localOapp.toBytes()], this.program);
164
210
  }
165
- /***
166
- * @param receiver
167
- * @param srcEid
168
- * @param sender
169
- * @param nonce
170
- * @param payloadHash
171
- * @srcChainId u32 to Uint8Array([0,0,0,0])
172
- * @sender [u8; 32] sender Address
173
- * @nonce u64 to Uint8Array([0,0,0,0,0,0,0,0])
174
- * @payloadHash [u8; 32]
211
+ /**
212
+ * Derives the payload hash address.
213
+ *
214
+ * @param {PublicKey} receiver - The receiver public key.
215
+ * @param {number} srcEid - The source endpoint ID.
216
+ * @param {Uint8Array} sender - The sender address.
217
+ * @param {number} nonce - The nonce.
218
+ * @returns {[PublicKey, number]} The derived address and bump seed.
175
219
  */
176
220
  payloadHash(receiver, srcEid, sender, nonce) {
177
221
  return PublicKey.findProgramAddressSync(
@@ -185,6 +229,16 @@ var EndpointPDADeriver = class {
185
229
  this.program
186
230
  );
187
231
  }
232
+ /**
233
+ * Derives the composed message address.
234
+ *
235
+ * @param {PublicKey} from - The sender public key.
236
+ * @param {Uint8Array} guid - The GUID.
237
+ * @param {number} index - The index.
238
+ * @param {PublicKey} to - The receiver public key.
239
+ * @param {Uint8Array} messageHash - The message hash.
240
+ * @returns {[PublicKey, number]} The derived address and bump seed.
241
+ */
188
242
  composedMessage(from, guid, index, to, messageHash) {
189
243
  return PublicKey.findProgramAddressSync(
190
244
  [
@@ -200,18 +254,42 @@ var EndpointPDADeriver = class {
200
254
  }
201
255
  };
202
256
  var MessageLibPDADeriver = class {
257
+ /**
258
+ * Creates an instance of the MessageLibPDADeriver class.
259
+ *
260
+ * @param {PublicKey} program - The program public key.
261
+ */
203
262
  constructor(program) {
204
263
  this.program = program;
205
264
  }
265
+ /**
266
+ * Derives the message library address.
267
+ *
268
+ * @returns {[PublicKey, number]} The derived address and bump seed.
269
+ */
206
270
  messageLib() {
207
271
  return PublicKey.findProgramAddressSync([Buffer.from(MESSAGE_LIB_SEED, "utf8")], this.program);
208
272
  }
273
+ /**
274
+ * Derives the send configuration address.
275
+ *
276
+ * @param {number} eid - The endpoint ID.
277
+ * @param {PublicKey} oapp - The OApp public key.
278
+ * @returns {[PublicKey, number]} The derived address and bump seed.
279
+ */
209
280
  sendConfig(eid, oapp) {
210
281
  return PublicKey.findProgramAddressSync(
211
282
  [Buffer.from(SEND_CONFIG_SEED, "utf8"), new BN(eid).toArrayLike(Buffer, "be", 4), oapp.toBuffer()],
212
283
  this.program
213
284
  );
214
285
  }
286
+ /**
287
+ * Derives the receive configuration address.
288
+ *
289
+ * @param {number} eid - The endpoint ID.
290
+ * @param {PublicKey} oapp - The OApp public key.
291
+ * @returns {[PublicKey, number]} The derived address and bump seed.
292
+ */
215
293
  receiveConfig(eid, oapp) {
216
294
  return PublicKey.findProgramAddressSync(
217
295
  [Buffer.from(RECEIVE_CONFIG_SEED, "utf8"), new BN(eid).toArrayLike(Buffer, "be", 4), oapp.toBuffer()],
@@ -220,36 +298,79 @@ var MessageLibPDADeriver = class {
220
298
  }
221
299
  };
222
300
  var UlnPDADeriver = class extends MessageLibPDADeriver {
301
+ /**
302
+ * Derives the setting address.
303
+ *
304
+ * @returns {[PublicKey, number]} The derived address and bump seed.
305
+ */
223
306
  setting() {
224
307
  return PublicKey.findProgramAddressSync([Buffer.from(ULN_SEED, "utf8")], this.program);
225
308
  }
309
+ /**
310
+ * Derives the configuration address.
311
+ *
312
+ * @param {number} eid - The endpoint ID.
313
+ * @returns {[PublicKey, number]} The derived address and bump seed.
314
+ */
226
315
  config(eid) {
227
316
  return PublicKey.findProgramAddressSync(
228
317
  [Buffer.from(ULN_CONFIG_SEED, "utf8"), new BN(eid).toArrayLike(Buffer, "be", 4)],
229
318
  this.program
230
319
  );
231
320
  }
321
+ /**
322
+ * Derives the default send configuration address.
323
+ *
324
+ * @param {number} eid - The endpoint ID.
325
+ * @returns {[PublicKey, number]} The derived address and bump seed.
326
+ */
232
327
  defaultSendConfig(eid) {
233
328
  return PublicKey.findProgramAddressSync(
234
329
  [Buffer.from(SEND_CONFIG_SEED, "utf8"), new BN(eid).toArrayLike(Buffer, "be", 4)],
235
330
  this.program
236
331
  );
237
332
  }
333
+ /**
334
+ * Derives the default receive configuration address.
335
+ *
336
+ * @param {number} eid - The endpoint ID.
337
+ * @returns {[PublicKey, number]} The derived address and bump seed.
338
+ */
238
339
  defaultReceiveConfig(eid) {
239
340
  return PublicKey.findProgramAddressSync(
240
341
  [Buffer.from(RECEIVE_CONFIG_SEED, "utf8"), new BN(eid).toArrayLike(Buffer, "be", 4)],
241
342
  this.program
242
343
  );
243
344
  }
345
+ /**
346
+ * Derives the options address.
347
+ *
348
+ * @param {number} eit - The endpoint ID.
349
+ * @returns {[PublicKey, number]} The derived address and bump seed.
350
+ */
244
351
  options(eit) {
245
352
  return PublicKey.findProgramAddressSync(
246
353
  [Buffer.from(OPTIONS_SEED, "utf8"), new BN(eit).toArrayLike(Buffer, "be", 4)],
247
354
  this.program
248
355
  );
249
356
  }
357
+ /**
358
+ * Derives the worker configuration address.
359
+ *
360
+ * @param {PublicKey} worker - The worker public key.
361
+ * @returns {[PublicKey, number]} The derived address and bump seed.
362
+ */
250
363
  workerConfig(worker) {
251
364
  return PublicKey.findProgramAddressSync([Buffer.from(WORKER_SEED, "utf8"), worker.toBuffer()], this.program);
252
365
  }
366
+ /**
367
+ * Derives the confirmations address.
368
+ *
369
+ * @param {Uint8Array} headerHash - The header hash.
370
+ * @param {Uint8Array} payloadHash - The payload hash.
371
+ * @param {PublicKey} dvn - The DVN public key.
372
+ * @returns {[PublicKey, number]} The derived address and bump seed.
373
+ */
253
374
  confirmations(headerHash, payloadHash, dvn) {
254
375
  return PublicKey.findProgramAddressSync(
255
376
  [Buffer.from(CONFIRMATIONS_SEED, "utf8"), headerHash, payloadHash, dvn.toBytes()],
@@ -258,18 +379,39 @@ var UlnPDADeriver = class extends MessageLibPDADeriver {
258
379
  }
259
380
  };
260
381
  var OAppBasePDADeriver = class {
382
+ /**
383
+ * Creates an instance of the OAppBasePDADeriver class.
384
+ *
385
+ * @param {PublicKey} program - The program public key.
386
+ */
261
387
  constructor(program) {
262
388
  this.program = program;
263
389
  }
390
+ /**
391
+ * Derives the remote address.
392
+ *
393
+ * @param {number} dstChainId - The destination chain ID.
394
+ * @returns {[PublicKey, number]} The derived address and bump seed.
395
+ */
264
396
  remote(dstChainId) {
265
397
  return PublicKey.findProgramAddressSync(
266
398
  [Buffer.from(REMOTE_SEED), new BN(dstChainId).toArrayLike(Buffer, "be", 4)],
267
399
  this.program
268
400
  );
269
401
  }
402
+ /**
403
+ * Derives the LzReceive types accounts address.
404
+ *
405
+ * @returns {[PublicKey, number]} The derived address and bump seed.
406
+ */
270
407
  lzReceiveTypesAccounts() {
271
408
  return PublicKey.findProgramAddressSync([Buffer.from(LZ_RECEIVE_TYPES_SEED, "utf8")], this.program);
272
409
  }
410
+ /**
411
+ * Derives the LzCompose types accounts address.
412
+ *
413
+ * @returns {[PublicKey, number]} The derived address and bump seed.
414
+ */
273
415
  lzComposeTypesAccounts() {
274
416
  return PublicKey.findProgramAddressSync([Buffer.from(LZ_COMPOSE_TYPES_SEED, "utf8")], this.program);
275
417
  }
@@ -278,36 +420,82 @@ var DVNDeriver = class {
278
420
  constructor(program) {
279
421
  this.program = program;
280
422
  }
423
+ /**
424
+ * Derives the authority address.
425
+ *
426
+ * @returns {[PublicKey, number]} The derived address and bump seed.
427
+ */
281
428
  authority() {
282
429
  return PublicKey.findProgramAddressSync([Buffer.from("dvn", "utf8")], this.program);
283
430
  }
431
+ /**
432
+ * Derives the configuration address.
433
+ *
434
+ * @returns {[PublicKey, number]} The derived address and bump seed.
435
+ */
284
436
  config() {
285
437
  return PublicKey.findProgramAddressSync([Buffer.from(DVN_CONFIG_SEED, "utf8")], this.program);
286
438
  }
439
+ /**
440
+ * Derives the execute hash address.
441
+ *
442
+ * @param {Buffer} digestHash - The digest hash.
443
+ * @returns {[PublicKey, number]} The derived address and bump seed.
444
+ */
287
445
  executeHash(digestHash) {
288
446
  return PublicKey.findProgramAddressSync([Buffer.from("ExecuteHash", "utf8"), digestHash], this.program);
289
447
  }
290
448
  };
291
449
  var EventPDADeriver = class {
450
+ /**
451
+ * Creates an instance of the EventPDADeriver class.
452
+ *
453
+ * @param {PublicKey} program - The program public key.
454
+ */
292
455
  constructor(program) {
293
456
  this.program = program;
294
457
  }
458
+ /**
459
+ * Derives the event authority PDA.
460
+ *
461
+ * @returns {[PublicKey, number]} The event authority PDA and bump seed.
462
+ */
295
463
  eventAuthority() {
296
464
  return PublicKey.findProgramAddressSync([Buffer.from(EVENT_SEED, "utf8")], this.program);
297
465
  }
298
466
  };
299
467
  var ExecutorPDADeriver = class {
468
+ /**
469
+ * Creates an instance of the ExecutorPDADeriver class.
470
+ *
471
+ * @param {PublicKey} program - The program public key.
472
+ */
300
473
  constructor(program) {
301
474
  this.program = program;
302
475
  }
476
+ /**
477
+ * Derives the executor configuration PDA.
478
+ *
479
+ * @returns {[PublicKey, number]} The executor configuration PDA and bump seed.
480
+ */
303
481
  config() {
304
482
  return PublicKey.findProgramAddressSync([Buffer.from(EXECUTOR_CONFIG_SEED, "utf8")], this.program);
305
483
  }
306
484
  };
307
485
  var PriceFeedPDADeriver = class {
486
+ /**
487
+ * Creates an instance of the PriceFeedPDADeriver class.
488
+ *
489
+ * @param {PublicKey} program - The program public key.
490
+ */
308
491
  constructor(program) {
309
492
  this.program = program;
310
493
  }
494
+ /**
495
+ * Derives the price feed PDA.
496
+ *
497
+ * @returns {[PublicKey, number]} The price feed PDA and bump seed.
498
+ */
311
499
  priceFeed() {
312
500
  return PublicKey.findProgramAddressSync([Buffer.from(PRICE_FEED_SEED, "utf8")], this.program);
313
501
  }
@@ -326,138 +514,6 @@ __export(endpoint_exports, {
326
514
  instructions: () => instructions_exports,
327
515
  types: () => types_exports
328
516
  });
329
- function hexZeroPadTo32(addr) {
330
- return hexZeroPad(addr, 32);
331
- }
332
- function bytes32ToEthAddress(bytes322) {
333
- if (bytes322 instanceof Uint8Array) {
334
- bytes322 = hexlify(bytes322);
335
- }
336
- return getAddress(bytes322.slice(-40));
337
- }
338
- function trim0x(str) {
339
- return str.replace(/^0x/, "");
340
- }
341
- function addressToBytes32(address) {
342
- if (isSolanaAddress(address)) {
343
- return base58.decode(address);
344
- } else if (address.startsWith("0x") && address.length <= 66) {
345
- return arrayify(hexZeroPadTo32(address));
346
- }
347
- throw new Error("Invalid address");
348
- }
349
- var solanaAddressRegex = /^([1-9A-HJ-NP-Za-km-z]{32,44})$/;
350
- function isSolanaAddress(address) {
351
- return solanaAddressRegex.test(address);
352
- }
353
- BigNumber.from("0xffffffffffffffffffffffffffffffff");
354
- var PACKET_VERSION_OFFSET = 0;
355
- var NONCE_OFFSET = 1;
356
- var SRC_CHAIN_OFFSET = 9;
357
- var SRC_ADDRESS_OFFSET = 13;
358
- var DST_CHAIN_OFFSET = 45;
359
- var DST_ADDRESS_OFFSET = 49;
360
- var GUID_OFFSET = 81;
361
- var MESSAGE_OFFSET = 113;
362
- var PacketV1Codec = class _PacketV1Codec {
363
- constructor(payloadEncoded) {
364
- __publicField(this, "buffer");
365
- this.buffer = Buffer.from(trim0x(payloadEncoded), "hex");
366
- }
367
- static from(payloadEncoded) {
368
- return new _PacketV1Codec(payloadEncoded);
369
- }
370
- static fromBytes(payload) {
371
- return new _PacketV1Codec("0x" + Buffer.from(payload).toString("hex"));
372
- }
373
- /**
374
- * encode packet to hex string
375
- */
376
- static encode(packet) {
377
- const buff = this.encodeBytes(packet);
378
- return "0x" + Buffer.from(buff).toString("hex");
379
- }
380
- /**
381
- * encode packet to Uint8Array
382
- * @param packet
383
- */
384
- static encodeBytes(packet) {
385
- const message = trim0x(packet.message);
386
- const buffer = Buffer.alloc(MESSAGE_OFFSET + message.length / 2);
387
- buffer.writeUInt8(packet.version, PACKET_VERSION_OFFSET);
388
- buffer.writeBigUInt64BE(BigInt(packet.nonce), NONCE_OFFSET);
389
- buffer.writeUInt32BE(packet.srcEid, SRC_CHAIN_OFFSET);
390
- buffer.write(Buffer.from(addressToBytes32(packet.sender)).toString("hex"), SRC_ADDRESS_OFFSET, 32, "hex");
391
- buffer.writeUInt32BE(packet.dstEid, DST_CHAIN_OFFSET);
392
- buffer.write(Buffer.from(addressToBytes32(packet.receiver)).toString("hex"), DST_ADDRESS_OFFSET, 32, "hex");
393
- buffer.write(trim0x(packet.guid), GUID_OFFSET, 32, "hex");
394
- buffer.write(message, MESSAGE_OFFSET, message.length / 2, "hex");
395
- return new Uint8Array(buffer);
396
- }
397
- version() {
398
- return this.buffer.readUInt8(PACKET_VERSION_OFFSET);
399
- }
400
- nonce() {
401
- return this.buffer.readBigUint64BE(NONCE_OFFSET).toString();
402
- }
403
- srcEid() {
404
- return this.buffer.readUint32BE(SRC_CHAIN_OFFSET);
405
- }
406
- sender() {
407
- return "0x" + this.buffer.slice(SRC_ADDRESS_OFFSET, DST_CHAIN_OFFSET).toString("hex");
408
- }
409
- senderAddressB20() {
410
- return bytes32ToEthAddress(this.sender());
411
- }
412
- dstEid() {
413
- return this.buffer.readUint32BE(DST_CHAIN_OFFSET);
414
- }
415
- receiver() {
416
- return "0x" + this.buffer.slice(DST_ADDRESS_OFFSET, GUID_OFFSET).toString("hex");
417
- }
418
- receiverAddressB20() {
419
- return bytes32ToEthAddress(this.receiver());
420
- }
421
- guid() {
422
- return "0x" + this.buffer.slice(GUID_OFFSET, MESSAGE_OFFSET).toString("hex");
423
- }
424
- message() {
425
- return "0x" + this.buffer.slice(MESSAGE_OFFSET).toString("hex");
426
- }
427
- payloadHash() {
428
- return keccak256(this.payload());
429
- }
430
- payload() {
431
- return "0x" + this.buffer.slice(GUID_OFFSET).toString("hex");
432
- }
433
- header() {
434
- return "0x" + this.buffer.slice(0, GUID_OFFSET).toString("hex");
435
- }
436
- headerHash() {
437
- return keccak256(this.header());
438
- }
439
- /**
440
- * deserialize packet from hex string
441
- * @deprecated use toPacket instead
442
- */
443
- decode() {
444
- return this.toPacket();
445
- }
446
- toPacket() {
447
- return {
448
- version: this.version(),
449
- nonce: this.nonce(),
450
- srcEid: this.srcEid(),
451
- sender: this.sender(),
452
- dstEid: this.dstEid(),
453
- receiver: this.receiver(),
454
- guid: this.guid(),
455
- message: this.message(),
456
- // derived
457
- payload: this.payload()
458
- };
459
- }
460
- };
461
517
 
462
518
  // src/generated/endpoint/accounts/index.ts
463
519
  var accounts_exports = {};
@@ -5836,6 +5892,11 @@ var sendLibrarySetEventBeet = new beet159.BeetArgsStruct(
5836
5892
  var EventEmitDiscriminator = "e445a52e51cb9a1d";
5837
5893
  var DefaultMessageLib = PublicKey.default;
5838
5894
  var Endpoint = class {
5895
+ /**
5896
+ * Creates an instance of the Endpoint class.
5897
+ *
5898
+ * @param {PublicKey} program - The program public key.
5899
+ */
5839
5900
  constructor(program) {
5840
5901
  this.program = program;
5841
5902
  this.deriver = new EndpointPDADeriver(program);
@@ -5843,7 +5904,12 @@ var Endpoint = class {
5843
5904
  this.eventAuthorityPDA = eventAuthorityPDA;
5844
5905
  }
5845
5906
  /**
5846
- * init endpoint settings, including eid, admin, it also registers the blocked message lib
5907
+ * Initializes the endpoint settings, including eid and admin, and registers the blocked message library.
5908
+ *
5909
+ * @param {number} endpointId - The endpoint ID.
5910
+ * @param {PublicKey} payer - The payer public key.
5911
+ * @param {PublicKey} admin - The admin public key.
5912
+ * @returns {TransactionInstruction} The transaction instruction.
5847
5913
  */
5848
5914
  initEndpoint(endpointId, payer, admin) {
5849
5915
  const [settingPDA] = this.deriver.setting();
@@ -5862,8 +5928,14 @@ var Endpoint = class {
5862
5928
  );
5863
5929
  }
5864
5930
  // async initOrUpdateConfig(connection:Connection,)
5865
- /***
5931
+ /**
5932
+ * Registers a library.
5866
5933
  * call this function after endpoint initialized. Only admin can call this function.
5934
+ *
5935
+ * @param {PublicKey} admin - The admin public key.
5936
+ * @param {PublicKey} messageLibProgram - The message library program public key.
5937
+ * @param {types.MessageLibType} [libType=types.MessageLibType.SendAndReceive] - The library type.
5938
+ * @returns {TransactionInstruction} The transaction instruction.
5867
5939
  */
5868
5940
  registerLibrary(admin, messageLibProgram, libType = 2 /* SendAndReceive */) {
5869
5941
  const [msgLibPda] = new MessageLibPDADeriver(messageLibProgram).messageLib();
@@ -5886,6 +5958,16 @@ var Endpoint = class {
5886
5958
  this.program
5887
5959
  );
5888
5960
  }
5961
+ /**
5962
+ * Sets the default send library.
5963
+ *
5964
+ * @param {Connection} connection - The connection to the Solana cluster.
5965
+ * @param {PublicKey} admin - The admin public key.
5966
+ * @param {PublicKey} messageLibProgram - The message library program public key.
5967
+ * @param {number} dstEid - The destination endpoint ID.
5968
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
5969
+ * @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
5970
+ */
5889
5971
  async setDefaultSendLibrary(connection, admin, messageLibProgram, dstEid, commitmentOrConfig) {
5890
5972
  const [msgLib] = new MessageLibPDADeriver(messageLibProgram).messageLib();
5891
5973
  const [defaultSendLibConfig] = this.deriver.defaultSendLibraryConfig(dstEid);
@@ -5938,6 +6020,16 @@ var Endpoint = class {
5938
6020
  );
5939
6021
  }
5940
6022
  }
6023
+ /**
6024
+ * Sets the default receive library.
6025
+ *
6026
+ * @param {Connection} connection - The connection to the Solana cluster.
6027
+ * @param {PublicKey} admin - The admin public key.
6028
+ * @param {PublicKey} messageLibProgram - The message library program public key.
6029
+ * @param {number} srcEid - The source endpoint ID.
6030
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
6031
+ * @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
6032
+ */
5941
6033
  async setDefaultReceiveLibrary(connection, admin, messageLibProgram, srcEid, commitmentOrConfig) {
5942
6034
  const [msgLib] = new MessageLibPDADeriver(messageLibProgram).messageLib();
5943
6035
  const [defaultReceiveLibConfig] = this.deriver.defaultReceiveLibraryConfig(srcEid);
@@ -5992,6 +6084,16 @@ var Endpoint = class {
5992
6084
  );
5993
6085
  }
5994
6086
  }
6087
+ /**
6088
+ * Initializes the OApp configuration.
6089
+ *
6090
+ * @param {PublicKey} delegate - The delegate public key.
6091
+ * @param {MessageLibInterface} msgLibSDK - The message library SDK.
6092
+ * @param {PublicKey} payer - The payer public key.
6093
+ * @param {PublicKey} oappID - The OApp ID public key.
6094
+ * @param {number} eid - The endpoint ID.
6095
+ * @returns {TransactionInstruction} The transaction instruction.
6096
+ */
5995
6097
  initOAppConfig(delegate, msgLibSDK, payer, oappID, eid) {
5996
6098
  const [msgLib] = new MessageLibPDADeriver(msgLibSDK.program).messageLib();
5997
6099
  const [oappRegistry] = this.deriver.oappRegistry(oappID);
@@ -6014,6 +6116,15 @@ var Endpoint = class {
6014
6116
  this.program
6015
6117
  );
6016
6118
  }
6119
+ /**
6120
+ * Initializes the OApp nonce.
6121
+ *
6122
+ * @param {PublicKey} delegate - The delegate public key.
6123
+ * @param {number} dstEid - The destination endpoint ID.
6124
+ * @param {PublicKey} oappIDPDA - The OApp ID PDA.
6125
+ * @param {Uint8Array} remoteOappAddr - The remote OApp address.
6126
+ * @returns {TransactionInstruction} The transaction instruction.
6127
+ */
6017
6128
  initOAppNonce(delegate, dstEid, oappIDPDA2, remoteOappAddr) {
6018
6129
  const [nonce] = this.deriver.nonce(oappIDPDA2, dstEid, remoteOappAddr);
6019
6130
  const [pendingNonce] = this.deriver.pendingNonce(oappIDPDA2, dstEid, remoteOappAddr);
@@ -6035,6 +6146,14 @@ var Endpoint = class {
6035
6146
  this.program
6036
6147
  );
6037
6148
  }
6149
+ /**
6150
+ * Initializes the send library.
6151
+ *
6152
+ * @param {PublicKey} delegate - The delegate public key.
6153
+ * @param {PublicKey} sender - The sender public key.
6154
+ * @param {number} dstEid - The destination endpoint ID.
6155
+ * @returns {TransactionInstruction} The transaction instruction.
6156
+ */
6038
6157
  initSendLibrary(delegate, sender, dstEid) {
6039
6158
  const [oappRegistry] = this.deriver.oappRegistry(sender);
6040
6159
  const [sendLibraryConfig] = this.deriver.sendLibraryConfig(sender, dstEid);
@@ -6053,6 +6172,15 @@ var Endpoint = class {
6053
6172
  this.program
6054
6173
  );
6055
6174
  }
6175
+ /**
6176
+ * Sets the send library.
6177
+ *
6178
+ * @param {PublicKey} oappAdmin - The OApp admin public key.
6179
+ * @param {PublicKey} oappIDPDA - The OApp ID PDA.
6180
+ * @param {PublicKey} newSendLibProgram - The new send library program public key.
6181
+ * @param {number} dstEid - The destination endpoint ID.
6182
+ * @returns {TransactionInstruction} The transaction instruction.
6183
+ */
6056
6184
  setSendLibrary(oappAdmin, oappIDPDA2, newSendLibProgram, dstEid) {
6057
6185
  const [newSendLib] = new MessageLibPDADeriver(newSendLibProgram).messageLib();
6058
6186
  const [sendLibraryConfig] = this.deriver.sendLibraryConfig(oappIDPDA2, dstEid);
@@ -6078,6 +6206,14 @@ var Endpoint = class {
6078
6206
  );
6079
6207
  return ix;
6080
6208
  }
6209
+ /**
6210
+ * Initializes the receive library.
6211
+ *
6212
+ * @param {PublicKey} delegate - The delegate public key.
6213
+ * @param {PublicKey} receiver - The receiver public key.
6214
+ * @param {number} srcEid - The source endpoint ID.
6215
+ * @returns {TransactionInstruction} The transaction instruction.
6216
+ */
6081
6217
  initReceiveLibrary(delegate, receiver, srcEid) {
6082
6218
  const [oappRegistry] = this.deriver.oappRegistry(receiver);
6083
6219
  const [receiveLibraryConfig] = this.deriver.receiveLibraryConfig(receiver, srcEid);
@@ -6096,6 +6232,16 @@ var Endpoint = class {
6096
6232
  this.program
6097
6233
  );
6098
6234
  }
6235
+ /**
6236
+ * Sets the receive library.
6237
+ *
6238
+ * @param {PublicKey} oappAdmin - The OApp admin public key.
6239
+ * @param {PublicKey} oappIDPDA - The OApp ID PDA.
6240
+ * @param {PublicKey} newReceiveLibProgram - The new receive library program public key.
6241
+ * @param {number} srcEid - The source endpoint ID.
6242
+ * @param {bigint | number} [gracePeriod] - The grace period.
6243
+ * @returns {TransactionInstruction} The transaction instruction.
6244
+ */
6099
6245
  setReceiveLibrary(oappAdmin, oappIDPDA2, newReceiveLibProgram, srcEid, gracePeriod) {
6100
6246
  const [newReceiveLib] = new MessageLibPDADeriver(newReceiveLibProgram).messageLib();
6101
6247
  const [receiveLibraryConfig] = this.deriver.receiveLibraryConfig(oappIDPDA2, srcEid);
@@ -6122,6 +6268,21 @@ var Endpoint = class {
6122
6268
  );
6123
6269
  return ix;
6124
6270
  }
6271
+ /**
6272
+ * Sets the OApp configuration.
6273
+ *
6274
+ * @param {Connection} connection - The connection to the Solana cluster.
6275
+ * @param {PublicKey} oappDelegate - The OApp delegate public key.
6276
+ * @param {PublicKey} oappID - The OApp ID public key.
6277
+ * @param {PublicKey} msgLibProgram - The message library program public key.
6278
+ * @param {number} eid - The endpoint ID.
6279
+ * @param {object} config - The configuration object.
6280
+ * @param {SetConfigType} config.configType - The configuration type.
6281
+ * @param {UlnProgram.types.ExecutorConfig | UlnProgram.types.UlnConfig} config.value - The configuration value.
6282
+ * @param {Commitment} [commitment='confirmed'] - The commitment level.
6283
+ * @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
6284
+ * @throws {Error} If the message library version is unsupported.
6285
+ */
6125
6286
  async setOappConfig(connection, oappDelegate, oappID, msgLibProgram, eid, config, commitment = "confirmed") {
6126
6287
  const [msgLib] = new MessageLibPDADeriver(msgLibProgram).messageLib();
6127
6288
  const [msgLibInfo] = this.deriver.messageLibraryInfo(msgLib);
@@ -6159,7 +6320,9 @@ var Endpoint = class {
6159
6320
  return ix;
6160
6321
  }
6161
6322
  /// send a simulated transaction to the endpoint to get the fee for sending a message
6162
- /***
6323
+ /**
6324
+ *
6325
+ * Gets the account metadata for the CPI (Cross-Program Invocation) of the quote instruction.
6163
6326
  *
6164
6327
  * caculate the fee for sending a message with ULN:
6165
6328
  * 1. executorFee: feeForGas + feeForOptionType
@@ -6170,6 +6333,13 @@ var Endpoint = class {
6170
6333
  *
6171
6334
  * The priceRatioDenominator is 10^20
6172
6335
  * totalFee = executorFee + oracleFee * numOracles(requiredOracles + optionalOracles)
6336
+ *
6337
+ * @param {Connection} connection - The connection to the Solana cluster.
6338
+ * @param {PublicKey} payer - The payer public key.
6339
+ * @param {PacketPath} path - The packet path.
6340
+ * @param {MessageLibInterface} msgLibProgram - The message library program.
6341
+ * @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
6342
+ * @throws {Error} If the default send library is not initialized or the message library is blocked.
6173
6343
  */
6174
6344
  async getQuoteIXAccountMetaForCPI(connection, payer, path, msgLibProgram) {
6175
6345
  const { sender: sender_, dstEid, receiver: receiver_ } = path;
@@ -6208,8 +6378,16 @@ var Endpoint = class {
6208
6378
  ].concat(accounts)
6209
6379
  );
6210
6380
  }
6211
- /***
6212
- * Get the account meta of the send instruction for CPI(Cross-Program Invocation )
6381
+ /**
6382
+ * Gets the account metadata for the CPI (Cross-Program Invocation) of the send instruction.
6383
+ *
6384
+ * @param {Connection} connection - The connection to the Solana cluster.
6385
+ * @param {PublicKey} payer - The payer public key.
6386
+ * @param {PacketPath} path - The packet path.
6387
+ * @param {MessageLibInterface} msgLibProgram - The message library program.
6388
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
6389
+ * @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
6390
+ * @throws {Error} If the default send library is not initialized or the message library is blocked.
6213
6391
  */
6214
6392
  async getSendIXAccountMetaForCPI(connection, payer, path, msgLibProgram, commitmentOrConfig) {
6215
6393
  const { sender: sender_, dstEid, receiver: receiver_ } = path;
@@ -6253,6 +6431,16 @@ var Endpoint = class {
6253
6431
  }
6254
6432
  ].concat(accounts);
6255
6433
  }
6434
+ /**
6435
+ * Skips a message.
6436
+ *
6437
+ * @param {PublicKey} payer - The payer public key.
6438
+ * @param {PublicKey} sender - The sender public key.
6439
+ * @param {PublicKey} receiver - The receiver public key.
6440
+ * @param {number} srcEid - The source endpoint ID.
6441
+ * @param {string} nonce - The nonce.
6442
+ * @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
6443
+ */
6256
6444
  async skip(payer, sender, receiver, srcEid, nonce) {
6257
6445
  const [nonceAccount] = this.deriver.nonce(receiver, srcEid, addressToBytes32(sender.toBase58()));
6258
6446
  const [payloadHash] = this.deriver.payloadHash(receiver, srcEid, sender.toBytes(), parseInt(nonce));
@@ -6284,6 +6472,18 @@ var Endpoint = class {
6284
6472
  );
6285
6473
  return Promise.resolve(ix);
6286
6474
  }
6475
+ /**
6476
+ * Initializes the verification process.
6477
+ *
6478
+ * @param {Connection} connection - The connection to the Solana cluster.
6479
+ * @param {PublicKey} payer - The payer public key.
6480
+ * @param {PublicKey} sender - The sender public key.
6481
+ * @param {PublicKey} receiver - The receiver public key.
6482
+ * @param {number} srcEid - The source endpoint ID.
6483
+ * @param {string} nonce - The nonce.
6484
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
6485
+ * @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
6486
+ */
6287
6487
  async initVerify(connection, payer, sender, receiver, srcEid, nonce, commitmentOrConfig) {
6288
6488
  const [nonceAccount] = this.deriver.nonce(receiver, srcEid, addressToBytes32(sender.toBase58()));
6289
6489
  const [payloadHash] = this.deriver.payloadHash(receiver, srcEid, sender.toBytes(), parseInt(nonce));
@@ -6308,6 +6508,13 @@ var Endpoint = class {
6308
6508
  this.program
6309
6509
  );
6310
6510
  }
6511
+ /**
6512
+ * Gets the account metadata for the CPI (Cross-Program Invocation) of the verify instruction.
6513
+ *
6514
+ * @param {PacketV1Codec} packet - The packet.
6515
+ * @param {PublicKey} receiveLibrary - The receive library public key.
6516
+ * @returns {AccountMeta[]} An array of account metadata.
6517
+ */
6311
6518
  getVerifyIXAccountMetaForCPI(packet, receiveLibrary) {
6312
6519
  const receiver = new PublicKey(Buffer.from(packet.receiver().slice(2), "hex"));
6313
6520
  const srcEid = packet.srcEid();
@@ -6503,6 +6710,13 @@ var Endpoint = class {
6503
6710
  // } as AccountMeta,
6504
6711
  // ].concat(ix.keys)
6505
6712
  // }
6713
+ /**
6714
+ * Gets the account metadata for the CPI (Cross-Program Invocation) of the register OApp instruction.
6715
+ *
6716
+ * @param {PublicKey} payer - The payer public key.
6717
+ * @param {PublicKey} oapp - The OApp public key.
6718
+ * @returns {AccountMeta[]} An array of account metadata.
6719
+ */
6506
6720
  getRegisterOappIxAccountMetaForCPI(payer, oapp) {
6507
6721
  const [oappRegistry] = this.deriver.oappRegistry(oapp);
6508
6722
  const eventAuthority = this.eventAuthorityPDA;
@@ -6527,6 +6741,15 @@ var Endpoint = class {
6527
6741
  }
6528
6742
  ].concat(keys);
6529
6743
  }
6744
+ /**
6745
+ * Gets the account metadata for the CPI (Cross-Program Invocation) of the skip instruction.
6746
+ *
6747
+ * @param {PublicKey} receiver - The receiver public key.
6748
+ * @param {Uint8Array} sender - The sender address.
6749
+ * @param {number} srcEid - The source endpoint ID.
6750
+ * @param {number} nonce - The nonce.
6751
+ * @returns {AccountMeta[]} An array of account metadata.
6752
+ */
6530
6753
  getSkipIxAccountMetaForCPI(receiver, sender, srcEid, nonce) {
6531
6754
  const [noncePDA] = this.deriver.nonce(receiver, srcEid, sender);
6532
6755
  const [pendingNonce] = this.deriver.pendingNonce(receiver, srcEid, sender);
@@ -6556,6 +6779,15 @@ var Endpoint = class {
6556
6779
  }
6557
6780
  ].concat(keys);
6558
6781
  }
6782
+ /**
6783
+ * Checks if the given message library program is the default send library.
6784
+ *
6785
+ * @param {Connection} connection - The connection to the Solana cluster.
6786
+ * @param {PublicKey} messageLibProgram - The message library program public key.
6787
+ * @param {number} dstEid - The destination endpoint ID.
6788
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
6789
+ * @returns {Promise<boolean>} A promise that resolves to true if the message library program is the default send library, false otherwise.
6790
+ */
6559
6791
  async isDefaultSendLibrary(connection, messageLibProgram, dstEid, commitmentOrConfig) {
6560
6792
  const [msgLib] = new MessageLibPDADeriver(messageLibProgram).messageLib();
6561
6793
  const info = await this.getDefaultSendLibrary(connection, dstEid, commitmentOrConfig);
@@ -6564,6 +6796,15 @@ var Endpoint = class {
6564
6796
  }
6565
6797
  return false;
6566
6798
  }
6799
+ /**
6800
+ * Checks if the given message library program is the default receive library.
6801
+ *
6802
+ * @param {Connection} connection - The connection to the Solana cluster.
6803
+ * @param {PublicKey} messageLibProgram - The message library program public key.
6804
+ * @param {number} srcEid - The source endpoint ID.
6805
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
6806
+ * @returns {Promise<boolean>} A promise that resolves to true if the message library program is the default receive library, false otherwise.
6807
+ */
6567
6808
  async isDefaultReceiveLibrary(connection, messageLibProgram, srcEid, commitmentOrConfig) {
6568
6809
  const [msgLib] = new MessageLibPDADeriver(messageLibProgram).messageLib();
6569
6810
  const info = await this.getDefaultReceiveLibrary(connection, srcEid, commitmentOrConfig);
@@ -6573,6 +6814,13 @@ var Endpoint = class {
6573
6814
  return false;
6574
6815
  }
6575
6816
  // all of below functions are retrieving accounts state
6817
+ /**
6818
+ * Gets the endpoint settings.
6819
+ *
6820
+ * @param {Connection} connection - The connection to the Solana cluster.
6821
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
6822
+ * @returns {Promise<EndpointSettings | null>} A promise that resolves to the endpoint settings or null if not found.
6823
+ */
6576
6824
  async getSetting(connection, commitmentOrConfig) {
6577
6825
  const [setting] = this.deriver.setting();
6578
6826
  try {
@@ -6582,8 +6830,12 @@ var Endpoint = class {
6582
6830
  }
6583
6831
  }
6584
6832
  /**
6833
+ * Gets the message library information.
6585
6834
  *
6586
- * @param messageLib It is a PDA of the message library program
6835
+ * @param {Connection} connection - The connection to the Solana cluster.
6836
+ * @param {PublicKey} messageLibProgram - The message library program public key, It is a PDA of the message library program
6837
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
6838
+ * @returns {Promise<MessageLibInfo | null>} A promise that resolves to the message library information or null if not found.
6587
6839
  */
6588
6840
  async getMessageLibInfo(connection, messageLibProgram, commitmentOrConfig) {
6589
6841
  const [msgLib] = new MessageLibPDADeriver(messageLibProgram).messageLib();
@@ -6594,6 +6846,14 @@ var Endpoint = class {
6594
6846
  return null;
6595
6847
  }
6596
6848
  }
6849
+ /**
6850
+ * Gets the default receive library.
6851
+ *
6852
+ * @param {Connection} connection - The connection to the Solana cluster.
6853
+ * @param {number} srcEid - The source endpoint ID.
6854
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
6855
+ * @returns {Promise<{ msgLib: PublicKey; owner?: PublicKey } | null>} A promise that resolves to the default receive library or null if not found.
6856
+ */
6597
6857
  async getDefaultReceiveLibrary(connection, srcEid, commitmentOrConfig) {
6598
6858
  const [defaultReceiveLibConfig] = this.deriver.defaultReceiveLibraryConfig(srcEid);
6599
6859
  try {
@@ -6616,6 +6876,14 @@ var Endpoint = class {
6616
6876
  return null;
6617
6877
  }
6618
6878
  }
6879
+ /**
6880
+ * Gets the default send library.
6881
+ *
6882
+ * @param {Connection} connection - The connection to the Solana cluster.
6883
+ * @param {number} dstEid - The destination endpoint ID.
6884
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
6885
+ * @returns {Promise<{ msgLib: PublicKey; owner?: PublicKey } | null>} A promise that resolves to the default send library or null if not found.
6886
+ */
6619
6887
  async getDefaultSendLibrary(connection, dstEid, commitmentOrConfig) {
6620
6888
  const [defaultSendLibConfig] = this.deriver.defaultSendLibraryConfig(dstEid);
6621
6889
  try {
@@ -6639,8 +6907,13 @@ var Endpoint = class {
6639
6907
  }
6640
6908
  }
6641
6909
  /**
6642
- * get app configured send library
6643
- * 2 RPC calls
6910
+ * Gets the configured send library for the app.
6911
+ *
6912
+ * @param {Connection} connection - The connection to the Solana cluster.
6913
+ * @param {PublicKey} oappPda - The OApp PDA.
6914
+ * @param {number} dstEid - The destination endpoint ID.
6915
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig='confirmed'] - The commitment level or account info configuration.
6916
+ * @returns {Promise<{ msgLib: PublicKey; programId?: PublicKey; isDefault: boolean } | null>} A promise that resolves to the configured send library or null if not found.
6644
6917
  */
6645
6918
  async getSendLibrary(connection, oappPda, dstEid, commitmentOrConfig = "confirmed") {
6646
6919
  const [sendLibConfig] = this.deriver.sendLibraryConfig(oappPda, dstEid);
@@ -6673,7 +6946,13 @@ var Endpoint = class {
6673
6946
  }
6674
6947
  }
6675
6948
  /**
6676
- * get app configured receive library
6949
+ * Gets the configured receive library for the app.
6950
+ *
6951
+ * @param {Connection} connection - The connection to the Solana cluster.
6952
+ * @param {PublicKey} oappPda - The OApp PDA.
6953
+ * @param {number} srcEid - The source endpoint ID.
6954
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
6955
+ * @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.
6677
6956
  */
6678
6957
  async getReceiveLibrary(connection, oappPda, srcEid, commitmentOrConfig) {
6679
6958
  const [receiveLibConfig] = this.deriver.receiveLibraryConfig(oappPda, srcEid);
@@ -6709,7 +6988,7 @@ var Endpoint = class {
6709
6988
  };
6710
6989
  }
6711
6990
  const messageLibInfo = await connection.getAccountInfo(info.messageLib, commitmentOrConfig);
6712
- invariant4(messageLibInfo, "messageLibInfo should not be null");
6991
+ invariant3(messageLibInfo, "messageLibInfo should not be null");
6713
6992
  const { timeout } = info;
6714
6993
  if (timeout) {
6715
6994
  return {
@@ -6722,6 +7001,18 @@ var Endpoint = class {
6722
7001
  return { programId: messageLibInfo.owner, msgLib: info.messageLib, isDefault: false, timeout: null };
6723
7002
  }
6724
7003
  // rename to a more generic name
7004
+ /**
7005
+ * Gets the inbound payload hash.
7006
+ *
7007
+ * @param {Connection} connection - The connection to the Solana cluster.
7008
+ * @param {PublicKey} receiver - The receiver public key.
7009
+ * @param {number} srcEid - The source endpoint ID.
7010
+ * @param {Uint8Array} sender - The sender address.
7011
+ * @param {number} nonce - The nonce.
7012
+ * @param {Uint8Array} _payloadHash - The payload hash.
7013
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
7014
+ * @returns {Promise<PayloadHash | null>} A promise that resolves to the payload hash or null if not found.
7015
+ */
6725
7016
  async getInboundPayloadHash(connection, receiver, srcEid, sender, nonce, _payloadHash, commitmentOrConfig) {
6726
7017
  const [payloadHashPDA] = this.deriver.payloadHash(receiver, srcEid, sender, nonce);
6727
7018
  const accountInfo = await connection.getAccountInfo(payloadHashPDA, commitmentOrConfig);
@@ -6730,8 +7021,17 @@ var Endpoint = class {
6730
7021
  }
6731
7022
  return PayloadHash.fromAccountInfo(accountInfo, 0)[0];
6732
7023
  }
7024
+ /**
7025
+ * Gets the composed message state.
7026
+ *
7027
+ * @param {Connection} connection - The connection to the Solana cluster.
7028
+ * @param {PublicKey} from - The sender public key.
7029
+ * @param {types.SendComposeParams} params - The send compose parameters.
7030
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
7031
+ * @returns {Promise<ComposeMessageState | null>} A promise that resolves to the composed message state or null if not found.
7032
+ */
6733
7033
  async getComposedMessageState(connection, from, params, commitmentOrConfig) {
6734
- const message = arrayify(keccak256(params.message));
7034
+ const message = keccak_256(params.message);
6735
7035
  const [composedMessagePDA] = this.deriver.composedMessage(
6736
7036
  from,
6737
7037
  Uint8Array.from(params.guid),
@@ -6745,6 +7045,16 @@ var Endpoint = class {
6745
7045
  }
6746
7046
  return ComposeMessageState.fromAccountInfo(accountInfo, 0)[0];
6747
7047
  }
7048
+ /**
7049
+ * Gets the nonce.
7050
+ *
7051
+ * @param {Connection} connection - The connection to the Solana cluster.
7052
+ * @param {PublicKey} oappIDPDA - The OApp ID PDA.
7053
+ * @param {number} remoteEid - The remote endpoint ID.
7054
+ * @param {Uint8Array} remoteOappAddr - The remote OApp address.
7055
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
7056
+ * @returns {Promise<accounts.Nonce | null>} A promise that resolves to the nonce or null if not found.
7057
+ */
6748
7058
  async getNonce(connection, oappIDPDA2, remoteEid, remoteOappAddr, commitmentOrConfig) {
6749
7059
  const [nonce] = this.deriver.nonce(oappIDPDA2, remoteEid, remoteOappAddr);
6750
7060
  try {
@@ -6753,6 +7063,16 @@ var Endpoint = class {
6753
7063
  return null;
6754
7064
  }
6755
7065
  }
7066
+ /**
7067
+ * Gets the pending inbound nonce.
7068
+ *
7069
+ * @param {Connection} connection - The connection to the Solana cluster.
7070
+ * @param {PublicKey} oappIDPDA - The OApp ID PDA.
7071
+ * @param {number} remoteEid - The remote endpoint ID.
7072
+ * @param {Uint8Array} remoteOappAddr - The remote OApp address.
7073
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
7074
+ * @returns {Promise<accounts.PendingInboundNonce | null>} A promise that resolves to the pending inbound nonce or null if not found.
7075
+ */
6756
7076
  async getPendingInboundNonce(connection, oappIDPDA2, remoteEid, remoteOappAddr, commitmentOrConfig) {
6757
7077
  const [nonce] = this.deriver.pendingNonce(oappIDPDA2, remoteEid, remoteOappAddr);
6758
7078
  try {
@@ -6761,12 +7081,30 @@ var Endpoint = class {
6761
7081
  return null;
6762
7082
  }
6763
7083
  }
7084
+ /**
7085
+ * Gets the message library version.
7086
+ *
7087
+ * @param {Connection} connection - The connection to the Solana cluster.
7088
+ * @param {PublicKey} payer - The payer public key.
7089
+ * @param {PublicKey} messageLibProgram - The message library program public key.
7090
+ * @param {Commitment} [commitment='confirmed'] - The commitment level.
7091
+ * @returns {Promise<Version | null>} A promise that resolves to the version or null if not found.
7092
+ */
6764
7093
  async getMessageLibVersion(connection, payer, messageLibProgram, commitment = "confirmed") {
6765
7094
  const ix = simple_message_lib_exports.instructions.createVersionInstruction(messageLibProgram);
6766
7095
  const simulateResp = await simulateTransaction(connection, [ix], messageLibProgram, payer, commitment);
6767
7096
  const version = simple_message_lib_exports.types.versionBeet.read(simulateResp, 0);
6768
7097
  return version;
6769
7098
  }
7099
+ /**
7100
+ * Transfers the admin role to a new admin.
7101
+ *
7102
+ * @param {Connection} connection - The connection to the Solana cluster.
7103
+ * @param {PublicKey} admin - The current admin public key.
7104
+ * @param {PublicKey} newAdmin - The new admin public key.
7105
+ * @param {Commitment} [commitment='confirmed'] - The commitment level.
7106
+ * @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
7107
+ */
6770
7108
  async transferAdmin(connection, admin, newAdmin, commitment = "confirmed") {
6771
7109
  const [settingPDA] = this.deriver.setting();
6772
7110
  const endpointSettings = await EndpointSettings.fromAccountAddress(connection, settingPDA, commitment);
@@ -8713,10 +9051,27 @@ var PROGRAM_ID2 = new PublicKey(PROGRAM_ADDRESS2);
8713
9051
 
8714
9052
  // src/simple-message-lib.ts
8715
9053
  var SimpleMessageLib = class {
9054
+ /**
9055
+ * Creates an instance of the SimpleMessageLib class.
9056
+ *
9057
+ * @param {PublicKey} program - The program public key.
9058
+ */
8716
9059
  constructor(program) {
8717
9060
  this.program = program;
8718
9061
  this.deriver = new MessageLibPDADeriver(program);
8719
9062
  }
9063
+ /**
9064
+ * Initializes the SimpleMessageLib.
9065
+ *
9066
+ * @param {PublicKey} endpointProgram - The endpoint program public key.
9067
+ * @param {PublicKey} payer - The payer public key.
9068
+ * @param {PublicKey} admin - The admin public key.
9069
+ * @param {number} eid - The endpoint ID.
9070
+ * @param {number} nativeFee - The native fee.
9071
+ * @param {number} [lzTokenFee=0] - The LayerZero token fee.
9072
+ *
9073
+ * @returns {TransactionInstruction} The transaction instruction.
9074
+ */
8720
9075
  initSimpleMessageLib(endpointProgram, payer, admin, eid, nativeFee, lzTokenFee = 0) {
8721
9076
  const [messageLibPda] = this.deriver.messageLib();
8722
9077
  const [endpointAuth] = new EndpointPDADeriver(endpointProgram).messageLibraryInfo(messageLibPda);
@@ -8738,6 +9093,14 @@ var SimpleMessageLib = class {
8738
9093
  this.program
8739
9094
  );
8740
9095
  }
9096
+ /**
9097
+ * Sets the whitelist caller.
9098
+ *
9099
+ * @param {PublicKey} admin - The admin public key.
9100
+ * @param {PublicKey} newCaller - The new caller public key.
9101
+ *
9102
+ * @returns {TransactionInstruction} The transaction instruction.
9103
+ */
8741
9104
  setWhitelistCaller(admin, newCaller) {
8742
9105
  const [messageLibPDA] = this.deriver.messageLib();
8743
9106
  return createSetWlCallerInstruction(
@@ -8753,6 +9116,15 @@ var SimpleMessageLib = class {
8753
9116
  this.program
8754
9117
  );
8755
9118
  }
9119
+ /**
9120
+ * Checks if a caller is whitelisted.
9121
+ *
9122
+ * @param {Connection} connection - The connection object.
9123
+ * @param {PublicKey} caller - The caller public key.
9124
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment or config.
9125
+ *
9126
+ * @returns {Promise<boolean>} A promise that resolves to true if the caller is whitelisted, false otherwise.
9127
+ */
8756
9128
  async isWhiteListed(connection, caller, commitmentOrConfig) {
8757
9129
  try {
8758
9130
  const exceptedCaller = await this.getWhiteListCaller(connection, commitmentOrConfig);
@@ -8761,6 +9133,14 @@ var SimpleMessageLib = class {
8761
9133
  return false;
8762
9134
  }
8763
9135
  }
9136
+ /**
9137
+ * Gets the whitelisted caller.
9138
+ *
9139
+ * @param {Connection} connection - The connection object.
9140
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment or config.
9141
+ *
9142
+ * @returns {Promise<PublicKey>} A promise that resolves to the whitelisted caller public key.
9143
+ */
8764
9144
  async getWhiteListCaller(connection, commitmentOrConfig) {
8765
9145
  const [messageLibPDA] = this.deriver.messageLib();
8766
9146
  const messageLibInfo = await MessageLib.fromAccountAddress(
@@ -8770,6 +9150,16 @@ var SimpleMessageLib = class {
8770
9150
  );
8771
9151
  return messageLibInfo.wlCaller;
8772
9152
  }
9153
+ /**
9154
+ * Validates a packet.
9155
+ *
9156
+ * @param {Connection} _connection - The connection object.
9157
+ * @param {PublicKey} endpointProgram - The endpoint program public key.
9158
+ * @param {PublicKey} payer - The payer public key.
9159
+ * @param {Uint8Array} encodedPacket - The encoded packet.
9160
+ *
9161
+ * @returns {TransactionInstruction} The transaction instruction.
9162
+ */
8773
9163
  validatePacket(_connection, endpointProgram, payer, encodedPacket) {
8774
9164
  const packet = PacketV1Codec.fromBytes(encodedPacket);
8775
9165
  const [receiveLibrary] = this.deriver.messageLib();
@@ -8786,8 +9176,14 @@ var SimpleMessageLib = class {
8786
9176
  this.program
8787
9177
  );
8788
9178
  }
8789
- /***
8790
- * Get the account meta of the send instruction for CPI(Cross-Program Invocation )
9179
+ /**
9180
+ * Gets the account meta of the send instruction for CPI (Cross-Program Invocation).
9181
+ *
9182
+ * @param {Connection} _connection - The connection object.
9183
+ * @param {PublicKey} payer - The payer public key.
9184
+ * @param {PacketPath} _path - The packet path.
9185
+ *
9186
+ * @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account meta.
8791
9187
  */
8792
9188
  async getSendIXAccountMetaForCPI(_connection, payer, _path) {
8793
9189
  const [msgLib] = this.deriver.messageLib();
@@ -8807,6 +9203,16 @@ var SimpleMessageLib = class {
8807
9203
  });
8808
9204
  return Promise.resolve(cpiAccounts.slice(1));
8809
9205
  }
9206
+ /**
9207
+ * Gets the account meta of the quote instruction for CPI (Cross-Program Invocation).
9208
+ *
9209
+ * @param {Connection} _connection - The connection object.
9210
+ * @param {PublicKey} _payer - The payer public key.
9211
+ * @param {PacketPath} _path - The packet path.
9212
+ * @param {Commitment} [commitment] - The commitment.
9213
+ *
9214
+ * @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account meta.
9215
+ */
8810
9216
  async getQuoteIXAccountMetaForCPI(_connection, _payer, _path, _commitment) {
8811
9217
  const [msgLib] = this.deriver.messageLib();
8812
9218
  const keys = createQuoteInstructionAccounts2(
@@ -8819,8 +9225,14 @@ var SimpleMessageLib = class {
8819
9225
  );
8820
9226
  return Promise.resolve(keys.slice(1));
8821
9227
  }
8822
- /***
8823
- * Get the account meta of the send instruction for CPI(Cross-Program Invocation )
9228
+ /**
9229
+ * Gets the account meta of the init config instruction for CPI (Cross-Program Invocation).
9230
+ *
9231
+ * @param {PublicKey} payer - The payer public key.
9232
+ * @param {PublicKey} oappID - The oapp ID public key.
9233
+ * @param {number} eid - The endpoint ID.
9234
+ *
9235
+ * @returns {AccountMeta[]} An array of account meta.
8824
9236
  */
8825
9237
  getInitConfigIXAccountMetaForCPI(payer, oappID, eid) {
8826
9238
  const [sendConfig] = this.deriver.sendConfig(eid, oappID);
@@ -8844,6 +9256,15 @@ var SimpleMessageLib = class {
8844
9256
  });
8845
9257
  return keys.slice(1);
8846
9258
  }
9259
+ /**
9260
+ * Gets the account meta of the set config instruction for CPI (Cross-Program Invocation).
9261
+ *
9262
+ * @param {PublicKey} endpointProgram - The endpoint program public key.
9263
+ * @param {PublicKey} oappID - The oapp ID public key.
9264
+ * @param {number} eid - The endpoint ID.
9265
+ *
9266
+ * @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account meta.
9267
+ */
8847
9268
  async getSetConfigIXAccountMetaForCPI(endpointProgram, oappID, eid) {
8848
9269
  const [sendConfig] = this.deriver.sendConfig(eid, oappID);
8849
9270
  const [receiveConfig] = this.deriver.receiveConfig(eid, oappID);
@@ -10721,9 +11142,21 @@ var SolanaSignerExt = class _SolanaSignerExt {
10721
11142
  constructor(signers) {
10722
11143
  this.signers = signers;
10723
11144
  }
11145
+ /**
11146
+ * Creates an instance of the SolanaSignerExt class.
11147
+ *
11148
+ * @param {HashSigner[]} signers - The signers.
11149
+ * @returns {SolanaSignerExt} The SolanaSignerExt instance.
11150
+ */
10724
11151
  static from(signers) {
10725
11152
  return new _SolanaSignerExt(signers);
10726
11153
  }
11154
+ /**
11155
+ * Signs a message.
11156
+ *
11157
+ * @param {Buffer} message - The message to sign.
11158
+ * @returns {Promise<{ signature: Uint8Array; recoveryId: number }[]>} A promise that resolves to an array of signature objects.
11159
+ */
10727
11160
  async sign(message) {
10728
11161
  return Promise.all(
10729
11162
  this.signers.map(async (s) => {
@@ -10734,12 +11167,27 @@ var SolanaSignerExt = class _SolanaSignerExt {
10734
11167
  }
10735
11168
  };
10736
11169
  var DVN = class {
11170
+ /**
11171
+ * Creates an instance of the DVN class.
11172
+ *
11173
+ * @param {PublicKey} programId - The program ID.
11174
+ * @param {EndpointId} [endpointId=EndpointId.SOLANA_V2_SANDBOX] - The endpoint ID.
11175
+ */
10737
11176
  constructor(programId, endpointId = EndpointId.SOLANA_V2_SANDBOX) {
10738
11177
  this.programId = programId;
10739
11178
  this.dvnDeriver = new DVNDeriver(programId);
10740
11179
  this.vid = endpointId % 3e4;
10741
11180
  this.eventAuthority = new EventPDADeriver(programId).eventAuthority()[0];
10742
11181
  }
11182
+ /**
11183
+ * Initializes the DVN.
11184
+ *
11185
+ * @param {Connection} connection - The connection.
11186
+ * @param {PublicKey} payer - The payer.
11187
+ * @param {InitDvnParams} params - The initialization parameters.
11188
+ * @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
11189
+ * @throws {Error} If the DVN is already initialized.
11190
+ */
10743
11191
  async initDVN(connection, payer, params) {
10744
11192
  const [config] = this.dvnDeriver.config();
10745
11193
  const info = await connection.getAccountInfo(config);
@@ -10757,6 +11205,14 @@ var DVN = class {
10757
11205
  this.programId
10758
11206
  );
10759
11207
  }
11208
+ /**
11209
+ * Gets the digest for a transaction.
11210
+ *
11211
+ * @param {number} vid - The validator ID.
11212
+ * @param {TransactionInstruction} instruction - The transaction instruction.
11213
+ * @param {number} expiration - The expiration time.
11214
+ * @returns {types.ExecuteTransactionDigest} The transaction digest.
11215
+ */
10760
11216
  getDigest(vid, instruction, expiration) {
10761
11217
  return {
10762
11218
  vid,
@@ -10772,15 +11228,39 @@ var DVN = class {
10772
11228
  expiration
10773
11229
  };
10774
11230
  }
11231
+ /**
11232
+ * Gets the execute hash for a given hash bytes.
11233
+ *
11234
+ * @param {Buffer} hashBytes - The hash bytes.
11235
+ * @returns {PublicKey} The execute hash.
11236
+ */
10775
11237
  getExecuteHash(hashBytes) {
10776
11238
  const [executeHash] = this.dvnDeriver.executeHash(hashBytes);
10777
11239
  return executeHash;
10778
11240
  }
11241
+ /**
11242
+ * Gets the hash bytes for a given digest.
11243
+ *
11244
+ * @param {types.ExecuteTransactionDigest} digest - The transaction digest.
11245
+ * @returns {Buffer} The hash bytes.
11246
+ */
10779
11247
  getHashBytes(digest) {
10780
11248
  const [digestBytes] = executeTransactionDigestBeet.serialize(digest);
10781
- const hash = keccak256(digestBytes);
10782
- return Buffer.from(hash.slice(2), "hex");
11249
+ const hash = keccak_256(digestBytes);
11250
+ return Buffer.from(hash);
10783
11251
  }
11252
+ /**
11253
+ * Invokes a transaction.
11254
+ *
11255
+ * @param {Connection} connection - The connection.
11256
+ * @param {number} vid - The validator ID.
11257
+ * @param {PublicKey} payer - The payer.
11258
+ * @param {TransactionInstruction} instruction - The transaction instruction.
11259
+ * @param {number} expiration - The expiration time.
11260
+ * @param {SignFunc} sign - The sign function.
11261
+ * @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
11262
+ * @throws {Error} If the DVN is not initialized.
11263
+ */
10784
11264
  async invoke(connection, vid, payer, instruction, expiration, sign) {
10785
11265
  const configState = await this.getConfigState(connection, "confirmed");
10786
11266
  if (!configState) {
@@ -10822,6 +11302,12 @@ var DVN = class {
10822
11302
  this.programId
10823
11303
  );
10824
11304
  }
11305
+ /**
11306
+ * Creates a transaction instruction to set the quorum.
11307
+ *
11308
+ * @param {number} quorum - The quorum.
11309
+ * @returns {TransactionInstruction} The transaction instruction.
11310
+ */
10825
11311
  createSetQuorumInstruction(quorum) {
10826
11312
  const params = {
10827
11313
  fields: [quorum],
@@ -10836,6 +11322,12 @@ var DVN = class {
10836
11322
  data: buffer
10837
11323
  });
10838
11324
  }
11325
+ /**
11326
+ * Creates a transaction instruction to set the admins.
11327
+ *
11328
+ * @param {PublicKey[]} admins - The admin public keys.
11329
+ * @returns {TransactionInstruction} The transaction instruction.
11330
+ */
10839
11331
  createSetAdminsInstruction(admins) {
10840
11332
  const params = {
10841
11333
  fields: [admins],
@@ -10850,6 +11342,12 @@ var DVN = class {
10850
11342
  data: buffer
10851
11343
  });
10852
11344
  }
11345
+ /**
11346
+ * Creates a transaction instruction to set the signers.
11347
+ *
11348
+ * @param {Uint8Array[]} signers - The signer public keys.
11349
+ * @returns {TransactionInstruction} The transaction instruction.
11350
+ */
10853
11351
  createSetSignersInstruction(signers) {
10854
11352
  const params = {
10855
11353
  fields: [signers.map((s) => Array.from(s))],
@@ -10864,6 +11362,12 @@ var DVN = class {
10864
11362
  data: buffer
10865
11363
  });
10866
11364
  }
11365
+ /**
11366
+ * Creates a transaction instruction to set the allowlist.
11367
+ *
11368
+ * @param {PublicKey[]} allowlist - The allowlist public keys.
11369
+ * @returns {TransactionInstruction} The transaction instruction.
11370
+ */
10867
11371
  createSetAllowlistInstruction(allowlist) {
10868
11372
  const params = {
10869
11373
  fields: [allowlist],
@@ -10878,6 +11382,12 @@ var DVN = class {
10878
11382
  data: buffer
10879
11383
  });
10880
11384
  }
11385
+ /**
11386
+ * Creates a transaction instruction to set the denylist.
11387
+ *
11388
+ * @param {PublicKey[]} denylist - The denylist public keys.
11389
+ * @returns {TransactionInstruction} The transaction instruction.
11390
+ */
10881
11391
  createSetDenylistInstruction(denylist) {
10882
11392
  const params = {
10883
11393
  fields: [denylist],
@@ -10892,6 +11402,12 @@ var DVN = class {
10892
11402
  data: buffer
10893
11403
  });
10894
11404
  }
11405
+ /**
11406
+ * Creates a transaction instruction to set the pause state.
11407
+ *
11408
+ * @param {boolean} pause - The pause state.
11409
+ * @returns {TransactionInstruction} The transaction instruction.
11410
+ */
10895
11411
  createSetPauseInstruction(pause) {
10896
11412
  const params = {
10897
11413
  fields: [pause],
@@ -10906,6 +11422,13 @@ var DVN = class {
10906
11422
  data: buffer
10907
11423
  });
10908
11424
  }
11425
+ /**
11426
+ * Creates a transaction instruction to set the default multiplier basis points.
11427
+ *
11428
+ * @param {PublicKey} admin - The admin public key.
11429
+ * @param {number} defaultMultiplierBps - The default multiplier basis points.
11430
+ * @returns {TransactionInstruction} The transaction instruction.
11431
+ */
10909
11432
  createSetDefaultMultiplierBpsInstruction(admin, defaultMultiplierBps) {
10910
11433
  const [configAccount] = this.dvnDeriver.config();
10911
11434
  return createSetConfigInstruction3(
@@ -10926,6 +11449,13 @@ var DVN = class {
10926
11449
  this.programId
10927
11450
  );
10928
11451
  }
11452
+ /**
11453
+ * Creates a transaction instruction to change the admins.
11454
+ *
11455
+ * @param {PublicKey} admin - The admin public key.
11456
+ * @param {PublicKey[]} admins - The new admin public keys.
11457
+ * @returns {TransactionInstruction} The transaction instruction.
11458
+ */
10929
11459
  createChangeAdminsInstruction(admin, admins) {
10930
11460
  const [configAccount] = this.dvnDeriver.config();
10931
11461
  return createSetConfigInstruction3(
@@ -10946,6 +11476,13 @@ var DVN = class {
10946
11476
  this.programId
10947
11477
  );
10948
11478
  }
11479
+ /**
11480
+ * Creates a transaction instruction to set the destination configurations.
11481
+ *
11482
+ * @param {PublicKey} admin - The admin public key.
11483
+ * @param {types.DstConfig[]} dstConfigs - The destination configurations.
11484
+ * @returns {TransactionInstruction} The transaction instruction.
11485
+ */
10949
11486
  createSetDstConfigInstruction(admin, dstConfigs) {
10950
11487
  const [configAccount] = this.dvnDeriver.config();
10951
11488
  return createSetConfigInstruction3(
@@ -10966,6 +11503,13 @@ var DVN = class {
10966
11503
  this.programId
10967
11504
  );
10968
11505
  }
11506
+ /**
11507
+ * Creates a transaction instruction to remove the destination configurations.
11508
+ *
11509
+ * @param {PublicKey} admin - The admin public key.
11510
+ * @param {number[]} removeEids - The endpoint IDs to remove.
11511
+ * @returns {TransactionInstruction} The transaction instruction.
11512
+ */
10969
11513
  createRemoveDstConfigInstruction(admin, removeEids) {
10970
11514
  const [configAccount] = this.dvnDeriver.config();
10971
11515
  return createSetConfigInstruction3(
@@ -10986,6 +11530,12 @@ var DVN = class {
10986
11530
  this.programId
10987
11531
  );
10988
11532
  }
11533
+ /**
11534
+ * Creates a transaction instruction to set the message libraries.
11535
+ *
11536
+ * @param {PublicKey[]} msglibPrograms - The message library public keys.
11537
+ * @returns {TransactionInstruction} The transaction instruction.
11538
+ */
10989
11539
  createSetMsgLibsInstruction(msglibPrograms) {
10990
11540
  const params = {
10991
11541
  fields: [msglibPrograms],
@@ -11000,13 +11550,34 @@ var DVN = class {
11000
11550
  data: buffer
11001
11551
  });
11002
11552
  }
11553
+ /**
11554
+ * Gets the expiration time.
11555
+ *
11556
+ * @returns {number} The expiration time.
11557
+ */
11003
11558
  _getExpiration() {
11004
11559
  return (/* @__PURE__ */ new Date()).getTime() / 1e3 + 120;
11005
11560
  }
11561
+ /**
11562
+ * Sets the message libraries.
11563
+ *
11564
+ * @param {Connection} connection - The connection.
11565
+ * @param {PublicKey} payer - The payer.
11566
+ * @param {PublicKey[]} msgLibs - The message library public keys.
11567
+ * @param {SignFunc} sign - The sign function.
11568
+ * @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
11569
+ */
11006
11570
  async setMsgLibs(connection, payer, msgLibs, sign) {
11007
11571
  const expiration = this._getExpiration();
11008
11572
  return this.invoke(connection, this.vid, payer, this.createSetMsgLibsInstruction(msgLibs), expiration, sign);
11009
11573
  }
11574
+ /**
11575
+ * Creates a transaction instruction to set the price feed.
11576
+ *
11577
+ * @param {PublicKey} admin - The admin public key.
11578
+ * @param {PublicKey} priceFeedProgram - The price feed program public key.
11579
+ * @returns {TransactionInstruction} The transaction instruction.
11580
+ */
11010
11581
  createSetPriceFeedInstruction(admin, priceFeedProgram) {
11011
11582
  const [configAccount] = this.dvnDeriver.config();
11012
11583
  const [priceFeedPda] = new PriceFeedPDADeriver(priceFeedProgram).priceFeed();
@@ -11028,6 +11599,14 @@ var DVN = class {
11028
11599
  this.programId
11029
11600
  );
11030
11601
  }
11602
+ /**
11603
+ * Gets the account metadata for the CPI (Cross-Program Invocation) of the quote instruction.
11604
+ *
11605
+ * @param {PublicKey} priceFeedConfig - The price feed configuration public key.
11606
+ * @param {PublicKey} priceFeedProgram - The price feed program public key.
11607
+ * @param {boolean} payment - Indicates if payment is required.
11608
+ * @returns {AccountMeta[]} An array of account metadata.
11609
+ */
11031
11610
  getQuoteIXAccountMetaForCPI(priceFeedConfig, priceFeedProgram, payment) {
11032
11611
  const [config] = this.dvnDeriver.config();
11033
11612
  const keys = createQuoteDvnInstructionAccounts(
@@ -11049,6 +11628,13 @@ var DVN = class {
11049
11628
  }
11050
11629
  ].concat(keys);
11051
11630
  }
11631
+ /**
11632
+ * Gets the configuration state.
11633
+ *
11634
+ * @param {Connection} connection - The connection to the Solana cluster.
11635
+ * @param {Commitment | GetAccountInfoConfig} [commitment='confirmed'] - The commitment level or account info configuration.
11636
+ * @returns {Promise<accounts.DvnConfig | null>} A promise that resolves to the configuration state or null if not found.
11637
+ */
11052
11638
  async getConfigState(connection, commitment = "confirmed") {
11053
11639
  const [config] = this.dvnDeriver.config();
11054
11640
  try {
@@ -12620,8 +13206,8 @@ var treasurySetEventBeet = new beet159.FixableBeetArgsStruct(
12620
13206
  function getEventDiscriminator(event) {
12621
13207
  const hash = crypto.createHash("sha256");
12622
13208
  hash.update(`event:${event}`);
12623
- const sha2562 = hash.digest("hex");
12624
- return sha2562.slice(0, 16);
13209
+ const sha256 = hash.digest("hex");
13210
+ return sha256.slice(0, 16);
12625
13211
  }
12626
13212
  async function extractSentPacketEventByTxHash(connection, program, signature, commitment, unsafeParseErr = false) {
12627
13213
  const events = await extractEventFromTransactionSignature(
@@ -12632,8 +13218,7 @@ async function extractSentPacketEventByTxHash(connection, program, signature, co
12632
13218
  commitment,
12633
13219
  unsafeParseErr
12634
13220
  );
12635
- if (!events)
12636
- return null;
13221
+ if (!events) return null;
12637
13222
  return events;
12638
13223
  }
12639
13224
  async function extractVerifiedPacketEventByTxHash(connection, program, signature, commitment, unsafeParseErr = false) {
@@ -12645,8 +13230,7 @@ async function extractVerifiedPacketEventByTxHash(connection, program, signature
12645
13230
  commitment,
12646
13231
  unsafeParseErr
12647
13232
  );
12648
- if (!events)
12649
- return null;
13233
+ if (!events) return null;
12650
13234
  return events;
12651
13235
  }
12652
13236
  async function extractReceivedPacketEventByTxHash(connection, program, signature, commitment, unsafeParseErr = false) {
@@ -12658,8 +13242,7 @@ async function extractReceivedPacketEventByTxHash(connection, program, signature
12658
13242
  commitment,
12659
13243
  unsafeParseErr
12660
13244
  );
12661
- if (!events)
12662
- return null;
13245
+ if (!events) return null;
12663
13246
  return events;
12664
13247
  }
12665
13248
  async function extractComposeSentEventByTxHash(connection, program, signature, commitment, unsafeParseErr = false) {
@@ -12671,8 +13254,7 @@ async function extractComposeSentEventByTxHash(connection, program, signature, c
12671
13254
  commitment,
12672
13255
  unsafeParseErr
12673
13256
  );
12674
- if (!events)
12675
- return null;
13257
+ if (!events) return null;
12676
13258
  return events;
12677
13259
  }
12678
13260
  async function extractComposeDeliveredEventByTxHash(connection, program, signature, commitment, unsafeParseErr = false) {
@@ -12684,8 +13266,7 @@ async function extractComposeDeliveredEventByTxHash(connection, program, signatu
12684
13266
  commitment,
12685
13267
  unsafeParseErr
12686
13268
  );
12687
- if (!events)
12688
- return null;
13269
+ if (!events) return null;
12689
13270
  return events;
12690
13271
  }
12691
13272
  async function extractWorkerFeePaidEventByTxHash(connection, program, signature, commitment, unsafeParseErr = false) {
@@ -12697,14 +13278,12 @@ async function extractWorkerFeePaidEventByTxHash(connection, program, signature,
12697
13278
  commitment,
12698
13279
  unsafeParseErr
12699
13280
  );
12700
- if (!events)
12701
- return null;
13281
+ if (!events) return null;
12702
13282
  return events;
12703
13283
  }
12704
13284
  async function extractEventFromTransactionSignature(connection, program, signature, eventBeet, commitment, unsafeParseErr = false) {
12705
13285
  const tx = typeof signature === "string" ? await connection.getParsedTransaction(signature, commitment) : signature;
12706
- if (tx == null)
12707
- return null;
13286
+ if (tx == null) return null;
12708
13287
  const events = new Array();
12709
13288
  if (tx.meta?.err !== null && !unsafeParseErr) {
12710
13289
  return null;
@@ -12851,7 +13430,7 @@ async function buildVersionedTransaction(connection, payerKey, instructions, com
12851
13430
  );
12852
13431
  }
12853
13432
  function instructionDiscriminator(method) {
12854
- return Buffer.from(sha256(Buffer.from(`global:${method}`)).substring(2), "hex").subarray(0, 8);
13433
+ return Buffer.from(sha2_256(Buffer.from(`global:${method}`))).subarray(0, 8);
12855
13434
  }
12856
13435
  async function simulateTransaction(connection, instructions, programId, payer, commitment = "confirmed", blockhash, lookupTableAddress) {
12857
13436
  const tx = await buildVersionedTransaction(
@@ -12999,8 +13578,7 @@ function retrieveAccountFromSimulatedResp(resp, payer) {
12999
13578
  const results = fixedBeet.read(resp, 0);
13000
13579
  return results.map((r) => {
13001
13580
  if (r.pubkey.toBase58() == PublicKey.default.toBase58() && r.isSigner) {
13002
- if (!payer)
13003
- throw new Error("payer is required");
13581
+ if (!payer) throw new Error("payer is required");
13004
13582
  return {
13005
13583
  pubkey: payer,
13006
13584
  isSigner: true,
@@ -13292,11 +13870,28 @@ var PROGRAM_ID4 = new PublicKey(PROGRAM_ADDRESS4);
13292
13870
 
13293
13871
  // src/executor.ts
13294
13872
  var Executor = class {
13873
+ /**
13874
+ * Creates an instance of the Executor class.
13875
+ *
13876
+ * @param {PublicKey} program - The program public key.
13877
+ */
13295
13878
  constructor(program) {
13296
13879
  this.program = program;
13297
13880
  this.deriver = new ExecutorPDADeriver(this.program);
13298
13881
  }
13299
13882
  // owner methods
13883
+ /**
13884
+ * Initializes the executor.
13885
+ *
13886
+ * @param {PublicKey} payer - The payer public key.
13887
+ * @param {PublicKey} owner - The owner public key.
13888
+ * @param {PublicKey[]} admins - The admin public keys.
13889
+ * @param {PublicKey[]} executors - The executor public keys.
13890
+ * @param {PublicKey[]} msglibs - The message library public keys.
13891
+ * @param {PublicKey} priceFeed - The price feed public key.
13892
+ *
13893
+ * @returns {TransactionInstruction} The transaction instruction.
13894
+ */
13300
13895
  initExecutor(payer, owner, admins, executors, msglibs, priceFeed) {
13301
13896
  const [configAccount] = this.deriver.config();
13302
13897
  return createInitExecutorInstruction(
@@ -13316,6 +13911,14 @@ var Executor = class {
13316
13911
  this.program
13317
13912
  );
13318
13913
  }
13914
+ /**
13915
+ * Sets the owner.
13916
+ *
13917
+ * @param {PublicKey} owner - The current owner public key.
13918
+ * @param {PublicKey} newOwner - The new owner public key.
13919
+ *
13920
+ * @returns {TransactionInstruction} The transaction instruction.
13921
+ */
13319
13922
  setOwner(owner, newOwner) {
13320
13923
  const [configAccount] = this.deriver.config();
13321
13924
  return createOwnerSetConfigInstruction(
@@ -13332,6 +13935,14 @@ var Executor = class {
13332
13935
  this.program
13333
13936
  );
13334
13937
  }
13938
+ /**
13939
+ * Sets the admins.
13940
+ *
13941
+ * @param {PublicKey} owner - The owner public key.
13942
+ * @param {PublicKey[]} admins - The admin public keys.
13943
+ *
13944
+ * @returns {TransactionInstruction} The transaction instruction.
13945
+ */
13335
13946
  setAdmins(owner, admins) {
13336
13947
  const [configAccount] = this.deriver.config();
13337
13948
  return createOwnerSetConfigInstruction(
@@ -13348,6 +13959,14 @@ var Executor = class {
13348
13959
  this.program
13349
13960
  );
13350
13961
  }
13962
+ /**
13963
+ * Sets the allow list.
13964
+ *
13965
+ * @param {PublicKey} owner - The owner public key.
13966
+ * @param {PublicKey[]} allowlist - The allow list public keys.
13967
+ *
13968
+ * @returns {TransactionInstruction} The transaction instruction.
13969
+ */
13351
13970
  setAllowList(owner, allowlist) {
13352
13971
  const [configAccount] = this.deriver.config();
13353
13972
  return createOwnerSetConfigInstruction(
@@ -13364,6 +13983,14 @@ var Executor = class {
13364
13983
  this.program
13365
13984
  );
13366
13985
  }
13986
+ /**
13987
+ * Sets the deny list.
13988
+ *
13989
+ * @param {PublicKey} owner - The owner public key.
13990
+ * @param {PublicKey[]} denylist - The deny list public keys.
13991
+ *
13992
+ * @returns {TransactionInstruction} The transaction instruction.
13993
+ */
13367
13994
  setDenyList(owner, denylist) {
13368
13995
  const [configAccount] = this.deriver.config();
13369
13996
  return createOwnerSetConfigInstruction(
@@ -13380,6 +14007,14 @@ var Executor = class {
13380
14007
  this.program
13381
14008
  );
13382
14009
  }
14010
+ /**
14011
+ * Sets the paused state.
14012
+ *
14013
+ * @param {PublicKey} owner - The owner public key.
14014
+ * @param {boolean} paused - The paused state.
14015
+ *
14016
+ * @returns {TransactionInstruction} The transaction instruction.
14017
+ */
13383
14018
  setPaused(owner, paused) {
13384
14019
  const [configAccount] = this.deriver.config();
13385
14020
  return createOwnerSetConfigInstruction(
@@ -13396,6 +14031,14 @@ var Executor = class {
13396
14031
  this.program
13397
14032
  );
13398
14033
  }
14034
+ /**
14035
+ * Sets the executors.
14036
+ *
14037
+ * @param {PublicKey} owner - The owner public key.
14038
+ * @param {PublicKey[]} executors - The executor public keys.
14039
+ *
14040
+ * @returns {TransactionInstruction} The transaction instruction.
14041
+ */
13399
14042
  setExecutors(owner, executors) {
13400
14043
  const [configAccount] = this.deriver.config();
13401
14044
  return createOwnerSetConfigInstruction(
@@ -13412,6 +14055,14 @@ var Executor = class {
13412
14055
  this.program
13413
14056
  );
13414
14057
  }
14058
+ /**
14059
+ * Sets the message libraries by programs.
14060
+ *
14061
+ * @param {PublicKey} owner - The owner public key.
14062
+ * @param {PublicKey[]} msglibPrograms - The message library program public keys.
14063
+ *
14064
+ * @returns {TransactionInstruction} The transaction instruction.
14065
+ */
13415
14066
  setMsglibByPrograms(owner, msglibPrograms) {
13416
14067
  this.deriver.config();
13417
14068
  const msglibPdas = msglibPrograms.map((program) => {
@@ -13419,6 +14070,14 @@ var Executor = class {
13419
14070
  });
13420
14071
  return this.setMsglibByPDAs(owner, msglibPdas);
13421
14072
  }
14073
+ /**
14074
+ * Sets the message libraries by PDAs.
14075
+ *
14076
+ * @param {PublicKey} owner - The owner public key.
14077
+ * @param {PublicKey[]} msglibPDAs - The message library PDA public keys.
14078
+ *
14079
+ * @returns {TransactionInstruction} The transaction instruction.
14080
+ */
13422
14081
  setMsglibByPDAs(owner, msglibPDAs) {
13423
14082
  const [configAccount] = this.deriver.config();
13424
14083
  return createOwnerSetConfigInstruction(
@@ -13436,6 +14095,14 @@ var Executor = class {
13436
14095
  );
13437
14096
  }
13438
14097
  // admin methods
14098
+ /**
14099
+ * Sets the default multiplier BPS.
14100
+ *
14101
+ * @param {PublicKey} admin - The admin public key.
14102
+ * @param {number} defaultMultiplierBps - The default multiplier BPS.
14103
+ *
14104
+ * @returns {TransactionInstruction} The transaction instruction.
14105
+ */
13439
14106
  setDefaultMultiplierBps(admin, defaultMultiplierBps) {
13440
14107
  const [configAccount] = this.deriver.config();
13441
14108
  return createAdminSetConfigInstruction(
@@ -13452,6 +14119,14 @@ var Executor = class {
13452
14119
  this.program
13453
14120
  );
13454
14121
  }
14122
+ /**
14123
+ * Sets the destination configurations.
14124
+ *
14125
+ * @param {PublicKey} admin - The admin public key.
14126
+ * @param {types.DstConfig[]} dstConfigs - The destination configurations.
14127
+ *
14128
+ * @returns {TransactionInstruction} The transaction instruction.
14129
+ */
13455
14130
  setDstConfig(admin, dstConfigs) {
13456
14131
  const [configAccount] = this.deriver.config();
13457
14132
  return createAdminSetConfigInstruction(
@@ -13468,6 +14143,14 @@ var Executor = class {
13468
14143
  this.program
13469
14144
  );
13470
14145
  }
14146
+ /**
14147
+ * Sets the price feed.
14148
+ *
14149
+ * @param {PublicKey} admin - The admin public key.
14150
+ * @param {PublicKey} priceFeedProgram - The price feed program public key.
14151
+ *
14152
+ * @returns {TransactionInstruction} The transaction instruction.
14153
+ */
13471
14154
  setPriceFeed(admin, priceFeedProgram) {
13472
14155
  const [configAccount] = this.deriver.config();
13473
14156
  const [priceFeed] = new PriceFeedPDADeriver(priceFeedProgram).priceFeed();
@@ -13485,6 +14168,14 @@ var Executor = class {
13485
14168
  this.program
13486
14169
  );
13487
14170
  }
14171
+ /**
14172
+ * Gets the executor configuration.
14173
+ *
14174
+ * @param {Connection} connection - The connection.
14175
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment or configuration.
14176
+ *
14177
+ * @returns {Promise<accounts.ExecutorConfig | null>} A promise that resolves to the executor configuration or null.
14178
+ */
13488
14179
  async getExecutorConfig(connection, commitmentOrConfig) {
13489
14180
  const [configAccount] = this.deriver.config();
13490
14181
  try {
@@ -13498,6 +14189,15 @@ var Executor = class {
13498
14189
  return null;
13499
14190
  }
13500
14191
  }
14192
+ /**
14193
+ * Gets the quote instruction account meta for CPI.
14194
+ *
14195
+ * @param {PublicKey} priceFeedConfig - The price feed configuration public key.
14196
+ * @param {PublicKey} priceFeedProgram - The price feed program public key.
14197
+ * @param {boolean} payment - Whether payment is required.
14198
+ *
14199
+ * @returns {AccountMeta[]} The account meta array.
14200
+ */
13501
14201
  getQuoteIXAccountMetaForCPI(priceFeedConfig, priceFeedProgram, payment) {
13502
14202
  const [config] = this.deriver.config();
13503
14203
  const ixAccounts = createQuoteExecutorInstructionAccounts(
@@ -13519,6 +14219,20 @@ var Executor = class {
13519
14219
  }
13520
14220
  ].concat(ixAccounts);
13521
14221
  }
14222
+ /**
14223
+ * Executes a transaction.
14224
+ *
14225
+ * @param {Connection} connection - The connection.
14226
+ * @param {PublicKey} executor - The executor public key.
14227
+ * @param {PublicKey} endpointProgram - The endpoint program public key.
14228
+ * @param {Packet} packet - The packet.
14229
+ * @param {Uint8Array} extraData - The extra data.
14230
+ * @param {BN} [value] - The value.
14231
+ * @param {number} [computeUnits] - The compute units.
14232
+ * @param {Commitment} [commitmentOrConfig] - The commitment or configuration.
14233
+ *
14234
+ * @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
14235
+ */
13522
14236
  async execute(connection, executor, endpointProgram, packet, extraData, value = new BN(0), computeUnits = 2e5, commitmentOrConfig) {
13523
14237
  const [config] = this.deriver.config();
13524
14238
  const endpointEventDeriver = new EventPDADeriver(endpointProgram);
@@ -13578,6 +14292,20 @@ var Executor = class {
13578
14292
  this.program
13579
14293
  );
13580
14294
  }
14295
+ /**
14296
+ * Composes a transaction.
14297
+ *
14298
+ * @param {Connection} connection - The connection.
14299
+ * @param {PublicKey} executor - The executor public key.
14300
+ * @param {PublicKey} endpointProgram - The endpoint program public key.
14301
+ * @param {ComposeSentEvent} event - The compose sent event.
14302
+ * @param {Uint8Array} extraData - The extra data.
14303
+ * @param {BN} [value] - The value.
14304
+ * @param {number} [computeUnits] - The compute units.
14305
+ * @param {Commitment} [commitmentOrConfig] - The commitment or configuration.
14306
+ *
14307
+ * @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
14308
+ */
13581
14309
  async compose(connection, executor, endpointProgram, event, extraData, value = new BN(0), computeUnits = 4e5, commitmentOrConfig) {
13582
14310
  const [config] = this.deriver.config();
13583
14311
  const endpointEventDeriver = new EventPDADeriver(endpointProgram);
@@ -16440,12 +17168,26 @@ var PROGRAM_ID5 = new PublicKey(PROGRAM_ADDRESS5);
16440
17168
 
16441
17169
  // src/uln.ts
16442
17170
  var Uln = class {
17171
+ /**
17172
+ * Creates an instance of the Uln class.
17173
+ *
17174
+ * @param {PublicKey} program - The program public key.
17175
+ */
16443
17176
  constructor(program) {
16444
17177
  this.program = program;
16445
17178
  this.deriver = new UlnPDADeriver(program);
16446
17179
  const [eventAuthorityPDA] = new EventPDADeriver(program).eventAuthority();
16447
17180
  this.eventAuthorityPDA = eventAuthorityPDA;
16448
17181
  }
17182
+ /**
17183
+ * Initializes the ULN.
17184
+ *
17185
+ * @param {PublicKey} endpointProgram - The endpoint program public key.
17186
+ * @param {PublicKey} payer - The payer public key.
17187
+ * @param {PublicKey} admin - The admin public key.
17188
+ * @param {number} eid - The endpoint ID.
17189
+ * @returns {TransactionInstruction} The transaction instruction.
17190
+ */
16449
17191
  initUln(endpointProgram, payer, admin, eid) {
16450
17192
  const [setting] = this.deriver.setting();
16451
17193
  const [msgLib] = this.deriver.messageLib();
@@ -16467,7 +17209,17 @@ var Uln = class {
16467
17209
  );
16468
17210
  }
16469
17211
  /**
17212
+ * Initializes or updates the default configuration.
16470
17213
  * before calling this function, you should call initUln to initialize the uln
17214
+ *
17215
+ * @param {Connection} connection - The connection to the Solana cluster.
17216
+ * @param {PublicKey} admin - The admin public key.
17217
+ * @param {number} eid - The endpoint ID.
17218
+ * @param {types.UlnConfig} sendUlnConfig - The send ULN configuration.
17219
+ * @param {types.UlnConfig} receiveUlnConfig - The receive ULN configuration.
17220
+ * @param {types.ExecutorConfig} executorConfig - The executor configuration.
17221
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
17222
+ * @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
16471
17223
  */
16472
17224
  async initOrUpdateDefaultConfig(connection, admin, eid, sendUlnConfig, receiveUlnConfig, executorConfig, commitmentOrConfig) {
16473
17225
  const [setting] = this.deriver.setting();
@@ -16518,7 +17270,18 @@ var Uln = class {
16518
17270
  }
16519
17271
  // msg_lib -> msg_lib_program ->
16520
17272
  /**
17273
+ * Sets the treasury.
16521
17274
  * before calling this function, you should call initUln to initialize the uln
17275
+ *
17276
+ * @param {PublicKey} admin - The admin public key.
17277
+ * @param {object} treasury - The treasury object.
17278
+ * @param {PublicKey} treasury.admin - The treasury admin public key.
17279
+ * @param {PublicKey} treasury.nativeReceiver - The native receiver public key.
17280
+ * @param {number} treasury.nativeFeeBps - The native fee basis points.
17281
+ * @param {object} treasury.lzToken - The LZ token object.
17282
+ * @param {PublicKey} treasury.lzToken.receiver - The LZ token receiver public key.
17283
+ * @param {number} treasury.lzToken.fee - The LZ token fee.
17284
+ * @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
16522
17285
  */
16523
17286
  async setTreasury(admin, treasury) {
16524
17287
  const [setting] = this.deriver.setting();
@@ -16538,6 +17301,16 @@ var Uln = class {
16538
17301
  );
16539
17302
  return Promise.resolve(ix);
16540
17303
  }
17304
+ /**
17305
+ * Transfers the admin role to a new admin.
17306
+ *
17307
+ * @param {Connection} connection - The connection to the Solana cluster.
17308
+ * @param {PublicKey} admin - The current admin public key.
17309
+ * @param {PublicKey} newAdmin - The new admin public key.
17310
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
17311
+ * @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
17312
+ * @throws {Error} If the ULN is not initialized.
17313
+ */
16541
17314
  async transferAdmin(connection, admin, newAdmin, commitmentOrConfig) {
16542
17315
  const [setting] = this.deriver.setting();
16543
17316
  const info = await connection.getAccountInfo(setting, commitmentOrConfig);
@@ -16560,15 +17333,13 @@ var Uln = class {
16560
17333
  );
16561
17334
  }
16562
17335
  /**
17336
+ * Gets the account metadata for the CPI (Cross-Program Invocation) of the quote instruction.
16563
17337
  *
16564
- * @param connection
16565
- *
16566
- * @param sender the oApp PDA
16567
- * @param sendLibraryAuthority
16568
- * @param dstEid
16569
- * @param payInLzToken
16570
- * @param commitment
16571
- * @returns
17338
+ * @param {Connection} connection - The connection to the Solana cluster.
17339
+ * @param {PublicKey} _payer - The payer public key.
17340
+ * @param {PacketPath} path - The packet path.
17341
+ * @param {Commitment} [commitment] - The commitment level.
17342
+ * @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
16572
17343
  */
16573
17344
  async getQuoteIXAccountMetaForCPI(connection, _payer, path, commitment) {
16574
17345
  const { sender: sender_, dstEid } = path;
@@ -16590,8 +17361,14 @@ var Uln = class {
16590
17361
  );
16591
17362
  return accounts.slice(1);
16592
17363
  }
16593
- /***
16594
- * Get the account meta of the send instruction for CPI(Cross-Program Invocation )
17364
+ /**
17365
+ * Gets the account metadata for the CPI (Cross-Program Invocation) of the send instruction.
17366
+ *
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='confirmed'] - The commitment level.
17371
+ * @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
16595
17372
  */
16596
17373
  async getSendIXAccountMetaForCPI(connection, payer, path, commitment = "confirmed") {
16597
17374
  const { sender: sender_, dstEid } = path;
@@ -16629,6 +17406,16 @@ var Uln = class {
16629
17406
  return accounts.slice(1);
16630
17407
  }
16631
17408
  // 3 RPC requests
17409
+ /**
17410
+ * Gets the remaining accounts for the send instruction.
17411
+ *
17412
+ * @param {Connection} connection - The connection to the Solana cluster.
17413
+ * @param {PublicKey} sender - The sender public key.
17414
+ * @param {number} dstEid - The destination endpoint ID.
17415
+ * @param {boolean} payment - Indicates if payment is required.
17416
+ * @param {Commitment | GetAccountInfoConfig} [commitment='confirmed'] - The commitment level or account info configuration.
17417
+ * @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
17418
+ */
16632
17419
  async getSendIxRemainingAccounts(connection, sender, dstEid, payment, commitment = "confirmed") {
16633
17420
  const { executor, dvns } = await this.getWorkers(connection, sender, dstEid, commitment);
16634
17421
  const priceFeeds = new Array();
@@ -16639,7 +17426,7 @@ var Uln = class {
16639
17426
  });
16640
17427
  const priceFeedInfos = await connection.getMultipleAccountsInfo(priceFeeds, commitment);
16641
17428
  const priceFeedDict = priceFeedInfos.reduce((acc, info, i) => {
16642
- invariant4(info, `priceFeed:${priceFeeds[i].toBase58()} not initialized`);
17429
+ invariant3(info, `priceFeed:${priceFeeds[i].toBase58()} not initialized`);
16643
17430
  acc.set(priceFeeds[i].toBase58(), info.owner);
16644
17431
  return acc;
16645
17432
  }, /* @__PURE__ */ new Map());
@@ -16659,9 +17446,15 @@ var Uln = class {
16659
17446
  });
16660
17447
  return executorAccounts.concat(dvnAccounts.flat());
16661
17448
  }
16662
- /***
16663
- * Get all workers(executor&DVN)
17449
+ /**
17450
+ * Gets all workers (executor and DVN).
16664
17451
  * 2 RPC requests
17452
+ *
17453
+ * @param {Connection} connection - The connection to the Solana cluster.
17454
+ * @param {PublicKey} sender - The sender public key.
17455
+ * @param {number} eid - The endpoint ID.
17456
+ * @param {Commitment | GetAccountInfoConfig} [commitment='confirmed'] - The commitment level or account info configuration.
17457
+ * @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.
16665
17458
  */
16666
17459
  async getWorkers(connection, sender, eid, commitment = "confirmed") {
16667
17460
  const [defaultSendConfig] = this.deriver.defaultSendConfig(eid);
@@ -16670,7 +17463,7 @@ var Uln = class {
16670
17463
  [defaultSendConfig, sendConfig],
16671
17464
  commitment
16672
17465
  );
16673
- invariant4(defaultSendConfigBuf, "defaultSendConfig not initialized");
17466
+ invariant3(defaultSendConfigBuf, "defaultSendConfig not initialized");
16674
17467
  const [defaultSendConfigState] = SendConfig.fromAccountInfo(defaultSendConfigBuf);
16675
17468
  let {
16676
17469
  executor,
@@ -16695,14 +17488,14 @@ var Uln = class {
16695
17488
  [executor.executor, ...dvns],
16696
17489
  commitment
16697
17490
  );
16698
- invariant4(executorBuf, `executor:${executor.executor.toBase58()} not initialized`);
17491
+ invariant3(executorBuf, `executor:${executor.executor.toBase58()} not initialized`);
16699
17492
  return {
16700
17493
  executor: {
16701
17494
  config: accounts_exports4.ExecutorConfig.fromAccountInfo(executorBuf)[0],
16702
17495
  owner: executorBuf.owner
16703
17496
  },
16704
17497
  dvns: dvnBuf.map((dvn, i) => {
16705
- invariant4(dvn, `dvn:${dvns[i].toBase58()} not initialized`);
17498
+ invariant3(dvn, `dvn:${dvns[i].toBase58()} not initialized`);
16706
17499
  return {
16707
17500
  config: accounts_exports3.DvnConfig.fromAccountInfo(dvn)[0],
16708
17501
  owner: dvn.owner
@@ -16710,6 +17503,16 @@ var Uln = class {
16710
17503
  })
16711
17504
  };
16712
17505
  }
17506
+ /**
17507
+ * Initializes the verification process.
17508
+ *
17509
+ * @param {Connection} connection - The connection to the Solana cluster.
17510
+ * @param {PublicKey} payer - The payer public key.
17511
+ * @param {PublicKey} dvn - The DVN public key.
17512
+ * @param {Uint8Array} packetBytes - The packet bytes.
17513
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
17514
+ * @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
17515
+ */
16713
17516
  async initVerify(connection, payer, dvn, packetBytes, commitmentOrConfig) {
16714
17517
  const packet = PacketV1Codec.fromBytes(packetBytes);
16715
17518
  const headerHash = packet.headerHash();
@@ -16736,6 +17539,14 @@ var Uln = class {
16736
17539
  this.program
16737
17540
  );
16738
17541
  }
17542
+ /**
17543
+ * Verifies the packet.
17544
+ *
17545
+ * @param {PublicKey} dvn - The DVN public key.
17546
+ * @param {Uint8Array} packetBytes - The packet bytes.
17547
+ * @param {number | string} confirmations - The number of confirmations.
17548
+ * @returns {TransactionInstruction} The transaction instruction.
17549
+ */
16739
17550
  verify(dvn, packetBytes, confirmations) {
16740
17551
  const packet = PacketV1Codec.fromBytes(packetBytes);
16741
17552
  const headerHash = packet.headerHash();
@@ -16760,6 +17571,14 @@ var Uln = class {
16760
17571
  this.program
16761
17572
  );
16762
17573
  }
17574
+ /**
17575
+ * Closes the verification process.
17576
+ *
17577
+ * @param {PublicKey} dvn - The DVN public key.
17578
+ * @param {PublicKey} receiver - The receiver public key.
17579
+ * @param {Uint8Array} packetBytes - The packet bytes.
17580
+ * @returns {TransactionInstruction} The transaction instruction.
17581
+ */
16763
17582
  closeVerify(dvn, receiver, packetBytes) {
16764
17583
  const packet = PacketV1Codec.fromBytes(packetBytes);
16765
17584
  const headerHash = packet.headerHash();
@@ -16782,6 +17601,16 @@ var Uln = class {
16782
17601
  this.program
16783
17602
  );
16784
17603
  }
17604
+ /**
17605
+ * Checks if the DVN is verified.
17606
+ *
17607
+ * @param {Connection} connection - The connection to the Solana cluster.
17608
+ * @param {PublicKey} endpointProgram - The endpoint program public key.
17609
+ * @param {PublicKey} dvn - The DVN public key.
17610
+ * @param {Uint8Array} packetBytes - The packet bytes.
17611
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig='confirmed'] - The commitment level or account info configuration.
17612
+ * @returns {Promise<boolean>} A promise that resolves to true if the DVN is verified, false otherwise.
17613
+ */
16785
17614
  async isDvnVerified(connection, endpointProgram, dvn, packetBytes, commitmentOrConfig = "confirmed") {
16786
17615
  const packet = PacketV1Codec.fromBytes(packetBytes);
16787
17616
  const headerHash = packet.headerHash();
@@ -16824,6 +17653,14 @@ var Uln = class {
16824
17653
  return false;
16825
17654
  }
16826
17655
  }
17656
+ /**
17657
+ * Commits the verification process.
17658
+ *
17659
+ * @param {Connection} connection - The connection to the Solana cluster.
17660
+ * @param {PublicKey} endpointProgram - The endpoint program public key.
17661
+ * @param {Uint8Array} packetBytes - The packet bytes.
17662
+ * @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
17663
+ */
16827
17664
  async commitVerification(connection, endpointProgram, packetBytes) {
16828
17665
  const packet = PacketV1Codec.fromBytes(packetBytes);
16829
17666
  const payloadHash = packet.payloadHash();
@@ -16863,8 +17700,13 @@ var Uln = class {
16863
17700
  this.program
16864
17701
  );
16865
17702
  }
16866
- /***
16867
- * Get the account meta of the send instruction for CPI(Cross-Program Invocation )
17703
+ /**
17704
+ * Gets the account metadata for the CPI (Cross-Program Invocation) of the init config instruction.
17705
+ *
17706
+ * @param {PublicKey} payer - The payer public key.
17707
+ * @param {PublicKey} oappID - The OApp ID public key.
17708
+ * @param {number} eid - The endpoint ID.
17709
+ * @returns {AccountMeta[]} An array of account metadata.
16868
17710
  */
16869
17711
  getInitConfigIXAccountMetaForCPI(payer, oappID, eid) {
16870
17712
  const [sendConfig] = this.deriver.sendConfig(eid, oappID);
@@ -16888,6 +17730,14 @@ var Uln = class {
16888
17730
  });
16889
17731
  return accounts.slice(1);
16890
17732
  }
17733
+ /**
17734
+ * Constructs the set config data.
17735
+ *
17736
+ * @param {SetConfigType} configType - The configuration type.
17737
+ * @param {types.ExecutorConfig | types.UlnConfig} configData - The configuration data.
17738
+ * @returns {Uint8Array} The constructed set config data.
17739
+ * @throws {Error} If the configuration type is invalid.
17740
+ */
16891
17741
  static constructSetConfigData(configType, configData) {
16892
17742
  switch (configType) {
16893
17743
  case 1 /* EXECUTOR */: {
@@ -16904,8 +17754,12 @@ var Uln = class {
16904
17754
  }
16905
17755
  }
16906
17756
  /**
16907
- * @param oappID the oApp PDA
17757
+ * Gets the account metadata for the CPI (Cross-Program Invocation) of the set config instruction.
16908
17758
  *
17759
+ * @param {PublicKey} endpointProgram - The endpoint program public key.
17760
+ * @param {PublicKey} oappID - The OApp ID public key.
17761
+ * @param {number} eid - The endpoint ID.
17762
+ * @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
16909
17763
  */
16910
17764
  async getSetConfigIXAccountMetaForCPI(endpointProgram, oappID, eid) {
16911
17765
  const [sendConfig] = this.deriver.sendConfig(eid, oappID);
@@ -16932,6 +17786,13 @@ var Uln = class {
16932
17786
  }
16933
17787
  //
16934
17788
  // all of below functions are retrieving accounts state
17789
+ /**
17790
+ * Gets the ULN settings.
17791
+ *
17792
+ * @param {Connection} connection - The connection to the Solana cluster.
17793
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
17794
+ * @returns {Promise<accounts.UlnSettings | null>} A promise that resolves to the ULN settings or null if not found.
17795
+ */
16935
17796
  async getSetting(connection, commitmentOrConfig) {
16936
17797
  const [setting] = this.deriver.setting();
16937
17798
  try {
@@ -16940,6 +17801,14 @@ var Uln = class {
16940
17801
  return null;
16941
17802
  }
16942
17803
  }
17804
+ /**
17805
+ * Gets the default send configuration state.
17806
+ *
17807
+ * @param {Connection} connection - The connection to the Solana cluster.
17808
+ * @param {number} eid - The endpoint ID.
17809
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
17810
+ * @returns {Promise<accounts.SendConfig | null>} A promise that resolves to the default send configuration state or null if not found.
17811
+ */
16943
17812
  async getDefaultSendConfigState(connection, eid, commitmentOrConfig) {
16944
17813
  const [config] = this.deriver.defaultSendConfig(eid);
16945
17814
  try {
@@ -16948,6 +17817,15 @@ var Uln = class {
16948
17817
  return null;
16949
17818
  }
16950
17819
  }
17820
+ /**
17821
+ * Gets the send configuration state.
17822
+ *
17823
+ * @param {Connection} connection - The connection to the Solana cluster.
17824
+ * @param {PublicKey} sender - The sender public key.
17825
+ * @param {number} eid - The endpoint ID.
17826
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
17827
+ * @returns {Promise<accounts.SendConfig | null>} A promise that resolves to the send configuration state or null if not found.
17828
+ */
16951
17829
  async getSendConfigState(connection, sender, eid, commitmentOrConfig) {
16952
17830
  const [config] = this.deriver.sendConfig(eid, sender);
16953
17831
  try {
@@ -16956,6 +17834,14 @@ var Uln = class {
16956
17834
  return null;
16957
17835
  }
16958
17836
  }
17837
+ /**
17838
+ * Gets the default receive configuration state.
17839
+ *
17840
+ * @param {Connection} connection - The connection to the Solana cluster.
17841
+ * @param {number} eid - The endpoint ID.
17842
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
17843
+ * @returns {Promise<accounts.ReceiveConfig | null>} A promise that resolves to the default receive configuration state or null if not found.
17844
+ */
16959
17845
  async getDefaultReceiveConfigState(connection, eid, commitmentOrConfig) {
16960
17846
  const [config] = this.deriver.defaultReceiveConfig(eid);
16961
17847
  try {
@@ -16964,6 +17850,15 @@ var Uln = class {
16964
17850
  return null;
16965
17851
  }
16966
17852
  }
17853
+ /**
17854
+ * Gets the receive configuration state.
17855
+ *
17856
+ * @param {Connection} connection - The connection to the Solana cluster.
17857
+ * @param {PublicKey} receiver - The receiver public key.
17858
+ * @param {number} eid - The endpoint ID.
17859
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
17860
+ * @returns {Promise<accounts.ReceiveConfig | null>} A promise that resolves to the receive configuration state or null if not found.
17861
+ */
16967
17862
  async getReceiveConfigState(connection, receiver, eid, commitmentOrConfig) {
16968
17863
  const [config] = this.deriver.receiveConfig(eid, receiver);
16969
17864
  try {
@@ -16972,6 +17867,16 @@ var Uln = class {
16972
17867
  return null;
16973
17868
  }
16974
17869
  }
17870
+ /**
17871
+ * Gets the final receive configuration state.
17872
+ *
17873
+ * @param {Connection} connection - The connection to the Solana cluster.
17874
+ * @param {PublicKey} receiver - The receiver public key.
17875
+ * @param {number} eid - The endpoint ID.
17876
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig='confirmed'] - The commitment level or account info configuration.
17877
+ * @returns {Promise<accounts.ReceiveConfig>} A promise that resolves to the final receive configuration state.
17878
+ * @throws {Error} If no DVN is found.
17879
+ */
16975
17880
  async getFinalReceiveConfigState(connection, receiver, eid, commitmentOrConfig = "confirmed") {
16976
17881
  const NIL_CONFIRMATIONS = "18446744073709551615";
16977
17882
  const NIL_DVN_COUNT = "255";
@@ -17803,10 +18708,26 @@ var PROGRAM_ID6 = new PublicKey(PROGRAM_ADDRESS6);
17803
18708
 
17804
18709
  // src/pricefeed.ts
17805
18710
  var PriceFeed2 = class {
18711
+ /**
18712
+ * Creates an instance of the PriceFeed class.
18713
+ *
18714
+ * @param {PublicKey} program - The public key of the program.
18715
+ */
17806
18716
  constructor(program) {
17807
18717
  this.program = program;
17808
18718
  this.deriver = new PriceFeedPDADeriver(this.program);
17809
18719
  }
18720
+ /**
18721
+ * Initializes the price feed.
18722
+ *
18723
+ * @param {Connection} connection - The Solana connection object.
18724
+ * @param {PublicKey} payer - The public key of the payer.
18725
+ * @param {PublicKey} admin - The public key of the admin.
18726
+ * @param {PublicKey[]} updaters - The list of public keys of the updaters.
18727
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - Optional commitment or configuration.
18728
+ *
18729
+ * @returns {Promise<TransactionInstruction>} The transaction instruction.
18730
+ */
17810
18731
  async initPriceFeed(connection, payer, admin, updaters, commitmentOrConfig) {
17811
18732
  const [priceFeed] = this.deriver.priceFeed();
17812
18733
  const info = await connection.getAccountInfo(priceFeed, commitmentOrConfig);
@@ -17827,6 +18748,16 @@ var PriceFeed2 = class {
17827
18748
  this.program
17828
18749
  );
17829
18750
  }
18751
+ /**
18752
+ * Sets the price feed.
18753
+ *
18754
+ * @param {PublicKey} admin - The public key of the admin.
18755
+ * @param {PublicKey[]} updaters - The list of public keys of the updaters.
18756
+ * @param {bignum} priceRatioDenominator - The price ratio denominator.
18757
+ * @param {number} arbitrumCompressionPercent - The Arbitrum compression percentage.
18758
+ *
18759
+ * @returns {TransactionInstruction} The transaction instruction.
18760
+ */
17830
18761
  setPriceFeed(admin, updaters, priceRatioDenominator, arbitrumCompressionPercent) {
17831
18762
  const [priceFeed] = this.deriver.priceFeed();
17832
18763
  return createSetPriceFeedInstruction(
@@ -17844,6 +18775,18 @@ var PriceFeed2 = class {
17844
18775
  this.program
17845
18776
  );
17846
18777
  }
18778
+ /**
18779
+ * Sets the price.
18780
+ *
18781
+ * @param {PublicKey} updater - The public key of the updater.
18782
+ * @param {number} dstEid - The destination EID.
18783
+ * @param {bignum} priceRatio - The price ratio.
18784
+ * @param {bignum} gasPriceInUnit - The gas price in unit.
18785
+ * @param {number} gasPerByte - The gas per byte.
18786
+ * @param {types.ModelType | null} modelType - The model type.
18787
+ *
18788
+ * @returns {TransactionInstruction} The transaction instruction.
18789
+ */
17847
18790
  setPrice(updater, dstEid, priceRatio, gasPriceInUnit, gasPerByte, modelType) {
17848
18791
  const EID_MODULUS = 3e4;
17849
18792
  dstEid = dstEid % EID_MODULUS;
@@ -17867,6 +18810,14 @@ var PriceFeed2 = class {
17867
18810
  this.program
17868
18811
  );
17869
18812
  }
18813
+ /**
18814
+ * Sets the SOL price.
18815
+ *
18816
+ * @param {PublicKey} updater - The public key of the updater.
18817
+ * @param {bignum | null} nativeTokenPriceUsd - The native token price in USD.
18818
+ *
18819
+ * @returns {TransactionInstruction} The transaction instruction.
18820
+ */
17870
18821
  setSolPrice(updater, nativeTokenPriceUsd) {
17871
18822
  const [priceFeed] = this.deriver.priceFeed();
17872
18823
  return createSetSolPriceInstruction(
@@ -17882,6 +18833,14 @@ var PriceFeed2 = class {
17882
18833
  this.program
17883
18834
  );
17884
18835
  }
18836
+ /**
18837
+ * Transfers the admin role.
18838
+ *
18839
+ * @param {PublicKey} admin - The public key of the current admin.
18840
+ * @param {PublicKey} newAdmin - The public key of the new admin.
18841
+ *
18842
+ * @returns {TransactionInstruction} The transaction instruction.
18843
+ */
17885
18844
  transferAdmin(admin, newAdmin) {
17886
18845
  const [priceFeed] = this.deriver.priceFeed();
17887
18846
  return createTransferAdminInstruction4(
@@ -17897,6 +18856,14 @@ var PriceFeed2 = class {
17897
18856
  this.program
17898
18857
  );
17899
18858
  }
18859
+ /**
18860
+ * Retrieves the price feed account.
18861
+ *
18862
+ * @param {Connection} connection - The Solana connection object.
18863
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - Optional commitment or configuration.
18864
+ *
18865
+ * @returns {Promise<accounts.PriceFeed | null>} The price feed account or null if not found.
18866
+ */
17900
18867
  async getPriceFeed(connection, commitmentOrConfig) {
17901
18868
  const [priceFeed] = this.deriver.priceFeed();
17902
18869
  try {
@@ -17929,19 +18896,52 @@ function deriveLzComposeTypesAccountsPDA(program, oappId) {
17929
18896
  return PublicKey.findProgramAddressSync([Buffer.from(LZ_COMPOSE_TYPES_SEED, "utf8")], program);
17930
18897
  }
17931
18898
  var BaseOApp = class {
18899
+ /**
18900
+ * Creates an instance of the BaseOApp class.
18901
+ *
18902
+ * @param {PublicKey} program - The program public key.
18903
+ */
17932
18904
  constructor(program) {
17933
18905
  this.program = program;
17934
18906
  this.oappBaseDeriver = new OAppBasePDADeriver(program);
17935
18907
  }
18908
+ /**
18909
+ * Queries the ID PDA info.
18910
+ *
18911
+ * @param {Connection} connection - The connection.
18912
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment or config.
18913
+ * @returns {Promise<AccountInfo<Buffer> | null>} The account info.
18914
+ */
17936
18915
  async queryIDPDAInfo(connection, commitmentOrConfig) {
17937
18916
  return this.queryPDAInfo(connection, this.idPDA()[0], commitmentOrConfig);
17938
18917
  }
18918
+ /**
18919
+ * Queries the PDA info.
18920
+ *
18921
+ * @param {Connection} connection - The connection.
18922
+ * @param {PublicKey} pda - The PDA public key.
18923
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment or config.
18924
+ * @returns {Promise<AccountInfo<Buffer> | null>} The account info.
18925
+ */
17939
18926
  async queryPDAInfo(connection, pda, commitmentOrConfig) {
17940
18927
  return connection.getAccountInfo(pda, commitmentOrConfig);
17941
18928
  }
18929
+ /**
18930
+ * Gets the ID PDA.
18931
+ *
18932
+ * @returns {[PublicKey, number]} The ID PDA and bump.
18933
+ */
17942
18934
  idPDA() {
17943
18935
  return oappIDPDA(this.program);
17944
18936
  }
18937
+ /**
18938
+ * Gets the remote.
18939
+ *
18940
+ * @param {Connection} connection - The connection.
18941
+ * @param {number} dstEid - The destination endpoint ID.
18942
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment or config.
18943
+ * @returns {Promise<Uint8Array | null>} The remote data.
18944
+ */
17945
18945
  async getRemote(connection, dstEid, commitmentOrConfig) {
17946
18946
  const [remotePDA] = this.oappBaseDeriver.remote(dstEid);
17947
18947
  const info = await this.queryPDAInfo(connection, remotePDA, commitmentOrConfig);
@@ -18043,6 +19043,13 @@ function createVersionInstructionAccounts3(programId) {
18043
19043
  var PROGRAM_ADDRESS7 = "2XrYqmhBMPJgDsb4SVbjV1PnJBprurd5bzRCkHwiFCJB";
18044
19044
  var PROGRAM_ID7 = new PublicKey(PROGRAM_ADDRESS7);
18045
19045
  var SendHelper = class {
19046
+ /**
19047
+ * Creates an instance of the SendHelper class.
19048
+ *
19049
+ * @param {PublicKey} [endpointProgram=EndpointProgram.PROGRAM_ID] - The endpoint program public key.
19050
+ * @param {PublicKey} [ulnProgram=UlnProgram.PROGRAM_ID] - The ULN program public key.
19051
+ * @param {PublicKey} [simpleMsgLibProgram=SimpleMessageLibProgram.PROGRAM_ID] - The simple message library program public key.
19052
+ */
18046
19053
  constructor(endpointProgram = endpoint_exports.PROGRAM_ID, ulnProgram = uln_exports.PROGRAM_ID, simpleMsgLibProgram = simple_message_lib_exports.PROGRAM_ID) {
18047
19054
  this.endpointProgram = endpointProgram;
18048
19055
  this.ulnProgram = ulnProgram;
@@ -18052,6 +19059,14 @@ var SendHelper = class {
18052
19059
  this.uln = new uln_exports.Uln(ulnProgram);
18053
19060
  this.simpleMsgLib = new simple_message_lib_exports.SimpleMessageLib(simpleMsgLibProgram);
18054
19061
  }
19062
+ /**
19063
+ * Fetches multiple account information.
19064
+ *
19065
+ * @param {Connection} connection - The connection to the Solana cluster.
19066
+ * @param {PublicKey[]} keys - The public keys of the accounts.
19067
+ * @param {Commitment | GetAccountInfoConfig} [commitment] - The commitment level or account info configuration.
19068
+ * @returns {Promise<(AccountInfo<Buffer> | null)[]>} A promise that resolves to an array of account information.
19069
+ */
18055
19070
  async getMultipleAccountsInfo(connection, keys, commitment) {
18056
19071
  const missingKeys = keys.filter((key) => !this.accounts.has(key.toBase58()));
18057
19072
  if (missingKeys.length > 0) {
@@ -18062,6 +19077,17 @@ var SendHelper = class {
18062
19077
  }
18063
19078
  return keys.map((key) => this.accounts.get(key.toBase58()));
18064
19079
  }
19080
+ /**
19081
+ * Gets the account metadata for the quote instruction.
19082
+ *
19083
+ * @param {Connection} connection - The connection to the Solana cluster.
19084
+ * @param {PublicKey} payer - The payer public key.
19085
+ * @param {PublicKey} sender - The sender public key.
19086
+ * @param {number} dstEid - The destination endpoint ID.
19087
+ * @param {string} receiver - The receiver address.
19088
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig='confirmed'] - The commitment level or account info configuration.
19089
+ * @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
19090
+ */
18065
19091
  async getQuoteAccounts(connection, payer, sender, dstEid, receiver, commitmentOrConfig = "confirmed") {
18066
19092
  const [sendLibConfig] = this.endpoint.deriver.sendLibraryConfig(sender, dstEid);
18067
19093
  const [defaultSendLibConfig] = this.endpoint.deriver.defaultSendLibraryConfig(dstEid);
@@ -18081,7 +19107,7 @@ var SendHelper = class {
18081
19107
  [sendLibConfig, defaultSendLibConfig, simpleMsgLib, uln, ulnDefaultSendConfig, ulnSendConfig],
18082
19108
  commitmentOrConfig
18083
19109
  );
18084
- invariant4(defaultSendLibConfigBuf && sendLibConfigBuf, "endpoint send library not initialized");
19110
+ invariant3(defaultSendLibConfigBuf && sendLibConfigBuf, "endpoint send library not initialized");
18085
19111
  const [sendLibConfigInfo] = endpoint_exports.accounts.SendLibraryConfig.fromAccountInfo(sendLibConfigBuf, 0);
18086
19112
  const [defaultSendLibConfigInfo] = endpoint_exports.accounts.SendLibraryConfig.fromAccountInfo(
18087
19113
  defaultSendLibConfigBuf,
@@ -18120,14 +19146,16 @@ var SendHelper = class {
18120
19146
  );
18121
19147
  }
18122
19148
  /**
18123
- * @param connection
18124
- * @param payer
18125
- * @param sender the PDA of the oApp
18126
- * @param dstEid the destination endpoint id
18127
- * @param receiver the remote peer's address
18128
- * @param commitmentOrConfig
18129
- * 1 or 3(1+2) RPC calls
18130
- * */
19149
+ * Gets the account metadata for the send instruction.
19150
+ *
19151
+ * @param {Connection} connection - The connection to the Solana cluster.
19152
+ * @param {PublicKey} payer - The payer public key.
19153
+ * @param {PublicKey} sender - The sender public key.
19154
+ * @param {number} dstEid - The destination endpoint ID.
19155
+ * @param {string} receiver - The receiver address.
19156
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig='confirmed'] - The commitment level or account info configuration.
19157
+ * @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
19158
+ */
18131
19159
  async getSendAccounts(connection, payer, sender, dstEid, receiver, commitmentOrConfig = "confirmed") {
18132
19160
  const [sendLibConfig] = this.endpoint.deriver.sendLibraryConfig(sender, dstEid);
18133
19161
  const [defaultSendLibConfig] = this.endpoint.deriver.defaultSendLibraryConfig(dstEid);
@@ -18147,7 +19175,7 @@ var SendHelper = class {
18147
19175
  [sendLibConfig, defaultSendLibConfig, simpleMsgLib, uln, ulnDefaultSendConfig, ulnSendConfig],
18148
19176
  commitmentOrConfig
18149
19177
  );
18150
- invariant4(defaultSendLibConfigBuf && sendLibConfigBuf, "endpoint send library not initialized");
19178
+ invariant3(defaultSendLibConfigBuf && sendLibConfigBuf, "endpoint send library not initialized");
18151
19179
  const [sendLibConfigInfo] = endpoint_exports.accounts.SendLibraryConfig.fromAccountInfo(sendLibConfigBuf, 0);
18152
19180
  const [defaultSendLibConfigInfo] = endpoint_exports.accounts.SendLibraryConfig.fromAccountInfo(
18153
19181
  defaultSendLibConfigBuf,
@@ -18185,6 +19213,17 @@ var SendHelper = class {
18185
19213
  )
18186
19214
  );
18187
19215
  }
19216
+ /**
19217
+ * Gets the account metadata for the endpoint.
19218
+ *
19219
+ * @param {PublicKey} msgLibProgram - The message library program public key.
19220
+ * @param {PublicKey} msgLib - The message library public key.
19221
+ * @param {PublicKey} sender - The sender public key.
19222
+ * @param {number} dstEid - The destination endpoint ID.
19223
+ * @param {string} receiver - The receiver address.
19224
+ * @param {QuoteOrSend} quoteOrSend - The quote or send action.
19225
+ * @returns {AccountMeta[]} An array of account metadata.
19226
+ */
18188
19227
  getEndpointAccounts(msgLibProgram, msgLib, sender, dstEid, receiver, quoteOrSend) {
18189
19228
  const [sendLibraryConfig] = this.endpoint.deriver.sendLibraryConfig(sender, dstEid);
18190
19229
  const [defaultSendLibraryConfig] = this.endpoint.deriver.defaultSendLibraryConfig(dstEid);
@@ -18231,6 +19270,13 @@ var SendHelper = class {
18231
19270
  }
18232
19271
  ].concat(accounts);
18233
19272
  }
19273
+ /**
19274
+ * Gets the account metadata for the simple message library.
19275
+ *
19276
+ * @param {PublicKey} payer - The payer public key.
19277
+ * @param {QuoteOrSend} quoteOrSend - The quote or send action.
19278
+ * @returns {AccountMeta[]} An array of account metadata.
19279
+ */
18234
19280
  getSimpleMsgLibAccounts(payer, quoteOrSend) {
18235
19281
  const [msgLib] = this.simpleMsgLib.deriver.messageLib();
18236
19282
  let accounts;
@@ -18261,9 +19307,20 @@ var SendHelper = class {
18261
19307
  });
18262
19308
  return accounts.slice(1);
18263
19309
  }
18264
- // 2 RPC calls
19310
+ /**
19311
+ * Gets the account metadata for the ULN.
19312
+ *
19313
+ * @param {Connection} connection - The connection to the Solana cluster.
19314
+ * @param {PublicKey} payer - The payer public key.
19315
+ * @param {KeyedAccountInfo} ulnInfo - The ULN account information.
19316
+ * @param {KeyedAccountInfo} ulnDefaultSendConfigInfo - The ULN default send configuration account information.
19317
+ * @param {KeyedAccountInfo} ulnSendConfigInfo - The ULN send configuration account information.
19318
+ * @param {QuoteOrSend} quoteOrSend - The quote or send action.
19319
+ * @param {Commitment | GetAccountInfoConfig} [commitment] - The commitment level or account info configuration.
19320
+ * @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
19321
+ */
18265
19322
  async getUlnAccounts(connection, payer, ulnInfo, ulnDefaultSendConfigInfo, ulnSendConfigInfo, quoteOrSend, commitment) {
18266
- invariant4(ulnInfo.accountInfo && ulnDefaultSendConfigInfo.accountInfo, "uln send library not initialized");
19323
+ invariant3(ulnInfo.accountInfo && ulnDefaultSendConfigInfo.accountInfo, "uln send library not initialized");
18267
19324
  const [ulnState] = uln_exports.accounts.UlnSettings.fromAccountInfo(ulnInfo.accountInfo, 0);
18268
19325
  const [defaultSendConfigState] = uln_exports.accounts.SendConfig.fromAccountInfo(
18269
19326
  ulnDefaultSendConfigInfo.accountInfo,
@@ -18293,7 +19350,7 @@ var SendHelper = class {
18293
19350
  [executor.executor, ...dvnsKey],
18294
19351
  commitment
18295
19352
  );
18296
- invariant4(executorBuf, `executor:${executor.executor.toBase58()} not initialized`);
19353
+ invariant3(executorBuf, `executor:${executor.executor.toBase58()} not initialized`);
18297
19354
  let executorAccounts, dvnAccounts;
18298
19355
  {
18299
19356
  const executor2 = {
@@ -18301,7 +19358,7 @@ var SendHelper = class {
18301
19358
  owner: executorBuf.owner
18302
19359
  };
18303
19360
  const dvns = dvnBuf.map((dvn, i) => {
18304
- invariant4(dvn, `dvn:${dvnsKey[i].toBase58()} not initialized`);
19361
+ invariant3(dvn, `dvn:${dvnsKey[i].toBase58()} not initialized`);
18305
19362
  return {
18306
19363
  config: accounts_exports3.DvnConfig.fromAccountInfo(dvn)[0],
18307
19364
  owner: dvn.owner
@@ -18313,7 +19370,7 @@ var SendHelper = class {
18313
19370
  });
18314
19371
  const priceFeedInfos = await this.getMultipleAccountsInfo(connection, priceFeeds, commitment);
18315
19372
  priceFeedInfos.forEach((info, i) => {
18316
- invariant4(info, `priceFeed:${priceFeeds[i].toBase58()} not initialized`);
19373
+ invariant3(info, `priceFeed:${priceFeeds[i].toBase58()} not initialized`);
18317
19374
  });
18318
19375
  executorAccounts = new Executor(executor2.owner).getQuoteIXAccountMetaForCPI(
18319
19376
  executor2.config.priceFeed,
@@ -19911,6 +20968,9 @@ var types = [
19911
20968
 
19912
20969
  // src/index.ts
19913
20970
  var IdlTypes = {
20971
+ /**
20972
+ * The endpoint types.
20973
+ */
19914
20974
  endpoint: types
19915
20975
  };
19916
20976
  var SetConfigType2 = /* @__PURE__ */ ((SetConfigType3) => {
@@ -19921,5 +20981,5 @@ var SetConfigType2 = /* @__PURE__ */ ((SetConfigType3) => {
19921
20981
  })(SetConfigType2 || {});
19922
20982
 
19923
20983
  export { AddressType, BaseOApp, blocked_messagelib_exports as BlockedMessageLibProgram, COMPOSED_MESSAGE_HASH_SEED, CONFIRMATIONS_SEED, COUNT_SEED, DVNDeriver, dvn_exports2 as DVNProgram, DVN_CONFIG_SEED, dvn_exports as DvnProgram, ENDPOINT_SEED, ENFORCED_OPTIONS_SEED, EVENT_SEED, EXECUTOR_CONFIG_SEED, EndpointPDADeriver, endpoint_exports as EndpointProgram, EventPDADeriver, ExecutorOptionType, ExecutorPDADeriver, executor_exports as ExecutorProgram, FAUCET_URL, IdlTypes, LZ_COMPOSE_TYPES_SEED, LZ_RECEIVE_TYPES_SEED, LzComposeParamsBeet, LzReceiveAccountBeet, LzReceiveParamsBeet, MESSAGE_LIB_SEED, MINT_SEED, MSG_TYPE_OFFSET, MaxExecutorOptionTypeLength, MessageLibPDADeriver, MessageType, NONCE_SEED, OAPP_SEED, OAppBasePDADeriver, OPTIONS_SEED, PAYLOAD_HASH_SEED, PEER_SEED, PENDING_NONCE_SEED, PRICE_FEED_SEED, PriceFeedPDADeriver, pricefeed_exports as PriceFeedProgram, RECEIVE_CONFIG_SEED, RECEIVE_LIBRARY_CONFIG_SEED, REMOTE_SEED, SEND_CONFIG_SEED, SEND_LIBRARY_CONFIG_SEED, SendHelper, SetConfigType2 as SetConfigType, simple_message_lib_exports as SimpleMessageLibProgram, ULN_CONFIG_SEED, ULN_SEED, UlnPDADeriver, uln_exports as UlnProgram, WORKER_SEED, buildMessageV0, buildVersionedTransaction, closeLookupTable, createNonceAccountTX, deactivateLookupTable, deriveLzComposeTypesAccountsPDA, deriveLzReceiveTypesAccountsPDA, extractComposeDeliveredEventByTxHash, extractComposeSentEventByTxHash, extractEventFromTransactionSignature, extractReceivedPacketEventByTxHash, extractSentPacketEventByTxHash, extractVerifiedPacketEventByTxHash, extractWorkerFeePaidEventByTxHash, generateAddressLookupTable, getBlockedMessageLibProgramId, getDVNProgramId, getEndpointProgramId, getExecutorProgramId, getLzComposeAccountMeta, getLzReceiveAccounts, getPricefeedProgramId, getProgramKeypair, getSimpleMessageLibProgramId, getULNProgramId, idlTypes, instructionDiscriminator, isAccountInitialized, lzCompose, lzReceive, messageLibs, oappIDPDA, simulateTransaction, txWithAddressLookupTable, txWithNonce };
19924
- //# sourceMappingURL=out.js.map
20984
+ //# sourceMappingURL=index.mjs.map
19925
20985
  //# sourceMappingURL=index.mjs.map