@layerzerolabs/lz-movevm-sdk-v2 3.0.67 → 3.0.68
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 +12 -0
- package/dist/index.cjs +129 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +25 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.mjs +129 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @layerzerolabs/lz-movevm-sdk-v2
|
|
2
2
|
|
|
3
|
+
## 3.0.68
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b54c86d: concrete mainnet endpoint
|
|
8
|
+
- Updated dependencies [b54c86d]
|
|
9
|
+
- @layerzerolabs/lz-definitions@3.0.68
|
|
10
|
+
- @layerzerolabs/lz-serdes@3.0.68
|
|
11
|
+
- @layerzerolabs/lz-utilities@3.0.68
|
|
12
|
+
- @layerzerolabs/lz-v2-utilities@3.0.68
|
|
13
|
+
- @layerzerolabs/move-definitions@3.0.68
|
|
14
|
+
|
|
3
15
|
## 3.0.67
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -710,6 +710,23 @@ var Endpoint = class {
|
|
|
710
710
|
const config = deserializeUlnConfig(view[0]);
|
|
711
711
|
return Number(config.confirmations);
|
|
712
712
|
}
|
|
713
|
+
/**
|
|
714
|
+
* Retrieves the ULN (Ultra Light Node) configuration for a given remote endpoint ID and application.
|
|
715
|
+
*
|
|
716
|
+
* @param {number} remoteEid - The remote endpoint ID.
|
|
717
|
+
* @param {string} oapp - The application identifier.
|
|
718
|
+
* @param {ConfigType} configType - The type of configuration to retrieve.
|
|
719
|
+
* @returns {Promise<UlnConfig>} A promise that resolves to the ULN configuration.
|
|
720
|
+
*/
|
|
721
|
+
async getUlnConfig(remoteEid, oapp, configType) {
|
|
722
|
+
const ulnMsgLibAddr = this.sdk.accounts.uln_message_lib?.toString() ?? "0x0";
|
|
723
|
+
const view = await this.sdk.viewFunction({
|
|
724
|
+
functionName: `${this.module[0]}::${this.module[1]}::get_config`,
|
|
725
|
+
functionArgs: [oapp, ulnMsgLibAddr, remoteEid, configType],
|
|
726
|
+
functionArgTypes: ["address", "address", "u32", "u32"]
|
|
727
|
+
});
|
|
728
|
+
return deserializeUlnConfig(view[0]);
|
|
729
|
+
}
|
|
713
730
|
/**
|
|
714
731
|
* Checks if a message can be verified.
|
|
715
732
|
*
|
|
@@ -1254,6 +1271,34 @@ var Executor = class {
|
|
|
1254
1271
|
*/
|
|
1255
1272
|
constructor(sdk) {
|
|
1256
1273
|
this.sdk = sdk;
|
|
1274
|
+
this.lzReceiveWithValueScriptHex = (oappAddressHex, lzReceiveModuleName) => {
|
|
1275
|
+
oappAddressHex = lzV2Utilities.trim0x(lzUtilities.padify(oappAddressHex));
|
|
1276
|
+
const stdAddressHex = "0000000000000000000000000000000000000000000000000000000000000001";
|
|
1277
|
+
const modLen = lzReceiveModuleName.length;
|
|
1278
|
+
const modLenHex = modLen.toString(16).padStart(2, "0");
|
|
1279
|
+
const modNameHex = asciiToHex(lzReceiveModuleName);
|
|
1280
|
+
const a = toUleb(245 + modLen).padStart(4, "0");
|
|
1281
|
+
const b = toUleb(442 + modLen).padStart(4, "0");
|
|
1282
|
+
const c = toUleb(602 + modLen).padStart(4, "0");
|
|
1283
|
+
const endpointV2AddressHex = lzV2Utilities.trim0x(this.sdk.accounts.endpoint_v2);
|
|
1284
|
+
const endpointV2CommonAddressHex = lzV2Utilities.trim0x(this.sdk.accounts.endpoint_v2_common);
|
|
1285
|
+
const executorAddressHex = lzV2Utilities.trim0x(this.sdk.accounts.executor);
|
|
1286
|
+
return `a11ceb0b0600000008010012021212032435045906055f6607c501${a}08${b}a00106${c}22000000010002010302040205020603070408010907010000000a00000411070003130000020b03040100060c050600070d070500050e080900010f0a0b01000110050b010004120c0d0003140d0e0008150f0500071610050000020409050909060c0e0a02030a020a020a02030a02020b000108010b00010801010201060a0900010100010e07060c0e0a02030e050a0202060c03010801010900010b00010900010a02010802010803070e0a020308030a020a020b0001080107060c050e0a02030a02030e66756e6769626c655f6173736574066f7074696f6e06766563746f7208656e64706f696e7407627974657333320c6e61746976655f746f6b656e10756e6976657273616c5f636f6e666967086578656375746f72${modLenHex}${modNameHex}064f7074696f6e0d46756e6769626c6541737365740869735f656d707479036569640b6e61746976655f64726f7008776974686472617704736f6d65046e6f6e6507427974657333320a746f5f627974657333320b577261707065644775696409777261705f67756964156c7a5f726563656976655f776974685f76616c75651e656d69745f6c7a5f726563656976655f76616c75655f70726f7669646564${stdAddressHex}${endpointV2AddressHex}${endpointV2CommonAddressHex}${executorAddressHex}${oappAddressHex}0520${oappAddressHex}0000012d0e08380020040c0a000a010a020a03110107000b0811020a070600000000000000002404160a000a07110338010c09051838020c090b090c0a0a010a020a030a04110611070b050b060b0a11080b0007000b010b020b030b040b07110902`;
|
|
1287
|
+
};
|
|
1288
|
+
this.lzComposeWithValueScriptHex = (oappAddressHex, lzComposeModuleName) => {
|
|
1289
|
+
oappAddressHex = lzV2Utilities.trim0x(lzUtilities.padify(oappAddressHex));
|
|
1290
|
+
const stdAddressHex = "0000000000000000000000000000000000000000000000000000000000000001";
|
|
1291
|
+
const modLen = lzComposeModuleName.length;
|
|
1292
|
+
const modLenHex = modLen.toString(16).padStart(2, "0");
|
|
1293
|
+
const modNameHex = asciiToHex(lzComposeModuleName);
|
|
1294
|
+
const a = toUleb(214 + modLen).padStart(4, "0");
|
|
1295
|
+
const b = toUleb(364 + modLen).padStart(4, "0");
|
|
1296
|
+
const c = toUleb(524 + modLen).padStart(4, "0");
|
|
1297
|
+
const endpointV2AddressHex = lzV2Utilities.trim0x(this.sdk.accounts.endpoint_v2);
|
|
1298
|
+
const endpointV2CommonAddressHex = lzV2Utilities.trim0x(this.sdk.accounts.endpoint_v2_common);
|
|
1299
|
+
const executorAddressHex = lzV2Utilities.trim0x(this.sdk.accounts.executor);
|
|
1300
|
+
return `a11ceb0b060000000801000e020e1203202504450405494d079601${a}08${b}a00106${c}2200000001010202030204030504060107070100000008000002090000030d0700040a030400010b05060100010c02060100030e070800020f090a0006100b020005110c02000104020407060c050a020d0a020a0203030b000108010b0001080108020002060c03010801010900010b00010900010a020108030208030d010802050508020a020a020b0001080106060c05050d0a02030e66756e6769626c655f6173736574066f7074696f6e08656e64706f696e7407627974657333320c6e61746976655f746f6b656e086578656375746f72${modLenHex}${modNameHex}064f7074696f6e0d46756e6769626c654173736574135772617070656447756964416e64496e64657808776974686472617704736f6d65046e6f6e6507427974657333320a746f5f6279746573333213777261705f677569645f616e645f696e646578156c7a5f636f6d706f73655f776974685f76616c75651e656d69745f6c7a5f636f6d706f73655f76616c75655f70726f7669646564${stdAddressHex}${endpointV2AddressHex}${endpointV2CommonAddressHex}${executorAddressHex}${oappAddressHex}0520${oappAddressHex}000001210a0606000000000000000024040a0a000a06110038000c07050c38010c070b070c080a0211030a0311040c090a010b090b040b050b0811050b000b0107000b030b020b06110602`;
|
|
1301
|
+
};
|
|
1257
1302
|
this.module = [sdk.accounts.executor?.toString() ?? "0x0", "executor"];
|
|
1258
1303
|
}
|
|
1259
1304
|
/**
|
|
@@ -1749,6 +1794,57 @@ var Executor = class {
|
|
|
1749
1794
|
functionArgumentTypes: ["address"]
|
|
1750
1795
|
};
|
|
1751
1796
|
}
|
|
1797
|
+
async lzReceivePayload(packet, lzReceiveValue, nativeDropOptions) {
|
|
1798
|
+
const { receiver, srcEid, sender, nonce, guid, message } = packet;
|
|
1799
|
+
const module = await this.sdk.LayerzeroModule.Endpoint.getLzReceiveModule(receiver);
|
|
1800
|
+
const lzReceiveByteCode = this.lzReceiveWithValueScriptHex(receiver, module);
|
|
1801
|
+
const functionArguments = [
|
|
1802
|
+
srcEid,
|
|
1803
|
+
lzUtilities.arrayify(sender),
|
|
1804
|
+
BigInt(nonce),
|
|
1805
|
+
lzUtilities.arrayify(guid),
|
|
1806
|
+
lzUtilities.arrayify(message),
|
|
1807
|
+
new Uint8Array(),
|
|
1808
|
+
//unused field
|
|
1809
|
+
lzReceiveValue,
|
|
1810
|
+
nativeDropOptions ?? new Uint8Array()
|
|
1811
|
+
];
|
|
1812
|
+
const functionArgumentTypes = [
|
|
1813
|
+
"u32",
|
|
1814
|
+
"vector<u8>",
|
|
1815
|
+
"u64",
|
|
1816
|
+
"vector<u8>",
|
|
1817
|
+
"vector<u8>",
|
|
1818
|
+
"vector<u8>",
|
|
1819
|
+
"u64",
|
|
1820
|
+
"vector<u8>"
|
|
1821
|
+
];
|
|
1822
|
+
return {
|
|
1823
|
+
function: lzReceiveByteCode,
|
|
1824
|
+
functionArguments,
|
|
1825
|
+
functionArgumentTypes
|
|
1826
|
+
};
|
|
1827
|
+
}
|
|
1828
|
+
async lzComposePayload(composeMessage, lzComposeValue) {
|
|
1829
|
+
const { from, to, guid, index, message } = composeMessage;
|
|
1830
|
+
const module = await this.sdk.LayerzeroModule.Endpoint.getLzComposeModule(to);
|
|
1831
|
+
const lzComposeByteCode = this.lzComposeWithValueScriptHex(to, module);
|
|
1832
|
+
const functionArguments = [
|
|
1833
|
+
from,
|
|
1834
|
+
guid,
|
|
1835
|
+
index,
|
|
1836
|
+
message,
|
|
1837
|
+
new Uint8Array(),
|
|
1838
|
+
//unused field extra Data
|
|
1839
|
+
lzComposeValue
|
|
1840
|
+
];
|
|
1841
|
+
const functionArgumentTypes = ["address", "vector<u8>", "u16", "vector<u8>", "vector<u8>", "u64"];
|
|
1842
|
+
return {
|
|
1843
|
+
function: lzComposeByteCode,
|
|
1844
|
+
functionArguments,
|
|
1845
|
+
functionArgumentTypes
|
|
1846
|
+
};
|
|
1847
|
+
}
|
|
1752
1848
|
};
|
|
1753
1849
|
var initializeExecutorScriptHex = (deployerAddressHex, executorAddressHex, uln302AddressHex) => {
|
|
1754
1850
|
const stdAddressHex = "0000000000000000000000000000000000000000000000000000000000000001";
|
|
@@ -1757,6 +1853,25 @@ var initializeExecutorScriptHex = (deployerAddressHex, executorAddressHex, uln30
|
|
|
1757
1853
|
uln302AddressHex = lzV2Utilities.trim0x(lzUtilities.padify(uln302AddressHex));
|
|
1758
1854
|
return `a11ceb0b060000000701000a030a1a042402052648076e970108850280010685030e000000010102020303040405030400010606070101000708090002080a020003090b0200010507060c0505050a020a0205100c010103030a020a05060c0303030303030a020a050002060c05010c010203060a09000303010a0900010a02010506060c05050a050a050502060c010866726f6d5f62637306766563746f72086578656375746f72066d73676c6962166f626a6563745f636f64655f6465706c6f796d656e74166765745f636f64655f6f626a6563745f7369676e657205736c6963650a746f5f616464726573730a696e697469616c697a652c7365745f776f726b65725f636f6e6669675f666f725f6665655f6c69625f726f7574696e675f6f70745f696e${stdAddressHex}${executorAddressHex}${uln302AddressHex}${deployerAddressHex}030820000000000000000a0501000000017b0b000b0111000c070e070c0e0e0441050c110a1107001906000000000000000021041005140b0e010601000000000000002707010c0d0600000000000000000c0f090c080b1107001a0c0a0a0804250b0f060100000000000000160c0f0527080c080a0f0a0a23043b0a0f0700180c130e040a130b1307001638000c0c0d0d0b0c11024409051e0e0541050c120a1207001906000000000000000021044505490b0e010601000000000000002707010c160600000000000000000c10090c090b1207001a0c0b0a09045a0b10060100000000000000160c10055c080c090a100a0b2304700a100700180c140e050a140b1407001638000c150d160b151102440905530a0e0b020b030b0d0b160b0611030b0e08110402`;
|
|
1759
1855
|
};
|
|
1856
|
+
function asciiToHex(str) {
|
|
1857
|
+
let hex = "";
|
|
1858
|
+
for (let i = 0; i < str.length; i++) {
|
|
1859
|
+
hex += str.charCodeAt(i).toString(16);
|
|
1860
|
+
}
|
|
1861
|
+
return hex;
|
|
1862
|
+
}
|
|
1863
|
+
function toUleb(decimal) {
|
|
1864
|
+
const result = [];
|
|
1865
|
+
do {
|
|
1866
|
+
let byte = decimal & 127;
|
|
1867
|
+
decimal >>>= 7;
|
|
1868
|
+
if (decimal !== 0) {
|
|
1869
|
+
byte |= 128;
|
|
1870
|
+
}
|
|
1871
|
+
result.push(byte.toString(16).padStart(2, "0"));
|
|
1872
|
+
} while (decimal !== 0);
|
|
1873
|
+
return result.join("");
|
|
1874
|
+
}
|
|
1760
1875
|
var EmptyUint8Array = Uint8Array.from([]);
|
|
1761
1876
|
var DefaultSharedDecimals = 6;
|
|
1762
1877
|
var DefaultLocalDecimals = 8;
|
|
@@ -3441,6 +3556,7 @@ var Uln302 = class {
|
|
|
3441
3556
|
this.module = [sdk.accounts.uln_message_lib?.toString() ?? "0x0", "msglib"];
|
|
3442
3557
|
this.adminModule = [sdk.accounts.uln_message_lib?.toString() ?? "0x0", "admin"];
|
|
3443
3558
|
this.uln302StoreModule = [sdk.accounts.uln_message_lib?.toString() ?? "0x0", "uln_302_store"];
|
|
3559
|
+
this.routerCallsModule = [sdk.accounts.uln_message_lib?.toString() ?? "0x0", "router_calls"];
|
|
3444
3560
|
}
|
|
3445
3561
|
/**
|
|
3446
3562
|
* Gets the address of the ULN 302 contract.
|
|
@@ -3580,6 +3696,19 @@ var Uln302 = class {
|
|
|
3580
3696
|
functionArgumentTypes: ["bool"]
|
|
3581
3697
|
};
|
|
3582
3698
|
}
|
|
3699
|
+
async version() {
|
|
3700
|
+
const view = await this.sdk.viewFunction({
|
|
3701
|
+
functionName: `${this.routerCallsModule[0]}::${this.routerCallsModule[1]}::version`,
|
|
3702
|
+
functionArgs: [],
|
|
3703
|
+
functionArgTypes: []
|
|
3704
|
+
});
|
|
3705
|
+
const retval = view[0];
|
|
3706
|
+
return {
|
|
3707
|
+
major: Number(retval[0]),
|
|
3708
|
+
minor: retval[1],
|
|
3709
|
+
endpointVersion: retval[2]
|
|
3710
|
+
};
|
|
3711
|
+
}
|
|
3583
3712
|
/**
|
|
3584
3713
|
* Parses the ULN configuration response.
|
|
3585
3714
|
*
|