@mysten/kiosk 0.14.5 → 1.0.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/CHANGELOG.md +112 -2
- package/dist/client/kiosk-client.d.mts +126 -0
- package/dist/client/kiosk-client.d.mts.map +1 -0
- package/dist/client/kiosk-client.mjs +124 -0
- package/dist/client/kiosk-client.mjs.map +1 -0
- package/dist/client/kiosk-transaction.d.mts +236 -0
- package/dist/client/kiosk-transaction.d.mts.map +1 -0
- package/dist/client/kiosk-transaction.mjs +472 -0
- package/dist/client/kiosk-transaction.mjs.map +1 -0
- package/dist/client/tp-transaction.d.mts +139 -0
- package/dist/client/tp-transaction.d.mts.map +1 -0
- package/dist/client/tp-transaction.mjs +273 -0
- package/dist/client/tp-transaction.mjs.map +1 -0
- package/dist/constants.d.mts +42 -0
- package/dist/constants.d.mts.map +1 -0
- package/dist/constants.mjs +62 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/contracts/0x2/bag.mjs +19 -0
- package/dist/contracts/0x2/bag.mjs.map +1 -0
- package/dist/contracts/0x2/balance.mjs +20 -0
- package/dist/contracts/0x2/balance.mjs.map +1 -0
- package/dist/contracts/0x2/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.mjs +16 -0
- package/dist/contracts/0x2/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.mjs.map +1 -0
- package/dist/contracts/0x2/kiosk.mjs +244 -0
- package/dist/contracts/0x2/kiosk.mjs.map +1 -0
- package/dist/contracts/0x2/kiosk_extension.mjs +25 -0
- package/dist/contracts/0x2/kiosk_extension.mjs.map +1 -0
- package/dist/contracts/0x2/transfer_policy.mjs +99 -0
- package/dist/contracts/0x2/transfer_policy.mjs.map +1 -0
- package/dist/contracts/0x2/vec_set.mjs +18 -0
- package/dist/contracts/0x2/vec_set.mjs.map +1 -0
- package/dist/contracts/kiosk/deps/sui/kiosk.mjs +98 -0
- package/dist/contracts/kiosk/deps/sui/kiosk.mjs.map +1 -0
- package/dist/contracts/kiosk/floor_price_rule.mjs +70 -0
- package/dist/contracts/kiosk/floor_price_rule.mjs.map +1 -0
- package/dist/contracts/kiosk/kiosk_lock_rule.mjs +72 -0
- package/dist/contracts/kiosk/kiosk_lock_rule.mjs.map +1 -0
- package/dist/contracts/kiosk/personal_kiosk.mjs +102 -0
- package/dist/contracts/kiosk/personal_kiosk.mjs.map +1 -0
- package/dist/contracts/kiosk/personal_kiosk_rule.mjs +66 -0
- package/dist/contracts/kiosk/personal_kiosk_rule.mjs.map +1 -0
- package/dist/contracts/kiosk/royalty_rule.mjs +115 -0
- package/dist/contracts/kiosk/royalty_rule.mjs.map +1 -0
- package/dist/contracts/utils/index.mjs +118 -0
- package/dist/contracts/utils/index.mjs.map +1 -0
- package/dist/index.d.mts +9 -0
- package/dist/index.mjs +9 -0
- package/dist/query/client-utils.mjs +30 -0
- package/dist/query/client-utils.mjs.map +1 -0
- package/dist/query/kiosk.mjs +154 -0
- package/dist/query/kiosk.mjs.map +1 -0
- package/dist/query/transfer-policy.mjs +110 -0
- package/dist/query/transfer-policy.mjs.map +1 -0
- package/dist/tx/kiosk.mjs +20 -0
- package/dist/tx/kiosk.mjs.map +1 -0
- package/dist/tx/rules/resolve.mjs +114 -0
- package/dist/tx/rules/resolve.mjs.map +1 -0
- package/dist/tx/transfer-policy.mjs +38 -0
- package/dist/tx/transfer-policy.mjs.map +1 -0
- package/dist/types/index.d.mts +23 -0
- package/dist/types/index.d.mts.map +1 -0
- package/dist/types/kiosk.d.mts +165 -0
- package/dist/types/kiosk.d.mts.map +1 -0
- package/dist/types/kiosk.mjs +21 -0
- package/dist/types/kiosk.mjs.map +1 -0
- package/dist/types/transfer-policy.d.mts +56 -0
- package/dist/types/transfer-policy.d.mts.map +1 -0
- package/dist/types/transfer-policy.mjs +19 -0
- package/dist/types/transfer-policy.mjs.map +1 -0
- package/dist/utils.d.mts +45 -0
- package/dist/utils.d.mts.map +1 -0
- package/dist/utils.mjs +156 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +31 -20
- package/src/client/kiosk-client.ts +42 -5
- package/src/client/kiosk-transaction.ts +144 -65
- package/src/client/tp-transaction.ts +149 -95
- package/src/constants.ts +19 -24
- package/src/contracts/0x2/accumulator.ts +24 -0
- package/src/contracts/0x2/accumulator_metadata.ts +38 -0
- package/src/contracts/0x2/accumulator_settlement.ts +14 -0
- package/src/contracts/0x2/address.ts +145 -0
- package/src/contracts/0x2/address_alias.ts +92 -0
- package/src/contracts/0x2/authenticator_state.ts +44 -0
- package/src/contracts/0x2/bag.ts +192 -0
- package/src/contracts/0x2/balance.ts +269 -0
- package/src/contracts/0x2/bcs.ts +495 -0
- package/src/contracts/0x2/bls12381.ts +717 -0
- package/src/contracts/0x2/borrow.ts +99 -0
- package/src/contracts/0x2/clock.ts +30 -0
- package/src/contracts/0x2/coin.ts +977 -0
- package/src/contracts/0x2/coin_registry.ts +874 -0
- package/src/contracts/0x2/config.ts +30 -0
- package/src/contracts/0x2/deny_list.ts +55 -0
- package/src/contracts/0x2/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.ts +12 -0
- package/src/contracts/0x2/derived_object.ts +95 -0
- package/src/contracts/0x2/display.ts +258 -0
- package/src/contracts/0x2/dynamic_field.ts +171 -0
- package/src/contracts/0x2/dynamic_object_field.ts +167 -0
- package/src/contracts/0x2/ecdsa_k1.ts +65 -0
- package/src/contracts/0x2/ecdsa_r1.ts +49 -0
- package/src/contracts/0x2/ecvrf.ts +29 -0
- package/src/contracts/0x2/ed25519.ts +25 -0
- package/src/contracts/0x2/event.ts +42 -0
- package/src/contracts/0x2/funds_accumulator.ts +86 -0
- package/src/contracts/0x2/groth16.ts +171 -0
- package/src/contracts/0x2/group_ops.ts +49 -0
- package/src/contracts/0x2/hash.ts +37 -0
- package/src/contracts/0x2/hex.ts +37 -0
- package/src/contracts/0x2/hmac.ts +21 -0
- package/src/contracts/0x2/kiosk.ts +797 -0
- package/src/contracts/0x2/kiosk_extension.ts +270 -0
- package/src/contracts/0x2/linked_table.ts +354 -0
- package/src/contracts/0x2/math.ts +117 -0
- package/src/contracts/0x2/nitro_attestation.ts +186 -0
- package/src/contracts/0x2/object.ts +249 -0
- package/src/contracts/0x2/object_bag.ts +210 -0
- package/src/contracts/0x2/object_table.ts +200 -0
- package/src/contracts/0x2/package.ts +414 -0
- package/src/contracts/0x2/party.ts +37 -0
- package/src/contracts/0x2/pay.ts +153 -0
- package/src/contracts/0x2/poseidon.ts +21 -0
- package/src/contracts/0x2/priority_queue.ts +139 -0
- package/src/contracts/0x2/random.ts +294 -0
- package/src/contracts/0x2/sui.ts +29 -0
- package/src/contracts/0x2/table.ts +200 -0
- package/src/contracts/0x2/table_vec.ts +232 -0
- package/src/contracts/0x2/token.ts +873 -0
- package/src/contracts/0x2/transfer.ts +216 -0
- package/src/contracts/0x2/transfer_policy.ts +400 -0
- package/src/contracts/0x2/tx_context.ts +129 -0
- package/src/contracts/0x2/types.ts +24 -0
- package/src/contracts/0x2/url.ts +77 -0
- package/src/contracts/0x2/vdf.ts +45 -0
- package/src/contracts/0x2/vec_map.ts +401 -0
- package/src/contracts/0x2/vec_set.ts +211 -0
- package/src/contracts/0x2/versioned.ts +153 -0
- package/src/contracts/0x2/zklogin_verified_id.ts +172 -0
- package/src/contracts/0x2/zklogin_verified_issuer.ts +99 -0
- package/src/contracts/kiosk/deps/sui/kiosk.ts +94 -0
- package/src/contracts/kiosk/deps/sui/object.ts +15 -0
- package/src/contracts/kiosk/floor_price_rule.ts +92 -0
- package/src/contracts/kiosk/kiosk_lock_rule.ts +97 -0
- package/src/contracts/kiosk/personal_kiosk.ts +295 -0
- package/src/contracts/kiosk/personal_kiosk_rule.ts +89 -0
- package/src/contracts/kiosk/royalty_rule.ts +144 -0
- package/src/contracts/kiosk/witness_rule.ts +92 -0
- package/src/contracts/utils/index.ts +234 -0
- package/src/query/client-utils.ts +51 -0
- package/src/query/kiosk.ts +128 -100
- package/src/query/transfer-policy.ts +112 -78
- package/src/tx/kiosk.ts +7 -231
- package/src/tx/rules/resolve.ts +97 -48
- package/src/tx/transfer-policy.ts +25 -86
- package/src/types/index.ts +3 -14
- package/src/types/kiosk.ts +10 -12
- package/src/types/transfer-policy.ts +4 -4
- package/src/utils.ts +90 -128
- package/dist/cjs/bcs.d.ts +0 -23
- package/dist/cjs/bcs.js +0 -50
- package/dist/cjs/bcs.js.map +0 -7
- package/dist/cjs/client/kiosk-client.d.ts +0 -76
- package/dist/cjs/client/kiosk-client.js +0 -123
- package/dist/cjs/client/kiosk-client.js.map +0 -7
- package/dist/cjs/client/kiosk-transaction.d.ts +0 -186
- package/dist/cjs/client/kiosk-transaction.js +0 -462
- package/dist/cjs/client/kiosk-transaction.js.map +0 -7
- package/dist/cjs/client/tp-transaction.d.ts +0 -114
- package/dist/cjs/client/tp-transaction.js +0 -307
- package/dist/cjs/client/tp-transaction.js.map +0 -7
- package/dist/cjs/constants.d.ts +0 -31
- package/dist/cjs/constants.js +0 -102
- package/dist/cjs/constants.js.map +0 -7
- package/dist/cjs/index.d.ts +0 -6
- package/dist/cjs/index.js +0 -24
- package/dist/cjs/index.js.map +0 -7
- package/dist/cjs/package.json +0 -5
- package/dist/cjs/query/kiosk.d.ts +0 -8
- package/dist/cjs/query/kiosk.js +0 -181
- package/dist/cjs/query/kiosk.js.map +0 -7
- package/dist/cjs/query/transfer-policy.d.ts +0 -29
- package/dist/cjs/query/transfer-policy.js +0 -92
- package/dist/cjs/query/transfer-policy.js.map +0 -7
- package/dist/cjs/tx/kiosk.d.ts +0 -71
- package/dist/cjs/tx/kiosk.js +0 -130
- package/dist/cjs/tx/kiosk.js.map +0 -7
- package/dist/cjs/tx/personal-kiosk.d.ts +0 -7
- package/dist/cjs/tx/personal-kiosk.js +0 -38
- package/dist/cjs/tx/personal-kiosk.js.map +0 -7
- package/dist/cjs/tx/rules/attach.d.ts +0 -7
- package/dist/cjs/tx/rules/attach.js +0 -62
- package/dist/cjs/tx/rules/attach.js.map +0 -7
- package/dist/cjs/tx/rules/resolve.d.ts +0 -15
- package/dist/cjs/tx/rules/resolve.js +0 -109
- package/dist/cjs/tx/rules/resolve.js.map +0 -7
- package/dist/cjs/tx/transfer-policy.d.ts +0 -29
- package/dist/cjs/tx/transfer-policy.js +0 -78
- package/dist/cjs/tx/transfer-policy.js.map +0 -7
- package/dist/cjs/types/index.d.ts +0 -27
- package/dist/cjs/types/index.js +0 -33
- package/dist/cjs/types/index.js.map +0 -7
- package/dist/cjs/types/kiosk.d.ts +0 -160
- package/dist/cjs/types/kiosk.js +0 -37
- package/dist/cjs/types/kiosk.js.map +0 -7
- package/dist/cjs/types/transfer-policy.d.ts +0 -53
- package/dist/cjs/types/transfer-policy.js +0 -35
- package/dist/cjs/types/transfer-policy.js.map +0 -7
- package/dist/cjs/utils.d.ts +0 -51
- package/dist/cjs/utils.js +0 -198
- package/dist/cjs/utils.js.map +0 -7
- package/dist/esm/bcs.d.ts +0 -23
- package/dist/esm/bcs.js +0 -35
- package/dist/esm/bcs.js.map +0 -7
- package/dist/esm/client/kiosk-client.d.ts +0 -76
- package/dist/esm/client/kiosk-client.js +0 -114
- package/dist/esm/client/kiosk-client.js.map +0 -7
- package/dist/esm/client/kiosk-transaction.d.ts +0 -186
- package/dist/esm/client/kiosk-transaction.js +0 -432
- package/dist/esm/client/kiosk-transaction.js.map +0 -7
- package/dist/esm/client/tp-transaction.d.ts +0 -114
- package/dist/esm/client/tp-transaction.js +0 -298
- package/dist/esm/client/tp-transaction.js.map +0 -7
- package/dist/esm/constants.d.ts +0 -31
- package/dist/esm/constants.js +0 -87
- package/dist/esm/constants.js.map +0 -7
- package/dist/esm/index.d.ts +0 -6
- package/dist/esm/index.js +0 -7
- package/dist/esm/index.js.map +0 -7
- package/dist/esm/package.json +0 -5
- package/dist/esm/query/kiosk.d.ts +0 -8
- package/dist/esm/query/kiosk.js +0 -169
- package/dist/esm/query/kiosk.js.map +0 -7
- package/dist/esm/query/transfer-policy.d.ts +0 -29
- package/dist/esm/query/transfer-policy.js +0 -76
- package/dist/esm/query/transfer-policy.js.map +0 -7
- package/dist/esm/tx/kiosk.d.ts +0 -71
- package/dist/esm/tx/kiosk.js +0 -110
- package/dist/esm/tx/kiosk.js.map +0 -7
- package/dist/esm/tx/personal-kiosk.d.ts +0 -7
- package/dist/esm/tx/personal-kiosk.js +0 -18
- package/dist/esm/tx/personal-kiosk.js.map +0 -7
- package/dist/esm/tx/rules/attach.d.ts +0 -7
- package/dist/esm/tx/rules/attach.js +0 -42
- package/dist/esm/tx/rules/attach.js.map +0 -7
- package/dist/esm/tx/rules/resolve.d.ts +0 -15
- package/dist/esm/tx/rules/resolve.js +0 -89
- package/dist/esm/tx/rules/resolve.js.map +0 -7
- package/dist/esm/tx/transfer-policy.d.ts +0 -29
- package/dist/esm/tx/transfer-policy.js +0 -58
- package/dist/esm/tx/transfer-policy.js.map +0 -7
- package/dist/esm/types/index.d.ts +0 -27
- package/dist/esm/types/index.js +0 -12
- package/dist/esm/types/index.js.map +0 -7
- package/dist/esm/types/kiosk.d.ts +0 -160
- package/dist/esm/types/kiosk.js +0 -17
- package/dist/esm/types/kiosk.js.map +0 -7
- package/dist/esm/types/transfer-policy.d.ts +0 -53
- package/dist/esm/types/transfer-policy.js +0 -15
- package/dist/esm/types/transfer-policy.js.map +0 -7
- package/dist/esm/utils.d.ts +0 -51
- package/dist/esm/utils.js +0 -183
- package/dist/esm/utils.js.map +0 -7
- package/dist/tsconfig.esm.tsbuildinfo +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/src/bcs.ts +0 -39
- package/src/tx/personal-kiosk.ts +0 -34
- package/src/tx/rules/attach.ts +0 -73
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,115 @@
|
|
|
1
1
|
# @mysten/kiosk
|
|
2
2
|
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- e00788c: ### Breaking Changes
|
|
8
|
+
|
|
9
|
+
**Removed deprecated `transactionBlock` parameter**
|
|
10
|
+
|
|
11
|
+
The deprecated `transactionBlock` parameter has been removed from `KioskTransaction`,
|
|
12
|
+
`TransferPolicyTransaction`, and rule resolving functions. Use `transaction` instead:
|
|
13
|
+
|
|
14
|
+
```diff
|
|
15
|
+
const kioskTx = new KioskTransaction({
|
|
16
|
+
- transactionBlock: tx,
|
|
17
|
+
+ transaction: tx,
|
|
18
|
+
kioskClient,
|
|
19
|
+
cap,
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Removed low-level transaction helper functions**
|
|
24
|
+
|
|
25
|
+
The following low-level helper functions have been removed. Use `KioskTransaction` and
|
|
26
|
+
`TransferPolicyTransaction` classes instead:
|
|
27
|
+
|
|
28
|
+
From kiosk operations:
|
|
29
|
+
- `createKiosk` - use `kioskTx.create()`
|
|
30
|
+
- `shareKiosk` - use `kioskTx.share()`
|
|
31
|
+
- `place` - use `kioskTx.place()`
|
|
32
|
+
- `lock` - use `kioskTx.lock()`
|
|
33
|
+
- `take` - use `kioskTx.take()`
|
|
34
|
+
- `list` - use `kioskTx.list()`
|
|
35
|
+
- `delist` - use `kioskTx.delist()`
|
|
36
|
+
- `placeAndList` - use `kioskTx.placeAndList()`
|
|
37
|
+
- `purchase` - use `kioskTx.purchase()`
|
|
38
|
+
- `withdrawFromKiosk` - use `kioskTx.withdraw()`
|
|
39
|
+
- `borrowValue` - use `kioskTx.borrow()`
|
|
40
|
+
- `returnValue` - use `kioskTx.return()`
|
|
41
|
+
|
|
42
|
+
From transfer policy operations:
|
|
43
|
+
- `createTransferPolicyWithoutSharing` - use `tpTx.create()`
|
|
44
|
+
- `shareTransferPolicy` - use `tpTx.shareAndTransferCap()`
|
|
45
|
+
- `confirmRequest` - handled automatically by `kioskTx.purchaseAndResolve()`
|
|
46
|
+
- `removeTransferPolicyRule` - use `tpTx.removeRule()`
|
|
47
|
+
|
|
48
|
+
From personal kiosk operations:
|
|
49
|
+
- `convertToPersonalTx` - use `kioskTx.convertToPersonal()`
|
|
50
|
+
- `transferPersonalCapTx` - handled automatically by `kioskTx.finalize()`
|
|
51
|
+
|
|
52
|
+
From rule attachment:
|
|
53
|
+
- `attachKioskLockRuleTx` - use `tpTx.addLockRule()`
|
|
54
|
+
- `attachRoyaltyRuleTx` - use `tpTx.addRoyaltyRule()`
|
|
55
|
+
- `attachPersonalKioskRuleTx` - use `tpTx.addPersonalKioskRule()`
|
|
56
|
+
- `attachFloorPriceRuleTx` - use `tpTx.addFloorPriceRule()`
|
|
57
|
+
|
|
58
|
+
**Updated client requirements**
|
|
59
|
+
|
|
60
|
+
The SDK now uses the core client API (`ClientWithCoreApi`) instead of direct JSON-RPC types.
|
|
61
|
+
Update your `KioskClient` initialization:
|
|
62
|
+
|
|
63
|
+
```diff
|
|
64
|
+
const kioskClient = new KioskClient({
|
|
65
|
+
- client: new SuiClient({ url: getFullnodeUrl('mainnet') }),
|
|
66
|
+
+ client: new SuiJsonRpcClient({
|
|
67
|
+
+ url: getJsonRpcFullnodeUrl('mainnet'),
|
|
68
|
+
+ network: 'mainnet',
|
|
69
|
+
+ }),
|
|
70
|
+
network: Network.MAINNET,
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Removed BCS exports**
|
|
75
|
+
|
|
76
|
+
The `KioskType` and other BCS type exports from `bcs.ts` have been removed. The SDK now uses
|
|
77
|
+
generated contract bindings internally.
|
|
78
|
+
|
|
79
|
+
### Minor Changes
|
|
80
|
+
|
|
81
|
+
- e00788c: Update to use SuiJsonRpcClient instead of SuiClient
|
|
82
|
+
|
|
83
|
+
Updated all type signatures, internal usages, examples, and documentation to use
|
|
84
|
+
`SuiJsonRpcClient` from `@mysten/sui/jsonRpc` instead of the deprecated `SuiClient` from
|
|
85
|
+
`@mysten/sui/client`.
|
|
86
|
+
|
|
87
|
+
### Patch Changes
|
|
88
|
+
|
|
89
|
+
- Updated dependencies [e00788c]
|
|
90
|
+
- Updated dependencies [e00788c]
|
|
91
|
+
- Updated dependencies [e00788c]
|
|
92
|
+
- Updated dependencies [e00788c]
|
|
93
|
+
- Updated dependencies [e00788c]
|
|
94
|
+
- Updated dependencies [e00788c]
|
|
95
|
+
- Updated dependencies [e00788c]
|
|
96
|
+
- Updated dependencies [e00788c]
|
|
97
|
+
- Updated dependencies [e00788c]
|
|
98
|
+
- Updated dependencies [e00788c]
|
|
99
|
+
- Updated dependencies [e00788c]
|
|
100
|
+
- Updated dependencies [e00788c]
|
|
101
|
+
- Updated dependencies [e00788c]
|
|
102
|
+
- Updated dependencies [e00788c]
|
|
103
|
+
- @mysten/sui@2.0.0
|
|
104
|
+
- @mysten/bcs@2.0.0
|
|
105
|
+
|
|
106
|
+
## 0.14.6
|
|
107
|
+
|
|
108
|
+
### Patch Changes
|
|
109
|
+
|
|
110
|
+
- Updated dependencies [29e8b92]
|
|
111
|
+
- @mysten/sui@1.45.2
|
|
112
|
+
|
|
3
113
|
## 0.14.5
|
|
4
114
|
|
|
5
115
|
### Patch Changes
|
|
@@ -694,8 +804,8 @@
|
|
|
694
804
|
|
|
695
805
|
- a92b03de42: The Typescript SDK has been renamed to `@mysten/sui` and includes many new features
|
|
696
806
|
and breaking changes. See the
|
|
697
|
-
[full migration guide](https://sdk.mystenlabs.com/
|
|
698
|
-
|
|
807
|
+
[full migration guide](https://sdk.mystenlabs.com/sui/migrations/sui-1.0) for details on how to
|
|
808
|
+
upgrade.
|
|
699
809
|
|
|
700
810
|
### Patch Changes
|
|
701
811
|
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { BaseRulePackageIds, TransferPolicyRule } from "../constants.mjs";
|
|
2
|
+
import { FetchKioskOptions, KioskData, KioskExtension, OwnedKiosks } from "../types/kiosk.mjs";
|
|
3
|
+
import { TransferPolicy, TransferPolicyCap } from "../types/transfer-policy.mjs";
|
|
4
|
+
import { KioskClientOptions } from "../types/index.mjs";
|
|
5
|
+
import { PaginationArguments } from "@mysten/sui/jsonRpc";
|
|
6
|
+
import { ClientWithCoreApi, SuiClientTypes } from "@mysten/sui/client";
|
|
7
|
+
|
|
8
|
+
//#region src/client/kiosk-client.d.ts
|
|
9
|
+
type KioskExtensionOptions<Name extends string = 'kiosk'> = {
|
|
10
|
+
name?: Name;
|
|
11
|
+
packageIds?: BaseRulePackageIds;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Creates a kiosk client extension that can be used with `client.$extend()`.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
19
|
+
* import { kiosk } from '@mysten/kiosk';
|
|
20
|
+
*
|
|
21
|
+
* const client = new SuiJsonRpcClient({
|
|
22
|
+
* url: getJsonRpcFullnodeUrl('mainnet'),
|
|
23
|
+
* network: 'mainnet',
|
|
24
|
+
* }).$extend(kiosk());
|
|
25
|
+
*
|
|
26
|
+
* const ownedKiosks = await client.kiosk.getOwnedKiosks({ address: '0x...' });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
declare function kiosk<const Name extends string = 'kiosk'>({
|
|
30
|
+
name,
|
|
31
|
+
packageIds
|
|
32
|
+
}?: KioskExtensionOptions<Name>): {
|
|
33
|
+
name: Name;
|
|
34
|
+
register: (client: ClientWithCoreApi) => KioskClient;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* A Client that allows you to interact with kiosk.
|
|
38
|
+
* Offers utilities to query kiosk, craft transactions to edit your own kiosk,
|
|
39
|
+
* purchase, manage transfer policies, create new kiosks etc.
|
|
40
|
+
* If you pass packageIds, all functionality will be managed using these packages.
|
|
41
|
+
*/
|
|
42
|
+
declare class KioskClient {
|
|
43
|
+
client: ClientWithCoreApi;
|
|
44
|
+
network: SuiClientTypes.Network;
|
|
45
|
+
rules: TransferPolicyRule[];
|
|
46
|
+
packageIds?: BaseRulePackageIds;
|
|
47
|
+
constructor(options: KioskClientOptions);
|
|
48
|
+
/**
|
|
49
|
+
* Get an addresses's owned kiosks.
|
|
50
|
+
* @param address The address for which we want to retrieve the kiosks.
|
|
51
|
+
* @param pagination Optional pagination arguments.
|
|
52
|
+
* @returns An Object containing all the `kioskOwnerCap` objects as well as the kioskIds.
|
|
53
|
+
*/
|
|
54
|
+
getOwnedKiosks({
|
|
55
|
+
address,
|
|
56
|
+
pagination
|
|
57
|
+
}: {
|
|
58
|
+
address: string;
|
|
59
|
+
pagination?: PaginationArguments<string>;
|
|
60
|
+
}): Promise<OwnedKiosks>;
|
|
61
|
+
/**
|
|
62
|
+
* Fetches the kiosk contents.
|
|
63
|
+
* @param id The ID of the kiosk to fetch.
|
|
64
|
+
* @param options Optional to control the fetch behavior.
|
|
65
|
+
* @returns
|
|
66
|
+
*/
|
|
67
|
+
getKiosk({
|
|
68
|
+
id,
|
|
69
|
+
options
|
|
70
|
+
}: {
|
|
71
|
+
id: string;
|
|
72
|
+
options?: FetchKioskOptions;
|
|
73
|
+
}): Promise<KioskData>;
|
|
74
|
+
/**
|
|
75
|
+
* Fetch the extension data (if any) for a kiosk, by type
|
|
76
|
+
* @param kioskId The ID of the kiosk to lookup
|
|
77
|
+
* @param extensionType The Type of the extension (can be used from by using the type returned by `getKiosk()`)
|
|
78
|
+
*/
|
|
79
|
+
getKioskExtension({
|
|
80
|
+
kioskId,
|
|
81
|
+
type
|
|
82
|
+
}: {
|
|
83
|
+
kioskId: string;
|
|
84
|
+
type: string;
|
|
85
|
+
}): Promise<KioskExtension | null>;
|
|
86
|
+
/**
|
|
87
|
+
* Query the Transfer Policy(ies) for type `T`.
|
|
88
|
+
* @param type The Type we're querying for (E.g `0xMyAddress::hero::Hero`)
|
|
89
|
+
*/
|
|
90
|
+
getTransferPolicies({
|
|
91
|
+
type
|
|
92
|
+
}: {
|
|
93
|
+
type: string;
|
|
94
|
+
}): Promise<TransferPolicy[]>;
|
|
95
|
+
/**
|
|
96
|
+
* Query all the owned transfer policies for an address.
|
|
97
|
+
* Returns `TransferPolicyCap` which uncludes `policyId, policyCapId, type`.
|
|
98
|
+
* @param address The address we're searching the owned transfer policies for.
|
|
99
|
+
*/
|
|
100
|
+
getOwnedTransferPolicies({
|
|
101
|
+
address
|
|
102
|
+
}: {
|
|
103
|
+
address: string;
|
|
104
|
+
}): Promise<TransferPolicyCap[] | undefined>;
|
|
105
|
+
/**
|
|
106
|
+
* Query the Transfer Policy Cap for type `T`, owned by `address`
|
|
107
|
+
* @param type The Type `T` for the object
|
|
108
|
+
* @param address The address that owns the cap.
|
|
109
|
+
*/
|
|
110
|
+
getOwnedTransferPoliciesByType({
|
|
111
|
+
type,
|
|
112
|
+
address
|
|
113
|
+
}: {
|
|
114
|
+
type: string;
|
|
115
|
+
address: string;
|
|
116
|
+
}): Promise<TransferPolicyCap[]>;
|
|
117
|
+
addRuleResolver(rule: TransferPolicyRule): void;
|
|
118
|
+
/**
|
|
119
|
+
* A convenient helper to get the packageIds for our supported ruleset,
|
|
120
|
+
* based on `kioskClient` configuration.
|
|
121
|
+
*/
|
|
122
|
+
getRulePackageId(rule: 'kioskLockRulePackageId' | 'royaltyRulePackageId' | 'personalKioskRulePackageId' | 'floorPriceRulePackageId'): string | undefined;
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
export { KioskClient, KioskExtensionOptions, kiosk };
|
|
126
|
+
//# sourceMappingURL=kiosk-client.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kiosk-client.d.mts","names":[],"sources":["../../src/client/kiosk-client.ts"],"sourcesContent":[],"mappings":";;;;;;;;KA4BY;SACJ;eACM;;AAFd;AAqBA;;;;;;;;;AAsBA;;;;;;AA0BE,iBAhDc,KAgDd,CAAA,mBAAA,MAAA,GAAA,OAAA,CAAA,CAAA;EAAA,IAAA;EAAA;AAAA,CAAA,CAAA,EA7CC,qBA6CD,CA7CuB,IA6CvB,CAAA,CAAA,EAAA;EACA,IAAA,MAAA;EAGa,QAAA,EAAA,CAAA,MAAA,EA9CM,iBA8CN,EAAA,GA9CuB,WA8CvB;CACF;;;;;;;AA2Bc,cA1Dd,WAAA,CA0Dc;EAAS,MAAA,EAzD3B,iBAyD2B;EAAI,OAAA,EAxD9B,cAAA,CAAe,OAwDe;EAAqC,KAAA,EAvDrE,kBAuDqE,EAAA;EAQhD,UAAA,CAAA,EA9Df,kBA8De;EAAI,WAAA,CAAA,OAAA,EA5DX,kBA4DW;EAAoB;;;;;;EAkBA,cAAA,CAAA;IAAA,OAAA;IAAA;EAOZ,CAPY,EAAA;IAAqC,OAAA,EAAA,MAAA;IAOnE,UAAA,CAAA,EA7DR,mBA6DQ,CAAA,MAAA,CAAA;EAAkB,CAAA,CAAA,EA5DpC,OA4DoC,CA5D5B,WA4D4B,CAAA;;;;;;;;;;;;cA1CgB;MAAsB,QAAQ;;;;;;;;;;;;MASV,QAArC,cAAA;;;;;;;;;MAQa,QAApB,cAAA;;;;;;;;;;MAS+B,QAAvB,iBAAA;;;;;;;;;;;;MASiD,QAArC,iBAAA;wBAO9B"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { FLOOR_PRICE_RULE_ADDRESS, KIOSK_LOCK_RULE_ADDRESS, PERSONAL_KIOSK_RULE_ADDRESS, ROYALTY_RULE_ADDRESS, getBaseRules, rules } from "../constants.mjs";
|
|
2
|
+
import { fetchKiosk, fetchKioskExtension, getOwnedKiosks } from "../query/kiosk.mjs";
|
|
3
|
+
import { queryOwnedTransferPolicies, queryTransferPolicy, queryTransferPolicyCapsByType } from "../query/transfer-policy.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/client/kiosk-client.ts
|
|
6
|
+
/**
|
|
7
|
+
* Creates a kiosk client extension that can be used with `client.$extend()`.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
12
|
+
* import { kiosk } from '@mysten/kiosk';
|
|
13
|
+
*
|
|
14
|
+
* const client = new SuiJsonRpcClient({
|
|
15
|
+
* url: getJsonRpcFullnodeUrl('mainnet'),
|
|
16
|
+
* network: 'mainnet',
|
|
17
|
+
* }).$extend(kiosk());
|
|
18
|
+
*
|
|
19
|
+
* const ownedKiosks = await client.kiosk.getOwnedKiosks({ address: '0x...' });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
function kiosk({ name = "kiosk", packageIds } = {}) {
|
|
23
|
+
return {
|
|
24
|
+
name,
|
|
25
|
+
register: (client) => {
|
|
26
|
+
return new KioskClient({
|
|
27
|
+
client,
|
|
28
|
+
network: client.network,
|
|
29
|
+
packageIds
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A Client that allows you to interact with kiosk.
|
|
36
|
+
* Offers utilities to query kiosk, craft transactions to edit your own kiosk,
|
|
37
|
+
* purchase, manage transfer policies, create new kiosks etc.
|
|
38
|
+
* If you pass packageIds, all functionality will be managed using these packages.
|
|
39
|
+
*/
|
|
40
|
+
var KioskClient = class {
|
|
41
|
+
constructor(options) {
|
|
42
|
+
this.client = options.client;
|
|
43
|
+
this.network = options.network;
|
|
44
|
+
this.rules = rules;
|
|
45
|
+
this.packageIds = options.packageIds;
|
|
46
|
+
if (options.packageIds) this.rules.push(...getBaseRules(options.packageIds));
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get an addresses's owned kiosks.
|
|
50
|
+
* @param address The address for which we want to retrieve the kiosks.
|
|
51
|
+
* @param pagination Optional pagination arguments.
|
|
52
|
+
* @returns An Object containing all the `kioskOwnerCap` objects as well as the kioskIds.
|
|
53
|
+
*/
|
|
54
|
+
async getOwnedKiosks({ address, pagination }) {
|
|
55
|
+
const personalPackageId = this.packageIds?.personalKioskRulePackageId || PERSONAL_KIOSK_RULE_ADDRESS[this.network];
|
|
56
|
+
return getOwnedKiosks(this.client, address, {
|
|
57
|
+
pagination,
|
|
58
|
+
personalKioskType: personalPackageId ? `${personalPackageId}::personal_kiosk::PersonalKioskCap` : ""
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Fetches the kiosk contents.
|
|
63
|
+
* @param id The ID of the kiosk to fetch.
|
|
64
|
+
* @param options Optional to control the fetch behavior.
|
|
65
|
+
* @returns
|
|
66
|
+
*/
|
|
67
|
+
async getKiosk({ id, options }) {
|
|
68
|
+
return (await fetchKiosk(this.client, id, {}, options || {})).data;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Fetch the extension data (if any) for a kiosk, by type
|
|
72
|
+
* @param kioskId The ID of the kiosk to lookup
|
|
73
|
+
* @param extensionType The Type of the extension (can be used from by using the type returned by `getKiosk()`)
|
|
74
|
+
*/
|
|
75
|
+
async getKioskExtension({ kioskId, type }) {
|
|
76
|
+
return fetchKioskExtension(this.client, kioskId, type);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Query the Transfer Policy(ies) for type `T`.
|
|
80
|
+
* @param type The Type we're querying for (E.g `0xMyAddress::hero::Hero`)
|
|
81
|
+
*/
|
|
82
|
+
async getTransferPolicies({ type }) {
|
|
83
|
+
return queryTransferPolicy(this.client, type);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Query all the owned transfer policies for an address.
|
|
87
|
+
* Returns `TransferPolicyCap` which uncludes `policyId, policyCapId, type`.
|
|
88
|
+
* @param address The address we're searching the owned transfer policies for.
|
|
89
|
+
*/
|
|
90
|
+
async getOwnedTransferPolicies({ address }) {
|
|
91
|
+
return queryOwnedTransferPolicies(this.client, address);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Query the Transfer Policy Cap for type `T`, owned by `address`
|
|
95
|
+
* @param type The Type `T` for the object
|
|
96
|
+
* @param address The address that owns the cap.
|
|
97
|
+
*/
|
|
98
|
+
async getOwnedTransferPoliciesByType({ type, address }) {
|
|
99
|
+
return queryTransferPolicyCapsByType(this.client, address, type);
|
|
100
|
+
}
|
|
101
|
+
addRuleResolver(rule) {
|
|
102
|
+
if (this.rules.find((x) => x.rule === rule.rule)) throw new Error(`Rule ${rule.rule} resolver already exists.`);
|
|
103
|
+
this.rules.push(rule);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* A convenient helper to get the packageIds for our supported ruleset,
|
|
107
|
+
* based on `kioskClient` configuration.
|
|
108
|
+
*/
|
|
109
|
+
getRulePackageId(rule) {
|
|
110
|
+
const rules$1 = this.packageIds || {};
|
|
111
|
+
const network = this.network;
|
|
112
|
+
if (!rules$1[rule] && network !== "mainnet" && network !== "testnet") throw new Error(`Missing packageId for rule ${rule}`);
|
|
113
|
+
switch (rule) {
|
|
114
|
+
case "kioskLockRulePackageId": return rules$1[rule] || KIOSK_LOCK_RULE_ADDRESS[network];
|
|
115
|
+
case "royaltyRulePackageId": return rules$1[rule] || ROYALTY_RULE_ADDRESS[network];
|
|
116
|
+
case "personalKioskRulePackageId": return rules$1[rule] || PERSONAL_KIOSK_RULE_ADDRESS[network];
|
|
117
|
+
case "floorPriceRulePackageId": return rules$1[rule] || FLOOR_PRICE_RULE_ADDRESS[network];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
//#endregion
|
|
123
|
+
export { KioskClient, kiosk };
|
|
124
|
+
//# sourceMappingURL=kiosk-client.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kiosk-client.mjs","names":["rules"],"sources":["../../src/client/kiosk-client.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { PaginationArguments } from '@mysten/sui/jsonRpc';\nimport type { ClientWithCoreApi, SuiClientTypes } from '@mysten/sui/client';\n\nimport {\n\tFLOOR_PRICE_RULE_ADDRESS,\n\tgetBaseRules,\n\tKIOSK_LOCK_RULE_ADDRESS,\n\tPERSONAL_KIOSK_RULE_ADDRESS,\n\tROYALTY_RULE_ADDRESS,\n\trules,\n} from '../constants.js';\nimport type { BaseRulePackageIds, TransferPolicyRule } from '../constants.js';\nimport { fetchKiosk, fetchKioskExtension, getOwnedKiosks } from '../query/kiosk.js';\nimport {\n\tqueryOwnedTransferPolicies,\n\tqueryTransferPolicy,\n\tqueryTransferPolicyCapsByType,\n} from '../query/transfer-policy.js';\nimport type {\n\tFetchKioskOptions,\n\tKioskClientOptions,\n\tKioskData,\n\tOwnedKiosks,\n} from '../types/index.js';\n\nexport type KioskExtensionOptions<Name extends string = 'kiosk'> = {\n\tname?: Name;\n\tpackageIds?: BaseRulePackageIds;\n};\n\n/**\n * Creates a kiosk client extension that can be used with `client.$extend()`.\n *\n * @example\n * ```ts\n * import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';\n * import { kiosk } from '@mysten/kiosk';\n *\n * const client = new SuiJsonRpcClient({\n * url: getJsonRpcFullnodeUrl('mainnet'),\n * network: 'mainnet',\n * }).$extend(kiosk());\n *\n * const ownedKiosks = await client.kiosk.getOwnedKiosks({ address: '0x...' });\n * ```\n */\nexport function kiosk<const Name extends string = 'kiosk'>({\n\tname = 'kiosk' as Name,\n\tpackageIds,\n}: KioskExtensionOptions<Name> = {}) {\n\treturn {\n\t\tname,\n\t\tregister: (client: ClientWithCoreApi) => {\n\t\t\treturn new KioskClient({\n\t\t\t\tclient,\n\t\t\t\tnetwork: client.network,\n\t\t\t\tpackageIds,\n\t\t\t});\n\t\t},\n\t};\n}\n\n/**\n * A Client that allows you to interact with kiosk.\n * Offers utilities to query kiosk, craft transactions to edit your own kiosk,\n * purchase, manage transfer policies, create new kiosks etc.\n * If you pass packageIds, all functionality will be managed using these packages.\n */\nexport class KioskClient {\n\tclient: ClientWithCoreApi;\n\tnetwork: SuiClientTypes.Network;\n\trules: TransferPolicyRule[];\n\tpackageIds?: BaseRulePackageIds;\n\n\tconstructor(options: KioskClientOptions) {\n\t\tthis.client = options.client;\n\t\tthis.network = options.network;\n\t\tthis.rules = rules; // add all the default rules.\n\t\tthis.packageIds = options.packageIds;\n\n\t\t// Add the custom Package Ids too on the rule list.\n\t\t// Only adds the rules that are passed in the packageId object.\n\t\tif (options.packageIds) this.rules.push(...getBaseRules(options.packageIds));\n\t}\n\n\t/// Querying\n\n\t/**\n\t * Get an addresses's owned kiosks.\n\t * @param address The address for which we want to retrieve the kiosks.\n\t * @param pagination Optional pagination arguments.\n\t * @returns An Object containing all the `kioskOwnerCap` objects as well as the kioskIds.\n\t */\n\tasync getOwnedKiosks({\n\t\taddress,\n\t\tpagination,\n\t}: {\n\t\taddress: string;\n\t\tpagination?: PaginationArguments<string>;\n\t}): Promise<OwnedKiosks> {\n\t\tconst personalPackageId =\n\t\t\tthis.packageIds?.personalKioskRulePackageId || PERSONAL_KIOSK_RULE_ADDRESS[this.network];\n\n\t\treturn getOwnedKiosks(this.client, address, {\n\t\t\tpagination,\n\t\t\tpersonalKioskType: personalPackageId\n\t\t\t\t? `${personalPackageId}::personal_kiosk::PersonalKioskCap`\n\t\t\t\t: '',\n\t\t});\n\t}\n\n\t/**\n\t * Fetches the kiosk contents.\n\t * @param id The ID of the kiosk to fetch.\n\t * @param options Optional to control the fetch behavior.\n\t * @returns\n\t */\n\tasync getKiosk({ id, options }: { id: string; options?: FetchKioskOptions }): Promise<KioskData> {\n\t\treturn (await fetchKiosk(this.client, id, {}, options || {})).data;\n\t}\n\n\t/**\n\t * Fetch the extension data (if any) for a kiosk, by type\n\t * @param kioskId The ID of the kiosk to lookup\n\t * @param extensionType The Type of the extension (can be used from by using the type returned by `getKiosk()`)\n\t */\n\tasync getKioskExtension({ kioskId, type }: { kioskId: string; type: string }) {\n\t\treturn fetchKioskExtension(this.client, kioskId, type);\n\t}\n\n\t/**\n\t * Query the Transfer Policy(ies) for type `T`.\n\t * @param type The Type we're querying for (E.g `0xMyAddress::hero::Hero`)\n\t */\n\tasync getTransferPolicies({ type }: { type: string }) {\n\t\treturn queryTransferPolicy(this.client, type);\n\t}\n\n\t/**\n\t * Query all the owned transfer policies for an address.\n\t * Returns `TransferPolicyCap` which uncludes `policyId, policyCapId, type`.\n\t * @param address The address we're searching the owned transfer policies for.\n\t */\n\tasync getOwnedTransferPolicies({ address }: { address: string }) {\n\t\treturn queryOwnedTransferPolicies(this.client, address);\n\t}\n\n\t/**\n\t * Query the Transfer Policy Cap for type `T`, owned by `address`\n\t * @param type The Type `T` for the object\n\t * @param address The address that owns the cap.\n\t */\n\tasync getOwnedTransferPoliciesByType({ type, address }: { type: string; address: string }) {\n\t\treturn queryTransferPolicyCapsByType(this.client, address, type);\n\t}\n\n\t// Someone would just have to create a `kiosk-client.ts` file in their project, initialize a KioskClient\n\t// and call the `addRuleResolver` function. Each rule has a `resolve` function.\n\t// The resolve function is automatically called on `purchaseAndResolve` function call.\n\taddRuleResolver(rule: TransferPolicyRule) {\n\t\tif (this.rules.find((x) => x.rule === rule.rule))\n\t\t\tthrow new Error(`Rule ${rule.rule} resolver already exists.`);\n\t\tthis.rules.push(rule);\n\t}\n\n\t/**\n\t * A convenient helper to get the packageIds for our supported ruleset,\n\t * based on `kioskClient` configuration.\n\t */\n\tgetRulePackageId(\n\t\trule:\n\t\t\t| 'kioskLockRulePackageId'\n\t\t\t| 'royaltyRulePackageId'\n\t\t\t| 'personalKioskRulePackageId'\n\t\t\t| 'floorPriceRulePackageId',\n\t) {\n\t\tconst rules = this.packageIds || {};\n\t\tconst network = this.network;\n\n\t\t/// Check existence of rule based on network and throw an error if it's not found.\n\t\t/// We always have a fallback for testnet or mainnet.\n\t\tif (!rules[rule] && network !== 'mainnet' && network !== 'testnet') {\n\t\t\tthrow new Error(`Missing packageId for rule ${rule}`);\n\t\t}\n\n\t\tswitch (rule) {\n\t\t\tcase 'kioskLockRulePackageId':\n\t\t\t\treturn rules[rule] || KIOSK_LOCK_RULE_ADDRESS[network];\n\t\t\tcase 'royaltyRulePackageId':\n\t\t\t\treturn rules[rule] || ROYALTY_RULE_ADDRESS[network];\n\t\t\tcase 'personalKioskRulePackageId':\n\t\t\t\treturn rules[rule] || PERSONAL_KIOSK_RULE_ADDRESS[network];\n\t\t\tcase 'floorPriceRulePackageId':\n\t\t\t\treturn rules[rule] || FLOOR_PRICE_RULE_ADDRESS[network];\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAiDA,SAAgB,MAA2C,EAC1D,OAAO,SACP,eACgC,EAAE,EAAE;AACpC,QAAO;EACN;EACA,WAAW,WAA8B;AACxC,UAAO,IAAI,YAAY;IACtB;IACA,SAAS,OAAO;IAChB;IACA,CAAC;;EAEH;;;;;;;;AASF,IAAa,cAAb,MAAyB;CAMxB,YAAY,SAA6B;AACxC,OAAK,SAAS,QAAQ;AACtB,OAAK,UAAU,QAAQ;AACvB,OAAK,QAAQ;AACb,OAAK,aAAa,QAAQ;AAI1B,MAAI,QAAQ,WAAY,MAAK,MAAM,KAAK,GAAG,aAAa,QAAQ,WAAW,CAAC;;;;;;;;CAW7E,MAAM,eAAe,EACpB,SACA,cAIwB;EACxB,MAAM,oBACL,KAAK,YAAY,8BAA8B,4BAA4B,KAAK;AAEjF,SAAO,eAAe,KAAK,QAAQ,SAAS;GAC3C;GACA,mBAAmB,oBAChB,GAAG,kBAAkB,sCACrB;GACH,CAAC;;;;;;;;CASH,MAAM,SAAS,EAAE,IAAI,WAA4E;AAChG,UAAQ,MAAM,WAAW,KAAK,QAAQ,IAAI,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE;;;;;;;CAQ/D,MAAM,kBAAkB,EAAE,SAAS,QAA2C;AAC7E,SAAO,oBAAoB,KAAK,QAAQ,SAAS,KAAK;;;;;;CAOvD,MAAM,oBAAoB,EAAE,QAA0B;AACrD,SAAO,oBAAoB,KAAK,QAAQ,KAAK;;;;;;;CAQ9C,MAAM,yBAAyB,EAAE,WAAgC;AAChE,SAAO,2BAA2B,KAAK,QAAQ,QAAQ;;;;;;;CAQxD,MAAM,+BAA+B,EAAE,MAAM,WAA8C;AAC1F,SAAO,8BAA8B,KAAK,QAAQ,SAAS,KAAK;;CAMjE,gBAAgB,MAA0B;AACzC,MAAI,KAAK,MAAM,MAAM,MAAM,EAAE,SAAS,KAAK,KAAK,CAC/C,OAAM,IAAI,MAAM,QAAQ,KAAK,KAAK,2BAA2B;AAC9D,OAAK,MAAM,KAAK,KAAK;;;;;;CAOtB,iBACC,MAKC;EACD,MAAMA,UAAQ,KAAK,cAAc,EAAE;EACnC,MAAM,UAAU,KAAK;AAIrB,MAAI,CAACA,QAAM,SAAS,YAAY,aAAa,YAAY,UACxD,OAAM,IAAI,MAAM,8BAA8B,OAAO;AAGtD,UAAQ,MAAR;GACC,KAAK,yBACJ,QAAOA,QAAM,SAAS,wBAAwB;GAC/C,KAAK,uBACJ,QAAOA,QAAM,SAAS,qBAAqB;GAC5C,KAAK,6BACJ,QAAOA,QAAM,SAAS,4BAA4B;GACnD,KAAK,0BACJ,QAAOA,QAAM,SAAS,yBAAyB"}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { ItemId, ItemReference, ItemValue, KioskOwnerCap, Price, PurchaseOptions } from "../types/kiosk.mjs";
|
|
2
|
+
import { KioskClient } from "./kiosk-client.mjs";
|
|
3
|
+
import { ObjectArgument } from "../types/index.mjs";
|
|
4
|
+
import { Transaction, TransactionArgument, TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
5
|
+
|
|
6
|
+
//#region src/client/kiosk-transaction.d.ts
|
|
7
|
+
type KioskTransactionParams = {
|
|
8
|
+
/** The Transaction for this run */
|
|
9
|
+
transaction: Transaction;
|
|
10
|
+
/**
|
|
11
|
+
* You can create a new KioskClient by calling `new KioskClient()`
|
|
12
|
+
*/
|
|
13
|
+
kioskClient: KioskClient;
|
|
14
|
+
/**
|
|
15
|
+
* You can optionally pass in the `cap` as returned
|
|
16
|
+
* from `kioskClient.getOwnedKiosks` when initializing the client
|
|
17
|
+
* Otherwise, you can set it by calling `kioskTransaction.setCap()`
|
|
18
|
+
*/
|
|
19
|
+
cap?: KioskOwnerCap;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A helper for building transactions that involve kiosk.
|
|
23
|
+
*/
|
|
24
|
+
declare class KioskTransaction {
|
|
25
|
+
#private;
|
|
26
|
+
transaction: Transaction;
|
|
27
|
+
kioskClient: KioskClient;
|
|
28
|
+
kiosk?: TransactionObjectArgument;
|
|
29
|
+
kioskCap?: TransactionObjectArgument;
|
|
30
|
+
constructor({
|
|
31
|
+
transaction,
|
|
32
|
+
kioskClient,
|
|
33
|
+
cap
|
|
34
|
+
}: KioskTransactionParams);
|
|
35
|
+
/**
|
|
36
|
+
* Creates a kiosk and saves `kiosk` and `kioskOwnerCap` in state.
|
|
37
|
+
* Helpful if we want to chain some actions before sharing + transferring the cap to the specified address.
|
|
38
|
+
* @param borrow If true, the `kioskOwnerCap` is borrowed from the `PersonalKioskCap` to be used in next transactions.
|
|
39
|
+
*/
|
|
40
|
+
create(): this;
|
|
41
|
+
/**
|
|
42
|
+
* Creates a personal kiosk & shares it.
|
|
43
|
+
* The `PersonalKioskCap` is transferred to the signer.
|
|
44
|
+
* @param borrow If true, the `kioskOwnerCap` is borrowed from the `PersonalKioskCap` to be used in next transactions.
|
|
45
|
+
*/
|
|
46
|
+
createPersonal(borrow?: boolean): this;
|
|
47
|
+
/**
|
|
48
|
+
* Converts a kiosk to a Personal (Soulbound) Kiosk.
|
|
49
|
+
* Requires initialization by either calling `ktxb.create()` or `ktxb.setCap()`.
|
|
50
|
+
*/
|
|
51
|
+
convertToPersonal(borrow?: boolean): this;
|
|
52
|
+
/**
|
|
53
|
+
* Single function way to create a kiosk, share it and transfer the cap to the specified address.
|
|
54
|
+
*/
|
|
55
|
+
createAndShare(address: string): this;
|
|
56
|
+
/**
|
|
57
|
+
* Shares the kiosk.
|
|
58
|
+
*/
|
|
59
|
+
share(): this;
|
|
60
|
+
/**
|
|
61
|
+
* Should be called only after `create` is called.
|
|
62
|
+
* It shares the kiosk & transfers the cap to the specified address.
|
|
63
|
+
*/
|
|
64
|
+
shareAndTransferCap(address: string): this;
|
|
65
|
+
/**
|
|
66
|
+
* A function to borrow an item from a kiosk & execute any function with it.
|
|
67
|
+
* Example: You could borrow a Fren out of a kiosk, attach an accessory (or mix), and return it.
|
|
68
|
+
*/
|
|
69
|
+
borrowTx({
|
|
70
|
+
itemType,
|
|
71
|
+
itemId
|
|
72
|
+
}: ItemId, callback: (item: TransactionArgument) => void): this;
|
|
73
|
+
/**
|
|
74
|
+
* Borrows an item from the kiosk.
|
|
75
|
+
* This will fail if the item is listed for sale.
|
|
76
|
+
*
|
|
77
|
+
* Requires calling `return`.
|
|
78
|
+
*/
|
|
79
|
+
borrow({
|
|
80
|
+
itemType,
|
|
81
|
+
itemId
|
|
82
|
+
}: ItemId): [TransactionArgument, TransactionArgument];
|
|
83
|
+
/**
|
|
84
|
+
* Returns the item back to the kiosk.
|
|
85
|
+
* Accepts the parameters returned from the `borrow` function.
|
|
86
|
+
*/
|
|
87
|
+
return({
|
|
88
|
+
itemType,
|
|
89
|
+
item,
|
|
90
|
+
promise
|
|
91
|
+
}: ItemValue & {
|
|
92
|
+
promise: TransactionArgument;
|
|
93
|
+
}): this;
|
|
94
|
+
/**
|
|
95
|
+
* A function to withdraw from kiosk
|
|
96
|
+
* @param address Where to transfer the coin.
|
|
97
|
+
* @param amount The amount we aim to withdraw.
|
|
98
|
+
*/
|
|
99
|
+
withdraw(address: string, amount?: string | bigint | number): this;
|
|
100
|
+
/**
|
|
101
|
+
* A function to place an item in the kiosk.
|
|
102
|
+
* @param itemType The type `T` of the item
|
|
103
|
+
* @param item The ID or Transaction Argument of the item
|
|
104
|
+
*/
|
|
105
|
+
place({
|
|
106
|
+
itemType,
|
|
107
|
+
item
|
|
108
|
+
}: ItemReference): this;
|
|
109
|
+
/**
|
|
110
|
+
* A function to place an item in the kiosk and list it for sale in one transaction.
|
|
111
|
+
* @param itemType The type `T` of the item
|
|
112
|
+
* @param item The ID or Transaction Argument of the item
|
|
113
|
+
* @param price The price in MIST
|
|
114
|
+
*/
|
|
115
|
+
placeAndList({
|
|
116
|
+
itemType,
|
|
117
|
+
item,
|
|
118
|
+
price
|
|
119
|
+
}: ItemReference & Price): this;
|
|
120
|
+
/**
|
|
121
|
+
* A function to list an item in the kiosk.
|
|
122
|
+
* @param itemType The type `T` of the item
|
|
123
|
+
* @param itemId The ID of the item
|
|
124
|
+
* @param price The price in MIST
|
|
125
|
+
*/
|
|
126
|
+
list({
|
|
127
|
+
itemType,
|
|
128
|
+
itemId,
|
|
129
|
+
price
|
|
130
|
+
}: ItemId & {
|
|
131
|
+
price: string | bigint;
|
|
132
|
+
}): this;
|
|
133
|
+
/**
|
|
134
|
+
* A function to delist an item from the kiosk.
|
|
135
|
+
* @param itemType The type `T` of the item
|
|
136
|
+
* @param itemId The ID of the item
|
|
137
|
+
*/
|
|
138
|
+
delist({
|
|
139
|
+
itemType,
|
|
140
|
+
itemId
|
|
141
|
+
}: ItemId): this;
|
|
142
|
+
/**
|
|
143
|
+
* A function to take an item from the kiosk. The transaction won't succeed if the item is listed or locked.
|
|
144
|
+
* @param itemType The type `T` of the item
|
|
145
|
+
* @param itemId The ID of the item
|
|
146
|
+
*/
|
|
147
|
+
take({
|
|
148
|
+
itemType,
|
|
149
|
+
itemId
|
|
150
|
+
}: ItemId): TransactionObjectArgument;
|
|
151
|
+
/**
|
|
152
|
+
* Transfer a non-locked/non-listed item to an address.
|
|
153
|
+
*
|
|
154
|
+
* @param itemType The type `T` of the item
|
|
155
|
+
* @param itemId The ID of the item
|
|
156
|
+
* @param address The destination address
|
|
157
|
+
*/
|
|
158
|
+
transfer({
|
|
159
|
+
itemType,
|
|
160
|
+
itemId,
|
|
161
|
+
address
|
|
162
|
+
}: ItemId & {
|
|
163
|
+
address: string;
|
|
164
|
+
}): this;
|
|
165
|
+
/**
|
|
166
|
+
* A function to take lock an item in the kiosk.
|
|
167
|
+
* @param itemType The type `T` of the item
|
|
168
|
+
* @param item The ID or Transaction Argument of the item
|
|
169
|
+
* @param itemId The ID of the item - Deprecated: Use `item` instead.
|
|
170
|
+
* @param policy The Policy ID or Transaction Argument for item T
|
|
171
|
+
*/
|
|
172
|
+
lock({
|
|
173
|
+
itemType,
|
|
174
|
+
item,
|
|
175
|
+
itemId,
|
|
176
|
+
policy
|
|
177
|
+
}: ItemReference & {
|
|
178
|
+
policy: ObjectArgument;
|
|
179
|
+
itemId?: string;
|
|
180
|
+
}): this;
|
|
181
|
+
/**
|
|
182
|
+
* Purchase an item from a seller's kiosk.
|
|
183
|
+
* Returns [item, transferRequest]
|
|
184
|
+
* Can be called like: `const [item, transferRequest] = kioskTx.purchase({...})`
|
|
185
|
+
* @param itemType The type `T` of the item
|
|
186
|
+
* @param itemId The ID of the item
|
|
187
|
+
* @param price The price in MIST
|
|
188
|
+
* @param sellerKiosk The kiosk which is selling the item. Can be an id or an object argument.
|
|
189
|
+
*/
|
|
190
|
+
purchase({
|
|
191
|
+
itemType,
|
|
192
|
+
itemId,
|
|
193
|
+
price,
|
|
194
|
+
sellerKiosk
|
|
195
|
+
}: ItemId & Price & {
|
|
196
|
+
sellerKiosk: ObjectArgument;
|
|
197
|
+
}): [TransactionObjectArgument, TransactionObjectArgument];
|
|
198
|
+
/**
|
|
199
|
+
* A function to purchase and resolve a transfer policy.
|
|
200
|
+
* If the transfer policy has the `lock` rule, the item is locked in the kiosk.
|
|
201
|
+
* Otherwise, the item is placed in the kiosk.
|
|
202
|
+
* @param itemType The type of the item
|
|
203
|
+
* @param itemId The id of the item
|
|
204
|
+
* @param price The price of the specified item
|
|
205
|
+
* @param sellerKiosk The kiosk which is selling the item. Can be an id or an object argument.
|
|
206
|
+
* @param extraArgs Used to pass arguments for custom rule resolvers.
|
|
207
|
+
*/
|
|
208
|
+
purchaseAndResolve({
|
|
209
|
+
itemType,
|
|
210
|
+
itemId,
|
|
211
|
+
price,
|
|
212
|
+
sellerKiosk,
|
|
213
|
+
extraArgs
|
|
214
|
+
}: ItemId & Price & {
|
|
215
|
+
sellerKiosk: ObjectArgument;
|
|
216
|
+
} & PurchaseOptions): Promise<this>;
|
|
217
|
+
/**
|
|
218
|
+
* A function to setup the client using an existing `ownerCap`,
|
|
219
|
+
* as return from the `kioskClient.getOwnedKiosks` function.
|
|
220
|
+
* @param cap `KioskOwnerCap` object as returned from `getOwnedKiosks` SDK call.
|
|
221
|
+
*/
|
|
222
|
+
setCap(cap: KioskOwnerCap): this | undefined;
|
|
223
|
+
/**
|
|
224
|
+
* A function that ends up the kiosk building tx & returns the `kioskOwnerCap` back to the
|
|
225
|
+
* `PersonalKioskCap`, in case we are operating on a personal kiosk.
|
|
226
|
+
* It will also share the `kiosk` if it's not shared, and finalize the transfer of the personal cap if it's pending.
|
|
227
|
+
*/
|
|
228
|
+
finalize(): void;
|
|
229
|
+
setKioskCap(cap: TransactionObjectArgument): this;
|
|
230
|
+
setKiosk(kiosk: TransactionObjectArgument): this;
|
|
231
|
+
getKiosk(): TransactionObjectArgument;
|
|
232
|
+
getKioskCap(): TransactionObjectArgument;
|
|
233
|
+
}
|
|
234
|
+
//#endregion
|
|
235
|
+
export { KioskTransaction, KioskTransactionParams };
|
|
236
|
+
//# sourceMappingURL=kiosk-transaction.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kiosk-transaction.d.mts","names":[],"sources":["../../src/client/kiosk-transaction.ts"],"sourcesContent":[],"mappings":";;;;;;KAyBY,sBAAA;;eAEE;EAFF;;;EAaL,WAAA,EANO,WAMP;EAAa;AAMpB;;;;EAIY,GAAA,CAAA,EAVL,aAUK;CAYG;;;;AAsGH,cAtHC,gBAAA,CAsHD;EAAU,CAAA,OAAA;EAAU,WAAA,EArHlB,WAqHkB;EAAyB,WAAA,EApH3C,WAoH2C;EAoB/C,KAAA,CAAA,EAvID,yBAuIC;EAAU,QAAA,CAAA,EAtIR,yBAsIQ;EAAU,WAAA,CAAA;IAAA,WAAA;IAAA,WAAA;IAAA;EAAA,CAAA,EA1HkB,sBA0HlB;EAAU;;;;;EAgBH,MAAA,CAAA,CAAA,EAAA,IAAA;EAAuB;;;;;EAmDlC,cAAA,CAAA,MAAA,CAAA,EAAA,OAAA,CAAA,EAAA,IAAA;EAAM;;;;EAmBd,iBAAA,CAAA,MAAA,CAAA,EAAA,OAAA,CAAA,EAAA,IAAA;EAAQ;;;EAiBN,cAAA,CAAA,OAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAAU;;;EAiBF,KAAA,CAAA,CAAA,EAAA,IAAA;EAAS;;;;EAkBI,mBAAA,CAAA,OAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAgBvC;;;;EAIE,QAAA,CAAA;IAAA,QAAA;IAAA;EAAA,CAAA,EAlL4B,MAkL5B,EAAA,QAAA,EAAA,CAAA,IAAA,EAlLqD,mBAkLrD,EAAA,GAAA,IAAA,CAAA,EAAA,IAAA;EAA0B;;;;;;EA+BjB,MAAA,CAAA;IAAA,QAAA;IAAA;EAAA,CAAA,EA7LiB,MA6LjB,CAAA,EAAA,CA7L2B,mBA6L3B,EA7LgD,mBA6LhD,CAAA;EAAuB;;;;EA6BlC,MAAA,CAAA;IAAA,QAAA;IAAA,IAAA;IAAA;EAEA,CAFA,EA1MmC,SA0MnC,GAAA;IACA,OAAA,EA3M0D,mBA2M1D;EACA,CAAA,CAAA,EAAA,IAAA;EACA;;;;;EACoE,QAAA,CAAA,OAAA,EAAA,MAAA,EAAA,MAAA,CAAA,EAAA,MAAA,GAAA,MAAA,GAAA,MAAA,CAAA,EAAA,IAAA;EAiEzD;;;;;EAyFD,KAAA,CAAA;IAAA,QAAA;IAAA;EAAA,CAAA,EAvUe,aAuUf,CAAA,EAAA,IAAA;;;;;;;;;;;KArT6B,gBAAgB;;;;;;;;;;;KAmBtB;;;;;;;;;;;KAiBL;;;;;;;;;KAiBF,SAAS;;;;;;;;;;;;KAkBI;;;;;;;;;;;;;;;KAoBrC;YAA0B;;;;;;;;;;;;;;;;;KA+B1B,SAAS;iBAAuB;OAClC,2BACA;;;;;;;;;;;;;;;;;KA+BE,SAAS;iBAAuB;MAAmB,kBAAe;;;;;;cAiEzD;;;;;;;mBAgEK;kBAMD;cAUR;iBASG"}
|