@waterx/sdk 2.4.1 → 3.0.1
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 +25 -21
- package/dist/src/{utils → account}/account-request.d.ts +2 -2
- package/dist/src/{user → account}/account.d.ts +23 -21
- package/dist/src/{user → account}/account.js +5 -5
- package/dist/src/account/client.d.ts +42 -0
- package/dist/src/account/client.js +17 -0
- package/dist/src/account/config.d.ts +151 -0
- package/dist/src/account/config.js +8 -0
- package/dist/src/account/constants.d.ts +5 -0
- package/dist/src/account/constants.js +5 -0
- package/dist/src/account/fetch/referral.d.ts +15 -0
- package/dist/src/account/fetch/referral.js +51 -0
- package/dist/src/account/fetch/simulate.d.ts +34 -0
- package/dist/src/account/fetch/simulate.js +43 -0
- package/dist/src/{utils/consolidate-balance.d.ts → account/funding/balance.d.ts} +3 -8
- package/dist/src/{utils/consolidate-balance.js → account/funding/balance.js} +6 -1
- package/dist/src/account/funding/consolidate.d.ts +46 -0
- package/dist/src/account/funding/consolidate.js +137 -0
- package/dist/src/{user → account/funding}/credit.d.ts +10 -10
- package/dist/src/{user → account/funding}/credit.js +6 -6
- package/dist/src/{user → account/funding}/custody.d.ts +4 -4
- package/dist/src/{user → account/funding}/custody.js +2 -2
- package/dist/src/{utils → account/funding}/wormhole.d.ts +4 -4
- package/dist/src/{utils → account/funding}/wormhole.js +1 -1
- package/dist/src/account/index.d.ts +29 -0
- package/dist/src/account/index.js +29 -0
- package/dist/src/{user → account}/referral.d.ts +3 -3
- package/dist/src/{user → account}/referral.js +1 -1
- package/dist/src/base-client.d.ts +74 -0
- package/dist/src/base-client.js +97 -0
- package/dist/src/constants.d.ts +4 -46
- package/dist/src/constants.js +8 -52
- package/dist/src/generated/bucket_v2_framework/liability.d.ts +0 -26
- package/dist/src/generated/bucket_v2_framework/liability.js +0 -28
- package/dist/src/generated/waterx_account/account.d.ts +50 -15
- package/dist/src/generated/waterx_account/account.js +51 -15
- package/dist/src/generated/waterx_oracle/oracle.d.ts +7 -1
- package/dist/src/generated/waterx_oracle/oracle.js +7 -2
- package/dist/src/{prediction/generated → generated}/waterx_prediction/account_data.d.ts +19 -2
- package/dist/src/{prediction/generated → generated}/waterx_prediction/admin.d.ts +3 -1
- package/dist/src/{prediction/generated → generated}/waterx_prediction/deps/sui/balance.d.ts +3 -1
- package/dist/src/{prediction/generated/waterx_account → generated/waterx_prediction}/deps/sui/table.d.ts +6 -1
- package/dist/src/generated/waterx_prediction/events.d.ts +288 -0
- package/dist/src/{prediction/generated → generated}/waterx_prediction/events.js +39 -0
- package/dist/src/{prediction/generated → generated}/waterx_prediction/global_config.d.ts +6 -1
- package/dist/src/{prediction/generated → generated}/waterx_prediction/order.d.ts +34 -1
- package/dist/src/{prediction/generated → generated}/waterx_prediction/position.d.ts +16 -1
- package/dist/src/{prediction/generated → generated}/waterx_prediction/view.d.ts +69 -4
- package/dist/src/{prediction/generated → generated}/waterx_prediction/waterx_prediction.d.ts +162 -2
- package/dist/src/{prediction/generated → generated}/waterx_prediction/waterx_prediction.js +99 -0
- package/dist/src/generated/waterx_pyth_rule/pyth_rule.d.ts +102 -0
- package/dist/src/generated/waterx_pyth_rule/pyth_rule.js +99 -0
- package/dist/src/generated/waterx_supra_rule/supra_rule.d.ts +5 -5
- package/dist/src/generated/waterx_supra_rule/supra_rule.js +1 -2
- package/dist/src/generated/withdrawal_queue/withdrawal_queue.d.ts +23 -23
- package/dist/src/generated/withdrawal_queue/withdrawal_queue.js +3 -6
- package/dist/src/oracle/aggregate.d.ts +74 -0
- package/dist/src/oracle/aggregate.js +112 -0
- package/dist/src/oracle/config.d.ts +99 -0
- package/dist/src/oracle/config.js +23 -0
- package/dist/src/oracle/host.d.ts +32 -0
- package/dist/src/oracle/host.js +10 -0
- package/dist/src/oracle/index.d.ts +16 -0
- package/dist/src/oracle/index.js +18 -0
- package/dist/src/oracle/pyth.d.ts +52 -0
- package/dist/src/oracle/pyth.js +220 -0
- package/dist/src/oracle/rules/constant-rule.d.ts +9 -0
- package/dist/src/oracle/rules/constant-rule.js +14 -0
- package/dist/src/oracle/rules/pyth-rule.d.ts +11 -0
- package/dist/src/oracle/rules/pyth-rule.js +20 -0
- package/dist/src/oracle/rules/sponsor.d.ts +28 -0
- package/dist/src/oracle/rules/sponsor.js +48 -0
- package/dist/src/oracle/rules/supra-rule.d.ts +11 -0
- package/dist/src/oracle/rules/supra-rule.js +22 -0
- package/dist/src/perp/client.d.ts +78 -0
- package/dist/src/perp/client.js +108 -0
- package/dist/src/{client.d.ts → perp/config-view.d.ts} +15 -60
- package/dist/src/{client.js → perp/config-view.js} +23 -95
- package/dist/src/perp/config.d.ts +126 -0
- package/dist/src/{config.js → perp/config.js} +11 -12
- package/dist/src/perp/constants.d.ts +49 -0
- package/dist/src/perp/constants.js +61 -0
- package/dist/src/perp/fetch/account.d.ts +43 -0
- package/dist/src/perp/fetch/account.js +64 -0
- package/dist/src/perp/fetch/bridge.d.ts +90 -0
- package/dist/src/perp/fetch/bridge.js +127 -0
- package/dist/src/perp/fetch/custody.d.ts +32 -0
- package/dist/src/perp/fetch/custody.js +62 -0
- package/dist/src/perp/fetch/market.d.ts +30 -0
- package/dist/src/perp/fetch/market.js +68 -0
- package/dist/src/perp/fetch/positions.d.ts +70 -0
- package/dist/src/perp/fetch/positions.js +185 -0
- package/dist/src/perp/fetch/simulate.d.ts +12 -0
- package/dist/src/perp/fetch/simulate.js +13 -0
- package/dist/src/perp/fetch.d.ts +23 -0
- package/dist/src/perp/fetch.js +23 -0
- package/dist/src/{index.d.ts → perp/index.d.ts} +21 -21
- package/dist/src/{index.js → perp/index.js} +21 -21
- package/dist/src/perp/tx-builders/common.d.ts +83 -0
- package/dist/src/perp/tx-builders/common.js +70 -0
- package/dist/src/perp/tx-builders/credit.d.ts +65 -0
- package/dist/src/perp/tx-builders/credit.js +62 -0
- package/dist/src/perp/tx-builders/rewards.d.ts +30 -0
- package/dist/src/perp/tx-builders/rewards.js +34 -0
- package/dist/src/perp/tx-builders/trading.d.ts +51 -0
- package/dist/src/perp/tx-builders/trading.js +59 -0
- package/dist/src/perp/tx-builders/wlp.d.ts +90 -0
- package/dist/src/perp/tx-builders/wlp.js +120 -0
- package/dist/src/perp/tx-builders.d.ts +23 -0
- package/dist/src/perp/tx-builders.js +23 -0
- package/dist/src/perp/user/index.d.ts +8 -0
- package/dist/src/perp/user/index.js +8 -0
- package/dist/src/{user → perp/user}/order.d.ts +7 -7
- package/dist/src/{user → perp/user}/order.js +3 -3
- package/dist/src/{user → perp/user}/staking.d.ts +4 -4
- package/dist/src/{user → perp/user}/staking.js +2 -2
- package/dist/src/{user → perp/user}/trading.d.ts +13 -13
- package/dist/src/{user → perp/user}/trading.js +2 -2
- package/dist/src/{user → perp/user}/wlp.d.ts +7 -7
- package/dist/src/{user → perp/user}/wlp.js +3 -3
- package/dist/src/prediction/account.js +40 -76
- package/dist/src/prediction/bcs.d.ts +15 -9
- package/dist/src/prediction/bcs.js +17 -81
- package/dist/src/prediction/client.d.ts +8 -38
- package/dist/src/prediction/client.js +11 -67
- package/dist/src/prediction/config.d.ts +16 -2
- package/dist/src/prediction/config.js +10 -4
- package/dist/src/prediction/gift.js +2 -10
- package/dist/src/prediction/index.d.ts +11 -11
- package/dist/src/prediction/index.js +10 -10
- package/dist/src/prediction/prediction.d.ts +45 -0
- package/dist/src/prediction/prediction.js +71 -0
- package/dist/src/prediction/tx-builders.d.ts +4 -4
- package/dist/src/prediction/tx-builders.js +2 -2
- package/dist/src/prediction/types.d.ts +2 -0
- package/dist/src/prediction/user/index.d.ts +2 -2
- package/dist/src/prediction/user/index.js +1 -1
- package/dist/src/prediction/user/position.d.ts +2 -2
- package/dist/src/prediction/user/position.js +1 -1
- package/dist/src/prediction/utils/bcs.d.ts +5 -0
- package/dist/src/prediction/utils/bcs.js +5 -0
- package/dist/src/prediction/utils/index.d.ts +7 -0
- package/dist/src/prediction/utils/index.js +7 -0
- package/dist/src/sdk.d.ts +10 -6
- package/dist/src/sdk.js +9 -5
- package/dist/src/unified-client.d.ts +140 -145
- package/dist/src/unified-client.js +98 -40
- package/dist/src/utils/config.d.ts +1 -1
- package/package.json +22 -5
- package/dist/src/config.d.ts +0 -292
- package/dist/src/fetch.d.ts +0 -254
- package/dist/src/fetch.js +0 -564
- package/dist/src/prediction/generated/bucket_v2_framework/account.d.ts +0 -100
- package/dist/src/prediction/generated/bucket_v2_framework/account.js +0 -129
- package/dist/src/prediction/generated/bucket_v2_framework/deps/std/type_name.d.ts +0 -6
- package/dist/src/prediction/generated/bucket_v2_framework/deps/std/type_name.js +0 -19
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/balance.d.ts +0 -10
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_map.d.ts +0 -36
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_map.js +0 -27
- package/dist/src/prediction/generated/bucket_v2_framework/double.d.ts +0 -382
- package/dist/src/prediction/generated/bucket_v2_framework/double.js +0 -466
- package/dist/src/prediction/generated/bucket_v2_framework/float.d.ts +0 -362
- package/dist/src/prediction/generated/bucket_v2_framework/float.js +0 -440
- package/dist/src/prediction/generated/bucket_v2_framework/liability.d.ts +0 -193
- package/dist/src/prediction/generated/bucket_v2_framework/liability.js +0 -205
- package/dist/src/prediction/generated/bucket_v2_framework/linked_table.d.ts +0 -384
- package/dist/src/prediction/generated/bucket_v2_framework/linked_table.js +0 -382
- package/dist/src/prediction/generated/bucket_v2_framework/sheet.d.ts +0 -344
- package/dist/src/prediction/generated/bucket_v2_framework/sheet.js +0 -338
- package/dist/src/prediction/generated/utils/index.d.ts +0 -30
- package/dist/src/prediction/generated/utils/index.js +0 -160
- package/dist/src/prediction/generated/waterx_account/account.d.ts +0 -1589
- package/dist/src/prediction/generated/waterx_account/account.js +0 -1758
- package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/liability.d.ts +0 -7
- package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/liability.js +0 -13
- package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/sheet.d.ts +0 -7
- package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/sheet.js +0 -16
- package/dist/src/prediction/generated/waterx_account/deps/std/type_name.d.ts +0 -6
- package/dist/src/prediction/generated/waterx_account/deps/std/type_name.js +0 -19
- package/dist/src/prediction/generated/waterx_account/deps/sui/balance.d.ts +0 -10
- package/dist/src/prediction/generated/waterx_account/deps/sui/balance.js +0 -14
- package/dist/src/prediction/generated/waterx_account/deps/sui/object_table.d.ts +0 -12
- package/dist/src/prediction/generated/waterx_account/deps/sui/object_table.js +0 -19
- package/dist/src/prediction/generated/waterx_account/deps/sui/vec_map.d.ts +0 -36
- package/dist/src/prediction/generated/waterx_account/deps/sui/vec_map.js +0 -27
- package/dist/src/prediction/generated/waterx_account/deps/sui/vec_set.d.ts +0 -16
- package/dist/src/prediction/generated/waterx_account/deps/sui/vec_set.js +0 -19
- package/dist/src/prediction/generated/waterx_account/direct_rule.d.ts +0 -75
- package/dist/src/prediction/generated/waterx_account/direct_rule.js +0 -78
- package/dist/src/prediction/generated/waterx_account/events.d.ts +0 -33
- package/dist/src/prediction/generated/waterx_account/events.js +0 -137
- package/dist/src/prediction/generated/waterx_account/version.js +0 -8
- package/dist/src/prediction/generated/waterx_prediction/bet_sharing.d.ts +0 -60
- package/dist/src/prediction/generated/waterx_prediction/bet_sharing.js +0 -83
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/balance.js +0 -14
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/table.d.ts +0 -24
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/table.js +0 -31
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/vec_set.d.ts +0 -16
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/vec_set.js +0 -19
- package/dist/src/prediction/generated/waterx_prediction/events.d.ts +0 -22
- package/dist/src/prediction/generated/waterx_prediction/version.d.ts +0 -10
- package/dist/src/tx-builders.d.ts +0 -296
- package/dist/src/tx-builders.js +0 -461
- package/dist/src/user/index.d.ts +0 -8
- package/dist/src/user/index.js +0 -8
- package/dist/src/utils/pyth.d.ts +0 -124
- package/dist/src/utils/pyth.js +0 -392
- /package/dist/src/{utils → account}/account-request.js +0 -0
- /package/dist/src/{core → account}/waterx-account.d.ts +0 -0
- /package/dist/src/{core → account}/waterx-account.js +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/account_data.js +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/admin.js +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/deps/bucket_v2_framework/linked_table.d.ts +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/deps/bucket_v2_framework/linked_table.js +0 -0
- /package/dist/src/{prediction/generated/bucket_v2_framework → generated/waterx_prediction}/deps/sui/balance.js +0 -0
- /package/dist/src/{prediction/generated/waterx_account → generated/waterx_prediction}/deps/sui/table.js +0 -0
- /package/dist/src/{prediction/generated/bucket_v2_framework → generated/waterx_prediction}/deps/sui/vec_set.d.ts +0 -0
- /package/dist/src/{prediction/generated/bucket_v2_framework → generated/waterx_prediction}/deps/sui/vec_set.js +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/global_config.js +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/order.js +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/outcome.d.ts +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/outcome.js +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/position.js +0 -0
- /package/dist/src/{prediction/generated/waterx_account → generated/waterx_prediction}/version.d.ts +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/version.js +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/view.js +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { bcs } from "@mysten/sui/bcs";
|
|
2
2
|
import { Transaction } from "@mysten/sui/transactions";
|
|
3
|
-
import {
|
|
3
|
+
import { addDelegate as sharedAddDelegate, createAccount as sharedCreateAccount, removeDelegate as sharedRemoveDelegate, requestDeposit as sharedRequestDeposit, requestDepositFromReceivings as sharedRequestDepositFromReceivings, requestWithdraw as sharedRequestWithdraw, transferToAccount as sharedTransferToAccount, } from "../account/account.js";
|
|
4
4
|
import { extractReturnBytes } from "./fetch.js";
|
|
5
5
|
import { clockArg, createAccountRequest, idArg, objectArg, receivingCoinArg, resolveAccountRegistry, resolvePackageId, toBigInt, } from "./utils.js";
|
|
6
6
|
function accountPackage(client, packageId) {
|
|
@@ -20,36 +20,29 @@ export async function resolveRegistryAccountId(client, accountObjectId, params =
|
|
|
20
20
|
return bcs.Address.parse(extractReturnBytes(result));
|
|
21
21
|
}
|
|
22
22
|
export function createAccount(client, tx, params) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
// Delegates to the shared account/ builder — `waterx_account` is a single shared
|
|
24
|
+
// contract, so the account id + registry are identical across lines. (The
|
|
25
|
+
// per-call package/registry overrides are moot with one package.)
|
|
26
|
+
return sharedCreateAccount(client, tx, {
|
|
27
|
+
alias: params.alias,
|
|
28
|
+
bucketAccount: params.bucketAccount,
|
|
29
|
+
});
|
|
28
30
|
}
|
|
29
31
|
export function transferCoinToAccount(client, tx, params) {
|
|
30
|
-
tx
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
35
|
-
idArg(tx, params.accountId),
|
|
36
|
-
objectArg(tx, params.coin),
|
|
37
|
-
],
|
|
32
|
+
sharedTransferToAccount(client, tx, {
|
|
33
|
+
accountId: params.accountId,
|
|
34
|
+
coin: objectArg(tx, params.coin),
|
|
35
|
+
coinType: params.coinType ?? client.settlementCoinType(),
|
|
38
36
|
});
|
|
39
37
|
return tx;
|
|
40
38
|
}
|
|
41
39
|
export function requestDeposit(client, tx, params) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
idArg(tx, params.accountId),
|
|
48
|
-
objectArg(tx, params.coin),
|
|
49
|
-
tx.pure.vector("u8", Array.from(params.extraData ?? [])),
|
|
50
|
-
],
|
|
40
|
+
return sharedRequestDeposit(client, tx, {
|
|
41
|
+
accountId: params.accountId,
|
|
42
|
+
coin: objectArg(tx, params.coin),
|
|
43
|
+
coinType: params.coinType ?? client.settlementCoinType(),
|
|
44
|
+
extraData: params.extraData == null ? undefined : Uint8Array.from(params.extraData),
|
|
51
45
|
});
|
|
52
|
-
return request;
|
|
53
46
|
}
|
|
54
47
|
/** Finishes a `request_deposit` hot potato via `direct_rule` (same-coin credit). */
|
|
55
48
|
export function consumeDepositDirect(client, tx, params) {
|
|
@@ -78,39 +71,22 @@ export function deposit(client, tx, params) {
|
|
|
78
71
|
return tx;
|
|
79
72
|
}
|
|
80
73
|
export function requestDepositFromReceivings(client, tx, params) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
arguments: [
|
|
87
|
-
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
88
|
-
idArg(tx, params.accountId),
|
|
89
|
-
tx.makeMoveVec({
|
|
90
|
-
type: `0x2::transfer::Receiving<0x2::coin::Coin<${coinType}>>`,
|
|
91
|
-
elements: receivings,
|
|
92
|
-
}),
|
|
93
|
-
tx.pure.vector("u8", Array.from(params.extraData ?? [])),
|
|
94
|
-
],
|
|
74
|
+
return sharedRequestDepositFromReceivings(client, tx, {
|
|
75
|
+
accountId: params.accountId,
|
|
76
|
+
receivings: params.coins.map((coin) => receivingCoinArg(tx, coin)),
|
|
77
|
+
coinType: params.coinType ?? client.settlementCoinType(),
|
|
78
|
+
extraData: params.extraData == null ? undefined : Uint8Array.from(params.extraData),
|
|
95
79
|
});
|
|
96
|
-
return request;
|
|
97
80
|
}
|
|
98
81
|
export function requestWithdraw(client, tx, params) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
idArg(tx, params.accountId),
|
|
107
|
-
tx.pure.u64(toBigInt(params.amount)),
|
|
108
|
-
tx.pure.address(params.recipient),
|
|
109
|
-
tx.pure.vector("u8", Array.from(params.extraData ?? [])),
|
|
110
|
-
clockArg(tx),
|
|
111
|
-
],
|
|
82
|
+
return sharedRequestWithdraw(client, tx, {
|
|
83
|
+
accountId: params.accountId,
|
|
84
|
+
amount: toBigInt(params.amount),
|
|
85
|
+
recipient: params.recipient,
|
|
86
|
+
coinType: params.coinType ?? client.settlementCoinType(),
|
|
87
|
+
extraData: params.extraData == null ? undefined : Uint8Array.from(params.extraData),
|
|
88
|
+
bucketAccount: params.bucketAccount,
|
|
112
89
|
});
|
|
113
|
-
return request;
|
|
114
90
|
}
|
|
115
91
|
/** Finishes a `request_withdraw` hot potato via `direct_rule` (same-coin payout). */
|
|
116
92
|
export function consumeWithdrawDirect(client, tx, params) {
|
|
@@ -139,33 +115,21 @@ export function withdraw(client, tx, params) {
|
|
|
139
115
|
return tx;
|
|
140
116
|
}
|
|
141
117
|
export function addDelegate(client, tx, params) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
tx.pure.address(params.delegate),
|
|
150
|
-
tx.pure.string(params.alias),
|
|
151
|
-
tx.pure.u32(params.permissions),
|
|
152
|
-
tx.pure.option("u64", params.expiresAtMs == null ? null : toBigInt(params.expiresAtMs)),
|
|
153
|
-
clockArg(tx),
|
|
154
|
-
],
|
|
118
|
+
sharedAddDelegate(client, tx, {
|
|
119
|
+
accountId: params.accountId,
|
|
120
|
+
delegateAddress: params.delegate,
|
|
121
|
+
alias: params.alias,
|
|
122
|
+
permissions: params.permissions,
|
|
123
|
+
expiresAtMs: params.expiresAtMs == null ? undefined : toBigInt(params.expiresAtMs),
|
|
124
|
+
bucketAccount: params.bucketAccount,
|
|
155
125
|
});
|
|
156
126
|
return tx;
|
|
157
127
|
}
|
|
158
128
|
export function removeDelegate(client, tx, params) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
164
|
-
senderRequest,
|
|
165
|
-
idArg(tx, params.accountId),
|
|
166
|
-
tx.pure.address(params.delegate),
|
|
167
|
-
clockArg(tx),
|
|
168
|
-
],
|
|
129
|
+
sharedRemoveDelegate(client, tx, {
|
|
130
|
+
accountId: params.accountId,
|
|
131
|
+
delegateAddress: params.delegate,
|
|
132
|
+
bucketAccount: params.bucketAccount,
|
|
169
133
|
});
|
|
170
134
|
return tx;
|
|
171
135
|
}
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
+
import { OrderKind as OrderKindBcs } from "../generated/waterx_prediction/order.ts";
|
|
2
|
+
import { Outcome as OutcomeBcs } from "../generated/waterx_prediction/outcome.ts";
|
|
3
|
+
import { Selection as SelectionBcs, Status as StatusBcs } from "../generated/waterx_prediction/position.ts";
|
|
4
|
+
import { AccountDataView as AccountDataViewBcs, MarketView as MarketViewBcs, OrderView as OrderViewBcs, PositionView as PositionViewBcs, RegistryView as RegistryViewBcs } from "../generated/waterx_prediction/view.ts";
|
|
1
5
|
import type { AccountDataView, CursorView, MarketExposure, MarketView, OrderKind, OrderView, Outcome, PositionStatus, PositionView, RegistryView, Selection } from "./types.ts";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
/**
|
|
7
|
+
* The prediction line decodes its `view::*` simulate reads with the codegen
|
|
8
|
+
* schemas in `../generated/waterx_prediction/*` — the single source of truth,
|
|
9
|
+
* regenerated by `pnpm codegen` from the deployed Move ABI. They are re-exported
|
|
10
|
+
* here under the legacy `*Bcs` names for back-compat (the public
|
|
11
|
+
* `@waterx/sdk/prediction/utils/bcs` subpath + tests). There is NO hand-written
|
|
12
|
+
* BCS mirror to keep in sync — a contract field add/remove/reorder flows in via
|
|
13
|
+
* `pnpm codegen`; the `map*` helpers below only translate the raw parse output
|
|
14
|
+
* to the public camelCase view types.
|
|
15
|
+
*/
|
|
16
|
+
export { AccountDataViewBcs, MarketViewBcs, OrderKindBcs, OrderViewBcs, OutcomeBcs, PositionViewBcs, RegistryViewBcs, SelectionBcs, StatusBcs, };
|
|
11
17
|
export declare function decodeEnumVariant(raw: unknown): string;
|
|
12
18
|
export declare function mapSelection(raw: unknown): Selection;
|
|
13
19
|
export declare function mapOutcome(raw: unknown): Outcome;
|
|
@@ -1,85 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OrderKind as OrderKindBcs } from "../generated/waterx_prediction/order.js";
|
|
2
|
+
import { Outcome as OutcomeBcs } from "../generated/waterx_prediction/outcome.js";
|
|
3
|
+
import { Selection as SelectionBcs, Status as StatusBcs, } from "../generated/waterx_prediction/position.js";
|
|
4
|
+
import { AccountDataView as AccountDataViewBcs, MarketView as MarketViewBcs, OrderView as OrderViewBcs, PositionView as PositionViewBcs, RegistryView as RegistryViewBcs, } from "../generated/waterx_prediction/view.js";
|
|
2
5
|
import { bytesToHex, marketIdBytesFromUnknown } from "./utils.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
});
|
|
15
|
-
export const OutcomeBcs = bcs.enum("Outcome", {
|
|
16
|
-
No: null,
|
|
17
|
-
Yes: null,
|
|
18
|
-
Invalid: null,
|
|
19
|
-
});
|
|
20
|
-
export const RegistryViewBcs = bcs.struct("RegistryView", {
|
|
21
|
-
balance: bcs.u64(),
|
|
22
|
-
min_reserve: bcs.u64(),
|
|
23
|
-
order_cancel_cooldown_ms: bcs.u64(),
|
|
24
|
-
next_order_id: bcs.u64(),
|
|
25
|
-
order_count: bcs.u64(),
|
|
26
|
-
position_count: bcs.u64(),
|
|
27
|
-
unresolved_market_count: bcs.u64(),
|
|
28
|
-
resolved_market_count: bcs.u64(),
|
|
29
|
-
});
|
|
30
|
-
export const OrderViewBcs = bcs.struct("OrderView", {
|
|
31
|
-
order_id: bcs.u64(),
|
|
32
|
-
kind: OrderKindBcs,
|
|
33
|
-
account_id: bcs.Address,
|
|
34
|
-
market_id: bcs.vector(bcs.u8()),
|
|
35
|
-
selection: SelectionBcs,
|
|
36
|
-
position_id: bcs.option(bcs.u64()),
|
|
37
|
-
max_spend: bcs.u64(),
|
|
38
|
-
min_shares: bcs.u64(),
|
|
39
|
-
price_cap: bcs.u64(),
|
|
40
|
-
min_proceeds: bcs.u64(),
|
|
41
|
-
expiry_ts: bcs.u64(),
|
|
42
|
-
self_cancel_after_ts: bcs.u64(),
|
|
43
|
-
created_ts: bcs.u64(),
|
|
44
|
-
by_admin: bcs.bool(),
|
|
45
|
-
});
|
|
46
|
-
export const PositionViewBcs = bcs.struct("PositionView", {
|
|
47
|
-
position_id: bcs.u64(),
|
|
48
|
-
account_id: bcs.Address,
|
|
49
|
-
market_id: bcs.vector(bcs.u8()),
|
|
50
|
-
selection: SelectionBcs,
|
|
51
|
-
status: StatusBcs,
|
|
52
|
-
filled_shares: bcs.u64(),
|
|
53
|
-
filled_cost: bcs.u64(),
|
|
54
|
-
opened_ts: bcs.u64(),
|
|
55
|
-
payout: bcs.u64(),
|
|
56
|
-
close_order_id: bcs.option(bcs.u64()),
|
|
57
|
-
close_min_proceeds: bcs.u64(),
|
|
58
|
-
close_expiry_ts: bcs.u64(),
|
|
59
|
-
close_self_cancel_after_ts: bcs.u64(),
|
|
60
|
-
});
|
|
61
|
-
export const MarketViewBcs = bcs.struct("MarketView", {
|
|
62
|
-
market_key: bcs.u64(),
|
|
63
|
-
market_id: bcs.vector(bcs.u8()),
|
|
64
|
-
resolved: bcs.bool(),
|
|
65
|
-
paused: bcs.bool(),
|
|
66
|
-
outcome: bcs.option(OutcomeBcs),
|
|
67
|
-
unclaimed_count: bcs.u64(),
|
|
68
|
-
yes_shares: bcs.u64(),
|
|
69
|
-
yes_cost: bcs.u64(),
|
|
70
|
-
no_shares: bcs.u64(),
|
|
71
|
-
no_cost: bcs.u64(),
|
|
72
|
-
});
|
|
73
|
-
export const AccountDataViewBcs = bcs.struct("AccountDataView", {
|
|
74
|
-
account_id: bcs.Address,
|
|
75
|
-
has_data: bcs.bool(),
|
|
76
|
-
order_count: bcs.u64(),
|
|
77
|
-
position_count: bcs.u64(),
|
|
78
|
-
order_front: bcs.option(bcs.u64()),
|
|
79
|
-
order_back: bcs.option(bcs.u64()),
|
|
80
|
-
position_front: bcs.option(bcs.u64()),
|
|
81
|
-
position_back: bcs.option(bcs.u64()),
|
|
82
|
-
});
|
|
6
|
+
/**
|
|
7
|
+
* The prediction line decodes its `view::*` simulate reads with the codegen
|
|
8
|
+
* schemas in `../generated/waterx_prediction/*` — the single source of truth,
|
|
9
|
+
* regenerated by `pnpm codegen` from the deployed Move ABI. They are re-exported
|
|
10
|
+
* here under the legacy `*Bcs` names for back-compat (the public
|
|
11
|
+
* `@waterx/sdk/prediction/utils/bcs` subpath + tests). There is NO hand-written
|
|
12
|
+
* BCS mirror to keep in sync — a contract field add/remove/reorder flows in via
|
|
13
|
+
* `pnpm codegen`; the `map*` helpers below only translate the raw parse output
|
|
14
|
+
* to the public camelCase view types.
|
|
15
|
+
*/
|
|
16
|
+
export { AccountDataViewBcs, MarketViewBcs, OrderKindBcs, OrderViewBcs, OutcomeBcs, PositionViewBcs, RegistryViewBcs, SelectionBcs, StatusBcs, };
|
|
83
17
|
export function decodeEnumVariant(raw) {
|
|
84
18
|
if (typeof raw === "string")
|
|
85
19
|
return raw;
|
|
@@ -150,6 +84,7 @@ export function mapRegistryView(raw) {
|
|
|
150
84
|
minReserve: BigInt(raw.min_reserve),
|
|
151
85
|
orderCancelCooldownMs: BigInt(raw.order_cancel_cooldown_ms),
|
|
152
86
|
nextOrderId: BigInt(raw.next_order_id),
|
|
87
|
+
nextPositionId: BigInt(raw.next_position_id),
|
|
153
88
|
orderCount: BigInt(raw.order_count),
|
|
154
89
|
positionCount: BigInt(raw.position_count),
|
|
155
90
|
unresolvedMarketCount: BigInt(raw.unresolved_market_count),
|
|
@@ -162,6 +97,7 @@ export function mapOrderView(raw) {
|
|
|
162
97
|
orderId: BigInt(raw.order_id),
|
|
163
98
|
kind: mapOrderKind(raw.kind),
|
|
164
99
|
accountId: raw.account_id,
|
|
100
|
+
receiverAccountId: raw.receiver_account_id,
|
|
165
101
|
marketId,
|
|
166
102
|
marketIdHex: bytesToHex(marketId),
|
|
167
103
|
selection: mapSelection(raw.selection),
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import type { SuiClientTypes } from "@mysten/sui/client";
|
|
2
|
-
import type { Signer } from "@mysten/sui/cryptography";
|
|
3
|
-
import { SuiGrpcClient } from "@mysten/sui/grpc";
|
|
4
1
|
import type { Transaction } from "@mysten/sui/transactions";
|
|
2
|
+
import { BaseLineClient } from "../base-client.ts";
|
|
5
3
|
import { type LoadConfigOptions, type WaterxPredictionConfig } from "./config.ts";
|
|
6
4
|
import type { Network } from "./constants.ts";
|
|
7
5
|
export interface CreateClientOptions extends LoadConfigOptions {
|
|
@@ -9,13 +7,7 @@ export interface CreateClientOptions extends LoadConfigOptions {
|
|
|
9
7
|
/** Settlement alias in `packages.waterx_prediction.*` maps. Default: "USD". */
|
|
10
8
|
settlement?: string;
|
|
11
9
|
}
|
|
12
|
-
export declare class PredictClient {
|
|
13
|
-
/** gRPC client - all RPC including `simulateTransaction`. */
|
|
14
|
-
grpcClient: SuiGrpcClient;
|
|
15
|
-
/** Network identifier in upper case (`MAINNET` / `TESTNET`). */
|
|
16
|
-
network: Network;
|
|
17
|
-
/** Parsed canonical `waterx-config` JSON. */
|
|
18
|
-
config: WaterxPredictionConfig;
|
|
10
|
+
export declare class PredictClient extends BaseLineClient<WaterxPredictionConfig> {
|
|
19
11
|
/** Default settlement alias for prediction registry lookups. */
|
|
20
12
|
settlement: string;
|
|
21
13
|
constructor(network: Network, config: WaterxPredictionConfig, opts?: {
|
|
@@ -29,36 +21,14 @@ export declare class PredictClient {
|
|
|
29
21
|
* a ready-to-use client. Pass `opts.cache=true` to memoize the JSON.
|
|
30
22
|
*/
|
|
31
23
|
static create(network?: Network, opts?: CreateClientOptions): Promise<PredictClient>;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}): Promise<SuiClientTypes.ListCoinsResponse>;
|
|
39
|
-
getBalance(params: {
|
|
40
|
-
owner: string;
|
|
41
|
-
coinType?: string;
|
|
42
|
-
}): Promise<SuiClientTypes.GetBalanceResponse>;
|
|
43
|
-
listDynamicFields(parentId: string): ReturnType<SuiGrpcClient["listDynamicFields"]>;
|
|
44
|
-
getDynamicField(parentId: string, name: {
|
|
45
|
-
type: string;
|
|
46
|
-
bcs: Uint8Array;
|
|
47
|
-
}): Promise<SuiClientTypes.GetDynamicFieldResponse>;
|
|
48
|
-
waitForTransaction(digest: string): Promise<SuiClientTypes.TransactionResult<{}>>;
|
|
49
|
-
simulate(tx: Transaction): Promise<SuiClientTypes.SimulateTransactionResult<{
|
|
24
|
+
/**
|
|
25
|
+
* Simulate with rate-limit retry — the prediction line hammers the public
|
|
26
|
+
* testnet RPC harder (batch claims / dual-path reads), so it backs off on
|
|
27
|
+
* `RESOURCE_EXHAUSTED` where the base client does not.
|
|
28
|
+
*/
|
|
29
|
+
simulate(tx: Transaction): Promise<import("@mysten/sui/client").SuiClientTypes.SimulateTransactionResult<{
|
|
50
30
|
commandResults: true;
|
|
51
31
|
}>>;
|
|
52
|
-
signAndExecuteTransaction<Include extends SuiClientTypes.TransactionInclude = object>(params: {
|
|
53
|
-
signer: {
|
|
54
|
-
toSuiAddress: () => string;
|
|
55
|
-
} & Signer;
|
|
56
|
-
transaction: Transaction | Uint8Array;
|
|
57
|
-
additionalSignatures?: string[];
|
|
58
|
-
include?: Include & SuiClientTypes.TransactionInclude;
|
|
59
|
-
}): Promise<SuiClientTypes.TransactionResult<Include & SuiClientTypes.TransactionInclude>>;
|
|
60
|
-
/** All package IDs (`published_at`) keyed by package name. */
|
|
61
|
-
packageIds(): Record<string, string>;
|
|
62
32
|
packageId(): string;
|
|
63
33
|
bucketFrameworkPackageId(): string;
|
|
64
34
|
waterxAccountPackageId(): string;
|
|
@@ -1,27 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { loadConfig
|
|
3
|
-
|
|
4
|
-
MAINNET: "https://fullnode.mainnet.sui.io:443",
|
|
5
|
-
TESTNET: "https://fullnode.testnet.sui.io:443",
|
|
6
|
-
};
|
|
7
|
-
export class PredictClient {
|
|
8
|
-
/** gRPC client - all RPC including `simulateTransaction`. */
|
|
9
|
-
grpcClient;
|
|
10
|
-
/** Network identifier in upper case (`MAINNET` / `TESTNET`). */
|
|
11
|
-
network;
|
|
12
|
-
/** Parsed canonical `waterx-config` JSON. */
|
|
13
|
-
config;
|
|
1
|
+
import { BaseLineClient } from "../base-client.js";
|
|
2
|
+
import { loadConfig } from "./config.js";
|
|
3
|
+
export class PredictClient extends BaseLineClient {
|
|
14
4
|
/** Default settlement alias for prediction registry lookups. */
|
|
15
5
|
settlement;
|
|
16
6
|
constructor(network, config, opts = {}) {
|
|
17
|
-
|
|
18
|
-
this.config = config;
|
|
7
|
+
super(network, config, opts);
|
|
19
8
|
this.settlement = opts.settlement ?? "USD";
|
|
20
|
-
const baseUrl = opts.grpcUrl ?? config.grpcUrl ?? GRPC_URLS[network];
|
|
21
|
-
this.grpcClient = new SuiGrpcClient({
|
|
22
|
-
baseUrl,
|
|
23
|
-
network: network.toLowerCase(),
|
|
24
|
-
});
|
|
25
9
|
}
|
|
26
10
|
static testnet(params = {}) {
|
|
27
11
|
return PredictClient.create("TESTNET", params);
|
|
@@ -40,51 +24,17 @@ export class PredictClient {
|
|
|
40
24
|
settlement: opts.settlement,
|
|
41
25
|
});
|
|
42
26
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
listOwnedObjects(owner) {
|
|
50
|
-
return this.grpcClient.listOwnedObjects({ owner });
|
|
51
|
-
}
|
|
52
|
-
listCoins(params) {
|
|
53
|
-
return this.grpcClient.listCoins(params);
|
|
54
|
-
}
|
|
55
|
-
getBalance(params) {
|
|
56
|
-
return this.grpcClient.getBalance(params);
|
|
57
|
-
}
|
|
58
|
-
listDynamicFields(parentId) {
|
|
59
|
-
return this.grpcClient.listDynamicFields({ parentId });
|
|
60
|
-
}
|
|
61
|
-
getDynamicField(parentId, name) {
|
|
62
|
-
return this.grpcClient.getDynamicField({ parentId, name });
|
|
63
|
-
}
|
|
64
|
-
waitForTransaction(digest) {
|
|
65
|
-
return this.grpcClient.waitForTransaction({ digest });
|
|
66
|
-
}
|
|
27
|
+
/**
|
|
28
|
+
* Simulate with rate-limit retry — the prediction line hammers the public
|
|
29
|
+
* testnet RPC harder (batch claims / dual-path reads), so it backs off on
|
|
30
|
+
* `RESOURCE_EXHAUSTED` where the base client does not.
|
|
31
|
+
*/
|
|
67
32
|
async simulate(tx) {
|
|
68
|
-
return withRpcRetry(() =>
|
|
69
|
-
transaction: tx,
|
|
70
|
-
include: { commandResults: true },
|
|
71
|
-
}));
|
|
72
|
-
}
|
|
73
|
-
async signAndExecuteTransaction(params) {
|
|
74
|
-
return this.grpcClient.signAndExecuteTransaction(params);
|
|
33
|
+
return withRpcRetry(() => super.simulate(tx));
|
|
75
34
|
}
|
|
76
35
|
// ========================================================
|
|
77
|
-
//
|
|
36
|
+
// Config-schema lookups (prediction-specific)
|
|
78
37
|
// ========================================================
|
|
79
|
-
/** All package IDs (`published_at`) keyed by package name. */
|
|
80
|
-
packageIds() {
|
|
81
|
-
const out = {};
|
|
82
|
-
for (const [name, pkg] of Object.entries(this.config.packages)) {
|
|
83
|
-
if (isPublishedPackage(pkg))
|
|
84
|
-
out[name] = pkg.published_at;
|
|
85
|
-
}
|
|
86
|
-
return out;
|
|
87
|
-
}
|
|
88
38
|
packageId() {
|
|
89
39
|
return this.config.packages.waterx_prediction.published_at;
|
|
90
40
|
}
|
|
@@ -125,12 +75,6 @@ export class PredictClient {
|
|
|
125
75
|
return requireConfigValue(this.config.packages.waterx_referral, "referral_table", "packages.waterx_referral.referral_table");
|
|
126
76
|
}
|
|
127
77
|
}
|
|
128
|
-
function isPublishedPackage(value) {
|
|
129
|
-
return (!!value &&
|
|
130
|
-
typeof value === "object" &&
|
|
131
|
-
"published_at" in value &&
|
|
132
|
-
typeof value.published_at === "string");
|
|
133
|
-
}
|
|
134
78
|
function requireConfigValue(map, key, path) {
|
|
135
79
|
const value = map?.[key];
|
|
136
80
|
if (typeof value !== "string" || value.length === 0) {
|
|
@@ -46,8 +46,18 @@ export interface WaterxPredictionConfig {
|
|
|
46
46
|
packages: WaterxPredictionConfigPackages;
|
|
47
47
|
}
|
|
48
48
|
export interface LoadConfigOptions {
|
|
49
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* Override the default waterx-config raw JSON URL. Use this to point at a
|
|
51
|
+
* local mirror during development. Takes precedence over {@link configRef}.
|
|
52
|
+
*/
|
|
50
53
|
configUrl?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Pin the canonical config to a specific git ref — a commit SHA, branch, or
|
|
56
|
+
* tag — instead of the default `main` branch. Resolves to
|
|
57
|
+
* `https://raw.githubusercontent.com/WaterXProtocol/waterx-config/<ref>/<network>.json`.
|
|
58
|
+
* Ignored when {@link configUrl} is set.
|
|
59
|
+
*/
|
|
60
|
+
configRef?: string;
|
|
51
61
|
/** Reuse a previously fetched config in memory. Default: false. */
|
|
52
62
|
cache?: boolean;
|
|
53
63
|
/** Optional fetch implementation for tests or runtimes without global fetch. */
|
|
@@ -55,6 +65,10 @@ export interface LoadConfigOptions {
|
|
|
55
65
|
/** Request timeout in ms. Default: 10_000. */
|
|
56
66
|
timeoutMs?: number;
|
|
57
67
|
}
|
|
58
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Build the canonical config URL for `network`, optionally pinned to a
|
|
70
|
+
* specific git `ref` (commit SHA, branch, or tag). Defaults to `main`.
|
|
71
|
+
*/
|
|
72
|
+
export declare function defaultConfigUrl(network: Network, ref?: string): string;
|
|
59
73
|
export declare function clearConfigCache(): void;
|
|
60
74
|
export declare function loadConfig(network: Network, opts?: LoadConfigOptions): Promise<WaterxPredictionConfig>;
|
|
@@ -4,16 +4,22 @@
|
|
|
4
4
|
* Mirrors the canonical `waterx-config` JSON for the packages used by this SDK
|
|
5
5
|
* and fetches it from GitHub raw by default.
|
|
6
6
|
*/
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const CONFIG_REPO_RAW_BASE = "https://raw.githubusercontent.com/WaterXProtocol/waterx-config";
|
|
8
|
+
/** Default git ref for the canonical config when none is pinned. */
|
|
9
|
+
const DEFAULT_CONFIG_REF = "main";
|
|
10
|
+
/**
|
|
11
|
+
* Build the canonical config URL for `network`, optionally pinned to a
|
|
12
|
+
* specific git `ref` (commit SHA, branch, or tag). Defaults to `main`.
|
|
13
|
+
*/
|
|
14
|
+
export function defaultConfigUrl(network, ref = DEFAULT_CONFIG_REF) {
|
|
15
|
+
return `${CONFIG_REPO_RAW_BASE}/${ref}/${network.toLowerCase()}.json`;
|
|
10
16
|
}
|
|
11
17
|
const configCache = new Map();
|
|
12
18
|
export function clearConfigCache() {
|
|
13
19
|
configCache.clear();
|
|
14
20
|
}
|
|
15
21
|
export async function loadConfig(network, opts = {}) {
|
|
16
|
-
const url = opts.configUrl ?? defaultConfigUrl(network);
|
|
22
|
+
const url = opts.configUrl ?? defaultConfigUrl(network, opts.configRef);
|
|
17
23
|
if (opts.cache && configCache.has(url)) {
|
|
18
24
|
return configCache.get(url);
|
|
19
25
|
}
|
|
@@ -23,7 +23,7 @@ import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
|
|
|
23
23
|
import { Transaction } from "@mysten/sui/transactions";
|
|
24
24
|
import { deriveObjectID, fromBase64, toBase64 } from "@mysten/sui/utils";
|
|
25
25
|
import { sha256 } from "@noble/hashes/sha2.js";
|
|
26
|
-
import { SelectionBcs } from "./bcs.js";
|
|
26
|
+
import { mapSelection, SelectionBcs } from "./bcs.js";
|
|
27
27
|
import { GIFT_DOMAIN_CLAIM, GIFT_KDF_DOMAIN, GIFT_PUBKEY_LEN, GIFT_SIG_LEN, GIFT_URL_SEED_BYTES, } from "./constants.js";
|
|
28
28
|
import { extractReturnBytes } from "./fetch.js";
|
|
29
29
|
import { clockArg, createAccountRequest, idArg, resolveAccountRegistry, resolveGlobalConfig, resolveMarketRegistry, resolveSettlementCoinType, toBigInt, } from "./utils.js";
|
|
@@ -296,15 +296,7 @@ export async function getGift(client, params) {
|
|
|
296
296
|
const id = () => bcs.Address.parse(extractReturnBytes(result, i++));
|
|
297
297
|
const u64 = () => BigInt(bcs.u64().parse(extractReturnBytes(result, i++)));
|
|
298
298
|
const bytes = () => new Uint8Array(bcs.vector(bcs.u8()).parse(extractReturnBytes(result, i++)));
|
|
299
|
-
const sel = () =>
|
|
300
|
-
const parsed = SelectionBcs.parse(extractReturnBytes(result, i++));
|
|
301
|
-
const variant = parsed?.$kind ?? parsed; // bcs.enum returns { $kind } in v2
|
|
302
|
-
if (variant === "Yes" || variant === "YES")
|
|
303
|
-
return "YES";
|
|
304
|
-
if (variant === "No" || variant === "NO")
|
|
305
|
-
return "NO";
|
|
306
|
-
throw new Error(`Unrecognized Selection variant: ${JSON.stringify(parsed)}`);
|
|
307
|
-
};
|
|
299
|
+
const sel = () => mapSelection(SelectionBcs.parse(extractReturnBytes(result, i++)));
|
|
308
300
|
const addrs = () => bcs.vector(bcs.Address).parse(extractReturnBytes(result, i++));
|
|
309
301
|
const optString = () => bcs.option(bcs.string()).parse(extractReturnBytes(result, i++));
|
|
310
302
|
const giftId = id();
|
|
@@ -10,20 +10,20 @@ export { addDelegate, allowPredictionProtocolAsset, consumeDepositDirect, consum
|
|
|
10
10
|
export type { AddDelegateParams, ConsumeDepositDirectParams, CreateAccountParams, ConsumeWithdrawDirectParams, PredictionProtocolAssetParams, RemoveDelegateParams, RequestDepositFromReceivingsParams, RequestDepositParams, RequestWithdrawParams, SetDelegatePredictionPermissionParams, TransferCoinToAccountParams, WhitelistPredictionProtocolParams, } from "./account.ts";
|
|
11
11
|
export { addKeeper, adminWithdraw, createMarketRegistry, depositSettlement, pauseMarket, removeKeeper, setMinReserve, setOrderCancelCooldownMs, unpauseMarket, } from "./admin.ts";
|
|
12
12
|
export type { AdminWithdrawParams, CreateMarketRegistryParams, DepositSettlementParams, KeeperAdminParams, MarketPauseParams, SetMinReserveParams, SetOrderCancelCooldownParams, } from "./admin.ts";
|
|
13
|
-
export { adminPlaceOrderFor, batchClaim, batchForceClaim, buildBatchForceClaimTransactions, cancelClose, cancelOrder, claim, confirmClose, fillOrder, forceClaim, outcomeArg, placeOrder, requestClose, resolveMarket, selectionArg, selfCancelClose, selfCancelOrder, } from "./prediction.ts";
|
|
14
|
-
export type { AdminPlaceOrderForParams, BatchClaimParams, BatchForceClaimParams, BuildBatchForceClaimTransactionsParams, CancelCloseParams, CancelOrderParams, ClaimParams, ConfirmCloseParams, FillOrderParams, ForceClaimParams, PlaceOrderParams, RequestCloseParams, ResolveMarketParams, SelfCancelCloseParams, SelfCancelOrderParams, } from "./prediction.ts";
|
|
13
|
+
export { adminPlaceOrderFor, batchClaim, batchForceClaim, buildBatchForceClaimTransactions, cancelClose, cancelOrder, claim, confirmClose, fillOrder, forceClaim, outcomeArg, placeOrder, requestClose, requestPartialClose, resolveMarket, selectionArg, selfCancelClose, selfCancelOrder, splitPosition, transferPosition, } from "./prediction.ts";
|
|
14
|
+
export type { AdminPlaceOrderForParams, BatchClaimParams, BatchForceClaimParams, BuildBatchForceClaimTransactionsParams, CancelCloseParams, CancelOrderParams, ClaimParams, ConfirmCloseParams, FillOrderParams, ForceClaimParams, PlaceOrderParams, RequestCloseParams, RequestPartialCloseParams, ResolveMarketParams, SelfCancelCloseParams, SelfCancelOrderParams, SplitPositionParams, TransferPositionParams, } from "./prediction.ts";
|
|
15
15
|
export { buildBatchClaimTx, buildPlaceOrderTx } from "./tx-builders.ts";
|
|
16
16
|
export type { BuildBatchClaimTxParams, BuildPlaceOrderTxParams, PredictCommonBuildOpts, } from "./tx-builders.ts";
|
|
17
17
|
export { getAccountData, getAccountIds, getAccountOrderIds, getAccountOrderIdsByMarketId, getAccountPositionIds, getAccountPositionIdsByMarketId, getKeeperAddresses, getAllowedVersions, getMarketExposure, getMarketExposureByKey, getMarketById, getMarketByKey, getOrder, getOrderCursor, getPosition, getPositionCursor, getRegistry, getResolvedMarketCursor, getUnresolvedMarketCursor, isKeeper, isPredictionProtocolAssetAllowed, } from "./fetch.ts";
|
|
18
18
|
export type { GetAccountIdsParams, ViewBaseParams } from "./fetch.ts";
|
|
19
19
|
export { base64UrlNoPadDecode, base64UrlNoPadEncode, buildClaimShareFlow, buildCreateGiftFlow, buildGiftClaimMessage, claimShare, createGift, deleteGift, deriveGiftAddress, deriveGiftKeypair, encodeGiftUrl, generateGiftSeed, getCreatorGiftCount, getCreatorGiftIds, getGift, getGiftConfigPaused, getGiftControllerAddress, getGiftHasClaimed, parseGiftUrl, signGiftClaim, } from "./gift.ts";
|
|
20
20
|
export type { BuildClaimShareFlowParams, BuildClaimShareFlowResult, BuildCreateGiftFlowResult, ClaimShareParams, CreateGiftParams, DeleteGiftParams, GiftBaseParams, GiftReferralParams, GiftUrlParts, GiftView, } from "./gift.ts";
|
|
21
|
-
export * as bucketFrameworkAccountCalls from "
|
|
22
|
-
export * as waterxAccountCalls from "
|
|
23
|
-
export * as predictionAccountDataCalls from "
|
|
24
|
-
export * as predictionGlobalConfigCalls from "
|
|
25
|
-
export * as predictionOutcomeCalls from "
|
|
26
|
-
export * as predictionPositionCalls from "
|
|
27
|
-
export * as predictionVersionCalls from "
|
|
28
|
-
export * as predictionViewCalls from "
|
|
29
|
-
export * as predictionCalls from "
|
|
21
|
+
export * as bucketFrameworkAccountCalls from "../generated/bucket_v2_framework/account.ts";
|
|
22
|
+
export * as waterxAccountCalls from "../generated/waterx_account/account.ts";
|
|
23
|
+
export * as predictionAccountDataCalls from "../generated/waterx_prediction/account_data.ts";
|
|
24
|
+
export * as predictionGlobalConfigCalls from "../generated/waterx_prediction/global_config.ts";
|
|
25
|
+
export * as predictionOutcomeCalls from "../generated/waterx_prediction/outcome.ts";
|
|
26
|
+
export * as predictionPositionCalls from "../generated/waterx_prediction/position.ts";
|
|
27
|
+
export * as predictionVersionCalls from "../generated/waterx_prediction/version.ts";
|
|
28
|
+
export * as predictionViewCalls from "../generated/waterx_prediction/view.ts";
|
|
29
|
+
export * as predictionCalls from "../generated/waterx_prediction/waterx_prediction.ts";
|
|
@@ -6,16 +6,16 @@ export * as user from "./user/index.js";
|
|
|
6
6
|
export * as utils from "./utils/index.js";
|
|
7
7
|
export { addDelegate, allowPredictionProtocolAsset, consumeDepositDirect, consumeWithdrawDirect, createAccount, deposit, disallowPredictionProtocolAsset, removeDelegate, resolveRegistryAccountId, requestDeposit, requestDepositFromReceivings, requestWithdraw, setDelegatePredictionPermission, transferCoinToAccount, whitelistPredictionProtocol, withdraw, } from "./account.js";
|
|
8
8
|
export { addKeeper, adminWithdraw, createMarketRegistry, depositSettlement, pauseMarket, removeKeeper, setMinReserve, setOrderCancelCooldownMs, unpauseMarket, } from "./admin.js";
|
|
9
|
-
export { adminPlaceOrderFor, batchClaim, batchForceClaim, buildBatchForceClaimTransactions, cancelClose, cancelOrder, claim, confirmClose, fillOrder, forceClaim, outcomeArg, placeOrder, requestClose, resolveMarket, selectionArg, selfCancelClose, selfCancelOrder, } from "./prediction.js";
|
|
9
|
+
export { adminPlaceOrderFor, batchClaim, batchForceClaim, buildBatchForceClaimTransactions, cancelClose, cancelOrder, claim, confirmClose, fillOrder, forceClaim, outcomeArg, placeOrder, requestClose, requestPartialClose, resolveMarket, selectionArg, selfCancelClose, selfCancelOrder, splitPosition, transferPosition, } from "./prediction.js";
|
|
10
10
|
export { buildBatchClaimTx, buildPlaceOrderTx } from "./tx-builders.js";
|
|
11
11
|
export { getAccountData, getAccountIds, getAccountOrderIds, getAccountOrderIdsByMarketId, getAccountPositionIds, getAccountPositionIdsByMarketId, getKeeperAddresses, getAllowedVersions, getMarketExposure, getMarketExposureByKey, getMarketById, getMarketByKey, getOrder, getOrderCursor, getPosition, getPositionCursor, getRegistry, getResolvedMarketCursor, getUnresolvedMarketCursor, isKeeper, isPredictionProtocolAssetAllowed, } from "./fetch.js";
|
|
12
12
|
export { base64UrlNoPadDecode, base64UrlNoPadEncode, buildClaimShareFlow, buildCreateGiftFlow, buildGiftClaimMessage, claimShare, createGift, deleteGift, deriveGiftAddress, deriveGiftKeypair, encodeGiftUrl, generateGiftSeed, getCreatorGiftCount, getCreatorGiftIds, getGift, getGiftConfigPaused, getGiftControllerAddress, getGiftHasClaimed, parseGiftUrl, signGiftClaim, } from "./gift.js";
|
|
13
|
-
export * as bucketFrameworkAccountCalls from "
|
|
14
|
-
export * as waterxAccountCalls from "
|
|
15
|
-
export * as predictionAccountDataCalls from "
|
|
16
|
-
export * as predictionGlobalConfigCalls from "
|
|
17
|
-
export * as predictionOutcomeCalls from "
|
|
18
|
-
export * as predictionPositionCalls from "
|
|
19
|
-
export * as predictionVersionCalls from "
|
|
20
|
-
export * as predictionViewCalls from "
|
|
21
|
-
export * as predictionCalls from "
|
|
13
|
+
export * as bucketFrameworkAccountCalls from "../generated/bucket_v2_framework/account.js";
|
|
14
|
+
export * as waterxAccountCalls from "../generated/waterx_account/account.js";
|
|
15
|
+
export * as predictionAccountDataCalls from "../generated/waterx_prediction/account_data.js";
|
|
16
|
+
export * as predictionGlobalConfigCalls from "../generated/waterx_prediction/global_config.js";
|
|
17
|
+
export * as predictionOutcomeCalls from "../generated/waterx_prediction/outcome.js";
|
|
18
|
+
export * as predictionPositionCalls from "../generated/waterx_prediction/position.js";
|
|
19
|
+
export * as predictionVersionCalls from "../generated/waterx_prediction/version.js";
|
|
20
|
+
export * as predictionViewCalls from "../generated/waterx_prediction/view.js";
|
|
21
|
+
export * as predictionCalls from "../generated/waterx_prediction/waterx_prediction.js";
|