@layerzerolabs/lz-movevm-sdk-v2 3.0.85 → 3.0.87
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 +24 -0
- package/dist/index.cjs +148 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +36 -1
- package/dist/index.d.ts +36 -1
- package/dist/index.mjs +172 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @layerzerolabs/lz-movevm-sdk-v2
|
|
2
2
|
|
|
3
|
+
## 3.0.87
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e92c65d: Update initia.js version
|
|
8
|
+
- Updated dependencies [e92c65d]
|
|
9
|
+
- @layerzerolabs/lz-definitions@3.0.87
|
|
10
|
+
- @layerzerolabs/lz-serdes@3.0.87
|
|
11
|
+
- @layerzerolabs/lz-utilities@3.0.87
|
|
12
|
+
- @layerzerolabs/lz-v2-utilities@3.0.87
|
|
13
|
+
- @layerzerolabs/move-definitions@3.0.87
|
|
14
|
+
|
|
15
|
+
## 3.0.86
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- a372bd0: Fix import bugs in generated test codes and add feature for testing malicious DVNs in ton-sdk-tools.
|
|
20
|
+
- Updated dependencies [a372bd0]
|
|
21
|
+
- @layerzerolabs/lz-definitions@3.0.86
|
|
22
|
+
- @layerzerolabs/lz-serdes@3.0.86
|
|
23
|
+
- @layerzerolabs/lz-utilities@3.0.86
|
|
24
|
+
- @layerzerolabs/lz-v2-utilities@3.0.86
|
|
25
|
+
- @layerzerolabs/move-definitions@3.0.86
|
|
26
|
+
|
|
3
27
|
## 3.0.85
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var lzSerdes = require('@layerzerolabs/lz-serdes');
|
|
4
|
-
var lzUtilities = require('@layerzerolabs/lz-utilities');
|
|
5
4
|
var lzV2Utilities = require('@layerzerolabs/lz-v2-utilities');
|
|
5
|
+
var lzUtilities = require('@layerzerolabs/lz-utilities');
|
|
6
6
|
var moveDefinitions = require('@layerzerolabs/move-definitions');
|
|
7
7
|
var assert = require('assert');
|
|
8
8
|
|
|
@@ -37,7 +37,10 @@ var types_exports = {};
|
|
|
37
37
|
__export(types_exports, {
|
|
38
38
|
ConfigType: () => ConfigType,
|
|
39
39
|
VERIFICATION_STATE: () => VERIFICATION_STATE,
|
|
40
|
+
deserializeExecutorConfig: () => deserializeExecutorConfig,
|
|
40
41
|
deserializeUlnConfig: () => deserializeUlnConfig,
|
|
42
|
+
serializeExecutorConfig: () => serializeExecutorConfig,
|
|
43
|
+
serializeUlnConfig: () => serializeUlnConfig,
|
|
41
44
|
serializeUpdatePrices: () => serializeUpdatePrices,
|
|
42
45
|
verificationStateValueOf: () => verificationStateValueOf
|
|
43
46
|
});
|
|
@@ -72,6 +75,21 @@ var ConfigType = /* @__PURE__ */ ((ConfigType2) => {
|
|
|
72
75
|
ConfigType2[ConfigType2["receiveUln"] = 3] = "receiveUln";
|
|
73
76
|
return ConfigType2;
|
|
74
77
|
})(ConfigType || {});
|
|
78
|
+
function serializeExecutorConfig(config) {
|
|
79
|
+
const serializer = new lzSerdes.Serializer(false);
|
|
80
|
+
serializer.serializeU32(config.maxMessageSize);
|
|
81
|
+
serializer.serializeFixedBytes(lzV2Utilities.addressToBytes32(config.executorAddress));
|
|
82
|
+
return serializer.getBytes();
|
|
83
|
+
}
|
|
84
|
+
function deserializeExecutorConfig(data) {
|
|
85
|
+
if (typeof data === "string") {
|
|
86
|
+
data = Uint8Array.from(Buffer.from(lzV2Utilities.trim0x(data), "hex"));
|
|
87
|
+
}
|
|
88
|
+
const deserializer = new lzSerdes.Deserializer(data, false);
|
|
89
|
+
const maxMessageSize = deserializer.deserializeU32();
|
|
90
|
+
const executorAddress = Buffer.from(deserializer.deserializeFixedBytes(32)).toString("hex");
|
|
91
|
+
return { maxMessageSize, executorAddress };
|
|
92
|
+
}
|
|
75
93
|
function deserializeUlnConfig(data) {
|
|
76
94
|
if (typeof data === "string") {
|
|
77
95
|
data = Uint8Array.from(Buffer.from(lzUtilities.trim0x(data), "hex"));
|
|
@@ -102,6 +120,25 @@ function deserializeUlnConfig(data) {
|
|
|
102
120
|
useDefaultForOptionalDVNs
|
|
103
121
|
};
|
|
104
122
|
}
|
|
123
|
+
function serializeUlnConfig(config) {
|
|
124
|
+
const serializer = new lzSerdes.Serializer(false);
|
|
125
|
+
serializer.serializeU64(config.confirmations);
|
|
126
|
+
serializer.serializeU8(config.optionalDVNThreshold);
|
|
127
|
+
const requiredDVNCount = config.requiredDVNs.length;
|
|
128
|
+
serializer.serializeU8(requiredDVNCount);
|
|
129
|
+
for (const item of config.requiredDVNs) {
|
|
130
|
+
serializer.serializeFixedBytes(lzV2Utilities.addressToBytes32(lzUtilities.ensure0x(item)));
|
|
131
|
+
}
|
|
132
|
+
const optionalDVNCount = config.optionalDVNs.length;
|
|
133
|
+
serializer.serializeU8(optionalDVNCount);
|
|
134
|
+
for (const item of config.optionalDVNs) {
|
|
135
|
+
serializer.serializeFixedBytes(lzV2Utilities.addressToBytes32(lzUtilities.ensure0x(item)));
|
|
136
|
+
}
|
|
137
|
+
serializer.serializeBool(config.useDefaultForConfirmations);
|
|
138
|
+
serializer.serializeBool(config.useDefaultForRequiredDVNs);
|
|
139
|
+
serializer.serializeBool(config.useDefaultForOptionalDVNs);
|
|
140
|
+
return serializer.getBytes();
|
|
141
|
+
}
|
|
105
142
|
function serializeUpdatePrices(updatePrices) {
|
|
106
143
|
const serializer = new lzSerdes.Serializer(false);
|
|
107
144
|
for (const updatePrice of updatePrices) {
|
|
@@ -375,6 +412,15 @@ var DvnWorker = class {
|
|
|
375
412
|
const hash = view[0];
|
|
376
413
|
return hash.bytes;
|
|
377
414
|
}
|
|
415
|
+
async createSetMsgLibsHash(msglibs, vid, expiration) {
|
|
416
|
+
const view = await this.sdk.viewFunction({
|
|
417
|
+
functionName: `${this.module[0]}::hashes::create_set_msglibs_hash`,
|
|
418
|
+
functionArgs: [msglibs, vid, expiration],
|
|
419
|
+
functionArgTypes: ["vector<address>", "u32", "u64"]
|
|
420
|
+
});
|
|
421
|
+
const hash = view[0];
|
|
422
|
+
return hash.bytes;
|
|
423
|
+
}
|
|
378
424
|
/**
|
|
379
425
|
* Creates a payload for initializing the DVN contract.
|
|
380
426
|
*
|
|
@@ -454,6 +500,35 @@ var DvnWorker = class {
|
|
|
454
500
|
throw e;
|
|
455
501
|
}
|
|
456
502
|
}
|
|
503
|
+
async createSetWorkerConfigForFeeLibRoutingOptInForUln301Payload(uln301Address) {
|
|
504
|
+
if (await this.sdk.isObjectAddress(this.module[0])) {
|
|
505
|
+
const functionIdOrBytecode = setWorkerConfigForFeeLibRoutingOptInForUln301ScriptHex(
|
|
506
|
+
this.sdk.accounts.deploy_to_object,
|
|
507
|
+
uln301Address
|
|
508
|
+
);
|
|
509
|
+
const functionArguments = [this.module[0]];
|
|
510
|
+
const functionArgumentTypes = ["address"];
|
|
511
|
+
return {
|
|
512
|
+
function: functionIdOrBytecode,
|
|
513
|
+
functionArguments,
|
|
514
|
+
functionArgumentTypes
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
throw new Error("Only supported object deployment");
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Gets the opt in/out status of a worker
|
|
521
|
+
* @param uln301Address - The ULN 301 address
|
|
522
|
+
* @returns {Promise<boolean>} The opt in/out status of the worker
|
|
523
|
+
*/
|
|
524
|
+
async getWorkerConfigForFeeLibRoutingOptIn(uln301Address) {
|
|
525
|
+
const view = await this.sdk.viewFunction({
|
|
526
|
+
functionName: `${uln301Address}::msglib::worker_config_for_fee_lib_routing_opt_in`,
|
|
527
|
+
functionArgs: [this.module[0]],
|
|
528
|
+
functionArgTypes: ["address"]
|
|
529
|
+
});
|
|
530
|
+
return view[0];
|
|
531
|
+
}
|
|
457
532
|
/**
|
|
458
533
|
* Gets the destination configuration for the specified endpoint.
|
|
459
534
|
*
|
|
@@ -484,6 +559,39 @@ var DvnWorker = class {
|
|
|
484
559
|
throw e;
|
|
485
560
|
}
|
|
486
561
|
}
|
|
562
|
+
/**
|
|
563
|
+
* Creates a payload for setting the supported message libraries.
|
|
564
|
+
*
|
|
565
|
+
* @param {string[]} msglibs - The supported message libraries.
|
|
566
|
+
* @returns {InputEntryFunctionData} The input entry function data.
|
|
567
|
+
*/
|
|
568
|
+
createSetSupportedMsglibsPayload(msglibs, expiration, signatures) {
|
|
569
|
+
return {
|
|
570
|
+
function: `${this.module[0]}::${this.module[1]}::set_supported_msglibs`,
|
|
571
|
+
functionArguments: [msglibs, BigInt(expiration), lzUtilities.arrayify(signatures)],
|
|
572
|
+
functionArgumentTypes: ["vector<address>", "u64", "vector<u8>"]
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* Gets the supported message libraries.
|
|
577
|
+
*
|
|
578
|
+
* @returns {Promise<string[]>} The supported message libraries.
|
|
579
|
+
*/
|
|
580
|
+
async getSupportedMsglibs() {
|
|
581
|
+
try {
|
|
582
|
+
const view = await this.sdk.viewFunction({
|
|
583
|
+
functionName: `${this.module[0]}::${this.module[1]}::get_supported_msglibs`,
|
|
584
|
+
functionArgs: [],
|
|
585
|
+
functionArgTypes: []
|
|
586
|
+
});
|
|
587
|
+
return view[0];
|
|
588
|
+
} catch (e) {
|
|
589
|
+
if (e instanceof moveDefinitions.MoveAbortError && e.abortCode === EWORKER_NOT_REGISTERED) {
|
|
590
|
+
return [];
|
|
591
|
+
}
|
|
592
|
+
throw e;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
487
595
|
/**
|
|
488
596
|
* Creates a payload for setting the destination configuration.
|
|
489
597
|
*
|
|
@@ -622,6 +730,11 @@ var initializeDvnScriptHex = (deployerAddressHex, dvnAddressHex, uln302AddressHe
|
|
|
622
730
|
uln302AddressHex = lzV2Utilities.trim0x(lzUtilities.padify(uln302AddressHex));
|
|
623
731
|
return `a11ceb0b060000000701000a030a1a042402052657077d9201088f028001068f031d000000010102020303040405030400010606070101000708090002080a020003090b0200010508060c05050a020a02030a0205170c0101010303030a020a05060c0a020a0a020303030303030303030a020a050002060c05010c010203060a09000303010a0900010a02010507060c050a050a0a02030a050502060c010866726f6d5f62637306766563746f720364766e066d73676c6962166f626a6563745f636f64655f6465706c6f796d656e74166765745f636f64655f6f626a6563745f7369676e657205736c6963650a746f5f616464726573730a696e697469616c697a652c7365745f776f726b65725f636f6e6669675f666f725f6665655f6c69625f726f7574696e675f6f70745f696e${stdAddressHex}${dvnAddressHex}${uln302AddressHex}${deployerAddressHex}03082000000000000000030840000000000000000a0501000a0a020100000001b0010b000b0111000c080e080c110e0341050c170a1707001906000000000000000021041005140b11010601000000000000002707020c100600000000000000000c14090c090b1707001a0c0c0a0904250b14060100000000000000160c140527080c090a140a0c23043b0a140700180c1a0e030a1a0b1a07001638000c0f0d100b0f11024409051e0e0641050c180a1807001906000000000000000021044505490b11010601000000000000002707020c1e0600000000000000000c15090c0a0b1807001a0c0e0a0a045a0b15060100000000000000160c15055c080c0a0a150a0e2304700a150700180c1c0e060a1c0b1c07001638000c1d0d1e0b1d1102440905530e0441050c190a1907011906000000000000000021047a057e0b11010601000000000000002707030c130600000000000000000c16090c0b0b1907011a0c0d0a0b048f010b16060100000000000000160c16059101080c0b0a160a0d2304a4010a160701180c1b0e040a1b0b1b07011638000c120d130b1244080588010a110b020b100b130b050b1e0b0711030b1108110402`;
|
|
624
732
|
};
|
|
733
|
+
var setWorkerConfigForFeeLibRoutingOptInForUln301ScriptHex = (deployerAddressHex, uln301AddressHex) => {
|
|
734
|
+
deployerAddressHex = lzV2Utilities.trim0x(lzUtilities.padify(deployerAddressHex));
|
|
735
|
+
uln301AddressHex = lzV2Utilities.trim0x(lzUtilities.padify(uln301AddressHex));
|
|
736
|
+
return `a11ceb0b060000000501000403040a050e0b071962087b40000001010102000100000303020002060c05010c0002060c01066d73676c6962166f626a6563745f636f64655f6465706c6f796d656e74166765745f636f64655f6f626a6563745f7369676e65722c7365745f776f726b65725f636f6e6669675f666f725f6665655f6c69625f726f7574696e675f6f70745f696e${uln301AddressHex}${deployerAddressHex}000001080b000b0111000c020e0208110102`;
|
|
737
|
+
};
|
|
625
738
|
var Endpoint = class {
|
|
626
739
|
/**
|
|
627
740
|
* Creates an instance of Endpoint.
|
|
@@ -1410,6 +1523,35 @@ var Executor = class {
|
|
|
1410
1523
|
gasOptions
|
|
1411
1524
|
);
|
|
1412
1525
|
}
|
|
1526
|
+
async createSetWorkerConfigForFeeLibRoutingOptInForUln301Payload(uln301Address) {
|
|
1527
|
+
if (await this.sdk.isObjectAddress(this.module[0])) {
|
|
1528
|
+
const functionIdOrBytecode = setWorkerConfigForFeeLibRoutingOptInForUln301ScriptHex2(
|
|
1529
|
+
this.sdk.accounts.deploy_to_object,
|
|
1530
|
+
uln301Address
|
|
1531
|
+
);
|
|
1532
|
+
const functionArguments = [this.module[0]];
|
|
1533
|
+
const functionArgumentTypes = ["address"];
|
|
1534
|
+
return {
|
|
1535
|
+
function: functionIdOrBytecode,
|
|
1536
|
+
functionArguments,
|
|
1537
|
+
functionArgumentTypes
|
|
1538
|
+
};
|
|
1539
|
+
}
|
|
1540
|
+
throw new Error("Only supported object deployment");
|
|
1541
|
+
}
|
|
1542
|
+
/**
|
|
1543
|
+
* Gets the opt in/out status of a worker
|
|
1544
|
+
* @param uln301Address - The ULN 301 address
|
|
1545
|
+
* @returns {Promise<boolean>} The opt in/out status of the worker
|
|
1546
|
+
*/
|
|
1547
|
+
async getWorkerConfigForFeeLibRoutingOptIn(uln301Address) {
|
|
1548
|
+
const view = await this.sdk.viewFunction({
|
|
1549
|
+
functionName: `${uln301Address}::msglib::worker_config_for_fee_lib_routing_opt_in`,
|
|
1550
|
+
functionArgs: [this.module[0]],
|
|
1551
|
+
functionArgTypes: ["address"]
|
|
1552
|
+
});
|
|
1553
|
+
return view[0];
|
|
1554
|
+
}
|
|
1413
1555
|
/**
|
|
1414
1556
|
* Gets the destination configuration for the specified endpoint.
|
|
1415
1557
|
*
|
|
@@ -1853,6 +1995,11 @@ var initializeExecutorScriptHex = (deployerAddressHex, executorAddressHex, uln30
|
|
|
1853
1995
|
uln302AddressHex = lzV2Utilities.trim0x(lzUtilities.padify(uln302AddressHex));
|
|
1854
1996
|
return `a11ceb0b060000000701000a030a1a042402052648076e970108850280010685030e000000010102020303040405030400010606070101000708090002080a020003090b0200010507060c0505050a020a0205100c010103030a020a05060c0303030303030a020a050002060c05010c010203060a09000303010a0900010a02010506060c05050a050a050502060c010866726f6d5f62637306766563746f72086578656375746f72066d73676c6962166f626a6563745f636f64655f6465706c6f796d656e74166765745f636f64655f6f626a6563745f7369676e657205736c6963650a746f5f616464726573730a696e697469616c697a652c7365745f776f726b65725f636f6e6669675f666f725f6665655f6c69625f726f7574696e675f6f70745f696e${stdAddressHex}${executorAddressHex}${uln302AddressHex}${deployerAddressHex}030820000000000000000a0501000000017b0b000b0111000c070e070c0e0e0441050c110a1107001906000000000000000021041005140b0e010601000000000000002707010c0d0600000000000000000c0f090c080b1107001a0c0a0a0804250b0f060100000000000000160c0f0527080c080a0f0a0a23043b0a0f0700180c130e040a130b1307001638000c0c0d0d0b0c11024409051e0e0541050c120a1207001906000000000000000021044505490b0e010601000000000000002707010c160600000000000000000c10090c090b1207001a0c0b0a09045a0b10060100000000000000160c10055c080c090a100a0b2304700a100700180c140e050a140b1407001638000c150d160b151102440905530a0e0b020b030b0d0b160b0611030b0e08110402`;
|
|
1855
1997
|
};
|
|
1998
|
+
var setWorkerConfigForFeeLibRoutingOptInForUln301ScriptHex2 = (deployerAddressHex, uln301AddressHex) => {
|
|
1999
|
+
deployerAddressHex = lzV2Utilities.trim0x(lzUtilities.padify(deployerAddressHex));
|
|
2000
|
+
uln301AddressHex = lzV2Utilities.trim0x(lzUtilities.padify(uln301AddressHex));
|
|
2001
|
+
return `a11ceb0b060000000501000403040a050e0b071962087b40000001010102000100000303020002060c05010c0002060c01066d73676c6962166f626a6563745f636f64655f6465706c6f796d656e74166765745f636f64655f6f626a6563745f7369676e65722c7365745f776f726b65725f636f6e6669675f666f725f6665655f6c69625f726f7574696e675f6f70745f696e${uln301AddressHex}${deployerAddressHex}000001080b000b0111000c020e0208110102`;
|
|
2002
|
+
};
|
|
1856
2003
|
function asciiToHex(str) {
|
|
1857
2004
|
let hex = "";
|
|
1858
2005
|
for (let i = 0; i < str.length; i++) {
|