@mysten/deepbook-v3 2.0.0 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +100 -0
- package/PREDICT.md +256 -0
- package/README.md +116 -0
- package/dist/account.d.mts +139 -0
- package/dist/account.d.mts.map +1 -0
- package/dist/account.mjs +181 -0
- package/dist/account.mjs.map +1 -0
- package/dist/bcs/integers.mjs +23 -0
- package/dist/bcs/integers.mjs.map +1 -0
- package/dist/contracts/account/account.d.mts +382 -0
- package/dist/contracts/account/account.d.mts.map +1 -0
- package/dist/contracts/account/account.mjs +443 -0
- package/dist/contracts/account/account.mjs.map +1 -0
- package/dist/contracts/account/account_events.d.mts +41 -0
- package/dist/contracts/account/account_events.d.mts.map +1 -0
- package/dist/contracts/account/account_events.mjs +72 -0
- package/dist/contracts/account/account_events.mjs.map +1 -0
- package/dist/contracts/account/account_registry.d.mts +210 -0
- package/dist/contracts/account/account_registry.d.mts.map +1 -0
- package/dist/contracts/account/account_registry.mjs +263 -0
- package/dist/contracts/account/account_registry.mjs.map +1 -0
- package/dist/contracts/account/config-arguments.d.mts +10 -0
- package/dist/contracts/account/config-arguments.d.mts.map +1 -0
- package/dist/contracts/account/deps/sui/bag.mjs +44 -0
- package/dist/contracts/account/deps/sui/bag.mjs.map +1 -0
- package/dist/contracts/deepbook/account.d.mts +18 -18
- package/dist/contracts/deepbook/balance_manager.mjs.map +1 -1
- package/dist/contracts/deepbook/balances.d.mts +4 -4
- package/dist/contracts/deepbook/balances.d.mts.map +1 -1
- package/dist/contracts/deepbook/deep_price.d.mts +3 -3
- package/dist/contracts/deepbook/deep_price.d.mts.map +1 -1
- package/dist/contracts/deepbook/order.d.mts +12 -12
- package/dist/contracts/deepbook/pool.mjs.map +1 -1
- package/dist/contracts/deepbook/registry.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/margin_manager.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/margin_manager_upgraded.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/margin_pool.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/margin_registry.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/pool_proxy.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/protocol_config.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/tpsl.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/builder_code_events.mjs +38 -0
- package/dist/contracts/deepbook_predict/builder_code_events.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/config-arguments.d.mts +13 -0
- package/dist/contracts/deepbook_predict/config-arguments.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/deps/fixed_math/i64.mjs +25 -0
- package/dist/contracts/deepbook_predict/deps/fixed_math/i64.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/deps/sui/balance.mjs +25 -0
- package/dist/contracts/deepbook_predict/deps/sui/balance.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/deps/sui/coin.mjs +24 -0
- package/dist/contracts/deepbook_predict/deps/sui/coin.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/deps/sui/table.mjs +39 -0
- package/dist/contracts/deepbook_predict/deps/sui/table.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/deps/sui/vec_set.mjs +26 -0
- package/dist/contracts/deepbook_predict/deps/sui/vec_set.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/ewma.mjs +29 -0
- package/dist/contracts/deepbook_predict/ewma.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/expiry_cash.mjs +27 -0
- package/dist/contracts/deepbook_predict/expiry_cash.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/expiry_market.mjs +367 -0
- package/dist/contracts/deepbook_predict/expiry_market.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/lp_book.mjs +92 -0
- package/dist/contracts/deepbook_predict/lp_book.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/market_manager.mjs +59 -0
- package/dist/contracts/deepbook_predict/market_manager.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/order.mjs +26 -0
- package/dist/contracts/deepbook_predict/order.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/order_events.mjs +84 -0
- package/dist/contracts/deepbook_predict/order_events.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/plp.mjs +284 -0
- package/dist/contracts/deepbook_predict/plp.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/pool_accounting.mjs +58 -0
- package/dist/contracts/deepbook_predict/pool_accounting.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/predict_account.mjs +106 -0
- package/dist/contracts/deepbook_predict/predict_account.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/pricing.mjs +80 -0
- package/dist/contracts/deepbook_predict/pricing.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/range_codec.mjs +41 -0
- package/dist/contracts/deepbook_predict/range_codec.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/registry.mjs +55 -0
- package/dist/contracts/deepbook_predict/registry.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/strike_exposure.mjs +65 -0
- package/dist/contracts/deepbook_predict/strike_exposure.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/strike_exposure_config.mjs +33 -0
- package/dist/contracts/deepbook_predict/strike_exposure_config.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/strike_payout_tree.mjs +72 -0
- package/dist/contracts/deepbook_predict/strike_payout_tree.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/vault_events.mjs +184 -0
- package/dist/contracts/deepbook_predict/vault_events.mjs.map +1 -0
- package/dist/contracts/deepbook_sessions/config-arguments.d.mts +10 -0
- package/dist/contracts/deepbook_sessions/config-arguments.d.mts.map +1 -0
- package/dist/contracts/deepbook_sessions/deps/sui/vec_map.mjs +37 -0
- package/dist/contracts/deepbook_sessions/deps/sui/vec_map.mjs.map +1 -0
- package/dist/contracts/deepbook_sessions/session_config.d.mts +63 -0
- package/dist/contracts/deepbook_sessions/session_config.d.mts.map +1 -0
- package/dist/contracts/deepbook_sessions/session_config.mjs +82 -0
- package/dist/contracts/deepbook_sessions/session_config.mjs.map +1 -0
- package/dist/contracts/deepbook_sessions/sessions.d.mts +275 -0
- package/dist/contracts/deepbook_sessions/sessions.d.mts.map +1 -0
- package/dist/contracts/deepbook_sessions/sessions.mjs +443 -0
- package/dist/contracts/deepbook_sessions/sessions.mjs.map +1 -0
- package/dist/contracts/margin_liquidation/liquidation_vault.mjs.map +1 -1
- package/dist/contracts/utils/index.d.mts +18 -1
- package/dist/contracts/utils/index.d.mts.map +1 -1
- package/dist/deployments/index.d.mts +31 -0
- package/dist/deployments/index.d.mts.map +1 -0
- package/dist/deployments/index.mjs +30 -0
- package/dist/deployments/index.mjs.map +1 -0
- package/dist/deployments/testnet.d.mts +14 -0
- package/dist/deployments/testnet.d.mts.map +1 -0
- package/dist/deployments/testnet.mjs +73 -0
- package/dist/deployments/testnet.mjs.map +1 -0
- package/dist/deployments/types.d.mts +36 -0
- package/dist/deployments/types.d.mts.map +1 -0
- package/dist/index.mjs +0 -1
- package/dist/predict/client.d.mts +255 -0
- package/dist/predict/client.d.mts.map +1 -0
- package/dist/predict/client.mjs +436 -0
- package/dist/predict/client.mjs.map +1 -0
- package/dist/predict/config/generated.d.mts +29 -0
- package/dist/predict/config/generated.d.mts.map +1 -0
- package/dist/predict/config/generated.mjs +16 -0
- package/dist/predict/config/generated.mjs.map +1 -0
- package/dist/predict/config/index.d.mts +10 -0
- package/dist/predict/config/index.d.mts.map +1 -0
- package/dist/predict/config/index.mjs +13 -0
- package/dist/predict/config/index.mjs.map +1 -0
- package/dist/predict/config/testnet.d.mts +17 -0
- package/dist/predict/config/testnet.d.mts.map +1 -0
- package/dist/predict/config/testnet.mjs +26 -0
- package/dist/predict/config/testnet.mjs.map +1 -0
- package/dist/predict/config/types.d.mts +55 -0
- package/dist/predict/config/types.d.mts.map +1 -0
- package/dist/predict/decode.d.mts +162 -0
- package/dist/predict/decode.d.mts.map +1 -0
- package/dist/predict/decode.mjs +175 -0
- package/dist/predict/decode.mjs.map +1 -0
- package/dist/predict/errors.d.mts +42 -0
- package/dist/predict/errors.d.mts.map +1 -0
- package/dist/predict/errors.mjs +37 -0
- package/dist/predict/errors.mjs.map +1 -0
- package/dist/predict/index.d.mts +18 -0
- package/dist/predict/index.mjs +14 -0
- package/dist/predict/pricing.d.mts +73 -0
- package/dist/predict/pricing.d.mts.map +1 -0
- package/dist/predict/pricing.mjs +129 -0
- package/dist/predict/pricing.mjs.map +1 -0
- package/dist/predict/reads/balances.mjs +41 -0
- package/dist/predict/reads/balances.mjs.map +1 -0
- package/dist/predict/reads/inspect.d.mts +8 -0
- package/dist/predict/reads/inspect.d.mts.map +1 -0
- package/dist/predict/reads/inspect.mjs +37 -0
- package/dist/predict/reads/inspect.mjs.map +1 -0
- package/dist/predict/reads/markets.mjs +130 -0
- package/dist/predict/reads/markets.mjs.map +1 -0
- package/dist/predict/reads/parse.mjs +20 -0
- package/dist/predict/reads/parse.mjs.map +1 -0
- package/dist/predict/reads/pool.mjs +26 -0
- package/dist/predict/reads/pool.mjs.map +1 -0
- package/dist/predict/reads/positions.d.mts +12 -0
- package/dist/predict/reads/positions.d.mts.map +1 -0
- package/dist/predict/reads/positions.mjs +77 -0
- package/dist/predict/reads/positions.mjs.map +1 -0
- package/dist/predict/reads/pricing.d.mts +20 -0
- package/dist/predict/reads/pricing.d.mts.map +1 -0
- package/dist/predict/reads/pricing.mjs +43 -0
- package/dist/predict/reads/pricing.mjs.map +1 -0
- package/dist/predict/ticks.d.mts +11 -0
- package/dist/predict/ticks.d.mts.map +1 -0
- package/dist/predict/ticks.mjs +21 -0
- package/dist/predict/ticks.mjs.map +1 -0
- package/dist/predict/tx/authed.mjs +18 -0
- package/dist/predict/tx/authed.mjs.map +1 -0
- package/dist/predict/tx/common.d.mts +18 -0
- package/dist/predict/tx/common.d.mts.map +1 -0
- package/dist/predict/tx/common.mjs +52 -0
- package/dist/predict/tx/common.mjs.map +1 -0
- package/dist/predict/tx/trade.d.mts +15 -0
- package/dist/predict/tx/trade.d.mts.map +1 -0
- package/dist/predict/tx/trade.mjs +86 -0
- package/dist/predict/tx/trade.mjs.map +1 -0
- package/dist/predict/units.d.mts +11 -0
- package/dist/predict/units.d.mts.map +1 -0
- package/dist/predict/units.mjs +44 -0
- package/dist/predict/units.mjs.map +1 -0
- package/dist/queries/accountQueries.mjs +0 -1
- package/dist/queries/accountQueries.mjs.map +1 -1
- package/dist/queries/orderQueries.mjs +0 -1
- package/dist/queries/orderQueries.mjs.map +1 -1
- package/dist/queries/registryQueries.mjs +0 -1
- package/dist/queries/registryQueries.mjs.map +1 -1
- package/dist/sessions.d.mts +244 -0
- package/dist/sessions.d.mts.map +1 -0
- package/dist/sessions.mjs +291 -0
- package/dist/sessions.mjs.map +1 -0
- package/dist/transactions/balanceManager.d.mts +12 -12
- package/dist/transactions/deepbook.d.mts +20 -20
- package/dist/transactions/deepbookAdmin.d.mts +4 -4
- package/dist/transactions/deepbookAdmin.d.mts.map +1 -1
- package/dist/transactions/marginAdmin.d.mts +7 -7
- package/dist/transactions/marginLiquidations.d.mts +3 -3
- package/dist/transactions/marginMaintainer.d.mts +5 -5
- package/dist/transactions/marginManager.d.mts +32 -32
- package/dist/transactions/marginPool.d.mts +18 -18
- package/dist/transactions/marginRegistry.d.mts +16 -16
- package/dist/transactions/marginTPSL.d.mts +10 -10
- package/dist/transactions/poolProxy.d.mts +8 -8
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/utils/constants.d.mts.map +1 -1
- package/dist/utils/constants.mjs +1 -1
- package/dist/utils/constants.mjs.map +1 -1
- package/package.json +33 -12
- package/src/account.ts +239 -0
- package/src/bcs/integers.ts +35 -0
- package/src/contracts/account/account.ts +706 -0
- package/src/contracts/account/account_events.ts +64 -0
- package/src/contracts/account/account_registry.ts +468 -0
- package/src/contracts/account/config-arguments.ts +8 -0
- package/src/contracts/account/deps/sui/bag.ts +42 -0
- package/src/contracts/deepbook/balance_manager.ts +1 -2
- package/src/contracts/deepbook/pool.ts +12 -24
- package/src/contracts/deepbook/registry.ts +1 -2
- package/src/contracts/deepbook_margin/margin_manager.ts +9 -18
- package/src/contracts/deepbook_margin/margin_manager_upgraded.ts +5 -10
- package/src/contracts/deepbook_margin/margin_pool.ts +2 -4
- package/src/contracts/deepbook_margin/margin_registry.ts +3 -6
- package/src/contracts/deepbook_margin/pool_proxy.ts +3 -6
- package/src/contracts/deepbook_margin/protocol_config.ts +1 -2
- package/src/contracts/deepbook_margin/tpsl.ts +1 -2
- package/src/contracts/deepbook_predict/admin.ts +44 -0
- package/src/contracts/deepbook_predict/builder_code.ts +155 -0
- package/src/contracts/deepbook_predict/builder_code_events.ts +34 -0
- package/src/contracts/deepbook_predict/config-arguments.ts +11 -0
- package/src/contracts/deepbook_predict/config_events.ts +140 -0
- package/src/contracts/deepbook_predict/deps/fixed_math/i64.ts +21 -0
- package/src/contracts/deepbook_predict/deps/sui/balance.ts +25 -0
- package/src/contracts/deepbook_predict/deps/sui/coin.ts +20 -0
- package/src/contracts/deepbook_predict/deps/sui/table.ts +37 -0
- package/src/contracts/deepbook_predict/deps/sui/vec_set.ts +22 -0
- package/src/contracts/deepbook_predict/ewma.ts +26 -0
- package/src/contracts/deepbook_predict/ewma_config.ts +28 -0
- package/src/contracts/deepbook_predict/expiry_cash.ts +24 -0
- package/src/contracts/deepbook_predict/expiry_market.ts +1549 -0
- package/src/contracts/deepbook_predict/lp_book.ts +105 -0
- package/src/contracts/deepbook_predict/market_lifecycle_cap.ts +75 -0
- package/src/contracts/deepbook_predict/market_manager.ts +218 -0
- package/src/contracts/deepbook_predict/order.ts +24 -0
- package/src/contracts/deepbook_predict/order_events.ts +129 -0
- package/src/contracts/deepbook_predict/pause_cap.ts +68 -0
- package/src/contracts/deepbook_predict/plp.ts +987 -0
- package/src/contracts/deepbook_predict/pool_accounting.ts +79 -0
- package/src/contracts/deepbook_predict/predict_account.ts +180 -0
- package/src/contracts/deepbook_predict/pricing.ts +124 -0
- package/src/contracts/deepbook_predict/pricing_config.ts +41 -0
- package/src/contracts/deepbook_predict/protocol_config.ts +1066 -0
- package/src/contracts/deepbook_predict/range_codec.ts +53 -0
- package/src/contracts/deepbook_predict/registry.ts +694 -0
- package/src/contracts/deepbook_predict/strike_exposure.ts +77 -0
- package/src/contracts/deepbook_predict/strike_exposure_config.ts +46 -0
- package/src/contracts/deepbook_predict/strike_payout_tree.ts +89 -0
- package/src/contracts/deepbook_predict/vault_events.ts +222 -0
- package/src/contracts/deepbook_sessions/config-arguments.ts +8 -0
- package/src/contracts/deepbook_sessions/deps/sui/vec_map.ts +33 -0
- package/src/contracts/deepbook_sessions/session_config.ts +130 -0
- package/src/contracts/deepbook_sessions/sessions.ts +663 -0
- package/src/contracts/margin_liquidation/liquidation_vault.ts +2 -4
- package/src/contracts/propbook/block_scholes_store.ts +842 -0
- package/src/contracts/propbook/deps/sui/table.ts +37 -0
- package/src/contracts/propbook/oracle_lane.ts +170 -0
- package/src/contracts/propbook/pyth_feed.ts +414 -0
- package/src/contracts/propbook/registry.ts +596 -0
- package/src/contracts/pyth/pyth.ts +2 -4
- package/src/deployments/index.ts +73 -0
- package/src/deployments/testnet.ts +107 -0
- package/src/deployments/types.ts +81 -0
- package/src/index.ts +5 -0
- package/src/predict/client.ts +941 -0
- package/src/predict/config/generated.ts +39 -0
- package/src/predict/config/index.ts +25 -0
- package/src/predict/config/testnet.ts +27 -0
- package/src/predict/config/types.ts +52 -0
- package/src/predict/decode.ts +476 -0
- package/src/predict/errors.ts +83 -0
- package/src/predict/index.ts +94 -0
- package/src/predict/pricing.ts +199 -0
- package/src/predict/reads/balances.ts +55 -0
- package/src/predict/reads/inspect.ts +78 -0
- package/src/predict/reads/markets.ts +222 -0
- package/src/predict/reads/parse.ts +30 -0
- package/src/predict/reads/pool.ts +37 -0
- package/src/predict/reads/positions.ts +144 -0
- package/src/predict/reads/pricing.ts +79 -0
- package/src/predict/ticks.ts +42 -0
- package/src/predict/tx/authed.ts +20 -0
- package/src/predict/tx/common.ts +92 -0
- package/src/predict/tx/trade.ts +183 -0
- package/src/predict/units.ts +49 -0
- package/src/sessions.ts +471 -0
- package/src/types/index.ts +1 -2
- package/src/utils/constants.ts +1 -7
- package/dist/types/bcs.mjs +0 -7
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Defines canonical-account lifecycle, app-authorization, and per-coin custody
|
|
7
|
+
* events. `account_registry` emits creation and authorization transitions;
|
|
8
|
+
* `account` emits balance transitions.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { MoveStruct } from '../utils/index.js';
|
|
12
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
13
|
+
import { U64 } from '../../bcs/integers.js';
|
|
14
|
+
const $moduleName = '@local-pkg/account::account_events';
|
|
15
|
+
export const AccountCreated = new MoveStruct({
|
|
16
|
+
name: `${$moduleName}::AccountCreated`,
|
|
17
|
+
fields: {
|
|
18
|
+
account_id: bcs.Address,
|
|
19
|
+
wrapper_id: bcs.Address,
|
|
20
|
+
owner: bcs.Address,
|
|
21
|
+
self_owned: bcs.bool(),
|
|
22
|
+
referrer_account_id: bcs.option(bcs.Address),
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
export const AppAuthorized = new MoveStruct({
|
|
26
|
+
name: `${$moduleName}::AppAuthorized`,
|
|
27
|
+
fields: {
|
|
28
|
+
/** Fully-qualified `App` witness type name. */
|
|
29
|
+
app: bcs.string(),
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
export const AppDeauthorized = new MoveStruct({
|
|
33
|
+
name: `${$moduleName}::AppDeauthorized`,
|
|
34
|
+
fields: {
|
|
35
|
+
app: bcs.string(),
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
export const Deposited = new MoveStruct({
|
|
39
|
+
name: `${$moduleName}::Deposited`,
|
|
40
|
+
fields: {
|
|
41
|
+
account_id: bcs.Address,
|
|
42
|
+
coin_type: bcs.string(),
|
|
43
|
+
amount: U64,
|
|
44
|
+
new_balance: U64,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
export const Withdrawn = new MoveStruct({
|
|
48
|
+
name: `${$moduleName}::Withdrawn`,
|
|
49
|
+
fields: {
|
|
50
|
+
account_id: bcs.Address,
|
|
51
|
+
coin_type: bcs.string(),
|
|
52
|
+
amount: U64,
|
|
53
|
+
new_balance: U64,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
export const FundsSettled = new MoveStruct({
|
|
57
|
+
name: `${$moduleName}::FundsSettled`,
|
|
58
|
+
fields: {
|
|
59
|
+
account_id: bcs.Address,
|
|
60
|
+
coin_type: bcs.string(),
|
|
61
|
+
amount: U64,
|
|
62
|
+
new_balance: U64,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Owns the derivation root for canonical accounts and the global whitelist of
|
|
7
|
+
* application witness types. App authorization is package-wide rather than
|
|
8
|
+
* per-account: an authorized app can request full mutable authority for any
|
|
9
|
+
* account wrapper supplied to its flow. `account::account` owns wrapper
|
|
10
|
+
* construction, custody, accumulator settlement, and app-data invariants.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
MoveStruct,
|
|
15
|
+
MoveTuple,
|
|
16
|
+
normalizeMoveArguments,
|
|
17
|
+
type RawTransactionArgument,
|
|
18
|
+
type ConfigValue,
|
|
19
|
+
} from '../utils/index.js';
|
|
20
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
21
|
+
import { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';
|
|
22
|
+
const $moduleName = '@local-pkg/account::account_registry';
|
|
23
|
+
export const AccountAdminCap = new MoveStruct({
|
|
24
|
+
name: `${$moduleName}::AccountAdminCap`,
|
|
25
|
+
fields: {
|
|
26
|
+
id: bcs.Address,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
export const AccountRegistry = new MoveStruct({
|
|
30
|
+
name: `${$moduleName}::AccountRegistry`,
|
|
31
|
+
fields: {
|
|
32
|
+
id: bcs.Address,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
export const AccountKey = new MoveTuple({
|
|
36
|
+
name: `${$moduleName}::AccountKey`,
|
|
37
|
+
fields: [bcs.Address],
|
|
38
|
+
});
|
|
39
|
+
export const AccountWrapperKey = new MoveTuple({
|
|
40
|
+
name: `${$moduleName}::AccountWrapperKey`,
|
|
41
|
+
fields: [bcs.Address],
|
|
42
|
+
});
|
|
43
|
+
export const AppKey = new MoveTuple({
|
|
44
|
+
name: `${$moduleName}::AppKey<phantom App>`,
|
|
45
|
+
fields: [bcs.bool()],
|
|
46
|
+
});
|
|
47
|
+
export interface DerivedAddressArguments {
|
|
48
|
+
registry?: RawTransactionArgument<string>;
|
|
49
|
+
owner: RawTransactionArgument<string>;
|
|
50
|
+
}
|
|
51
|
+
export interface DerivedAddressOptions {
|
|
52
|
+
package?: string;
|
|
53
|
+
arguments: DerivedAddressArguments;
|
|
54
|
+
config?: {
|
|
55
|
+
accountRegistry: ConfigValue;
|
|
56
|
+
accountPackageId?: string;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Returns the deterministic canonical account address for external discovery and
|
|
61
|
+
* PTB construction.
|
|
62
|
+
*/
|
|
63
|
+
export function derivedAddress(options: DerivedAddressOptions) {
|
|
64
|
+
const packageAddress =
|
|
65
|
+
options.package ?? options.config?.accountPackageId ?? '@local-pkg/account';
|
|
66
|
+
const argumentsTypes = [null, 'address'] satisfies (string | null)[];
|
|
67
|
+
const parameterNames = ['registry', 'owner'];
|
|
68
|
+
return (tx: Transaction) =>
|
|
69
|
+
tx.moveCall({
|
|
70
|
+
package: packageAddress,
|
|
71
|
+
module: 'account_registry',
|
|
72
|
+
function: 'derived_address',
|
|
73
|
+
arguments: normalizeMoveArguments(
|
|
74
|
+
{
|
|
75
|
+
...options.arguments,
|
|
76
|
+
registry: options.arguments?.registry ?? options.config?.accountRegistry,
|
|
77
|
+
},
|
|
78
|
+
argumentsTypes,
|
|
79
|
+
parameterNames,
|
|
80
|
+
),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
export interface DerivedWrapperAddressArguments {
|
|
84
|
+
registry?: RawTransactionArgument<string>;
|
|
85
|
+
owner: RawTransactionArgument<string>;
|
|
86
|
+
}
|
|
87
|
+
export interface DerivedWrapperAddressOptions {
|
|
88
|
+
package?: string;
|
|
89
|
+
arguments: DerivedWrapperAddressArguments;
|
|
90
|
+
config?: {
|
|
91
|
+
accountRegistry: ConfigValue;
|
|
92
|
+
accountPackageId?: string;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Returns the deterministic wrapper address for external discovery, accumulator
|
|
97
|
+
* delivery, and PTB construction.
|
|
98
|
+
*/
|
|
99
|
+
export function derivedWrapperAddress(options: DerivedWrapperAddressOptions) {
|
|
100
|
+
const packageAddress =
|
|
101
|
+
options.package ?? options.config?.accountPackageId ?? '@local-pkg/account';
|
|
102
|
+
const argumentsTypes = [null, 'address'] satisfies (string | null)[];
|
|
103
|
+
const parameterNames = ['registry', 'owner'];
|
|
104
|
+
return (tx: Transaction) =>
|
|
105
|
+
tx.moveCall({
|
|
106
|
+
package: packageAddress,
|
|
107
|
+
module: 'account_registry',
|
|
108
|
+
function: 'derived_wrapper_address',
|
|
109
|
+
arguments: normalizeMoveArguments(
|
|
110
|
+
{
|
|
111
|
+
...options.arguments,
|
|
112
|
+
registry: options.arguments?.registry ?? options.config?.accountRegistry,
|
|
113
|
+
},
|
|
114
|
+
argumentsTypes,
|
|
115
|
+
parameterNames,
|
|
116
|
+
),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
export interface DerivedExistsArguments {
|
|
120
|
+
registry?: RawTransactionArgument<string>;
|
|
121
|
+
owner: RawTransactionArgument<string>;
|
|
122
|
+
}
|
|
123
|
+
export interface DerivedExistsOptions {
|
|
124
|
+
package?: string;
|
|
125
|
+
arguments: DerivedExistsArguments;
|
|
126
|
+
config?: {
|
|
127
|
+
accountRegistry: ConfigValue;
|
|
128
|
+
accountPackageId?: string;
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/** Returns whether the canonical account identity has been claimed. */
|
|
132
|
+
export function derivedExists(options: DerivedExistsOptions) {
|
|
133
|
+
const packageAddress =
|
|
134
|
+
options.package ?? options.config?.accountPackageId ?? '@local-pkg/account';
|
|
135
|
+
const argumentsTypes = [null, 'address'] satisfies (string | null)[];
|
|
136
|
+
const parameterNames = ['registry', 'owner'];
|
|
137
|
+
return (tx: Transaction) =>
|
|
138
|
+
tx.moveCall({
|
|
139
|
+
package: packageAddress,
|
|
140
|
+
module: 'account_registry',
|
|
141
|
+
function: 'derived_exists',
|
|
142
|
+
arguments: normalizeMoveArguments(
|
|
143
|
+
{
|
|
144
|
+
...options.arguments,
|
|
145
|
+
registry: options.arguments?.registry ?? options.config?.accountRegistry,
|
|
146
|
+
},
|
|
147
|
+
argumentsTypes,
|
|
148
|
+
parameterNames,
|
|
149
|
+
),
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
export interface DerivedWrapperExistsArguments {
|
|
153
|
+
registry?: RawTransactionArgument<string>;
|
|
154
|
+
owner: RawTransactionArgument<string>;
|
|
155
|
+
}
|
|
156
|
+
export interface DerivedWrapperExistsOptions {
|
|
157
|
+
package?: string;
|
|
158
|
+
arguments: DerivedWrapperExistsArguments;
|
|
159
|
+
config?: {
|
|
160
|
+
accountRegistry: ConfigValue;
|
|
161
|
+
accountPackageId?: string;
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
/** Returns whether the canonical wrapper has been claimed. */
|
|
165
|
+
export function derivedWrapperExists(options: DerivedWrapperExistsOptions) {
|
|
166
|
+
const packageAddress =
|
|
167
|
+
options.package ?? options.config?.accountPackageId ?? '@local-pkg/account';
|
|
168
|
+
const argumentsTypes = [null, 'address'] satisfies (string | null)[];
|
|
169
|
+
const parameterNames = ['registry', 'owner'];
|
|
170
|
+
return (tx: Transaction) =>
|
|
171
|
+
tx.moveCall({
|
|
172
|
+
package: packageAddress,
|
|
173
|
+
module: 'account_registry',
|
|
174
|
+
function: 'derived_wrapper_exists',
|
|
175
|
+
arguments: normalizeMoveArguments(
|
|
176
|
+
{
|
|
177
|
+
...options.arguments,
|
|
178
|
+
registry: options.arguments?.registry ?? options.config?.accountRegistry,
|
|
179
|
+
},
|
|
180
|
+
argumentsTypes,
|
|
181
|
+
parameterNames,
|
|
182
|
+
),
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
export interface NewArguments {
|
|
186
|
+
registry?: RawTransactionArgument<string>;
|
|
187
|
+
}
|
|
188
|
+
export interface NewOptions {
|
|
189
|
+
package?: string;
|
|
190
|
+
arguments?: NewArguments;
|
|
191
|
+
config?: {
|
|
192
|
+
accountRegistry: ConfigValue;
|
|
193
|
+
accountPackageId?: string;
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Creates the sender's canonical account and wrapper, aborting if either derived
|
|
198
|
+
* ID is already claimed.
|
|
199
|
+
*/
|
|
200
|
+
export function _new(options: NewOptions) {
|
|
201
|
+
const packageAddress =
|
|
202
|
+
options.package ?? options.config?.accountPackageId ?? '@local-pkg/account';
|
|
203
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
204
|
+
const parameterNames = ['registry'];
|
|
205
|
+
return (tx: Transaction) =>
|
|
206
|
+
tx.moveCall({
|
|
207
|
+
package: packageAddress,
|
|
208
|
+
module: 'account_registry',
|
|
209
|
+
function: 'new',
|
|
210
|
+
arguments: normalizeMoveArguments(
|
|
211
|
+
{
|
|
212
|
+
...options.arguments,
|
|
213
|
+
registry: options.arguments?.registry ?? options.config?.accountRegistry,
|
|
214
|
+
},
|
|
215
|
+
argumentsTypes,
|
|
216
|
+
parameterNames,
|
|
217
|
+
),
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
export interface NewWithReferrerArguments {
|
|
221
|
+
registry?: RawTransactionArgument<string>;
|
|
222
|
+
referrer: RawTransactionArgument<string>;
|
|
223
|
+
}
|
|
224
|
+
export interface NewWithReferrerOptions {
|
|
225
|
+
package?: string;
|
|
226
|
+
arguments: NewWithReferrerArguments;
|
|
227
|
+
config?: {
|
|
228
|
+
accountRegistry: ConfigValue;
|
|
229
|
+
accountPackageId?: string;
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Creates the sender's canonical account and permanently records the supplied
|
|
234
|
+
* wrapper's account identity and receive address as its referrer.
|
|
235
|
+
*/
|
|
236
|
+
export function newWithReferrer(options: NewWithReferrerOptions) {
|
|
237
|
+
const packageAddress =
|
|
238
|
+
options.package ?? options.config?.accountPackageId ?? '@local-pkg/account';
|
|
239
|
+
const argumentsTypes = [null, null] satisfies (string | null)[];
|
|
240
|
+
const parameterNames = ['registry', 'referrer'];
|
|
241
|
+
return (tx: Transaction) =>
|
|
242
|
+
tx.moveCall({
|
|
243
|
+
package: packageAddress,
|
|
244
|
+
module: 'account_registry',
|
|
245
|
+
function: 'new_with_referrer',
|
|
246
|
+
arguments: normalizeMoveArguments(
|
|
247
|
+
{
|
|
248
|
+
...options.arguments,
|
|
249
|
+
registry: options.arguments?.registry ?? options.config?.accountRegistry,
|
|
250
|
+
},
|
|
251
|
+
argumentsTypes,
|
|
252
|
+
parameterNames,
|
|
253
|
+
),
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
export interface NewSelfOwnedArguments {
|
|
257
|
+
registry?: RawTransactionArgument<string>;
|
|
258
|
+
ownerUid: RawTransactionArgument<string>;
|
|
259
|
+
}
|
|
260
|
+
export interface NewSelfOwnedOptions {
|
|
261
|
+
package?: string;
|
|
262
|
+
arguments: NewSelfOwnedArguments;
|
|
263
|
+
config?: {
|
|
264
|
+
accountRegistry: ConfigValue;
|
|
265
|
+
accountPackageId?: string;
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Creates the canonical account owned by `owner_uid`'s object address, aborting if
|
|
270
|
+
* either derived ID is already claimed.
|
|
271
|
+
*/
|
|
272
|
+
export function newSelfOwned(options: NewSelfOwnedOptions) {
|
|
273
|
+
const packageAddress =
|
|
274
|
+
options.package ?? options.config?.accountPackageId ?? '@local-pkg/account';
|
|
275
|
+
const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[];
|
|
276
|
+
const parameterNames = ['registry', 'ownerUid'];
|
|
277
|
+
return (tx: Transaction) =>
|
|
278
|
+
tx.moveCall({
|
|
279
|
+
package: packageAddress,
|
|
280
|
+
module: 'account_registry',
|
|
281
|
+
function: 'new_self_owned',
|
|
282
|
+
arguments: normalizeMoveArguments(
|
|
283
|
+
{
|
|
284
|
+
...options.arguments,
|
|
285
|
+
registry: options.arguments?.registry ?? options.config?.accountRegistry,
|
|
286
|
+
},
|
|
287
|
+
argumentsTypes,
|
|
288
|
+
parameterNames,
|
|
289
|
+
),
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
export interface IsAppAuthorizedArguments {
|
|
293
|
+
registry?: RawTransactionArgument<string>;
|
|
294
|
+
}
|
|
295
|
+
export interface IsAppAuthorizedOptions {
|
|
296
|
+
package?: string;
|
|
297
|
+
arguments?: IsAppAuthorizedArguments;
|
|
298
|
+
config?: {
|
|
299
|
+
accountRegistry: ConfigValue;
|
|
300
|
+
accountPackageId?: string;
|
|
301
|
+
};
|
|
302
|
+
typeArguments: [string];
|
|
303
|
+
}
|
|
304
|
+
/** Returns whether `App` may request package-issued mutable account authority. */
|
|
305
|
+
export function isAppAuthorized(options: IsAppAuthorizedOptions) {
|
|
306
|
+
const packageAddress =
|
|
307
|
+
options.package ?? options.config?.accountPackageId ?? '@local-pkg/account';
|
|
308
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
309
|
+
const parameterNames = ['registry'];
|
|
310
|
+
return (tx: Transaction) =>
|
|
311
|
+
tx.moveCall({
|
|
312
|
+
package: packageAddress,
|
|
313
|
+
module: 'account_registry',
|
|
314
|
+
function: 'is_app_authorized',
|
|
315
|
+
arguments: normalizeMoveArguments(
|
|
316
|
+
{
|
|
317
|
+
...options.arguments,
|
|
318
|
+
registry: options.arguments?.registry ?? options.config?.accountRegistry,
|
|
319
|
+
},
|
|
320
|
+
argumentsTypes,
|
|
321
|
+
parameterNames,
|
|
322
|
+
),
|
|
323
|
+
typeArguments: options.typeArguments,
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
export interface AuthorizeAppArguments {
|
|
327
|
+
registry?: RawTransactionArgument<string>;
|
|
328
|
+
Cap: RawTransactionArgument<string>;
|
|
329
|
+
}
|
|
330
|
+
export interface AuthorizeAppOptions {
|
|
331
|
+
package?: string;
|
|
332
|
+
arguments: AuthorizeAppArguments;
|
|
333
|
+
config?: {
|
|
334
|
+
accountRegistry: ConfigValue;
|
|
335
|
+
accountPackageId?: string;
|
|
336
|
+
};
|
|
337
|
+
typeArguments: [string];
|
|
338
|
+
}
|
|
339
|
+
/** Globally authorizes `App` to request mutable authority for account wrappers. */
|
|
340
|
+
export function authorizeApp(options: AuthorizeAppOptions) {
|
|
341
|
+
const packageAddress =
|
|
342
|
+
options.package ?? options.config?.accountPackageId ?? '@local-pkg/account';
|
|
343
|
+
const argumentsTypes = [null, null] satisfies (string | null)[];
|
|
344
|
+
const parameterNames = ['registry', 'Cap'];
|
|
345
|
+
return (tx: Transaction) =>
|
|
346
|
+
tx.moveCall({
|
|
347
|
+
package: packageAddress,
|
|
348
|
+
module: 'account_registry',
|
|
349
|
+
function: 'authorize_app',
|
|
350
|
+
arguments: normalizeMoveArguments(
|
|
351
|
+
{
|
|
352
|
+
...options.arguments,
|
|
353
|
+
registry: options.arguments?.registry ?? options.config?.accountRegistry,
|
|
354
|
+
},
|
|
355
|
+
argumentsTypes,
|
|
356
|
+
parameterNames,
|
|
357
|
+
),
|
|
358
|
+
typeArguments: options.typeArguments,
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
export interface DeauthorizeAppArguments {
|
|
362
|
+
registry?: RawTransactionArgument<string>;
|
|
363
|
+
Cap: RawTransactionArgument<string>;
|
|
364
|
+
}
|
|
365
|
+
export interface DeauthorizeAppOptions {
|
|
366
|
+
package?: string;
|
|
367
|
+
arguments: DeauthorizeAppArguments;
|
|
368
|
+
config?: {
|
|
369
|
+
accountRegistry: ConfigValue;
|
|
370
|
+
accountPackageId?: string;
|
|
371
|
+
};
|
|
372
|
+
typeArguments: [string];
|
|
373
|
+
}
|
|
374
|
+
/** Revokes `App` from requesting new mutable account authority. */
|
|
375
|
+
export function deauthorizeApp(options: DeauthorizeAppOptions) {
|
|
376
|
+
const packageAddress =
|
|
377
|
+
options.package ?? options.config?.accountPackageId ?? '@local-pkg/account';
|
|
378
|
+
const argumentsTypes = [null, null] satisfies (string | null)[];
|
|
379
|
+
const parameterNames = ['registry', 'Cap'];
|
|
380
|
+
return (tx: Transaction) =>
|
|
381
|
+
tx.moveCall({
|
|
382
|
+
package: packageAddress,
|
|
383
|
+
module: 'account_registry',
|
|
384
|
+
function: 'deauthorize_app',
|
|
385
|
+
arguments: normalizeMoveArguments(
|
|
386
|
+
{
|
|
387
|
+
...options.arguments,
|
|
388
|
+
registry: options.arguments?.registry ?? options.config?.accountRegistry,
|
|
389
|
+
},
|
|
390
|
+
argumentsTypes,
|
|
391
|
+
parameterNames,
|
|
392
|
+
),
|
|
393
|
+
typeArguments: options.typeArguments,
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
export interface AssertAppIsAuthorizedArguments {
|
|
397
|
+
registry?: RawTransactionArgument<string>;
|
|
398
|
+
}
|
|
399
|
+
export interface AssertAppIsAuthorizedOptions {
|
|
400
|
+
package?: string;
|
|
401
|
+
arguments?: AssertAppIsAuthorizedArguments;
|
|
402
|
+
config?: {
|
|
403
|
+
accountRegistry: ConfigValue;
|
|
404
|
+
accountPackageId?: string;
|
|
405
|
+
};
|
|
406
|
+
typeArguments: [string];
|
|
407
|
+
}
|
|
408
|
+
/** Aborts unless `App` is currently authorized for app-driven account access. */
|
|
409
|
+
export function assertAppIsAuthorized(options: AssertAppIsAuthorizedOptions) {
|
|
410
|
+
const packageAddress =
|
|
411
|
+
options.package ?? options.config?.accountPackageId ?? '@local-pkg/account';
|
|
412
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
413
|
+
const parameterNames = ['registry'];
|
|
414
|
+
return (tx: Transaction) =>
|
|
415
|
+
tx.moveCall({
|
|
416
|
+
package: packageAddress,
|
|
417
|
+
module: 'account_registry',
|
|
418
|
+
function: 'assert_app_is_authorized',
|
|
419
|
+
arguments: normalizeMoveArguments(
|
|
420
|
+
{
|
|
421
|
+
...options.arguments,
|
|
422
|
+
registry: options.arguments?.registry ?? options.config?.accountRegistry,
|
|
423
|
+
},
|
|
424
|
+
argumentsTypes,
|
|
425
|
+
parameterNames,
|
|
426
|
+
),
|
|
427
|
+
typeArguments: options.typeArguments,
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
export interface GenerateAuthAsAppArguments {
|
|
431
|
+
registry?: RawTransactionArgument<string>;
|
|
432
|
+
Permit: TransactionArgument;
|
|
433
|
+
}
|
|
434
|
+
export interface GenerateAuthAsAppOptions {
|
|
435
|
+
package?: string;
|
|
436
|
+
arguments: GenerateAuthAsAppArguments;
|
|
437
|
+
config?: {
|
|
438
|
+
accountRegistry: ConfigValue;
|
|
439
|
+
accountPackageId?: string;
|
|
440
|
+
};
|
|
441
|
+
typeArguments: [string];
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Generates full mutable account authority after checking the global app
|
|
445
|
+
* whitelist. `Permit<App>` restricts the request to the module that defines `App`;
|
|
446
|
+
* the returned authority is not bound to an owner, wrapper, or operation.
|
|
447
|
+
*/
|
|
448
|
+
export function generateAuthAsApp(options: GenerateAuthAsAppOptions) {
|
|
449
|
+
const packageAddress =
|
|
450
|
+
options.package ?? options.config?.accountPackageId ?? '@local-pkg/account';
|
|
451
|
+
const argumentsTypes = [null, null] satisfies (string | null)[];
|
|
452
|
+
const parameterNames = ['registry', 'Permit'];
|
|
453
|
+
return (tx: Transaction) =>
|
|
454
|
+
tx.moveCall({
|
|
455
|
+
package: packageAddress,
|
|
456
|
+
module: 'account_registry',
|
|
457
|
+
function: 'generate_auth_as_app',
|
|
458
|
+
arguments: normalizeMoveArguments(
|
|
459
|
+
{
|
|
460
|
+
...options.arguments,
|
|
461
|
+
registry: options.arguments?.registry ?? options.config?.accountRegistry,
|
|
462
|
+
},
|
|
463
|
+
argumentsTypes,
|
|
464
|
+
parameterNames,
|
|
465
|
+
),
|
|
466
|
+
typeArguments: options.typeArguments,
|
|
467
|
+
});
|
|
468
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import { type ConfigValue } from '../utils/index.js';
|
|
5
|
+
export interface AccountConfig {
|
|
6
|
+
accountPackageId?: string;
|
|
7
|
+
accountRegistry: ConfigValue;
|
|
8
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A bag is a heterogeneous map-like collection. The collection is similar to
|
|
7
|
+
* `sui::table` in that its keys and values are not stored within the `Bag` value,
|
|
8
|
+
* but instead are stored using Sui's object system. The `Bag` struct acts only as
|
|
9
|
+
* a handle into the object system to retrieve those keys and values. Note that
|
|
10
|
+
* this means that `Bag` values with exactly the same key-value mapping will not be
|
|
11
|
+
* equal, with `==`, at runtime. For example
|
|
12
|
+
*
|
|
13
|
+
* ```
|
|
14
|
+
* let bag1 = bag::new();
|
|
15
|
+
* let bag2 = bag::new();
|
|
16
|
+
* bag::add(&mut bag1, 0, false);
|
|
17
|
+
* bag::add(&mut bag1, 1, true);
|
|
18
|
+
* bag::add(&mut bag2, 0, false);
|
|
19
|
+
* bag::add(&mut bag2, 1, true);
|
|
20
|
+
* // bag1 does not equal bag2, despite having the same entries
|
|
21
|
+
* assert!(&bag1 != &bag2);
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* At it's core, `sui::bag` is a wrapper around `UID` that allows for access to
|
|
25
|
+
* `sui::dynamic_field` while preventing accidentally stranding field values. A
|
|
26
|
+
* `UID` can be deleted, even if it has dynamic fields associated with it, but a
|
|
27
|
+
* bag, on the other hand, must be empty to be destroyed.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
import { MoveStruct } from '../../../utils/index.js';
|
|
31
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
32
|
+
import { U64 } from '../../../../bcs/integers.js';
|
|
33
|
+
const $moduleName = '0x2::bag';
|
|
34
|
+
export const Bag = new MoveStruct({
|
|
35
|
+
name: `${$moduleName}::Bag`,
|
|
36
|
+
fields: {
|
|
37
|
+
/** the ID of this bag */
|
|
38
|
+
id: bcs.Address,
|
|
39
|
+
/** the number of key-value pairs in the bag */
|
|
40
|
+
size: U64,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
@@ -239,8 +239,7 @@ export function newWithCustomOwnerCapsV2<App extends BcsType<any>>(
|
|
|
239
239
|
) {
|
|
240
240
|
const packageAddress = options.package ?? '@deepbook/core';
|
|
241
241
|
const argumentsTypes = [`${options.typeArguments[0]}`, null, 'address'] satisfies (
|
|
242
|
-
|
|
|
243
|
-
| null
|
|
242
|
+
string | null
|
|
244
243
|
)[];
|
|
245
244
|
const parameterNames = ['Witness', 'deepbookRegistry', 'owner'];
|
|
246
245
|
return (tx: Transaction) =>
|