@layerzerolabs/lz-iotal1-sdk-v2 3.0.143
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 +32 -0
- package/README.md +19 -0
- package/deployments/iotal1-mainnet/blocked_message_lib.json +58 -0
- package/deployments/iotal1-mainnet/blocked_msglib_ptb_builder.json +58 -0
- package/deployments/iotal1-mainnet/call.json +46 -0
- package/deployments/iotal1-mainnet/counter.json +85 -0
- package/deployments/iotal1-mainnet/dvn.json +49 -0
- package/deployments/iotal1-mainnet/dvn_call_type.json +45 -0
- package/deployments/iotal1-mainnet/dvn_fee_lib.json +59 -0
- package/deployments/iotal1-mainnet/dvn_layerzero.json +56 -0
- package/deployments/iotal1-mainnet/dvn_ptb_builder.json +45 -0
- package/deployments/iotal1-mainnet/endpoint_ptb_builder.json +70 -0
- package/deployments/iotal1-mainnet/endpoint_v2.json +86 -0
- package/deployments/iotal1-mainnet/executor.json +49 -0
- package/deployments/iotal1-mainnet/executor_call_type.json +45 -0
- package/deployments/iotal1-mainnet/executor_fee_lib.json +60 -0
- package/deployments/iotal1-mainnet/executor_layerzero.json +56 -0
- package/deployments/iotal1-mainnet/executor_ptb_builder.json +45 -0
- package/deployments/iotal1-mainnet/layerzero_views.json +46 -0
- package/deployments/iotal1-mainnet/message_lib_common.json +47 -0
- package/deployments/iotal1-mainnet/msglib_ptb_builder_call_types.json +45 -0
- package/deployments/iotal1-mainnet/multi_call.json +45 -0
- package/deployments/iotal1-mainnet/oapp.json +50 -0
- package/deployments/iotal1-mainnet/object-BlockedMessageLib.json +9 -0
- package/deployments/iotal1-mainnet/object-BlockedMsglibPtbBuilder.json +9 -0
- package/deployments/iotal1-mainnet/object-Counter.json +9 -0
- package/deployments/iotal1-mainnet/object-CounterAdminCap.json +9 -0
- package/deployments/iotal1-mainnet/object-CounterOApp.json +9 -0
- package/deployments/iotal1-mainnet/object-DVN.json +5 -0
- package/deployments/iotal1-mainnet/object-DVNCap.json +9 -0
- package/deployments/iotal1-mainnet/object-DVNFeeLib.json +9 -0
- package/deployments/iotal1-mainnet/object-EndpointPtbBuilder.json +9 -0
- package/deployments/iotal1-mainnet/object-EndpointPtbBuilderAdminCap.json +9 -0
- package/deployments/iotal1-mainnet/object-EndpointV2.json +9 -0
- package/deployments/iotal1-mainnet/object-EndpointV2AdminCap.json +9 -0
- package/deployments/iotal1-mainnet/object-Executor.json +5 -0
- package/deployments/iotal1-mainnet/object-ExecutorCap.json +9 -0
- package/deployments/iotal1-mainnet/object-ExecutorFeeLib.json +9 -0
- package/deployments/iotal1-mainnet/object-ExecutorOwnerCap.json +5 -0
- package/deployments/iotal1-mainnet/object-OFTComposerManager.json +9 -0
- package/deployments/iotal1-mainnet/object-PackageWhitelistValidator.json +9 -0
- package/deployments/iotal1-mainnet/object-PriceFeed.json +9 -0
- package/deployments/iotal1-mainnet/object-PriceFeedOwnerCap.json +9 -0
- package/deployments/iotal1-mainnet/object-SimpleMessageLib.json +9 -0
- package/deployments/iotal1-mainnet/object-SimpleMessageLibAdminCap.json +9 -0
- package/deployments/iotal1-mainnet/object-SmlPtbBuilder.json +9 -0
- package/deployments/iotal1-mainnet/object-Treasury.json +9 -0
- package/deployments/iotal1-mainnet/object-TreasuryAdminCap.json +9 -0
- package/deployments/iotal1-mainnet/object-ULN302.json +9 -0
- package/deployments/iotal1-mainnet/object-ULN302AdminCap.json +9 -0
- package/deployments/iotal1-mainnet/object-Uln302PtbBuilder.json +9 -0
- package/deployments/iotal1-mainnet/object-Uln302Verification.json +9 -0
- package/deployments/iotal1-mainnet/object-WorkerRegistry.json +9 -0
- package/deployments/iotal1-mainnet/object-ZroCoinMetadata.json +9 -0
- package/deployments/iotal1-mainnet/object-ZroTreasuryCap.json +9 -0
- package/deployments/iotal1-mainnet/oft_common.json +61 -0
- package/deployments/iotal1-mainnet/package_whitelist_validator.json +113 -0
- package/deployments/iotal1-mainnet/price_feed.json +70 -0
- package/deployments/iotal1-mainnet/price_feed_call_types.json +45 -0
- package/deployments/iotal1-mainnet/ptb_move_call.json +48 -0
- package/deployments/iotal1-mainnet/simple_message_lib.json +69 -0
- package/deployments/iotal1-mainnet/simple_msglib_ptb_builder.json +58 -0
- package/deployments/iotal1-mainnet/treasury.json +69 -0
- package/deployments/iotal1-mainnet/uln_302.json +87 -0
- package/deployments/iotal1-mainnet/uln_302_ptb_builder.json +58 -0
- package/deployments/iotal1-mainnet/uln_common.json +49 -0
- package/deployments/iotal1-mainnet/utils.json +57 -0
- package/deployments/iotal1-mainnet/worker_common.json +46 -0
- package/deployments/iotal1-mainnet/worker_registry.json +58 -0
- package/deployments/iotal1-mainnet/zro.json +67 -0
- package/deployments/iotal1-sandbox-local/blocked_message_lib.json +58 -0
- package/deployments/iotal1-sandbox-local/blocked_msglib_ptb_builder.json +58 -0
- package/deployments/iotal1-sandbox-local/call.json +46 -0
- package/deployments/iotal1-sandbox-local/counter.json +148 -0
- package/deployments/iotal1-sandbox-local/dvn.json +49 -0
- package/deployments/iotal1-sandbox-local/dvn_call_type.json +73 -0
- package/deployments/iotal1-sandbox-local/dvn_fee_lib.json +59 -0
- package/deployments/iotal1-sandbox-local/dvn_layerzero.json +56 -0
- package/deployments/iotal1-sandbox-local/dvn_ptb_builder.json +45 -0
- package/deployments/iotal1-sandbox-local/endpoint_ptb_builder.json +70 -0
- package/deployments/iotal1-sandbox-local/endpoint_v2.json +86 -0
- package/deployments/iotal1-sandbox-local/executor.json +49 -0
- package/deployments/iotal1-sandbox-local/executor_call_type.json +73 -0
- package/deployments/iotal1-sandbox-local/executor_fee_lib.json +60 -0
- package/deployments/iotal1-sandbox-local/executor_layerzero.json +56 -0
- package/deployments/iotal1-sandbox-local/executor_ptb_builder.json +45 -0
- package/deployments/iotal1-sandbox-local/layerzero_views.json +46 -0
- package/deployments/iotal1-sandbox-local/message_lib_common.json +47 -0
- package/deployments/iotal1-sandbox-local/msglib_ptb_builder_call_types.json +45 -0
- package/deployments/iotal1-sandbox-local/multi_call.json +45 -0
- package/deployments/iotal1-sandbox-local/oapp.json +50 -0
- package/deployments/iotal1-sandbox-local/object-BlockedMessageLib.json +9 -0
- package/deployments/iotal1-sandbox-local/object-BlockedMsglibPtbBuilder.json +9 -0
- package/deployments/iotal1-sandbox-local/object-Counter.json +9 -0
- package/deployments/iotal1-sandbox-local/object-CounterAdminCap.json +9 -0
- package/deployments/iotal1-sandbox-local/object-CounterOApp.json +9 -0
- package/deployments/iotal1-sandbox-local/object-DVN.json +5 -0
- package/deployments/iotal1-sandbox-local/object-DVNCap.json +9 -0
- package/deployments/iotal1-sandbox-local/object-DVNFeeLib.json +9 -0
- package/deployments/iotal1-sandbox-local/object-EndpointPtbBuilder.json +9 -0
- package/deployments/iotal1-sandbox-local/object-EndpointPtbBuilderAdminCap.json +9 -0
- package/deployments/iotal1-sandbox-local/object-EndpointV2.json +9 -0
- package/deployments/iotal1-sandbox-local/object-EndpointV2AdminCap.json +9 -0
- package/deployments/iotal1-sandbox-local/object-Executor.json +5 -0
- package/deployments/iotal1-sandbox-local/object-ExecutorCap.json +9 -0
- package/deployments/iotal1-sandbox-local/object-ExecutorFeeLib.json +9 -0
- package/deployments/iotal1-sandbox-local/object-ExecutorOwnerCap.json +5 -0
- package/deployments/iotal1-sandbox-local/object-PackageWhitelistValidator.json +9 -0
- package/deployments/iotal1-sandbox-local/object-PriceFeed.json +9 -0
- package/deployments/iotal1-sandbox-local/object-PriceFeedOwnerCap.json +9 -0
- package/deployments/iotal1-sandbox-local/object-SimpleMessageLib.json +9 -0
- package/deployments/iotal1-sandbox-local/object-SimpleMessageLibAdminCap.json +9 -0
- package/deployments/iotal1-sandbox-local/object-SmlPtbBuilder.json +9 -0
- package/deployments/iotal1-sandbox-local/object-Treasury.json +9 -0
- package/deployments/iotal1-sandbox-local/object-TreasuryAdminCap.json +9 -0
- package/deployments/iotal1-sandbox-local/object-ULN302.json +9 -0
- package/deployments/iotal1-sandbox-local/object-ULN302AdminCap.json +9 -0
- package/deployments/iotal1-sandbox-local/object-Uln302PtbBuilder.json +9 -0
- package/deployments/iotal1-sandbox-local/object-Uln302Verification.json +9 -0
- package/deployments/iotal1-sandbox-local/object-WorkerRegistry.json +9 -0
- package/deployments/iotal1-sandbox-local/object-ZroCoinMetadata.json +9 -0
- package/deployments/iotal1-sandbox-local/object-ZroTreasuryCap.json +9 -0
- package/deployments/iotal1-sandbox-local/package_whitelist_validator.json +113 -0
- package/deployments/iotal1-sandbox-local/price_feed.json +98 -0
- package/deployments/iotal1-sandbox-local/price_feed_call_types.json +45 -0
- package/deployments/iotal1-sandbox-local/ptb_move_call.json +48 -0
- package/deployments/iotal1-sandbox-local/simple_message_lib.json +69 -0
- package/deployments/iotal1-sandbox-local/simple_msglib_ptb_builder.json +58 -0
- package/deployments/iotal1-sandbox-local/treasury.json +97 -0
- package/deployments/iotal1-sandbox-local/uln_302.json +87 -0
- package/deployments/iotal1-sandbox-local/uln_302_ptb_builder.json +58 -0
- package/deployments/iotal1-sandbox-local/uln_common.json +49 -0
- package/deployments/iotal1-sandbox-local/utils.json +78 -0
- package/deployments/iotal1-sandbox-local/worker_common.json +46 -0
- package/deployments/iotal1-sandbox-local/worker_registry.json +58 -0
- package/deployments/iotal1-sandbox-local/zro.json +67 -0
- package/deployments/iotal1-testnet/blocked_message_lib.json +58 -0
- package/deployments/iotal1-testnet/blocked_msglib_ptb_builder.json +58 -0
- package/deployments/iotal1-testnet/call.json +46 -0
- package/deployments/iotal1-testnet/counter.json +85 -0
- package/deployments/iotal1-testnet/dvn.json +49 -0
- package/deployments/iotal1-testnet/dvn_call_type.json +45 -0
- package/deployments/iotal1-testnet/dvn_fee_lib.json +59 -0
- package/deployments/iotal1-testnet/dvn_layerzero.json +56 -0
- package/deployments/iotal1-testnet/dvn_ptb_builder.json +45 -0
- package/deployments/iotal1-testnet/endpoint_ptb_builder.json +70 -0
- package/deployments/iotal1-testnet/endpoint_v2.json +86 -0
- package/deployments/iotal1-testnet/executor.json +49 -0
- package/deployments/iotal1-testnet/executor_call_type.json +45 -0
- package/deployments/iotal1-testnet/executor_fee_lib.json +60 -0
- package/deployments/iotal1-testnet/executor_layerzero.json +56 -0
- package/deployments/iotal1-testnet/executor_ptb_builder.json +45 -0
- package/deployments/iotal1-testnet/layerzero_views.json +46 -0
- package/deployments/iotal1-testnet/message_lib_common.json +47 -0
- package/deployments/iotal1-testnet/msglib_ptb_builder_call_types.json +45 -0
- package/deployments/iotal1-testnet/multi_call.json +45 -0
- package/deployments/iotal1-testnet/oapp.json +50 -0
- package/deployments/iotal1-testnet/object-BlockedMessageLib.json +9 -0
- package/deployments/iotal1-testnet/object-BlockedMsglibPtbBuilder.json +9 -0
- package/deployments/iotal1-testnet/object-Counter.json +9 -0
- package/deployments/iotal1-testnet/object-CounterAdminCap.json +9 -0
- package/deployments/iotal1-testnet/object-CounterOApp.json +9 -0
- package/deployments/iotal1-testnet/object-DVN.json +5 -0
- package/deployments/iotal1-testnet/object-DVNCap.json +9 -0
- package/deployments/iotal1-testnet/object-DVNFeeLib.json +9 -0
- package/deployments/iotal1-testnet/object-EndpointPtbBuilder.json +9 -0
- package/deployments/iotal1-testnet/object-EndpointPtbBuilderAdminCap.json +9 -0
- package/deployments/iotal1-testnet/object-EndpointV2.json +9 -0
- package/deployments/iotal1-testnet/object-EndpointV2AdminCap.json +9 -0
- package/deployments/iotal1-testnet/object-Executor.json +5 -0
- package/deployments/iotal1-testnet/object-ExecutorCap.json +9 -0
- package/deployments/iotal1-testnet/object-ExecutorFeeLib.json +9 -0
- package/deployments/iotal1-testnet/object-ExecutorOwnerCap.json +5 -0
- package/deployments/iotal1-testnet/object-PackageWhitelistValidator.json +9 -0
- package/deployments/iotal1-testnet/object-PriceFeed.json +9 -0
- package/deployments/iotal1-testnet/object-PriceFeedOwnerCap.json +9 -0
- package/deployments/iotal1-testnet/object-SimpleMessageLib.json +9 -0
- package/deployments/iotal1-testnet/object-SimpleMessageLibAdminCap.json +9 -0
- package/deployments/iotal1-testnet/object-SmlPtbBuilder.json +9 -0
- package/deployments/iotal1-testnet/object-Treasury.json +9 -0
- package/deployments/iotal1-testnet/object-TreasuryAdminCap.json +9 -0
- package/deployments/iotal1-testnet/object-ULN302.json +9 -0
- package/deployments/iotal1-testnet/object-ULN302AdminCap.json +9 -0
- package/deployments/iotal1-testnet/object-Uln302PtbBuilder.json +9 -0
- package/deployments/iotal1-testnet/object-Uln302Verification.json +9 -0
- package/deployments/iotal1-testnet/object-WorkerRegistry.json +9 -0
- package/deployments/iotal1-testnet/object-ZroCoinMetadata.json +9 -0
- package/deployments/iotal1-testnet/object-ZroTreasuryCap.json +9 -0
- package/deployments/iotal1-testnet/package_whitelist_validator.json +113 -0
- package/deployments/iotal1-testnet/price_feed.json +70 -0
- package/deployments/iotal1-testnet/price_feed_call_types.json +45 -0
- package/deployments/iotal1-testnet/ptb_move_call.json +48 -0
- package/deployments/iotal1-testnet/simple_message_lib.json +69 -0
- package/deployments/iotal1-testnet/simple_msglib_ptb_builder.json +58 -0
- package/deployments/iotal1-testnet/treasury.json +69 -0
- package/deployments/iotal1-testnet/uln_302.json +87 -0
- package/deployments/iotal1-testnet/uln_302_ptb_builder.json +58 -0
- package/deployments/iotal1-testnet/uln_common.json +49 -0
- package/deployments/iotal1-testnet/utils.json +57 -0
- package/deployments/iotal1-testnet/worker_common.json +46 -0
- package/deployments/iotal1-testnet/worker_registry.json +58 -0
- package/deployments/iotal1-testnet/zro.json +67 -0
- package/dist/index.cjs +11279 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +5824 -0
- package/dist/index.d.ts +5824 -0
- package/dist/index.mjs +11107 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +68 -0
- package/src/bcs/dvn.ts +7 -0
- package/src/bcs/endpoint.ts +7 -0
- package/src/bcs/executor.ts +27 -0
- package/src/bcs/index.ts +8 -0
- package/src/bcs/messaging-fee.ts +6 -0
- package/src/bcs/move-call.ts +28 -0
- package/src/bcs/oapp.ts +14 -0
- package/src/bcs/price-feed.ts +21 -0
- package/src/bcs/uln.ts +15 -0
- package/src/generated/addresses.ts +344 -0
- package/src/index.ts +5 -0
- package/src/module-manager.ts +360 -0
- package/src/modules/call.ts +245 -0
- package/src/modules/endpoint.ts +2417 -0
- package/src/modules/index.ts +10 -0
- package/src/modules/layerzero-views.ts +205 -0
- package/src/modules/message-libs/blocked-message-lib.ts +112 -0
- package/src/modules/message-libs/index.ts +4 -0
- package/src/modules/message-libs/simple-message-lib.ts +270 -0
- package/src/modules/message-libs/uln302.ts +827 -0
- package/src/modules/oapps/counter.ts +458 -0
- package/src/modules/oapps/index.ts +3 -0
- package/src/modules/oapps/oapp.ts +744 -0
- package/src/modules/ptb-builders/blocked-message-lib-ptb-builder.ts +49 -0
- package/src/modules/ptb-builders/dvn-ptb-builder.ts +58 -0
- package/src/modules/ptb-builders/endpoint-ptb-builder.ts +520 -0
- package/src/modules/ptb-builders/executor-ptb-builder.ts +58 -0
- package/src/modules/ptb-builders/index.ts +9 -0
- package/src/modules/ptb-builders/package-whitelist-validator.ts +142 -0
- package/src/modules/ptb-builders/ptb-builder.ts +357 -0
- package/src/modules/ptb-builders/simple-message-lib-ptb-builder.ts +53 -0
- package/src/modules/ptb-builders/uln302-ptb-builder.ts +222 -0
- package/src/modules/utils.ts +902 -0
- package/src/modules/workers/dvn-fee-lib.ts +89 -0
- package/src/modules/workers/dvn-layerzero.ts +85 -0
- package/src/modules/workers/dvn.ts +1727 -0
- package/src/modules/workers/executor-fee-lib.ts +94 -0
- package/src/modules/workers/executor-layerzero.ts +79 -0
- package/src/modules/workers/executor.ts +1170 -0
- package/src/modules/workers/index.ts +10 -0
- package/src/modules/workers/price-feed.ts +575 -0
- package/src/modules/workers/treasury.ts +295 -0
- package/src/modules/workers/worker-registry.ts +110 -0
- package/src/modules/zro.ts +94 -0
- package/src/resource.ts +104 -0
- package/src/sdk.ts +183 -0
- package/src/types/dvn.ts +20 -0
- package/src/types/endpoint.ts +16 -0
- package/src/types/errors.ts +10 -0
- package/src/types/executor.ts +23 -0
- package/src/types/index.ts +13 -0
- package/src/types/layerzero-views.ts +59 -0
- package/src/types/message-lib.ts +38 -0
- package/src/types/modules.ts +36 -0
- package/src/types/move-types.ts +24 -0
- package/src/types/oapp.ts +6 -0
- package/src/types/options.ts +333 -0
- package/src/types/price-feed.ts +21 -0
- package/src/types/ptb-builder.ts +29 -0
- package/src/types/simulation.ts +8 -0
- package/src/utils/argument.ts +198 -0
- package/src/utils/index.ts +8 -0
- package/src/utils/move-call-object-fetcher.ts +105 -0
- package/src/utils/non-sender-object-validator.ts +102 -0
- package/src/utils/package-allowlist-validator.ts +134 -0
- package/src/utils/ptb-validator.ts +14 -0
- package/src/utils/share-object-validator.ts +37 -0
- package/src/utils/transaction.ts +157 -0
- package/src/utils/type-name.ts +99 -0
- package/src/utils/validate-with-details.ts +50 -0
|
@@ -0,0 +1,744 @@
|
|
|
1
|
+
import { bcs } from '@iota/iota-sdk/bcs'
|
|
2
|
+
import { IotaClient } from '@iota/iota-sdk/client'
|
|
3
|
+
import { Transaction, TransactionArgument, TransactionResult } from '@iota/iota-sdk/transactions'
|
|
4
|
+
|
|
5
|
+
import { OAppInfoV1Bcs } from '../../bcs'
|
|
6
|
+
import { ModuleManager } from '../../module-manager'
|
|
7
|
+
import { ObjectOptions } from '../../types'
|
|
8
|
+
import { OAppInfoV1 } from '../../types/oapp'
|
|
9
|
+
import {
|
|
10
|
+
asAddress,
|
|
11
|
+
asBytes,
|
|
12
|
+
asBytes32,
|
|
13
|
+
asObject,
|
|
14
|
+
asU16,
|
|
15
|
+
asU32,
|
|
16
|
+
asU64,
|
|
17
|
+
executeSimulate,
|
|
18
|
+
isTransactionArgument,
|
|
19
|
+
} from '../../utils'
|
|
20
|
+
|
|
21
|
+
const MODULE_NAME = 'oapp'
|
|
22
|
+
|
|
23
|
+
export const OAppErrorCode = {
|
|
24
|
+
// OApp related errors (matching oapp.move)
|
|
25
|
+
OApp_EInvalidAdminCap: 1,
|
|
26
|
+
OApp_EInvalidOAppCap: 2,
|
|
27
|
+
OApp_EInvalidRefundAddress: 3,
|
|
28
|
+
OApp_EInvalidSendingCall: 4,
|
|
29
|
+
OApp_EOnlyEndpoint: 5,
|
|
30
|
+
OApp_EOnlyPeer: 6,
|
|
31
|
+
OApp_ESendingInProgress: 7,
|
|
32
|
+
|
|
33
|
+
// OAppPeer related errors (matching oapp_peer.move)
|
|
34
|
+
OAppPeer_EPeerNotFound: 0,
|
|
35
|
+
OAppPeer_EInvalidPeer: 1,
|
|
36
|
+
|
|
37
|
+
// EnforcedOptions related errors (matching enforced_options.move)
|
|
38
|
+
EnforcedOptions_EEnforcedOptionsNotFound: 1,
|
|
39
|
+
EnforcedOptions_EInvalidOptionsLength: 2,
|
|
40
|
+
EnforcedOptions_EInvalidOptionsType: 3,
|
|
41
|
+
|
|
42
|
+
// OAppInfoV1 related errors (matching oapp_info_v1.move)
|
|
43
|
+
OAppInfoV1_EInvalidData: 1,
|
|
44
|
+
OAppInfoV1_EInvalidVersion: 2,
|
|
45
|
+
} as const
|
|
46
|
+
|
|
47
|
+
export class OApp {
|
|
48
|
+
public packageId: string
|
|
49
|
+
public oappCallCapId: string
|
|
50
|
+
public readonly client: IotaClient
|
|
51
|
+
public oappInfo: OAppInfoV1 | null = null
|
|
52
|
+
private readonly objects: ObjectOptions
|
|
53
|
+
|
|
54
|
+
constructor(
|
|
55
|
+
packageId: string,
|
|
56
|
+
oappCallCapId: string,
|
|
57
|
+
client: IotaClient,
|
|
58
|
+
objects: ObjectOptions,
|
|
59
|
+
private readonly moduleManager: ModuleManager
|
|
60
|
+
) {
|
|
61
|
+
this.packageId = packageId
|
|
62
|
+
this.oappCallCapId = oappCallCapId
|
|
63
|
+
this.client = client
|
|
64
|
+
this.objects = objects
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// === Set Functions ===
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Set enforced options for OApp messaging
|
|
71
|
+
* @param tx - The transaction to add the move call to
|
|
72
|
+
* @param eid - Endpoint ID or transaction argument
|
|
73
|
+
* @param msgType - Message type or transaction argument
|
|
74
|
+
* @param options - Enforced options as bytes or transaction argument
|
|
75
|
+
*/
|
|
76
|
+
async setEnforcedOptionsMoveCall(
|
|
77
|
+
tx: Transaction,
|
|
78
|
+
eid: number | TransactionArgument,
|
|
79
|
+
msgType: number | TransactionArgument,
|
|
80
|
+
options: Uint8Array | TransactionArgument
|
|
81
|
+
): Promise<void> {
|
|
82
|
+
const oappInfo = await this.#oappInfo()
|
|
83
|
+
const adminCap = await this.getAdminCap(oappInfo.oapp_object)
|
|
84
|
+
tx.moveCall({
|
|
85
|
+
target: this.#target('set_enforced_options'),
|
|
86
|
+
arguments: [
|
|
87
|
+
asObject(tx, oappInfo.oapp_object),
|
|
88
|
+
asObject(tx, adminCap),
|
|
89
|
+
asU32(tx, eid),
|
|
90
|
+
asU16(tx, msgType),
|
|
91
|
+
asBytes(tx, options),
|
|
92
|
+
],
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Set peer OApp on another chain
|
|
98
|
+
* @param tx - The transaction to add the move call to
|
|
99
|
+
* @param eid - Peer endpoint ID or transaction argument
|
|
100
|
+
* @param peer - Peer OApp address as bytes or transaction argument
|
|
101
|
+
*/
|
|
102
|
+
async setPeerMoveCall(
|
|
103
|
+
tx: Transaction,
|
|
104
|
+
eid: number | TransactionArgument,
|
|
105
|
+
peer: Uint8Array | TransactionArgument
|
|
106
|
+
): Promise<void> {
|
|
107
|
+
const oappInfo = await this.#oappInfo()
|
|
108
|
+
const adminCap = await this.getAdminCap(oappInfo.oapp_object)
|
|
109
|
+
const messagingChannel = await this.moduleManager.getEndpoint().getMessagingChannel(this.oappCallCapId)
|
|
110
|
+
tx.moveCall({
|
|
111
|
+
target: this.#target('set_peer'),
|
|
112
|
+
arguments: [
|
|
113
|
+
asObject(tx, oappInfo.oapp_object),
|
|
114
|
+
asObject(tx, adminCap),
|
|
115
|
+
asObject(tx, this.objects.endpointV2),
|
|
116
|
+
asObject(tx, messagingChannel),
|
|
117
|
+
asU32(tx, eid),
|
|
118
|
+
asBytes32(tx, peer, this.moduleManager.getUtils()),
|
|
119
|
+
],
|
|
120
|
+
})
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// === View Functions ===
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Get admin capability address for OApp
|
|
127
|
+
* @param tx - The transaction to add the move call to
|
|
128
|
+
* @param oapp - The OApp object ID or transaction argument
|
|
129
|
+
* @returns Transaction result containing the admin capability address
|
|
130
|
+
*/
|
|
131
|
+
getAdminCapMoveCall(tx: Transaction, oapp: string | TransactionArgument): TransactionResult {
|
|
132
|
+
return tx.moveCall({
|
|
133
|
+
target: this.#target('admin_cap'),
|
|
134
|
+
arguments: [asObject(tx, oapp)],
|
|
135
|
+
})
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Get admin capability address for OApp
|
|
140
|
+
* @param oapp - The OApp object ID
|
|
141
|
+
* @returns Promise<string> - The admin capability address
|
|
142
|
+
*/
|
|
143
|
+
async getAdminCap(oapp: string): Promise<string> {
|
|
144
|
+
return executeSimulate(
|
|
145
|
+
this.client,
|
|
146
|
+
(tx) => {
|
|
147
|
+
this.getAdminCapMoveCall(tx, oapp)
|
|
148
|
+
},
|
|
149
|
+
(result) => bcs.Address.parse(result[0].value)
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Get OApp CallCap identifier
|
|
155
|
+
* @param tx - The transaction to add the move call to
|
|
156
|
+
* @returns Transaction result containing the OApp CallCap identifier
|
|
157
|
+
*/
|
|
158
|
+
async getOAppCapIdMoveCall(tx: Transaction): Promise<TransactionResult> {
|
|
159
|
+
const oappInfo = await this.#oappInfo()
|
|
160
|
+
return tx.moveCall({
|
|
161
|
+
target: this.#target('oapp_cap_id'),
|
|
162
|
+
arguments: [asObject(tx, oappInfo.oapp_object)],
|
|
163
|
+
})
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Get OApp CallCap identifier
|
|
168
|
+
* @returns Promise<string> - The OApp CallCap identifier
|
|
169
|
+
*/
|
|
170
|
+
async getOAppCapId(): Promise<string> {
|
|
171
|
+
return executeSimulate(
|
|
172
|
+
this.client,
|
|
173
|
+
async (tx) => {
|
|
174
|
+
await this.getOAppCapIdMoveCall(tx)
|
|
175
|
+
},
|
|
176
|
+
(result) => bcs.Address.parse(result[0].value)
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Combine enforced options with extra options for message execution
|
|
182
|
+
* @param tx - The transaction to add the move call to
|
|
183
|
+
* @param eid - Destination endpoint ID or transaction argument
|
|
184
|
+
* @param msgType - Message type or transaction argument
|
|
185
|
+
* @param extraOptions - Extra options to combine with enforced options or transaction argument
|
|
186
|
+
* @returns Transaction result containing combined options
|
|
187
|
+
*/
|
|
188
|
+
async combineOptionsMoveCall(
|
|
189
|
+
tx: Transaction,
|
|
190
|
+
eid: number | TransactionArgument,
|
|
191
|
+
msgType: number | TransactionArgument,
|
|
192
|
+
extraOptions: Uint8Array | TransactionArgument
|
|
193
|
+
): Promise<TransactionResult> {
|
|
194
|
+
const oappInfo = await this.#oappInfo()
|
|
195
|
+
return tx.moveCall({
|
|
196
|
+
target: this.#target('combine_options'),
|
|
197
|
+
arguments: [
|
|
198
|
+
asObject(tx, oappInfo.oapp_object),
|
|
199
|
+
asU32(tx, eid),
|
|
200
|
+
asU16(tx, msgType),
|
|
201
|
+
asBytes(tx, extraOptions),
|
|
202
|
+
],
|
|
203
|
+
})
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Combine enforced options with extra options for message execution
|
|
208
|
+
* @param eid - Destination endpoint ID
|
|
209
|
+
* @param msgType - Message type
|
|
210
|
+
* @param extraOptions - Extra options to combine with enforced options
|
|
211
|
+
* @returns Promise<Uint8Array> - Combined options as bytes
|
|
212
|
+
*/
|
|
213
|
+
async combineOptions(eid: number, msgType: number, extraOptions: Uint8Array): Promise<Uint8Array> {
|
|
214
|
+
return executeSimulate(
|
|
215
|
+
this.client,
|
|
216
|
+
async (tx) => {
|
|
217
|
+
await this.combineOptionsMoveCall(tx, eid, msgType, extraOptions)
|
|
218
|
+
},
|
|
219
|
+
(result) => new Uint8Array(bcs.vector(bcs.u8()).parse(result[0].value))
|
|
220
|
+
)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Get enforced options for a specific destination and message type
|
|
225
|
+
* @param tx - The transaction to add the move call to
|
|
226
|
+
* @param eid - Destination endpoint ID or transaction argument
|
|
227
|
+
* @param msgType - Message type or transaction argument
|
|
228
|
+
* @returns Transaction result containing enforced options
|
|
229
|
+
*/
|
|
230
|
+
async getEnforcedOptionsMoveCall(
|
|
231
|
+
tx: Transaction,
|
|
232
|
+
eid: number | TransactionArgument,
|
|
233
|
+
msgType: number | TransactionArgument
|
|
234
|
+
): Promise<TransactionResult> {
|
|
235
|
+
const oappInfo = await this.#oappInfo()
|
|
236
|
+
return tx.moveCall({
|
|
237
|
+
target: this.#target('get_enforced_options'),
|
|
238
|
+
arguments: [asObject(tx, oappInfo.oapp_object), asU32(tx, eid), asU16(tx, msgType)],
|
|
239
|
+
})
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Get enforced options for a specific destination and message type
|
|
244
|
+
* @param eid - Destination endpoint ID
|
|
245
|
+
* @param msgType - Message type
|
|
246
|
+
* @returns Promise<Uint8Array> - Enforced options as bytes
|
|
247
|
+
*/
|
|
248
|
+
async getEnforcedOptions(eid: number, msgType: number): Promise<Uint8Array> {
|
|
249
|
+
return executeSimulate(
|
|
250
|
+
this.client,
|
|
251
|
+
async (tx) => {
|
|
252
|
+
await this.getEnforcedOptionsMoveCall(tx, eid, msgType)
|
|
253
|
+
},
|
|
254
|
+
(result) => new Uint8Array(bcs.vector(bcs.u8()).parse(result[0].value))
|
|
255
|
+
)
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Check if a peer is configured for a specific destination chain
|
|
260
|
+
* @param tx - The transaction to add the move call to
|
|
261
|
+
* @param dstEid - Destination endpoint ID or transaction argument
|
|
262
|
+
* @returns Transaction result containing boolean result
|
|
263
|
+
*/
|
|
264
|
+
async hasPeerMoveCall(tx: Transaction, dstEid: number | TransactionArgument): Promise<TransactionResult> {
|
|
265
|
+
const oappInfo = await this.#oappInfo()
|
|
266
|
+
return tx.moveCall({
|
|
267
|
+
target: this.#target('has_peer'),
|
|
268
|
+
arguments: [asObject(tx, oappInfo.oapp_object), asU32(tx, dstEid)],
|
|
269
|
+
})
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Check if a peer is configured for a specific destination chain
|
|
274
|
+
* @param dstEid - Destination endpoint ID
|
|
275
|
+
* @returns Promise<boolean> - True if peer is configured, false otherwise
|
|
276
|
+
*/
|
|
277
|
+
async hasPeer(dstEid: number): Promise<boolean> {
|
|
278
|
+
return executeSimulate(
|
|
279
|
+
this.client,
|
|
280
|
+
async (tx) => {
|
|
281
|
+
await this.hasPeerMoveCall(tx, dstEid)
|
|
282
|
+
},
|
|
283
|
+
(result) => bcs.Bool.parse(result[0].value)
|
|
284
|
+
)
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Get the configured peer address for a specific destination chain
|
|
289
|
+
* @param tx - The transaction to add the move call to
|
|
290
|
+
* @param dstEid - Destination endpoint ID or transaction argument
|
|
291
|
+
* @returns Transaction result containing peer address
|
|
292
|
+
*/
|
|
293
|
+
async getPeerMoveCall(tx: Transaction, dstEid: number | TransactionArgument): Promise<TransactionResult> {
|
|
294
|
+
const oappInfo = await this.#oappInfo()
|
|
295
|
+
return tx.moveCall({
|
|
296
|
+
target: this.#target('get_peer'),
|
|
297
|
+
arguments: [asObject(tx, oappInfo.oapp_object), asU32(tx, dstEid)],
|
|
298
|
+
})
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Get the configured peer address for a specific destination chain
|
|
303
|
+
* @param dstEid - Destination endpoint ID
|
|
304
|
+
* @returns Promise<Uint8Array> - Peer address as bytes32
|
|
305
|
+
*/
|
|
306
|
+
async getPeer(dstEid: number): Promise<Uint8Array> {
|
|
307
|
+
return executeSimulate(
|
|
308
|
+
this.client,
|
|
309
|
+
async (tx) => {
|
|
310
|
+
await this.getPeerMoveCall(tx, dstEid)
|
|
311
|
+
},
|
|
312
|
+
(result) => {
|
|
313
|
+
return new Uint8Array(bcs.vector(bcs.u8()).parse(result[0].value))
|
|
314
|
+
}
|
|
315
|
+
)
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Get OApp information V1 structure
|
|
320
|
+
* @param tx - The transaction to add the move call to
|
|
321
|
+
* @returns Transaction result containing the OApp information V1
|
|
322
|
+
*/
|
|
323
|
+
getOAppInfoV1MoveCall(tx: Transaction): TransactionResult {
|
|
324
|
+
const endpoint = this.moduleManager.getEndpoint()
|
|
325
|
+
const oappInfoRaw = endpoint.getOappInfoMoveCall(tx, this.oappCallCapId) // the new OAppInfo used to be named as lz_receive_info
|
|
326
|
+
return tx.moveCall({
|
|
327
|
+
target: this.#target('decode', 'oapp_info_v1'),
|
|
328
|
+
arguments: [oappInfoRaw],
|
|
329
|
+
})
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Get OApp information V1 structure
|
|
334
|
+
* @returns Promise<OAppInfoV1> - The OApp information V1
|
|
335
|
+
*/
|
|
336
|
+
async getOAppInfoV1(): Promise<OAppInfoV1> {
|
|
337
|
+
return executeSimulate(
|
|
338
|
+
this.client,
|
|
339
|
+
(tx) => {
|
|
340
|
+
this.getOAppInfoV1MoveCall(tx)
|
|
341
|
+
},
|
|
342
|
+
(result) => {
|
|
343
|
+
return OAppInfoV1Bcs.parse(result[0].value)
|
|
344
|
+
}
|
|
345
|
+
)
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
getOAppInfoV1ExtraInfoMoveCall(tx: Transaction, oappInfo: TransactionArgument): TransactionResult {
|
|
349
|
+
return tx.moveCall({
|
|
350
|
+
target: this.#target('extra_info', 'oapp_info_v1'),
|
|
351
|
+
arguments: [oappInfo],
|
|
352
|
+
})
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// === Endpoint Call Functions ===
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Register OApp with the endpoint
|
|
359
|
+
* @param tx - The transaction to add the move call to
|
|
360
|
+
* @param oappObjectId - The OApp object ID
|
|
361
|
+
* @param oappInfo - OApp information as bytes (optional)
|
|
362
|
+
* @returns Transaction result containing the messaging channel address
|
|
363
|
+
*/
|
|
364
|
+
async registerOAppMoveCall(
|
|
365
|
+
tx: Transaction,
|
|
366
|
+
oappObjectId: string,
|
|
367
|
+
oappInfo?: Uint8Array | TransactionArgument
|
|
368
|
+
): Promise<TransactionResult> {
|
|
369
|
+
let oappInfoArg: TransactionArgument
|
|
370
|
+
if (isTransactionArgument(oappInfo)) {
|
|
371
|
+
oappInfoArg = oappInfo
|
|
372
|
+
} else if (oappInfo) {
|
|
373
|
+
// For Some(vector<u8>), convert Uint8Array to number[] and wrap in Option
|
|
374
|
+
oappInfoArg = tx.pure.option('vector<u8>', Array.from(oappInfo))
|
|
375
|
+
} else {
|
|
376
|
+
// For None
|
|
377
|
+
oappInfoArg = tx.pure.option('vector<u8>', null)
|
|
378
|
+
}
|
|
379
|
+
const adminCap = await this.getAdminCap(oappObjectId)
|
|
380
|
+
return tx.moveCall({
|
|
381
|
+
target: this.#target('register_oapp', 'endpoint_calls'),
|
|
382
|
+
arguments: [
|
|
383
|
+
asObject(tx, oappObjectId),
|
|
384
|
+
asObject(tx, adminCap),
|
|
385
|
+
asObject(tx, this.objects.endpointV2),
|
|
386
|
+
oappInfoArg,
|
|
387
|
+
],
|
|
388
|
+
})
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Set delegate for OApp
|
|
393
|
+
* @param tx - The transaction to add the move call to
|
|
394
|
+
* @param newDelegate - New delegate address
|
|
395
|
+
*/
|
|
396
|
+
async setDelegateMoveCall(tx: Transaction, newDelegate: string | TransactionArgument): Promise<void> {
|
|
397
|
+
const oappInfo = await this.#oappInfo()
|
|
398
|
+
const adminCap = await this.getAdminCap(oappInfo.oapp_object)
|
|
399
|
+
tx.moveCall({
|
|
400
|
+
target: this.#target('set_delegate', 'endpoint_calls'),
|
|
401
|
+
arguments: [
|
|
402
|
+
asObject(tx, oappInfo.oapp_object),
|
|
403
|
+
asObject(tx, adminCap),
|
|
404
|
+
asObject(tx, this.objects.endpointV2),
|
|
405
|
+
asAddress(tx, newDelegate),
|
|
406
|
+
],
|
|
407
|
+
})
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Set OApp information in the endpoint
|
|
412
|
+
* @param tx - The transaction to add the move call to
|
|
413
|
+
* @param oappInfo - OApp information as bytes
|
|
414
|
+
* @param oappObjectId - Optional OApp object ID (uses configured oapp if not provided)
|
|
415
|
+
*/
|
|
416
|
+
async setOAppInfoMoveCall(
|
|
417
|
+
tx: Transaction,
|
|
418
|
+
oappInfo: Uint8Array | TransactionArgument,
|
|
419
|
+
oappObjectId?: string
|
|
420
|
+
): Promise<void> {
|
|
421
|
+
if (oappObjectId === undefined) {
|
|
422
|
+
const oappInfoObj = await this.#oappInfo()
|
|
423
|
+
oappObjectId = oappInfoObj.oapp_object
|
|
424
|
+
}
|
|
425
|
+
const adminCap = await this.getAdminCap(oappObjectId)
|
|
426
|
+
tx.moveCall({
|
|
427
|
+
target: this.#target('set_oapp_info', 'endpoint_calls'),
|
|
428
|
+
arguments: [
|
|
429
|
+
asObject(tx, oappObjectId),
|
|
430
|
+
asObject(tx, adminCap),
|
|
431
|
+
asObject(tx, this.objects.endpointV2),
|
|
432
|
+
asBytes(tx, oappInfo),
|
|
433
|
+
],
|
|
434
|
+
})
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Initialize channel with remote OApp
|
|
439
|
+
* @param tx - The transaction to add the move call to
|
|
440
|
+
* @param remoteEid - Remote endpoint ID
|
|
441
|
+
* @param remoteOApp - Remote OApp address as bytes32
|
|
442
|
+
*/
|
|
443
|
+
async initChannelMoveCall(
|
|
444
|
+
tx: Transaction,
|
|
445
|
+
remoteEid: number | TransactionArgument,
|
|
446
|
+
remoteOApp: Uint8Array | TransactionArgument
|
|
447
|
+
): Promise<void> {
|
|
448
|
+
const oappInfo = await this.#oappInfo()
|
|
449
|
+
const adminCap = await this.getAdminCap(oappInfo.oapp_object)
|
|
450
|
+
const messagingChannel = await this.moduleManager.getEndpoint().getMessagingChannel(this.oappCallCapId)
|
|
451
|
+
tx.moveCall({
|
|
452
|
+
target: this.#target('init_channel', 'endpoint_calls'),
|
|
453
|
+
arguments: [
|
|
454
|
+
asObject(tx, oappInfo.oapp_object),
|
|
455
|
+
asObject(tx, adminCap),
|
|
456
|
+
asObject(tx, this.objects.endpointV2),
|
|
457
|
+
asObject(tx, messagingChannel),
|
|
458
|
+
asU32(tx, remoteEid),
|
|
459
|
+
asBytes32(tx, remoteOApp, this.moduleManager.getUtils()),
|
|
460
|
+
],
|
|
461
|
+
})
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Clear a message from the messaging channel
|
|
466
|
+
* @param tx - The transaction to add the move call to
|
|
467
|
+
* @param srcEid - Source endpoint ID
|
|
468
|
+
* @param sender - Sender address as bytes32
|
|
469
|
+
* @param nonce - Message nonce
|
|
470
|
+
* @param guid - Message GUID as bytes32
|
|
471
|
+
* @param message - Message payload
|
|
472
|
+
*/
|
|
473
|
+
async clearMoveCall(
|
|
474
|
+
tx: Transaction,
|
|
475
|
+
srcEid: number | TransactionArgument,
|
|
476
|
+
sender: Uint8Array | TransactionArgument,
|
|
477
|
+
nonce: number | bigint | TransactionArgument,
|
|
478
|
+
guid: Uint8Array | TransactionArgument,
|
|
479
|
+
message: Uint8Array | TransactionArgument
|
|
480
|
+
): Promise<void> {
|
|
481
|
+
const oappInfo = await this.#oappInfo()
|
|
482
|
+
const adminCap = await this.getAdminCap(oappInfo.oapp_object)
|
|
483
|
+
const messagingChannel = await this.moduleManager.getEndpoint().getMessagingChannel(this.oappCallCapId)
|
|
484
|
+
tx.moveCall({
|
|
485
|
+
target: this.#target('clear', 'endpoint_calls'),
|
|
486
|
+
arguments: [
|
|
487
|
+
asObject(tx, oappInfo.oapp_object),
|
|
488
|
+
asObject(tx, adminCap),
|
|
489
|
+
asObject(tx, this.objects.endpointV2),
|
|
490
|
+
asObject(tx, messagingChannel),
|
|
491
|
+
asU32(tx, srcEid),
|
|
492
|
+
asBytes32(tx, sender, this.moduleManager.getUtils()),
|
|
493
|
+
asU64(tx, nonce),
|
|
494
|
+
asBytes32(tx, guid, this.moduleManager.getUtils()),
|
|
495
|
+
asBytes(tx, message),
|
|
496
|
+
],
|
|
497
|
+
})
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Skip a message in the messaging channel
|
|
502
|
+
* @param tx - The transaction to add the move call to
|
|
503
|
+
* @param srcEid - Source endpoint ID
|
|
504
|
+
* @param sender - Sender address as bytes32
|
|
505
|
+
* @param nonce - Message nonce
|
|
506
|
+
*/
|
|
507
|
+
async skipMoveCall(
|
|
508
|
+
tx: Transaction,
|
|
509
|
+
srcEid: number | TransactionArgument,
|
|
510
|
+
sender: Uint8Array | TransactionArgument,
|
|
511
|
+
nonce: number | bigint | TransactionArgument
|
|
512
|
+
): Promise<void> {
|
|
513
|
+
const oappInfo = await this.#oappInfo()
|
|
514
|
+
const adminCap = await this.getAdminCap(oappInfo.oapp_object)
|
|
515
|
+
const messagingChannel = await this.moduleManager.getEndpoint().getMessagingChannel(this.oappCallCapId)
|
|
516
|
+
tx.moveCall({
|
|
517
|
+
target: this.#target('skip', 'endpoint_calls'),
|
|
518
|
+
arguments: [
|
|
519
|
+
asObject(tx, oappInfo.oapp_object),
|
|
520
|
+
asObject(tx, adminCap),
|
|
521
|
+
asObject(tx, this.objects.endpointV2),
|
|
522
|
+
asObject(tx, messagingChannel),
|
|
523
|
+
asU32(tx, srcEid),
|
|
524
|
+
asBytes32(tx, sender, this.moduleManager.getUtils()),
|
|
525
|
+
asU64(tx, nonce),
|
|
526
|
+
],
|
|
527
|
+
})
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* Nilify a message in the messaging channel
|
|
532
|
+
* @param tx - The transaction to add the move call to
|
|
533
|
+
* @param srcEid - Source endpoint ID
|
|
534
|
+
* @param sender - Sender address as bytes32
|
|
535
|
+
* @param nonce - Message nonce
|
|
536
|
+
* @param payloadHash - Payload hash as bytes32
|
|
537
|
+
*/
|
|
538
|
+
async nilifyMoveCall(
|
|
539
|
+
tx: Transaction,
|
|
540
|
+
srcEid: number | TransactionArgument,
|
|
541
|
+
sender: Uint8Array | TransactionArgument,
|
|
542
|
+
nonce: number | bigint | TransactionArgument,
|
|
543
|
+
payloadHash: Uint8Array | TransactionArgument
|
|
544
|
+
): Promise<void> {
|
|
545
|
+
const oappInfo = await this.#oappInfo()
|
|
546
|
+
const adminCap = await this.getAdminCap(oappInfo.oapp_object)
|
|
547
|
+
const messagingChannel = await this.moduleManager.getEndpoint().getMessagingChannel(this.oappCallCapId)
|
|
548
|
+
tx.moveCall({
|
|
549
|
+
target: this.#target('nilify', 'endpoint_calls'),
|
|
550
|
+
arguments: [
|
|
551
|
+
asObject(tx, oappInfo.oapp_object),
|
|
552
|
+
asObject(tx, adminCap),
|
|
553
|
+
asObject(tx, this.objects.endpointV2),
|
|
554
|
+
asObject(tx, messagingChannel),
|
|
555
|
+
asU32(tx, srcEid),
|
|
556
|
+
asBytes32(tx, sender, this.moduleManager.getUtils()),
|
|
557
|
+
asU64(tx, nonce),
|
|
558
|
+
asBytes32(tx, payloadHash, this.moduleManager.getUtils()),
|
|
559
|
+
],
|
|
560
|
+
})
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Burn a message in the messaging channel
|
|
565
|
+
* @param tx - The transaction to add the move call to
|
|
566
|
+
* @param srcEid - Source endpoint ID
|
|
567
|
+
* @param sender - Sender address as bytes32
|
|
568
|
+
* @param nonce - Message nonce
|
|
569
|
+
* @param payloadHash - Payload hash as bytes32
|
|
570
|
+
*/
|
|
571
|
+
async burnMoveCall(
|
|
572
|
+
tx: Transaction,
|
|
573
|
+
srcEid: number | TransactionArgument,
|
|
574
|
+
sender: Uint8Array | TransactionArgument,
|
|
575
|
+
nonce: number | bigint | TransactionArgument,
|
|
576
|
+
payloadHash: Uint8Array | TransactionArgument
|
|
577
|
+
): Promise<void> {
|
|
578
|
+
const oappInfo = await this.#oappInfo()
|
|
579
|
+
const adminCap = await this.getAdminCap(oappInfo.oapp_object)
|
|
580
|
+
const messagingChannel = await this.moduleManager.getEndpoint().getMessagingChannel(this.oappCallCapId)
|
|
581
|
+
tx.moveCall({
|
|
582
|
+
target: this.#target('burn', 'endpoint_calls'),
|
|
583
|
+
arguments: [
|
|
584
|
+
asObject(tx, oappInfo.oapp_object),
|
|
585
|
+
asObject(tx, adminCap),
|
|
586
|
+
asObject(tx, this.objects.endpointV2),
|
|
587
|
+
asObject(tx, messagingChannel),
|
|
588
|
+
asU32(tx, srcEid),
|
|
589
|
+
asBytes32(tx, sender, this.moduleManager.getUtils()),
|
|
590
|
+
asU64(tx, nonce),
|
|
591
|
+
asBytes32(tx, payloadHash, this.moduleManager.getUtils()),
|
|
592
|
+
],
|
|
593
|
+
})
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* Set send library for a destination chain
|
|
598
|
+
* @param tx - The transaction to add the move call to
|
|
599
|
+
* @param dstEid - Destination endpoint ID
|
|
600
|
+
* @param sendLibrary - Send library address
|
|
601
|
+
*/
|
|
602
|
+
async setSendLibraryMoveCall(
|
|
603
|
+
tx: Transaction,
|
|
604
|
+
dstEid: number | TransactionArgument,
|
|
605
|
+
sendLibrary: string | TransactionArgument
|
|
606
|
+
): Promise<void> {
|
|
607
|
+
const oappInfo = await this.#oappInfo()
|
|
608
|
+
const adminCap = await this.getAdminCap(oappInfo.oapp_object)
|
|
609
|
+
tx.moveCall({
|
|
610
|
+
target: this.#target('set_send_library', 'endpoint_calls'),
|
|
611
|
+
arguments: [
|
|
612
|
+
asObject(tx, oappInfo.oapp_object),
|
|
613
|
+
asObject(tx, adminCap),
|
|
614
|
+
asObject(tx, this.objects.endpointV2),
|
|
615
|
+
asU32(tx, dstEid),
|
|
616
|
+
asAddress(tx, sendLibrary),
|
|
617
|
+
],
|
|
618
|
+
})
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* Set receive library for a source chain
|
|
623
|
+
* @param tx - The transaction to add the move call to
|
|
624
|
+
* @param srcEid - Source endpoint ID
|
|
625
|
+
* @param receiveLibrary - Receive library address
|
|
626
|
+
* @param gracePeriod - Grace period in seconds
|
|
627
|
+
*/
|
|
628
|
+
async setReceiveLibraryMoveCall(
|
|
629
|
+
tx: Transaction,
|
|
630
|
+
srcEid: number | TransactionArgument,
|
|
631
|
+
receiveLibrary: string | TransactionArgument,
|
|
632
|
+
gracePeriod: number | bigint | TransactionArgument
|
|
633
|
+
): Promise<void> {
|
|
634
|
+
const oappInfo = await this.#oappInfo()
|
|
635
|
+
const adminCap = await this.getAdminCap(oappInfo.oapp_object)
|
|
636
|
+
tx.moveCall({
|
|
637
|
+
target: this.#target('set_receive_library', 'endpoint_calls'),
|
|
638
|
+
arguments: [
|
|
639
|
+
asObject(tx, oappInfo.oapp_object),
|
|
640
|
+
asObject(tx, adminCap),
|
|
641
|
+
asObject(tx, this.objects.endpointV2),
|
|
642
|
+
asU32(tx, srcEid),
|
|
643
|
+
asAddress(tx, receiveLibrary),
|
|
644
|
+
asU64(tx, gracePeriod),
|
|
645
|
+
tx.object.clock(),
|
|
646
|
+
],
|
|
647
|
+
})
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Set receive library timeout for a source chain
|
|
652
|
+
* @param tx - The transaction to add the move call to
|
|
653
|
+
* @param srcEid - Source endpoint ID
|
|
654
|
+
* @param receiveLibrary - Receive library address
|
|
655
|
+
* @param expiry - Expiry timestamp in seconds
|
|
656
|
+
*/
|
|
657
|
+
async setReceiveLibraryTimeoutMoveCall(
|
|
658
|
+
tx: Transaction,
|
|
659
|
+
srcEid: number | TransactionArgument,
|
|
660
|
+
receiveLibrary: string | TransactionArgument,
|
|
661
|
+
expiry: number | bigint | TransactionArgument
|
|
662
|
+
): Promise<void> {
|
|
663
|
+
const oappInfo = await this.#oappInfo()
|
|
664
|
+
const adminCap = await this.getAdminCap(oappInfo.oapp_object)
|
|
665
|
+
tx.moveCall({
|
|
666
|
+
target: this.#target('set_receive_library_timeout', 'endpoint_calls'),
|
|
667
|
+
arguments: [
|
|
668
|
+
asObject(tx, oappInfo.oapp_object),
|
|
669
|
+
asObject(tx, adminCap),
|
|
670
|
+
asObject(tx, this.objects.endpointV2),
|
|
671
|
+
asU32(tx, srcEid),
|
|
672
|
+
asAddress(tx, receiveLibrary),
|
|
673
|
+
asU64(tx, expiry),
|
|
674
|
+
tx.object.clock(),
|
|
675
|
+
],
|
|
676
|
+
})
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* Set configuration for a message library
|
|
681
|
+
* @param tx - The transaction to add the move call to
|
|
682
|
+
* @param lib - Library address
|
|
683
|
+
* @param eid - Endpoint ID
|
|
684
|
+
* @param configType - Configuration type
|
|
685
|
+
* @param config - Configuration data as bytes
|
|
686
|
+
* @returns Transaction result containing Call<MessageLibSetConfigParam, Void>
|
|
687
|
+
*/
|
|
688
|
+
async setConfigMoveCall(
|
|
689
|
+
tx: Transaction,
|
|
690
|
+
lib: string | TransactionArgument,
|
|
691
|
+
eid: number | TransactionArgument,
|
|
692
|
+
configType: number | TransactionArgument,
|
|
693
|
+
config: Uint8Array | TransactionArgument
|
|
694
|
+
): Promise<TransactionResult> {
|
|
695
|
+
const oappInfo = await this.#oappInfo()
|
|
696
|
+
const adminCap = await this.getAdminCap(oappInfo.oapp_object)
|
|
697
|
+
return tx.moveCall({
|
|
698
|
+
target: this.#target('set_config', 'endpoint_calls'),
|
|
699
|
+
typeArguments: [],
|
|
700
|
+
arguments: [
|
|
701
|
+
asObject(tx, oappInfo.oapp_object),
|
|
702
|
+
asObject(tx, adminCap),
|
|
703
|
+
asObject(tx, this.objects.endpointV2),
|
|
704
|
+
asAddress(tx, lib),
|
|
705
|
+
asU32(tx, eid),
|
|
706
|
+
asU32(tx, configType),
|
|
707
|
+
asBytes(tx, config),
|
|
708
|
+
],
|
|
709
|
+
})
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* Refresh the cached OApp information by fetching the latest data
|
|
714
|
+
* @returns Promise<void> - Completes when the OApp info is refreshed
|
|
715
|
+
*/
|
|
716
|
+
async refreshOAppInfo(): Promise<void> {
|
|
717
|
+
this.oappInfo = await this.getOAppInfoV1()
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
// === Private Functions ===
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* Get OApp info, throwing if not set
|
|
724
|
+
* @returns The OApp info
|
|
725
|
+
* @throws Error if OApp info is not set
|
|
726
|
+
* @private
|
|
727
|
+
*/
|
|
728
|
+
async #oappInfo(): Promise<OAppInfoV1> {
|
|
729
|
+
if (!this.oappInfo) {
|
|
730
|
+
this.oappInfo = await this.getOAppInfoV1()
|
|
731
|
+
}
|
|
732
|
+
return this.oappInfo
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
/**
|
|
736
|
+
* Generate the full target path for move calls
|
|
737
|
+
* @param name - The function name to call
|
|
738
|
+
* @returns The full module path for the move call
|
|
739
|
+
* @private
|
|
740
|
+
*/
|
|
741
|
+
#target(name: string, module_name = MODULE_NAME): string {
|
|
742
|
+
return `${this.packageId}::${module_name}::${name}`
|
|
743
|
+
}
|
|
744
|
+
}
|