@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,419 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read-only queries built on top of `waterx_perp_view`.
|
|
3
|
+
*
|
|
4
|
+
* Each helper builds a one-shot PTB, runs `client.simulate(tx)`, and
|
|
5
|
+
* decodes the first command's return values into the matching generated
|
|
6
|
+
* BCS struct. The simulated sender is the zero address.
|
|
7
|
+
*/
|
|
8
|
+
import { fromBase64 } from "@mysten/bcs";
|
|
9
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
10
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
11
|
+
import { DRY_RUN_SENDER } from "./constants.js";
|
|
12
|
+
import { burnFeeRate as burnFeeRateCall, creditSupply as creditSupplyCall, hasAsset as hasAssetCall, mintFeeRate as mintFeeRateCall, } from "./generated/native_custody/custody_vault.js";
|
|
13
|
+
import { accountBalance as accountBalanceCall, accountIds as accountIdsCall, } from "./generated/waterx_account/account.js";
|
|
14
|
+
import { AccountData, accountData as accountDataCall, getAccountOrders as getAccountOrdersCall, getAccountPositions as getAccountPositionsCall, getMarketOrders as getMarketOrdersCall, getMarketPositions as getMarketPositionsCall, getRedeemRequests as getRedeemRequestsCall, GlobalConfigData, globalConfigData as globalConfigDataCall, MarketData, marketData as marketDataCall, OrderData, orderData as orderDataCall, PoolData, poolData as poolDataCall, PositionData, positionData as positionDataCall, positionExists as positionExistsCall, RedeemRequestData, TokenPoolData, tokenPoolData as tokenPoolDataCall, } from "./generated/waterx_perp_view/view.js";
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// Referral queries (waterx_referral::referral_table)
|
|
17
|
+
// ============================================================================
|
|
18
|
+
import { isValidReferralCode as isValidReferralCodeCall, referralCodeExists as referralCodeExistsCall, tryGetRefer as tryGetReferCall, } from "./generated/waterx_referral/referral_table.js";
|
|
19
|
+
function toBytes(b) {
|
|
20
|
+
if (!b)
|
|
21
|
+
return undefined;
|
|
22
|
+
if (typeof b === "string")
|
|
23
|
+
return fromBase64(b);
|
|
24
|
+
// gRPC returns Uint8Array; JSON-RPC serialization may turn it into a
|
|
25
|
+
// numeric-indexed object. Normalize both.
|
|
26
|
+
if (b instanceof Uint8Array)
|
|
27
|
+
return b;
|
|
28
|
+
return new Uint8Array(Object.values(b));
|
|
29
|
+
}
|
|
30
|
+
async function simulateAndExtract(client, tx, commandIndex = 0, returnIndex = 0) {
|
|
31
|
+
tx.setSender(DRY_RUN_SENDER);
|
|
32
|
+
const sim = (await client.simulate(tx));
|
|
33
|
+
if (sim.$kind === "FailedTransaction") {
|
|
34
|
+
const err = sim.FailedTransaction?.status?.error?.message ?? "FailedTransaction";
|
|
35
|
+
throw new Error(`simulate aborted: ${err}`);
|
|
36
|
+
}
|
|
37
|
+
const cmd = sim.commandResults?.[commandIndex];
|
|
38
|
+
const ret = cmd?.returnValues?.[returnIndex];
|
|
39
|
+
const bytes = toBytes(ret?.bcs) ?? toBytes(ret?.value?.bcs);
|
|
40
|
+
if (!bytes) {
|
|
41
|
+
throw new Error(`simulate returned no BCS value at commandResults[${commandIndex}].returnValues[${returnIndex}]`);
|
|
42
|
+
}
|
|
43
|
+
return bytes;
|
|
44
|
+
}
|
|
45
|
+
function withLp(client, lpType) {
|
|
46
|
+
return lpType ?? client.wlpType();
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Look up the registered AccountData for a given wxa account ID.
|
|
50
|
+
* Returns `undefined` if the account has no perp data slot installed yet
|
|
51
|
+
* (the slot auto-installs on the first `add_position` / `add_order`).
|
|
52
|
+
* The underlying view fn returns `Option<AccountData>`.
|
|
53
|
+
*/
|
|
54
|
+
export async function getAccountData(client, accountId) {
|
|
55
|
+
const tx = new Transaction();
|
|
56
|
+
accountDataCall({
|
|
57
|
+
package: client.config.packages.waterx_perp_view.published_at,
|
|
58
|
+
arguments: {
|
|
59
|
+
wxaRegistry: tx.object(client.config.packages.waterx_account.account_registry),
|
|
60
|
+
accountId,
|
|
61
|
+
},
|
|
62
|
+
})(tx);
|
|
63
|
+
const bytes = await simulateAndExtract(client, tx);
|
|
64
|
+
const opt = bcs.option(AccountData).parse(bytes);
|
|
65
|
+
return opt ?? undefined;
|
|
66
|
+
}
|
|
67
|
+
export async function getMarketData(client, args) {
|
|
68
|
+
const tx = new Transaction();
|
|
69
|
+
marketDataCall({
|
|
70
|
+
package: client.config.packages.waterx_perp_view.published_at,
|
|
71
|
+
arguments: {
|
|
72
|
+
marketRegistry: tx.object(client.config.packages.waterx_perp.market_registry_wlp),
|
|
73
|
+
ticker: args.ticker,
|
|
74
|
+
},
|
|
75
|
+
typeArguments: [withLp(client, args.lpType)],
|
|
76
|
+
})(tx);
|
|
77
|
+
return MarketData.parse(await simulateAndExtract(client, tx));
|
|
78
|
+
}
|
|
79
|
+
export async function getPoolData(client, args = {}) {
|
|
80
|
+
const tx = new Transaction();
|
|
81
|
+
poolDataCall({
|
|
82
|
+
package: client.config.packages.waterx_perp_view.published_at,
|
|
83
|
+
arguments: { pool: tx.object(client.config.packages.wlp.wlp_pool) },
|
|
84
|
+
typeArguments: [withLp(client, args.lpType)],
|
|
85
|
+
})(tx);
|
|
86
|
+
return PoolData.parse(await simulateAndExtract(client, tx));
|
|
87
|
+
}
|
|
88
|
+
export async function getTokenPoolData(client, args) {
|
|
89
|
+
const tx = new Transaction();
|
|
90
|
+
tokenPoolDataCall({
|
|
91
|
+
package: client.config.packages.waterx_perp_view.published_at,
|
|
92
|
+
arguments: {
|
|
93
|
+
pool: tx.object(client.config.packages.wlp.wlp_pool),
|
|
94
|
+
tokenIndex: args.tokenIndex,
|
|
95
|
+
},
|
|
96
|
+
typeArguments: [withLp(client, args.lpType)],
|
|
97
|
+
})(tx);
|
|
98
|
+
return TokenPoolData.parse(await simulateAndExtract(client, tx));
|
|
99
|
+
}
|
|
100
|
+
export async function getGlobalConfigData(client) {
|
|
101
|
+
const tx = new Transaction();
|
|
102
|
+
globalConfigDataCall({
|
|
103
|
+
package: client.config.packages.waterx_perp_view.published_at,
|
|
104
|
+
arguments: { cfg: tx.object(client.config.packages.waterx_perp.global_config) },
|
|
105
|
+
})(tx);
|
|
106
|
+
return GlobalConfigData.parse(await simulateAndExtract(client, tx));
|
|
107
|
+
}
|
|
108
|
+
export async function positionExists(client, args) {
|
|
109
|
+
const tx = new Transaction();
|
|
110
|
+
positionExistsCall({
|
|
111
|
+
package: client.config.packages.waterx_perp_view.published_at,
|
|
112
|
+
arguments: {
|
|
113
|
+
marketRegistry: tx.object(client.config.packages.waterx_perp.market_registry_wlp),
|
|
114
|
+
ticker: args.ticker,
|
|
115
|
+
positionId: args.positionId,
|
|
116
|
+
},
|
|
117
|
+
typeArguments: [withLp(client, args.lpType)],
|
|
118
|
+
})(tx);
|
|
119
|
+
const bytes = await simulateAndExtract(client, tx);
|
|
120
|
+
return bcs.bool().parse(bytes);
|
|
121
|
+
}
|
|
122
|
+
export async function getPosition(client, args) {
|
|
123
|
+
const tx = new Transaction();
|
|
124
|
+
positionDataCall({
|
|
125
|
+
package: client.config.packages.waterx_perp_view.published_at,
|
|
126
|
+
arguments: {
|
|
127
|
+
marketRegistry: tx.object(client.config.packages.waterx_perp.market_registry_wlp),
|
|
128
|
+
ticker: args.ticker,
|
|
129
|
+
pool: tx.object(client.config.packages.wlp.wlp_pool),
|
|
130
|
+
basePriceUsd: args.basePriceUsd,
|
|
131
|
+
collateralPriceUsd: args.collateralPriceUsd,
|
|
132
|
+
positionId: args.positionId,
|
|
133
|
+
},
|
|
134
|
+
typeArguments: [withLp(client, args.lpType)],
|
|
135
|
+
})(tx);
|
|
136
|
+
return PositionData.parse(await simulateAndExtract(client, tx));
|
|
137
|
+
}
|
|
138
|
+
export async function getOrder(client, args) {
|
|
139
|
+
const tx = new Transaction();
|
|
140
|
+
orderDataCall({
|
|
141
|
+
package: client.config.packages.waterx_perp_view.published_at,
|
|
142
|
+
arguments: {
|
|
143
|
+
marketRegistry: tx.object(client.config.packages.waterx_perp.market_registry_wlp),
|
|
144
|
+
ticker: args.ticker,
|
|
145
|
+
basePriceUsd: args.basePriceUsd,
|
|
146
|
+
orderTypeTag: args.orderTypeTag,
|
|
147
|
+
triggerPrice: args.triggerPrice,
|
|
148
|
+
orderId: args.orderId,
|
|
149
|
+
},
|
|
150
|
+
typeArguments: [withLp(client, args.lpType)],
|
|
151
|
+
})(tx);
|
|
152
|
+
return OrderData.parse(await simulateAndExtract(client, tx));
|
|
153
|
+
}
|
|
154
|
+
export async function getMarketOrders(client, args) {
|
|
155
|
+
const tx = new Transaction();
|
|
156
|
+
getMarketOrdersCall({
|
|
157
|
+
package: client.config.packages.waterx_perp_view.published_at,
|
|
158
|
+
arguments: {
|
|
159
|
+
marketRegistry: tx.object(client.config.packages.waterx_perp.market_registry_wlp),
|
|
160
|
+
ticker: args.ticker,
|
|
161
|
+
basePriceUsd: args.basePriceUsd ?? 0n,
|
|
162
|
+
cursor: args.cursor ?? 0n,
|
|
163
|
+
pageSize: args.pageSize ?? 100n,
|
|
164
|
+
},
|
|
165
|
+
typeArguments: [withLp(client, args.lpType)],
|
|
166
|
+
})(tx);
|
|
167
|
+
tx.setSender(DRY_RUN_SENDER);
|
|
168
|
+
const sim = (await client.simulate(tx));
|
|
169
|
+
const ret = sim.commandResults?.[0]?.returnValues;
|
|
170
|
+
if (!ret)
|
|
171
|
+
return { orders: [] };
|
|
172
|
+
const ordersBytes = toBytes(ret[0]?.bcs) ?? toBytes(ret[0]?.value?.bcs);
|
|
173
|
+
const cursorBytes = toBytes(ret[1]?.bcs) ?? toBytes(ret[1]?.value?.bcs);
|
|
174
|
+
if (!ordersBytes)
|
|
175
|
+
return { orders: [] };
|
|
176
|
+
const ordersBuf = ordersBytes;
|
|
177
|
+
const orders = bcs.vector(OrderData).parse(ordersBuf);
|
|
178
|
+
let nextCursor;
|
|
179
|
+
if (cursorBytes) {
|
|
180
|
+
const cb = cursorBytes;
|
|
181
|
+
const opt = bcs.option(bcs.u64()).parse(cb);
|
|
182
|
+
if (opt)
|
|
183
|
+
nextCursor = BigInt(opt);
|
|
184
|
+
}
|
|
185
|
+
return { orders, nextCursor };
|
|
186
|
+
}
|
|
187
|
+
export async function getMarketPositions(client, args) {
|
|
188
|
+
const tx = new Transaction();
|
|
189
|
+
getMarketPositionsCall({
|
|
190
|
+
package: client.config.packages.waterx_perp_view.published_at,
|
|
191
|
+
arguments: {
|
|
192
|
+
marketRegistry: tx.object(client.config.packages.waterx_perp.market_registry_wlp),
|
|
193
|
+
ticker: args.ticker,
|
|
194
|
+
pool: tx.object(client.config.packages.wlp.wlp_pool),
|
|
195
|
+
basePriceUsd: args.basePriceUsd,
|
|
196
|
+
collateralPriceUsd: args.collateralPriceUsd ?? 0n,
|
|
197
|
+
cursor: args.cursor ?? 0n,
|
|
198
|
+
pageSize: args.pageSize ?? 100n,
|
|
199
|
+
},
|
|
200
|
+
typeArguments: [withLp(client, args.lpType)],
|
|
201
|
+
})(tx);
|
|
202
|
+
tx.setSender(DRY_RUN_SENDER);
|
|
203
|
+
const sim = (await client.simulate(tx));
|
|
204
|
+
const ret = sim.commandResults?.[0]?.returnValues;
|
|
205
|
+
if (!ret)
|
|
206
|
+
return { positions: [] };
|
|
207
|
+
const positionsBytes = toBytes(ret[0]?.bcs) ?? toBytes(ret[0]?.value?.bcs);
|
|
208
|
+
const cursorBytes = toBytes(ret[1]?.bcs) ?? toBytes(ret[1]?.value?.bcs);
|
|
209
|
+
if (!positionsBytes)
|
|
210
|
+
return { positions: [] };
|
|
211
|
+
const buf = positionsBytes;
|
|
212
|
+
const positions = bcs.vector(PositionData).parse(buf);
|
|
213
|
+
let nextCursor;
|
|
214
|
+
if (cursorBytes) {
|
|
215
|
+
const cb = cursorBytes;
|
|
216
|
+
const opt = bcs.option(bcs.u64()).parse(cb);
|
|
217
|
+
if (opt)
|
|
218
|
+
nextCursor = BigInt(opt);
|
|
219
|
+
}
|
|
220
|
+
return { positions, nextCursor };
|
|
221
|
+
}
|
|
222
|
+
export async function getAccountPositions(client, args) {
|
|
223
|
+
const tx = new Transaction();
|
|
224
|
+
getAccountPositionsCall({
|
|
225
|
+
package: client.config.packages.waterx_perp_view.published_at,
|
|
226
|
+
arguments: {
|
|
227
|
+
marketRegistry: tx.object(client.config.packages.waterx_perp.market_registry_wlp),
|
|
228
|
+
ticker: args.ticker,
|
|
229
|
+
pool: tx.object(client.config.packages.wlp.wlp_pool),
|
|
230
|
+
wxaRegistry: tx.object(client.config.packages.waterx_account.account_registry),
|
|
231
|
+
basePriceUsd: args.basePriceUsd,
|
|
232
|
+
collateralPriceUsd: args.collateralPriceUsd ?? 0n,
|
|
233
|
+
accountObjectAddress: args.accountObjectAddress,
|
|
234
|
+
},
|
|
235
|
+
typeArguments: [withLp(client, args.lpType)],
|
|
236
|
+
})(tx);
|
|
237
|
+
return bcs.vector(PositionData).parse(await simulateAndExtract(client, tx));
|
|
238
|
+
}
|
|
239
|
+
export async function getAccountOrders(client, args) {
|
|
240
|
+
const tx = new Transaction();
|
|
241
|
+
getAccountOrdersCall({
|
|
242
|
+
package: client.config.packages.waterx_perp_view.published_at,
|
|
243
|
+
arguments: {
|
|
244
|
+
marketRegistry: tx.object(client.config.packages.waterx_perp.market_registry_wlp),
|
|
245
|
+
ticker: args.ticker,
|
|
246
|
+
basePriceUsd: args.basePriceUsd ?? 0n,
|
|
247
|
+
accountObjectAddress: args.accountObjectAddress,
|
|
248
|
+
},
|
|
249
|
+
typeArguments: [withLp(client, args.lpType)],
|
|
250
|
+
})(tx);
|
|
251
|
+
return bcs.vector(OrderData).parse(await simulateAndExtract(client, tx));
|
|
252
|
+
}
|
|
253
|
+
export async function getRedeemRequests(client, args = {}) {
|
|
254
|
+
const tx = new Transaction();
|
|
255
|
+
getRedeemRequestsCall({
|
|
256
|
+
package: client.config.packages.waterx_perp_view.published_at,
|
|
257
|
+
arguments: {
|
|
258
|
+
pool: tx.object(client.config.packages.wlp.wlp_pool),
|
|
259
|
+
cursor: args.cursor ?? 0n,
|
|
260
|
+
pageSize: args.pageSize ?? 100n,
|
|
261
|
+
},
|
|
262
|
+
typeArguments: [withLp(client, args.lpType)],
|
|
263
|
+
})(tx);
|
|
264
|
+
tx.setSender(DRY_RUN_SENDER);
|
|
265
|
+
const sim = (await client.simulate(tx));
|
|
266
|
+
const ret = sim.commandResults?.[0]?.returnValues;
|
|
267
|
+
if (!ret)
|
|
268
|
+
return { requests: [] };
|
|
269
|
+
const reqBytes = toBytes(ret[0]?.bcs) ?? toBytes(ret[0]?.value?.bcs);
|
|
270
|
+
const cursorBytes = toBytes(ret[1]?.bcs) ?? toBytes(ret[1]?.value?.bcs);
|
|
271
|
+
if (!reqBytes)
|
|
272
|
+
return { requests: [] };
|
|
273
|
+
const buf = reqBytes;
|
|
274
|
+
const requests = bcs.vector(RedeemRequestData).parse(buf);
|
|
275
|
+
let nextCursor;
|
|
276
|
+
if (cursorBytes) {
|
|
277
|
+
const cb = cursorBytes;
|
|
278
|
+
const opt = bcs.option(bcs.u64()).parse(cb);
|
|
279
|
+
if (opt)
|
|
280
|
+
nextCursor = BigInt(opt);
|
|
281
|
+
}
|
|
282
|
+
return { requests, nextCursor };
|
|
283
|
+
}
|
|
284
|
+
function requireReferralPackage(client) {
|
|
285
|
+
const pkg = client.config.packages.waterx_referral?.published_at;
|
|
286
|
+
const table = client.config.packages.waterx_referral?.referral_table;
|
|
287
|
+
if (!pkg || !table) {
|
|
288
|
+
throw new Error("referral package not configured: set config.packages.waterx_referral.{published_at,referral_table}");
|
|
289
|
+
}
|
|
290
|
+
return { pkg, table };
|
|
291
|
+
}
|
|
292
|
+
/** Returns the referrer address bound to `referee`, or `undefined` if none. */
|
|
293
|
+
export async function getRefererFor(client, referee) {
|
|
294
|
+
const { pkg, table } = requireReferralPackage(client);
|
|
295
|
+
const tx = new Transaction();
|
|
296
|
+
tryGetReferCall({
|
|
297
|
+
package: pkg,
|
|
298
|
+
arguments: { table: tx.object(table), referee },
|
|
299
|
+
})(tx);
|
|
300
|
+
const bytes = await simulateAndExtract(client, tx);
|
|
301
|
+
const opt = bcs.option(bcs.Address).parse(bytes);
|
|
302
|
+
return opt ?? undefined;
|
|
303
|
+
}
|
|
304
|
+
/** True if `code` is a syntactically valid referral code (matches the contract's char rules). */
|
|
305
|
+
export async function isValidReferralCode(client, code) {
|
|
306
|
+
const { pkg } = requireReferralPackage(client);
|
|
307
|
+
const tx = new Transaction();
|
|
308
|
+
isValidReferralCodeCall({ package: pkg, arguments: { code } })(tx);
|
|
309
|
+
const bytes = await simulateAndExtract(client, tx);
|
|
310
|
+
return bcs.bool().parse(bytes);
|
|
311
|
+
}
|
|
312
|
+
/** True if `code` is already claimed in the on-chain ReferralTable. */
|
|
313
|
+
export async function referralCodeExists(client, code) {
|
|
314
|
+
const { pkg, table } = requireReferralPackage(client);
|
|
315
|
+
const tx = new Transaction();
|
|
316
|
+
referralCodeExistsCall({
|
|
317
|
+
package: pkg,
|
|
318
|
+
arguments: { table: tx.object(table), code },
|
|
319
|
+
})(tx);
|
|
320
|
+
const bytes = await simulateAndExtract(client, tx);
|
|
321
|
+
return bcs.bool().parse(bytes);
|
|
322
|
+
}
|
|
323
|
+
// ============================================================================
|
|
324
|
+
// wxa account reads (waterx_account — works on credit-only deployments,
|
|
325
|
+
// which have no waterx_perp_view). Simulate `account::*` view functions.
|
|
326
|
+
// ============================================================================
|
|
327
|
+
/**
|
|
328
|
+
* List the wxa account IDs owned by `owner` (`account::account_ids`).
|
|
329
|
+
* Returns `[]` when the owner has never created an account. Use this to
|
|
330
|
+
* resolve the `account_id` a cross-chain deposit must target before
|
|
331
|
+
* filling the EVM `suiRecipient` field.
|
|
332
|
+
*/
|
|
333
|
+
export async function getAccountsByOwner(client, owner) {
|
|
334
|
+
const tx = new Transaction();
|
|
335
|
+
accountIdsCall({
|
|
336
|
+
package: client.config.packages.waterx_account.published_at,
|
|
337
|
+
arguments: {
|
|
338
|
+
registry: tx.object(client.config.packages.waterx_account.account_registry),
|
|
339
|
+
owner,
|
|
340
|
+
},
|
|
341
|
+
})(tx);
|
|
342
|
+
const bytes = await simulateAndExtract(client, tx);
|
|
343
|
+
return bcs.vector(bcs.Address).parse(bytes);
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* A wxa account's stored `Balance<T>` (`account::account_balance<T>`).
|
|
347
|
+
* `coinType` defaults to the deployment's CREDIT type — i.e. the bridged
|
|
348
|
+
* balance available to withdraw. Returns `0n` for an unknown coin type.
|
|
349
|
+
*/
|
|
350
|
+
export async function getAccountBalance(client, accountId, coinType) {
|
|
351
|
+
const tx = new Transaction();
|
|
352
|
+
accountBalanceCall({
|
|
353
|
+
package: client.config.packages.waterx_account.published_at,
|
|
354
|
+
arguments: {
|
|
355
|
+
registry: tx.object(client.config.packages.waterx_account.account_registry),
|
|
356
|
+
accountId,
|
|
357
|
+
},
|
|
358
|
+
typeArguments: [coinType ?? client.creditType()],
|
|
359
|
+
})(tx);
|
|
360
|
+
const bytes = await simulateAndExtract(client, tx);
|
|
361
|
+
return BigInt(bcs.u64().parse(bytes));
|
|
362
|
+
}
|
|
363
|
+
// ============================================================================
|
|
364
|
+
// Native custody (custody_vault)
|
|
365
|
+
// ============================================================================
|
|
366
|
+
function requireCustody(client) {
|
|
367
|
+
const nc = client.config.packages.native_custody;
|
|
368
|
+
if (!nc?.vault) {
|
|
369
|
+
throw new Error("native_custody not configured — set config.packages.native_custody.vault");
|
|
370
|
+
}
|
|
371
|
+
return { pkg: nc.published_at, vault: nc.vault, creditType: client.creditType() };
|
|
372
|
+
}
|
|
373
|
+
/** Reads vault-wide native-custody state via `custody_vault::credit_supply`. */
|
|
374
|
+
export async function getCustodyVaultData(client) {
|
|
375
|
+
const { pkg, vault, creditType } = requireCustody(client);
|
|
376
|
+
const tx = new Transaction();
|
|
377
|
+
creditSupplyCall({
|
|
378
|
+
package: pkg,
|
|
379
|
+
arguments: { vault: tx.object(vault) },
|
|
380
|
+
typeArguments: [creditType],
|
|
381
|
+
})(tx);
|
|
382
|
+
const bytes = await simulateAndExtract(client, tx);
|
|
383
|
+
return { creditSupply: BigInt(bcs.u64().parse(bytes)) };
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Reads per-asset native-custody state for backing asset `assetType`.
|
|
387
|
+
*
|
|
388
|
+
* Fee rates are the vault's default config — queried with the zero address as
|
|
389
|
+
* caller, so no partner discount is applied — as 1e9-scaled `Float` values.
|
|
390
|
+
* When the asset is not registered, returns `registered: false` with `0n` rates.
|
|
391
|
+
*
|
|
392
|
+
* Note: the `SingleVault` balance / decimal / backing / min-burn / deprecated
|
|
393
|
+
* fields are not exposed here — the contract's getters for those return a
|
|
394
|
+
* `&SingleVault<T>` reference, which a PTB simulate cannot read.
|
|
395
|
+
*/
|
|
396
|
+
export async function getCustodyAssetData(client, assetType) {
|
|
397
|
+
const { pkg, vault, creditType } = requireCustody(client);
|
|
398
|
+
const typeArguments = [assetType, creditType];
|
|
399
|
+
const hasTx = new Transaction();
|
|
400
|
+
hasAssetCall({ package: pkg, arguments: { vault: hasTx.object(vault) }, typeArguments })(hasTx);
|
|
401
|
+
const registered = bcs.bool().parse(await simulateAndExtract(client, hasTx));
|
|
402
|
+
if (!registered)
|
|
403
|
+
return { registered: false, mintFeeRate: 0n, burnFeeRate: 0n };
|
|
404
|
+
const mintTx = new Transaction();
|
|
405
|
+
mintFeeRateCall({
|
|
406
|
+
package: pkg,
|
|
407
|
+
arguments: { vault: mintTx.object(vault), caller: DRY_RUN_SENDER },
|
|
408
|
+
typeArguments,
|
|
409
|
+
})(mintTx);
|
|
410
|
+
const mintFeeRate = BigInt(bcs.u128().parse(await simulateAndExtract(client, mintTx)));
|
|
411
|
+
const burnTx = new Transaction();
|
|
412
|
+
burnFeeRateCall({
|
|
413
|
+
package: pkg,
|
|
414
|
+
arguments: { vault: burnTx.object(vault), caller: DRY_RUN_SENDER },
|
|
415
|
+
typeArguments,
|
|
416
|
+
})(burnTx);
|
|
417
|
+
const burnFeeRate = BigInt(bcs.u128().parse(await simulateAndExtract(client, burnTx)));
|
|
418
|
+
return { registered: true, mintFeeRate, burnFeeRate };
|
|
419
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
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 } from '@mysten/sui/transactions';
|
|
7
|
+
export declare const ACCOUNT: MoveStruct<{
|
|
8
|
+
dummy_field: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
|
|
9
|
+
}, "@bucket/framework::account::ACCOUNT">;
|
|
10
|
+
export declare const Account: MoveStruct<{
|
|
11
|
+
id: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
12
|
+
alias: import("@mysten/sui/bcs").BcsType<string | null, string | null | undefined, "Option<string>">;
|
|
13
|
+
}, "@bucket/framework::account::Account">;
|
|
14
|
+
export declare const AccountRequest: MoveStruct<{
|
|
15
|
+
account: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
16
|
+
}, "@bucket/framework::account::AccountRequest">;
|
|
17
|
+
export interface NewArguments {
|
|
18
|
+
alias: RawTransactionArgument<string | null>;
|
|
19
|
+
}
|
|
20
|
+
export interface NewOptions {
|
|
21
|
+
package?: string;
|
|
22
|
+
arguments: NewArguments | [
|
|
23
|
+
alias: RawTransactionArgument<string | null>
|
|
24
|
+
];
|
|
25
|
+
}
|
|
26
|
+
/** Public Funs */
|
|
27
|
+
export declare function _new(options: NewOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
28
|
+
export interface RequestOptions {
|
|
29
|
+
package?: string;
|
|
30
|
+
arguments?: [
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
export declare function request(options?: RequestOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
34
|
+
export interface RequestWithAccountArguments {
|
|
35
|
+
account: RawTransactionArgument<string>;
|
|
36
|
+
}
|
|
37
|
+
export interface RequestWithAccountOptions {
|
|
38
|
+
package?: string;
|
|
39
|
+
arguments: RequestWithAccountArguments | [
|
|
40
|
+
account: RawTransactionArgument<string>
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
export declare function requestWithAccount(options: RequestWithAccountOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
44
|
+
export interface ReceiveArguments {
|
|
45
|
+
account: RawTransactionArgument<string>;
|
|
46
|
+
receiving: RawTransactionArgument<string>;
|
|
47
|
+
}
|
|
48
|
+
export interface ReceiveOptions {
|
|
49
|
+
package?: string;
|
|
50
|
+
arguments: ReceiveArguments | [
|
|
51
|
+
account: RawTransactionArgument<string>,
|
|
52
|
+
receiving: RawTransactionArgument<string>
|
|
53
|
+
];
|
|
54
|
+
typeArguments: [
|
|
55
|
+
string
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
export declare function receive(options: ReceiveOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
59
|
+
export interface UpdateAliasArguments {
|
|
60
|
+
account: RawTransactionArgument<string>;
|
|
61
|
+
alias: RawTransactionArgument<string>;
|
|
62
|
+
}
|
|
63
|
+
export interface UpdateAliasOptions {
|
|
64
|
+
package?: string;
|
|
65
|
+
arguments: UpdateAliasArguments | [
|
|
66
|
+
account: RawTransactionArgument<string>,
|
|
67
|
+
alias: RawTransactionArgument<string>
|
|
68
|
+
];
|
|
69
|
+
}
|
|
70
|
+
export declare function updateAlias(options: UpdateAliasOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
71
|
+
export interface CreateArguments {
|
|
72
|
+
alias: RawTransactionArgument<string | null>;
|
|
73
|
+
}
|
|
74
|
+
export interface CreateOptions {
|
|
75
|
+
package?: string;
|
|
76
|
+
arguments: CreateArguments | [
|
|
77
|
+
alias: RawTransactionArgument<string | null>
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
/** Entry Funs */
|
|
81
|
+
export declare function create(options: CreateOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
82
|
+
export interface AccountAddressArguments {
|
|
83
|
+
account: RawTransactionArgument<string>;
|
|
84
|
+
}
|
|
85
|
+
export interface AccountAddressOptions {
|
|
86
|
+
package?: string;
|
|
87
|
+
arguments: AccountAddressArguments | [
|
|
88
|
+
account: RawTransactionArgument<string>
|
|
89
|
+
];
|
|
90
|
+
}
|
|
91
|
+
export declare function accountAddress(options: AccountAddressOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
92
|
+
export interface RequestAddressArguments {
|
|
93
|
+
req: RawTransactionArgument<string>;
|
|
94
|
+
}
|
|
95
|
+
export interface RequestAddressOptions {
|
|
96
|
+
package?: string;
|
|
97
|
+
arguments: RequestAddressArguments | [
|
|
98
|
+
req: RawTransactionArgument<string>
|
|
99
|
+
];
|
|
100
|
+
}
|
|
101
|
+
export declare function requestAddress(options: RequestAddressOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
102
|
+
export interface AliasLengthLimitOptions {
|
|
103
|
+
package?: string;
|
|
104
|
+
arguments?: [
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
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,17 @@
|
|
|
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<{
|
|
7
|
+
/**
|
|
8
|
+
* String representation of the type. All types are represented using their source
|
|
9
|
+
* syntax: "u8", "u64", "bool", "address", "vector", and so on for primitive types.
|
|
10
|
+
* Struct types are represented as fully qualified type names; e.g.
|
|
11
|
+
* `00000000000000000000000000000001::string::String` or
|
|
12
|
+
* `0000000000000000000000000000000a::module_name1::type_name1<0000000000000000000000000000000a::module_name2::type_name2<u64>>`
|
|
13
|
+
* Addresses are hex-encoded lowercase values of length ADDRESS_LENGTH (16, 20, or
|
|
14
|
+
* 32 depending on the Move platform)
|
|
15
|
+
*/
|
|
16
|
+
name: import("@mysten/sui/bcs").BcsType<string, string, "string">;
|
|
17
|
+
}, "std::type_name::TypeName">;
|