@waterx/sdk 2.1.0
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/LICENSE +21 -0
- package/README.md +204 -0
- package/dist/src/client.d.ts +109 -0
- package/dist/src/client.js +197 -0
- package/dist/src/config.d.ts +229 -0
- package/dist/src/config.js +107 -0
- package/dist/src/constants.d.ts +64 -0
- package/dist/src/constants.js +71 -0
- package/dist/src/fetch.d.ts +144 -0
- package/dist/src/fetch.js +419 -0
- package/dist/src/generated/bucket_v2_framework/account.d.ts +107 -0
- package/dist/src/generated/bucket_v2_framework/account.js +129 -0
- package/dist/src/generated/bucket_v2_framework/deps/std/type_name.d.ts +17 -0
- package/dist/src/generated/bucket_v2_framework/deps/std/type_name.js +19 -0
- package/dist/src/generated/bucket_v2_framework/deps/sui/balance.d.ts +12 -0
- package/dist/src/generated/bucket_v2_framework/deps/sui/balance.js +14 -0
- package/dist/src/generated/bucket_v2_framework/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/bucket_v2_framework/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/bucket_v2_framework/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/generated/bucket_v2_framework/deps/sui/vec_set.js +19 -0
- package/dist/src/generated/bucket_v2_framework/double.d.ts +384 -0
- package/dist/src/generated/bucket_v2_framework/double.js +466 -0
- package/dist/src/generated/bucket_v2_framework/float.d.ts +364 -0
- package/dist/src/generated/bucket_v2_framework/float.js +440 -0
- package/dist/src/generated/bucket_v2_framework/liability.d.ts +197 -0
- package/dist/src/generated/bucket_v2_framework/liability.js +205 -0
- package/dist/src/generated/bucket_v2_framework/linked_table.d.ts +384 -0
- package/dist/src/generated/bucket_v2_framework/linked_table.js +382 -0
- package/dist/src/generated/bucket_v2_framework/sheet.d.ts +424 -0
- package/dist/src/generated/bucket_v2_framework/sheet.js +344 -0
- package/dist/src/generated/native_custody/custody_vault.d.ts +572 -0
- package/dist/src/generated/native_custody/custody_vault.js +483 -0
- package/dist/src/generated/native_custody/deps/bucket_v2_framework/float.d.ts +8 -0
- package/dist/src/generated/native_custody/deps/bucket_v2_framework/float.js +10 -0
- package/dist/src/generated/native_custody/deps/bucket_v2_framework/liability.d.ts +11 -0
- package/dist/src/generated/native_custody/deps/bucket_v2_framework/liability.js +13 -0
- package/dist/src/generated/native_custody/deps/bucket_v2_framework/sheet.d.ts +49 -0
- package/dist/src/generated/native_custody/deps/bucket_v2_framework/sheet.js +18 -0
- package/dist/src/generated/native_custody/deps/std/type_name.d.ts +17 -0
- package/dist/src/generated/native_custody/deps/std/type_name.js +19 -0
- package/dist/src/generated/native_custody/deps/sui/balance.d.ts +12 -0
- package/dist/src/generated/native_custody/deps/sui/balance.js +14 -0
- package/dist/src/generated/native_custody/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/native_custody/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/native_custody/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/generated/native_custody/deps/sui/vec_set.js +19 -0
- package/dist/src/generated/native_custody/events.d.ts +36 -0
- package/dist/src/generated/native_custody/events.js +36 -0
- package/dist/src/generated/pyth_sponsor_rule/deps/sui/balance.d.ts +12 -0
- package/dist/src/generated/pyth_sponsor_rule/deps/sui/balance.js +14 -0
- package/dist/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.d.ts +68 -0
- package/dist/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.js +74 -0
- package/dist/src/generated/utils/index.d.ts +30 -0
- package/dist/src/generated/utils/index.js +157 -0
- package/dist/src/generated/waterx_account/account.d.ts +1818 -0
- package/dist/src/generated/waterx_account/account.js +1723 -0
- package/dist/src/generated/waterx_account/deps/bucket_v2_framework/liability.d.ts +11 -0
- package/dist/src/generated/waterx_account/deps/bucket_v2_framework/liability.js +13 -0
- package/dist/src/generated/waterx_account/deps/bucket_v2_framework/sheet.d.ts +49 -0
- package/dist/src/generated/waterx_account/deps/bucket_v2_framework/sheet.js +18 -0
- package/dist/src/generated/waterx_account/deps/std/type_name.d.ts +17 -0
- package/dist/src/generated/waterx_account/deps/std/type_name.js +19 -0
- package/dist/src/generated/waterx_account/deps/sui/balance.d.ts +12 -0
- package/dist/src/generated/waterx_account/deps/sui/balance.js +14 -0
- package/dist/src/generated/waterx_account/deps/sui/object_table.d.ts +17 -0
- package/dist/src/generated/waterx_account/deps/sui/object_table.js +19 -0
- package/dist/src/generated/waterx_account/deps/sui/table.d.ts +29 -0
- package/dist/src/generated/waterx_account/deps/sui/table.js +31 -0
- package/dist/src/generated/waterx_account/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/waterx_account/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/waterx_account/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/generated/waterx_account/deps/sui/vec_set.js +19 -0
- package/dist/src/generated/waterx_account/direct_rule.d.ts +77 -0
- package/dist/src/generated/waterx_account/direct_rule.js +78 -0
- package/dist/src/generated/waterx_account/events.d.ts +180 -0
- package/dist/src/generated/waterx_account/events.js +156 -0
- package/dist/src/generated/waterx_account/version.d.ts +10 -0
- package/dist/src/generated/waterx_account/version.js +8 -0
- package/dist/src/generated/waterx_credit/credit_registry.d.ts +708 -0
- package/dist/src/generated/waterx_credit/credit_registry.js +658 -0
- package/dist/src/generated/waterx_credit/deps/std/type_name.d.ts +17 -0
- package/dist/src/generated/waterx_credit/deps/std/type_name.js +19 -0
- package/dist/src/generated/waterx_credit/deps/sui/table.d.ts +29 -0
- package/dist/src/generated/waterx_credit/deps/sui/table.js +31 -0
- package/dist/src/generated/waterx_credit/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/waterx_credit/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/waterx_credit/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/generated/waterx_credit/deps/sui/vec_set.js +19 -0
- package/dist/src/generated/waterx_credit/limited_supply.d.ts +107 -0
- package/dist/src/generated/waterx_credit/limited_supply.js +131 -0
- package/dist/src/generated/waterx_oracle/aggregator.d.ts +211 -0
- package/dist/src/generated/waterx_oracle/aggregator.js +213 -0
- package/dist/src/generated/waterx_oracle/collector.d.ts +119 -0
- package/dist/src/generated/waterx_oracle/collector.js +105 -0
- package/dist/src/generated/waterx_oracle/deps/bucket_v2_framework/float.d.ts +8 -0
- package/dist/src/generated/waterx_oracle/deps/bucket_v2_framework/float.js +10 -0
- package/dist/src/generated/waterx_oracle/deps/std/type_name.d.ts +17 -0
- package/dist/src/generated/waterx_oracle/deps/std/type_name.js +19 -0
- package/dist/src/generated/waterx_oracle/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/waterx_oracle/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/waterx_oracle/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/generated/waterx_oracle/deps/sui/vec_set.js +19 -0
- package/dist/src/generated/waterx_oracle/oracle.d.ts +298 -0
- package/dist/src/generated/waterx_oracle/oracle.js +323 -0
- package/dist/src/generated/waterx_oracle/version.d.ts +10 -0
- package/dist/src/generated/waterx_oracle/version.js +8 -0
- package/dist/src/generated/waterx_perp/account_data.d.ts +269 -0
- package/dist/src/generated/waterx_perp/account_data.js +284 -0
- package/dist/src/generated/waterx_perp/admin.d.ts +19 -0
- package/dist/src/generated/waterx_perp/admin.js +22 -0
- package/dist/src/generated/waterx_perp/deps/bucket_v2_framework/double.d.ts +8 -0
- package/dist/src/generated/waterx_perp/deps/bucket_v2_framework/double.js +10 -0
- package/dist/src/generated/waterx_perp/deps/bucket_v2_framework/float.d.ts +8 -0
- package/dist/src/generated/waterx_perp/deps/bucket_v2_framework/float.js +10 -0
- package/dist/src/generated/waterx_perp/deps/bucket_v2_framework/liability.d.ts +11 -0
- package/dist/src/generated/waterx_perp/deps/bucket_v2_framework/liability.js +13 -0
- package/dist/src/generated/waterx_perp/deps/bucket_v2_framework/linked_table.d.ts +8 -0
- package/dist/src/generated/waterx_perp/deps/bucket_v2_framework/linked_table.js +18 -0
- package/dist/src/generated/waterx_perp/deps/bucket_v2_framework/sheet.d.ts +49 -0
- package/dist/src/generated/waterx_perp/deps/bucket_v2_framework/sheet.js +18 -0
- package/dist/src/generated/waterx_perp/deps/std/type_name.d.ts +17 -0
- package/dist/src/generated/waterx_perp/deps/std/type_name.js +19 -0
- package/dist/src/generated/waterx_perp/deps/sui/balance.d.ts +15 -0
- package/dist/src/generated/waterx_perp/deps/sui/balance.js +17 -0
- package/dist/src/generated/waterx_perp/deps/sui/coin.d.ts +14 -0
- package/dist/src/generated/waterx_perp/deps/sui/coin.js +15 -0
- package/dist/src/generated/waterx_perp/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/waterx_perp/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/waterx_perp/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/generated/waterx_perp/deps/sui/vec_set.js +19 -0
- package/dist/src/generated/waterx_perp/events.d.ts +1283 -0
- package/dist/src/generated/waterx_perp/events.js +1018 -0
- package/dist/src/generated/waterx_perp/global_config.d.ts +775 -0
- package/dist/src/generated/waterx_perp/global_config.js +836 -0
- package/dist/src/generated/waterx_perp/keyed_big_vector.d.ts +553 -0
- package/dist/src/generated/waterx_perp/keyed_big_vector.js +554 -0
- package/dist/src/generated/waterx_perp/lp_pool.d.ts +1648 -0
- package/dist/src/generated/waterx_perp/lp_pool.js +1521 -0
- package/dist/src/generated/waterx_perp/market_config.d.ts +715 -0
- package/dist/src/generated/waterx_perp/market_config.js +780 -0
- package/dist/src/generated/waterx_perp/math.d.ts +63 -0
- package/dist/src/generated/waterx_perp/math.js +64 -0
- package/dist/src/generated/waterx_perp/memo.d.ts +251 -0
- package/dist/src/generated/waterx_perp/memo.js +323 -0
- package/dist/src/generated/waterx_perp/order_book.d.ts +290 -0
- package/dist/src/generated/waterx_perp/order_book.js +329 -0
- package/dist/src/generated/waterx_perp/position.d.ts +1005 -0
- package/dist/src/generated/waterx_perp/position.js +1103 -0
- package/dist/src/generated/waterx_perp/request.d.ts +544 -0
- package/dist/src/generated/waterx_perp/request.js +541 -0
- package/dist/src/generated/waterx_perp/response.d.ts +247 -0
- package/dist/src/generated/waterx_perp/response.js +280 -0
- package/dist/src/generated/waterx_perp/trading.d.ts +2821 -0
- package/dist/src/generated/waterx_perp/trading.js +2372 -0
- package/dist/src/generated/waterx_perp/version.d.ts +10 -0
- package/dist/src/generated/waterx_perp/version.js +8 -0
- package/dist/src/generated/waterx_perp/witness.d.ts +18 -0
- package/dist/src/generated/waterx_perp/witness.js +21 -0
- package/dist/src/generated/waterx_perp_view/deps/std/type_name.d.ts +17 -0
- package/dist/src/generated/waterx_perp_view/deps/std/type_name.js +19 -0
- package/dist/src/generated/waterx_perp_view/view.d.ts +447 -0
- package/dist/src/generated/waterx_perp_view/view.js +414 -0
- package/dist/src/generated/waterx_pyth_rule/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/waterx_pyth_rule/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/waterx_pyth_rule/pyth_rule.d.ts +90 -0
- package/dist/src/generated/waterx_pyth_rule/pyth_rule.js +72 -0
- package/dist/src/generated/waterx_referral/deps/sui/table.d.ts +29 -0
- package/dist/src/generated/waterx_referral/deps/sui/table.js +31 -0
- package/dist/src/generated/waterx_referral/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/generated/waterx_referral/deps/sui/vec_set.js +19 -0
- package/dist/src/generated/waterx_referral/referral_table.d.ts +171 -0
- package/dist/src/generated/waterx_referral/referral_table.js +192 -0
- package/dist/src/generated/waterx_staking/deps/bucket_v2_framework/double.d.ts +8 -0
- package/dist/src/generated/waterx_staking/deps/bucket_v2_framework/double.js +10 -0
- package/dist/src/generated/waterx_staking/deps/sui/balance.d.ts +12 -0
- package/dist/src/generated/waterx_staking/deps/sui/balance.js +14 -0
- package/dist/src/generated/waterx_staking/deps/sui/table.d.ts +29 -0
- package/dist/src/generated/waterx_staking/deps/sui/table.js +31 -0
- package/dist/src/generated/waterx_staking/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/generated/waterx_staking/deps/sui/vec_set.js +19 -0
- package/dist/src/generated/waterx_staking/waterx_staking.d.ts +746 -0
- package/dist/src/generated/waterx_staking/waterx_staking.js +731 -0
- package/dist/src/generated/waterx_staking/witness.d.ts +16 -0
- package/dist/src/generated/waterx_staking/witness.js +18 -0
- package/dist/src/generated/withdrawal_queue/deps/bucket_v2_framework/linked_table.d.ts +8 -0
- package/dist/src/generated/withdrawal_queue/deps/bucket_v2_framework/linked_table.js +18 -0
- package/dist/src/generated/withdrawal_queue/deps/std/type_name.d.ts +17 -0
- package/dist/src/generated/withdrawal_queue/deps/std/type_name.js +19 -0
- package/dist/src/generated/withdrawal_queue/deps/sui/balance.d.ts +12 -0
- package/dist/src/generated/withdrawal_queue/deps/sui/balance.js +14 -0
- package/dist/src/generated/withdrawal_queue/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/generated/withdrawal_queue/deps/sui/vec_set.js +19 -0
- package/dist/src/generated/withdrawal_queue/withdrawal_queue.d.ts +483 -0
- package/dist/src/generated/withdrawal_queue/withdrawal_queue.js +480 -0
- package/dist/src/generated/wlp/wlp.d.ts +28 -0
- package/dist/src/generated/wlp/wlp.js +32 -0
- package/dist/src/generated/wormhole_bridge/deps/sui/table.d.ts +29 -0
- package/dist/src/generated/wormhole_bridge/deps/sui/table.js +31 -0
- package/dist/src/generated/wormhole_bridge/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/wormhole_bridge/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/wormhole_bridge/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/generated/wormhole_bridge/deps/sui/vec_set.js +19 -0
- package/dist/src/generated/wormhole_bridge/deps/wormhole_sdk/consumed_vaas.d.ts +12 -0
- package/dist/src/generated/wormhole_bridge/deps/wormhole_sdk/consumed_vaas.js +9 -0
- package/dist/src/generated/wormhole_bridge/deps/wormhole_sdk/emitter.d.ts +14 -0
- package/dist/src/generated/wormhole_bridge/deps/wormhole_sdk/emitter.js +16 -0
- package/dist/src/generated/wormhole_bridge/deps/wormhole_sdk/set.d.ts +16 -0
- package/dist/src/generated/wormhole_bridge/deps/wormhole_sdk/set.js +15 -0
- package/dist/src/generated/wormhole_bridge/events.d.ts +32 -0
- package/dist/src/generated/wormhole_bridge/events.js +28 -0
- package/dist/src/generated/wormhole_bridge/wormhole_bridge.d.ts +498 -0
- package/dist/src/generated/wormhole_bridge/wormhole_bridge.js +494 -0
- package/dist/src/index.d.ts +28 -0
- package/dist/src/index.js +34 -0
- package/dist/src/tx-builders.d.ts +242 -0
- package/dist/src/tx-builders.js +320 -0
- package/dist/src/user/account.d.ts +129 -0
- package/dist/src/user/account.js +166 -0
- package/dist/src/user/credit.d.ts +135 -0
- package/dist/src/user/credit.js +255 -0
- package/dist/src/user/custody.d.ts +71 -0
- package/dist/src/user/custody.js +112 -0
- package/dist/src/user/index.d.ts +8 -0
- package/dist/src/user/index.js +8 -0
- package/dist/src/user/order.d.ts +89 -0
- package/dist/src/user/order.js +134 -0
- package/dist/src/user/referral.d.ts +21 -0
- package/dist/src/user/referral.js +41 -0
- package/dist/src/user/staking.d.ts +54 -0
- package/dist/src/user/staking.js +109 -0
- package/dist/src/user/trading.d.ts +119 -0
- package/dist/src/user/trading.js +262 -0
- package/dist/src/user/wlp.d.ts +58 -0
- package/dist/src/user/wlp.js +99 -0
- package/dist/src/utils/account-request.d.ts +9 -0
- package/dist/src/utils/account-request.js +17 -0
- package/dist/src/utils/config.d.ts +11 -0
- package/dist/src/utils/config.js +15 -0
- package/dist/src/utils/math.d.ts +201 -0
- package/dist/src/utils/math.js +343 -0
- package/dist/src/utils/pyth.d.ts +89 -0
- package/dist/src/utils/pyth.js +316 -0
- package/dist/src/utils/wormhole.d.ts +86 -0
- package/dist/src/utils/wormhole.js +154 -0
- package/package.json +66 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import { type BcsType } from '@mysten/sui/bcs';
|
|
5
|
+
import { MoveStruct } from '../../../utils/index.ts';
|
|
6
|
+
/** An entry in the map */
|
|
7
|
+
export declare function Entry<K extends BcsType<any>, V extends BcsType<any>>(...typeParameters: [
|
|
8
|
+
K,
|
|
9
|
+
V
|
|
10
|
+
]): MoveStruct<{
|
|
11
|
+
key: K;
|
|
12
|
+
value: V;
|
|
13
|
+
}, `0x2::vec_map::Entry<${K["name"]}, ${V["name"]}>`>;
|
|
14
|
+
/**
|
|
15
|
+
* A map data structure backed by a vector. The map is guaranteed not to contain
|
|
16
|
+
* duplicate keys, but entries are _not_ sorted by key--entries are included in
|
|
17
|
+
* insertion order. All operations are O(N) in the size of the map--the intention
|
|
18
|
+
* of this data structure is only to provide the convenience of programming against
|
|
19
|
+
* a map API. Large maps should use handwritten parent/child relationships instead.
|
|
20
|
+
* Maps that need sorted iteration rather than insertion order iteration should
|
|
21
|
+
* also be handwritten.
|
|
22
|
+
*/
|
|
23
|
+
export declare function VecMap<K extends BcsType<any>, V extends BcsType<any>>(...typeParameters: [
|
|
24
|
+
K,
|
|
25
|
+
V
|
|
26
|
+
]): MoveStruct<{
|
|
27
|
+
contents: BcsType<{
|
|
28
|
+
key: K extends BcsType<infer U, any, string> ? U : never;
|
|
29
|
+
value: V extends BcsType<infer U, any, string> ? U : never;
|
|
30
|
+
}[], Iterable<{
|
|
31
|
+
key: K extends BcsType<any, infer U_1, string> ? U_1 : never;
|
|
32
|
+
value: V extends BcsType<any, infer U_1, string> ? U_1 : never;
|
|
33
|
+
}> & {
|
|
34
|
+
length: number;
|
|
35
|
+
}, string>;
|
|
36
|
+
}, `0x2::vec_map::VecMap<${K["name"]}, ${V["name"]}>`>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
5
|
+
import { MoveStruct } from "../../../utils/index.js";
|
|
6
|
+
const $moduleName = '0x2::vec_map';
|
|
7
|
+
/** An entry in the map */
|
|
8
|
+
export function Entry(...typeParameters) {
|
|
9
|
+
return new MoveStruct({ name: `${$moduleName}::Entry<${typeParameters[0].name}, ${typeParameters[1].name}>`, fields: {
|
|
10
|
+
key: typeParameters[0],
|
|
11
|
+
value: typeParameters[1]
|
|
12
|
+
} });
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A map data structure backed by a vector. The map is guaranteed not to contain
|
|
16
|
+
* duplicate keys, but entries are _not_ sorted by key--entries are included in
|
|
17
|
+
* insertion order. All operations are O(N) in the size of the map--the intention
|
|
18
|
+
* of this data structure is only to provide the convenience of programming against
|
|
19
|
+
* a map API. Large maps should use handwritten parent/child relationships instead.
|
|
20
|
+
* Maps that need sorted iteration rather than insertion order iteration should
|
|
21
|
+
* also be handwritten.
|
|
22
|
+
*/
|
|
23
|
+
export function VecMap(...typeParameters) {
|
|
24
|
+
return new MoveStruct({ name: `${$moduleName}::VecMap<${typeParameters[0].name}, ${typeParameters[1].name}>`, fields: {
|
|
25
|
+
contents: bcs.vector(Entry(typeParameters[0], typeParameters[1]))
|
|
26
|
+
} });
|
|
27
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import { type BcsType } from '@mysten/sui/bcs';
|
|
5
|
+
import { MoveStruct } from '../../../utils/index.ts';
|
|
6
|
+
/**
|
|
7
|
+
* A set data structure backed by a vector. The set is guaranteed not to contain
|
|
8
|
+
* duplicate keys. All operations are O(N) in the size of the set
|
|
9
|
+
*
|
|
10
|
+
* - the intention of this data structure is only to provide the convenience of
|
|
11
|
+
* programming against a set API. Sets that need sorted iteration rather than
|
|
12
|
+
* insertion order iteration should be handwritten.
|
|
13
|
+
*/
|
|
14
|
+
export declare function VecSet<K extends BcsType<any>>(...typeParameters: [
|
|
15
|
+
K
|
|
16
|
+
]): MoveStruct<any, any>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
5
|
+
import { MoveStruct } from "../../../utils/index.js";
|
|
6
|
+
const $moduleName = '0x2::vec_set';
|
|
7
|
+
/**
|
|
8
|
+
* A set data structure backed by a vector. The set is guaranteed not to contain
|
|
9
|
+
* duplicate keys. All operations are O(N) in the size of the set
|
|
10
|
+
*
|
|
11
|
+
* - the intention of this data structure is only to provide the convenience of
|
|
12
|
+
* programming against a set API. Sets that need sorted iteration rather than
|
|
13
|
+
* insertion order iteration should be handwritten.
|
|
14
|
+
*/
|
|
15
|
+
export function VecSet(...typeParameters) {
|
|
16
|
+
return new MoveStruct({ name: `${$moduleName}::VecSet<${typeParameters[0].name}>`, fields: {
|
|
17
|
+
contents: bcs.vector(typeParameters[0])
|
|
18
|
+
} });
|
|
19
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
/** Events emitted by `native_custody::custody_vault`. */
|
|
5
|
+
import { MoveStruct } from '../utils/index.ts';
|
|
6
|
+
export declare const NewCustodyVault: MoveStruct<{
|
|
7
|
+
vault_id: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
8
|
+
}, "@waterx/native-custody::events::NewCustodyVault<phantom CREDIT>">;
|
|
9
|
+
export declare const AssetAdded: MoveStruct<{
|
|
10
|
+
vault_id: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
11
|
+
single_vault_id: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
12
|
+
decimal: import("@mysten/sui/bcs").BcsType<number, number, "u8">;
|
|
13
|
+
mint_fee_rate: MoveStruct<{
|
|
14
|
+
value: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u128">;
|
|
15
|
+
}, "bucket_v2_framework::float::Float">;
|
|
16
|
+
burn_fee_rate: MoveStruct<{
|
|
17
|
+
value: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u128">;
|
|
18
|
+
}, "bucket_v2_framework::float::Float">;
|
|
19
|
+
min_burn_amount: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
20
|
+
}, "@waterx/native-custody::events::AssetAdded<phantom CREDIT, phantom T>">;
|
|
21
|
+
export declare const Mint: MoveStruct<{
|
|
22
|
+
asset_in_amount: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
23
|
+
asset_balance: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
24
|
+
credit_out_amount: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
25
|
+
asset_credit_backing: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
26
|
+
credit_supply: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
27
|
+
fee_amount: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
28
|
+
}, "@waterx/native-custody::events::Mint<phantom CREDIT, phantom T>">;
|
|
29
|
+
export declare const Burn: MoveStruct<{
|
|
30
|
+
credit_in_amount: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
31
|
+
asset_credit_backing: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
32
|
+
asset_out_amount: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
33
|
+
asset_balance: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
34
|
+
credit_supply: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
35
|
+
fee_amount: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
36
|
+
}, "@waterx/native-custody::events::Burn<phantom CREDIT, phantom T>">;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
/** Events emitted by `native_custody::custody_vault`. */
|
|
5
|
+
import { MoveStruct } from "../utils/index.js";
|
|
6
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
7
|
+
import * as float from "./deps/bucket_v2_framework/float.js";
|
|
8
|
+
import * as float_1 from "./deps/bucket_v2_framework/float.js";
|
|
9
|
+
const $moduleName = '@waterx/native-custody::events';
|
|
10
|
+
export const NewCustodyVault = new MoveStruct({ name: `${$moduleName}::NewCustodyVault<phantom CREDIT>`, fields: {
|
|
11
|
+
vault_id: bcs.Address
|
|
12
|
+
} });
|
|
13
|
+
export const AssetAdded = new MoveStruct({ name: `${$moduleName}::AssetAdded<phantom CREDIT, phantom T>`, fields: {
|
|
14
|
+
vault_id: bcs.Address,
|
|
15
|
+
single_vault_id: bcs.Address,
|
|
16
|
+
decimal: bcs.u8(),
|
|
17
|
+
mint_fee_rate: float.Float,
|
|
18
|
+
burn_fee_rate: float_1.Float,
|
|
19
|
+
min_burn_amount: bcs.u64()
|
|
20
|
+
} });
|
|
21
|
+
export const Mint = new MoveStruct({ name: `${$moduleName}::Mint<phantom CREDIT, phantom T>`, fields: {
|
|
22
|
+
asset_in_amount: bcs.u64(),
|
|
23
|
+
asset_balance: bcs.u64(),
|
|
24
|
+
credit_out_amount: bcs.u64(),
|
|
25
|
+
asset_credit_backing: bcs.u64(),
|
|
26
|
+
credit_supply: bcs.u64(),
|
|
27
|
+
fee_amount: bcs.u64()
|
|
28
|
+
} });
|
|
29
|
+
export const Burn = new MoveStruct({ name: `${$moduleName}::Burn<phantom CREDIT, phantom T>`, fields: {
|
|
30
|
+
credit_in_amount: bcs.u64(),
|
|
31
|
+
asset_credit_backing: bcs.u64(),
|
|
32
|
+
asset_out_amount: bcs.u64(),
|
|
33
|
+
asset_balance: bcs.u64(),
|
|
34
|
+
credit_supply: bcs.u64(),
|
|
35
|
+
fee_amount: bcs.u64()
|
|
36
|
+
} });
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
/**
|
|
5
|
+
* A storable handler for Balances in general. Is used in the `Coin` module to
|
|
6
|
+
* allow balance operations and can be used to implement custom coins with `Supply`
|
|
7
|
+
* and `Balance`s.
|
|
8
|
+
*/
|
|
9
|
+
import { MoveStruct } from '../../../utils/index.ts';
|
|
10
|
+
export declare const Balance: MoveStruct<{
|
|
11
|
+
value: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
12
|
+
}, "0x2::balance::Balance<phantom T>">;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
/**
|
|
5
|
+
* A storable handler for Balances in general. Is used in the `Coin` module to
|
|
6
|
+
* allow balance operations and can be used to implement custom coins with `Supply`
|
|
7
|
+
* and `Balance`s.
|
|
8
|
+
*/
|
|
9
|
+
import { MoveStruct } from "../../../utils/index.js";
|
|
10
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
11
|
+
const $moduleName = '0x2::balance';
|
|
12
|
+
export const Balance = new MoveStruct({ name: `${$moduleName}::Balance<phantom T>`, fields: {
|
|
13
|
+
value: bcs.u64()
|
|
14
|
+
} });
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import { MoveStruct, type RawTransactionArgument } from '../utils/index.ts';
|
|
5
|
+
import { type Transaction } from '@mysten/sui/transactions';
|
|
6
|
+
export declare const PythSponsorRule: MoveStruct<{
|
|
7
|
+
dummy_field: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
|
|
8
|
+
}, "@waterx/pyth-sponsor-rule::pyth_sponsor_rule::PythSponsorRule">;
|
|
9
|
+
export declare const PythSponsor: MoveStruct<{
|
|
10
|
+
id: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
11
|
+
balance: MoveStruct<{
|
|
12
|
+
value: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
13
|
+
}, "0x2::balance::Balance<phantom T>">;
|
|
14
|
+
}, "@waterx/pyth-sponsor-rule::pyth_sponsor_rule::PythSponsor">;
|
|
15
|
+
export declare const Fund: MoveStruct<{
|
|
16
|
+
balance: MoveStruct<{
|
|
17
|
+
value: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
18
|
+
}, "0x2::balance::Balance<phantom T>">;
|
|
19
|
+
}, "@waterx/pyth-sponsor-rule::pyth_sponsor_rule::Fund">;
|
|
20
|
+
export interface RequestArguments {
|
|
21
|
+
self: RawTransactionArgument<string>;
|
|
22
|
+
}
|
|
23
|
+
export interface RequestOptions {
|
|
24
|
+
package?: string;
|
|
25
|
+
arguments: RequestArguments | [
|
|
26
|
+
self: RawTransactionArgument<string>
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
export declare function request(options: RequestOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
30
|
+
export interface SplitArguments {
|
|
31
|
+
fund: RawTransactionArgument<string>;
|
|
32
|
+
}
|
|
33
|
+
export interface SplitOptions {
|
|
34
|
+
package?: string;
|
|
35
|
+
arguments: SplitArguments | [
|
|
36
|
+
fund: RawTransactionArgument<string>
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
export declare function split(options: SplitOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
40
|
+
export interface ReimburseArguments {
|
|
41
|
+
self: RawTransactionArgument<string>;
|
|
42
|
+
fund: RawTransactionArgument<string>;
|
|
43
|
+
tradingReq: RawTransactionArgument<string>;
|
|
44
|
+
}
|
|
45
|
+
export interface ReimburseOptions {
|
|
46
|
+
package?: string;
|
|
47
|
+
arguments: ReimburseArguments | [
|
|
48
|
+
self: RawTransactionArgument<string>,
|
|
49
|
+
fund: RawTransactionArgument<string>,
|
|
50
|
+
tradingReq: RawTransactionArgument<string>
|
|
51
|
+
];
|
|
52
|
+
typeArguments: [
|
|
53
|
+
string
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
export declare function reimburse(options: ReimburseOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
57
|
+
export interface SupplyArguments {
|
|
58
|
+
self: RawTransactionArgument<string>;
|
|
59
|
+
coin: RawTransactionArgument<string>;
|
|
60
|
+
}
|
|
61
|
+
export interface SupplyOptions {
|
|
62
|
+
package?: string;
|
|
63
|
+
arguments: SupplyArguments | [
|
|
64
|
+
self: RawTransactionArgument<string>,
|
|
65
|
+
coin: RawTransactionArgument<string>
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
export declare function supply(options: SupplyOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import { MoveStruct, normalizeMoveArguments } from "../utils/index.js";
|
|
5
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
6
|
+
import * as balance from "./deps/sui/balance.js";
|
|
7
|
+
import * as balance_1 from "./deps/sui/balance.js";
|
|
8
|
+
const $moduleName = '@waterx/pyth-sponsor-rule::pyth_sponsor_rule';
|
|
9
|
+
export const PythSponsorRule = new MoveStruct({ name: `${$moduleName}::PythSponsorRule`, fields: {
|
|
10
|
+
dummy_field: bcs.bool()
|
|
11
|
+
} });
|
|
12
|
+
export const PythSponsor = new MoveStruct({ name: `${$moduleName}::PythSponsor`, fields: {
|
|
13
|
+
id: bcs.Address,
|
|
14
|
+
balance: balance.Balance
|
|
15
|
+
} });
|
|
16
|
+
export const Fund = new MoveStruct({ name: `${$moduleName}::Fund`, fields: {
|
|
17
|
+
balance: balance_1.Balance
|
|
18
|
+
} });
|
|
19
|
+
export function request(options) {
|
|
20
|
+
const packageAddress = options.package ?? '@waterx/pyth-sponsor-rule';
|
|
21
|
+
const argumentsTypes = [
|
|
22
|
+
null
|
|
23
|
+
];
|
|
24
|
+
const parameterNames = ["self"];
|
|
25
|
+
return (tx) => tx.moveCall({
|
|
26
|
+
package: packageAddress,
|
|
27
|
+
module: 'pyth_sponsor_rule',
|
|
28
|
+
function: 'request',
|
|
29
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
export function split(options) {
|
|
33
|
+
const packageAddress = options.package ?? '@waterx/pyth-sponsor-rule';
|
|
34
|
+
const argumentsTypes = [
|
|
35
|
+
null
|
|
36
|
+
];
|
|
37
|
+
const parameterNames = ["fund"];
|
|
38
|
+
return (tx) => tx.moveCall({
|
|
39
|
+
package: packageAddress,
|
|
40
|
+
module: 'pyth_sponsor_rule',
|
|
41
|
+
function: 'split',
|
|
42
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
export function reimburse(options) {
|
|
46
|
+
const packageAddress = options.package ?? '@waterx/pyth-sponsor-rule';
|
|
47
|
+
const argumentsTypes = [
|
|
48
|
+
null,
|
|
49
|
+
null,
|
|
50
|
+
null
|
|
51
|
+
];
|
|
52
|
+
const parameterNames = ["self", "fund", "tradingReq"];
|
|
53
|
+
return (tx) => tx.moveCall({
|
|
54
|
+
package: packageAddress,
|
|
55
|
+
module: 'pyth_sponsor_rule',
|
|
56
|
+
function: 'reimburse',
|
|
57
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
58
|
+
typeArguments: options.typeArguments
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
export function supply(options) {
|
|
62
|
+
const packageAddress = options.package ?? '@waterx/pyth-sponsor-rule';
|
|
63
|
+
const argumentsTypes = [
|
|
64
|
+
null,
|
|
65
|
+
null
|
|
66
|
+
];
|
|
67
|
+
const parameterNames = ["self", "coin"];
|
|
68
|
+
return (tx) => tx.moveCall({
|
|
69
|
+
package: packageAddress,
|
|
70
|
+
module: 'pyth_sponsor_rule',
|
|
71
|
+
function: 'supply',
|
|
72
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
73
|
+
});
|
|
74
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BcsType, TypeTag, BcsStruct, BcsEnum, BcsTuple } from '@mysten/sui/bcs';
|
|
2
|
+
import { TransactionArgument } from '@mysten/sui/transactions';
|
|
3
|
+
import { ClientWithCoreApi, SuiClientTypes } from '@mysten/sui/client';
|
|
4
|
+
export type RawTransactionArgument<T> = T | TransactionArgument;
|
|
5
|
+
export interface GetOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> extends SuiClientTypes.GetObjectOptions<Include> {
|
|
6
|
+
client: ClientWithCoreApi;
|
|
7
|
+
}
|
|
8
|
+
export interface GetManyOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> extends SuiClientTypes.GetObjectsOptions<Include> {
|
|
9
|
+
client: ClientWithCoreApi;
|
|
10
|
+
}
|
|
11
|
+
export declare function getPureBcsSchema(typeTag: string | TypeTag): BcsType<any> | null;
|
|
12
|
+
export declare function normalizeMoveArguments(args: unknown[] | object, argTypes: readonly (string | null)[], parameterNames?: string[]): TransactionArgument[];
|
|
13
|
+
export declare class MoveStruct<T extends Record<string, BcsType<any>>, const Name extends string = string> extends BcsStruct<T, Name> {
|
|
14
|
+
get<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({ objectId, ...options }: GetOptions<Include>): Promise<SuiClientTypes.Object<Include & {
|
|
15
|
+
content: true;
|
|
16
|
+
json: true;
|
|
17
|
+
}> & {
|
|
18
|
+
json: BcsStruct<T>['$inferType'];
|
|
19
|
+
}>;
|
|
20
|
+
getMany<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({ client, ...options }: GetManyOptions<Include>): Promise<Array<SuiClientTypes.Object<Include & {
|
|
21
|
+
content: true;
|
|
22
|
+
json: true;
|
|
23
|
+
}> & {
|
|
24
|
+
json: BcsStruct<T>['$inferType'];
|
|
25
|
+
}>>;
|
|
26
|
+
}
|
|
27
|
+
export declare class MoveEnum<T extends Record<string, BcsType<any> | null>, const Name extends string> extends BcsEnum<T, Name> {
|
|
28
|
+
}
|
|
29
|
+
export declare class MoveTuple<const T extends readonly BcsType<any>[], const Name extends string> extends BcsTuple<T, Name> {
|
|
30
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { bcs, TypeTagSerializer, BcsStruct, BcsEnum, BcsTuple, } from '@mysten/sui/bcs';
|
|
2
|
+
import { normalizeSuiAddress } from '@mysten/sui/utils';
|
|
3
|
+
import { isArgument } from '@mysten/sui/transactions';
|
|
4
|
+
const MOVE_STDLIB_ADDRESS = normalizeSuiAddress('0x1');
|
|
5
|
+
const SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress('0x2');
|
|
6
|
+
export function getPureBcsSchema(typeTag) {
|
|
7
|
+
const parsedTag = typeof typeTag === 'string' ? TypeTagSerializer.parseFromStr(typeTag) : typeTag;
|
|
8
|
+
if ('u8' in parsedTag) {
|
|
9
|
+
return bcs.U8;
|
|
10
|
+
}
|
|
11
|
+
else if ('u16' in parsedTag) {
|
|
12
|
+
return bcs.U16;
|
|
13
|
+
}
|
|
14
|
+
else if ('u32' in parsedTag) {
|
|
15
|
+
return bcs.U32;
|
|
16
|
+
}
|
|
17
|
+
else if ('u64' in parsedTag) {
|
|
18
|
+
return bcs.U64;
|
|
19
|
+
}
|
|
20
|
+
else if ('u128' in parsedTag) {
|
|
21
|
+
return bcs.U128;
|
|
22
|
+
}
|
|
23
|
+
else if ('u256' in parsedTag) {
|
|
24
|
+
return bcs.U256;
|
|
25
|
+
}
|
|
26
|
+
else if ('address' in parsedTag) {
|
|
27
|
+
return bcs.Address;
|
|
28
|
+
}
|
|
29
|
+
else if ('bool' in parsedTag) {
|
|
30
|
+
return bcs.Bool;
|
|
31
|
+
}
|
|
32
|
+
else if ('vector' in parsedTag) {
|
|
33
|
+
const type = getPureBcsSchema(parsedTag.vector);
|
|
34
|
+
return type ? bcs.vector(type) : null;
|
|
35
|
+
}
|
|
36
|
+
else if ('struct' in parsedTag) {
|
|
37
|
+
const structTag = parsedTag.struct;
|
|
38
|
+
const pkg = normalizeSuiAddress(structTag.address);
|
|
39
|
+
if (pkg === MOVE_STDLIB_ADDRESS) {
|
|
40
|
+
if ((structTag.module === 'ascii' || structTag.module === 'string') &&
|
|
41
|
+
structTag.name === 'String') {
|
|
42
|
+
return bcs.String;
|
|
43
|
+
}
|
|
44
|
+
if (structTag.module === 'option' && structTag.name === 'Option') {
|
|
45
|
+
const type = getPureBcsSchema(structTag.typeParams[0]);
|
|
46
|
+
return type ? bcs.option(type) : null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (pkg === SUI_FRAMEWORK_ADDRESS &&
|
|
50
|
+
structTag.module === 'object' &&
|
|
51
|
+
(structTag.name === 'ID' || structTag.name === 'UID')) {
|
|
52
|
+
return bcs.Address;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
export function normalizeMoveArguments(args, argTypes, parameterNames) {
|
|
58
|
+
const argLen = Array.isArray(args) ? args.length : Object.keys(args).length;
|
|
59
|
+
if (parameterNames && argLen !== parameterNames.length) {
|
|
60
|
+
throw new Error(`Invalid number of arguments, expected ${parameterNames.length}, got ${argLen}`);
|
|
61
|
+
}
|
|
62
|
+
const normalizedArgs = [];
|
|
63
|
+
let index = 0;
|
|
64
|
+
for (const [i, argType] of argTypes.entries()) {
|
|
65
|
+
if (argType === '0x2::clock::Clock') {
|
|
66
|
+
normalizedArgs.push((tx) => tx.object.clock());
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (argType === '0x2::random::Random') {
|
|
70
|
+
normalizedArgs.push((tx) => tx.object.random());
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (argType === '0x2::deny_list::DenyList') {
|
|
74
|
+
normalizedArgs.push((tx) => tx.object.denyList());
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (argType === '0x3::sui_system::SuiSystemState') {
|
|
78
|
+
normalizedArgs.push((tx) => tx.object.system());
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
let arg;
|
|
82
|
+
if (Array.isArray(args)) {
|
|
83
|
+
if (index >= args.length) {
|
|
84
|
+
throw new Error(`Invalid number of arguments, expected at least ${index + 1}, got ${args.length}`);
|
|
85
|
+
}
|
|
86
|
+
arg = args[index];
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
if (!parameterNames) {
|
|
90
|
+
throw new Error(`Expected arguments to be passed as an array`);
|
|
91
|
+
}
|
|
92
|
+
const name = parameterNames[index];
|
|
93
|
+
arg = args[name];
|
|
94
|
+
if (arg === undefined) {
|
|
95
|
+
throw new Error(`Parameter ${name} is required`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
index += 1;
|
|
99
|
+
if (typeof arg === 'function' || isArgument(arg)) {
|
|
100
|
+
normalizedArgs.push(arg);
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
const type = argTypes[i];
|
|
104
|
+
const bcsType = type === null ? null : getPureBcsSchema(type);
|
|
105
|
+
if (bcsType) {
|
|
106
|
+
const bytes = bcsType.serialize(arg);
|
|
107
|
+
normalizedArgs.push((tx) => tx.pure(bytes));
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
else if (typeof arg === 'string') {
|
|
111
|
+
normalizedArgs.push((tx) => tx.object(arg));
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
throw new Error(`Invalid argument ${stringify(arg)} for type ${type}`);
|
|
115
|
+
}
|
|
116
|
+
return normalizedArgs;
|
|
117
|
+
}
|
|
118
|
+
export class MoveStruct extends BcsStruct {
|
|
119
|
+
async get({ objectId, ...options }) {
|
|
120
|
+
const [res] = await this.getMany({
|
|
121
|
+
...options,
|
|
122
|
+
objectIds: [objectId],
|
|
123
|
+
});
|
|
124
|
+
return res;
|
|
125
|
+
}
|
|
126
|
+
async getMany({ client, ...options }) {
|
|
127
|
+
const response = (await client.core.getObjects({
|
|
128
|
+
...options,
|
|
129
|
+
include: {
|
|
130
|
+
...options.include,
|
|
131
|
+
content: true,
|
|
132
|
+
},
|
|
133
|
+
}));
|
|
134
|
+
return response.objects.map((obj) => {
|
|
135
|
+
if (obj instanceof Error) {
|
|
136
|
+
throw obj;
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
...obj,
|
|
140
|
+
json: this.parse(obj.content),
|
|
141
|
+
};
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
export class MoveEnum extends BcsEnum {
|
|
146
|
+
}
|
|
147
|
+
export class MoveTuple extends BcsTuple {
|
|
148
|
+
}
|
|
149
|
+
function stringify(val) {
|
|
150
|
+
if (typeof val === 'object') {
|
|
151
|
+
return JSON.stringify(val, (val) => val);
|
|
152
|
+
}
|
|
153
|
+
if (typeof val === 'bigint') {
|
|
154
|
+
return val.toString();
|
|
155
|
+
}
|
|
156
|
+
return val;
|
|
157
|
+
}
|