@layerzerolabs/lz-solana-sdk-v2 2.3.32 → 2.3.34

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,27 @@
1
1
  # @layerzerolabs/lz-solana-sdk-v2
2
2
 
3
+ ## 2.3.34
4
+
5
+ ### Patch Changes
6
+
7
+ - 5a99681: Fix an issue in Solana
8
+ - Updated dependencies [5a99681]
9
+ - @layerzerolabs/lz-corekit-solana@2.3.34
10
+ - @layerzerolabs/lz-definitions@2.3.34
11
+ - @layerzerolabs/lz-v2-utilities@2.3.34
12
+
13
+ ## 2.3.33
14
+
15
+ ### Patch Changes
16
+
17
+ - d9c0c10: testnets: new solana devnet, codex(evm), bahamut (evm)
18
+ - 1099b5f: testnets: lif3,iota,lyra,lightlink
19
+ - Updated dependencies [d9c0c10]
20
+ - Updated dependencies [1099b5f]
21
+ - @layerzerolabs/lz-corekit-solana@2.3.33
22
+ - @layerzerolabs/lz-definitions@2.3.33
23
+ - @layerzerolabs/lz-v2-utilities@2.3.33
24
+
3
25
  ## 2.3.32
4
26
 
5
27
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -9115,15 +9115,11 @@ var Endpoint = class {
9115
9115
  if (messageLibInfo2) {
9116
9116
  const { timeout: timeout2 } = defaultInfo;
9117
9117
  if (timeout2) {
9118
- const slot = await connection.getSlot();
9119
- const timestamp = await connection.getBlockTime(slot);
9120
- invariant5__default.default(timestamp, "timestamp should not be null");
9121
- const isValid = parseInt(timeout2.expiry.toString()) > timestamp;
9122
9118
  return {
9123
9119
  programId: defaultInfo.messageLib,
9124
9120
  msgLib: defaultInfo.messageLib,
9125
9121
  isDefault: true,
9126
- timeout: { msgLib: timeout2.messageLib, isValid }
9122
+ timeout: { msgLib: timeout2.messageLib, expiry: BigInt(timeout2.expiry.toString()) }
9127
9123
  };
9128
9124
  }
9129
9125
  }
@@ -9138,15 +9134,11 @@ var Endpoint = class {
9138
9134
  invariant5__default.default(messageLibInfo, "messageLibInfo should not be null");
9139
9135
  const { timeout } = info;
9140
9136
  if (timeout) {
9141
- const slot = await connection.getSlot();
9142
- const timestamp = await connection.getBlockTime(slot);
9143
- invariant5__default.default(timestamp, "timestamp should not be null");
9144
- const isValid = parseInt(timeout.expiry.toString()) > timestamp;
9145
9137
  return {
9146
9138
  programId: messageLibInfo.owner,
9147
9139
  msgLib: info.messageLib,
9148
9140
  isDefault: false,
9149
- timeout: { msgLib: timeout.messageLib, isValid }
9141
+ timeout: { msgLib: timeout.messageLib, expiry: BigInt(timeout.expiry.toString()) }
9150
9142
  };
9151
9143
  }
9152
9144
  return { programId: messageLibInfo.owner, msgLib: info.messageLib, isDefault: false, timeout: null };
@@ -19233,13 +19225,7 @@ var Uln = class {
19233
19225
  const [receiveConfig] = this.deriver.receiveConfig(srcEid, receiver);
19234
19226
  const [setting] = this.deriver.setting();
19235
19227
  const [msgLib] = this.deriver.messageLib();
19236
- let receiveConfigState = await this.getReceiveConfigState(connection, receiver, srcEid);
19237
- if (!receiveConfigState) {
19238
- receiveConfigState = await this.getDefaultReceiveConfigState(connection, srcEid);
19239
- }
19240
- if (!receiveConfigState) {
19241
- throw new Error("receive config not initialized");
19242
- }
19228
+ const receiveConfigState = await this.getFinalReceiveConfigState(connection, receiver, srcEid);
19243
19229
  const headerHash = packet.headerHash();
19244
19230
  const headerHashBytes = Uint8Array.from(Buffer.from(headerHash.slice(2), "hex"));
19245
19231
  const confirmations = receiveConfigState.uln.requiredDvns.concat(receiveConfigState.uln.optionalDvns).map((p) => {
@@ -19377,6 +19363,61 @@ var Uln = class {
19377
19363
  return null;
19378
19364
  }
19379
19365
  }
19366
+ async getFinalReceiveConfigState(connection, receiver, eid, commitmentOrConfig) {
19367
+ const NIL_CONFIRMATIONS = "18446744073709551615";
19368
+ const NIL_DVN_COUNT = "255";
19369
+ const rtn_config = {
19370
+ confirmations: 0,
19371
+ requiredDvnCount: 0,
19372
+ optionalDvnCount: 0,
19373
+ optionalDvnThreshold: 0,
19374
+ requiredDvns: [],
19375
+ optionalDvns: []
19376
+ };
19377
+ const [defaultConfig] = this.deriver.defaultReceiveConfig(eid);
19378
+ const [customConfig] = this.deriver.receiveConfig(eid, receiver);
19379
+ const [defaultConfigInfo, customConfigInfo] = await connection.getMultipleAccountsInfo(
19380
+ [defaultConfig, customConfig],
19381
+ commitmentOrConfig
19382
+ );
19383
+ if (defaultConfigInfo == null) {
19384
+ throw new Error(`please init default receive config first. ${defaultConfig.toBase58()}`);
19385
+ }
19386
+ const defaultConfigState = ReceiveConfig2.fromAccountInfo(defaultConfigInfo)[0];
19387
+ const customConfigState = customConfigInfo ? ReceiveConfig2.fromAccountInfo(customConfigInfo)[0] : null;
19388
+ if (customConfigState == null || customConfigState.uln.confirmations == 0) {
19389
+ rtn_config.confirmations = defaultConfigState.uln.confirmations;
19390
+ } else if (customConfigState.uln.confirmations.toString() !== NIL_CONFIRMATIONS) {
19391
+ rtn_config.confirmations = customConfigState.uln.confirmations;
19392
+ }
19393
+ if (customConfigState == null || customConfigState.uln.requiredDvnCount == 0) {
19394
+ if (defaultConfigState.uln.requiredDvnCount > 0) {
19395
+ rtn_config.requiredDvns = defaultConfigState.uln.requiredDvns;
19396
+ rtn_config.requiredDvnCount = defaultConfigState.uln.requiredDvnCount;
19397
+ }
19398
+ } else if (customConfigState.uln.requiredDvnCount.toString() !== NIL_DVN_COUNT) {
19399
+ rtn_config.requiredDvns = customConfigState.uln.requiredDvns;
19400
+ rtn_config.requiredDvnCount = customConfigState.uln.requiredDvnCount;
19401
+ }
19402
+ if (customConfigState == null || customConfigState.uln.optionalDvnCount == 0) {
19403
+ if (defaultConfigState.uln.optionalDvnCount > 0) {
19404
+ rtn_config.optionalDvns = defaultConfigState.uln.optionalDvns;
19405
+ rtn_config.optionalDvnCount = defaultConfigState.uln.optionalDvnCount;
19406
+ rtn_config.optionalDvnThreshold = defaultConfigState.uln.optionalDvnThreshold;
19407
+ }
19408
+ } else if (customConfigState.uln.optionalDvnCount.toString() !== NIL_DVN_COUNT) {
19409
+ rtn_config.optionalDvns = customConfigState.uln.optionalDvns;
19410
+ rtn_config.optionalDvnCount = customConfigState.uln.optionalDvnCount;
19411
+ rtn_config.optionalDvnThreshold = customConfigState.uln.optionalDvnThreshold;
19412
+ }
19413
+ if (rtn_config.requiredDvnCount === 0 && rtn_config.optionalDvnCount === 0) {
19414
+ throw new Error("no dvn");
19415
+ }
19416
+ return ReceiveConfig2.fromArgs({
19417
+ bump: defaultConfigState.bump,
19418
+ uln: rtn_config
19419
+ });
19420
+ }
19380
19421
  };
19381
19422
 
19382
19423
  // src/pricefeed.ts