@layerzerolabs/lz-aptos-sdk-v1 1.5.19 → 1.5.20

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
@@ -75,24 +75,24 @@ var LAYERZERO_ADDRESS = {
75
75
  [lzDefinitions.Stage.MAINNET]: "0x54ad3d30af77b60d939ae356e6606de9a4da67583f02b962d2d3f2e481484e90",
76
76
  // MAINNET
77
77
  [lzDefinitions.Stage.TESTNET]: "0x1759cc0d3161f1eb79f65847d4feb9d1f74fb79014698a23b16b28b9cd4c37e3",
78
- [lzDefinitions.Stage.SANDBOX]: "0xcdc2c5597e2a96faf08135db560e3846e8c8c5683b0db868f6ad68f143906b3e"
78
+ [lzDefinitions.Stage.SANDBOX]: "0x88cb10d5573e2aa38ed9a92763535ed6828c193567906a56c0f3b9158b1decb7"
79
79
  };
80
80
  var LAYERZERO_APPS_ADDRESS = {
81
81
  [lzDefinitions.Stage.MAINNET]: "0x43d8cad89263e6936921a0adb8d5d49f0e236c229460f01b14dca073114df2b9",
82
82
  [lzDefinitions.Stage.TESTNET]: "0x2f972c173927006c83277b6e6ae38f83482eba560f343d022f145979020d3621",
83
- [lzDefinitions.Stage.SANDBOX]: "0x43d8cad89263e6936921a0adb8d5d49f0e236c229460f01b14dca073114df2b9"
83
+ [lzDefinitions.Stage.SANDBOX]: "0x3afbb2e0e598c6a6b1d694ae3ab6517a6d9941c99f8bb06257e1109b571bb823"
84
84
  };
85
85
  var ORACLE_ADDRESS = {
86
86
  [lzDefinitions.Stage.MAINNET]: "0xc2846ea05319c339b3b52186ceae40b43d4e9cf6c7350336c3eb0b351d9394eb",
87
87
  // MAINNET
88
88
  [lzDefinitions.Stage.TESTNET]: "0x8ab85d94bf34808386b3ce0f9516db74d2b6d2f1166aa48f75ca641f3adb6c63",
89
- [lzDefinitions.Stage.SANDBOX]: "0x38ee7e8bc9d2601ec0934a5d6e23182a266380d87840e5f0850bfeb647297d3a"
89
+ [lzDefinitions.Stage.SANDBOX]: "0x22be7b12e214d4f9f96dc3638fb8d9e3f760e483102c4b48b04a2a656de5a24a"
90
90
  };
91
91
  var ORACLE_SIGNER_ADDRESS = {
92
92
  [lzDefinitions.Stage.MAINNET]: "0x12e12de0af996d9611b0b78928cd9f4cbf50d94d972043cdd829baa77a78929b",
93
93
  // MAINNET
94
94
  [lzDefinitions.Stage.TESTNET]: "0x47a30bcdb5b5bdbf6af883c7325827f3e40b3f52c3538e9e677e68cf0c0db060",
95
- [lzDefinitions.Stage.SANDBOX]: "0x760b1ad2811b7c3e7e04a9dc38520320dc30850fbf001db61c18d1e36221d5c8"
95
+ [lzDefinitions.Stage.SANDBOX]: "0xbccf3169d417448997cb4928e2b8e33e97067871b8564b20c5c2ef6c3a7bf377"
96
96
  };
97
97
  var RELAYER_SIGNER_ADDRESS = {
98
98
  [lzDefinitions.Stage.MAINNET]: "0x1d8727df513fa2a8785d0834e40b34223daff1affc079574082baadb74b66ee4",
@@ -110,19 +110,19 @@ var EXECUTOR_EXT_ADDRESS = {
110
110
  [lzDefinitions.Stage.MAINNET]: "0xd122ac52d43736e0f524a334fc37b6750884559da7ddf1aee0b11b6ae62643d7",
111
111
  // MAINNET
112
112
  [lzDefinitions.Stage.TESTNET]: "0x39942f4bd78e899f162644b5ec5998a19cb6de1ff8b7321070cb75cf96e5cf6c",
113
- [lzDefinitions.Stage.SANDBOX]: ""
113
+ [lzDefinitions.Stage.SANDBOX]: "0xeed8a91797cdfcbe0d33f92b57b76830f1ff6b4613db00f0c33035e31f77c936"
114
114
  };
115
115
  var LAYERZERO_APPS_PUBKEY = {
116
116
  [lzDefinitions.Stage.MAINNET]: "0xf57e5a95ae0e2b5f999ac14abd0ff73daf64e6e7e2a1fad024f2e44422e88d76",
117
117
  // MAINNET
118
118
  [lzDefinitions.Stage.TESTNET]: "0xa6d39a1f522da0298a387032952393b1dd2f88ea75423de05c26792930c60ac0",
119
- [lzDefinitions.Stage.SANDBOX]: "0xf57e5a95ae0e2b5f999ac14abd0ff73daf64e6e7e2a1fad024f2e44422e88d76"
119
+ [lzDefinitions.Stage.SANDBOX]: "0x3378e95c0f5f245208d3b330815eccdf704df522ccdebceabb4310354dd22e06"
120
120
  };
121
121
  var BRIDGE_ADDRESS = {
122
122
  [lzDefinitions.Stage.MAINNET]: "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa",
123
123
  // MAINNET
124
124
  [lzDefinitions.Stage.TESTNET]: "0xec84c05cc40950c86d8a8bed19552f1e8ebb783196bb021c916161d22dc179f7",
125
- [lzDefinitions.Stage.SANDBOX]: "0x808b4ffe04011cd20327a910518b4bff661f73fa907e9fc41ad690f84fa6f83e"
125
+ [lzDefinitions.Stage.SANDBOX]: "0x96a9b4d53a6cb4f4fe2c43a82ab71b52624396f0792b64b5f23a1085690d8edb"
126
126
  };
127
127
 
128
128
  // src/utils.ts
@@ -2122,6 +2122,17 @@ var MsgLibConfig = class {
2122
2122
  }
2123
2123
  };
2124
2124
 
2125
+ // src/modules/uln/index.ts
2126
+ var uln_exports = {};
2127
+ __export(uln_exports, {
2128
+ MsgLibV1_0: () => MsgLibV1_0,
2129
+ PacketEvent: () => PacketEvent,
2130
+ Uln: () => Uln,
2131
+ UlnConfig: () => UlnConfig,
2132
+ UlnReceive: () => UlnReceive,
2133
+ UlnSigner: () => UlnSigner
2134
+ });
2135
+
2125
2136
  // src/modules/uln/msglib_v1_0.ts
2126
2137
  var MsgLibV1_0 = class {
2127
2138
  constructor(sdk) {
@@ -2535,7 +2546,7 @@ var UlnSigner = class {
2535
2546
  }
2536
2547
  };
2537
2548
 
2538
- // src/modules/uln/index.ts
2549
+ // src/modules/uln/uln.ts
2539
2550
  var Uln = class {
2540
2551
  constructor(sdk) {
2541
2552
  this.Receive = new UlnReceive(sdk);
@@ -2569,6 +2580,7 @@ __export(apps_exports, {
2569
2580
  Counter: () => Counter,
2570
2581
  LzApp: () => LzApp,
2571
2582
  MultisigOracle: () => MultisigOracle,
2583
+ MultisigOracleTss: () => MultisigOracleTss,
2572
2584
  OFT: () => OFT,
2573
2585
  Oracle: () => Oracle,
2574
2586
  bridge: () => bridge_exports
@@ -2646,6 +2658,13 @@ var LzApp = class {
2646
2658
  const transaction = this.setRemotePaylaod(remoteChainId, remoteAddress);
2647
2659
  return this.sdk.sendAndConfirmTransaction(signer, transaction);
2648
2660
  }
2661
+ setConfigPayload(uaType, majorVersion, minorVersion, remoteChainId, configType, configBytes) {
2662
+ return {
2663
+ function: `${this.lzApp}::lzapp::set_config`,
2664
+ type_arguments: [uaType],
2665
+ arguments: [majorVersion, minorVersion, remoteChainId, configType, Array.from(configBytes)]
2666
+ };
2667
+ }
2649
2668
  async setConfig(signer, uaType, majorVersion, minorVersion, remoteChainId, configType, configBytes) {
2650
2669
  console.log(`configType: ${configType}, configBytes: ${configBytes}`);
2651
2670
  const transaction = {
@@ -3205,17 +3224,33 @@ var Counter = class {
3205
3224
  const { i } = resource.data;
3206
3225
  return BigInt(i);
3207
3226
  }
3208
- async createCounter(signer, i) {
3209
- const transaction = {
3227
+ createCounterPayload(i) {
3228
+ return {
3210
3229
  function: `${this.address}::counter::create_counter`,
3211
3230
  type_arguments: [],
3212
3231
  arguments: [i]
3213
3232
  };
3233
+ }
3234
+ async createCounter(signer, i) {
3235
+ const transaction = this.createCounterPayload(i);
3214
3236
  return this.sdk.sendAndConfirmTransaction(signer, transaction);
3215
3237
  }
3238
+ setRemotePayload(remoteChainId, remoteAddress) {
3239
+ return this.lzApp.setRemotePaylaod(remoteChainId, remoteAddress);
3240
+ }
3216
3241
  async setRemote(signer, remoteChainId, remoteAddress) {
3217
3242
  return this.lzApp.setRemote(signer, remoteChainId, remoteAddress);
3218
3243
  }
3244
+ setAppConfigPayload(majorVersion, minorVersion, remoteChainId, configType, configBytes) {
3245
+ return this.lzApp.setConfigPayload(
3246
+ this.uaType,
3247
+ majorVersion,
3248
+ minorVersion,
3249
+ remoteChainId,
3250
+ configType,
3251
+ configBytes
3252
+ );
3253
+ }
3219
3254
  async setAppConfig(signer, majorVersion, minorVersion, remoteChainId, configType, configBytes) {
3220
3255
  console.log(`configType: ${configType}, configBytes: ${configBytes}`);
3221
3256
  return this.lzApp.setConfig(
@@ -3231,6 +3266,13 @@ var Counter = class {
3231
3266
  async setAppConfigBundle(signer, majorVersion, minorVersion, remoteChainId, config) {
3232
3267
  await this.lzApp.setConfigBundle(signer, this.uaType, majorVersion, minorVersion, remoteChainId, config);
3233
3268
  }
3269
+ sendToRemotePayload(remoteChainId, fee, adapterParams) {
3270
+ return {
3271
+ function: `${this.address}::counter::send_to_remote`,
3272
+ type_arguments: [],
3273
+ arguments: [remoteChainId, fee, Array.from(adapterParams)]
3274
+ };
3275
+ }
3234
3276
  async sendToRemote(signer, remoteChainId, fee, adapterParams) {
3235
3277
  const transaction = {
3236
3278
  function: `${this.address}::counter::send_to_remote`,
@@ -3384,6 +3426,193 @@ var MultisigOracle = class {
3384
3426
  return fullAddress(resource_addr).toString();
3385
3427
  }
3386
3428
  };
3429
+ var MultisigOracleTss = class {
3430
+ constructor(sdk, address) {
3431
+ this.sdk = sdk;
3432
+ this.address = address;
3433
+ this.module = `${this.address}::oracle`;
3434
+ this.moduleName = "oracle::oracle";
3435
+ }
3436
+ // Validator Functions
3437
+ getProposePayload(hash, confirmations, expiration, signatures) {
3438
+ return {
3439
+ function: `${this.module}::mso_propose`,
3440
+ type_arguments: [],
3441
+ arguments: [Array.from(hash), confirmations, expiration, Array.from(signatures)]
3442
+ };
3443
+ }
3444
+ async propose(signer, hash, confirmations, expiration, signatures) {
3445
+ const transaction = this.getProposePayload(hash, confirmations, expiration, signatures);
3446
+ return this.sdk.sendAndConfirmTransaction(signer, transaction);
3447
+ }
3448
+ getSetValidatorPayload(validator, active, expiration, signatures) {
3449
+ return {
3450
+ function: `${this.module}::mso_set_validator`,
3451
+ type_arguments: [],
3452
+ arguments: [Array.from(validator), active, expiration, Array.from(signatures)]
3453
+ };
3454
+ }
3455
+ async setValidator(signer, validator, active, expiration, signatures) {
3456
+ const transaction = this.getSetValidatorPayload(validator, active, expiration, signatures);
3457
+ return this.sdk.sendAndConfirmTransaction(signer, transaction);
3458
+ }
3459
+ getSetThresholdPayload(threshold, expiration, signatures) {
3460
+ return {
3461
+ function: `${this.module}::mso_set_threshold`,
3462
+ type_arguments: [],
3463
+ arguments: [threshold, expiration, Array.from(signatures)]
3464
+ };
3465
+ }
3466
+ async setThreshold(signer, threshold, expiration, signatures) {
3467
+ const transaction = this.getSetThresholdPayload(threshold, expiration, signatures);
3468
+ return this.sdk.sendAndConfirmTransaction(signer, transaction);
3469
+ }
3470
+ getSetAdminPayload(candidate, active, expiration, signatures) {
3471
+ return {
3472
+ function: `${this.module}::mso_set_admin`,
3473
+ type_arguments: [],
3474
+ arguments: [candidate, active, expiration, Array.from(signatures)]
3475
+ };
3476
+ }
3477
+ async setAdmin(signer, candidate, active, expiration, signatures) {
3478
+ const transaction = this.getSetAdminPayload(candidate, active, expiration, signatures);
3479
+ return this.sdk.sendAndConfirmTransaction(signer, transaction);
3480
+ }
3481
+ getAllowlistPayload(ua, expiration, signatures) {
3482
+ return {
3483
+ function: `${this.module}::mso_allowlist`,
3484
+ type_arguments: [],
3485
+ arguments: [ua, expiration, Array.from(signatures)]
3486
+ };
3487
+ }
3488
+ async allowlist(signer, ua, expiration, signatures) {
3489
+ const transaction = this.getAllowlistPayload(ua, expiration, signatures);
3490
+ return this.sdk.sendAndConfirmTransaction(signer, transaction);
3491
+ }
3492
+ getDenylistPayload(ua, expiration, signatures) {
3493
+ return {
3494
+ function: `${this.module}::mso_denylist`,
3495
+ type_arguments: [],
3496
+ arguments: [ua, expiration, Array.from(signatures)]
3497
+ };
3498
+ }
3499
+ async denylist(signer, ua, expiration, signatures) {
3500
+ const transaction = this.getDenylistPayload(ua, expiration, signatures);
3501
+ return this.sdk.sendAndConfirmTransaction(signer, transaction);
3502
+ }
3503
+ // Admin Functions
3504
+ getSetFeePayload(remoteChainId, baseFee) {
3505
+ return {
3506
+ function: `${this.module}::mso_set_fee`,
3507
+ type_arguments: [],
3508
+ arguments: [remoteChainId, baseFee]
3509
+ };
3510
+ }
3511
+ async setFee(signer, remoteChainId, baseFee) {
3512
+ const transaction = this.getSetFeePayload(remoteChainId, baseFee);
3513
+ return this.sdk.sendAndConfirmTransaction(signer, transaction);
3514
+ }
3515
+ getWithdrawFeePayload(receiver, amount) {
3516
+ return {
3517
+ function: `${this.module}::mso_withdraw_fee`,
3518
+ type_arguments: [],
3519
+ arguments: [receiver, amount]
3520
+ };
3521
+ }
3522
+ async withdrawFee(signer, receiver, amount) {
3523
+ const transaction = this.getWithdrawFeePayload(receiver, amount);
3524
+ return this.sdk.sendAndConfirmTransaction(signer, transaction);
3525
+ }
3526
+ // View Functions
3527
+ async getAdmins() {
3528
+ const resource = await this.sdk.client.getAccountResource(
3529
+ this.address,
3530
+ `${this.module}::MsoConfig`
3531
+ );
3532
+ return resource.data.admins;
3533
+ }
3534
+ async getValidators() {
3535
+ const resource = await this.sdk.client.getAccountResource(
3536
+ this.address,
3537
+ `${this.module}::MsoConfig`
3538
+ );
3539
+ return resource.data.validators;
3540
+ }
3541
+ async getThreshold() {
3542
+ const resource = await this.sdk.client.getAccountResource(
3543
+ this.address,
3544
+ `${this.module}::MsoConfig`
3545
+ );
3546
+ return parseInt(resource.data.threshold);
3547
+ }
3548
+ async getResourceAddress() {
3549
+ const resource = await this.sdk.client.getAccountResource(this.address, `${this.module}::Config`);
3550
+ const { resource_addr } = resource.data;
3551
+ return fullAddress(resource_addr).toString();
3552
+ }
3553
+ async isAdmin(account) {
3554
+ const admins = await this.getAdmins();
3555
+ const _admins = admins.map((a) => a.toString().toLowerCase());
3556
+ const acc = aptos2__namespace.HexString.ensure(account).toShortString();
3557
+ return _admins.includes(acc.toString().toLowerCase());
3558
+ }
3559
+ async isValidator(validator) {
3560
+ const validators = await this.getValidators();
3561
+ const _validators = validators.map((v) => v.toString().toLowerCase());
3562
+ const val = aptos2__namespace.HexString.ensure(validator);
3563
+ return _validators.includes(val.toString().toLowerCase());
3564
+ }
3565
+ // Hashing functions
3566
+ hashPropose(hash, blockConfirmation, expiration) {
3567
+ const encoded_data = new extendedBuffer.ExtendedBuffer();
3568
+ encoded_data.writeBuffer(Buffer.from(stringToUint8Array(getAptosFunctionSignature("propose"))));
3569
+ encoded_data.writeBuffer(Buffer.from(stringToUint8Array(hash.toString())));
3570
+ encoded_data.writeBuffer(new BN__default.default(blockConfirmation.toString()).toArrayLike(Buffer, "be", 8));
3571
+ encoded_data.writeBuffer(new BN__default.default(expiration.toString()).toArrayLike(Buffer, "be", 8));
3572
+ return keccak256Hash(encoded_data.buffer.toString("hex"));
3573
+ }
3574
+ hashSetValidator(validator, active, expiration) {
3575
+ const encoded_data = new extendedBuffer.ExtendedBuffer();
3576
+ encoded_data.writeBuffer(Buffer.from(stringToUint8Array(getAptosFunctionSignature("set_validator"))));
3577
+ encoded_data.writeBuffer(Buffer.from(stringToUint8Array(validator.toString())));
3578
+ encoded_data.writeUInt8(active ? 1 : 0);
3579
+ encoded_data.writeBuffer(new BN__default.default(expiration.toString()).toArrayLike(Buffer, "be", 8));
3580
+ return keccak256Hash(encoded_data.buffer.toString("hex"));
3581
+ }
3582
+ hashSetThreshold(threshold, expiration) {
3583
+ const encoded_data = new extendedBuffer.ExtendedBuffer();
3584
+ encoded_data.writeBuffer(Buffer.from(stringToUint8Array(getAptosFunctionSignature("set_threshold"))));
3585
+ encoded_data.writeBuffer(new BN__default.default(threshold).toArrayLike(Buffer, "be", 8));
3586
+ encoded_data.writeBuffer(new BN__default.default(expiration.toString()).toArrayLike(Buffer, "be", 8));
3587
+ return keccak256Hash(encoded_data.buffer.toString("hex"));
3588
+ }
3589
+ hashAllowlist(ua, expiration) {
3590
+ const encoded_data = new extendedBuffer.ExtendedBuffer();
3591
+ encoded_data.writeBuffer(Buffer.from(stringToUint8Array(getAptosFunctionSignature("allowlist"))));
3592
+ encoded_data.writeBuffer(Buffer.from(stringToUint8Array(ua.toString())));
3593
+ encoded_data.writeBuffer(new BN__default.default(expiration.toString()).toArrayLike(Buffer, "be", 8));
3594
+ return keccak256Hash(encoded_data.buffer.toString("hex"));
3595
+ }
3596
+ hashDenylist(ua, expiration) {
3597
+ const encoded_data = new extendedBuffer.ExtendedBuffer();
3598
+ encoded_data.writeBuffer(Buffer.from(stringToUint8Array(getAptosFunctionSignature("denylist"))));
3599
+ encoded_data.writeBuffer(Buffer.from(stringToUint8Array(ua.toString())));
3600
+ encoded_data.writeBuffer(new BN__default.default(expiration.toString()).toArrayLike(Buffer, "be", 8));
3601
+ return keccak256Hash(encoded_data.buffer.toString("hex"));
3602
+ }
3603
+ };
3604
+ function getAptosFunctionSignature(funcName) {
3605
+ const encoded_data = new extendedBuffer.ExtendedBuffer();
3606
+ const funcNameHexStr = Buffer.from(funcName).toString("hex");
3607
+ const funcNameBcs = aptos2__namespace.BCS.bcsSerializeBytes(stringToUint8Array(funcNameHexStr));
3608
+ encoded_data.writeBuffer(Buffer.from(funcNameBcs));
3609
+ return utils.bytesToHex(sha3.keccak_256(encoded_data.buffer)).slice(0, 8);
3610
+ }
3611
+ function keccak256Hash(data) {
3612
+ const encoded_data = new extendedBuffer.ExtendedBuffer();
3613
+ encoded_data.writeBuffer(Buffer.from(stringToUint8Array(data)));
3614
+ return utils.bytesToHex(sha3.keccak_256(encoded_data.buffer));
3615
+ }
3387
3616
  var OFT = class {
3388
3617
  constructor(sdk) {
3389
3618
  this.SEND_PAYLOAD_LENGTH = 41;
@@ -3896,6 +4125,7 @@ exports.SDK = SDK;
3896
4125
  exports.apps = apps_exports;
3897
4126
  exports.constants = constants_exports;
3898
4127
  exports.types = types_exports;
4128
+ exports.uln = uln_exports;
3899
4129
  exports.utils = utils_exports;
3900
4130
  //# sourceMappingURL=out.js.map
3901
4131
  //# sourceMappingURL=index.cjs.map