@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,333 @@
|
|
|
1
|
+
import { IotaClient } from '@iota/iota-sdk/client'
|
|
2
|
+
|
|
3
|
+
import { Chain, Stage } from '@layerzerolabs/lz-definitions'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Type representing the options for packages.
|
|
7
|
+
*/
|
|
8
|
+
export interface PackageOptions {
|
|
9
|
+
/**
|
|
10
|
+
* The endpoint V2 address.
|
|
11
|
+
*/
|
|
12
|
+
endpointV2: string
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The zro address.
|
|
16
|
+
*/
|
|
17
|
+
zro: string
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The utils address.
|
|
21
|
+
*/
|
|
22
|
+
utils: string
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The call address.
|
|
26
|
+
*/
|
|
27
|
+
call: string
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The simple message library address.
|
|
31
|
+
*/
|
|
32
|
+
simpleMessageLib: string
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The ULN-302 address.
|
|
36
|
+
*/
|
|
37
|
+
uln302: string
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The treasury address.
|
|
41
|
+
*/
|
|
42
|
+
treasury: string
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The common DVN address.
|
|
46
|
+
*/
|
|
47
|
+
dvn: string
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The DVN fee lib address.
|
|
51
|
+
*/
|
|
52
|
+
dvnFeeLib: string
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The common executor address.
|
|
56
|
+
*/
|
|
57
|
+
executor: string
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The executor fee lib address.
|
|
61
|
+
*/
|
|
62
|
+
executorFeeLib: string
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The price feed address.
|
|
66
|
+
*/
|
|
67
|
+
priceFeed: string
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The common oapp address.
|
|
71
|
+
*/
|
|
72
|
+
oapp: string
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The LayerZero Views address.
|
|
76
|
+
*/
|
|
77
|
+
layerzeroViews: string
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The dvn layerzero address.
|
|
81
|
+
*/
|
|
82
|
+
dvnLayerzero: string
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The executor layerzero address.
|
|
86
|
+
*/
|
|
87
|
+
executorLayerzero: string
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The counter V2 address.
|
|
91
|
+
*/
|
|
92
|
+
counterV2: string
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The ptb move call address.
|
|
96
|
+
*/
|
|
97
|
+
ptbMoveCall: string
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The endpoint PTB builder address.
|
|
101
|
+
*/
|
|
102
|
+
endpointPtbBuilder: string
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The simple message lib PTB builder address.
|
|
106
|
+
*/
|
|
107
|
+
simpleMessageLibPtbBuilder: string
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The ULN-302 PTB builder address.
|
|
111
|
+
*/
|
|
112
|
+
uln302PtbBuilder: string
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* The DVN PTB builder address.
|
|
116
|
+
*/
|
|
117
|
+
dvnPtbBuilder: string
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* The executor PTB builder address.
|
|
121
|
+
*/
|
|
122
|
+
executorPtbBuilder: string
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* The package whitelist validator address.
|
|
126
|
+
*/
|
|
127
|
+
packageWhitelistValidator: string
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The blocked message library object address.
|
|
131
|
+
*/
|
|
132
|
+
blockedMessageLib: string
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* The blocked message library PTB builder object address.
|
|
136
|
+
*/
|
|
137
|
+
blockedMessageLibPtbBuilder: string
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* The worker registry address.
|
|
141
|
+
*/
|
|
142
|
+
workerRegistry: string
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* The worker common address.
|
|
146
|
+
*/
|
|
147
|
+
workerCommon: string
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Allow additional properties beyond the explicitly defined ones
|
|
151
|
+
*/
|
|
152
|
+
[key: string]: any
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Type representing the options for objects.
|
|
157
|
+
*/
|
|
158
|
+
export interface ObjectOptions {
|
|
159
|
+
/**
|
|
160
|
+
* The endpoint V2 object address.
|
|
161
|
+
*/
|
|
162
|
+
endpointV2: string
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* The simple message library object address.
|
|
166
|
+
*/
|
|
167
|
+
simpleMessageLib: string
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* The simple message library cap object address.
|
|
171
|
+
*/
|
|
172
|
+
simpleMessageLibAdminCap: string
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* The simple message library PTB builder object address.
|
|
176
|
+
*/
|
|
177
|
+
simpleMessageLibPtbBuilder: string
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* The ULN-302 message library object address.
|
|
181
|
+
*/
|
|
182
|
+
uln302: string
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* The ULN-302 admin cap object address.
|
|
186
|
+
*/
|
|
187
|
+
uln302AdminCap: string
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* The ULN-302 verification object address.
|
|
191
|
+
*/
|
|
192
|
+
uln302Verification: string
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* The ULN-302 PTB builder object address.
|
|
196
|
+
*/
|
|
197
|
+
uln302PtbBuilder: string
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* The treasury object address.
|
|
201
|
+
*/
|
|
202
|
+
treasury: string
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* The treasury admin cap object address.
|
|
206
|
+
*/
|
|
207
|
+
treasuryAdminCap: string
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* The blocked message library object address.
|
|
211
|
+
*/
|
|
212
|
+
blockedMessageLib: string
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* The blocked message library PTB builder object address.
|
|
216
|
+
*/
|
|
217
|
+
blockedMessageLibPtbBuilder: string
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* The counter admin cap object address.
|
|
221
|
+
*/
|
|
222
|
+
counterAdminCap: string
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* The endpoint admin cap object address.
|
|
226
|
+
*/
|
|
227
|
+
endpointAdminCap: string
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* The endpoint PTB builder object address.
|
|
231
|
+
*/
|
|
232
|
+
endpointPtbBuilder: string
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* The endpoint PTB builder admin cap object address.
|
|
236
|
+
*/
|
|
237
|
+
endpointPtbBuilderAdminCap: string
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* The default DVN object address.
|
|
241
|
+
*/
|
|
242
|
+
dvn: string
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* The default DVN callCap object address, used in init_dvn move call
|
|
246
|
+
*/
|
|
247
|
+
dvnCap: string
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* The default DVN fee lib object address.
|
|
251
|
+
*/
|
|
252
|
+
dvnFeeLib: string
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* The default executor object address.
|
|
256
|
+
*/
|
|
257
|
+
executor: string
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* The default executor callCap object address, used in init_executor move call
|
|
261
|
+
*/
|
|
262
|
+
executorCap: string
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* The default executor owner cap object address.
|
|
266
|
+
*/
|
|
267
|
+
executorOwnerCap: string
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* The default executor fee lib object address.
|
|
271
|
+
*/
|
|
272
|
+
executorFeeLib: string
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* The default price feed object address.
|
|
276
|
+
*/
|
|
277
|
+
priceFeed: string
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* The default price feed owner cap object address.
|
|
281
|
+
*/
|
|
282
|
+
priceFeedOwnerCap: string
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* The counter OApp object address.
|
|
286
|
+
*/
|
|
287
|
+
counter: string
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* The OApp core object address.
|
|
291
|
+
*/
|
|
292
|
+
counterOapp: string
|
|
293
|
+
/**
|
|
294
|
+
* The default package whitelist validator object address.
|
|
295
|
+
*/
|
|
296
|
+
packageWhitelistValidator: string
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* The worker registry object address.
|
|
300
|
+
*/
|
|
301
|
+
workerRegistry: string
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Allow additional properties beyond the explicitly defined ones
|
|
305
|
+
*/
|
|
306
|
+
[key: string]: any
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Module options for customizing module creation
|
|
311
|
+
*/
|
|
312
|
+
export interface ModuleOptions {
|
|
313
|
+
/** Custom package ID to use instead of default */
|
|
314
|
+
packageId: string
|
|
315
|
+
/** Custom objects configuration to use instead of default */
|
|
316
|
+
objects: Partial<ObjectOptions>
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Options for initializing the SDK.
|
|
321
|
+
*/
|
|
322
|
+
export interface SdkOptions {
|
|
323
|
+
/** The chain for the SDK (default: Chain.IOTAL1) */
|
|
324
|
+
chain?: Chain
|
|
325
|
+
/** The Iota client for the SDK */
|
|
326
|
+
client: IotaClient
|
|
327
|
+
/** The stage of the SDK (default: Stage.MAINNET) */
|
|
328
|
+
stage?: Stage
|
|
329
|
+
/** Custom package addresses to override defaults */
|
|
330
|
+
packages?: Partial<PackageOptions>
|
|
331
|
+
/** Custom object addresses to override defaults */
|
|
332
|
+
objects?: Partial<ObjectOptions>
|
|
333
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// PriceFeed configuration and data interfaces
|
|
2
|
+
|
|
3
|
+
// Model Types enum - matches Move contract ModelType
|
|
4
|
+
export enum ModelType {
|
|
5
|
+
DEFAULT = 0,
|
|
6
|
+
ARB_STACK = 1,
|
|
7
|
+
OP_STACK = 2,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Price struct interface - matches Move contract Price struct
|
|
11
|
+
export interface Price {
|
|
12
|
+
priceRatio: bigint // u128 in Move (price_ratio)
|
|
13
|
+
gasPriceInUnit: bigint // u64 in Move (gas_price_in_unit)
|
|
14
|
+
gasPerByte: number // u32 in Move (gas_per_byte)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// ArbitrumPriceExt struct interface - matches Move contract ArbitrumPriceExt struct
|
|
18
|
+
export interface ArbitrumPriceExt {
|
|
19
|
+
gasPerL2Tx: bigint // u64 in Move (gas_per_l2_tx)
|
|
20
|
+
gasPerL1CallDataByte: number // u32 in Move (gas_per_l1_call_data_byte)
|
|
21
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// TypeScript interfaces matching the Move structs in move_call.move
|
|
2
|
+
export interface MoveCall {
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
4
|
+
function: Function
|
|
5
|
+
arguments: Argument[]
|
|
6
|
+
type_arguments: string[] // TypeName as string
|
|
7
|
+
result_ids: Uint8Array[]
|
|
8
|
+
is_builder_call: boolean
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface Function {
|
|
12
|
+
package: string
|
|
13
|
+
module_name: string
|
|
14
|
+
name: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type Argument =
|
|
18
|
+
| { ID: Uint8Array }
|
|
19
|
+
| { Object: string }
|
|
20
|
+
| { Pure: Uint8Array }
|
|
21
|
+
| { NestedResult: [number, number] } // [call_index, result_index]
|
|
22
|
+
|
|
23
|
+
export const MAX_BATCH_SIZE = 50
|
|
24
|
+
export const DEFAULT_SIMULATION_TIMES = 5
|
|
25
|
+
|
|
26
|
+
export interface BuilderPlaceholderInfo {
|
|
27
|
+
index: number
|
|
28
|
+
moveCallCount: number
|
|
29
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { bcs } from '@iota/iota-sdk/bcs'
|
|
2
|
+
import { Transaction, TransactionArgument } from '@iota/iota-sdk/transactions'
|
|
3
|
+
|
|
4
|
+
import { Utils } from '../modules'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Type guard to check if a value is already a TransactionArgument
|
|
8
|
+
* TransactionArgument can be:
|
|
9
|
+
* 1. Argument object with $kind property
|
|
10
|
+
* 2. Synchronous function: (tx: Transaction) => Argument
|
|
11
|
+
* 3. Asynchronous function: AsyncTransactionThunk
|
|
12
|
+
*/
|
|
13
|
+
export function isTransactionArgument(value: unknown): value is TransactionArgument {
|
|
14
|
+
// Check if it's a function (sync or async)
|
|
15
|
+
if (typeof value === 'function') {
|
|
16
|
+
return true
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Check if it's an Argument object
|
|
20
|
+
if (value !== null && typeof value === 'object' && '$kind' in value) {
|
|
21
|
+
const obj = value as { $kind: string }
|
|
22
|
+
return (
|
|
23
|
+
obj.$kind === 'GasCoin' || obj.$kind === 'Input' || obj.$kind === 'Result' || obj.$kind === 'NestedResult'
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return false
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Convert value to TransactionArgument using a simple converter function
|
|
32
|
+
* @param value - The value to convert (primitive type or TransactionArgument)
|
|
33
|
+
* @param converter - Function to convert primitive type to TransactionArgument
|
|
34
|
+
* @returns TransactionArgument
|
|
35
|
+
*/
|
|
36
|
+
export function asArg<T>(
|
|
37
|
+
value: T | TransactionArgument,
|
|
38
|
+
converter: (val: T) => TransactionArgument
|
|
39
|
+
): TransactionArgument {
|
|
40
|
+
if (isTransactionArgument(value)) {
|
|
41
|
+
return value
|
|
42
|
+
}
|
|
43
|
+
return converter(value)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Convert value to TransactionArgument using a converter that requires Transaction
|
|
48
|
+
* @param tx - The transaction
|
|
49
|
+
* @param value - The value to convert
|
|
50
|
+
* @param converter - Function to convert value using transaction
|
|
51
|
+
* @returns TransactionArgument
|
|
52
|
+
*/
|
|
53
|
+
export function asArgWithTx<T>(
|
|
54
|
+
tx: Transaction,
|
|
55
|
+
value: T | TransactionArgument,
|
|
56
|
+
converter: (tx: Transaction, val: T) => TransactionArgument
|
|
57
|
+
): TransactionArgument {
|
|
58
|
+
if (isTransactionArgument(value)) {
|
|
59
|
+
return value
|
|
60
|
+
}
|
|
61
|
+
return converter(tx, value)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Async version: Convert value to TransactionArgument using an async converter that requires Transaction
|
|
66
|
+
* @param tx - The transaction
|
|
67
|
+
* @param value - The value to convert
|
|
68
|
+
* @param converter - Async function to convert value using transaction
|
|
69
|
+
* @returns Promise<TransactionArgument>
|
|
70
|
+
*/
|
|
71
|
+
export async function asArgWithTxAsync<T>(
|
|
72
|
+
tx: Transaction,
|
|
73
|
+
value: T | TransactionArgument,
|
|
74
|
+
converter: (tx: Transaction, val: T) => Promise<TransactionArgument>
|
|
75
|
+
): Promise<TransactionArgument> {
|
|
76
|
+
if (isTransactionArgument(value)) {
|
|
77
|
+
return value
|
|
78
|
+
}
|
|
79
|
+
return converter(tx, value)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// ===== Simplified conversion methods =====
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Convert to object reference TransactionArgument
|
|
86
|
+
*/
|
|
87
|
+
export function asObject(tx: Transaction, value: string | TransactionArgument): TransactionArgument {
|
|
88
|
+
return asArg(value, (val) => tx.object(val))
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Convert to address TransactionArgument
|
|
93
|
+
*/
|
|
94
|
+
export function asAddress(tx: Transaction, value: string | TransactionArgument): TransactionArgument {
|
|
95
|
+
return asArg(value, (val) => tx.pure.address(val))
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Convert to u8 TransactionArgument
|
|
100
|
+
*/
|
|
101
|
+
export function asU8(tx: Transaction, value: number | TransactionArgument): TransactionArgument {
|
|
102
|
+
return asArg(value, (val) => tx.pure.u8(val))
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Convert to u16 TransactionArgument
|
|
107
|
+
*/
|
|
108
|
+
export function asU16(tx: Transaction, value: number | TransactionArgument): TransactionArgument {
|
|
109
|
+
return asArg(value, (val) => tx.pure.u16(val))
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Convert to u32 TransactionArgument
|
|
114
|
+
*/
|
|
115
|
+
export function asU32(tx: Transaction, value: number | TransactionArgument): TransactionArgument {
|
|
116
|
+
return asArg(value, (val) => tx.pure.u32(val))
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Convert to u64 TransactionArgument (supports bigint, number, or string)
|
|
121
|
+
*/
|
|
122
|
+
export function asU64(tx: Transaction, value: bigint | number | string | TransactionArgument): TransactionArgument {
|
|
123
|
+
return asArg(value, (val) => tx.pure.u64(val))
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Convert to u128 TransactionArgument (supports bigint, number, or string)
|
|
128
|
+
*/
|
|
129
|
+
export function asU128(tx: Transaction, value: bigint | number | string | TransactionArgument): TransactionArgument {
|
|
130
|
+
return asArg(value, (val) => tx.pure.u128(val))
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Convert to u256 TransactionArgument (supports bigint, number, or string)
|
|
135
|
+
*/
|
|
136
|
+
export function asU256(tx: Transaction, value: bigint | number | string | TransactionArgument): TransactionArgument {
|
|
137
|
+
return asArg(value, (val) => tx.pure.u256(val))
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Convert Uint8Array to Bytes32 using moduleManager's fromBytesMoveCall
|
|
142
|
+
* @param tx - The transaction
|
|
143
|
+
* @param value - Uint8Array or TransactionArgument
|
|
144
|
+
* @param utils - utils Module
|
|
145
|
+
* @returns TransactionArgument
|
|
146
|
+
*/
|
|
147
|
+
export function asBytes32(tx: Transaction, value: Uint8Array | TransactionArgument, utils: Utils): TransactionArgument {
|
|
148
|
+
return asArgWithTx(tx, value, (tx, bytes) => utils.fromBytesMoveCall(tx, bytes))
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Convert Uint8Array to serialized bytes vector TransactionArgument
|
|
153
|
+
* @param tx - The transaction
|
|
154
|
+
* @param value - Uint8Array or TransactionArgument
|
|
155
|
+
* @returns TransactionArgument
|
|
156
|
+
*/
|
|
157
|
+
export function asBytes(tx: Transaction, value: Uint8Array | TransactionArgument): TransactionArgument {
|
|
158
|
+
return asArg(value, (val) => tx.pure(bcs.vector(bcs.u8()).serialize(val)))
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Convert Uint8Array Vector to serialized bytes vector TransactionArgument
|
|
162
|
+
* @param tx - The transaction
|
|
163
|
+
* @param value - Uint8Array or TransactionArgument
|
|
164
|
+
* @returns TransactionArgument
|
|
165
|
+
*/
|
|
166
|
+
export function asBytesVector(tx: Transaction, value: Uint8Array[] | TransactionArgument): TransactionArgument {
|
|
167
|
+
return asArg(value, (val) => tx.pure(bcs.vector(bcs.vector(bcs.u8())).serialize(val)))
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Convert string to string TransactionArgument
|
|
172
|
+
* @param tx - The transaction
|
|
173
|
+
* @param value - string or TransactionArgument
|
|
174
|
+
* @returns TransactionArgument
|
|
175
|
+
*/
|
|
176
|
+
export function asString(tx: Transaction, value: string | TransactionArgument): TransactionArgument {
|
|
177
|
+
return asArg(value, (val) => tx.pure.string(val))
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Convert address array to serialized vector<address> TransactionArgument
|
|
182
|
+
* @param tx - The transaction
|
|
183
|
+
* @param value - string[] or TransactionArgument
|
|
184
|
+
* @returns TransactionArgument
|
|
185
|
+
*/
|
|
186
|
+
export function asAddressVector(tx: Transaction, value: string[] | TransactionArgument): TransactionArgument {
|
|
187
|
+
return asArg(value, (val) => tx.pure(bcs.vector(bcs.Address).serialize(val)))
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Convert boolean to boolean TransactionArgument
|
|
192
|
+
* @param tx - The transaction
|
|
193
|
+
* @param value - boolean or TransactionArgument
|
|
194
|
+
* @returns TransactionArgument
|
|
195
|
+
*/
|
|
196
|
+
export function asBool(tx: Transaction, value: boolean | TransactionArgument): TransactionArgument {
|
|
197
|
+
return asArg(value, (val) => tx.pure.bool(val))
|
|
198
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Utils unified exports
|
|
2
|
+
export * from './argument'
|
|
3
|
+
export * from './transaction'
|
|
4
|
+
export * from './ptb-validator'
|
|
5
|
+
export * from './package-allowlist-validator'
|
|
6
|
+
export * from './non-sender-object-validator'
|
|
7
|
+
export * from './share-object-validator'
|
|
8
|
+
export * from './validate-with-details'
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { IotaClient, IotaObjectResponse } from '@iota/iota-sdk/client'
|
|
2
|
+
|
|
3
|
+
import { MAX_BATCH_SIZE, MoveCall } from '../types'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents a move call with its associated object details
|
|
7
|
+
*/
|
|
8
|
+
export interface MoveCallWithObjectDetails {
|
|
9
|
+
moveCall: MoveCall
|
|
10
|
+
objectDetails: Map<string, IotaObjectResponse>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* MoveCallObjectFetcher fetches object details for move calls once
|
|
15
|
+
* and provides them to validators to avoid multiple API calls
|
|
16
|
+
*/
|
|
17
|
+
export class MoveCallObjectFetcher {
|
|
18
|
+
private client: IotaClient
|
|
19
|
+
private batchSize: number
|
|
20
|
+
|
|
21
|
+
constructor(client: IotaClient, batchSize: number = MAX_BATCH_SIZE) {
|
|
22
|
+
this.client = client
|
|
23
|
+
this.batchSize = batchSize
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Fetches object details for all objects referenced in move calls
|
|
28
|
+
* @param moveCalls - Array of move calls to fetch object details for
|
|
29
|
+
* @param options - Options for what object data to fetch
|
|
30
|
+
* @returns Array of move calls with their associated object details
|
|
31
|
+
*/
|
|
32
|
+
async fetchObjectDetails(
|
|
33
|
+
moveCalls: MoveCall[],
|
|
34
|
+
options: {
|
|
35
|
+
showOwner?: boolean
|
|
36
|
+
showType?: boolean
|
|
37
|
+
showContent?: boolean
|
|
38
|
+
showBcs?: boolean
|
|
39
|
+
showDisplay?: boolean
|
|
40
|
+
showStorageRebate?: boolean
|
|
41
|
+
} = {}
|
|
42
|
+
): Promise<MoveCallWithObjectDetails[]> {
|
|
43
|
+
// Extract all unique object IDs from move calls
|
|
44
|
+
const objectIdSet = new Set<string>()
|
|
45
|
+
for (const moveCall of moveCalls) {
|
|
46
|
+
for (const arg of moveCall.arguments) {
|
|
47
|
+
if ('Object' in arg) {
|
|
48
|
+
objectIdSet.add(arg.Object)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const objectIds = Array.from(objectIdSet)
|
|
54
|
+
if (objectIds.length === 0) {
|
|
55
|
+
// No objects to fetch, return move calls with empty object details
|
|
56
|
+
return moveCalls.map((moveCall) => ({
|
|
57
|
+
moveCall,
|
|
58
|
+
objectDetails: new Map<string, IotaObjectResponse>(),
|
|
59
|
+
}))
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Validate batch size
|
|
63
|
+
if (this.batchSize > MAX_BATCH_SIZE || this.batchSize < 1) {
|
|
64
|
+
throw new Error(`batchSize must be between 1 and ${MAX_BATCH_SIZE}`)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Fetch all objects in batches
|
|
68
|
+
const objectDetailsMap = new Map<string, IotaObjectResponse>()
|
|
69
|
+
|
|
70
|
+
for (let i = 0; i < objectIds.length; i += this.batchSize) {
|
|
71
|
+
const batch = objectIds.slice(i, i + this.batchSize)
|
|
72
|
+
const objects = await this.client.multiGetObjects({
|
|
73
|
+
ids: batch,
|
|
74
|
+
options,
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
// Map object responses to their IDs
|
|
78
|
+
objects.forEach((object, index) => {
|
|
79
|
+
const objectId = batch[index]
|
|
80
|
+
objectDetailsMap.set(objectId, object)
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Create move calls with object details
|
|
85
|
+
return moveCalls.map((moveCall) => {
|
|
86
|
+
// Get object details for this specific move call
|
|
87
|
+
const moveCallObjectDetails = new Map<string, IotaObjectResponse>()
|
|
88
|
+
|
|
89
|
+
for (const arg of moveCall.arguments) {
|
|
90
|
+
if ('Object' in arg) {
|
|
91
|
+
const objectId = arg.Object
|
|
92
|
+
const objectDetail = objectDetailsMap.get(objectId)
|
|
93
|
+
if (objectDetail) {
|
|
94
|
+
moveCallObjectDetails.set(objectId, objectDetail)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
moveCall,
|
|
101
|
+
objectDetails: moveCallObjectDetails,
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
}
|