@layerzerolabs/lz-aptos-sdk-v1 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.
Files changed (40) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/deployments/aptos-mainnet/Common.json +9 -0
  3. package/deployments/aptos-mainnet/Endpoint.json +9 -0
  4. package/deployments/aptos-mainnet/ExecutorExt.json +9 -0
  5. package/deployments/aptos-mainnet/ExecutorV2.json +9 -0
  6. package/deployments/aptos-mainnet/MsgLibV1.json +9 -0
  7. package/deployments/aptos-mainnet/MsgLibV2.json +9 -0
  8. package/deployments/aptos-mainnet/Zro.json +9 -0
  9. package/deployments/aptos-sandbox-local/Common.json +12 -0
  10. package/deployments/aptos-sandbox-local/Endpoint.json +12 -0
  11. package/deployments/aptos-sandbox-local/ExecutorAuth.json +12 -0
  12. package/deployments/aptos-sandbox-local/ExecutorExt.json +12 -0
  13. package/deployments/aptos-sandbox-local/ExecutorV2.json +12 -0
  14. package/deployments/aptos-sandbox-local/MsgLibV1.json +12 -0
  15. package/deployments/aptos-sandbox-local/MsgLibV2.json +12 -0
  16. package/deployments/aptos-sandbox-local/MsgLibV21.json +12 -0
  17. package/deployments/aptos-sandbox-local/MsgLibV3.json +12 -0
  18. package/deployments/aptos-sandbox-local/MsglibAuth.json +12 -0
  19. package/deployments/aptos-sandbox-local/Zro.json +12 -0
  20. package/deployments/aptos-sandbox-local/executor_v2_register.json +12 -0
  21. package/deployments/aptos-sandbox-local/fa_converter.json +12 -0
  22. package/deployments/aptos-sandbox-local/layerzero_view.json +12 -0
  23. package/deployments/aptos-sandbox-local/msglib_routing_helper.json +12 -0
  24. package/deployments/aptos-sandbox-local/packet_converter.json +12 -0
  25. package/deployments/aptos-sandbox-local/uln_301.json +12 -0
  26. package/deployments/aptos-sandbox-local/uln_301_receive_helper.json +12 -0
  27. package/deployments/aptos-testnet/Common.json +9 -0
  28. package/deployments/aptos-testnet/Endpoint.json +9 -0
  29. package/deployments/aptos-testnet/ExecutorExt.json +9 -0
  30. package/deployments/aptos-testnet/ExecutorV2.json +9 -0
  31. package/deployments/aptos-testnet/MsgLibV1.json +9 -0
  32. package/deployments/aptos-testnet/MsgLibV2.json +9 -0
  33. package/deployments/aptos-testnet/Zro.json +9 -0
  34. package/dist/index.cjs +648 -48
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +290 -17
  37. package/dist/index.d.ts +290 -17
  38. package/dist/index.mjs +648 -48
  39. package/dist/index.mjs.map +1 -1
  40. package/package.json +9 -4
package/dist/index.mjs CHANGED
@@ -8,6 +8,7 @@ import { bytesToHex, hexToBytes } from '@noble/hashes/utils';
8
8
  import * as bip39 from 'bip39';
9
9
  import BN from 'bn.js';
10
10
  import { ExtendedBuffer } from 'extended-buffer';
11
+ import { types } from '@layerzerolabs/lz-movevm-sdk-v2';
11
12
 
12
13
  var __defProp = Object.defineProperty;
13
14
  var __export = (target, all) => {
@@ -23,15 +24,20 @@ __export(constants_exports, {
23
24
  COUNTER_ADDRESS: () => COUNTER_ADDRESS,
24
25
  EXECUTOR_ADDRESS: () => EXECUTOR_ADDRESS,
25
26
  EXECUTOR_EXT_ADDRESS: () => EXECUTOR_EXT_ADDRESS,
27
+ EXECUTOR_V2_ADDRESS: () => EXECUTOR_V2_ADDRESS,
26
28
  FAUCET_URL: () => FAUCET_URL,
27
29
  LAYERZERO_ADDRESS: () => LAYERZERO_ADDRESS,
28
30
  LAYERZERO_APPS_ADDRESS: () => LAYERZERO_APPS_ADDRESS,
29
31
  LAYERZERO_APPS_PUBKEY: () => LAYERZERO_APPS_PUBKEY,
32
+ LAYERZERO_VIEW_ADDRESS: () => LAYERZERO_VIEW_ADDRESS,
33
+ MSGLIB_ROUTING_HELPER_ADDRESS: () => MSGLIB_ROUTING_HELPER_ADDRESS,
30
34
  NODE_URL: () => NODE_URL,
31
35
  OFT_PRECRIME_ADDRESS: () => OFT_PRECRIME_ADDRESS,
32
36
  ORACLE_ADDRESS: () => ORACLE_ADDRESS,
33
37
  ORACLE_SIGNER_ADDRESS: () => ORACLE_SIGNER_ADDRESS,
34
- RELAYER_SIGNER_ADDRESS: () => RELAYER_SIGNER_ADDRESS
38
+ RELAYER_SIGNER_ADDRESS: () => RELAYER_SIGNER_ADDRESS,
39
+ ULN_301_ADDRESS: () => ULN_301_ADDRESS,
40
+ ULN_301_RECEIVE_HELPER_ADDRESS: () => ULN_301_RECEIVE_HELPER_ADDRESS
35
41
  });
36
42
  var NODE_URL = {
37
43
  [Environment.MAINNET]: "https://mainnet.aptoslabs.com/v1",
@@ -54,6 +60,21 @@ var LAYERZERO_ADDRESS = {
54
60
  [Stage.SANDBOX]: "0xf2e1e034475dc0439487dd09dfc3950c462f731599e53a6b015dd85502352e68"
55
61
  //TODO(Ethan) double check
56
62
  };
63
+ var ULN_301_ADDRESS = {
64
+ [Stage.MAINNET]: "",
65
+ [Stage.TESTNET]: "",
66
+ [Stage.SANDBOX]: "0x1050fe8b6900532a0fc312c1635f3e0bfb1153cc9ef55bc190ce48f0db471514"
67
+ };
68
+ var ULN_301_RECEIVE_HELPER_ADDRESS = {
69
+ [Stage.MAINNET]: "",
70
+ [Stage.TESTNET]: "",
71
+ [Stage.SANDBOX]: "0x4198b568d9044d0165f8c357e88a7b12dd76fecd3016e7726e5512f668164be9"
72
+ };
73
+ var MSGLIB_ROUTING_HELPER_ADDRESS = {
74
+ [Stage.MAINNET]: "",
75
+ [Stage.TESTNET]: "",
76
+ [Stage.SANDBOX]: "0xda0ee3324a739cf664fedfba5174fbc6a11ffbb669b6ead9dc366415b9a37114"
77
+ };
57
78
  var LAYERZERO_APPS_ADDRESS = {
58
79
  [Stage.MAINNET]: "0x43d8cad89263e6936921a0adb8d5d49f0e236c229460f01b14dca073114df2b9",
59
80
  [Stage.TESTNET]: "0x2f972c173927006c83277b6e6ae38f83482eba560f343d022f145979020d3621",
@@ -95,6 +116,12 @@ var EXECUTOR_EXT_ADDRESS = {
95
116
  [Stage.SANDBOX]: "0xd8f318cab62a1142e1cd60f3f090331becc9a462a1a85180de8a99e2a27eadc0"
96
117
  //TODO(Ethan) double check
97
118
  };
119
+ var EXECUTOR_V2_ADDRESS = {
120
+ [Stage.MAINNET]: "",
121
+ // MAINNET
122
+ [Stage.TESTNET]: "",
123
+ [Stage.SANDBOX]: "0xf2e1e034475dc0439487dd09dfc3950c462f731599e53a6b015dd85502352e68"
124
+ };
98
125
  var LAYERZERO_APPS_PUBKEY = {
99
126
  [Stage.MAINNET]: "0xf57e5a95ae0e2b5f999ac14abd0ff73daf64e6e7e2a1fad024f2e44422e88d76",
100
127
  // MAINNET
@@ -127,6 +154,11 @@ var COUNTER_ADDRESS = {
127
154
  // [Stage.SANDBOX]: '0x9584ff2b8ec928fc82889c979a0d443ebccde12a0c65840bd302f6254e14c004',
128
155
  [Stage.SANDBOX]: "0x2b249feeed4e30deb84f92c0960baf68652757ce2d7d672d566fdb9a34f8720e"
129
156
  };
157
+ var LAYERZERO_VIEW_ADDRESS = {
158
+ [Stage.MAINNET]: "",
159
+ [Stage.TESTNET]: "",
160
+ [Stage.SANDBOX]: "0xaebc3f4f27559ea378f21d75b43236ea0f8038a2c171224eb01be7a7dfe918ab"
161
+ };
130
162
 
131
163
  // src/utils.ts
132
164
  var utils_exports = {};
@@ -816,6 +848,7 @@ var Endpoint = class {
816
848
  this.sdk = sdk;
817
849
  this.module = `${sdk.accounts.layerzero}::endpoint`;
818
850
  this.moduleName = "layerzero::endpoint";
851
+ this.viewModule = `${sdk.accounts.view}::endpoint_view`;
819
852
  }
820
853
  /**
821
854
  * The module name.
@@ -825,6 +858,10 @@ var Endpoint = class {
825
858
  * The module name with namespace.
826
859
  */
827
860
  moduleName;
861
+ /**
862
+ * The view module name.
863
+ */
864
+ viewModule;
828
865
  /**
829
866
  * Initializes the endpoint.
830
867
  *
@@ -944,15 +981,28 @@ var Endpoint = class {
944
981
  * @param {number} payloadSize - The payload size.
945
982
  * @param {Object} [query] - The query parameters.
946
983
  * @param {bigint | number} [query.ledgerVersion] - The ledger version.
947
- * @returns {Promise<aptos.BCS.Uint64>} A promise that resolves to the quoted fee.
984
+ * @param {aptos.BCS.Bytes} [msglibParams] - The msglib parameters.
985
+ * @returns {Promise<{ nativeFee: aptos.BCS.Uint64; zroFee: aptos.BCS.Uint64 }>} A promise that resolves to the quoted fee.
948
986
  */
949
- async quoteFee(uaAddress, dstChainId, adapterParams, payloadSize, query) {
950
- let totalFee = BigInt(
951
- await this.sdk.LayerzeroModule.Uln.Config.quoteFee(uaAddress, dstChainId, payloadSize, query)
952
- );
953
- const [executor] = await this.sdk.LayerzeroModule.ExecutorConfig.getExecutor(uaAddress, dstChainId, query);
954
- totalFee += await this.sdk.LayerzeroModule.Executor.quoteFee(executor, dstChainId, adapterParams, query);
955
- return totalFee;
987
+ async quoteFee(uaAddress, dstChainId, adapterParams, payloadSize, msglibParams, payInZro = false, query) {
988
+ const payload = {
989
+ function: `${this.viewModule}::quote_fee`,
990
+ type_arguments: [],
991
+ arguments: [
992
+ uaAddress,
993
+ dstChainId.toString(),
994
+ payloadSize.toString(),
995
+ payInZro,
996
+ Buffer.from(adapterParams).toString("hex"),
997
+ Buffer.from(msglibParams ?? new Uint8Array([])).toString("hex")
998
+ ]
999
+ };
1000
+ const view = await this.sdk.viewFunction(payload);
1001
+ const [nativeFee, zroFee] = view[0];
1002
+ return {
1003
+ nativeFee,
1004
+ zroFee
1005
+ };
956
1006
  }
957
1007
  /**
958
1008
  * Creates a payload for registering an executor.
@@ -2781,9 +2831,9 @@ var Executor = class {
2781
2831
  };
2782
2832
  try {
2783
2833
  const ret = await this.sdk.client.view(payload, ledger_version);
2784
- const types = ret[0];
2834
+ const types2 = ret[0];
2785
2835
  return [
2786
- types.map((t) => {
2836
+ types2.map((t) => {
2787
2837
  const account_address = fullAddress(t.account_address).toString();
2788
2838
  const module_name = hexToAscii(t.module_name);
2789
2839
  const struct_name = hexToAscii(t.struct_name);
@@ -2963,6 +3013,95 @@ var ExecutorConfig = class {
2963
3013
  };
2964
3014
  }
2965
3015
  };
3016
+ var MsgLib = class {
3017
+ /**
3018
+ * Creates an instance of the MsgLib class.
3019
+ *
3020
+ * @param {SDK} sdk - The SDK instance.
3021
+ */
3022
+ constructor(sdk) {
3023
+ this.sdk = sdk;
3024
+ this.module = `${sdk.accounts.msglib_v2}::msglib_v2_router`;
3025
+ this.routingModule = `${sdk.accounts.msglib_routing_helper}::version_mirroring`;
3026
+ }
3027
+ /**
3028
+ * The module name.
3029
+ */
3030
+ module;
3031
+ routingModule;
3032
+ //--------------------entry functions--------------------
3033
+ async createInitPayload() {
3034
+ const transaction = {
3035
+ function: `${this.module}::init`,
3036
+ type_arguments: [],
3037
+ arguments: []
3038
+ };
3039
+ return Promise.resolve(transaction);
3040
+ }
3041
+ async init(signer) {
3042
+ const payload = await this.createInitPayload();
3043
+ return this.sdk.sendAndConfirmTransaction(signer, payload);
3044
+ }
3045
+ async createSyncVersionPayload(uaAddress, chainId) {
3046
+ const transaction = {
3047
+ function: `${this.routingModule}::sync`,
3048
+ type_arguments: [],
3049
+ arguments: [uaAddress, chainId]
3050
+ };
3051
+ return Promise.resolve(transaction);
3052
+ }
3053
+ async syncVersion(signer, uaAddress, chainId) {
3054
+ const payload = await this.createSyncVersionPayload(uaAddress, chainId);
3055
+ return this.sdk.sendAndConfirmTransaction(signer, payload);
3056
+ }
3057
+ //--------------------view functions--------------------
3058
+ /**
3059
+ * Checks if the module is initialized.
3060
+ *
3061
+ * @returns {Promise<boolean>} A promise that resolves to true if the module is initialized, false otherwise.
3062
+ */
3063
+ async isInitialize() {
3064
+ try {
3065
+ await this.sdk.client.getAccountResource(`${this.sdk.accounts.msglib_v2}`, `${this.module}::MsgLibConfig`);
3066
+ return true;
3067
+ } catch (err) {
3068
+ if (err instanceof ApiError && err.errorCode === "resource_not_found") {
3069
+ return false;
3070
+ }
3071
+ throw err;
3072
+ }
3073
+ }
3074
+ async isVersionSynced(uaAddress, chainId) {
3075
+ if (this.sdk.accounts.msglib_v2 === void 0) {
3076
+ throw new Error("sdk accounts msglib_v2 is undefined when invoke isVersionSynced");
3077
+ }
3078
+ if (this.sdk.accounts.layerzero_common === void 0) {
3079
+ throw new Error("sdk accounts layerzero_common is undefined when invoke isVersionSynced");
3080
+ }
3081
+ const resource = await this.sdk.client.getAccountResource(
3082
+ this.sdk.accounts.msglib_v2,
3083
+ `${this.module}::MsgLibConfig`
3084
+ );
3085
+ const { send_version } = resource.data;
3086
+ const { handle } = send_version;
3087
+ try {
3088
+ const version = await this.sdk.client.getTableItem(handle, {
3089
+ key_type: `${this.module}::ConfigKey`,
3090
+ value_type: `${this.sdk.accounts.layerzero_common}::semver::SemVer`,
3091
+ key: {
3092
+ ua_address: uaAddress,
3093
+ chain_id: chainId.toString()
3094
+ }
3095
+ });
3096
+ return true;
3097
+ } catch (err) {
3098
+ if (err instanceof ApiError && (err.errorCode === "resource_not_found" || err.errorCode === "table_item_not_found")) {
3099
+ return false;
3100
+ }
3101
+ throw err;
3102
+ }
3103
+ }
3104
+ };
2966
3105
  var MsgLibAuth = class {
2967
3106
  /**
2968
3107
  * Creates an instance of the MsgLibAuth class.
@@ -4070,6 +4209,347 @@ var Uln = class {
4070
4209
  this.PacketEvent = new PacketEvent(sdk);
4071
4210
  }
4072
4211
  };
4212
+ var Uln301 = class {
4213
+ /**
4214
+ * Creates an instance of the UlnReceive class.
4215
+ *
4216
+ * @param {SDK} sdk - The SDK instance.
4217
+ */
4218
+ constructor(sdk) {
4219
+ this.sdk = sdk;
4220
+ this.module = `${sdk.accounts.uln_301}::msglib`;
4221
+ this.adminModule = `${sdk.accounts.uln_301}::admin`;
4222
+ this.routerModule = `${sdk.accounts.uln_301}::router_calls`;
4223
+ }
4224
+ /**
4225
+ * The module name.
4226
+ */
4227
+ module;
4228
+ adminModule;
4229
+ routerModule;
4230
+ emptyUlnConfig = {
4231
+ confirmations: BigInt(0),
4232
+ optionalDVNThreshold: 0,
4233
+ requiredDVNs: [],
4234
+ optionalDVNs: [],
4235
+ useDefaultForConfirmations: false,
4236
+ useDefaultForRequiredDVNs: false,
4237
+ useDefaultForOptionalDVNs: false
4238
+ };
4239
+ emptyExecutorConfig = {
4240
+ maxMessageSize: 0,
4241
+ executorAddress: ""
4242
+ };
4243
+ //--------------------entry functions--------------------
4244
+ async createInitializePayload(eid) {
4245
+ const transaction = {
4246
+ function: `${this.adminModule}::initialize`,
4247
+ type_arguments: [],
4248
+ arguments: [eid]
4249
+ };
4250
+ return Promise.resolve(transaction);
4251
+ }
4252
+ async isInitialized() {
4253
+ const resource = await this.sdk.client.getAccountResource(
4254
+ `${this.sdk.accounts.uln_301}`,
4255
+ `${this.sdk.accounts.uln_301}::uln_301_store::Store`
4256
+ );
4257
+ const { eid: storeEid } = resource.data;
4258
+ return storeEid !== 0;
4259
+ }
4260
+ async createSetDefaultUlnSendConfigPayload(dstEid, ulnConfig) {
4261
+ const transaction = {
4262
+ function: `${this.adminModule}::set_default_uln_send_config`,
4263
+ type_arguments: [],
4264
+ arguments: [
4265
+ dstEid,
4266
+ ulnConfig.confirmations,
4267
+ ulnConfig.optionalDVNThreshold,
4268
+ ulnConfig.requiredDVNs,
4269
+ ulnConfig.optionalDVNs
4270
+ ]
4271
+ };
4272
+ return Promise.resolve(transaction);
4273
+ }
4274
+ async setDefaultUlnSendConfig(signer, dstEid, ulnConfig) {
4275
+ const transaction = await this.createSetDefaultUlnSendConfigPayload(dstEid, ulnConfig);
4276
+ return this.sdk.sendAndConfirmTransaction(signer, transaction);
4277
+ }
4278
+ async createSetDefaultUlnReceiveConfigPayload(srcEid, ulnConfig) {
4279
+ const transaction = {
4280
+ function: `${this.adminModule}::set_default_uln_receive_config`,
4281
+ type_arguments: [],
4282
+ arguments: [
4283
+ srcEid,
4284
+ ulnConfig.confirmations,
4285
+ ulnConfig.optionalDVNThreshold,
4286
+ ulnConfig.requiredDVNs,
4287
+ ulnConfig.optionalDVNs
4288
+ ]
4289
+ };
4290
+ return Promise.resolve(transaction);
4291
+ }
4292
+ async setDefaultUlnReceiveConfig(signer, srcEid, ulnConfig) {
4293
+ const transaction = await this.createSetDefaultUlnReceiveConfigPayload(srcEid, ulnConfig);
4294
+ return this.sdk.sendAndConfirmTransaction(signer, transaction);
4295
+ }
4296
+ async createSetDefaultExecutorConfigPayload(eid, executorConfig) {
4297
+ const transaction = {
4298
+ function: `${this.adminModule}::set_default_executor_config`,
4299
+ type_arguments: [],
4300
+ arguments: [eid, executorConfig.maxMessageSize, executorConfig.executorAddress]
4301
+ };
4302
+ return Promise.resolve(transaction);
4303
+ }
4304
+ async setDefaultExecutorConfig(signer, eid, executorConfig) {
4305
+ const transaction = await this.createSetDefaultExecutorConfigPayload(eid, executorConfig);
4306
+ return this.sdk.sendAndConfirmTransaction(signer, transaction);
4307
+ }
4308
+ async createSetWorkerConfigForFeeLibRoutingOptInPayload(optIn) {
4309
+ const transaction = {
4310
+ function: `${this.module}::set_worker_config_for_fee_lib_routing_opt_in`,
4311
+ type_arguments: [],
4312
+ arguments: [optIn]
4313
+ };
4314
+ return Promise.resolve(transaction);
4315
+ }
4316
+ async setWorkerConfigForFeeLibRoutingOptIn(signer, optIn) {
4317
+ const transaction = await this.createSetWorkerConfigForFeeLibRoutingOptInPayload(optIn);
4318
+ return this.sdk.sendAndConfirmTransaction(signer, transaction);
4319
+ }
4320
+ //--------------------view functions--------------------
4321
+ async getTreasury() {
4322
+ const payload = {
4323
+ function: `${this.module}::get_treasury`,
4324
+ type_arguments: [],
4325
+ arguments: []
4326
+ };
4327
+ const ret = await this.sdk.client.view(payload);
4328
+ return ret[0];
4329
+ }
4330
+ async getDefaultUlnSendConfig(dstEid) {
4331
+ const payload = {
4332
+ function: `${this.module}::get_default_uln_send_config`,
4333
+ type_arguments: [],
4334
+ arguments: [dstEid]
4335
+ };
4336
+ const view = await this.sdk.viewFunction(payload);
4337
+ if (view.length === 0) {
4338
+ return this.emptyUlnConfig;
4339
+ }
4340
+ return this.parseUlnConfig(view[0]);
4341
+ }
4342
+ async getDefaultUlnReceiveConfig(srcEid) {
4343
+ const payload = {
4344
+ function: `${this.module}::get_default_uln_receive_config`,
4345
+ type_arguments: [],
4346
+ arguments: [srcEid]
4347
+ };
4348
+ const view = await this.sdk.viewFunction(payload);
4349
+ if (view.length === 0) {
4350
+ return this.emptyUlnConfig;
4351
+ }
4352
+ return this.parseUlnConfig(view[0]);
4353
+ }
4354
+ async getDefaultExecutorConfig(eid) {
4355
+ const payload = {
4356
+ function: `${this.module}::get_default_executor_config`,
4357
+ type_arguments: [],
4358
+ arguments: [eid]
4359
+ };
4360
+ const view = await this.sdk.viewFunction(payload);
4361
+ if (view.length === 0) {
4362
+ return this.emptyExecutorConfig;
4363
+ }
4364
+ return this.parseExecutorConfig(view[0]);
4365
+ }
4366
+ async getAppSendConfig(oappAddress, dstEid) {
4367
+ const payload = {
4368
+ function: `${this.module}::get_app_send_config`,
4369
+ type_arguments: [],
4370
+ arguments: [oappAddress, dstEid]
4371
+ };
4372
+ const view = await this.sdk.viewFunction(payload);
4373
+ if (view.length === 0) {
4374
+ return this.emptyUlnConfig;
4375
+ }
4376
+ return this.parseUlnConfig(view[0]);
4377
+ }
4378
+ async getAppReceiveConfig(oappAddress, srcEid) {
4379
+ const payload = {
4380
+ function: `${this.module}::get_app_receive_config`,
4381
+ type_arguments: [],
4382
+ arguments: [oappAddress, srcEid]
4383
+ };
4384
+ const view = await this.sdk.viewFunction(payload);
4385
+ if (view.length === 0) {
4386
+ return this.emptyUlnConfig;
4387
+ }
4388
+ return this.parseUlnConfig(view[0]);
4389
+ }
4390
+ async getAppExecutorConfig(oappAddress, eid) {
4391
+ const payload = {
4392
+ function: `${this.module}::get_app_executor_config`,
4393
+ type_arguments: [],
4394
+ arguments: [oappAddress, eid]
4395
+ };
4396
+ const view = await this.sdk.viewFunction(payload);
4397
+ if (view.length === 0) {
4398
+ return this.emptyExecutorConfig;
4399
+ }
4400
+ return this.parseExecutorConfig(view[0]);
4401
+ }
4402
+ async workerConfigForFeeLibRoutingOptIn() {
4403
+ const payload = {
4404
+ function: `${this.module}::worker_config_for_fee_lib_routing_opt_in`,
4405
+ type_arguments: [],
4406
+ arguments: []
4407
+ };
4408
+ const ret = await this.sdk.client.view(payload);
4409
+ return ret[0];
4410
+ }
4411
+ async verifiable(packetHeader, payloadHash) {
4412
+ const payload = {
4413
+ function: `${this.module}::verifiable`,
4414
+ type_arguments: [],
4415
+ arguments: [packetHeader, payloadHash]
4416
+ };
4417
+ const ret = await this.sdk.client.view(payload);
4418
+ return ret[0];
4419
+ }
4420
+ async getVerificationConfirmations(packetHeaderHash, payloadHash, dvnAddress) {
4421
+ const payload = {
4422
+ function: `${this.module}::get_verification_confirmations`,
4423
+ type_arguments: [],
4424
+ arguments: [packetHeaderHash, payloadHash, dvnAddress]
4425
+ };
4426
+ const ret = await this.sdk.client.view(payload);
4427
+ return ret[0];
4428
+ }
4429
+ async version() {
4430
+ const payload = {
4431
+ function: `${this.module}::version`,
4432
+ type_arguments: [],
4433
+ arguments: []
4434
+ };
4435
+ const ret = await this.sdk.client.view(payload);
4436
+ return ret[0];
4437
+ }
4438
+ async getUaConfig(uaAddress, chainId, configType) {
4439
+ if (configType === types.ConfigType.Executor) {
4440
+ throw new Error("Executor config is not supported");
4441
+ }
4442
+ const payload = {
4443
+ function: `${this.routerModule}::get_ua_config`,
4444
+ type_arguments: [],
4445
+ arguments: [uaAddress, chainId.toString(), configType]
4446
+ };
4447
+ const view = await this.sdk.viewFunction(payload);
4448
+ return types.deserializeUlnConfig(view[0]);
4449
+ }
4450
+ /**
4451
+ * Parses the ULN configuration response.
4452
+ *
4453
+ * @param {UlnConfigResponse} ulnConfigResponse - The ULN configuration response.
4454
+ * @returns {UlnConfig} The parsed ULN configuration.
4455
+ */
4456
+ parseUlnConfig(ulnConfigResponse) {
4457
+ return {
4458
+ confirmations: ulnConfigResponse.confirmations,
4459
+ optionalDVNThreshold: ulnConfigResponse.optional_dvn_threshold,
4460
+ requiredDVNs: ulnConfigResponse.required_dvns,
4461
+ optionalDVNs: ulnConfigResponse.optional_dvns,
4462
+ useDefaultForConfirmations: ulnConfigResponse.use_default_for_confirmations,
4463
+ useDefaultForOptionalDVNs: ulnConfigResponse.use_default_for_optional_dvns,
4464
+ useDefaultForRequiredDVNs: ulnConfigResponse.use_default_for_required_dvns
4465
+ };
4466
+ }
4467
+ /**
4468
+ * Parses the executor configuration response.
4469
+ *
4470
+ * @param {ExecutorConfigResponse} executorConfigResponse - The executor configuration response.
4471
+ * @returns {ExecutorConfig} The parsed executor configuration.
4472
+ */
4473
+ parseExecutorConfig(executorConfigResponse) {
4474
+ return {
4475
+ maxMessageSize: executorConfigResponse.max_message_size,
4476
+ executorAddress: executorConfigResponse.executor_address
4477
+ };
4478
+ }
4479
+ };
4480
+ var Uln301Receiver = class {
4481
+ /**
4482
+ * Creates an instance of the UlnReceive class.
4483
+ *
4484
+ * @param {SDK} sdk - The SDK instance.
4485
+ */
4486
+ constructor(sdk) {
4487
+ this.sdk = sdk;
4488
+ this.module = `${sdk.accounts.uln_301_receiver}::uln_301_receive_helper`;
4489
+ }
4490
+ /**
4491
+ * The module name.
4492
+ */
4493
+ module;
4494
+ //--------------------entry functions--------------------
4495
+ async createSetChainAddressSizePayload(eid, size) {
4496
+ const transaction = {
4497
+ function: `${this.module}::set_address_size`,
4498
+ type_arguments: [],
4499
+ arguments: [eid, size]
4500
+ };
4501
+ return Promise.resolve(transaction);
4502
+ }
4503
+ async setChainAddressSize(signer, eid, size) {
4504
+ const payload = await this.createSetChainAddressSizePayload(eid, size);
4505
+ return this.sdk.sendAndConfirmTransaction(signer, payload);
4506
+ }
4507
+ async createCommitVerificationPayload(uaType, rawPacketBytes) {
4508
+ const transaction = {
4509
+ function: `${this.module}::commit_verification`,
4510
+ type_arguments: [uaType],
4511
+ arguments: [rawPacketBytes]
4512
+ };
4513
+ return Promise.resolve(transaction);
4514
+ }
4515
+ async commitVerification(signer, uaType, rawPacketBytes) {
4516
+ const payload = await this.createCommitVerificationPayload(uaType, rawPacketBytes);
4517
+ return this.sdk.sendAndConfirmTransaction(signer, payload);
4518
+ }
4519
+ //--------------------view functions--------------------
4520
+ /**
4521
+ * Checks if the module is initialized.
4522
+ *
4523
+ * @returns {Promise<boolean>} A promise that resolves to true if the module is initialized, false otherwise.
4524
+ */
4525
+ async isInitialize() {
4526
+ try {
4527
+ await this.sdk.client.getAccountResource(`${this.sdk.accounts.uln_301_receiver}`, `${this.module}::Store`);
4528
+ return true;
4529
+ } catch (err) {
4530
+ if (err instanceof ApiError && err.errorCode === "resource_not_found") {
4531
+ return false;
4532
+ }
4533
+ throw err;
4534
+ }
4535
+ }
4536
+ async getAddressSize(chainId) {
4537
+ const payload = {
4538
+ function: `${this.module}::get_address_size`,
4539
+ type_arguments: [],
4540
+ arguments: [chainId]
4541
+ };
4542
+ try {
4543
+ const ret = await this.sdk.client.view(payload);
4544
+ return ret[0];
4545
+ } catch (e) {
4546
+ if (isErrorOfApiError(e, 400)) {
4547
+ return BigInt(-1);
4548
+ }
4549
+ throw e;
4550
+ }
4551
+ }
4552
+ };
4073
4553
 
4074
4554
  // src/modules/index.ts
4075
4555
  var Layerzero = class {
@@ -4093,6 +4573,16 @@ var Layerzero = class {
4093
4573
  * @see {@link Uln}
4094
4574
  */
4095
4575
  Uln;
4576
+ /**
4577
+ * The Uln301 instance.
4578
+ * @see {@link Uln301}
4579
+ */
4580
+ Uln301;
4581
+ /**
4582
+ * The Uln301Receiver instance.
4583
+ * @see {@link Uln301Receiver}
4584
+ */
4585
+ Uln301Receiver;
4096
4586
  /**
4097
4587
  * The MsgLibConfig instance.
4098
4588
  * @see {@link MsgLibConfig}
@@ -4108,6 +4598,11 @@ var Layerzero = class {
4108
4598
  * @see {@link ExecutorConfig}
4109
4599
  */
4110
4600
  ExecutorConfig;
4601
+ /**
4602
+ * The MsgLib instance.
4603
+ * @see {@link MsgLib}
4604
+ */
4605
+ MsgLib;
4111
4606
  /**
4112
4607
  * Creates an instance of the Layerzero class.
4113
4608
  *
@@ -4121,6 +4616,9 @@ var Layerzero = class {
4121
4616
  this.MsgLibAuth = new MsgLibAuth(sdk);
4122
4617
  this.ExecutorConfig = new ExecutorConfig(sdk);
4123
4618
  this.Uln = new Uln(sdk);
4619
+ this.Uln301 = new Uln301(sdk);
4620
+ this.Uln301Receiver = new Uln301Receiver(sdk);
4621
+ this.MsgLib = new MsgLib(sdk);
4124
4622
  }
4125
4623
  };
4126
4624
 
@@ -4280,6 +4778,36 @@ var LzApp = class {
4280
4778
  const transaction = this.setRemotePaylaod(remoteChainId, remoteAddress);
4281
4779
  return this.sdk.sendAndConfirmTransaction(signer, transaction);
4282
4780
  }
4781
+ /**
4782
+ * Creates a payload for setting the executor version and address.
4783
+ *
4784
+ * @param {string} uaType - The user application type.
4785
+ * @param {aptos.BCS.Uint16} remoteChainId - The remote chain ID.
4786
+ * @param {aptos.BCS.Uint8} executorVersion - The executor version.
4787
+ * @param {string} executorAddress - The executor address.
4788
+ * @returns {aptos.Types.EntryFunctionPayload} The entry function payload.
4789
+ */
4790
+ setExecutorPayload(uaType, remoteChainId, executorVersion, executorAddress) {
4791
+ return {
4792
+ function: `${this.lzApp}::lzapp::set_executor`,
4793
+ type_arguments: [uaType],
4794
+ arguments: [remoteChainId, executorVersion, executorAddress]
4795
+ };
4796
+ }
4797
+ /**
4798
+ * Sets the executor version and address.
4799
+ *
4800
+ * @param {aptos.AptosAccount} signer - The signer account.
4801
+ * @param {string} uaType - The user application type.
4802
+ * @param {aptos.BCS.Uint16} remoteChainId - The remote chain ID.
4803
+ * @param {aptos.BCS.Uint8} executorVersion - The executor version.
4804
+ * @param {string} executorAddress - The executor address.
4805
+ * @returns {Promise<aptos.Types.Transaction>} The transaction result.
4806
+ */
4807
+ async setExecutor(signer, uaType, remoteChainId, executorVersion, executorAddress) {
4808
+ const transaction = this.setExecutorPayload(uaType, remoteChainId, executorVersion, executorAddress);
4809
+ return this.sdk.sendAndConfirmTransaction(signer, transaction);
4810
+ }
4283
4811
  /**
4284
4812
  * Creates a payload for setting the configuration.
4285
4813
  *
@@ -5322,49 +5850,50 @@ var Counter = class {
5322
5850
  return BigInt(i);
5323
5851
  }
5324
5852
  /**
5325
- * Creates a payload for creating a counter.
5853
+ * Creates a payload for setting a remote address.
5326
5854
  *
5327
- * @param {aptos.BCS.Uint64 | aptos.BCS.Uint32} i - The initial count value.
5855
+ * @param {aptos.BCS.Uint16} remoteChainId - The remote chain ID.
5856
+ * @param {aptos.BCS.Bytes} remoteAddress - The remote address.
5328
5857
  * @returns {aptos.Types.EntryFunctionPayload} The entry function payload.
5329
5858
  */
5330
- createCounterPayload(i) {
5331
- return {
5332
- function: `${this.address}::counter::create_counter`,
5333
- type_arguments: [],
5334
- arguments: [i]
5335
- };
5859
+ setRemotePayload(remoteChainId, remoteAddress) {
5860
+ return this.lzApp.setRemotePaylaod(remoteChainId, remoteAddress);
5336
5861
  }
5337
5862
  /**
5338
- * Creates a counter.
5863
+ * Sets a remote address.
5339
5864
  *
5340
5865
  * @param {aptos.AptosAccount} signer - The signer account.
5341
- * @param {aptos.BCS.Uint64 | aptos.BCS.Uint32} i - The initial count value.
5866
+ * @param {aptos.BCS.Uint16} remoteChainId - The remote chain ID.
5867
+ * @param {aptos.BCS.Bytes} remoteAddress - The remote address.
5342
5868
  * @returns {Promise<aptos.Types.Transaction>} The transaction result.
5343
5869
  */
5344
- async createCounter(signer, i) {
5345
- const transaction = this.createCounterPayload(i);
5346
- return this.sdk.sendAndConfirmTransaction(signer, transaction);
5870
+ async setRemote(signer, remoteChainId, remoteAddress) {
5871
+ return this.lzApp.setRemote(signer, remoteChainId, remoteAddress);
5347
5872
  }
5348
5873
  /**
5349
- * Creates a payload for setting a remote address.
5874
+ * Creates a payload for setting the executor version and address.
5350
5875
  *
5876
+ * @param {string} uaType - The user application type.
5351
5877
  * @param {aptos.BCS.Uint16} remoteChainId - The remote chain ID.
5352
- * @param {aptos.BCS.Bytes} remoteAddress - The remote address.
5878
+ * @param {aptos.BCS.Uint8} executorVersion - The executor version.
5879
+ * @param {string} executorAddress - The executor address.
5353
5880
  * @returns {aptos.Types.EntryFunctionPayload} The entry function payload.
5354
5881
  */
5355
- setRemotePayload(remoteChainId, remoteAddress) {
5356
- return this.lzApp.setRemotePaylaod(remoteChainId, remoteAddress);
5882
+ setExecutorPayload(uaType, remoteChainId, executorVersion, executorAddress) {
5883
+ return this.lzApp.setExecutorPayload(uaType, remoteChainId, executorVersion, executorAddress);
5357
5884
  }
5358
5885
  /**
5359
- * Sets a remote address.
5886
+ * Sets the executor version and address.
5360
5887
  *
5361
5888
  * @param {aptos.AptosAccount} signer - The signer account.
5889
+ * @param {string} uaType - The user application type.
5362
5890
  * @param {aptos.BCS.Uint16} remoteChainId - The remote chain ID.
5363
- * @param {aptos.BCS.Bytes} remoteAddress - The remote address.
5891
+ * @param {aptos.BCS.Uint8} executorVersion - The executor version.
5892
+ * @param {string} executorAddress - The executor address.
5364
5893
  * @returns {Promise<aptos.Types.Transaction>} The transaction result.
5365
5894
  */
5366
- async setRemote(signer, remoteChainId, remoteAddress) {
5367
- return this.lzApp.setRemote(signer, remoteChainId, remoteAddress);
5895
+ async setExecutor(signer, uaType, remoteChainId, executorVersion, executorAddress) {
5896
+ return this.lzApp.setExecutor(signer, uaType, remoteChainId, executorVersion, executorAddress);
5368
5897
  }
5369
5898
  /**
5370
5899
  * Creates a payload for setting the application configuration.
@@ -5490,6 +6019,23 @@ var Counter = class {
5490
6019
  throw e;
5491
6020
  }
5492
6021
  }
6022
+ /**
6023
+ * Gets the fee quote for sending a message to a remote chain.
6024
+ *
6025
+ * @param {aptos.BCS.Uint16} remoteChainId - The remote chain ID.
6026
+ * @param {string} adapterParams - The adapter parameters.
6027
+ * @param {boolean} payInZro - Whether to pay the fee in ZRO tokens.
6028
+ * @returns {Promise<[aptos.BCS.Uint64, aptos.BCS.Uint64]>} A tuple containing the native fee and ZRO fee.
6029
+ */
6030
+ async quoteFee(remoteChainId, adapterParams, payInZro) {
6031
+ const payload = {
6032
+ function: `${this.address}::counter::quote_fee`,
6033
+ type_arguments: [],
6034
+ arguments: [remoteChainId.toString(), adapterParams, payInZro]
6035
+ };
6036
+ const view = await this.sdk.viewFunction(payload);
6037
+ return view[0];
6038
+ }
5493
6039
  };
5494
6040
  var MultisigOracle = class {
5495
6041
  /**
@@ -7150,10 +7696,10 @@ var PreCrime = class {
7150
7696
  * @returns {Promise<aptos.MaybeHexString>} The configuration.
7151
7697
  */
7152
7698
  async getConfig(packets, ledger_version) {
7153
- const types = await this.getConfigTypes(packets, ledger_version);
7699
+ const types2 = await this.getConfigTypes(packets, ledger_version);
7154
7700
  const payload = {
7155
7701
  function: `${this.module}::get_config`,
7156
- type_arguments: types,
7702
+ type_arguments: types2,
7157
7703
  arguments: [packets]
7158
7704
  };
7159
7705
  const ret = await this.sdk.client.view(payload, ledger_version);
@@ -7167,10 +7713,10 @@ var PreCrime = class {
7167
7713
  * @returns {Promise<aptos.MaybeHexString>} The simulation result.
7168
7714
  */
7169
7715
  async simulate(packets, ledger_version) {
7170
- const types = await this.getSimulateTypes(packets, ledger_version);
7716
+ const types2 = await this.getSimulateTypes(packets, ledger_version);
7171
7717
  const payload = {
7172
7718
  function: `${this.module}::simulate`,
7173
- type_arguments: types,
7719
+ type_arguments: types2,
7174
7720
  arguments: [packets]
7175
7721
  };
7176
7722
  const ret = await this.sdk.client.view(payload, ledger_version);
@@ -7185,10 +7731,10 @@ var PreCrime = class {
7185
7731
  * @returns {Promise<boolean>} The result of the precrime.
7186
7732
  */
7187
7733
  async precrime(packets, simulations, ledger_version) {
7188
- const types = await this.getPreCrimeTypes(packets, simulations, ledger_version);
7734
+ const types2 = await this.getPreCrimeTypes(packets, simulations, ledger_version);
7189
7735
  const payload = {
7190
7736
  function: `${this.module}::precrime`,
7191
- type_arguments: types,
7737
+ type_arguments: types2,
7192
7738
  arguments: [packets, simulations]
7193
7739
  };
7194
7740
  const ret = await this.sdk.client.view(payload, ledger_version);
@@ -7208,8 +7754,8 @@ var PreCrime = class {
7208
7754
  arguments: [packets]
7209
7755
  };
7210
7756
  const ret = await this.sdk.client.view(payload, ledger_version);
7211
- const types = ret[0];
7212
- return this.formatTypes(types);
7757
+ const types2 = ret[0];
7758
+ return this.formatTypes(types2);
7213
7759
  }
7214
7760
  /**
7215
7761
  * Get the simulation types for the given packets.
@@ -7225,8 +7771,8 @@ var PreCrime = class {
7225
7771
  arguments: [packets]
7226
7772
  };
7227
7773
  const ret = await this.sdk.client.view(payload, ledger_version);
7228
- const types = ret[0];
7229
- return this.formatTypes(types);
7774
+ const types2 = ret[0];
7775
+ return this.formatTypes(types2);
7230
7776
  }
7231
7777
  /**
7232
7778
  * Get the precrime types for the given packets and simulations.
@@ -7243,8 +7789,8 @@ var PreCrime = class {
7243
7789
  arguments: [packets, simulations]
7244
7790
  };
7245
7791
  const ret = await this.sdk.client.view(payload, ledger_version);
7246
- const types = ret[0];
7247
- return this.formatTypes(types);
7792
+ const types2 = ret[0];
7793
+ return this.formatTypes(types2);
7248
7794
  }
7249
7795
  /**
7250
7796
  * Format the given types.
@@ -7252,9 +7798,9 @@ var PreCrime = class {
7252
7798
  * @param {TypeInfo[]} types - The types to format.
7253
7799
  * @returns {string[]} The formatted types.
7254
7800
  */
7255
- formatTypes(types) {
7801
+ formatTypes(types2) {
7256
7802
  const rtn = [];
7257
- for (const typeInfo of types) {
7803
+ for (const typeInfo of types2) {
7258
7804
  const info = normalizeTypeInfo(typeInfo);
7259
7805
  rtn.push(buildStructTagFromTypeInfo(info));
7260
7806
  }
@@ -7281,6 +7827,9 @@ __export(format_exports, {
7281
7827
  });
7282
7828
 
7283
7829
  // src/index.ts
7830
+ function isOptionValue(value) {
7831
+ return typeof value === "object" && value != null && "vec" in value;
7832
+ }
7284
7833
  var SDK = class {
7285
7834
  /**
7286
7835
  * The stage of the SDK.
@@ -7307,20 +7856,44 @@ var SDK = class {
7307
7856
  this.stage = options.stage ?? Stage.SANDBOX;
7308
7857
  this.accounts = options.accounts ?? {
7309
7858
  layerzero: LAYERZERO_ADDRESS[this.stage],
7859
+ layerzero_common: LAYERZERO_ADDRESS[this.stage],
7310
7860
  msglib_auth: LAYERZERO_ADDRESS[this.stage],
7311
7861
  msglib_v1_1: LAYERZERO_ADDRESS[this.stage],
7312
7862
  msglib_v2: LAYERZERO_ADDRESS[this.stage],
7863
+ msglib_v2_1: LAYERZERO_ADDRESS[this.stage],
7864
+ msglib_v3: LAYERZERO_ADDRESS[this.stage],
7865
+ uln_301: ULN_301_ADDRESS[this.stage],
7866
+ uln_301_receiver: ULN_301_RECEIVE_HELPER_ADDRESS[this.stage],
7867
+ msglib_routing_helper: MSGLIB_ROUTING_HELPER_ADDRESS[this.stage],
7313
7868
  zro: LAYERZERO_ADDRESS[this.stage],
7314
7869
  executor_auth: LAYERZERO_ADDRESS[this.stage],
7315
7870
  executor_ext: EXECUTOR_EXT_ADDRESS[this.stage],
7316
7871
  executor_v2: LAYERZERO_ADDRESS[this.stage],
7317
7872
  layerzero_apps: LAYERZERO_APPS_ADDRESS[this.stage],
7318
7873
  layerzero_apps_pubkey: LAYERZERO_APPS_PUBKEY[this.stage],
7319
- counter: COUNTER_ADDRESS[this.stage]
7874
+ counter: COUNTER_ADDRESS[this.stage],
7875
+ view: LAYERZERO_VIEW_ADDRESS[this.stage]
7320
7876
  };
7321
7877
  this.client = options.provider;
7322
7878
  this.LayerzeroModule = new Layerzero(this);
7323
7879
  }
7880
+ async viewFunction(payload) {
7881
+ let view = await this.client.view(payload);
7882
+ view = view.map((item) => {
7883
+ if (isOptionValue(item)) {
7884
+ if (item.vec.length !== 0) {
7885
+ return item.vec[0];
7886
+ } else {
7887
+ return null;
7888
+ }
7889
+ }
7890
+ return item;
7891
+ }).filter((item) => item !== null);
7892
+ if (view.length > 1) {
7893
+ view = [view];
7894
+ }
7895
+ return view;
7896
+ }
7324
7897
  /**
7325
7898
  * Sends and confirms a BCS transaction.
7326
7899
  *
@@ -7344,6 +7917,20 @@ var SDK = class {
7344
7917
  const signedTxn = await this.client.signTransaction(signer, txnRequest);
7345
7918
  return this.sendAndConfirmRawTransaction(signedTxn);
7346
7919
  }
7920
+ async sendAndConfirmScriptTransaction(signer, payload) {
7921
+ const scriptPayload = new aptos2.TxnBuilderTypes.TransactionPayloadScript(payload);
7922
+ const options = await this.estimateScriptTxGas(signer, scriptPayload);
7923
+ const txnRequest = await this.client.generateRawTransaction(
7924
+ new aptos2.HexString(signer.address().toString()),
7925
+ scriptPayload,
7926
+ {
7927
+ maxGasAmount: BigInt(options.max_gas_amount),
7928
+ gasUnitPrice: BigInt(options.gas_unit_price)
7929
+ }
7930
+ );
7931
+ const signedTxn = await this.client.signTransaction(signer, txnRequest);
7932
+ return this.sendAndConfirmRawTransaction(signedTxn);
7933
+ }
7347
7934
  /**
7348
7935
  * Estimates the gas for a transaction.
7349
7936
  *
@@ -7352,7 +7939,20 @@ var SDK = class {
7352
7939
  * @returns {Promise<{ max_gas_amount: string, gas_unit_price: string }>} The gas estimation.
7353
7940
  */
7354
7941
  async estimateGas(signer, payload) {
7355
- const txnRequest = await this.client.generateTransaction(signer.address(), payload);
7942
+ const txnRequest = await this.client.generateTransaction(
7943
+ signer.address(),
7944
+ payload
7945
+ );
7946
+ return this.innerEstimateGas(signer, txnRequest);
7947
+ }
7948
+ async estimateScriptTxGas(signer, payload) {
7949
+ const txnRequest = await this.client.generateRawTransaction(
7950
+ signer.address(),
7951
+ payload
7952
+ );
7953
+ return this.innerEstimateGas(signer, txnRequest);
7954
+ }
7955
+ async innerEstimateGas(signer, txnRequest) {
7356
7956
  const sim = await this.client.simulateTransaction(signer, txnRequest, {
7357
7957
  estimateGasUnitPrice: true,
7358
7958
  estimateMaxGasAmount: true,