@layerzerolabs/lz-solana-sdk-v2 2.3.33 → 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 +10 -0
- package/dist/index.cjs +56 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +56 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -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
|
@@ -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
|
@@ -19197,13 +19197,7 @@ var Uln = class {
|
|
|
19197
19197
|
const [receiveConfig] = this.deriver.receiveConfig(srcEid, receiver);
|
|
19198
19198
|
const [setting] = this.deriver.setting();
|
|
19199
19199
|
const [msgLib] = this.deriver.messageLib();
|
|
19200
|
-
|
|
19201
|
-
if (!receiveConfigState) {
|
|
19202
|
-
receiveConfigState = await this.getDefaultReceiveConfigState(connection, srcEid);
|
|
19203
|
-
}
|
|
19204
|
-
if (!receiveConfigState) {
|
|
19205
|
-
throw new Error("receive config not initialized");
|
|
19206
|
-
}
|
|
19200
|
+
const receiveConfigState = await this.getFinalReceiveConfigState(connection, receiver, srcEid);
|
|
19207
19201
|
const headerHash = packet.headerHash();
|
|
19208
19202
|
const headerHashBytes = Uint8Array.from(Buffer.from(headerHash.slice(2), "hex"));
|
|
19209
19203
|
const confirmations = receiveConfigState.uln.requiredDvns.concat(receiveConfigState.uln.optionalDvns).map((p) => {
|
|
@@ -19341,6 +19335,61 @@ var Uln = class {
|
|
|
19341
19335
|
return null;
|
|
19342
19336
|
}
|
|
19343
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
|
+
}
|
|
19344
19393
|
};
|
|
19345
19394
|
|
|
19346
19395
|
// src/pricefeed.ts
|