@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,10 @@
|
|
|
1
|
+
// Worker modules (DVN and Executor)
|
|
2
|
+
export * from './dvn'
|
|
3
|
+
export * from './dvn-fee-lib'
|
|
4
|
+
export * from './dvn-layerzero'
|
|
5
|
+
export * from './executor'
|
|
6
|
+
export * from './executor-fee-lib'
|
|
7
|
+
export * from './executor-layerzero'
|
|
8
|
+
export * from './price-feed'
|
|
9
|
+
export * from './treasury'
|
|
10
|
+
export * from './worker-registry'
|
|
@@ -0,0 +1,575 @@
|
|
|
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 { ArbitrumPriceExtBcs, ModelTypeBcs, PriceBcs } from '../../bcs'
|
|
6
|
+
import { ModuleManager } from '../../module-manager'
|
|
7
|
+
import { ArbitrumPriceExt, ModelType, ObjectOptions, Price } from '../../types'
|
|
8
|
+
import { asAddress, asBool, asObject, asU128, asU32, asU64, executeSimulate } from '../../utils'
|
|
9
|
+
|
|
10
|
+
const MODULE_NAME = 'price_feed'
|
|
11
|
+
|
|
12
|
+
export const PriceFeedErrorCode = {
|
|
13
|
+
// PriceFeed related errors
|
|
14
|
+
PRICE_FEED_EInvalidDenominator: 1,
|
|
15
|
+
PRICE_FEED_ENoPrice: 2,
|
|
16
|
+
PRICE_FEED_ENotAnOPStack: 3,
|
|
17
|
+
PRICE_FEED_EOnlyPriceUpdater: 4,
|
|
18
|
+
PRICE_FEED_EPriceUpdaterCapNotFound: 5,
|
|
19
|
+
} as const
|
|
20
|
+
|
|
21
|
+
export class PriceFeed {
|
|
22
|
+
public packageId: string
|
|
23
|
+
public readonly client: IotaClient
|
|
24
|
+
private readonly objects: ObjectOptions
|
|
25
|
+
|
|
26
|
+
constructor(
|
|
27
|
+
packageId: string,
|
|
28
|
+
client: IotaClient,
|
|
29
|
+
objects: ObjectOptions,
|
|
30
|
+
private readonly moduleManager: ModuleManager
|
|
31
|
+
) {
|
|
32
|
+
this.packageId = packageId
|
|
33
|
+
this.client = client
|
|
34
|
+
this.objects = objects
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// === Helper Functions ===
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Create price configuration object
|
|
41
|
+
* @param tx - The transaction to add the move call to
|
|
42
|
+
* @param priceRatio - Price ratio value or transaction argument
|
|
43
|
+
* @param gasPriceInUnit - Gas price in unit or transaction argument
|
|
44
|
+
* @param gasPerByte - Gas per byte value or transaction argument
|
|
45
|
+
* @returns Transaction result containing the price object
|
|
46
|
+
*/
|
|
47
|
+
createPriceMoveCall(
|
|
48
|
+
tx: Transaction,
|
|
49
|
+
priceRatio: bigint | number | string | TransactionArgument,
|
|
50
|
+
gasPriceInUnit: bigint | number | string | TransactionArgument,
|
|
51
|
+
gasPerByte: number | TransactionArgument
|
|
52
|
+
): TransactionResult {
|
|
53
|
+
return tx.moveCall({
|
|
54
|
+
target: this.#target('create_price'),
|
|
55
|
+
arguments: [asU128(tx, priceRatio), asU64(tx, gasPriceInUnit), asU32(tx, gasPerByte)],
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Create Arbitrum price extension object
|
|
61
|
+
* @param tx - The transaction to add the move call to
|
|
62
|
+
* @param gasPerL2Tx - Gas per L2 transaction or transaction argument
|
|
63
|
+
* @param gasPerL1CallDataByte - Gas per L1 call data byte or transaction argument
|
|
64
|
+
* @returns Transaction result containing the Arbitrum price extension object
|
|
65
|
+
*/
|
|
66
|
+
createArbitrumPriceExtMoveCall(
|
|
67
|
+
tx: Transaction,
|
|
68
|
+
gasPerL2Tx: bigint | number | string | TransactionArgument,
|
|
69
|
+
gasPerL1CallDataByte: number | TransactionArgument
|
|
70
|
+
): TransactionResult {
|
|
71
|
+
return tx.moveCall({
|
|
72
|
+
target: this.#target('create_arbitrum_price_ext'),
|
|
73
|
+
arguments: [asU64(tx, gasPerL2Tx), asU32(tx, gasPerL1CallDataByte)],
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Get price model type move call result
|
|
79
|
+
* @param tx - The transaction to add the move call to
|
|
80
|
+
* @param modelType - The price model type enum value
|
|
81
|
+
* @returns Transaction result containing the model type
|
|
82
|
+
*/
|
|
83
|
+
getModelTypeMoveCall(tx: Transaction, modelType: ModelType): TransactionResult {
|
|
84
|
+
switch (modelType) {
|
|
85
|
+
case ModelType.DEFAULT:
|
|
86
|
+
return tx.moveCall({
|
|
87
|
+
target: this.#target('model_type_default'),
|
|
88
|
+
arguments: [],
|
|
89
|
+
})
|
|
90
|
+
case ModelType.ARB_STACK:
|
|
91
|
+
return tx.moveCall({
|
|
92
|
+
target: this.#target('model_type_arbitrum'),
|
|
93
|
+
arguments: [],
|
|
94
|
+
})
|
|
95
|
+
case ModelType.OP_STACK:
|
|
96
|
+
return tx.moveCall({
|
|
97
|
+
target: this.#target('model_type_optimism'),
|
|
98
|
+
arguments: [],
|
|
99
|
+
})
|
|
100
|
+
default:
|
|
101
|
+
throw new Error(`Invalid model type: ${JSON.stringify(modelType)}`)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// === Set Functions ===
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Set price updater role for an address (admin only)
|
|
109
|
+
* Note: This function will automatically create a price updater capability for new updaters
|
|
110
|
+
* @param tx - The transaction to add the move call to
|
|
111
|
+
* @param updater - The updater address or transaction argument
|
|
112
|
+
* @param active - Whether to activate or deactivate the updater role or transaction argument
|
|
113
|
+
*/
|
|
114
|
+
setPriceUpdaterMoveCall(
|
|
115
|
+
tx: Transaction,
|
|
116
|
+
updater: string | TransactionArgument,
|
|
117
|
+
active: boolean | TransactionArgument
|
|
118
|
+
): void {
|
|
119
|
+
tx.moveCall({
|
|
120
|
+
target: this.#target('set_price_updater'),
|
|
121
|
+
arguments: [
|
|
122
|
+
tx.object(this.objects.priceFeed),
|
|
123
|
+
tx.object(this.objects.priceFeedOwnerCap),
|
|
124
|
+
asAddress(tx, updater),
|
|
125
|
+
asBool(tx, active),
|
|
126
|
+
],
|
|
127
|
+
})
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Set price ratio denominator for price calculations (admin only)
|
|
132
|
+
* Note: denominator must be greater than 0, otherwise the transaction will fail
|
|
133
|
+
* @param tx - The transaction to add the move call to
|
|
134
|
+
* @param denominator - The price ratio denominator value or transaction argument (must be > 0)
|
|
135
|
+
*/
|
|
136
|
+
setPriceRatioDenominatorMoveCall(
|
|
137
|
+
tx: Transaction,
|
|
138
|
+
denominator: bigint | number | string | TransactionArgument
|
|
139
|
+
): void {
|
|
140
|
+
tx.moveCall({
|
|
141
|
+
target: this.#target('set_price_ratio_denominator'),
|
|
142
|
+
arguments: [
|
|
143
|
+
tx.object(this.objects.priceFeed),
|
|
144
|
+
tx.object(this.objects.priceFeedOwnerCap),
|
|
145
|
+
asU128(tx, denominator),
|
|
146
|
+
],
|
|
147
|
+
})
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Set Arbitrum compression percentage (admin only)
|
|
152
|
+
* @param tx - The transaction to add the move call to
|
|
153
|
+
* @param compressionPercent - The compression percentage for Arbitrum or transaction argument
|
|
154
|
+
*/
|
|
155
|
+
setArbitrumCompressionPercentMoveCall(
|
|
156
|
+
tx: Transaction,
|
|
157
|
+
compressionPercent: bigint | number | string | TransactionArgument
|
|
158
|
+
): void {
|
|
159
|
+
tx.moveCall({
|
|
160
|
+
target: this.#target('set_arbitrum_compression_percent'),
|
|
161
|
+
arguments: [
|
|
162
|
+
tx.object(this.objects.priceFeed),
|
|
163
|
+
tx.object(this.objects.priceFeedOwnerCap),
|
|
164
|
+
asU128(tx, compressionPercent),
|
|
165
|
+
],
|
|
166
|
+
})
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Set price model type for a destination EID (admin only)
|
|
171
|
+
* @param tx - The transaction to add the move call to
|
|
172
|
+
* @param dstEid - Destination endpoint ID or transaction argument
|
|
173
|
+
* @param modelType - The price model type to set
|
|
174
|
+
*/
|
|
175
|
+
setEidToModelTypeMoveCall(tx: Transaction, dstEid: number | TransactionArgument, modelType: ModelType): void {
|
|
176
|
+
const modelTypeCall = this.getModelTypeMoveCall(tx, modelType)
|
|
177
|
+
|
|
178
|
+
tx.moveCall({
|
|
179
|
+
target: this.#target('set_eid_to_model_type'),
|
|
180
|
+
arguments: [
|
|
181
|
+
tx.object(this.objects.priceFeed),
|
|
182
|
+
tx.object(this.objects.priceFeedOwnerCap),
|
|
183
|
+
asU32(tx, dstEid),
|
|
184
|
+
modelTypeCall,
|
|
185
|
+
],
|
|
186
|
+
})
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Set price for a destination EID (price updater capability required)
|
|
191
|
+
* @param tx - The transaction to add the move call to
|
|
192
|
+
* @param updaterCap - The price updater capability object or transaction argument
|
|
193
|
+
* @param dstEid - Destination endpoint ID or transaction argument
|
|
194
|
+
* @param price - The price configuration to set
|
|
195
|
+
*/
|
|
196
|
+
setPriceMoveCall(
|
|
197
|
+
tx: Transaction,
|
|
198
|
+
updaterCap: string | TransactionArgument,
|
|
199
|
+
dstEid: number | TransactionArgument,
|
|
200
|
+
price: Price
|
|
201
|
+
): void {
|
|
202
|
+
const priceCall = this.createPriceMoveCall(tx, price.priceRatio, price.gasPriceInUnit, price.gasPerByte)
|
|
203
|
+
|
|
204
|
+
tx.moveCall({
|
|
205
|
+
target: this.#target('set_price'),
|
|
206
|
+
arguments: [tx.object(this.objects.priceFeed), asObject(tx, updaterCap), asU32(tx, dstEid), priceCall],
|
|
207
|
+
})
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Set price for Arbitrum with additional extension parameters (price updater capability required)
|
|
212
|
+
* @param tx - The transaction to add the move call to
|
|
213
|
+
* @param updaterCap - The price updater capability object or transaction argument
|
|
214
|
+
* @param dstEid - Destination endpoint ID
|
|
215
|
+
* @param price - The base price configuration
|
|
216
|
+
* @param arbitrumPriceExt - Additional Arbitrum-specific price parameters
|
|
217
|
+
*/
|
|
218
|
+
setPriceForArbitrumMoveCall(
|
|
219
|
+
tx: Transaction,
|
|
220
|
+
updaterCap: string | TransactionArgument,
|
|
221
|
+
dstEid: number | TransactionArgument,
|
|
222
|
+
price: Price,
|
|
223
|
+
arbitrumPriceExt: ArbitrumPriceExt
|
|
224
|
+
): void {
|
|
225
|
+
const priceCall = this.createPriceMoveCall(tx, price.priceRatio, price.gasPriceInUnit, price.gasPerByte)
|
|
226
|
+
const arbitrumPriceExtCall = this.createArbitrumPriceExtMoveCall(
|
|
227
|
+
tx,
|
|
228
|
+
arbitrumPriceExt.gasPerL2Tx,
|
|
229
|
+
arbitrumPriceExt.gasPerL1CallDataByte
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
tx.moveCall({
|
|
233
|
+
target: this.#target('set_price_for_arbitrum'),
|
|
234
|
+
arguments: [
|
|
235
|
+
tx.object(this.objects.priceFeed),
|
|
236
|
+
asObject(tx, updaterCap),
|
|
237
|
+
asU32(tx, dstEid),
|
|
238
|
+
priceCall,
|
|
239
|
+
arbitrumPriceExtCall,
|
|
240
|
+
],
|
|
241
|
+
})
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Set native token price in USD (price updater capability required)
|
|
246
|
+
* @param tx - The transaction to add the move call to
|
|
247
|
+
* @param updaterCap - The price updater capability object or transaction argument
|
|
248
|
+
* @param nativeTokenPriceUsd - The native token price in USD
|
|
249
|
+
*/
|
|
250
|
+
setNativeTokenPriceUsdMoveCall(
|
|
251
|
+
tx: Transaction,
|
|
252
|
+
updaterCap: string | TransactionArgument,
|
|
253
|
+
nativeTokenPriceUsd: bigint | number | string | TransactionArgument
|
|
254
|
+
): void {
|
|
255
|
+
tx.moveCall({
|
|
256
|
+
target: this.#target('set_native_token_price_usd'),
|
|
257
|
+
arguments: [tx.object(this.objects.priceFeed), asObject(tx, updaterCap), asU128(tx, nativeTokenPriceUsd)],
|
|
258
|
+
})
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// === Witness Functions ===
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Create a LayerZero witness for PriceFeed package whitelist registration
|
|
265
|
+
* @param tx - The transaction to add the move call to
|
|
266
|
+
* @returns Transaction result containing the LayerZero witness
|
|
267
|
+
*/
|
|
268
|
+
createLayerZeroWitnessMoveCall(tx: Transaction): TransactionResult {
|
|
269
|
+
return tx.moveCall({
|
|
270
|
+
target: `${this.packageId}::price_feed_witness::new`,
|
|
271
|
+
arguments: [],
|
|
272
|
+
})
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// === Worker Function ===
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Estimate fee by endpoint ID using a call result
|
|
279
|
+
* @param tx - The transaction to add the move call to
|
|
280
|
+
* @param call - The call transaction result containing fee parameters
|
|
281
|
+
*/
|
|
282
|
+
estimateFeeByEidMoveCall(tx: Transaction, call: TransactionResult): void {
|
|
283
|
+
tx.moveCall({
|
|
284
|
+
target: this.#target('estimate_fee_by_eid'),
|
|
285
|
+
arguments: [tx.object(this.objects.priceFeed), call],
|
|
286
|
+
})
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// === View Functions ===
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Get owner capability address
|
|
293
|
+
* @param tx - The transaction to add the move call to
|
|
294
|
+
* @returns Transaction result containing the owner capability address
|
|
295
|
+
*/
|
|
296
|
+
getOwnerCapMoveCall(tx: Transaction): TransactionResult {
|
|
297
|
+
return tx.moveCall({
|
|
298
|
+
target: this.#target('get_owner_cap'),
|
|
299
|
+
arguments: [tx.object(this.objects.priceFeed)],
|
|
300
|
+
})
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Get price updater capability address for a specific updater
|
|
305
|
+
* @param tx - The transaction to add the move call to
|
|
306
|
+
* @param updater - The updater address to get capability for
|
|
307
|
+
* @returns Transaction result containing the price updater capability address
|
|
308
|
+
*/
|
|
309
|
+
getPriceUpdaterCapMoveCall(tx: Transaction, updater: string | TransactionArgument): TransactionResult {
|
|
310
|
+
return tx.moveCall({
|
|
311
|
+
target: this.#target('get_price_updater_cap'),
|
|
312
|
+
arguments: [tx.object(this.objects.priceFeed), asAddress(tx, updater)],
|
|
313
|
+
})
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Get the owner capability address of this PriceFeed
|
|
318
|
+
* @returns Promise<string> - The owner capability address
|
|
319
|
+
*/
|
|
320
|
+
async ownerCap(): Promise<string> {
|
|
321
|
+
return executeSimulate(
|
|
322
|
+
this.client,
|
|
323
|
+
(tx) => {
|
|
324
|
+
this.getOwnerCapMoveCall(tx)
|
|
325
|
+
},
|
|
326
|
+
(result) => bcs.Address.parse(result[0].value)
|
|
327
|
+
)
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Get price updater capability address for a specific updater
|
|
332
|
+
* @param updater - The updater address to get capability for
|
|
333
|
+
* @returns Promise<string> - The price updater capability address
|
|
334
|
+
*/
|
|
335
|
+
async priceUpdaterCap(updater: string): Promise<string> {
|
|
336
|
+
return executeSimulate(
|
|
337
|
+
this.client,
|
|
338
|
+
(tx) => {
|
|
339
|
+
this.getPriceUpdaterCapMoveCall(tx, updater)
|
|
340
|
+
},
|
|
341
|
+
(result) => bcs.Address.parse(result[0].value)
|
|
342
|
+
)
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Check if an address is a price updater
|
|
347
|
+
* @param tx - The transaction to add the move call to
|
|
348
|
+
* @param updater - The updater address to check
|
|
349
|
+
* @returns Transaction result containing the price updater status
|
|
350
|
+
*/
|
|
351
|
+
isPriceUpdaterMoveCall(tx: Transaction, updater: string | TransactionArgument): TransactionResult {
|
|
352
|
+
return tx.moveCall({
|
|
353
|
+
target: this.#target('is_price_updater'),
|
|
354
|
+
arguments: [tx.object(this.objects.priceFeed), asAddress(tx, updater)],
|
|
355
|
+
})
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Check if an address is a price updater
|
|
360
|
+
* @param updater - The updater address to check
|
|
361
|
+
* @returns Promise<boolean> - True if the address is a price updater
|
|
362
|
+
*/
|
|
363
|
+
async isPriceUpdater(updater: string): Promise<boolean> {
|
|
364
|
+
return executeSimulate(
|
|
365
|
+
this.client,
|
|
366
|
+
(tx) => {
|
|
367
|
+
this.isPriceUpdaterMoveCall(tx, updater)
|
|
368
|
+
},
|
|
369
|
+
(result) => bcs.Bool.parse(result[0].value)
|
|
370
|
+
)
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Get price ratio denominator
|
|
375
|
+
* @param tx - The transaction to add the move call to
|
|
376
|
+
* @returns Transaction result containing the price ratio denominator
|
|
377
|
+
*/
|
|
378
|
+
priceRatioDenominatorMoveCall(tx: Transaction): TransactionResult {
|
|
379
|
+
return tx.moveCall({
|
|
380
|
+
target: this.#target('get_price_ratio_denominator'),
|
|
381
|
+
arguments: [tx.object(this.objects.priceFeed)],
|
|
382
|
+
})
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Get price ratio denominator
|
|
387
|
+
* @returns Promise<bigint> - The price ratio denominator value
|
|
388
|
+
*/
|
|
389
|
+
async priceRatioDenominator(): Promise<bigint> {
|
|
390
|
+
return executeSimulate(
|
|
391
|
+
this.client,
|
|
392
|
+
(tx) => {
|
|
393
|
+
this.priceRatioDenominatorMoveCall(tx)
|
|
394
|
+
},
|
|
395
|
+
(result) => BigInt(bcs.U128.parse(result[0].value))
|
|
396
|
+
)
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Get Arbitrum compression percentage
|
|
401
|
+
* @param tx - The transaction to add the move call to
|
|
402
|
+
* @returns Transaction result containing the compression percentage
|
|
403
|
+
*/
|
|
404
|
+
arbitrumCompressionPercentMoveCall(tx: Transaction): TransactionResult {
|
|
405
|
+
return tx.moveCall({
|
|
406
|
+
target: this.#target('get_arbitrum_compression_percent'),
|
|
407
|
+
arguments: [tx.object(this.objects.priceFeed)],
|
|
408
|
+
})
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Get Arbitrum compression percentage
|
|
413
|
+
* @returns Promise<bigint> - The compression percentage value
|
|
414
|
+
*/
|
|
415
|
+
async arbitrumCompressionPercent(): Promise<bigint> {
|
|
416
|
+
return executeSimulate(
|
|
417
|
+
this.client,
|
|
418
|
+
(tx) => {
|
|
419
|
+
this.arbitrumCompressionPercentMoveCall(tx)
|
|
420
|
+
},
|
|
421
|
+
(result) => BigInt(bcs.U128.parse(result[0].value))
|
|
422
|
+
)
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Get model type for a destination EID
|
|
427
|
+
* @param tx - The transaction to add the move call to
|
|
428
|
+
* @param dstEid - Destination endpoint ID
|
|
429
|
+
* @returns Transaction result containing the model type
|
|
430
|
+
*/
|
|
431
|
+
modelTypeMoveCall(tx: Transaction, dstEid: number | TransactionArgument): TransactionResult {
|
|
432
|
+
return tx.moveCall({
|
|
433
|
+
target: this.#target('get_model_type'),
|
|
434
|
+
arguments: [tx.object(this.objects.priceFeed), asU32(tx, dstEid)],
|
|
435
|
+
})
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Get model type for a destination EID
|
|
440
|
+
* @param dstEid - Destination endpoint ID
|
|
441
|
+
* @returns Promise<PriceModelType> - The price model type
|
|
442
|
+
*/
|
|
443
|
+
async modelType(dstEid: number): Promise<ModelType> {
|
|
444
|
+
return executeSimulate(
|
|
445
|
+
this.client,
|
|
446
|
+
(tx) => {
|
|
447
|
+
this.modelTypeMoveCall(tx, dstEid)
|
|
448
|
+
},
|
|
449
|
+
(result) => {
|
|
450
|
+
const enumValue = ModelTypeBcs.parse(result[0].value) as { $kind: string }
|
|
451
|
+
switch (enumValue.$kind) {
|
|
452
|
+
case 'DEFAULT':
|
|
453
|
+
return ModelType.DEFAULT
|
|
454
|
+
case 'ARB_STACK':
|
|
455
|
+
return ModelType.ARB_STACK
|
|
456
|
+
case 'OP_STACK':
|
|
457
|
+
return ModelType.OP_STACK
|
|
458
|
+
default:
|
|
459
|
+
throw new Error(`Invalid model type: ${JSON.stringify(enumValue)}`)
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
)
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Get native token price in USD
|
|
467
|
+
* @param tx - The transaction to add the move call to
|
|
468
|
+
* @returns Transaction result containing the native token price in USD
|
|
469
|
+
*/
|
|
470
|
+
nativeTokenPriceUsdMoveCall(tx: Transaction): TransactionResult {
|
|
471
|
+
return tx.moveCall({
|
|
472
|
+
target: this.#target('native_token_price_usd'),
|
|
473
|
+
arguments: [tx.object(this.objects.priceFeed)],
|
|
474
|
+
})
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Get native token price in USD
|
|
479
|
+
* @returns Promise<bigint> - The native token price in USD
|
|
480
|
+
*/
|
|
481
|
+
async nativeTokenPriceUsd(): Promise<bigint> {
|
|
482
|
+
return executeSimulate(
|
|
483
|
+
this.client,
|
|
484
|
+
(tx) => {
|
|
485
|
+
this.nativeTokenPriceUsdMoveCall(tx)
|
|
486
|
+
},
|
|
487
|
+
(result) => BigInt(bcs.U128.parse(result[0].value))
|
|
488
|
+
)
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* Get Arbitrum price extension parameters
|
|
493
|
+
* @param tx - The transaction to add the move call to
|
|
494
|
+
* @returns Transaction result containing Arbitrum price extension
|
|
495
|
+
*/
|
|
496
|
+
arbitrumPriceExtMoveCall(tx: Transaction): TransactionResult {
|
|
497
|
+
return tx.moveCall({
|
|
498
|
+
target: this.#target('arbitrum_price_ext'),
|
|
499
|
+
arguments: [tx.object(this.objects.priceFeed)],
|
|
500
|
+
})
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Get Arbitrum price extension parameters
|
|
505
|
+
* @returns Promise<ArbitrumPriceExt> - The Arbitrum price extension configuration
|
|
506
|
+
*/
|
|
507
|
+
async arbitrumPriceExt(): Promise<ArbitrumPriceExt> {
|
|
508
|
+
return executeSimulate(
|
|
509
|
+
this.client,
|
|
510
|
+
(tx) => {
|
|
511
|
+
this.arbitrumPriceExtMoveCall(tx)
|
|
512
|
+
},
|
|
513
|
+
(result) => {
|
|
514
|
+
const parsed = ArbitrumPriceExtBcs.parse(result[0].value) as {
|
|
515
|
+
gas_per_l2_tx: string | number | bigint
|
|
516
|
+
gas_per_l1_call_data_byte: number
|
|
517
|
+
}
|
|
518
|
+
return {
|
|
519
|
+
gasPerL2Tx: BigInt(parsed.gas_per_l2_tx),
|
|
520
|
+
gasPerL1CallDataByte: parsed.gas_per_l1_call_data_byte,
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
)
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Get price for a specific destination EID
|
|
528
|
+
* @param tx - The transaction to add the move call to
|
|
529
|
+
* @param dstEid - Destination endpoint ID
|
|
530
|
+
* @returns Transaction result containing the price configuration
|
|
531
|
+
*/
|
|
532
|
+
priceMoveCall(tx: Transaction, dstEid: number | TransactionArgument): TransactionResult {
|
|
533
|
+
return tx.moveCall({
|
|
534
|
+
target: this.#target('get_price'),
|
|
535
|
+
arguments: [tx.object(this.objects.priceFeed), asU32(tx, dstEid)],
|
|
536
|
+
})
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Get price for a specific destination EID
|
|
541
|
+
* @param dstEid - Destination endpoint ID
|
|
542
|
+
* @returns Promise<Price> - The price configuration for the destination
|
|
543
|
+
*/
|
|
544
|
+
async price(dstEid: number): Promise<Price> {
|
|
545
|
+
return executeSimulate(
|
|
546
|
+
this.client,
|
|
547
|
+
(tx) => {
|
|
548
|
+
this.priceMoveCall(tx, dstEid)
|
|
549
|
+
},
|
|
550
|
+
(result) => {
|
|
551
|
+
const parsed = PriceBcs.parse(result[0].value) as {
|
|
552
|
+
price_ratio: string | number | bigint
|
|
553
|
+
gas_price_in_unit: string | number | bigint
|
|
554
|
+
gas_per_byte: number
|
|
555
|
+
}
|
|
556
|
+
return {
|
|
557
|
+
priceRatio: BigInt(parsed.price_ratio),
|
|
558
|
+
gasPriceInUnit: BigInt(parsed.gas_price_in_unit),
|
|
559
|
+
gasPerByte: parsed.gas_per_byte,
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
)
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* Generate the full target path for move calls
|
|
567
|
+
* @param name - The function name to call
|
|
568
|
+
* @param module_name - The module name (defaults to MODULE_NAME)
|
|
569
|
+
* @returns The full module path for the move call
|
|
570
|
+
* @private
|
|
571
|
+
*/
|
|
572
|
+
#target(name: string, module_name = MODULE_NAME): string {
|
|
573
|
+
return `${this.packageId}::${module_name}::${name}`
|
|
574
|
+
}
|
|
575
|
+
}
|