@layerzerolabs/lz-solana-sdk-v2 2.3.7 → 2.3.8

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.d.mts CHANGED
@@ -4,7 +4,7 @@ import { PacketPath, PacketV1Codec, Packet as Packet$2 } from '@layerzerolabs/lz
4
4
  import * as beet from '@metaplex-foundation/beet';
5
5
  import { bignum, FixableBeetArgsStruct, BeetArgsStruct } from '@metaplex-foundation/beet';
6
6
  import * as beetSolana from '@metaplex-foundation/beet-solana';
7
- import { SolanaSigner } from '@layerzerolabs/lz-corekit';
7
+ import { SolanaSigner } from '@layerzerolabs/lz-corekit-solana';
8
8
  import { EndpointId, Environment, Network } from '@layerzerolabs/lz-definitions';
9
9
  import { web3 as web3$1 } from '@coral-xyz/anchor';
10
10
  import { ProcessEnvOptions } from 'child_process';
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { PacketPath, PacketV1Codec, Packet as Packet$2 } from '@layerzerolabs/lz
4
4
  import * as beet from '@metaplex-foundation/beet';
5
5
  import { bignum, FixableBeetArgsStruct, BeetArgsStruct } from '@metaplex-foundation/beet';
6
6
  import * as beetSolana from '@metaplex-foundation/beet-solana';
7
- import { SolanaSigner } from '@layerzerolabs/lz-corekit';
7
+ import { SolanaSigner } from '@layerzerolabs/lz-corekit-solana';
8
8
  import { EndpointId, Environment, Network } from '@layerzerolabs/lz-definitions';
9
9
  import { web3 as web3$1 } from '@coral-xyz/anchor';
10
10
  import { ProcessEnvOptions } from 'child_process';
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
- import { BN } from '@coral-xyz/anchor';
2
1
  import * as web314 from '@solana/web3.js';
3
2
  import { PublicKey, Keypair, AddressLookupTableProgram, VersionedTransaction, TransactionMessage, NONCE_ACCOUNT_LENGTH, Transaction, SystemProgram, NonceAccount, TransactionInstruction } from '@solana/web3.js';
3
+ import BN2 from 'bn.js';
4
+ import { BN } from '@coral-xyz/anchor';
4
5
  import * as beet34 from '@metaplex-foundation/beet';
5
6
  import { uniformFixedSizeArray, u8, FixableBeetArgsStruct, u32, u64, bytes, u16, BeetArgsStruct, bool, array } from '@metaplex-foundation/beet';
6
7
  import * as beetSolana64 from '@metaplex-foundation/beet-solana';
@@ -159,7 +160,7 @@ var EndpointPDADeriver = class {
159
160
  [
160
161
  Buffer.from(SEND_LIBRARY_CONFIG_SEED, "utf8"),
161
162
  // U32 to Uint8Array([0,0,0,0])
162
- new BN(dstEndpointId).toArrayLike(Buffer, "be", 4)
163
+ new BN2(dstEndpointId).toArrayLike(Buffer, "be", 4)
163
164
  ],
164
165
  this.program
165
166
  );
@@ -170,7 +171,7 @@ var EndpointPDADeriver = class {
170
171
  Buffer.from(SEND_LIBRARY_CONFIG_SEED, "utf8"),
171
172
  sender.toBytes(),
172
173
  // U32 to Uint8Array([0,0,0,0])
173
- new BN(dstEndpointId).toArrayLike(Buffer, "be", 4)
174
+ new BN2(dstEndpointId).toArrayLike(Buffer, "be", 4)
174
175
  ],
175
176
  this.program
176
177
  );
@@ -189,7 +190,7 @@ var EndpointPDADeriver = class {
189
190
  [
190
191
  Buffer.from(RECEIVE_LIBRARY_CONFIG_SEED, "utf8"),
191
192
  // U32 to Uint8Array([0,0,0,0])
192
- new BN(srcEndpointId).toArrayLike(Buffer, "be", 4)
193
+ new BN2(srcEndpointId).toArrayLike(Buffer, "be", 4)
193
194
  ],
194
195
  this.program
195
196
  );
@@ -200,7 +201,7 @@ var EndpointPDADeriver = class {
200
201
  Buffer.from(RECEIVE_LIBRARY_CONFIG_SEED, "utf8"),
201
202
  receiver.toBytes(),
202
203
  // U32 to Uint8Array([0,0,0,0])
203
- new BN(srcEndpointId).toArrayLike(Buffer, "be", 4)
204
+ new BN2(srcEndpointId).toArrayLike(Buffer, "be", 4)
204
205
  ],
205
206
  this.program
206
207
  );
@@ -226,7 +227,7 @@ var EndpointPDADeriver = class {
226
227
  Buffer.from(NONCE_SEED, "utf8"),
227
228
  localOapp.toBytes(),
228
229
  // U32 to Uint8Array([0,0,0,0])
229
- new BN(remoteChainId).toArrayLike(Buffer, "be", 4),
230
+ new BN2(remoteChainId).toArrayLike(Buffer, "be", 4),
230
231
  remoteOapp
231
232
  ],
232
233
  this.program
@@ -251,9 +252,9 @@ var EndpointPDADeriver = class {
251
252
  [
252
253
  Buffer.from(PAYLOAD_HASH_SEED, "utf8"),
253
254
  receiver.toBytes(),
254
- new BN(srcEid).toArrayLike(Buffer, "be", 4),
255
+ new BN2(srcEid).toArrayLike(Buffer, "be", 4),
255
256
  sender,
256
- new BN(nonce).toArrayLike(Buffer, "be", 8)
257
+ new BN2(nonce).toArrayLike(Buffer, "be", 8)
257
258
  ],
258
259
  this.program
259
260
  );
@@ -265,7 +266,7 @@ var EndpointPDADeriver = class {
265
266
  from.toBytes(),
266
267
  to.toBytes(),
267
268
  guid,
268
- new BN(index).toArrayLike(Buffer, "be", 2),
269
+ new BN2(index).toArrayLike(Buffer, "be", 2),
269
270
  messageHash
270
271
  ],
271
272
  this.program
@@ -281,13 +282,13 @@ var MessageLibPDADeriver = class {
281
282
  }
282
283
  sendConfig(eid, oapp) {
283
284
  return PublicKey.findProgramAddressSync(
284
- [Buffer.from(SEND_CONFIG_SEED, "utf8"), new BN(eid).toArrayLike(Buffer, "be", 4), oapp.toBuffer()],
285
+ [Buffer.from(SEND_CONFIG_SEED, "utf8"), new BN2(eid).toArrayLike(Buffer, "be", 4), oapp.toBuffer()],
285
286
  this.program
286
287
  );
287
288
  }
288
289
  receiveConfig(eid, oapp) {
289
290
  return PublicKey.findProgramAddressSync(
290
- [Buffer.from(RECEIVE_CONFIG_SEED, "utf8"), new BN(eid).toArrayLike(Buffer, "be", 4), oapp.toBuffer()],
291
+ [Buffer.from(RECEIVE_CONFIG_SEED, "utf8"), new BN2(eid).toArrayLike(Buffer, "be", 4), oapp.toBuffer()],
291
292
  this.program
292
293
  );
293
294
  }
@@ -301,25 +302,25 @@ var UlnPDADeriver = class extends MessageLibPDADeriver {
301
302
  }
302
303
  config(eid) {
303
304
  return PublicKey.findProgramAddressSync(
304
- [Buffer.from(ULN_CONFIG_SEED, "utf8"), new BN(eid).toArrayLike(Buffer, "be", 4)],
305
+ [Buffer.from(ULN_CONFIG_SEED, "utf8"), new BN2(eid).toArrayLike(Buffer, "be", 4)],
305
306
  this.program
306
307
  );
307
308
  }
308
309
  defaultSendConfig(eid) {
309
310
  return PublicKey.findProgramAddressSync(
310
- [Buffer.from(SEND_CONFIG_SEED, "utf8"), new BN(eid).toArrayLike(Buffer, "be", 4)],
311
+ [Buffer.from(SEND_CONFIG_SEED, "utf8"), new BN2(eid).toArrayLike(Buffer, "be", 4)],
311
312
  this.program
312
313
  );
313
314
  }
314
315
  defaultReceiveConfig(eid) {
315
316
  return PublicKey.findProgramAddressSync(
316
- [Buffer.from(RECEIVE_CONFIG_SEED, "utf8"), new BN(eid).toArrayLike(Buffer, "be", 4)],
317
+ [Buffer.from(RECEIVE_CONFIG_SEED, "utf8"), new BN2(eid).toArrayLike(Buffer, "be", 4)],
317
318
  this.program
318
319
  );
319
320
  }
320
321
  options(eit) {
321
322
  return PublicKey.findProgramAddressSync(
322
- [Buffer.from(OPTIONS_SEED, "utf8"), new BN(eit).toArrayLike(Buffer, "be", 4)],
323
+ [Buffer.from(OPTIONS_SEED, "utf8"), new BN2(eit).toArrayLike(Buffer, "be", 4)],
323
324
  this.program
324
325
  );
325
326
  }
@@ -339,7 +340,7 @@ var OAppBasePDADeriver = class {
339
340
  }
340
341
  remote(dstChainId) {
341
342
  return PublicKey.findProgramAddressSync(
342
- [Buffer.from(REMOTE_SEED), new BN(dstChainId).toArrayLike(Buffer, "be", 4)],
343
+ [Buffer.from(REMOTE_SEED), new BN2(dstChainId).toArrayLike(Buffer, "be", 4)],
343
344
  this.program
344
345
  );
345
346
  }
@@ -360,7 +361,7 @@ var OmniCounterPDADeriver = class extends OAppBasePDADeriver {
360
361
  }
361
362
  remote(dstChainId) {
362
363
  return PublicKey.findProgramAddressSync(
363
- [Buffer.from(REMOTE_SEED), this.count()[0].toBytes(), new BN(dstChainId).toArrayLike(Buffer, "be", 4)],
364
+ [Buffer.from(REMOTE_SEED), this.count()[0].toBytes(), new BN2(dstChainId).toArrayLike(Buffer, "be", 4)],
364
365
  this.program
365
366
  );
366
367
  }
@@ -4584,7 +4585,7 @@ var Endpoint = class {
4584
4585
  const [receiveLibraryConfig] = this.endpointDeriver.receiveLibraryConfig(oappIDPDA2, srcEid);
4585
4586
  const [receiveLibraryInfo] = this.endpointDeriver.messageLibraryInfo(newReceiveLib);
4586
4587
  const [oappRegistry] = this.endpointDeriver.oappRegistry(oappIDPDA2);
4587
- return createSetReceiveLibraryInstruction(
4588
+ const retval = createSetReceiveLibraryInstruction(
4588
4589
  {
4589
4590
  signer: oappAdmin,
4590
4591
  receiveLibraryConfig,
@@ -4603,6 +4604,7 @@ var Endpoint = class {
4603
4604
  },
4604
4605
  this.program
4605
4606
  );
4607
+ return Promise.resolve(retval);
4606
4608
  }
4607
4609
  /// send a simulated transaction to the endpoint to get the fee for sending a message
4608
4610
  /***
@@ -6906,7 +6908,7 @@ var SimpleMessageLib = class {
6906
6908
  /***
6907
6909
  * Get the account meta of the send instruction for CPI(Cross-Program Invocation )
6908
6910
  */
6909
- getSendIXAccountMetaForCPI(_connection, payer, _path) {
6911
+ async getSendIXAccountMetaForCPI(_connection, payer, _path) {
6910
6912
  const [msgLib] = this.deriver.messageLib();
6911
6913
  const ix = createSendInstruction2(
6912
6914
  {
@@ -6940,7 +6942,7 @@ var SimpleMessageLib = class {
6940
6942
  });
6941
6943
  return Promise.resolve(ix.keys.slice(1));
6942
6944
  }
6943
- getQuoteIXAccountMetaForCPI(_connection, _payer, _path, _commitment) {
6945
+ async getQuoteIXAccountMetaForCPI(_connection, _payer, _path, _commitment) {
6944
6946
  const [msgLib] = this.deriver.messageLib();
6945
6947
  const ix = createQuoteInstruction2(
6946
6948
  {
@@ -8993,7 +8995,7 @@ var DVN = class {
8993
8995
  _getExpiration() {
8994
8996
  return (/* @__PURE__ */ new Date()).getTime() / 1e3 + 120;
8995
8997
  }
8996
- setMsgLibs(connection, payer, msgLibs, sign) {
8998
+ async setMsgLibs(connection, payer, msgLibs, sign) {
8997
8999
  const expiration = this._getExpiration();
8998
9000
  return this.invoke(connection, this.vid, payer, this.createSetMsgLibsInstruction(msgLibs), expiration, sign);
8999
9001
  }
@@ -9018,7 +9020,7 @@ var DVN = class {
9018
9020
  const priceFeedConfig = configState.priceFeed;
9019
9021
  const priceFeedConfigState = await connection.getAccountInfo(priceFeedConfig);
9020
9022
  if (!priceFeedConfigState) {
9021
- throw new Error(`Price feed config(${priceFeedConfig}) account not found`);
9023
+ throw new Error(`Price feed config(${priceFeedConfig.toString()}) account not found`);
9022
9024
  }
9023
9025
  const ix = createQuoteDvnInstruction(
9024
9026
  {
@@ -12313,7 +12315,7 @@ var Uln = class {
12313
12315
  commitment
12314
12316
  );
12315
12317
  const dvnAccounts = await Promise.all(
12316
- dvnPrograms.map((p) => new DVN(p).getQuoteIXAccountMetaForCPI(connection, false, commitment))
12318
+ dvnPrograms.map(async (p) => new DVN(p).getQuoteIXAccountMetaForCPI(connection, false, commitment))
12317
12319
  );
12318
12320
  const ix = createQuoteInstruction3(
12319
12321
  {
@@ -12362,7 +12364,7 @@ var Uln = class {
12362
12364
  commitment
12363
12365
  );
12364
12366
  const dvnAccounts = await Promise.all(
12365
- dvnPrograms.map((p) => new DVN(p).getQuoteIXAccountMetaForCPI(connection, true, commitment))
12367
+ dvnPrograms.map(async (p) => new DVN(p).getQuoteIXAccountMetaForCPI(connection, true, commitment))
12366
12368
  );
12367
12369
  const ix = createSendInstruction3(
12368
12370
  {
@@ -12401,7 +12403,7 @@ var Uln = class {
12401
12403
  }
12402
12404
  });
12403
12405
  if (treasury) {
12404
- const treasuryIndex = ix.keys.findIndex((k) => k.pubkey.toBase58() == treasury?.toBase58());
12406
+ const treasuryIndex = ix.keys.findIndex((k) => k.pubkey.toBase58() == treasury.toBase58());
12405
12407
  ix.keys[treasuryIndex].isWritable = true;
12406
12408
  }
12407
12409
  return ix.keys.slice(1);
@@ -12494,7 +12496,7 @@ var Uln = class {
12494
12496
  params: {
12495
12497
  packetHeader: Array.from(Uint8Array.from(Buffer.from(packet.header().slice(2), "hex"))),
12496
12498
  payloadHash: Array.from(payloadHashBytes),
12497
- confirmations: typeof confirmations === "string" ? new BN(confirmations) : confirmations
12499
+ confirmations: typeof confirmations === "string" ? new BN2(confirmations) : confirmations
12498
12500
  }
12499
12501
  },
12500
12502
  this.program
@@ -12528,7 +12530,7 @@ var Uln = class {
12528
12530
  }
12529
12531
  const headerHash = packet.headerHash();
12530
12532
  const headerHashBytes = Uint8Array.from(Buffer.from(headerHash.slice(2), "hex"));
12531
- const confirmations = receiveConfigState?.uln.requiredDvns.concat(receiveConfigState?.uln.optionalDvns).map((p) => {
12533
+ const confirmations = receiveConfigState.uln.requiredDvns.concat(receiveConfigState.uln.optionalDvns).map((p) => {
12532
12534
  const [confirmationsPDA] = this.deriver.confirmations(headerHashBytes, payloadHashBytes, p);
12533
12535
  return {
12534
12536
  pubkey: confirmationsPDA,
@@ -13569,7 +13571,7 @@ async function simulateTransaction(connection, instructions, programId, payer, c
13569
13571
  const simulateResp = await connection.simulateTransaction(tx, { sigVerify: false, commitment });
13570
13572
  const returnPrefix = `Program return: ${programId.toBase58()} `;
13571
13573
  const returnLog = simulateResp.value.logs?.find((l) => l.startsWith(returnPrefix));
13572
- if (!returnLog) {
13574
+ if (returnLog === void 0) {
13573
13575
  throw new Error(`Simulate Fail: ${JSON.stringify(simulateResp)}`);
13574
13576
  } else {
13575
13577
  return Buffer.from(returnLog.slice(returnPrefix.length), "base64");