@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 +22 -0
- package/dist/index.cjs +58 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +58 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -6581,7 +6581,7 @@ declare class Endpoint {
|
|
|
6581
6581
|
isDefault: boolean;
|
|
6582
6582
|
timeout: {
|
|
6583
6583
|
msgLib: PublicKey;
|
|
6584
|
-
|
|
6584
|
+
expiry: bigint;
|
|
6585
6585
|
} | null;
|
|
6586
6586
|
} | null>;
|
|
6587
6587
|
getInboundPayloadHash(connection: Connection, receiver: PublicKey, srcEid: number, sender: Uint8Array, nonce: number, _payloadHash: Uint8Array, commitmentOrConfig?: Commitment | GetAccountInfoConfig): Promise<PayloadHash | null>;
|
|
@@ -12887,6 +12887,7 @@ declare class Uln implements MessageLibInterface {
|
|
|
12887
12887
|
getSendConfigState(connection: Connection, sender: PublicKey, eid: number, commitmentOrConfig?: Commitment | GetAccountInfoConfig): Promise<SendConfig | null>;
|
|
12888
12888
|
getDefaultReceiveConfigState(connection: Connection, eid: number, commitmentOrConfig?: Commitment | GetAccountInfoConfig): Promise<ReceiveConfig | null>;
|
|
12889
12889
|
getReceiveConfigState(connection: Connection, receiver: PublicKey, eid: number, commitmentOrConfig?: Commitment | GetAccountInfoConfig): Promise<ReceiveConfig | null>;
|
|
12890
|
+
getFinalReceiveConfigState(connection: Connection, receiver: PublicKey, eid: number, commitmentOrConfig?: Commitment | GetAccountInfoConfig): Promise<ReceiveConfig>;
|
|
12890
12891
|
}
|
|
12891
12892
|
|
|
12892
12893
|
type uln_AtLeastOneDVNError = AtLeastOneDVNError;
|
package/dist/index.d.ts
CHANGED
|
@@ -6581,7 +6581,7 @@ declare class Endpoint {
|
|
|
6581
6581
|
isDefault: boolean;
|
|
6582
6582
|
timeout: {
|
|
6583
6583
|
msgLib: PublicKey;
|
|
6584
|
-
|
|
6584
|
+
expiry: bigint;
|
|
6585
6585
|
} | null;
|
|
6586
6586
|
} | null>;
|
|
6587
6587
|
getInboundPayloadHash(connection: Connection, receiver: PublicKey, srcEid: number, sender: Uint8Array, nonce: number, _payloadHash: Uint8Array, commitmentOrConfig?: Commitment | GetAccountInfoConfig): Promise<PayloadHash | null>;
|
|
@@ -12887,6 +12887,7 @@ declare class Uln implements MessageLibInterface {
|
|
|
12887
12887
|
getSendConfigState(connection: Connection, sender: PublicKey, eid: number, commitmentOrConfig?: Commitment | GetAccountInfoConfig): Promise<SendConfig | null>;
|
|
12888
12888
|
getDefaultReceiveConfigState(connection: Connection, eid: number, commitmentOrConfig?: Commitment | GetAccountInfoConfig): Promise<ReceiveConfig | null>;
|
|
12889
12889
|
getReceiveConfigState(connection: Connection, receiver: PublicKey, eid: number, commitmentOrConfig?: Commitment | GetAccountInfoConfig): Promise<ReceiveConfig | null>;
|
|
12890
|
+
getFinalReceiveConfigState(connection: Connection, receiver: PublicKey, eid: number, commitmentOrConfig?: Commitment | GetAccountInfoConfig): Promise<ReceiveConfig>;
|
|
12890
12891
|
}
|
|
12891
12892
|
|
|
12892
12893
|
type uln_AtLeastOneDVNError = AtLeastOneDVNError;
|
package/dist/index.mjs
CHANGED
|
@@ -9087,15 +9087,11 @@ var Endpoint = class {
|
|
|
9087
9087
|
if (messageLibInfo2) {
|
|
9088
9088
|
const { timeout: timeout2 } = defaultInfo;
|
|
9089
9089
|
if (timeout2) {
|
|
9090
|
-
const slot = await connection.getSlot();
|
|
9091
|
-
const timestamp = await connection.getBlockTime(slot);
|
|
9092
|
-
invariant5(timestamp, "timestamp should not be null");
|
|
9093
|
-
const isValid = parseInt(timeout2.expiry.toString()) > timestamp;
|
|
9094
9090
|
return {
|
|
9095
9091
|
programId: defaultInfo.messageLib,
|
|
9096
9092
|
msgLib: defaultInfo.messageLib,
|
|
9097
9093
|
isDefault: true,
|
|
9098
|
-
timeout: { msgLib: timeout2.messageLib,
|
|
9094
|
+
timeout: { msgLib: timeout2.messageLib, expiry: BigInt(timeout2.expiry.toString()) }
|
|
9099
9095
|
};
|
|
9100
9096
|
}
|
|
9101
9097
|
}
|
|
@@ -9110,15 +9106,11 @@ var Endpoint = class {
|
|
|
9110
9106
|
invariant5(messageLibInfo, "messageLibInfo should not be null");
|
|
9111
9107
|
const { timeout } = info;
|
|
9112
9108
|
if (timeout) {
|
|
9113
|
-
const slot = await connection.getSlot();
|
|
9114
|
-
const timestamp = await connection.getBlockTime(slot);
|
|
9115
|
-
invariant5(timestamp, "timestamp should not be null");
|
|
9116
|
-
const isValid = parseInt(timeout.expiry.toString()) > timestamp;
|
|
9117
9109
|
return {
|
|
9118
9110
|
programId: messageLibInfo.owner,
|
|
9119
9111
|
msgLib: info.messageLib,
|
|
9120
9112
|
isDefault: false,
|
|
9121
|
-
timeout: { msgLib: timeout.messageLib,
|
|
9113
|
+
timeout: { msgLib: timeout.messageLib, expiry: BigInt(timeout.expiry.toString()) }
|
|
9122
9114
|
};
|
|
9123
9115
|
}
|
|
9124
9116
|
return { programId: messageLibInfo.owner, msgLib: info.messageLib, isDefault: false, timeout: null };
|
|
@@ -19205,13 +19197,7 @@ var Uln = class {
|
|
|
19205
19197
|
const [receiveConfig] = this.deriver.receiveConfig(srcEid, receiver);
|
|
19206
19198
|
const [setting] = this.deriver.setting();
|
|
19207
19199
|
const [msgLib] = this.deriver.messageLib();
|
|
19208
|
-
|
|
19209
|
-
if (!receiveConfigState) {
|
|
19210
|
-
receiveConfigState = await this.getDefaultReceiveConfigState(connection, srcEid);
|
|
19211
|
-
}
|
|
19212
|
-
if (!receiveConfigState) {
|
|
19213
|
-
throw new Error("receive config not initialized");
|
|
19214
|
-
}
|
|
19200
|
+
const receiveConfigState = await this.getFinalReceiveConfigState(connection, receiver, srcEid);
|
|
19215
19201
|
const headerHash = packet.headerHash();
|
|
19216
19202
|
const headerHashBytes = Uint8Array.from(Buffer.from(headerHash.slice(2), "hex"));
|
|
19217
19203
|
const confirmations = receiveConfigState.uln.requiredDvns.concat(receiveConfigState.uln.optionalDvns).map((p) => {
|
|
@@ -19349,6 +19335,61 @@ var Uln = class {
|
|
|
19349
19335
|
return null;
|
|
19350
19336
|
}
|
|
19351
19337
|
}
|
|
19338
|
+
async getFinalReceiveConfigState(connection, receiver, eid, commitmentOrConfig) {
|
|
19339
|
+
const NIL_CONFIRMATIONS = "18446744073709551615";
|
|
19340
|
+
const NIL_DVN_COUNT = "255";
|
|
19341
|
+
const rtn_config = {
|
|
19342
|
+
confirmations: 0,
|
|
19343
|
+
requiredDvnCount: 0,
|
|
19344
|
+
optionalDvnCount: 0,
|
|
19345
|
+
optionalDvnThreshold: 0,
|
|
19346
|
+
requiredDvns: [],
|
|
19347
|
+
optionalDvns: []
|
|
19348
|
+
};
|
|
19349
|
+
const [defaultConfig] = this.deriver.defaultReceiveConfig(eid);
|
|
19350
|
+
const [customConfig] = this.deriver.receiveConfig(eid, receiver);
|
|
19351
|
+
const [defaultConfigInfo, customConfigInfo] = await connection.getMultipleAccountsInfo(
|
|
19352
|
+
[defaultConfig, customConfig],
|
|
19353
|
+
commitmentOrConfig
|
|
19354
|
+
);
|
|
19355
|
+
if (defaultConfigInfo == null) {
|
|
19356
|
+
throw new Error(`please init default receive config first. ${defaultConfig.toBase58()}`);
|
|
19357
|
+
}
|
|
19358
|
+
const defaultConfigState = ReceiveConfig2.fromAccountInfo(defaultConfigInfo)[0];
|
|
19359
|
+
const customConfigState = customConfigInfo ? ReceiveConfig2.fromAccountInfo(customConfigInfo)[0] : null;
|
|
19360
|
+
if (customConfigState == null || customConfigState.uln.confirmations == 0) {
|
|
19361
|
+
rtn_config.confirmations = defaultConfigState.uln.confirmations;
|
|
19362
|
+
} else if (customConfigState.uln.confirmations.toString() !== NIL_CONFIRMATIONS) {
|
|
19363
|
+
rtn_config.confirmations = customConfigState.uln.confirmations;
|
|
19364
|
+
}
|
|
19365
|
+
if (customConfigState == null || customConfigState.uln.requiredDvnCount == 0) {
|
|
19366
|
+
if (defaultConfigState.uln.requiredDvnCount > 0) {
|
|
19367
|
+
rtn_config.requiredDvns = defaultConfigState.uln.requiredDvns;
|
|
19368
|
+
rtn_config.requiredDvnCount = defaultConfigState.uln.requiredDvnCount;
|
|
19369
|
+
}
|
|
19370
|
+
} else if (customConfigState.uln.requiredDvnCount.toString() !== NIL_DVN_COUNT) {
|
|
19371
|
+
rtn_config.requiredDvns = customConfigState.uln.requiredDvns;
|
|
19372
|
+
rtn_config.requiredDvnCount = customConfigState.uln.requiredDvnCount;
|
|
19373
|
+
}
|
|
19374
|
+
if (customConfigState == null || customConfigState.uln.optionalDvnCount == 0) {
|
|
19375
|
+
if (defaultConfigState.uln.optionalDvnCount > 0) {
|
|
19376
|
+
rtn_config.optionalDvns = defaultConfigState.uln.optionalDvns;
|
|
19377
|
+
rtn_config.optionalDvnCount = defaultConfigState.uln.optionalDvnCount;
|
|
19378
|
+
rtn_config.optionalDvnThreshold = defaultConfigState.uln.optionalDvnThreshold;
|
|
19379
|
+
}
|
|
19380
|
+
} else if (customConfigState.uln.optionalDvnCount.toString() !== NIL_DVN_COUNT) {
|
|
19381
|
+
rtn_config.optionalDvns = customConfigState.uln.optionalDvns;
|
|
19382
|
+
rtn_config.optionalDvnCount = customConfigState.uln.optionalDvnCount;
|
|
19383
|
+
rtn_config.optionalDvnThreshold = customConfigState.uln.optionalDvnThreshold;
|
|
19384
|
+
}
|
|
19385
|
+
if (rtn_config.requiredDvnCount === 0 && rtn_config.optionalDvnCount === 0) {
|
|
19386
|
+
throw new Error("no dvn");
|
|
19387
|
+
}
|
|
19388
|
+
return ReceiveConfig2.fromArgs({
|
|
19389
|
+
bump: defaultConfigState.bump,
|
|
19390
|
+
uln: rtn_config
|
|
19391
|
+
});
|
|
19392
|
+
}
|
|
19352
19393
|
};
|
|
19353
19394
|
|
|
19354
19395
|
// src/pricefeed.ts
|