@mysten/kiosk 0.5.3 → 0.7.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +2 -287
  3. package/dist/client/kiosk-client.d.ts +64 -0
  4. package/dist/client/kiosk-transaction.d.ts +207 -0
  5. package/dist/client/tp-transaction.d.ts +112 -0
  6. package/dist/constants.d.ts +30 -4
  7. package/dist/index.d.ts +3 -6
  8. package/dist/index.js +1247 -257
  9. package/dist/index.js.map +1 -1
  10. package/dist/index.mjs +1230 -223
  11. package/dist/index.mjs.map +1 -1
  12. package/dist/query/kiosk.d.ts +2 -1
  13. package/dist/query/transfer-policy.d.ts +17 -1
  14. package/dist/tx/kiosk.d.ts +7 -23
  15. package/dist/tx/personal-kiosk.d.ts +7 -0
  16. package/dist/tx/rules/attach.d.ts +7 -0
  17. package/dist/tx/rules/resolve.d.ts +15 -0
  18. package/dist/tx/transfer-policy.d.ts +13 -16
  19. package/dist/types/index.d.ts +22 -4
  20. package/dist/types/kiosk.d.ts +30 -1
  21. package/dist/types/transfer-policy.d.ts +27 -1
  22. package/dist/utils.d.ts +32 -18
  23. package/package.json +12 -4
  24. package/src/bcs.ts +1 -0
  25. package/src/client/kiosk-client.ts +156 -0
  26. package/src/client/kiosk-transaction.ts +512 -0
  27. package/src/client/tp-transaction.ts +350 -0
  28. package/src/constants.ts +113 -6
  29. package/src/index.ts +3 -6
  30. package/src/query/kiosk.ts +51 -18
  31. package/src/query/transfer-policy.ts +82 -2
  32. package/src/tx/kiosk.ts +18 -146
  33. package/src/tx/personal-kiosk.ts +35 -0
  34. package/src/tx/rules/attach.ts +74 -0
  35. package/src/tx/rules/resolve.ts +87 -0
  36. package/src/tx/transfer-policy.ts +40 -78
  37. package/src/types/index.ts +25 -4
  38. package/src/types/kiosk.ts +26 -1
  39. package/src/types/transfer-policy.ts +35 -1
  40. package/src/utils.ts +141 -33
  41. package/dist/tx/rules.d.ts +0 -19
  42. package/dist/types/env.d.ts +0 -12
  43. package/src/tx/rules.ts +0 -58
  44. package/src/types/env.ts +0 -20
@@ -0,0 +1,112 @@
1
+ import { type TransactionBlock } from '@mysten/sui.js/transactions';
2
+ import { TransferPolicyCap, type ObjectArgument } from '../types';
3
+ import { KioskClient } from './kiosk-client';
4
+ export type TransferPolicyBaseParams = {
5
+ type: string;
6
+ publisher: ObjectArgument;
7
+ skipCheck?: boolean;
8
+ };
9
+ export type TransferPolicyTransactionParams = {
10
+ kioskClient: KioskClient;
11
+ transactionBlock: TransactionBlock;
12
+ cap?: TransferPolicyCap;
13
+ };
14
+ export declare class TransferPolicyTransaction {
15
+ #private;
16
+ transactionBlock: TransactionBlock;
17
+ kioskClient: KioskClient;
18
+ policy?: ObjectArgument;
19
+ policyCap?: ObjectArgument;
20
+ type?: string;
21
+ constructor({ kioskClient, transactionBlock, cap }: TransferPolicyTransactionParams);
22
+ /**
23
+ * A function to create a new transfer policy.
24
+ * Checks if there's already an existing transfer policy to prevent
25
+ * double transfer polciy mistakes.
26
+ * There's an optional `skipCheck` flag that will just create the policy
27
+ * without checking
28
+ *
29
+ * @param type The Type (`T`) for which we're creating the transfer policy.
30
+ * @param publisher The Publisher Object Id.
31
+ * @param address Address to save the `TransferPolicyCap` object to.
32
+ * @param skipCheck (Optional) skip checking if a transfer policy already exists
33
+ */
34
+ createAndShare({ type, publisher, address, skipCheck, }: TransferPolicyBaseParams & {
35
+ address: string;
36
+ }): Promise<void>;
37
+ /**
38
+ * A convenient function to create a Transfer Policy and attach some rules
39
+ * before sharing it (so you can prepare it in a single PTB)
40
+ * @param type The Type (`T`) for which we're creating the transfer policy.
41
+ * @param publisher The Publisher Object Id.
42
+ * @param address Address to save the `TransferPolicyCap` object to.
43
+ * @param skipCheck (Optional) skip checking if a transfer policy already exists
44
+ */
45
+ create({ type, publisher, skipCheck, }: TransferPolicyBaseParams): Promise<TransferPolicyTransaction>;
46
+ /**
47
+ * This can be called after calling the `create` function to share the `TransferPolicy`,
48
+ * and transfer the `TransferPolicyCap` to the specified address
49
+ *
50
+ * @param address The address to transfer the `TransferPolicyCap`
51
+ */
52
+ shareAndTransferCap(address: string): void;
53
+ /**
54
+ * Setup the TransferPolicy by passing a `cap` returned from `kioskClient.getOwnedTransferPolicies` or
55
+ * `kioskClient.getOwnedTransferPoliciesByType`.
56
+ * @param policyCapId The `TransferPolicyCap`
57
+ */
58
+ setCap({ policyId, policyCapId, type }: TransferPolicyCap): this;
59
+ /**
60
+ * Withdraw from the transfer policy's profits.
61
+ * @param address Address to transfer the profits to.
62
+ * @param amount (Optional) amount parameter. Will withdraw all profits if the amount is not specified.
63
+ */
64
+ withdraw(address: string, amount?: string | bigint): this;
65
+ /**
66
+ * Adds the Kiosk Royalty rule to the Transfer Policy.
67
+ * You can pass the percentage, as well as a minimum amount.
68
+ * The royalty that will be paid is the MAX(percentage, minAmount).
69
+ * You can pass 0 in either value if you want only percentage royalty, or a fixed amount fee.
70
+ * (but you should define at least one of them for the rule to make sense).
71
+ *
72
+ * @param percentageBps The royalty percentage in basis points. Use `percentageToBasisPoints` helper to convert from percentage [0,100].
73
+ * @param minAmount The minimum royalty amount per request in MIST.
74
+ */
75
+ addRoyaltyRule(percentageBps: number | string, // this is in basis points.
76
+ minAmount: number | string): this;
77
+ /**
78
+ * Adds the Kiosk Lock Rule to the Transfer Policy.
79
+ * This Rule forces buyer to lock the item in the kiosk, preserving strong royalties.
80
+ */
81
+ addLockRule(): this;
82
+ /**
83
+ * Attaches the Personal Kiosk Rule, making a purchase valid only for `SoulBound` kiosks.
84
+ */
85
+ addPersonalKioskRule(): this;
86
+ /**
87
+ * A function to add the floor price rule to a transfer policy.
88
+ * @param minPrice The minimum price in MIST.
89
+ */
90
+ addFloorPriceRule(minPrice: string | bigint): this;
91
+ /**
92
+ * Generic helper to remove a rule, not from the SDK's base ruleset.
93
+ * @param ruleType The Rule Type
94
+ * @param configType The Config Type
95
+ */
96
+ removeRule({ ruleType, configType }: {
97
+ ruleType: string;
98
+ configType: string;
99
+ }): void;
100
+ /**
101
+ * Removes the lock rule.
102
+ */
103
+ removeLockRule(): this;
104
+ /**
105
+ * Removes the Royalty rule
106
+ */
107
+ removeRoyaltyRule(): this;
108
+ removePersonalKioskRule(): this;
109
+ removeFloorPriceRule(): this;
110
+ getPolicy(): ObjectArgument;
111
+ getPolicyCap(): ObjectArgument;
112
+ }
@@ -1,4 +1,30 @@
1
- /** The Transer Policy Rules package address on testnet */
2
- export declare const TESTNET_RULES_PACKAGE_ADDRESS = "bd8fc1947cf119350184107a3087e2dc27efefa0dd82e25a1f699069fe81a585";
3
- /** The transfer policy rules package address on mainnet */
4
- export declare const MAINNET_RULES_PACKAGE_ADDRESS = "0x434b5bd8f6a7b05fede0ff46c6e511d71ea326ed38056e3bcd681d2d7c2a7879";
1
+ import { Network, type ObjectArgument, type RuleResolvingParams } from './types';
2
+ /**
3
+ * The base rule package ids that can be extended
4
+ */
5
+ export type BaseRulePackageIds = {
6
+ royaltyRulePackageId?: string;
7
+ kioskLockRulePackageId?: string;
8
+ personalKioskRulePackageId?: string;
9
+ floorPriceRulePackageId?: string;
10
+ };
11
+ /**
12
+ * The Transfer Policy rule.
13
+ */
14
+ export type TransferPolicyRule = {
15
+ rule: string;
16
+ packageId: string;
17
+ resolveRuleFunction: (rule: RuleResolvingParams) => ObjectArgument | void;
18
+ hasLockingRule?: boolean;
19
+ };
20
+ export declare const ROYALTY_RULE_ADDRESS: Record<Network, string>;
21
+ export declare const KIOSK_LOCK_RULE_ADDRESS: Record<Network, string>;
22
+ export declare const FLOOR_PRICE_RULE_ADDRESS: Record<Network, string>;
23
+ export declare const PERSONAL_KIOSK_RULE_ADDRESS: Record<Network, string>;
24
+ /**
25
+ * Constructs a list of rule resolvers based on the params.
26
+ */
27
+ export declare function getBaseRules({ royaltyRulePackageId, kioskLockRulePackageId, personalKioskRulePackageId, floorPriceRulePackageId, }: BaseRulePackageIds): TransferPolicyRule[];
28
+ export declare const testnetRules: TransferPolicyRule[];
29
+ export declare const mainnetRules: TransferPolicyRule[];
30
+ export declare const rules: TransferPolicyRule[];
package/dist/index.d.ts CHANGED
@@ -1,9 +1,6 @@
1
- export * from './tx/kiosk';
2
- export * from './tx/transfer-policy';
3
- export * from './tx/rules';
4
- export * from './query/kiosk';
5
- export * from './bcs';
6
1
  export * from './utils';
7
- export * from './query/transfer-policy';
8
2
  export * from './types';
9
3
  export * from './constants';
4
+ export * from './client/kiosk-client';
5
+ export * from './client/tp-transaction';
6
+ export * from './client/kiosk-transaction';