@mysten/pas 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +1 -0
  2. package/dist/client.d.mts +117 -0
  3. package/dist/client.d.mts.map +1 -0
  4. package/dist/client.mjs +89 -0
  5. package/dist/client.mjs.map +1 -0
  6. package/dist/constants.mjs +9 -0
  7. package/dist/constants.mjs.map +1 -0
  8. package/dist/contracts/pas/deps/std/type_name.mjs +17 -0
  9. package/dist/contracts/pas/deps/std/type_name.mjs.map +1 -0
  10. package/dist/contracts/pas/deps/sui/vec_map.mjs +37 -0
  11. package/dist/contracts/pas/deps/sui/vec_map.mjs.map +1 -0
  12. package/dist/contracts/pas/deps/sui/vec_set.mjs +26 -0
  13. package/dist/contracts/pas/deps/sui/vec_set.mjs.map +1 -0
  14. package/dist/contracts/pas/policy.mjs +33 -0
  15. package/dist/contracts/pas/policy.mjs.map +1 -0
  16. package/dist/contracts/pas/versioning.mjs +25 -0
  17. package/dist/contracts/pas/versioning.mjs.map +1 -0
  18. package/dist/contracts/ptb/ptb.mjs +162 -0
  19. package/dist/contracts/ptb/ptb.mjs.map +1 -0
  20. package/dist/contracts/sui/dynamic_field.mjs +22 -0
  21. package/dist/contracts/sui/dynamic_field.mjs.map +1 -0
  22. package/dist/contracts/utils/index.mjs +37 -0
  23. package/dist/contracts/utils/index.mjs.map +1 -0
  24. package/dist/derivation.mjs +70 -0
  25. package/dist/derivation.mjs.map +1 -0
  26. package/dist/error.d.mts +16 -0
  27. package/dist/error.d.mts.map +1 -0
  28. package/dist/error.mjs +26 -0
  29. package/dist/error.mjs.map +1 -0
  30. package/dist/index.d.mts +4 -0
  31. package/dist/index.mjs +4 -0
  32. package/dist/intents.mjs +494 -0
  33. package/dist/intents.mjs.map +1 -0
  34. package/dist/resolution.mjs +185 -0
  35. package/dist/resolution.mjs.map +1 -0
  36. package/dist/types.d.mts +34 -0
  37. package/dist/types.d.mts.map +1 -0
  38. package/package.json +59 -0
  39. package/src/client.ts +173 -0
  40. package/src/constants.ts +15 -0
  41. package/src/contracts/pas/account.ts +343 -0
  42. package/src/contracts/pas/clawback_funds.ts +114 -0
  43. package/src/contracts/pas/deps/std/type_name.ts +24 -0
  44. package/src/contracts/pas/deps/sui/vec_map.ts +33 -0
  45. package/src/contracts/pas/deps/sui/vec_set.ts +22 -0
  46. package/src/contracts/pas/keys.ts +90 -0
  47. package/src/contracts/pas/namespace.ts +207 -0
  48. package/src/contracts/pas/policy.ts +212 -0
  49. package/src/contracts/pas/request.ts +87 -0
  50. package/src/contracts/pas/send_funds.ts +174 -0
  51. package/src/contracts/pas/templates.ts +101 -0
  52. package/src/contracts/pas/unlock_funds.ts +155 -0
  53. package/src/contracts/pas/versioning.ts +69 -0
  54. package/src/contracts/ptb/ptb.ts +821 -0
  55. package/src/contracts/sui/dynamic_field.ts +171 -0
  56. package/src/contracts/utils/index.ts +235 -0
  57. package/src/derivation.ts +107 -0
  58. package/src/error.ts +29 -0
  59. package/src/index.ts +6 -0
  60. package/src/intents.ts +852 -0
  61. package/src/resolution.ts +294 -0
  62. package/src/types.ts +34 -0
@@ -0,0 +1,101 @@
1
+ /**************************************************************
2
+ * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
3
+ **************************************************************/
4
+
5
+ /**
6
+ * Template stores all the Command templates for PAS.
7
+ *
8
+ * This is the lookup point for PTB resolution on the client-side! There's no
9
+ * versioning enforcement here, as this is purely an off-chain used endpoint.
10
+ */
11
+
12
+ import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';
13
+ import { bcs } from '@mysten/sui/bcs';
14
+ import { type Transaction } from '@mysten/sui/transactions';
15
+ const $moduleName = '@mysten/pas::templates';
16
+ export const PAS = new MoveStruct({
17
+ name: `${$moduleName}::PAS`,
18
+ fields: {
19
+ dummy_field: bcs.bool(),
20
+ },
21
+ });
22
+ export const Templates = new MoveStruct({
23
+ name: `${$moduleName}::Templates`,
24
+ fields: {
25
+ id: bcs.Address,
26
+ },
27
+ });
28
+ export interface SetupArguments {
29
+ namespace: RawTransactionArgument<string>;
30
+ }
31
+ export interface SetupOptions {
32
+ package?: string;
33
+ arguments: SetupArguments | [namespace: RawTransactionArgument<string>];
34
+ }
35
+ /** Create the templates registry */
36
+ export function setup(options: SetupOptions) {
37
+ const packageAddress = options.package ?? '@mysten/pas';
38
+ const argumentsTypes = [null] satisfies (string | null)[];
39
+ const parameterNames = ['namespace'];
40
+ return (tx: Transaction) =>
41
+ tx.moveCall({
42
+ package: packageAddress,
43
+ module: 'templates',
44
+ function: 'setup',
45
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
46
+ });
47
+ }
48
+ export interface SetTemplateCommandArguments {
49
+ templates: RawTransactionArgument<string>;
50
+ _: RawTransactionArgument<string>;
51
+ command: RawTransactionArgument<string>;
52
+ }
53
+ export interface SetTemplateCommandOptions {
54
+ package?: string;
55
+ arguments:
56
+ | SetTemplateCommandArguments
57
+ | [
58
+ templates: RawTransactionArgument<string>,
59
+ _: RawTransactionArgument<string>,
60
+ command: RawTransactionArgument<string>,
61
+ ];
62
+ typeArguments: [string];
63
+ }
64
+ /** Sets the PTB template for a given Action. */
65
+ export function setTemplateCommand(options: SetTemplateCommandOptions) {
66
+ const packageAddress = options.package ?? '@mysten/pas';
67
+ const argumentsTypes = [null, null, null] satisfies (string | null)[];
68
+ const parameterNames = ['templates', '_', 'command'];
69
+ return (tx: Transaction) =>
70
+ tx.moveCall({
71
+ package: packageAddress,
72
+ module: 'templates',
73
+ function: 'set_template_command',
74
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
75
+ typeArguments: options.typeArguments,
76
+ });
77
+ }
78
+ export interface UnsetTemplateCommandArguments {
79
+ templates: RawTransactionArgument<string>;
80
+ _: RawTransactionArgument<string>;
81
+ }
82
+ export interface UnsetTemplateCommandOptions {
83
+ package?: string;
84
+ arguments:
85
+ | UnsetTemplateCommandArguments
86
+ | [templates: RawTransactionArgument<string>, _: RawTransactionArgument<string>];
87
+ typeArguments: [string];
88
+ }
89
+ export function unsetTemplateCommand(options: UnsetTemplateCommandOptions) {
90
+ const packageAddress = options.package ?? '@mysten/pas';
91
+ const argumentsTypes = [null, null] satisfies (string | null)[];
92
+ const parameterNames = ['templates', '_'];
93
+ return (tx: Transaction) =>
94
+ tx.moveCall({
95
+ package: packageAddress,
96
+ module: 'templates',
97
+ function: 'unset_template_command',
98
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
99
+ typeArguments: options.typeArguments,
100
+ });
101
+ }
@@ -0,0 +1,155 @@
1
+ /**************************************************************
2
+ * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
3
+ **************************************************************/
4
+ import { type BcsType, bcs } from '@mysten/sui/bcs';
5
+ import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';
6
+ import { type Transaction } from '@mysten/sui/transactions';
7
+ const $moduleName = '@mysten/pas::unlock_funds';
8
+ /**
9
+ * An unlock funds request that is generated once a Permissioned Funds Transfer is
10
+ * initiated.
11
+ *
12
+ * This can be resolved in two ways:
13
+ *
14
+ * 1. If the asset is `permissioned` (there's a `Policy<T>` for that asset), it
15
+ * can only be resolved by the creator by calling
16
+ * `policy::resolve_unlock_funds`
17
+ * 2. If the asset is not permissioned, it can be resolved by any address by
18
+ * calling `unlock_funds::resolve_unrestricted_balance`
19
+ */
20
+ export function UnlockFunds<T extends BcsType<any>>(...typeParameters: [T]) {
21
+ return new MoveStruct({
22
+ name: `${$moduleName}::UnlockFunds<${typeParameters[0].name as T['name']}>`,
23
+ fields: {
24
+ /** `owner` is the wallet OR object address, NOT the account address */
25
+ owner: bcs.Address,
26
+ /** The ID of the account the funds are coming from */
27
+ account_id: bcs.Address,
28
+ /** The actual balance being transferred */
29
+ funds: typeParameters[0],
30
+ },
31
+ });
32
+ }
33
+ export interface OwnerArguments {
34
+ request: RawTransactionArgument<string>;
35
+ }
36
+ export interface OwnerOptions {
37
+ package?: string;
38
+ arguments: OwnerArguments | [request: RawTransactionArgument<string>];
39
+ typeArguments: [string];
40
+ }
41
+ export function owner(options: OwnerOptions) {
42
+ const packageAddress = options.package ?? '@mysten/pas';
43
+ const argumentsTypes = [null] satisfies (string | null)[];
44
+ const parameterNames = ['request'];
45
+ return (tx: Transaction) =>
46
+ tx.moveCall({
47
+ package: packageAddress,
48
+ module: 'unlock_funds',
49
+ function: 'owner',
50
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
51
+ typeArguments: options.typeArguments,
52
+ });
53
+ }
54
+ export interface AccountIdArguments {
55
+ request: RawTransactionArgument<string>;
56
+ }
57
+ export interface AccountIdOptions {
58
+ package?: string;
59
+ arguments: AccountIdArguments | [request: RawTransactionArgument<string>];
60
+ typeArguments: [string];
61
+ }
62
+ export function accountId(options: AccountIdOptions) {
63
+ const packageAddress = options.package ?? '@mysten/pas';
64
+ const argumentsTypes = [null] satisfies (string | null)[];
65
+ const parameterNames = ['request'];
66
+ return (tx: Transaction) =>
67
+ tx.moveCall({
68
+ package: packageAddress,
69
+ module: 'unlock_funds',
70
+ function: 'account_id',
71
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
72
+ typeArguments: options.typeArguments,
73
+ });
74
+ }
75
+ export interface FundsArguments {
76
+ request: RawTransactionArgument<string>;
77
+ }
78
+ export interface FundsOptions {
79
+ package?: string;
80
+ arguments: FundsArguments | [request: RawTransactionArgument<string>];
81
+ typeArguments: [string];
82
+ }
83
+ export function funds(options: FundsOptions) {
84
+ const packageAddress = options.package ?? '@mysten/pas';
85
+ const argumentsTypes = [null] satisfies (string | null)[];
86
+ const parameterNames = ['request'];
87
+ return (tx: Transaction) =>
88
+ tx.moveCall({
89
+ package: packageAddress,
90
+ module: 'unlock_funds',
91
+ function: 'funds',
92
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
93
+ typeArguments: options.typeArguments,
94
+ });
95
+ }
96
+ export interface ResolveUnrestrictedBalanceArguments {
97
+ request: RawTransactionArgument<string>;
98
+ namespace: RawTransactionArgument<string>;
99
+ }
100
+ export interface ResolveUnrestrictedBalanceOptions {
101
+ package?: string;
102
+ arguments:
103
+ | ResolveUnrestrictedBalanceArguments
104
+ | [request: RawTransactionArgument<string>, namespace: RawTransactionArgument<string>];
105
+ typeArguments: [string];
106
+ }
107
+ /**
108
+ * This enables unlocking assets that are not managed by a Policy within the
109
+ * system. If a `Policy<T>` exists, they can only be resolved from within the
110
+ * system.
111
+ *
112
+ * For example, `SUI` will never be a managed asset, so the owner needs to be able
113
+ * to withdraw if anyone transfers some to their account.
114
+ */
115
+ export function resolveUnrestrictedBalance(options: ResolveUnrestrictedBalanceOptions) {
116
+ const packageAddress = options.package ?? '@mysten/pas';
117
+ const argumentsTypes = [null, null] satisfies (string | null)[];
118
+ const parameterNames = ['request', 'namespace'];
119
+ return (tx: Transaction) =>
120
+ tx.moveCall({
121
+ package: packageAddress,
122
+ module: 'unlock_funds',
123
+ function: 'resolve_unrestricted_balance',
124
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
125
+ typeArguments: options.typeArguments,
126
+ });
127
+ }
128
+ export interface ResolveArguments {
129
+ request: RawTransactionArgument<string>;
130
+ policy: RawTransactionArgument<string>;
131
+ }
132
+ export interface ResolveOptions {
133
+ package?: string;
134
+ arguments:
135
+ | ResolveArguments
136
+ | [request: RawTransactionArgument<string>, policy: RawTransactionArgument<string>];
137
+ typeArguments: [string];
138
+ }
139
+ /**
140
+ * Resolve an unlock funds request as long as funds management is enabled and there
141
+ * are enough valid approvals.
142
+ */
143
+ export function resolve(options: ResolveOptions) {
144
+ const packageAddress = options.package ?? '@mysten/pas';
145
+ const argumentsTypes = [null, null] satisfies (string | null)[];
146
+ const parameterNames = ['request', 'policy'];
147
+ return (tx: Transaction) =>
148
+ tx.moveCall({
149
+ package: packageAddress,
150
+ module: 'unlock_funds',
151
+ function: 'resolve',
152
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
153
+ typeArguments: options.typeArguments,
154
+ });
155
+ }
@@ -0,0 +1,69 @@
1
+ /**************************************************************
2
+ * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
3
+ **************************************************************/
4
+
5
+ /**
6
+ * Versioning module.
7
+ *
8
+ * This module is responsible for managing the versioning of the package.
9
+ *
10
+ * It allows for blocking specific versions of the package in case of emergency, or
11
+ * to slowly deprecate an earlier feature.
12
+ */
13
+
14
+ import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';
15
+ import { bcs } from '@mysten/sui/bcs';
16
+ import { type Transaction } from '@mysten/sui/transactions';
17
+ import * as vec_set from './deps/sui/vec_set.js';
18
+ const $moduleName = '@mysten/pas::versioning';
19
+ export const Versioning = new MoveStruct({
20
+ name: `${$moduleName}::Versioning`,
21
+ fields: {
22
+ blocked_versions: vec_set.VecSet(bcs.u64()),
23
+ },
24
+ });
25
+ export interface IsValidVersionArguments {
26
+ versioning: RawTransactionArgument<string>;
27
+ version: RawTransactionArgument<number | bigint>;
28
+ }
29
+ export interface IsValidVersionOptions {
30
+ package?: string;
31
+ arguments:
32
+ | IsValidVersionArguments
33
+ | [
34
+ versioning: RawTransactionArgument<string>,
35
+ version: RawTransactionArgument<number | bigint>,
36
+ ];
37
+ }
38
+ /** Verify that a version is not part of the blocked version list. */
39
+ export function isValidVersion(options: IsValidVersionOptions) {
40
+ const packageAddress = options.package ?? '@mysten/pas';
41
+ const argumentsTypes = [null, 'u64'] satisfies (string | null)[];
42
+ const parameterNames = ['versioning', 'version'];
43
+ return (tx: Transaction) =>
44
+ tx.moveCall({
45
+ package: packageAddress,
46
+ module: 'versioning',
47
+ function: 'is_valid_version',
48
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
49
+ });
50
+ }
51
+ export interface AssertIsValidVersionArguments {
52
+ versioning: RawTransactionArgument<string>;
53
+ }
54
+ export interface AssertIsValidVersionOptions {
55
+ package?: string;
56
+ arguments: AssertIsValidVersionArguments | [versioning: RawTransactionArgument<string>];
57
+ }
58
+ export function assertIsValidVersion(options: AssertIsValidVersionOptions) {
59
+ const packageAddress = options.package ?? '@mysten/pas';
60
+ const argumentsTypes = [null] satisfies (string | null)[];
61
+ const parameterNames = ['versioning'];
62
+ return (tx: Transaction) =>
63
+ tx.moveCall({
64
+ package: packageAddress,
65
+ module: 'versioning',
66
+ function: 'assert_is_valid_version',
67
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
68
+ });
69
+ }