@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,49 @@
|
|
|
1
|
+
import { IotaClient } from '@iota/iota-sdk/client'
|
|
2
|
+
import { Transaction, TransactionResult } from '@iota/iota-sdk/transactions'
|
|
3
|
+
|
|
4
|
+
import { ModuleManager } from '../../module-manager'
|
|
5
|
+
import { ObjectOptions } from '../../types'
|
|
6
|
+
|
|
7
|
+
const MODULE_NAME = 'blocked_msglib_ptb_builder'
|
|
8
|
+
|
|
9
|
+
export class BlockedMessageLibPtbBuilder {
|
|
10
|
+
public packageId: string
|
|
11
|
+
public readonly client: IotaClient
|
|
12
|
+
private readonly objects: ObjectOptions
|
|
13
|
+
|
|
14
|
+
constructor(
|
|
15
|
+
packageId: string,
|
|
16
|
+
client: IotaClient,
|
|
17
|
+
objects: ObjectOptions,
|
|
18
|
+
private readonly moduleManager: ModuleManager
|
|
19
|
+
) {
|
|
20
|
+
this.packageId = packageId
|
|
21
|
+
this.client = client
|
|
22
|
+
this.objects = objects
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// === View Functions ===
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Creates a transaction to get PTB builder info
|
|
29
|
+
* @param tx - The transaction to add the move call to
|
|
30
|
+
* @returns Transaction result containing PTB builder information
|
|
31
|
+
*/
|
|
32
|
+
getPtbBuilderInfoMoveCall(tx: Transaction): TransactionResult {
|
|
33
|
+
return tx.moveCall({
|
|
34
|
+
target: this.#target('get_ptb_builder_info'),
|
|
35
|
+
arguments: [tx.object(this.objects.blockedMessageLibPtbBuilder), tx.object(this.objects.blockedMessageLib)],
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Generate the full target path for move calls
|
|
41
|
+
* @param name - The function name to call
|
|
42
|
+
* @param module_name - The module name (defaults to MODULE_NAME)
|
|
43
|
+
* @returns The full module path for the move call
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
#target(name: string, module_name = MODULE_NAME): string {
|
|
47
|
+
return `${this.packageId}::${module_name}::${name}`
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { IotaClient } from '@iota/iota-sdk/client'
|
|
2
|
+
import { Transaction, TransactionArgument, TransactionResult } from '@iota/iota-sdk/transactions'
|
|
3
|
+
|
|
4
|
+
import { ModuleManager } from '../../module-manager'
|
|
5
|
+
import { ObjectOptions } from '../../types'
|
|
6
|
+
import { asObject } from '../../utils'
|
|
7
|
+
|
|
8
|
+
const MODULE_NAME = 'dvn_ptb_builder'
|
|
9
|
+
|
|
10
|
+
export class DvnPtbBuilder {
|
|
11
|
+
public packageId: string
|
|
12
|
+
public readonly client: IotaClient
|
|
13
|
+
private readonly objects: ObjectOptions
|
|
14
|
+
|
|
15
|
+
constructor(
|
|
16
|
+
packageId: string,
|
|
17
|
+
client: IotaClient,
|
|
18
|
+
objects: ObjectOptions,
|
|
19
|
+
private readonly moduleManager: ModuleManager
|
|
20
|
+
) {
|
|
21
|
+
this.packageId = packageId
|
|
22
|
+
this.client = client
|
|
23
|
+
this.objects = objects
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// === Set Functions ===
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Creates a transaction to build DVN PTB
|
|
30
|
+
* @param tx - The transaction to add the move call to
|
|
31
|
+
* @param dvnAddress - DVN object address or transaction argument
|
|
32
|
+
* @param feelibAddress - DVN fee lib object address or transaction argument
|
|
33
|
+
* @param priceFeedAddress - Price feed object address or transaction argument
|
|
34
|
+
* @returns Transaction result containing get_fee and assign_job move calls
|
|
35
|
+
*/
|
|
36
|
+
buildDvnPtbMoveCall(
|
|
37
|
+
tx: Transaction,
|
|
38
|
+
dvnAddress: string | TransactionArgument,
|
|
39
|
+
feelibAddress: string | TransactionArgument,
|
|
40
|
+
priceFeedAddress: string | TransactionArgument
|
|
41
|
+
): TransactionResult {
|
|
42
|
+
return tx.moveCall({
|
|
43
|
+
target: this.#target('build_dvn_ptb'),
|
|
44
|
+
arguments: [asObject(tx, dvnAddress), asObject(tx, feelibAddress), asObject(tx, priceFeedAddress)],
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Generate the full target path for move calls
|
|
50
|
+
* @param name - The function name to call
|
|
51
|
+
* @param module_name - The module name (defaults to MODULE_NAME)
|
|
52
|
+
* @returns The full module path for the move call
|
|
53
|
+
* @private
|
|
54
|
+
*/
|
|
55
|
+
#target(name: string, module_name = MODULE_NAME): string {
|
|
56
|
+
return `${this.packageId}::${module_name}::${name}`
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,520 @@
|
|
|
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 { ModuleManager } from '../../module-manager'
|
|
6
|
+
import { ObjectOptions } from '../../types'
|
|
7
|
+
import { asAddress, asBool, asU32, executeSimulate } from '../../utils'
|
|
8
|
+
|
|
9
|
+
export const EndpointPtbBuilderErrorCode = {
|
|
10
|
+
// EndpointPtbBuilder related errors (matching endpoint_ptb_builder.move)
|
|
11
|
+
EndpointPtbBuilder_EBuilderNotFound: 1,
|
|
12
|
+
EndpointPtbBuilder_EBuilderRegistered: 2,
|
|
13
|
+
EndpointPtbBuilder_EBuilderUnsupported: 3,
|
|
14
|
+
EndpointPtbBuilder_EInvalidBounds: 4,
|
|
15
|
+
EndpointPtbBuilder_EInvalidBuilderAddress: 5,
|
|
16
|
+
EndpointPtbBuilder_EInvalidLibrary: 6,
|
|
17
|
+
EndpointPtbBuilder_EUnauthorized: 7,
|
|
18
|
+
} as const
|
|
19
|
+
|
|
20
|
+
const ModuleName = 'endpoint_ptb_builder'
|
|
21
|
+
|
|
22
|
+
export class EndpointPtbBuilder {
|
|
23
|
+
public packageId: string
|
|
24
|
+
public readonly client: IotaClient
|
|
25
|
+
private readonly objects: ObjectOptions
|
|
26
|
+
|
|
27
|
+
constructor(
|
|
28
|
+
packageId: string,
|
|
29
|
+
client: IotaClient,
|
|
30
|
+
objects: ObjectOptions,
|
|
31
|
+
private readonly moduleManager: ModuleManager
|
|
32
|
+
) {
|
|
33
|
+
this.packageId = packageId
|
|
34
|
+
this.client = client
|
|
35
|
+
this.objects = objects
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// === Set Functions ===
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Creates a transaction to register a message library PTB builder
|
|
42
|
+
* @param tx - The transaction to add the move call to
|
|
43
|
+
* @param builderInfo - PTB builder info result from getPtbBuilderInfoMoveCall or transaction argument
|
|
44
|
+
*/
|
|
45
|
+
registerMsglibPtbBuilderMoveCall(tx: Transaction, builderInfo: TransactionArgument): void {
|
|
46
|
+
tx.moveCall({
|
|
47
|
+
target: this.#target('register_msglib_ptb_builder'),
|
|
48
|
+
arguments: [
|
|
49
|
+
tx.object(this.objects.endpointPtbBuilder),
|
|
50
|
+
tx.object(this.objects.endpointPtbBuilderAdminCap),
|
|
51
|
+
tx.object(this.objects.endpointV2),
|
|
52
|
+
builderInfo,
|
|
53
|
+
],
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Creates a transaction to set the default message library PTB builder
|
|
59
|
+
* @param tx - The transaction to add the move call to
|
|
60
|
+
* @param messageLib - Target message library address
|
|
61
|
+
* @param ptbBuilder - PTB builder address
|
|
62
|
+
*/
|
|
63
|
+
setDefaultMsglibPtbBuilderMoveCall(
|
|
64
|
+
tx: Transaction,
|
|
65
|
+
messageLib: string | TransactionArgument,
|
|
66
|
+
ptbBuilder: string | TransactionArgument
|
|
67
|
+
): void {
|
|
68
|
+
tx.moveCall({
|
|
69
|
+
target: this.#target('set_default_msglib_ptb_builder'),
|
|
70
|
+
arguments: [
|
|
71
|
+
tx.object(this.objects.endpointPtbBuilder),
|
|
72
|
+
tx.object(this.objects.endpointPtbBuilderAdminCap),
|
|
73
|
+
asAddress(tx, messageLib),
|
|
74
|
+
asAddress(tx, ptbBuilder),
|
|
75
|
+
],
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Creates a transaction to set message library PTB builder for an OApp
|
|
81
|
+
* @param tx - The transaction to add the move call to
|
|
82
|
+
* @param call - Call object for setting msglib PTB builder
|
|
83
|
+
*/
|
|
84
|
+
setMsglibPtbBuilderMoveCall(tx: Transaction, call: TransactionArgument): void {
|
|
85
|
+
tx.moveCall({
|
|
86
|
+
target: this.#target('set_msglib_ptb_builder'),
|
|
87
|
+
arguments: [tx.object(this.objects.endpointPtbBuilder), call],
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// ======== PTB Building Functions ========
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Build quote PTB by call for fee calculation
|
|
95
|
+
* @param tx - The transaction to add the move call to
|
|
96
|
+
* @param endpointQuoteCall - Endpoint quote call result
|
|
97
|
+
* @returns Transaction result containing the quote PTB
|
|
98
|
+
*/
|
|
99
|
+
buildQuotePtbByCallMoveCall(tx: Transaction, endpointQuoteCall: TransactionArgument): TransactionResult {
|
|
100
|
+
return tx.moveCall({
|
|
101
|
+
target: this.#target('build_quote_ptb_by_call'),
|
|
102
|
+
arguments: [
|
|
103
|
+
tx.object(this.objects.endpointPtbBuilder),
|
|
104
|
+
tx.object(this.objects.endpointV2),
|
|
105
|
+
endpointQuoteCall,
|
|
106
|
+
],
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Build send PTB by call for message transmission
|
|
112
|
+
* @param tx - The transaction to add the move call to
|
|
113
|
+
* @param endpointSendCall - Endpoint send call result
|
|
114
|
+
* @returns Transaction result containing the send PTB
|
|
115
|
+
*/
|
|
116
|
+
buildSendPtbByCallMoveCall(tx: Transaction, endpointSendCall: TransactionArgument): TransactionResult {
|
|
117
|
+
return tx.moveCall({
|
|
118
|
+
target: this.#target('build_send_ptb_by_call'),
|
|
119
|
+
arguments: [
|
|
120
|
+
tx.object(this.objects.endpointPtbBuilder),
|
|
121
|
+
tx.object(this.objects.endpointV2),
|
|
122
|
+
endpointSendCall,
|
|
123
|
+
],
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Build set config PTB by call for configuration updates
|
|
129
|
+
* @param tx - The transaction to add the move call to
|
|
130
|
+
* @param messageLibSetConfigCall - Endpoint set config call result
|
|
131
|
+
* @returns Transaction result containing the set config PTB
|
|
132
|
+
*/
|
|
133
|
+
buildSetConfigPtbByCallMoveCall(tx: Transaction, messageLibSetConfigCall: TransactionArgument): TransactionResult {
|
|
134
|
+
return tx.moveCall({
|
|
135
|
+
target: this.#target('build_set_config_ptb_by_call'),
|
|
136
|
+
arguments: [tx.object(this.objects.endpointPtbBuilder), messageLibSetConfigCall],
|
|
137
|
+
})
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Build quote PTB for on-chain composition
|
|
142
|
+
* @param tx - The transaction to add the move call to
|
|
143
|
+
* @param sender - Sender address
|
|
144
|
+
* @param dstEid - Destination endpoint ID
|
|
145
|
+
* @returns Transaction result containing the quote PTB
|
|
146
|
+
*/
|
|
147
|
+
buildQuotePtbMoveCall(
|
|
148
|
+
tx: Transaction,
|
|
149
|
+
sender: string | TransactionArgument,
|
|
150
|
+
dstEid: number | TransactionArgument
|
|
151
|
+
): TransactionResult {
|
|
152
|
+
return tx.moveCall({
|
|
153
|
+
target: this.#target('build_quote_ptb'),
|
|
154
|
+
arguments: [
|
|
155
|
+
tx.object(this.objects.endpointPtbBuilder),
|
|
156
|
+
tx.object(this.objects.endpointV2),
|
|
157
|
+
asAddress(tx, sender),
|
|
158
|
+
asU32(tx, dstEid),
|
|
159
|
+
],
|
|
160
|
+
})
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Build send PTB for on-chain composition
|
|
165
|
+
* @param tx - The transaction to add the move call to
|
|
166
|
+
* @param sender - Sender address
|
|
167
|
+
* @param dstEid - Destination endpoint ID
|
|
168
|
+
* @param refund - Whether to include refund step
|
|
169
|
+
* @returns Transaction result containing the send PTB
|
|
170
|
+
*/
|
|
171
|
+
buildSendPtbMoveCall(
|
|
172
|
+
tx: Transaction,
|
|
173
|
+
sender: string | TransactionArgument,
|
|
174
|
+
dstEid: number | TransactionArgument,
|
|
175
|
+
refund: boolean | TransactionArgument
|
|
176
|
+
): TransactionResult {
|
|
177
|
+
return tx.moveCall({
|
|
178
|
+
target: this.#target('build_send_ptb'),
|
|
179
|
+
arguments: [
|
|
180
|
+
tx.object(this.objects.endpointPtbBuilder),
|
|
181
|
+
tx.object(this.objects.endpointV2),
|
|
182
|
+
asAddress(tx, sender),
|
|
183
|
+
asU32(tx, dstEid),
|
|
184
|
+
asBool(tx, refund),
|
|
185
|
+
],
|
|
186
|
+
})
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Build set config PTB for on-chain composition
|
|
191
|
+
* @param tx - The transaction to add the move call to
|
|
192
|
+
* @param sender - Sender address
|
|
193
|
+
* @param lib - Message library address
|
|
194
|
+
* @returns Transaction result containing the set config PTB
|
|
195
|
+
*/
|
|
196
|
+
buildSetConfigPtbMoveCall(
|
|
197
|
+
tx: Transaction,
|
|
198
|
+
sender: string | TransactionArgument,
|
|
199
|
+
lib: string | TransactionArgument
|
|
200
|
+
): TransactionResult {
|
|
201
|
+
return tx.moveCall({
|
|
202
|
+
target: this.#target('build_set_config_ptb'),
|
|
203
|
+
arguments: [
|
|
204
|
+
tx.object(this.objects.endpointPtbBuilder),
|
|
205
|
+
tx.object(this.objects.endpointV2),
|
|
206
|
+
asAddress(tx, sender),
|
|
207
|
+
asAddress(tx, lib),
|
|
208
|
+
],
|
|
209
|
+
})
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// ======== Call ID Functions ========
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Get endpoint quote call ID
|
|
216
|
+
* @param tx - The transaction to add the move call to
|
|
217
|
+
* @returns Transaction result containing the endpoint quote call ID
|
|
218
|
+
*/
|
|
219
|
+
endpointQuoteCallIdMoveCall(tx: Transaction): TransactionResult {
|
|
220
|
+
return tx.moveCall({
|
|
221
|
+
target: this.#target('endpoint_quote_call_id'),
|
|
222
|
+
arguments: [],
|
|
223
|
+
})
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Get endpoint quote call ID as a hex string
|
|
228
|
+
* @returns Promise<string> - The endpoint quote call ID in hex format
|
|
229
|
+
*/
|
|
230
|
+
async endpointQuoteCallId(): Promise<string> {
|
|
231
|
+
return executeSimulate(
|
|
232
|
+
this.client,
|
|
233
|
+
(tx) => {
|
|
234
|
+
this.endpointQuoteCallIdMoveCall(tx)
|
|
235
|
+
},
|
|
236
|
+
(result) => Buffer.from(bcs.vector(bcs.u8()).parse(result[0].value)).toString('hex')
|
|
237
|
+
)
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Get endpoint send call ID
|
|
242
|
+
* @param tx - The transaction to add the move call to
|
|
243
|
+
* @returns Transaction result containing the endpoint send call ID
|
|
244
|
+
*/
|
|
245
|
+
endpointSendCallIdMoveCall(tx: Transaction): TransactionResult {
|
|
246
|
+
return tx.moveCall({
|
|
247
|
+
target: this.#target('endpoint_send_call_id'),
|
|
248
|
+
arguments: [],
|
|
249
|
+
})
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Get endpoint send call ID as a hex string
|
|
254
|
+
* @returns Promise<string> - The endpoint send call ID in hex format
|
|
255
|
+
*/
|
|
256
|
+
async endpointSendCallId(): Promise<string> {
|
|
257
|
+
return executeSimulate(
|
|
258
|
+
this.client,
|
|
259
|
+
(tx) => {
|
|
260
|
+
this.endpointSendCallIdMoveCall(tx)
|
|
261
|
+
},
|
|
262
|
+
(result) => Buffer.from(bcs.vector(bcs.u8()).parse(result[0].value)).toString('hex')
|
|
263
|
+
)
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Get message lib quote call ID
|
|
268
|
+
* @param tx - The transaction to add the move call to
|
|
269
|
+
* @returns Transaction result containing the message lib quote call ID
|
|
270
|
+
*/
|
|
271
|
+
messageLibQuoteCallIdMoveCall(tx: Transaction): TransactionResult {
|
|
272
|
+
return tx.moveCall({
|
|
273
|
+
target: this.#target('message_lib_quote_call_id'),
|
|
274
|
+
arguments: [],
|
|
275
|
+
})
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Get message lib quote call ID as a hex string
|
|
280
|
+
* @returns Promise<string> - The message lib quote call ID in hex format
|
|
281
|
+
*/
|
|
282
|
+
async messageLibQuoteCallId(): Promise<string> {
|
|
283
|
+
return executeSimulate(
|
|
284
|
+
this.client,
|
|
285
|
+
(tx) => {
|
|
286
|
+
this.messageLibQuoteCallIdMoveCall(tx)
|
|
287
|
+
},
|
|
288
|
+
(result) => Buffer.from(bcs.vector(bcs.u8()).parse(result[0].value)).toString('hex')
|
|
289
|
+
)
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Get message lib send call ID
|
|
294
|
+
* @param tx - The transaction to add the move call to
|
|
295
|
+
* @returns Transaction result containing the message lib send call ID
|
|
296
|
+
*/
|
|
297
|
+
messageLibSendCallIdMoveCall(tx: Transaction): TransactionResult {
|
|
298
|
+
return tx.moveCall({
|
|
299
|
+
target: this.#target('message_lib_send_call_id'),
|
|
300
|
+
arguments: [],
|
|
301
|
+
})
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Get message lib send call ID as a hex string
|
|
306
|
+
* @returns Promise<string> - The message lib send call ID in hex format
|
|
307
|
+
*/
|
|
308
|
+
async messageLibSendCallId(): Promise<string> {
|
|
309
|
+
return executeSimulate(
|
|
310
|
+
this.client,
|
|
311
|
+
(tx) => {
|
|
312
|
+
this.messageLibSendCallIdMoveCall(tx)
|
|
313
|
+
},
|
|
314
|
+
(result) => Buffer.from(bcs.vector(bcs.u8()).parse(result[0].value)).toString('hex')
|
|
315
|
+
)
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Get message lib set config call ID
|
|
320
|
+
* @param tx - The transaction to add the move call to
|
|
321
|
+
* @returns Transaction result containing the message lib set config call ID
|
|
322
|
+
*/
|
|
323
|
+
messageLibSetConfigCallIdMoveCall(tx: Transaction): TransactionResult {
|
|
324
|
+
return tx.moveCall({
|
|
325
|
+
target: this.#target('message_lib_set_config_call_id'),
|
|
326
|
+
arguments: [],
|
|
327
|
+
})
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Get message lib set config call ID as a hex string
|
|
332
|
+
* @returns Promise<string> - The message lib set config call ID in hex format
|
|
333
|
+
*/
|
|
334
|
+
async messageLibSetConfigCallId(): Promise<string> {
|
|
335
|
+
return executeSimulate(
|
|
336
|
+
this.client,
|
|
337
|
+
(tx) => {
|
|
338
|
+
this.messageLibSetConfigCallIdMoveCall(tx)
|
|
339
|
+
},
|
|
340
|
+
(result) => Buffer.from(bcs.vector(bcs.u8()).parse(result[0].value)).toString('hex')
|
|
341
|
+
)
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// ======== View Functions ========
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Get the default message library PTB builder for a given library
|
|
348
|
+
* @param tx - The transaction to add the move call to
|
|
349
|
+
* @param lib - Message library address
|
|
350
|
+
* @returns Transaction result containing the default PTB builder address
|
|
351
|
+
*/
|
|
352
|
+
getDefaultMsglibPtbBuilderMoveCall(tx: Transaction, lib: string | TransactionArgument): TransactionResult {
|
|
353
|
+
return tx.moveCall({
|
|
354
|
+
target: this.#target('get_default_msglib_ptb_builder'),
|
|
355
|
+
arguments: [tx.object(this.objects.endpointPtbBuilder), asAddress(tx, lib)],
|
|
356
|
+
})
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Get the default message library PTB builder
|
|
361
|
+
* @param lib - Message library address
|
|
362
|
+
* @returns Promise<string> - The default PTB builder address
|
|
363
|
+
*/
|
|
364
|
+
async getDefaultMsglibPtbBuilder(lib: string): Promise<string> {
|
|
365
|
+
return executeSimulate(
|
|
366
|
+
this.client,
|
|
367
|
+
(tx) => {
|
|
368
|
+
this.getDefaultMsglibPtbBuilderMoveCall(tx, lib)
|
|
369
|
+
},
|
|
370
|
+
(result) => bcs.Address.parse(result[0].value)
|
|
371
|
+
)
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Get the OApp-specific message library PTB builder
|
|
376
|
+
* @param tx - The transaction to add the move call to
|
|
377
|
+
* @param oapp - OApp address or transaction argument
|
|
378
|
+
* @param lib - Message library address or transaction argument
|
|
379
|
+
* @returns Transaction result containing the OApp-specific PTB builder address
|
|
380
|
+
*/
|
|
381
|
+
getOappMsglibPtbBuilderMoveCall(
|
|
382
|
+
tx: Transaction,
|
|
383
|
+
oapp: string | TransactionArgument,
|
|
384
|
+
lib: string | TransactionArgument
|
|
385
|
+
): TransactionResult {
|
|
386
|
+
return tx.moveCall({
|
|
387
|
+
target: this.#target('get_oapp_msglib_ptb_builder'),
|
|
388
|
+
arguments: [tx.object(this.objects.endpointPtbBuilder), asAddress(tx, oapp), asAddress(tx, lib)],
|
|
389
|
+
})
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Get the OApp-specific message library PTB builder
|
|
394
|
+
* @param oapp - OApp address
|
|
395
|
+
* @param lib - Message library address
|
|
396
|
+
* @returns Promise<string> - The OApp PTB builder address
|
|
397
|
+
*/
|
|
398
|
+
async getOappMsglibPtbBuilder(oapp: string, lib: string): Promise<string> {
|
|
399
|
+
return executeSimulate(
|
|
400
|
+
this.client,
|
|
401
|
+
(tx) => {
|
|
402
|
+
this.getOappMsglibPtbBuilderMoveCall(tx, oapp, lib)
|
|
403
|
+
},
|
|
404
|
+
(result) => bcs.Address.parse(result[0].value)
|
|
405
|
+
)
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Get the effective message library PTB builder (OApp-specific or default)
|
|
410
|
+
* @param tx - The transaction to add the move call to
|
|
411
|
+
* @param oapp - OApp address
|
|
412
|
+
* @param lib - Message library address
|
|
413
|
+
* @returns Transaction result containing the effective PTB builder address
|
|
414
|
+
*/
|
|
415
|
+
getEffectiveMsglibPtbBuilderMoveCall(
|
|
416
|
+
tx: Transaction,
|
|
417
|
+
oapp: string | TransactionArgument,
|
|
418
|
+
lib: string | TransactionArgument
|
|
419
|
+
): TransactionResult {
|
|
420
|
+
return tx.moveCall({
|
|
421
|
+
target: this.#target('get_effective_msglib_ptb_builder'),
|
|
422
|
+
arguments: [tx.object(this.objects.endpointPtbBuilder), asAddress(tx, oapp), asAddress(tx, lib)],
|
|
423
|
+
})
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Get the effective message library PTB builder
|
|
428
|
+
* @param oapp - OApp address
|
|
429
|
+
* @param lib - Message library address
|
|
430
|
+
* @returns Promise<string> - The effective PTB builder address
|
|
431
|
+
*/
|
|
432
|
+
async getEffectiveMsglibPtbBuilder(oapp: string, lib: string): Promise<string> {
|
|
433
|
+
return executeSimulate(
|
|
434
|
+
this.client,
|
|
435
|
+
(tx) => {
|
|
436
|
+
this.getEffectiveMsglibPtbBuilderMoveCall(tx, oapp, lib)
|
|
437
|
+
},
|
|
438
|
+
(result) => bcs.Address.parse(result[0].value)
|
|
439
|
+
)
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Get detailed information about a registered message library PTB builder
|
|
444
|
+
* @param tx - The transaction to add the move call to
|
|
445
|
+
* @param builder - PTB builder address
|
|
446
|
+
* @returns Transaction result containing the PTB builder information
|
|
447
|
+
*/
|
|
448
|
+
getMsglibPtbBuilderInfoMoveCall(tx: Transaction, builder: string | TransactionArgument): TransactionResult {
|
|
449
|
+
return tx.moveCall({
|
|
450
|
+
target: this.#target('get_msglib_ptb_builder_info'),
|
|
451
|
+
arguments: [tx.object(this.objects.endpointPtbBuilder), asAddress(tx, builder)],
|
|
452
|
+
})
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Check if a message library PTB builder is registered
|
|
457
|
+
* @param tx - The transaction to add the move call to
|
|
458
|
+
* @param builder - PTB builder address
|
|
459
|
+
* @returns Transaction result containing boolean registration status
|
|
460
|
+
*/
|
|
461
|
+
isMsglibPtbBuilderRegisteredMoveCall(tx: Transaction, builder: string | TransactionArgument): TransactionResult {
|
|
462
|
+
return tx.moveCall({
|
|
463
|
+
target: this.#target('is_msglib_ptb_builder_registered'),
|
|
464
|
+
arguments: [tx.object(this.objects.endpointPtbBuilder), asAddress(tx, builder)],
|
|
465
|
+
})
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Checks if a PTB builder is registered
|
|
470
|
+
* @param builder - PTB builder address
|
|
471
|
+
* @returns Promise<boolean> - Whether the builder is registered
|
|
472
|
+
*/
|
|
473
|
+
async isMsglibPtbBuilderRegistered(builder: string): Promise<boolean> {
|
|
474
|
+
return executeSimulate(
|
|
475
|
+
this.client,
|
|
476
|
+
(tx) => {
|
|
477
|
+
this.isMsglibPtbBuilderRegisteredMoveCall(tx, builder)
|
|
478
|
+
},
|
|
479
|
+
(result) => bcs.Bool.parse(result[0].value)
|
|
480
|
+
)
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Get the count of registered message library PTB builders
|
|
485
|
+
* @param tx - The transaction to add the move call to
|
|
486
|
+
* @returns Transaction result containing the count of registered builders
|
|
487
|
+
*/
|
|
488
|
+
registeredMsglibPtbBuildersCountMoveCall(tx: Transaction): TransactionResult {
|
|
489
|
+
return tx.moveCall({
|
|
490
|
+
target: this.#target('registered_msglib_ptb_builders_count'),
|
|
491
|
+
arguments: [tx.object(this.objects.endpointPtbBuilder)],
|
|
492
|
+
})
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Get the total number of registered PTB builders
|
|
497
|
+
* @returns Promise<number> - The count of registered builders
|
|
498
|
+
*/
|
|
499
|
+
async registeredMsglibPtbBuildersCount(): Promise<number> {
|
|
500
|
+
return executeSimulate(
|
|
501
|
+
this.client,
|
|
502
|
+
(tx) => {
|
|
503
|
+
this.registeredMsglibPtbBuildersCountMoveCall(tx)
|
|
504
|
+
},
|
|
505
|
+
(result) => Number(bcs.U64.parse(result[0].value))
|
|
506
|
+
)
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
// === Private Functions ===
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Generate the full target path for move calls
|
|
513
|
+
* @param name - The function name to call
|
|
514
|
+
* @returns The full module path for the move call
|
|
515
|
+
* @private
|
|
516
|
+
*/
|
|
517
|
+
#target(name: string): string {
|
|
518
|
+
return `${this.packageId}::${ModuleName}::${name}`
|
|
519
|
+
}
|
|
520
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { IotaClient } from '@iota/iota-sdk/client'
|
|
2
|
+
import { Transaction, TransactionArgument, TransactionResult } from '@iota/iota-sdk/transactions'
|
|
3
|
+
|
|
4
|
+
import { ModuleManager } from '../../module-manager'
|
|
5
|
+
import { ObjectOptions } from '../../types'
|
|
6
|
+
import { asObject } from '../../utils'
|
|
7
|
+
|
|
8
|
+
const MODULE_NAME = 'executor_ptb_builder'
|
|
9
|
+
|
|
10
|
+
export class ExecutorPtbBuilder {
|
|
11
|
+
public packageId: string
|
|
12
|
+
public readonly client: IotaClient
|
|
13
|
+
private readonly objects: ObjectOptions
|
|
14
|
+
|
|
15
|
+
constructor(
|
|
16
|
+
packageId: string,
|
|
17
|
+
client: IotaClient,
|
|
18
|
+
objects: ObjectOptions,
|
|
19
|
+
private readonly moduleManager: ModuleManager
|
|
20
|
+
) {
|
|
21
|
+
this.packageId = packageId
|
|
22
|
+
this.client = client
|
|
23
|
+
this.objects = objects
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// === Set Functions ===
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Creates a transaction to build Executor PTB
|
|
30
|
+
* @param tx - The transaction to add the move call to
|
|
31
|
+
* @param executorAddress - Executor object address or transaction argument
|
|
32
|
+
* @param feelibAddress - Executor fee lib object address or transaction argument
|
|
33
|
+
* @param priceFeedAddress - Price feed object address or transaction argument
|
|
34
|
+
* @returns Transaction result containing get_fee and assign_job move calls
|
|
35
|
+
*/
|
|
36
|
+
buildExecutorPtbMoveCall(
|
|
37
|
+
tx: Transaction,
|
|
38
|
+
executorAddress: string | TransactionArgument,
|
|
39
|
+
feelibAddress: string | TransactionArgument,
|
|
40
|
+
priceFeedAddress: string | TransactionArgument
|
|
41
|
+
): TransactionResult {
|
|
42
|
+
return tx.moveCall({
|
|
43
|
+
target: this.#target('build_executor_ptb'),
|
|
44
|
+
arguments: [asObject(tx, executorAddress), asObject(tx, feelibAddress), asObject(tx, priceFeedAddress)],
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Generate the full target path for move calls
|
|
50
|
+
* @param name - The function name to call
|
|
51
|
+
* @param module_name - The module name (defaults to MODULE_NAME)
|
|
52
|
+
* @returns The full module path for the move call
|
|
53
|
+
* @private
|
|
54
|
+
*/
|
|
55
|
+
#target(name: string, module_name = MODULE_NAME): string {
|
|
56
|
+
return `${this.packageId}::${module_name}::${name}`
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// PTB Builder modules
|
|
2
|
+
export * from './dvn-ptb-builder'
|
|
3
|
+
export * from './endpoint-ptb-builder'
|
|
4
|
+
export * from './executor-ptb-builder'
|
|
5
|
+
export * from './package-whitelist-validator'
|
|
6
|
+
export * from './ptb-builder'
|
|
7
|
+
export * from './simple-message-lib-ptb-builder'
|
|
8
|
+
export * from './uln302-ptb-builder'
|
|
9
|
+
export * from './blocked-message-lib-ptb-builder'
|