@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,207 @@
1
+ /**************************************************************
2
+ * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
3
+ **************************************************************/
4
+
5
+ /**
6
+ * The Namespace module.
7
+ *
8
+ * Namespace is responsible for creating objects that are easy to query & find:
9
+ *
10
+ * 1. Accounts
11
+ * 2. Policies ... any other module we might add in the future
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 versioning from './versioning.js';
18
+ const $moduleName = '@mysten/pas::namespace';
19
+ export const Namespace = new MoveStruct({
20
+ name: `${$moduleName}::Namespace`,
21
+ fields: {
22
+ id: bcs.Address,
23
+ /**
24
+ * The UpgradeCap of the package, used as the "ownership" capability, mainly to
25
+ * block versions of the package in case of emergency.
26
+ */
27
+ upgrade_cap_id: bcs.option(bcs.Address),
28
+ /** Enables "blocking" versions of the package */
29
+ versioning: versioning.Versioning,
30
+ },
31
+ });
32
+ export interface SetupArguments {
33
+ namespace: RawTransactionArgument<string>;
34
+ cap: RawTransactionArgument<string>;
35
+ }
36
+ export interface SetupOptions {
37
+ package?: string;
38
+ arguments:
39
+ | SetupArguments
40
+ | [namespace: RawTransactionArgument<string>, cap: RawTransactionArgument<string>];
41
+ }
42
+ /**
43
+ * Setup the namespace (links the `UpgradeCap`) once after publishing. This makes
44
+ * the UpgradeCap the "admin" capability (which can set the blocked versions of a
45
+ * package).
46
+ */
47
+ export function setup(options: SetupOptions) {
48
+ const packageAddress = options.package ?? '@mysten/pas';
49
+ const argumentsTypes = [null, null] satisfies (string | null)[];
50
+ const parameterNames = ['namespace', 'cap'];
51
+ return (tx: Transaction) =>
52
+ tx.moveCall({
53
+ package: packageAddress,
54
+ module: 'namespace',
55
+ function: 'setup',
56
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
57
+ });
58
+ }
59
+ export interface BlockVersionArguments {
60
+ namespace: RawTransactionArgument<string>;
61
+ cap: RawTransactionArgument<string>;
62
+ version: RawTransactionArgument<number | bigint>;
63
+ }
64
+ export interface BlockVersionOptions {
65
+ package?: string;
66
+ arguments:
67
+ | BlockVersionArguments
68
+ | [
69
+ namespace: RawTransactionArgument<string>,
70
+ cap: RawTransactionArgument<string>,
71
+ version: RawTransactionArgument<number | bigint>,
72
+ ];
73
+ }
74
+ /**
75
+ * Allows the package admin to block a version of the package.
76
+ *
77
+ * This is only used in case of emergency (e.g. security consideration), or if
78
+ * there is a breaking change
79
+ */
80
+ export function blockVersion(options: BlockVersionOptions) {
81
+ const packageAddress = options.package ?? '@mysten/pas';
82
+ const argumentsTypes = [null, null, 'u64'] satisfies (string | null)[];
83
+ const parameterNames = ['namespace', 'cap', 'version'];
84
+ return (tx: Transaction) =>
85
+ tx.moveCall({
86
+ package: packageAddress,
87
+ module: 'namespace',
88
+ function: 'block_version',
89
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
90
+ });
91
+ }
92
+ export interface UnblockVersionArguments {
93
+ namespace: RawTransactionArgument<string>;
94
+ cap: RawTransactionArgument<string>;
95
+ version: RawTransactionArgument<number | bigint>;
96
+ }
97
+ export interface UnblockVersionOptions {
98
+ package?: string;
99
+ arguments:
100
+ | UnblockVersionArguments
101
+ | [
102
+ namespace: RawTransactionArgument<string>,
103
+ cap: RawTransactionArgument<string>,
104
+ version: RawTransactionArgument<number | bigint>,
105
+ ];
106
+ }
107
+ /** Allows the package admin to unblock a version of the package. */
108
+ export function unblockVersion(options: UnblockVersionOptions) {
109
+ const packageAddress = options.package ?? '@mysten/pas';
110
+ const argumentsTypes = [null, null, 'u64'] satisfies (string | null)[];
111
+ const parameterNames = ['namespace', 'cap', 'version'];
112
+ return (tx: Transaction) =>
113
+ tx.moveCall({
114
+ package: packageAddress,
115
+ module: 'namespace',
116
+ function: 'unblock_version',
117
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
118
+ });
119
+ }
120
+ export interface PolicyExistsArguments {
121
+ namespace: RawTransactionArgument<string>;
122
+ }
123
+ export interface PolicyExistsOptions {
124
+ package?: string;
125
+ arguments: PolicyExistsArguments | [namespace: RawTransactionArgument<string>];
126
+ typeArguments: [string];
127
+ }
128
+ /** Check if `Policy<T>` exists in the namespace */
129
+ export function policyExists(options: PolicyExistsOptions) {
130
+ const packageAddress = options.package ?? '@mysten/pas';
131
+ const argumentsTypes = [null] satisfies (string | null)[];
132
+ const parameterNames = ['namespace'];
133
+ return (tx: Transaction) =>
134
+ tx.moveCall({
135
+ package: packageAddress,
136
+ module: 'namespace',
137
+ function: 'policy_exists',
138
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
139
+ typeArguments: options.typeArguments,
140
+ });
141
+ }
142
+ export interface PolicyAddressArguments {
143
+ namespace: RawTransactionArgument<string>;
144
+ }
145
+ export interface PolicyAddressOptions {
146
+ package?: string;
147
+ arguments: PolicyAddressArguments | [namespace: RawTransactionArgument<string>];
148
+ typeArguments: [string];
149
+ }
150
+ /** The derived address for `Policy<T>` */
151
+ export function policyAddress(options: PolicyAddressOptions) {
152
+ const packageAddress = options.package ?? '@mysten/pas';
153
+ const argumentsTypes = [null] satisfies (string | null)[];
154
+ const parameterNames = ['namespace'];
155
+ return (tx: Transaction) =>
156
+ tx.moveCall({
157
+ package: packageAddress,
158
+ module: 'namespace',
159
+ function: 'policy_address',
160
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
161
+ typeArguments: options.typeArguments,
162
+ });
163
+ }
164
+ export interface AccountExistsArguments {
165
+ namespace: RawTransactionArgument<string>;
166
+ owner: RawTransactionArgument<string>;
167
+ }
168
+ export interface AccountExistsOptions {
169
+ package?: string;
170
+ arguments:
171
+ | AccountExistsArguments
172
+ | [namespace: RawTransactionArgument<string>, owner: RawTransactionArgument<string>];
173
+ }
174
+ export function accountExists(options: AccountExistsOptions) {
175
+ const packageAddress = options.package ?? '@mysten/pas';
176
+ const argumentsTypes = [null, 'address'] satisfies (string | null)[];
177
+ const parameterNames = ['namespace', 'owner'];
178
+ return (tx: Transaction) =>
179
+ tx.moveCall({
180
+ package: packageAddress,
181
+ module: 'namespace',
182
+ function: 'account_exists',
183
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
184
+ });
185
+ }
186
+ export interface AccountAddressArguments {
187
+ namespace: RawTransactionArgument<string>;
188
+ owner: RawTransactionArgument<string>;
189
+ }
190
+ export interface AccountAddressOptions {
191
+ package?: string;
192
+ arguments:
193
+ | AccountAddressArguments
194
+ | [namespace: RawTransactionArgument<string>, owner: RawTransactionArgument<string>];
195
+ }
196
+ export function accountAddress(options: AccountAddressOptions) {
197
+ const packageAddress = options.package ?? '@mysten/pas';
198
+ const argumentsTypes = [null, 'address'] satisfies (string | null)[];
199
+ const parameterNames = ['namespace', 'owner'];
200
+ return (tx: Transaction) =>
201
+ tx.moveCall({
202
+ package: packageAddress,
203
+ module: 'namespace',
204
+ function: 'account_address',
205
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
206
+ });
207
+ }
@@ -0,0 +1,212 @@
1
+ /**************************************************************
2
+ * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
3
+ **************************************************************/
4
+ import {
5
+ MoveStruct,
6
+ MoveTuple,
7
+ normalizeMoveArguments,
8
+ type RawTransactionArgument,
9
+ } from '../utils/index.js';
10
+ import { bcs } from '@mysten/sui/bcs';
11
+ import { type Transaction } from '@mysten/sui/transactions';
12
+ import * as vec_map from './deps/sui/vec_map.js';
13
+ import * as vec_set from './deps/sui/vec_set.js';
14
+ import * as type_name from './deps/std/type_name.js';
15
+ import * as versioning from './versioning.js';
16
+ const $moduleName = '@mysten/pas::policy';
17
+ export const Policy = new MoveStruct({
18
+ name: `${$moduleName}::Policy<phantom T>`,
19
+ fields: {
20
+ id: bcs.Address,
21
+ /**
22
+ * The required approvals per request type. The key must be one of the request
23
+ * types (e.g. `send_funds`, `unlock_funds` or `clawback_funds`).
24
+ *
25
+ * The value is a vector of approvals that need to be gather to resolve the
26
+ * request.
27
+ */
28
+ required_approvals: vec_map.VecMap(bcs.string(), vec_set.VecSet(type_name.TypeName)),
29
+ /**
30
+ * Block versions to break backwards compatibility -- only used in case of
31
+ * emergency.
32
+ */
33
+ versioning: versioning.Versioning,
34
+ /** Whether clawback is allowed for this policy. */
35
+ clawback_allowed: bcs.bool(),
36
+ },
37
+ });
38
+ export const PolicyCap = new MoveStruct({
39
+ name: `${$moduleName}::PolicyCap<phantom T>`,
40
+ fields: {
41
+ id: bcs.Address,
42
+ },
43
+ });
44
+ export const PolicyCapKey = new MoveTuple({
45
+ name: `${$moduleName}::PolicyCapKey`,
46
+ fields: [bcs.bool()],
47
+ });
48
+ export interface NewForCurrencyArguments {
49
+ namespace: RawTransactionArgument<string>;
50
+ Cap: RawTransactionArgument<string>;
51
+ clawbackAllowed: RawTransactionArgument<boolean>;
52
+ }
53
+ export interface NewForCurrencyOptions {
54
+ package?: string;
55
+ arguments:
56
+ | NewForCurrencyArguments
57
+ | [
58
+ namespace: RawTransactionArgument<string>,
59
+ Cap: RawTransactionArgument<string>,
60
+ clawbackAllowed: RawTransactionArgument<boolean>,
61
+ ];
62
+ typeArguments: [string];
63
+ }
64
+ export function newForCurrency(options: NewForCurrencyOptions) {
65
+ const packageAddress = options.package ?? '@mysten/pas';
66
+ const argumentsTypes = [null, null, 'bool'] satisfies (string | null)[];
67
+ const parameterNames = ['namespace', 'Cap', 'clawbackAllowed'];
68
+ return (tx: Transaction) =>
69
+ tx.moveCall({
70
+ package: packageAddress,
71
+ module: 'policy',
72
+ function: 'new_for_currency',
73
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
74
+ typeArguments: options.typeArguments,
75
+ });
76
+ }
77
+ export interface ShareArguments {
78
+ policy: RawTransactionArgument<string>;
79
+ }
80
+ export interface ShareOptions {
81
+ package?: string;
82
+ arguments: ShareArguments | [policy: RawTransactionArgument<string>];
83
+ typeArguments: [string];
84
+ }
85
+ export function share(options: ShareOptions) {
86
+ const packageAddress = options.package ?? '@mysten/pas';
87
+ const argumentsTypes = [null] satisfies (string | null)[];
88
+ const parameterNames = ['policy'];
89
+ return (tx: Transaction) =>
90
+ tx.moveCall({
91
+ package: packageAddress,
92
+ module: 'policy',
93
+ function: 'share',
94
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
95
+ typeArguments: options.typeArguments,
96
+ });
97
+ }
98
+ export interface RequiredApprovalsArguments {
99
+ policy: RawTransactionArgument<string>;
100
+ actionType: RawTransactionArgument<string>;
101
+ }
102
+ export interface RequiredApprovalsOptions {
103
+ package?: string;
104
+ arguments:
105
+ | RequiredApprovalsArguments
106
+ | [policy: RawTransactionArgument<string>, actionType: RawTransactionArgument<string>];
107
+ typeArguments: [string];
108
+ }
109
+ /** Get the set of required approvals for a given action. */
110
+ export function requiredApprovals(options: RequiredApprovalsOptions) {
111
+ const packageAddress = options.package ?? '@mysten/pas';
112
+ const argumentsTypes = [null, '0x1::string::String'] satisfies (string | null)[];
113
+ const parameterNames = ['policy', 'actionType'];
114
+ return (tx: Transaction) =>
115
+ tx.moveCall({
116
+ package: packageAddress,
117
+ module: 'policy',
118
+ function: 'required_approvals',
119
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
120
+ typeArguments: options.typeArguments,
121
+ });
122
+ }
123
+ export interface SetRequiredApprovalArguments {
124
+ policy: RawTransactionArgument<string>;
125
+ cap: RawTransactionArgument<string>;
126
+ action: RawTransactionArgument<string>;
127
+ }
128
+ export interface SetRequiredApprovalOptions {
129
+ package?: string;
130
+ arguments:
131
+ | SetRequiredApprovalArguments
132
+ | [
133
+ policy: RawTransactionArgument<string>,
134
+ cap: RawTransactionArgument<string>,
135
+ action: RawTransactionArgument<string>,
136
+ ];
137
+ typeArguments: [string, string];
138
+ }
139
+ export function setRequiredApproval(options: SetRequiredApprovalOptions) {
140
+ const packageAddress = options.package ?? '@mysten/pas';
141
+ const argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[];
142
+ const parameterNames = ['policy', 'cap', 'action'];
143
+ return (tx: Transaction) =>
144
+ tx.moveCall({
145
+ package: packageAddress,
146
+ module: 'policy',
147
+ function: 'set_required_approval',
148
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
149
+ typeArguments: options.typeArguments,
150
+ });
151
+ }
152
+ export interface RemoveActionApprovalArguments {
153
+ policy: RawTransactionArgument<string>;
154
+ _: RawTransactionArgument<string>;
155
+ action: RawTransactionArgument<string>;
156
+ }
157
+ export interface RemoveActionApprovalOptions {
158
+ package?: string;
159
+ arguments:
160
+ | RemoveActionApprovalArguments
161
+ | [
162
+ policy: RawTransactionArgument<string>,
163
+ _: RawTransactionArgument<string>,
164
+ action: RawTransactionArgument<string>,
165
+ ];
166
+ typeArguments: [string];
167
+ }
168
+ /**
169
+ * Remove the action approval for a given action (this will make all requests not
170
+ * resolve).
171
+ */
172
+ export function removeActionApproval(options: RemoveActionApprovalOptions) {
173
+ const packageAddress = options.package ?? '@mysten/pas';
174
+ const argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[];
175
+ const parameterNames = ['policy', '_', 'action'];
176
+ return (tx: Transaction) =>
177
+ tx.moveCall({
178
+ package: packageAddress,
179
+ module: 'policy',
180
+ function: 'remove_action_approval',
181
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
182
+ typeArguments: options.typeArguments,
183
+ });
184
+ }
185
+ export interface SyncVersioningArguments {
186
+ policy: RawTransactionArgument<string>;
187
+ namespace: RawTransactionArgument<string>;
188
+ }
189
+ export interface SyncVersioningOptions {
190
+ package?: string;
191
+ arguments:
192
+ | SyncVersioningArguments
193
+ | [policy: RawTransactionArgument<string>, namespace: RawTransactionArgument<string>];
194
+ typeArguments: [string];
195
+ }
196
+ /**
197
+ * Allows syncing the versioning of a policy to the namespace's versioning. This is
198
+ * permission-less and can be done by anyone.
199
+ */
200
+ export function syncVersioning(options: SyncVersioningOptions) {
201
+ const packageAddress = options.package ?? '@mysten/pas';
202
+ const argumentsTypes = [null, null] satisfies (string | null)[];
203
+ const parameterNames = ['policy', 'namespace'];
204
+ return (tx: Transaction) =>
205
+ tx.moveCall({
206
+ package: packageAddress,
207
+ module: 'policy',
208
+ function: 'sync_versioning',
209
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
210
+ typeArguments: options.typeArguments,
211
+ });
212
+ }
@@ -0,0 +1,87 @@
1
+ /**************************************************************
2
+ * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
3
+ **************************************************************/
4
+ import { type BcsType } from '@mysten/sui/bcs';
5
+ import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';
6
+ import { type Transaction } from '@mysten/sui/transactions';
7
+ import * as vec_set from './deps/sui/vec_set.js';
8
+ import * as type_name from './deps/std/type_name.js';
9
+ const $moduleName = '@mysten/pas::request';
10
+ /** A base request type. Examples: `Request<SendFunds<T>>` `Request<UnlockFunds<T>>` */
11
+ export function Request<K extends BcsType<any>>(...typeParameters: [K]) {
12
+ return new MoveStruct({
13
+ name: `${$moduleName}::Request<${typeParameters[0].name as K['name']}>`,
14
+ fields: {
15
+ /** The collected approvals for this request */
16
+ approvals: vec_set.VecSet(type_name.TypeName),
17
+ data: typeParameters[0],
18
+ },
19
+ });
20
+ }
21
+ export interface ApproveArguments<U extends BcsType<any>> {
22
+ request: RawTransactionArgument<string>;
23
+ Approval: RawTransactionArgument<U>;
24
+ }
25
+ export interface ApproveOptions<U extends BcsType<any>> {
26
+ package?: string;
27
+ arguments:
28
+ | ApproveArguments<U>
29
+ | [request: RawTransactionArgument<string>, Approval: RawTransactionArgument<U>];
30
+ typeArguments: [string, string];
31
+ }
32
+ /** Adds an approval to a request. Can be called to resolve rules */
33
+ export function approve<U extends BcsType<any>>(options: ApproveOptions<U>) {
34
+ const packageAddress = options.package ?? '@mysten/pas';
35
+ const argumentsTypes = [null, `${options.typeArguments[1]}`] satisfies (string | null)[];
36
+ const parameterNames = ['request', 'Approval'];
37
+ return (tx: Transaction) =>
38
+ tx.moveCall({
39
+ package: packageAddress,
40
+ module: 'request',
41
+ function: 'approve',
42
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
43
+ typeArguments: options.typeArguments,
44
+ });
45
+ }
46
+ export interface DataArguments {
47
+ request: RawTransactionArgument<string>;
48
+ }
49
+ export interface DataOptions {
50
+ package?: string;
51
+ arguments: DataArguments | [request: RawTransactionArgument<string>];
52
+ typeArguments: [string];
53
+ }
54
+ export function data(options: DataOptions) {
55
+ const packageAddress = options.package ?? '@mysten/pas';
56
+ const argumentsTypes = [null] satisfies (string | null)[];
57
+ const parameterNames = ['request'];
58
+ return (tx: Transaction) =>
59
+ tx.moveCall({
60
+ package: packageAddress,
61
+ module: 'request',
62
+ function: 'data',
63
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
64
+ typeArguments: options.typeArguments,
65
+ });
66
+ }
67
+ export interface ApprovalsArguments {
68
+ request: RawTransactionArgument<string>;
69
+ }
70
+ export interface ApprovalsOptions {
71
+ package?: string;
72
+ arguments: ApprovalsArguments | [request: RawTransactionArgument<string>];
73
+ typeArguments: [string];
74
+ }
75
+ export function approvals(options: ApprovalsOptions) {
76
+ const packageAddress = options.package ?? '@mysten/pas';
77
+ const argumentsTypes = [null] satisfies (string | null)[];
78
+ const parameterNames = ['request'];
79
+ return (tx: Transaction) =>
80
+ tx.moveCall({
81
+ package: packageAddress,
82
+ module: 'request',
83
+ function: 'approvals',
84
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
85
+ typeArguments: options.typeArguments,
86
+ });
87
+ }
@@ -0,0 +1,174 @@
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::send_funds';
8
+ /**
9
+ * A transfer request that is generated once a send funds request is initialized.
10
+ *
11
+ * A hot potato that is issued when a transfer is initiated. It can only be
12
+ * resolved by presenting a witness `U` that is the witness of `Policy<T>`
13
+ *
14
+ * This enables the `resolve` function of each smart contract to be flexible and
15
+ * implement its own mechanisms for validation. The individual resolution module
16
+ * can:
17
+ *
18
+ * - Check whitelists/blacklists
19
+ * - Enforce holding periods
20
+ * - Collect fees
21
+ * - Emit regulatory events
22
+ * - Handle dividends/distributions
23
+ * - Implement any jurisdiction-specific rules
24
+ */
25
+ export function SendFunds<T extends BcsType<any>>(...typeParameters: [T]) {
26
+ return new MoveStruct({
27
+ name: `${$moduleName}::SendFunds<${typeParameters[0].name as T['name']}>`,
28
+ fields: {
29
+ /** `sender` is the wallet OR object address, NOT the account address */
30
+ sender: bcs.Address,
31
+ /** `recipient` is the wallet OR object address, NOT the account address */
32
+ recipient: bcs.Address,
33
+ /** The ID of the account the funds are coming from */
34
+ sender_account_id: bcs.Address,
35
+ /** The ID of the account the funds are going to */
36
+ recipient_account_id: bcs.Address,
37
+ /** The balance being transferred */
38
+ funds: typeParameters[0],
39
+ },
40
+ });
41
+ }
42
+ export interface SenderArguments {
43
+ request: RawTransactionArgument<string>;
44
+ }
45
+ export interface SenderOptions {
46
+ package?: string;
47
+ arguments: SenderArguments | [request: RawTransactionArgument<string>];
48
+ typeArguments: [string];
49
+ }
50
+ export function sender(options: SenderOptions) {
51
+ const packageAddress = options.package ?? '@mysten/pas';
52
+ const argumentsTypes = [null] satisfies (string | null)[];
53
+ const parameterNames = ['request'];
54
+ return (tx: Transaction) =>
55
+ tx.moveCall({
56
+ package: packageAddress,
57
+ module: 'send_funds',
58
+ function: 'sender',
59
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
60
+ typeArguments: options.typeArguments,
61
+ });
62
+ }
63
+ export interface RecipientArguments {
64
+ request: RawTransactionArgument<string>;
65
+ }
66
+ export interface RecipientOptions {
67
+ package?: string;
68
+ arguments: RecipientArguments | [request: RawTransactionArgument<string>];
69
+ typeArguments: [string];
70
+ }
71
+ export function recipient(options: RecipientOptions) {
72
+ const packageAddress = options.package ?? '@mysten/pas';
73
+ const argumentsTypes = [null] satisfies (string | null)[];
74
+ const parameterNames = ['request'];
75
+ return (tx: Transaction) =>
76
+ tx.moveCall({
77
+ package: packageAddress,
78
+ module: 'send_funds',
79
+ function: 'recipient',
80
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
81
+ typeArguments: options.typeArguments,
82
+ });
83
+ }
84
+ export interface SenderAccountIdArguments {
85
+ request: RawTransactionArgument<string>;
86
+ }
87
+ export interface SenderAccountIdOptions {
88
+ package?: string;
89
+ arguments: SenderAccountIdArguments | [request: RawTransactionArgument<string>];
90
+ typeArguments: [string];
91
+ }
92
+ export function senderAccountId(options: SenderAccountIdOptions) {
93
+ const packageAddress = options.package ?? '@mysten/pas';
94
+ const argumentsTypes = [null] satisfies (string | null)[];
95
+ const parameterNames = ['request'];
96
+ return (tx: Transaction) =>
97
+ tx.moveCall({
98
+ package: packageAddress,
99
+ module: 'send_funds',
100
+ function: 'sender_account_id',
101
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
102
+ typeArguments: options.typeArguments,
103
+ });
104
+ }
105
+ export interface RecipientAccountIdArguments {
106
+ request: RawTransactionArgument<string>;
107
+ }
108
+ export interface RecipientAccountIdOptions {
109
+ package?: string;
110
+ arguments: RecipientAccountIdArguments | [request: RawTransactionArgument<string>];
111
+ typeArguments: [string];
112
+ }
113
+ export function recipientAccountId(options: RecipientAccountIdOptions) {
114
+ const packageAddress = options.package ?? '@mysten/pas';
115
+ const argumentsTypes = [null] satisfies (string | null)[];
116
+ const parameterNames = ['request'];
117
+ return (tx: Transaction) =>
118
+ tx.moveCall({
119
+ package: packageAddress,
120
+ module: 'send_funds',
121
+ function: 'recipient_account_id',
122
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
123
+ typeArguments: options.typeArguments,
124
+ });
125
+ }
126
+ export interface FundsArguments {
127
+ request: RawTransactionArgument<string>;
128
+ }
129
+ export interface FundsOptions {
130
+ package?: string;
131
+ arguments: FundsArguments | [request: RawTransactionArgument<string>];
132
+ typeArguments: [string];
133
+ }
134
+ export function funds(options: FundsOptions) {
135
+ const packageAddress = options.package ?? '@mysten/pas';
136
+ const argumentsTypes = [null] satisfies (string | null)[];
137
+ const parameterNames = ['request'];
138
+ return (tx: Transaction) =>
139
+ tx.moveCall({
140
+ package: packageAddress,
141
+ module: 'send_funds',
142
+ function: 'funds',
143
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
144
+ typeArguments: options.typeArguments,
145
+ });
146
+ }
147
+ export interface ResolveBalanceArguments {
148
+ request: RawTransactionArgument<string>;
149
+ policy: RawTransactionArgument<string>;
150
+ }
151
+ export interface ResolveBalanceOptions {
152
+ package?: string;
153
+ arguments:
154
+ | ResolveBalanceArguments
155
+ | [request: RawTransactionArgument<string>, policy: RawTransactionArgument<string>];
156
+ typeArguments: [string];
157
+ }
158
+ /**
159
+ * resolve a transfer request, if funds management is enabled & there are enough
160
+ * approvals.
161
+ */
162
+ export function resolveBalance(options: ResolveBalanceOptions) {
163
+ const packageAddress = options.package ?? '@mysten/pas';
164
+ const argumentsTypes = [null, null] satisfies (string | null)[];
165
+ const parameterNames = ['request', 'policy'];
166
+ return (tx: Transaction) =>
167
+ tx.moveCall({
168
+ package: packageAddress,
169
+ module: 'send_funds',
170
+ function: 'resolve_balance',
171
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
172
+ typeArguments: options.typeArguments,
173
+ });
174
+ }