@waterx/sdk 2.1.0 → 2.3.1-dev.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/README.md +75 -169
- package/dist/src/client.d.ts +52 -2
- package/dist/src/client.js +76 -6
- package/dist/src/config.d.ts +57 -3
- package/dist/src/config.js +10 -4
- package/dist/src/constants.d.ts +6 -0
- package/dist/src/constants.js +6 -0
- package/dist/src/core/waterx-account.d.ts +31 -0
- package/dist/src/core/waterx-account.js +26 -0
- package/dist/src/fetch.d.ts +110 -0
- package/dist/src/fetch.js +149 -4
- package/dist/src/generated/bucket_v2_framework/account.d.ts +5 -5
- package/dist/src/generated/bucket_v2_framework/double.d.ts +77 -77
- package/dist/src/generated/bucket_v2_framework/float.d.ts +73 -73
- package/dist/src/generated/bucket_v2_framework/liability.d.ts +33 -33
- package/dist/src/generated/bucket_v2_framework/linked_table.d.ts +5 -5
- package/dist/src/generated/bucket_v2_framework/linked_table.js +2 -2
- package/dist/src/generated/bucket_v2_framework/sheet.d.ts +57 -57
- package/dist/src/generated/bucket_v2_framework/sheet.js +5 -11
- package/dist/src/generated/native_custody/custody_vault.d.ts +46 -32
- package/dist/src/generated/native_custody/custody_vault.js +19 -10
- package/dist/src/generated/native_custody/deps/bucket_v2_framework/sheet.js +1 -3
- package/dist/src/generated/native_custody/events.js +1 -2
- package/dist/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.d.ts +7 -7
- package/dist/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.js +1 -2
- package/dist/src/generated/utils/index.d.ts +7 -7
- package/dist/src/generated/utils/index.js +9 -6
- package/dist/src/generated/waterx_account/account.d.ts +124 -71
- package/dist/src/generated/waterx_account/account.js +64 -29
- package/dist/src/generated/waterx_account/deps/bucket_v2_framework/sheet.js +1 -3
- package/dist/src/generated/waterx_account/direct_rule.d.ts +5 -5
- package/dist/src/generated/waterx_account/events.d.ts +10 -0
- package/dist/src/generated/waterx_account/events.js +31 -50
- package/dist/src/generated/waterx_constant_rule/constant_rule.d.ts +68 -0
- package/dist/src/generated/waterx_constant_rule/constant_rule.js +59 -0
- package/dist/src/generated/waterx_constant_rule/deps/bucket_v2_framework/float.d.ts +8 -0
- package/dist/src/generated/waterx_constant_rule/deps/bucket_v2_framework/float.js +10 -0
- package/dist/src/generated/waterx_constant_rule/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/waterx_constant_rule/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/waterx_credit/credit_registry.d.ts +9 -9
- package/dist/src/generated/waterx_credit/credit_registry.js +1 -2
- package/dist/src/generated/waterx_credit/limited_supply.d.ts +17 -17
- package/dist/src/generated/waterx_oracle/aggregator.js +1 -2
- package/dist/src/generated/waterx_oracle/collector.d.ts +17 -17
- package/dist/src/generated/waterx_oracle/collector.js +1 -1
- package/dist/src/generated/waterx_oracle/oracle.d.ts +5 -5
- package/dist/src/generated/waterx_perp/account_data.d.ts +5 -5
- package/dist/src/generated/waterx_perp/account_data.js +1 -2
- package/dist/src/generated/waterx_perp/deps/bucket_v2_framework/sheet.js +1 -3
- package/dist/src/generated/waterx_perp/events.d.ts +181 -181
- package/dist/src/generated/waterx_perp/events.js +87 -173
- package/dist/src/generated/waterx_perp/global_config.d.ts +3 -3
- package/dist/src/generated/waterx_perp/global_config.js +6 -12
- package/dist/src/generated/waterx_perp/keyed_big_vector.d.ts +9 -9
- package/dist/src/generated/waterx_perp/keyed_big_vector.js +1 -2
- package/dist/src/generated/waterx_perp/lp_pool.d.ts +115 -115
- package/dist/src/generated/waterx_perp/lp_pool.js +11 -22
- package/dist/src/generated/waterx_perp/market_config.d.ts +61 -43
- package/dist/src/generated/waterx_perp/market_config.js +29 -22
- package/dist/src/generated/waterx_perp/math.d.ts +7 -7
- package/dist/src/generated/waterx_perp/order_book.d.ts +47 -47
- package/dist/src/generated/waterx_perp/position.d.ts +99 -99
- package/dist/src/generated/waterx_perp/position.js +6 -12
- package/dist/src/generated/waterx_perp/request.d.ts +67 -67
- package/dist/src/generated/waterx_perp/request.js +2 -3
- package/dist/src/generated/waterx_perp/response.d.ts +35 -35
- package/dist/src/generated/waterx_perp/response.js +1 -2
- package/dist/src/generated/waterx_perp/trading.d.ts +303 -179
- package/dist/src/generated/waterx_perp/trading.js +99 -14
- package/dist/src/generated/waterx_perp_view/view.js +5 -10
- package/dist/src/generated/waterx_pyth_rule/pyth_rule.d.ts +5 -5
- package/dist/src/generated/waterx_pyth_rule/pyth_rule.js +1 -2
- package/dist/src/generated/waterx_referral/referral_table.d.ts +5 -5
- package/dist/src/generated/waterx_referral/referral_table.js +1 -2
- package/dist/src/generated/waterx_staking/waterx_staking.d.ts +19 -19
- package/dist/src/generated/waterx_staking/waterx_staking.js +10 -20
- package/dist/src/generated/waterx_supra_rule/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/waterx_supra_rule/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/waterx_supra_rule/supra_rule.d.ts +158 -0
- package/dist/src/generated/waterx_supra_rule/supra_rule.js +148 -0
- package/dist/src/generated/withdrawal_queue/deps/bucket_v2_framework/float.d.ts +8 -0
- package/dist/src/generated/withdrawal_queue/deps/bucket_v2_framework/float.js +10 -0
- package/dist/src/generated/withdrawal_queue/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/withdrawal_queue/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/withdrawal_queue/withdrawal_queue.d.ts +444 -4
- package/dist/src/generated/withdrawal_queue/withdrawal_queue.js +417 -4
- package/dist/src/generated/wormhole_bridge/wormhole_bridge.d.ts +214 -74
- package/dist/src/generated/wormhole_bridge/wormhole_bridge.js +158 -29
- package/dist/src/index.d.ts +4 -3
- package/dist/src/index.js +3 -2
- package/dist/src/prediction/account.d.ts +96 -0
- package/dist/src/prediction/account.js +230 -0
- package/dist/src/prediction/admin.d.ts +47 -0
- package/dist/src/prediction/admin.js +105 -0
- package/dist/src/prediction/bcs.d.ts +22 -0
- package/dist/src/prediction/bcs.js +240 -0
- package/dist/src/prediction/client.d.ts +75 -0
- package/dist/src/prediction/client.js +164 -0
- package/dist/src/prediction/config.d.ts +60 -0
- package/dist/src/prediction/config.js +75 -0
- package/dist/src/prediction/constants.d.ts +44 -0
- package/dist/src/prediction/constants.js +46 -0
- package/dist/src/prediction/fetch.d.ts +82 -0
- package/dist/src/prediction/fetch.js +270 -0
- package/dist/src/prediction/generated/bucket_v2_framework/account.d.ts +100 -0
- package/dist/src/prediction/generated/bucket_v2_framework/account.js +129 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/std/type_name.d.ts +6 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/std/type_name.js +19 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/balance.d.ts +10 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/balance.js +14 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_map.js +27 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_set.js +19 -0
- package/dist/src/prediction/generated/bucket_v2_framework/double.d.ts +382 -0
- package/dist/src/prediction/generated/bucket_v2_framework/double.js +466 -0
- package/dist/src/prediction/generated/bucket_v2_framework/float.d.ts +362 -0
- package/dist/src/prediction/generated/bucket_v2_framework/float.js +440 -0
- package/dist/src/prediction/generated/bucket_v2_framework/liability.d.ts +193 -0
- package/dist/src/prediction/generated/bucket_v2_framework/liability.js +205 -0
- package/dist/src/prediction/generated/bucket_v2_framework/linked_table.d.ts +384 -0
- package/dist/src/prediction/generated/bucket_v2_framework/linked_table.js +382 -0
- package/dist/src/prediction/generated/bucket_v2_framework/sheet.d.ts +344 -0
- package/dist/src/prediction/generated/bucket_v2_framework/sheet.js +338 -0
- package/dist/src/prediction/generated/utils/index.d.ts +30 -0
- package/dist/src/prediction/generated/utils/index.js +160 -0
- package/dist/src/prediction/generated/waterx_account/account.d.ts +1589 -0
- package/dist/src/prediction/generated/waterx_account/account.js +1758 -0
- package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/liability.d.ts +7 -0
- package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/liability.js +13 -0
- package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/sheet.d.ts +7 -0
- package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/sheet.js +16 -0
- package/dist/src/prediction/generated/waterx_account/deps/std/type_name.d.ts +6 -0
- package/dist/src/prediction/generated/waterx_account/deps/std/type_name.js +19 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/balance.d.ts +10 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/balance.js +14 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/object_table.d.ts +12 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/object_table.js +19 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/table.d.ts +24 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/table.js +31 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/vec_map.js +27 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/vec_set.js +19 -0
- package/dist/src/prediction/generated/waterx_account/direct_rule.d.ts +75 -0
- package/dist/src/prediction/generated/waterx_account/direct_rule.js +78 -0
- package/dist/src/prediction/generated/waterx_account/events.d.ts +33 -0
- package/dist/src/prediction/generated/waterx_account/events.js +137 -0
- package/dist/src/prediction/generated/waterx_account/version.d.ts +10 -0
- package/dist/src/prediction/generated/waterx_account/version.js +8 -0
- package/dist/src/prediction/generated/waterx_prediction/account_data.d.ts +327 -0
- package/dist/src/prediction/generated/waterx_prediction/account_data.js +405 -0
- package/dist/src/prediction/generated/waterx_prediction/admin.d.ts +5 -0
- package/dist/src/prediction/generated/waterx_prediction/admin.js +9 -0
- package/dist/src/prediction/generated/waterx_prediction/bet_sharing.d.ts +60 -0
- package/dist/src/prediction/generated/waterx_prediction/bet_sharing.js +83 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/bucket_v2_framework/linked_table.d.ts +8 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/bucket_v2_framework/linked_table.js +18 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/balance.d.ts +10 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/balance.js +14 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/table.d.ts +24 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/table.js +31 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/vec_set.js +19 -0
- package/dist/src/prediction/generated/waterx_prediction/events.d.ts +22 -0
- package/dist/src/prediction/generated/waterx_prediction/events.js +179 -0
- package/dist/src/prediction/generated/waterx_prediction/global_config.d.ts +116 -0
- package/dist/src/prediction/generated/waterx_prediction/global_config.js +141 -0
- package/dist/src/prediction/generated/waterx_prediction/order.d.ts +200 -0
- package/dist/src/prediction/generated/waterx_prediction/order.js +284 -0
- package/dist/src/prediction/generated/waterx_prediction/outcome.d.ts +58 -0
- package/dist/src/prediction/generated/waterx_prediction/outcome.js +73 -0
- package/dist/src/prediction/generated/waterx_prediction/position.d.ts +160 -0
- package/dist/src/prediction/generated/waterx_prediction/position.js +214 -0
- package/dist/src/prediction/generated/waterx_prediction/version.d.ts +10 -0
- package/dist/src/prediction/generated/waterx_prediction/version.js +8 -0
- package/dist/src/prediction/generated/waterx_prediction/view.d.ts +353 -0
- package/dist/src/prediction/generated/waterx_prediction/view.js +432 -0
- package/dist/src/prediction/generated/waterx_prediction/waterx_prediction.d.ts +1698 -0
- package/dist/src/prediction/generated/waterx_prediction/waterx_prediction.js +1733 -0
- package/dist/src/prediction/gift-link.d.ts +6 -0
- package/dist/src/prediction/gift-link.js +5 -0
- package/dist/src/prediction/gift.d.ts +223 -0
- package/dist/src/prediction/gift.js +451 -0
- package/dist/src/prediction/index.d.ts +29 -0
- package/dist/src/prediction/index.js +21 -0
- package/dist/src/prediction/prediction.d.ts +104 -0
- package/dist/src/prediction/prediction.js +317 -0
- package/dist/src/prediction/tx-builders.d.ts +44 -0
- package/dist/src/prediction/tx-builders.js +52 -0
- package/dist/src/prediction/types.d.ts +93 -0
- package/dist/src/prediction/types.js +1 -0
- package/dist/src/prediction/user/account.d.ts +2 -0
- package/dist/src/prediction/user/account.js +1 -0
- package/dist/src/prediction/user/admin.d.ts +6 -0
- package/dist/src/prediction/user/admin.js +3 -0
- package/dist/src/prediction/user/gift.d.ts +2 -0
- package/dist/src/prediction/user/gift.js +1 -0
- package/dist/src/prediction/user/index.d.ts +5 -0
- package/dist/src/prediction/user/index.js +3 -0
- package/dist/src/prediction/user/keeper.d.ts +2 -0
- package/dist/src/prediction/user/keeper.js +1 -0
- package/dist/src/prediction/user/order.d.ts +2 -0
- package/dist/src/prediction/user/order.js +1 -0
- package/dist/src/prediction/user/position.d.ts +2 -0
- package/dist/src/prediction/user/position.js +1 -0
- package/dist/src/prediction/utils/bcs.d.ts +1 -0
- package/dist/src/prediction/utils/bcs.js +1 -0
- package/dist/src/prediction/utils/index.d.ts +1 -0
- package/dist/src/prediction/utils/index.js +1 -0
- package/dist/src/prediction/utils.d.ts +30 -0
- package/dist/src/prediction/utils.js +177 -0
- package/dist/src/sdk.d.ts +18 -0
- package/dist/src/sdk.js +17 -0
- package/dist/src/tx-builders.d.ts +54 -0
- package/dist/src/tx-builders.js +141 -0
- package/dist/src/unified-client.d.ts +407 -0
- package/dist/src/unified-client.js +123 -0
- package/dist/src/user/account.d.ts +27 -0
- package/dist/src/user/account.js +34 -8
- package/dist/src/user/credit.d.ts +8 -14
- package/dist/src/user/credit.js +9 -23
- package/dist/src/user/custody.d.ts +4 -18
- package/dist/src/user/custody.js +14 -25
- package/dist/src/utils/consolidate-balance.d.ts +37 -0
- package/dist/src/utils/consolidate-balance.js +89 -0
- package/dist/src/utils/math.d.ts +86 -0
- package/dist/src/utils/math.js +100 -0
- package/dist/src/utils/pyth.d.ts +35 -3
- package/dist/src/utils/pyth.js +145 -14
- package/package.json +129 -34
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
2
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
3
|
+
import { AccountDataViewBcs, mapAccountDataView, mapCursorView, mapMarketExposure, mapMarketView, mapOrderView, mapPositionView, mapRegistryView, MarketViewBcs, OrderViewBcs, PositionViewBcs, RegistryViewBcs, } from "./bcs.js";
|
|
4
|
+
import { marketIdArg, resolveAccountPackageId, resolveAccountRegistry, resolveGlobalConfig, resolveMarketRegistry, resolvePackageId, resolveSettlementCoinType, toBigInt, } from "./utils.js";
|
|
5
|
+
export function extractReturnBytes(result, commandIndex = 0, returnIndex = 0) {
|
|
6
|
+
if (result.$kind === "FailedTransaction") {
|
|
7
|
+
const err = result.FailedTransaction.status.error;
|
|
8
|
+
throw new Error(`Simulate transaction failed: ${err?.message ?? JSON.stringify(err)}`);
|
|
9
|
+
}
|
|
10
|
+
const bcsBytes = result.commandResults?.[commandIndex]?.returnValues?.[returnIndex]?.bcs;
|
|
11
|
+
if (bcsBytes)
|
|
12
|
+
return new Uint8Array(bcsBytes);
|
|
13
|
+
const legacy = result.results?.[commandIndex]?.returnValues?.[returnIndex];
|
|
14
|
+
if (legacy)
|
|
15
|
+
return new Uint8Array(legacy[0]);
|
|
16
|
+
throw new Error(`No return value at command[${commandIndex}].returnValues[${returnIndex}]`);
|
|
17
|
+
}
|
|
18
|
+
export async function getRegistry(client, params = {}) {
|
|
19
|
+
const tx = new Transaction();
|
|
20
|
+
tx.moveCall({
|
|
21
|
+
target: `${resolvePackageId(client, params.packageId)}::view::registry`,
|
|
22
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
23
|
+
arguments: [tx.object(resolveMarketRegistry(client, params.marketRegistry))],
|
|
24
|
+
});
|
|
25
|
+
const result = await client.simulate(tx);
|
|
26
|
+
return mapRegistryView(RegistryViewBcs.parse(extractReturnBytes(result)));
|
|
27
|
+
}
|
|
28
|
+
export async function getOrder(client, params) {
|
|
29
|
+
const tx = new Transaction();
|
|
30
|
+
tx.moveCall({
|
|
31
|
+
target: `${resolvePackageId(client, params.packageId)}::view::order`,
|
|
32
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
33
|
+
arguments: [
|
|
34
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
35
|
+
tx.pure.u64(toBigInt(params.orderId)),
|
|
36
|
+
],
|
|
37
|
+
});
|
|
38
|
+
const result = await client.simulate(tx);
|
|
39
|
+
return mapOrderView(OrderViewBcs.parse(extractReturnBytes(result)));
|
|
40
|
+
}
|
|
41
|
+
export async function getPosition(client, params) {
|
|
42
|
+
const tx = new Transaction();
|
|
43
|
+
tx.moveCall({
|
|
44
|
+
target: `${resolvePackageId(client, params.packageId)}::view::position`,
|
|
45
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
46
|
+
arguments: [
|
|
47
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
48
|
+
tx.pure.u64(toBigInt(params.positionId)),
|
|
49
|
+
],
|
|
50
|
+
});
|
|
51
|
+
const result = await client.simulate(tx);
|
|
52
|
+
return mapPositionView(PositionViewBcs.parse(extractReturnBytes(result)));
|
|
53
|
+
}
|
|
54
|
+
export async function getMarketById(client, params) {
|
|
55
|
+
const tx = new Transaction();
|
|
56
|
+
tx.moveCall({
|
|
57
|
+
target: `${resolvePackageId(client, params.packageId)}::view::market_by_id`,
|
|
58
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
59
|
+
arguments: [
|
|
60
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
61
|
+
marketIdArg(tx, params.marketId),
|
|
62
|
+
],
|
|
63
|
+
});
|
|
64
|
+
const result = await client.simulate(tx);
|
|
65
|
+
return mapMarketView(MarketViewBcs.parse(extractReturnBytes(result)));
|
|
66
|
+
}
|
|
67
|
+
export async function getMarketByKey(client, params) {
|
|
68
|
+
const tx = new Transaction();
|
|
69
|
+
tx.moveCall({
|
|
70
|
+
target: `${resolvePackageId(client, params.packageId)}::view::market_by_key`,
|
|
71
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
72
|
+
arguments: [
|
|
73
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
74
|
+
tx.pure.u64(toBigInt(params.marketKey)),
|
|
75
|
+
],
|
|
76
|
+
});
|
|
77
|
+
const result = await client.simulate(tx);
|
|
78
|
+
return mapMarketView(MarketViewBcs.parse(extractReturnBytes(result)));
|
|
79
|
+
}
|
|
80
|
+
export async function getMarketExposure(client, params) {
|
|
81
|
+
const tx = new Transaction();
|
|
82
|
+
tx.moveCall({
|
|
83
|
+
target: `${resolvePackageId(client, params.packageId)}::waterx_prediction::market_exposure`,
|
|
84
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
85
|
+
arguments: [
|
|
86
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
87
|
+
marketIdArg(tx, params.marketId),
|
|
88
|
+
],
|
|
89
|
+
});
|
|
90
|
+
const result = await client.simulate(tx);
|
|
91
|
+
return mapMarketExposure(bcs.u64().parse(extractReturnBytes(result, 0, 0)), bcs.u64().parse(extractReturnBytes(result, 0, 1)), bcs.u64().parse(extractReturnBytes(result, 0, 2)), bcs.u64().parse(extractReturnBytes(result, 0, 3)));
|
|
92
|
+
}
|
|
93
|
+
export async function getMarketExposureByKey(client, params) {
|
|
94
|
+
const tx = new Transaction();
|
|
95
|
+
tx.moveCall({
|
|
96
|
+
target: `${resolvePackageId(client, params.packageId)}::waterx_prediction::market_exposure_by_key`,
|
|
97
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
98
|
+
arguments: [
|
|
99
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
100
|
+
tx.pure.u64(toBigInt(params.marketKey)),
|
|
101
|
+
],
|
|
102
|
+
});
|
|
103
|
+
const result = await client.simulate(tx);
|
|
104
|
+
return mapMarketExposure(bcs.u64().parse(extractReturnBytes(result, 0, 0)), bcs.u64().parse(extractReturnBytes(result, 0, 1)), bcs.u64().parse(extractReturnBytes(result, 0, 2)), bcs.u64().parse(extractReturnBytes(result, 0, 3)));
|
|
105
|
+
}
|
|
106
|
+
async function readCursor(client, functionName, params = {}) {
|
|
107
|
+
const tx = new Transaction();
|
|
108
|
+
tx.moveCall({
|
|
109
|
+
target: `${resolvePackageId(client, params.packageId)}::view::${functionName}`,
|
|
110
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
111
|
+
arguments: [tx.object(resolveMarketRegistry(client, params.marketRegistry))],
|
|
112
|
+
});
|
|
113
|
+
const result = await client.simulate(tx);
|
|
114
|
+
return mapCursorView(bcs.u64().parse(extractReturnBytes(result, 0, 0)), bcs.option(bcs.u64()).parse(extractReturnBytes(result, 0, 1)), bcs.option(bcs.u64()).parse(extractReturnBytes(result, 0, 2)));
|
|
115
|
+
}
|
|
116
|
+
export function getOrderCursor(client, params = {}) {
|
|
117
|
+
return readCursor(client, "order_cursor", params);
|
|
118
|
+
}
|
|
119
|
+
export function getPositionCursor(client, params = {}) {
|
|
120
|
+
return readCursor(client, "position_cursor", params);
|
|
121
|
+
}
|
|
122
|
+
export function getUnresolvedMarketCursor(client, params = {}) {
|
|
123
|
+
return readCursor(client, "unresolved_market_cursor", params);
|
|
124
|
+
}
|
|
125
|
+
export function getResolvedMarketCursor(client, params = {}) {
|
|
126
|
+
return readCursor(client, "resolved_market_cursor", params);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Registry account ids (`0x2::object::ID`) for an owner via `waterx_account::account::account_ids`.
|
|
130
|
+
* Use these ids with `getAccountData`, `deposit`, and `placeOrder` — not Suiscan "Account" object addresses.
|
|
131
|
+
*/
|
|
132
|
+
export async function getAccountIds(client, params) {
|
|
133
|
+
const pkg = resolveAccountPackageId(client, params.accountPackageId);
|
|
134
|
+
const tx = new Transaction();
|
|
135
|
+
tx.moveCall({
|
|
136
|
+
target: `${pkg}::account::account_ids`,
|
|
137
|
+
arguments: [
|
|
138
|
+
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
139
|
+
tx.pure.address(params.owner),
|
|
140
|
+
],
|
|
141
|
+
});
|
|
142
|
+
const result = await client.simulate(tx);
|
|
143
|
+
return bcs.vector(bcs.Address).parse(extractReturnBytes(result));
|
|
144
|
+
}
|
|
145
|
+
export async function getAccountData(client, params) {
|
|
146
|
+
const tx = new Transaction();
|
|
147
|
+
tx.moveCall({
|
|
148
|
+
target: `${resolvePackageId(client, params.packageId)}::view::account`,
|
|
149
|
+
arguments: [
|
|
150
|
+
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
151
|
+
tx.pure.id(params.accountId),
|
|
152
|
+
],
|
|
153
|
+
});
|
|
154
|
+
const result = await client.simulate(tx);
|
|
155
|
+
return mapAccountDataView(AccountDataViewBcs.parse(extractReturnBytes(result)));
|
|
156
|
+
}
|
|
157
|
+
export async function getAccountOrderIds(client, params) {
|
|
158
|
+
const tx = new Transaction();
|
|
159
|
+
tx.moveCall({
|
|
160
|
+
target: `${resolvePackageId(client, params.packageId)}::view::account_order_ids`,
|
|
161
|
+
arguments: [
|
|
162
|
+
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
163
|
+
tx.pure.id(params.accountId),
|
|
164
|
+
tx.pure.u64(toBigInt(params.marketKey)),
|
|
165
|
+
],
|
|
166
|
+
});
|
|
167
|
+
const result = await client.simulate(tx);
|
|
168
|
+
return bcs
|
|
169
|
+
.vector(bcs.u64())
|
|
170
|
+
.parse(extractReturnBytes(result))
|
|
171
|
+
.map((v) => BigInt(v));
|
|
172
|
+
}
|
|
173
|
+
export async function getAccountPositionIds(client, params) {
|
|
174
|
+
const tx = new Transaction();
|
|
175
|
+
tx.moveCall({
|
|
176
|
+
target: `${resolvePackageId(client, params.packageId)}::view::account_position_ids`,
|
|
177
|
+
arguments: [
|
|
178
|
+
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
179
|
+
tx.pure.id(params.accountId),
|
|
180
|
+
tx.pure.u64(toBigInt(params.marketKey)),
|
|
181
|
+
],
|
|
182
|
+
});
|
|
183
|
+
const result = await client.simulate(tx);
|
|
184
|
+
return bcs
|
|
185
|
+
.vector(bcs.u64())
|
|
186
|
+
.parse(extractReturnBytes(result))
|
|
187
|
+
.map((v) => BigInt(v));
|
|
188
|
+
}
|
|
189
|
+
export async function getAccountOrderIdsByMarketId(client, params) {
|
|
190
|
+
const tx = new Transaction();
|
|
191
|
+
tx.moveCall({
|
|
192
|
+
target: `${resolvePackageId(client, params.packageId)}::view::account_order_ids_by_market_id`,
|
|
193
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
194
|
+
arguments: [
|
|
195
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
196
|
+
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
197
|
+
tx.pure.id(params.accountId),
|
|
198
|
+
marketIdArg(tx, params.marketId),
|
|
199
|
+
],
|
|
200
|
+
});
|
|
201
|
+
const result = await client.simulate(tx);
|
|
202
|
+
return bcs
|
|
203
|
+
.vector(bcs.u64())
|
|
204
|
+
.parse(extractReturnBytes(result))
|
|
205
|
+
.map((v) => BigInt(v));
|
|
206
|
+
}
|
|
207
|
+
export async function getAccountPositionIdsByMarketId(client, params) {
|
|
208
|
+
const tx = new Transaction();
|
|
209
|
+
tx.moveCall({
|
|
210
|
+
target: `${resolvePackageId(client, params.packageId)}::view::account_position_ids_by_market_id`,
|
|
211
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
212
|
+
arguments: [
|
|
213
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
214
|
+
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
215
|
+
tx.pure.id(params.accountId),
|
|
216
|
+
marketIdArg(tx, params.marketId),
|
|
217
|
+
],
|
|
218
|
+
});
|
|
219
|
+
const result = await client.simulate(tx);
|
|
220
|
+
return bcs
|
|
221
|
+
.vector(bcs.u64())
|
|
222
|
+
.parse(extractReturnBytes(result))
|
|
223
|
+
.map((v) => BigInt(v));
|
|
224
|
+
}
|
|
225
|
+
export async function isKeeper(client, params) {
|
|
226
|
+
const tx = new Transaction();
|
|
227
|
+
tx.moveCall({
|
|
228
|
+
target: `${resolvePackageId(client, params.packageId)}::global_config::is_keeper`,
|
|
229
|
+
arguments: [
|
|
230
|
+
tx.object(resolveGlobalConfig(client, params.globalConfig)),
|
|
231
|
+
tx.pure.address(params.keeper),
|
|
232
|
+
],
|
|
233
|
+
});
|
|
234
|
+
const result = await client.simulate(tx);
|
|
235
|
+
return bcs.bool().parse(extractReturnBytes(result));
|
|
236
|
+
}
|
|
237
|
+
export async function getKeeperAddresses(client, params = {}) {
|
|
238
|
+
const tx = new Transaction();
|
|
239
|
+
tx.moveCall({
|
|
240
|
+
target: `${resolvePackageId(client, params.packageId)}::global_config::keeper_addresses`,
|
|
241
|
+
arguments: [tx.object(resolveGlobalConfig(client, params.globalConfig))],
|
|
242
|
+
});
|
|
243
|
+
const result = await client.simulate(tx);
|
|
244
|
+
return bcs.vector(bcs.Address).parse(extractReturnBytes(result));
|
|
245
|
+
}
|
|
246
|
+
export async function getAllowedVersions(client, params = {}) {
|
|
247
|
+
const tx = new Transaction();
|
|
248
|
+
tx.moveCall({
|
|
249
|
+
target: `${resolvePackageId(client, params.packageId)}::global_config::allowed_versions`,
|
|
250
|
+
arguments: [tx.object(resolveGlobalConfig(client, params.globalConfig))],
|
|
251
|
+
});
|
|
252
|
+
const result = await client.simulate(tx);
|
|
253
|
+
return bcs
|
|
254
|
+
.vector(bcs.u16())
|
|
255
|
+
.parse(extractReturnBytes(result))
|
|
256
|
+
.map((v) => Number(v));
|
|
257
|
+
}
|
|
258
|
+
export async function isPredictionProtocolAssetAllowed(client, params = {}) {
|
|
259
|
+
const tx = new Transaction();
|
|
260
|
+
tx.moveCall({
|
|
261
|
+
target: `${resolveAccountPackageId(client, params.accountPackageId)}::account::is_protocol_asset_allowed`,
|
|
262
|
+
typeArguments: [
|
|
263
|
+
`${resolvePackageId(client, params.predictionPackageId)}::account_data::WaterXPrediction`,
|
|
264
|
+
params.coinType ?? client.settlementCoinType(),
|
|
265
|
+
],
|
|
266
|
+
arguments: [tx.object(resolveAccountRegistry(client, params.accountRegistry))],
|
|
267
|
+
});
|
|
268
|
+
const result = await client.simulate(tx);
|
|
269
|
+
return bcs.bool().parse(extractReturnBytes(result));
|
|
270
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
/** Module for Account Abstraction */
|
|
5
|
+
import { MoveStruct, type RawTransactionArgument } from '../utils/index.ts';
|
|
6
|
+
import { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';
|
|
7
|
+
export declare const ACCOUNT: MoveStruct<any, any>;
|
|
8
|
+
export declare const Account: MoveStruct<any, any>;
|
|
9
|
+
export declare const AccountRequest: MoveStruct<any, any>;
|
|
10
|
+
export interface NewArguments {
|
|
11
|
+
alias: RawTransactionArgument<string | null>;
|
|
12
|
+
}
|
|
13
|
+
export interface NewOptions {
|
|
14
|
+
package?: string;
|
|
15
|
+
arguments: NewArguments | [
|
|
16
|
+
alias: RawTransactionArgument<string | null>
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
/** Public Funs */
|
|
20
|
+
export declare function _new(options: NewOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
21
|
+
export interface RequestOptions {
|
|
22
|
+
package?: string;
|
|
23
|
+
arguments?: [
|
|
24
|
+
];
|
|
25
|
+
}
|
|
26
|
+
export declare function request(options?: RequestOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
27
|
+
export interface RequestWithAccountArguments {
|
|
28
|
+
account: RawTransactionArgument<string>;
|
|
29
|
+
}
|
|
30
|
+
export interface RequestWithAccountOptions {
|
|
31
|
+
package?: string;
|
|
32
|
+
arguments: RequestWithAccountArguments | [
|
|
33
|
+
account: RawTransactionArgument<string>
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
export declare function requestWithAccount(options: RequestWithAccountOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
37
|
+
export interface ReceiveArguments {
|
|
38
|
+
account: RawTransactionArgument<string>;
|
|
39
|
+
receiving: TransactionArgument;
|
|
40
|
+
}
|
|
41
|
+
export interface ReceiveOptions {
|
|
42
|
+
package?: string;
|
|
43
|
+
arguments: ReceiveArguments | [
|
|
44
|
+
account: RawTransactionArgument<string>,
|
|
45
|
+
receiving: TransactionArgument
|
|
46
|
+
];
|
|
47
|
+
typeArguments: [
|
|
48
|
+
string
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
export declare function receive(options: ReceiveOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
52
|
+
export interface UpdateAliasArguments {
|
|
53
|
+
account: RawTransactionArgument<string>;
|
|
54
|
+
alias: RawTransactionArgument<string>;
|
|
55
|
+
}
|
|
56
|
+
export interface UpdateAliasOptions {
|
|
57
|
+
package?: string;
|
|
58
|
+
arguments: UpdateAliasArguments | [
|
|
59
|
+
account: RawTransactionArgument<string>,
|
|
60
|
+
alias: RawTransactionArgument<string>
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
export declare function updateAlias(options: UpdateAliasOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
64
|
+
export interface CreateArguments {
|
|
65
|
+
alias: RawTransactionArgument<string | null>;
|
|
66
|
+
}
|
|
67
|
+
export interface CreateOptions {
|
|
68
|
+
package?: string;
|
|
69
|
+
arguments: CreateArguments | [
|
|
70
|
+
alias: RawTransactionArgument<string | null>
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
/** Entry Funs */
|
|
74
|
+
export declare function create(options: CreateOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
75
|
+
export interface AccountAddressArguments {
|
|
76
|
+
account: RawTransactionArgument<string>;
|
|
77
|
+
}
|
|
78
|
+
export interface AccountAddressOptions {
|
|
79
|
+
package?: string;
|
|
80
|
+
arguments: AccountAddressArguments | [
|
|
81
|
+
account: RawTransactionArgument<string>
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
export declare function accountAddress(options: AccountAddressOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
85
|
+
export interface RequestAddressArguments {
|
|
86
|
+
req: TransactionArgument;
|
|
87
|
+
}
|
|
88
|
+
export interface RequestAddressOptions {
|
|
89
|
+
package?: string;
|
|
90
|
+
arguments: RequestAddressArguments | [
|
|
91
|
+
req: TransactionArgument
|
|
92
|
+
];
|
|
93
|
+
}
|
|
94
|
+
export declare function requestAddress(options: RequestAddressOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
95
|
+
export interface AliasLengthLimitOptions {
|
|
96
|
+
package?: string;
|
|
97
|
+
arguments?: [
|
|
98
|
+
];
|
|
99
|
+
}
|
|
100
|
+
export declare function aliasLengthLimit(options?: AliasLengthLimitOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
/** Module for Account Abstraction */
|
|
5
|
+
import { MoveStruct, normalizeMoveArguments } from "../utils/index.js";
|
|
6
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
7
|
+
const $moduleName = '@bucket/framework::account';
|
|
8
|
+
export const ACCOUNT = new MoveStruct({ name: `${$moduleName}::ACCOUNT`, fields: {
|
|
9
|
+
dummy_field: bcs.bool()
|
|
10
|
+
} });
|
|
11
|
+
export const Account = new MoveStruct({ name: `${$moduleName}::Account`, fields: {
|
|
12
|
+
id: bcs.Address,
|
|
13
|
+
alias: bcs.option(bcs.string())
|
|
14
|
+
} });
|
|
15
|
+
export const AccountRequest = new MoveStruct({ name: `${$moduleName}::AccountRequest`, fields: {
|
|
16
|
+
account: bcs.Address
|
|
17
|
+
} });
|
|
18
|
+
/** Public Funs */
|
|
19
|
+
export function _new(options) {
|
|
20
|
+
const packageAddress = options.package ?? '@bucket/framework';
|
|
21
|
+
const argumentsTypes = [
|
|
22
|
+
'0x1::option::Option<0x1::string::String>'
|
|
23
|
+
];
|
|
24
|
+
const parameterNames = ["alias"];
|
|
25
|
+
return (tx) => tx.moveCall({
|
|
26
|
+
package: packageAddress,
|
|
27
|
+
module: 'account',
|
|
28
|
+
function: 'new',
|
|
29
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
export function request(options = {}) {
|
|
33
|
+
const packageAddress = options.package ?? '@bucket/framework';
|
|
34
|
+
return (tx) => tx.moveCall({
|
|
35
|
+
package: packageAddress,
|
|
36
|
+
module: 'account',
|
|
37
|
+
function: 'request',
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export function requestWithAccount(options) {
|
|
41
|
+
const packageAddress = options.package ?? '@bucket/framework';
|
|
42
|
+
const argumentsTypes = [
|
|
43
|
+
null
|
|
44
|
+
];
|
|
45
|
+
const parameterNames = ["account"];
|
|
46
|
+
return (tx) => tx.moveCall({
|
|
47
|
+
package: packageAddress,
|
|
48
|
+
module: 'account',
|
|
49
|
+
function: 'request_with_account',
|
|
50
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
export function receive(options) {
|
|
54
|
+
const packageAddress = options.package ?? '@bucket/framework';
|
|
55
|
+
const argumentsTypes = [
|
|
56
|
+
null,
|
|
57
|
+
null
|
|
58
|
+
];
|
|
59
|
+
const parameterNames = ["account", "receiving"];
|
|
60
|
+
return (tx) => tx.moveCall({
|
|
61
|
+
package: packageAddress,
|
|
62
|
+
module: 'account',
|
|
63
|
+
function: 'receive',
|
|
64
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
65
|
+
typeArguments: options.typeArguments
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
export function updateAlias(options) {
|
|
69
|
+
const packageAddress = options.package ?? '@bucket/framework';
|
|
70
|
+
const argumentsTypes = [
|
|
71
|
+
null,
|
|
72
|
+
'0x1::string::String'
|
|
73
|
+
];
|
|
74
|
+
const parameterNames = ["account", "alias"];
|
|
75
|
+
return (tx) => tx.moveCall({
|
|
76
|
+
package: packageAddress,
|
|
77
|
+
module: 'account',
|
|
78
|
+
function: 'update_alias',
|
|
79
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/** Entry Funs */
|
|
83
|
+
export function create(options) {
|
|
84
|
+
const packageAddress = options.package ?? '@bucket/framework';
|
|
85
|
+
const argumentsTypes = [
|
|
86
|
+
'0x1::option::Option<0x1::string::String>'
|
|
87
|
+
];
|
|
88
|
+
const parameterNames = ["alias"];
|
|
89
|
+
return (tx) => tx.moveCall({
|
|
90
|
+
package: packageAddress,
|
|
91
|
+
module: 'account',
|
|
92
|
+
function: 'create',
|
|
93
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
export function accountAddress(options) {
|
|
97
|
+
const packageAddress = options.package ?? '@bucket/framework';
|
|
98
|
+
const argumentsTypes = [
|
|
99
|
+
null
|
|
100
|
+
];
|
|
101
|
+
const parameterNames = ["account"];
|
|
102
|
+
return (tx) => tx.moveCall({
|
|
103
|
+
package: packageAddress,
|
|
104
|
+
module: 'account',
|
|
105
|
+
function: 'account_address',
|
|
106
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
export function requestAddress(options) {
|
|
110
|
+
const packageAddress = options.package ?? '@bucket/framework';
|
|
111
|
+
const argumentsTypes = [
|
|
112
|
+
null
|
|
113
|
+
];
|
|
114
|
+
const parameterNames = ["req"];
|
|
115
|
+
return (tx) => tx.moveCall({
|
|
116
|
+
package: packageAddress,
|
|
117
|
+
module: 'account',
|
|
118
|
+
function: 'request_address',
|
|
119
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
export function aliasLengthLimit(options = {}) {
|
|
123
|
+
const packageAddress = options.package ?? '@bucket/framework';
|
|
124
|
+
return (tx) => tx.moveCall({
|
|
125
|
+
package: packageAddress,
|
|
126
|
+
module: 'account',
|
|
127
|
+
function: 'alias_length_limit',
|
|
128
|
+
});
|
|
129
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
/** Functionality for converting Move types into values. Use with care! */
|
|
5
|
+
import { MoveStruct } from '../../../utils/index.ts';
|
|
6
|
+
export declare const TypeName: MoveStruct<any, any>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
/** Functionality for converting Move types into values. Use with care! */
|
|
5
|
+
import { MoveStruct } from "../../../utils/index.js";
|
|
6
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
7
|
+
const $moduleName = 'std::type_name';
|
|
8
|
+
export const TypeName = new MoveStruct({ name: `${$moduleName}::TypeName`, fields: {
|
|
9
|
+
/**
|
|
10
|
+
* String representation of the type. All types are represented using their source
|
|
11
|
+
* syntax: "u8", "u64", "bool", "address", "vector", and so on for primitive types.
|
|
12
|
+
* Struct types are represented as fully qualified type names; e.g.
|
|
13
|
+
* `00000000000000000000000000000001::string::String` or
|
|
14
|
+
* `0000000000000000000000000000000a::module_name1::type_name1<0000000000000000000000000000000a::module_name2::type_name2<u64>>`
|
|
15
|
+
* Addresses are hex-encoded lowercase values of length ADDRESS_LENGTH (16, 20, or
|
|
16
|
+
* 32 depending on the Move platform)
|
|
17
|
+
*/
|
|
18
|
+
name: bcs.string()
|
|
19
|
+
} });
|
|
@@ -0,0 +1,10 @@
|
|
|
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<any, any>;
|
|
@@ -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,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
|
+
}
|