@layerzerolabs/lz-movevm-sdk-v2 3.0.18 → 3.0.19-movment.0

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/dist/index.cjs CHANGED
@@ -381,20 +381,54 @@ var DvnWorker = class {
381
381
  * @param {string[]} msglibs - The list of message libraries.
382
382
  * @param {string} feeLib - The fee library address.
383
383
  * @param {string} depositAddress - The deposit address. Defaults to the DVN address.
384
- * @returns {InputEntryFunctionData} The input entry function data, used to build the transaction.
385
- */
386
- createInitializeDVNPayload(admins, dvnSigners, quorum, msglibs, feeLib, depositAddress) {
384
+ * @returns {Promise<InputEntryFunctionData>} The input entry function data, used to build the transaction.
385
+ */
386
+ async createInitializeDVNPayload(admins, dvnSigners, quorum, msglibs, feeLib, depositAddress) {
387
+ let functionIdOrBytecode = `${this.module[0]}::${this.module[1]}::initialize`;
388
+ let functionArguments = [
389
+ depositAddress ?? this.module[0],
390
+ admins,
391
+ dvnSigners,
392
+ quorum,
393
+ msglibs,
394
+ feeLib
395
+ ];
396
+ let functionArgumentTypes = [
397
+ "address",
398
+ "vector<address>",
399
+ "vector<vector<u8>>",
400
+ "u64",
401
+ "vector<address>",
402
+ "address"
403
+ ];
404
+ if (await this.sdk.isObjectAddress(this.module[0])) {
405
+ functionIdOrBytecode = initializeDvnScriptHex(
406
+ this.sdk.accounts.deploy_to_object,
407
+ this.module[0],
408
+ this.sdk.accounts.uln_message_lib
409
+ );
410
+ const adminsU8Array = new Uint8Array(
411
+ admins.flatMap((admin) => Array.from(Buffer.from(lzV2Utilities.trim0x(lzUtilities.padify(admin)), "hex")))
412
+ );
413
+ const msgLibsU8Array = new Uint8Array(
414
+ msglibs.flatMap((msgLib) => Array.from(Buffer.from(lzV2Utilities.trim0x(lzUtilities.padify(msgLib)), "hex")))
415
+ );
416
+ const dvnSignersU8Array = new Uint8Array(dvnSigners.flatMap((signer) => Array.from(signer)));
417
+ functionArguments = [
418
+ this.module[0],
419
+ depositAddress ?? this.module[0],
420
+ adminsU8Array,
421
+ dvnSignersU8Array,
422
+ quorum,
423
+ msgLibsU8Array,
424
+ feeLib
425
+ ];
426
+ functionArgumentTypes = ["address", "address", "vector<u8>", "vector<u8>", "u64", "vector<u8>", "address"];
427
+ }
387
428
  return {
388
- function: `${this.module[0]}::${this.module[1]}::initialize`,
389
- functionArguments: [depositAddress ?? this.module[0], admins, dvnSigners, quorum, msglibs, feeLib],
390
- functionArgumentTypes: [
391
- "address",
392
- "vector<address>",
393
- "vector<vector<u8>>",
394
- "u64",
395
- "vector<address>",
396
- "address"
397
- ]
429
+ function: functionIdOrBytecode,
430
+ functionArguments,
431
+ functionArgumentTypes
398
432
  };
399
433
  }
400
434
  /**
@@ -552,6 +586,13 @@ var DvnWorker = class {
552
586
  };
553
587
  }
554
588
  };
589
+ var initializeDvnScriptHex = (deployerAddressHex, dvnAddressHex, uln302AddressHex) => {
590
+ const stdAddressHex = "0000000000000000000000000000000000000000000000000000000000000001";
591
+ deployerAddressHex = lzV2Utilities.trim0x(lzUtilities.padify(deployerAddressHex));
592
+ dvnAddressHex = lzV2Utilities.trim0x(lzUtilities.padify(dvnAddressHex));
593
+ uln302AddressHex = lzV2Utilities.trim0x(lzUtilities.padify(uln302AddressHex));
594
+ return `a11ceb0b060000000701000a030a1a042402052657077d9201088f028001068f031d000000010102020303040405030400010606070101000708090002080a020003090b0200010508060c05050a020a02030a0205170c0101010303030a020a05060c0a020a0a020303030303030303030a020a050002060c05010c010203060a09000303010a0900010a02010507060c050a050a0a02030a050502060c010866726f6d5f62637306766563746f720364766e066d73676c6962166f626a6563745f636f64655f6465706c6f796d656e74166765745f636f64655f6f626a6563745f7369676e657205736c6963650a746f5f616464726573730a696e697469616c697a652c7365745f776f726b65725f636f6e6669675f666f725f6665655f6c69625f726f7574696e675f6f70745f696e${stdAddressHex}${dvnAddressHex}${uln302AddressHex}${deployerAddressHex}03082000000000000000030840000000000000000a0501000a0a020100000001b0010b000b0111000c080e080c110e0341050c170a1707001906000000000000000021041005140b11010601000000000000002707020c100600000000000000000c14090c090b1707001a0c0c0a0904250b14060100000000000000160c140527080c090a140a0c23043b0a140700180c1a0e030a1a0b1a07001638000c0f0d100b0f11024409051e0e0641050c180a1807001906000000000000000021044505490b11010601000000000000002707020c1e0600000000000000000c15090c0a0b1807001a0c0e0a0a045a0b15060100000000000000160c15055c080c0a0a150a0e2304700a150700180c1c0e060a1c0b1c07001638000c1d0d1e0b1d1102440905530e0441050c190a1907011906000000000000000021047a057e0b11010601000000000000002707030c130600000000000000000c16090c0b0b1907011a0c0d0a0b048f010b16060100000000000000160c16059101080c0b0a160a0d2304a4010a160701180c1b0e040a1b0b1b07011638000c120d130b1244080588010a110b020b100b130b050b1e0b0711030b1108110402`;
595
+ };
555
596
  var Endpoint = class {
556
597
  /**
557
598
  * Creates an instance of Endpoint.
@@ -1180,13 +1221,44 @@ var Executor = class {
1180
1221
  * @param {string[]} msgLibs - The list of message libraries.
1181
1222
  * @param {string} feeLib - The fee library address.
1182
1223
  * @param {string} [depositAddress] - The deposit address. Defaults to the executor address.
1183
- * @returns {InputEntryFunctionData} The input entry function data, used to build the transaction.
1184
- */
1185
- createInitExecutorPayload(roleAdmin, admins, msgLibs, feeLib, depositAddress) {
1224
+ * @returns {Promise<InputEntryFunctionData>} The input entry function data, used to build the transaction.
1225
+ */
1226
+ async createInitExecutorPayload(roleAdmin, admins, msgLibs, feeLib, depositAddress) {
1227
+ let functionIdOrBytecode = `${this.module[0]}::${this.module[1]}::initialize`;
1228
+ let functionArgumentTypes = ["address", "address", "vector<address>", "vector<address>", "address"];
1229
+ let functionArguments = [
1230
+ depositAddress ?? this.module[0],
1231
+ roleAdmin,
1232
+ admins,
1233
+ msgLibs,
1234
+ feeLib
1235
+ ];
1236
+ if (await this.sdk.isObjectAddress(this.module[0])) {
1237
+ functionIdOrBytecode = initializeExecutorScriptHex(
1238
+ this.sdk.accounts.deploy_to_object,
1239
+ this.module[0],
1240
+ this.sdk.accounts.uln_message_lib
1241
+ );
1242
+ functionArgumentTypes = ["address", "address", "address", "vector<u8>", "vector<u8>", "address"];
1243
+ const adminsU8Array = new Uint8Array(
1244
+ admins.flatMap((admin) => Array.from(Buffer.from(lzV2Utilities.trim0x(admin), "hex")))
1245
+ );
1246
+ const msgLibsU8Array = new Uint8Array(
1247
+ msgLibs.flatMap((msgLib) => Array.from(Buffer.from(lzV2Utilities.trim0x(msgLib), "hex")))
1248
+ );
1249
+ functionArguments = [
1250
+ this.module[0],
1251
+ depositAddress ?? this.module[0],
1252
+ roleAdmin,
1253
+ adminsU8Array,
1254
+ msgLibsU8Array,
1255
+ feeLib
1256
+ ];
1257
+ }
1186
1258
  return {
1187
- function: `${this.module[0]}::${this.module[1]}::initialize`,
1188
- functionArguments: [depositAddress ?? this.module[0], roleAdmin, admins, msgLibs, feeLib],
1189
- functionArgumentTypes: ["address", "address", "vector<address>", "vector<address>", "address"]
1259
+ function: functionIdOrBytecode,
1260
+ functionArguments,
1261
+ functionArgumentTypes
1190
1262
  };
1191
1263
  }
1192
1264
  /**
@@ -1202,11 +1274,42 @@ var Executor = class {
1202
1274
  * @returns {Promise<TransactionResponse>} The transaction response.
1203
1275
  */
1204
1276
  async initialize(signer, roleAdmin, admins, msgLibs, feeLib, depositAddress, gasOptions) {
1277
+ let functionIdOrBytecode = `${this.module[0]}::${this.module[1]}::initialize`;
1278
+ let functionArgumentTypes = ["address", "address", "vector<address>", "vector<address>", "address"];
1279
+ let functionArguments = [
1280
+ depositAddress ?? this.module[0],
1281
+ roleAdmin,
1282
+ admins,
1283
+ msgLibs,
1284
+ feeLib
1285
+ ];
1286
+ if (await this.sdk.isObjectAddress(this.module[0])) {
1287
+ functionIdOrBytecode = initializeExecutorScriptHex(
1288
+ this.sdk.accounts.deploy_to_object,
1289
+ this.module[0],
1290
+ this.sdk.accounts.uln_message_lib
1291
+ );
1292
+ functionArgumentTypes = ["address", "address", "address", "vector<u8>", "vector<u8>", "address"];
1293
+ const adminsU8Array = new Uint8Array(
1294
+ admins.flatMap((admin) => Array.from(Buffer.from(lzV2Utilities.trim0x(lzUtilities.padify(admin)), "hex")))
1295
+ );
1296
+ const msgLibsU8Array = new Uint8Array(
1297
+ msgLibs.flatMap((msgLib) => Array.from(Buffer.from(lzV2Utilities.trim0x(lzUtilities.padify(msgLib)), "hex")))
1298
+ );
1299
+ functionArguments = [
1300
+ this.module[0],
1301
+ depositAddress ?? this.module[0],
1302
+ roleAdmin,
1303
+ adminsU8Array,
1304
+ msgLibsU8Array,
1305
+ feeLib
1306
+ ];
1307
+ }
1205
1308
  return this.sdk.sendAndConfirmTransaction(
1206
1309
  signer,
1207
- `${this.module[0]}::${this.module[1]}::initialize`,
1208
- [depositAddress ?? this.module[0], roleAdmin, admins, msgLibs, feeLib],
1209
- ["address", "address", "vector<address>", "vector<address>", "address"],
1310
+ functionIdOrBytecode,
1311
+ functionArguments,
1312
+ functionArgumentTypes,
1210
1313
  gasOptions
1211
1314
  );
1212
1315
  }
@@ -1595,6 +1698,13 @@ var Executor = class {
1595
1698
  };
1596
1699
  }
1597
1700
  };
1701
+ var initializeExecutorScriptHex = (deployerAddressHex, executorAddressHex, uln302AddressHex) => {
1702
+ const stdAddressHex = "0000000000000000000000000000000000000000000000000000000000000001";
1703
+ deployerAddressHex = lzV2Utilities.trim0x(lzUtilities.padify(deployerAddressHex));
1704
+ executorAddressHex = lzV2Utilities.trim0x(lzUtilities.padify(executorAddressHex));
1705
+ uln302AddressHex = lzV2Utilities.trim0x(lzUtilities.padify(uln302AddressHex));
1706
+ return `a11ceb0b060000000701000a030a1a042402052648076e970108850280010685030e000000010102020303040405030400010606070101000708090002080a020003090b0200010507060c0505050a020a0205100c010103030a020a05060c0303030303030a020a050002060c05010c010203060a09000303010a0900010a02010506060c05050a050a050502060c010866726f6d5f62637306766563746f72086578656375746f72066d73676c6962166f626a6563745f636f64655f6465706c6f796d656e74166765745f636f64655f6f626a6563745f7369676e657205736c6963650a746f5f616464726573730a696e697469616c697a652c7365745f776f726b65725f636f6e6669675f666f725f6665655f6c69625f726f7574696e675f6f70745f696e${stdAddressHex}${executorAddressHex}${uln302AddressHex}${deployerAddressHex}030820000000000000000a0501000000017b0b000b0111000c070e070c0e0e0441050c110a1107001906000000000000000021041005140b0e010601000000000000002707010c0d0600000000000000000c0f090c080b1107001a0c0a0a0804250b0f060100000000000000160c0f0527080c080a0f0a0a23043b0a0f0700180c130e040a130b1307001638000c0c0d0d0b0c11024409051e0e0441050c120a1207001906000000000000000021044505490b0e010601000000000000002707010c160600000000000000000c10090c090b1207001a0c0b0a09045a0b10060100000000000000160c10055c080c090a100a0b2304700a100700180c140e050a140b1407001638000c150d160b151102440905530a0e0b020b030b0d0b160b0611030b0e08110402`;
1707
+ };
1598
1708
  var EmptyUint8Array = Uint8Array.from([]);
1599
1709
  var DefaultSharedDecimals = 6;
1600
1710
  var DefaultLocalDecimals = 8;