@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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @layerzerolabs/lz-solana-sdk-v2
2
2
 
3
+ ## 2.3.8
4
+
5
+ ### Patch Changes
6
+
7
+ - e0f5d04: deploy contracts to Ebi mainnet
8
+ - Updated dependencies [e0f5d04]
9
+ - @layerzerolabs/lz-corekit-solana@2.3.8
10
+ - @layerzerolabs/lz-definitions@2.3.8
11
+ - @layerzerolabs/lz-utilities@2.3.8
12
+ - @layerzerolabs/lz-v2-utilities@2.3.8
13
+
3
14
  ## 2.3.7
4
15
 
5
16
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -1,7 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var anchor = require('@coral-xyz/anchor');
4
3
  var web314 = require('@solana/web3.js');
4
+ var BN2 = require('bn.js');
5
+ var anchor = require('@coral-xyz/anchor');
5
6
  var beet34 = require('@metaplex-foundation/beet');
6
7
  var beetSolana64 = require('@metaplex-foundation/beet-solana');
7
8
  var utils = require('ethers/lib/utils');
@@ -38,6 +39,7 @@ function _interopNamespace(e) {
38
39
  }
39
40
 
40
41
  var web314__namespace = /*#__PURE__*/_interopNamespace(web314);
42
+ var BN2__default = /*#__PURE__*/_interopDefault(BN2);
41
43
  var beet34__namespace = /*#__PURE__*/_interopNamespace(beet34);
42
44
  var beetSolana64__namespace = /*#__PURE__*/_interopNamespace(beetSolana64);
43
45
  var invariant__default = /*#__PURE__*/_interopDefault(invariant);
@@ -189,7 +191,7 @@ var EndpointPDADeriver = class {
189
191
  [
190
192
  Buffer.from(SEND_LIBRARY_CONFIG_SEED, "utf8"),
191
193
  // U32 to Uint8Array([0,0,0,0])
192
- new anchor.BN(dstEndpointId).toArrayLike(Buffer, "be", 4)
194
+ new BN2__default.default(dstEndpointId).toArrayLike(Buffer, "be", 4)
193
195
  ],
194
196
  this.program
195
197
  );
@@ -200,7 +202,7 @@ var EndpointPDADeriver = class {
200
202
  Buffer.from(SEND_LIBRARY_CONFIG_SEED, "utf8"),
201
203
  sender.toBytes(),
202
204
  // U32 to Uint8Array([0,0,0,0])
203
- new anchor.BN(dstEndpointId).toArrayLike(Buffer, "be", 4)
205
+ new BN2__default.default(dstEndpointId).toArrayLike(Buffer, "be", 4)
204
206
  ],
205
207
  this.program
206
208
  );
@@ -219,7 +221,7 @@ var EndpointPDADeriver = class {
219
221
  [
220
222
  Buffer.from(RECEIVE_LIBRARY_CONFIG_SEED, "utf8"),
221
223
  // U32 to Uint8Array([0,0,0,0])
222
- new anchor.BN(srcEndpointId).toArrayLike(Buffer, "be", 4)
224
+ new BN2__default.default(srcEndpointId).toArrayLike(Buffer, "be", 4)
223
225
  ],
224
226
  this.program
225
227
  );
@@ -230,7 +232,7 @@ var EndpointPDADeriver = class {
230
232
  Buffer.from(RECEIVE_LIBRARY_CONFIG_SEED, "utf8"),
231
233
  receiver.toBytes(),
232
234
  // U32 to Uint8Array([0,0,0,0])
233
- new anchor.BN(srcEndpointId).toArrayLike(Buffer, "be", 4)
235
+ new BN2__default.default(srcEndpointId).toArrayLike(Buffer, "be", 4)
234
236
  ],
235
237
  this.program
236
238
  );
@@ -256,7 +258,7 @@ var EndpointPDADeriver = class {
256
258
  Buffer.from(NONCE_SEED, "utf8"),
257
259
  localOapp.toBytes(),
258
260
  // U32 to Uint8Array([0,0,0,0])
259
- new anchor.BN(remoteChainId).toArrayLike(Buffer, "be", 4),
261
+ new BN2__default.default(remoteChainId).toArrayLike(Buffer, "be", 4),
260
262
  remoteOapp
261
263
  ],
262
264
  this.program
@@ -281,9 +283,9 @@ var EndpointPDADeriver = class {
281
283
  [
282
284
  Buffer.from(PAYLOAD_HASH_SEED, "utf8"),
283
285
  receiver.toBytes(),
284
- new anchor.BN(srcEid).toArrayLike(Buffer, "be", 4),
286
+ new BN2__default.default(srcEid).toArrayLike(Buffer, "be", 4),
285
287
  sender,
286
- new anchor.BN(nonce).toArrayLike(Buffer, "be", 8)
288
+ new BN2__default.default(nonce).toArrayLike(Buffer, "be", 8)
287
289
  ],
288
290
  this.program
289
291
  );
@@ -295,7 +297,7 @@ var EndpointPDADeriver = class {
295
297
  from.toBytes(),
296
298
  to.toBytes(),
297
299
  guid,
298
- new anchor.BN(index).toArrayLike(Buffer, "be", 2),
300
+ new BN2__default.default(index).toArrayLike(Buffer, "be", 2),
299
301
  messageHash
300
302
  ],
301
303
  this.program
@@ -311,13 +313,13 @@ var MessageLibPDADeriver = class {
311
313
  }
312
314
  sendConfig(eid, oapp) {
313
315
  return web314.PublicKey.findProgramAddressSync(
314
- [Buffer.from(SEND_CONFIG_SEED, "utf8"), new anchor.BN(eid).toArrayLike(Buffer, "be", 4), oapp.toBuffer()],
316
+ [Buffer.from(SEND_CONFIG_SEED, "utf8"), new BN2__default.default(eid).toArrayLike(Buffer, "be", 4), oapp.toBuffer()],
315
317
  this.program
316
318
  );
317
319
  }
318
320
  receiveConfig(eid, oapp) {
319
321
  return web314.PublicKey.findProgramAddressSync(
320
- [Buffer.from(RECEIVE_CONFIG_SEED, "utf8"), new anchor.BN(eid).toArrayLike(Buffer, "be", 4), oapp.toBuffer()],
322
+ [Buffer.from(RECEIVE_CONFIG_SEED, "utf8"), new BN2__default.default(eid).toArrayLike(Buffer, "be", 4), oapp.toBuffer()],
321
323
  this.program
322
324
  );
323
325
  }
@@ -331,25 +333,25 @@ var UlnPDADeriver = class extends MessageLibPDADeriver {
331
333
  }
332
334
  config(eid) {
333
335
  return web314.PublicKey.findProgramAddressSync(
334
- [Buffer.from(ULN_CONFIG_SEED, "utf8"), new anchor.BN(eid).toArrayLike(Buffer, "be", 4)],
336
+ [Buffer.from(ULN_CONFIG_SEED, "utf8"), new BN2__default.default(eid).toArrayLike(Buffer, "be", 4)],
335
337
  this.program
336
338
  );
337
339
  }
338
340
  defaultSendConfig(eid) {
339
341
  return web314.PublicKey.findProgramAddressSync(
340
- [Buffer.from(SEND_CONFIG_SEED, "utf8"), new anchor.BN(eid).toArrayLike(Buffer, "be", 4)],
342
+ [Buffer.from(SEND_CONFIG_SEED, "utf8"), new BN2__default.default(eid).toArrayLike(Buffer, "be", 4)],
341
343
  this.program
342
344
  );
343
345
  }
344
346
  defaultReceiveConfig(eid) {
345
347
  return web314.PublicKey.findProgramAddressSync(
346
- [Buffer.from(RECEIVE_CONFIG_SEED, "utf8"), new anchor.BN(eid).toArrayLike(Buffer, "be", 4)],
348
+ [Buffer.from(RECEIVE_CONFIG_SEED, "utf8"), new BN2__default.default(eid).toArrayLike(Buffer, "be", 4)],
347
349
  this.program
348
350
  );
349
351
  }
350
352
  options(eit) {
351
353
  return web314.PublicKey.findProgramAddressSync(
352
- [Buffer.from(OPTIONS_SEED, "utf8"), new anchor.BN(eit).toArrayLike(Buffer, "be", 4)],
354
+ [Buffer.from(OPTIONS_SEED, "utf8"), new BN2__default.default(eit).toArrayLike(Buffer, "be", 4)],
353
355
  this.program
354
356
  );
355
357
  }
@@ -369,7 +371,7 @@ var OAppBasePDADeriver = class {
369
371
  }
370
372
  remote(dstChainId) {
371
373
  return web314.PublicKey.findProgramAddressSync(
372
- [Buffer.from(REMOTE_SEED), new anchor.BN(dstChainId).toArrayLike(Buffer, "be", 4)],
374
+ [Buffer.from(REMOTE_SEED), new BN2__default.default(dstChainId).toArrayLike(Buffer, "be", 4)],
373
375
  this.program
374
376
  );
375
377
  }
@@ -390,7 +392,7 @@ var OmniCounterPDADeriver = class extends OAppBasePDADeriver {
390
392
  }
391
393
  remote(dstChainId) {
392
394
  return web314.PublicKey.findProgramAddressSync(
393
- [Buffer.from(REMOTE_SEED), this.count()[0].toBytes(), new anchor.BN(dstChainId).toArrayLike(Buffer, "be", 4)],
395
+ [Buffer.from(REMOTE_SEED), this.count()[0].toBytes(), new BN2__default.default(dstChainId).toArrayLike(Buffer, "be", 4)],
394
396
  this.program
395
397
  );
396
398
  }
@@ -4614,7 +4616,7 @@ var Endpoint = class {
4614
4616
  const [receiveLibraryConfig] = this.endpointDeriver.receiveLibraryConfig(oappIDPDA2, srcEid);
4615
4617
  const [receiveLibraryInfo] = this.endpointDeriver.messageLibraryInfo(newReceiveLib);
4616
4618
  const [oappRegistry] = this.endpointDeriver.oappRegistry(oappIDPDA2);
4617
- return createSetReceiveLibraryInstruction(
4619
+ const retval = createSetReceiveLibraryInstruction(
4618
4620
  {
4619
4621
  signer: oappAdmin,
4620
4622
  receiveLibraryConfig,
@@ -4633,6 +4635,7 @@ var Endpoint = class {
4633
4635
  },
4634
4636
  this.program
4635
4637
  );
4638
+ return Promise.resolve(retval);
4636
4639
  }
4637
4640
  /// send a simulated transaction to the endpoint to get the fee for sending a message
4638
4641
  /***
@@ -6936,7 +6939,7 @@ var SimpleMessageLib = class {
6936
6939
  /***
6937
6940
  * Get the account meta of the send instruction for CPI(Cross-Program Invocation )
6938
6941
  */
6939
- getSendIXAccountMetaForCPI(_connection, payer, _path) {
6942
+ async getSendIXAccountMetaForCPI(_connection, payer, _path) {
6940
6943
  const [msgLib] = this.deriver.messageLib();
6941
6944
  const ix = createSendInstruction2(
6942
6945
  {
@@ -6970,7 +6973,7 @@ var SimpleMessageLib = class {
6970
6973
  });
6971
6974
  return Promise.resolve(ix.keys.slice(1));
6972
6975
  }
6973
- getQuoteIXAccountMetaForCPI(_connection, _payer, _path, _commitment) {
6976
+ async getQuoteIXAccountMetaForCPI(_connection, _payer, _path, _commitment) {
6974
6977
  const [msgLib] = this.deriver.messageLib();
6975
6978
  const ix = createQuoteInstruction2(
6976
6979
  {
@@ -9023,7 +9026,7 @@ var DVN = class {
9023
9026
  _getExpiration() {
9024
9027
  return (/* @__PURE__ */ new Date()).getTime() / 1e3 + 120;
9025
9028
  }
9026
- setMsgLibs(connection, payer, msgLibs, sign) {
9029
+ async setMsgLibs(connection, payer, msgLibs, sign) {
9027
9030
  const expiration = this._getExpiration();
9028
9031
  return this.invoke(connection, this.vid, payer, this.createSetMsgLibsInstruction(msgLibs), expiration, sign);
9029
9032
  }
@@ -9048,7 +9051,7 @@ var DVN = class {
9048
9051
  const priceFeedConfig = configState.priceFeed;
9049
9052
  const priceFeedConfigState = await connection.getAccountInfo(priceFeedConfig);
9050
9053
  if (!priceFeedConfigState) {
9051
- throw new Error(`Price feed config(${priceFeedConfig}) account not found`);
9054
+ throw new Error(`Price feed config(${priceFeedConfig.toString()}) account not found`);
9052
9055
  }
9053
9056
  const ix = createQuoteDvnInstruction(
9054
9057
  {
@@ -12343,7 +12346,7 @@ var Uln = class {
12343
12346
  commitment
12344
12347
  );
12345
12348
  const dvnAccounts = await Promise.all(
12346
- dvnPrograms.map((p) => new DVN(p).getQuoteIXAccountMetaForCPI(connection, false, commitment))
12349
+ dvnPrograms.map(async (p) => new DVN(p).getQuoteIXAccountMetaForCPI(connection, false, commitment))
12347
12350
  );
12348
12351
  const ix = createQuoteInstruction3(
12349
12352
  {
@@ -12392,7 +12395,7 @@ var Uln = class {
12392
12395
  commitment
12393
12396
  );
12394
12397
  const dvnAccounts = await Promise.all(
12395
- dvnPrograms.map((p) => new DVN(p).getQuoteIXAccountMetaForCPI(connection, true, commitment))
12398
+ dvnPrograms.map(async (p) => new DVN(p).getQuoteIXAccountMetaForCPI(connection, true, commitment))
12396
12399
  );
12397
12400
  const ix = createSendInstruction3(
12398
12401
  {
@@ -12431,7 +12434,7 @@ var Uln = class {
12431
12434
  }
12432
12435
  });
12433
12436
  if (treasury) {
12434
- const treasuryIndex = ix.keys.findIndex((k) => k.pubkey.toBase58() == treasury?.toBase58());
12437
+ const treasuryIndex = ix.keys.findIndex((k) => k.pubkey.toBase58() == treasury.toBase58());
12435
12438
  ix.keys[treasuryIndex].isWritable = true;
12436
12439
  }
12437
12440
  return ix.keys.slice(1);
@@ -12524,7 +12527,7 @@ var Uln = class {
12524
12527
  params: {
12525
12528
  packetHeader: Array.from(Uint8Array.from(Buffer.from(packet.header().slice(2), "hex"))),
12526
12529
  payloadHash: Array.from(payloadHashBytes),
12527
- confirmations: typeof confirmations === "string" ? new anchor.BN(confirmations) : confirmations
12530
+ confirmations: typeof confirmations === "string" ? new BN2__default.default(confirmations) : confirmations
12528
12531
  }
12529
12532
  },
12530
12533
  this.program
@@ -12558,7 +12561,7 @@ var Uln = class {
12558
12561
  }
12559
12562
  const headerHash = packet.headerHash();
12560
12563
  const headerHashBytes = Uint8Array.from(Buffer.from(headerHash.slice(2), "hex"));
12561
- const confirmations = receiveConfigState?.uln.requiredDvns.concat(receiveConfigState?.uln.optionalDvns).map((p) => {
12564
+ const confirmations = receiveConfigState.uln.requiredDvns.concat(receiveConfigState.uln.optionalDvns).map((p) => {
12562
12565
  const [confirmationsPDA] = this.deriver.confirmations(headerHashBytes, payloadHashBytes, p);
12563
12566
  return {
12564
12567
  pubkey: confirmationsPDA,
@@ -13599,7 +13602,7 @@ async function simulateTransaction(connection, instructions, programId, payer, c
13599
13602
  const simulateResp = await connection.simulateTransaction(tx, { sigVerify: false, commitment });
13600
13603
  const returnPrefix = `Program return: ${programId.toBase58()} `;
13601
13604
  const returnLog = simulateResp.value.logs?.find((l) => l.startsWith(returnPrefix));
13602
- if (!returnLog) {
13605
+ if (returnLog === void 0) {
13603
13606
  throw new Error(`Simulate Fail: ${JSON.stringify(simulateResp)}`);
13604
13607
  } else {
13605
13608
  return Buffer.from(returnLog.slice(returnPrefix.length), "base64");