@mysten/sui-groups 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 (46) hide show
  1. package/README.md +108 -0
  2. package/dist/bcs.d.mts +82 -0
  3. package/dist/bcs.d.mts.map +1 -0
  4. package/dist/bcs.mjs +55 -0
  5. package/dist/bcs.mjs.map +1 -0
  6. package/dist/call.d.mts +99 -0
  7. package/dist/call.d.mts.map +1 -0
  8. package/dist/call.mjs +171 -0
  9. package/dist/call.mjs.map +1 -0
  10. package/dist/client.d.mts +143 -0
  11. package/dist/client.d.mts.map +1 -0
  12. package/dist/client.mjs +173 -0
  13. package/dist/client.mjs.map +1 -0
  14. package/dist/constants.d.mts +65 -0
  15. package/dist/constants.d.mts.map +1 -0
  16. package/dist/constants.mjs +77 -0
  17. package/dist/constants.mjs.map +1 -0
  18. package/dist/contracts/sui_groups/deps/std/type_name.mjs +17 -0
  19. package/dist/contracts/sui_groups/deps/std/type_name.mjs.map +1 -0
  20. package/dist/contracts/sui_groups/permissioned_group.d.mts +84 -0
  21. package/dist/contracts/sui_groups/permissioned_group.d.mts.map +1 -0
  22. package/dist/contracts/sui_groups/permissioned_group.mjs +368 -0
  23. package/dist/contracts/sui_groups/permissioned_group.mjs.map +1 -0
  24. package/dist/contracts/sui_groups/permissions_table.mjs +26 -0
  25. package/dist/contracts/sui_groups/permissions_table.mjs.map +1 -0
  26. package/dist/contracts/utils/index.d.mts +35 -0
  27. package/dist/contracts/utils/index.d.mts.map +1 -0
  28. package/dist/contracts/utils/index.mjs +119 -0
  29. package/dist/contracts/utils/index.mjs.map +1 -0
  30. package/dist/error.d.mts +5 -0
  31. package/dist/error.d.mts.map +1 -0
  32. package/dist/error.mjs +6 -0
  33. package/dist/error.mjs.map +1 -0
  34. package/dist/index.d.mts +9 -0
  35. package/dist/index.mjs +9 -0
  36. package/dist/transactions.d.mts +110 -0
  37. package/dist/transactions.d.mts.map +1 -0
  38. package/dist/transactions.mjs +91 -0
  39. package/dist/transactions.mjs.map +1 -0
  40. package/dist/types.d.mts +221 -0
  41. package/dist/types.d.mts.map +1 -0
  42. package/dist/view.d.mts +85 -0
  43. package/dist/view.d.mts.map +1 -0
  44. package/dist/view.mjs +221 -0
  45. package/dist/view.mjs.map +1 -0
  46. package/package.json +57 -0
@@ -0,0 +1,368 @@
1
+ import { MoveStruct, MoveTuple, normalizeMoveArguments } from "../utils/index.mjs";
2
+ import { PermissionsTable } from "./permissions_table.mjs";
3
+ import { TypeName } from "./deps/std/type_name.mjs";
4
+ import { bcs } from "@mysten/sui/bcs";
5
+
6
+ //#region src/contracts/sui_groups/permissioned_group.ts
7
+ /**************************************************************
8
+ * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
9
+ **************************************************************/
10
+ /**
11
+ * Module: permissioned_group
12
+ *
13
+ * Generic permission system for group management.
14
+ *
15
+ * ## Permissions
16
+ *
17
+ * Core permissions (defined in this package):
18
+ *
19
+ * - `PermissionsAdmin`: Manages core permissions. Can grant/revoke
20
+ * PermissionsAdmin, ExtensionPermissionsAdmin, ObjectAdmin, Destroyer. Can
21
+ * remove members.
22
+ * - `ExtensionPermissionsAdmin`: Manages extension permissions defined in
23
+ * third-party packages.
24
+ * - `ObjectAdmin`: Admin-tier permission granting raw `&mut UID` access to the
25
+ * group object. Use cases include attaching dynamic fields or integrating with
26
+ * external protocols (e.g. SuiNS reverse lookup). Only accessible via the
27
+ * actor-object pattern (`object_uid` / `object_uid_mut`), which forces extending
28
+ * contracts to explicitly reason about the implications of mutating the group
29
+ * object.
30
+ * - `GroupDeleter`: Permission that allows destroying the group via `delete()`.
31
+ *
32
+ * ## Permission Scoping
33
+ *
34
+ * - `PermissionsAdmin` can ONLY manage core permissions (from this package):
35
+ * PermissionsAdmin, ExtensionPermissionsAdmin, ObjectAdmin, Destroyer
36
+ * - `ExtensionPermissionsAdmin` can ONLY manage extension permissions (from other
37
+ * packages)
38
+ *
39
+ * ## Key Concepts
40
+ *
41
+ * - **Membership is defined by permissions**: A member exists if and only if they
42
+ * have at least one permission
43
+ * - **Granting implicitly adds**: `grant_permission()` will automatically add a
44
+ * member if they don't exist
45
+ * - **Revoking may remove**: Revoking the last permission automatically removes
46
+ * the member from the group
47
+ *
48
+ * ## Invariants
49
+ *
50
+ * - At least one `PermissionsAdmin` must always exist
51
+ * - Members always have at least one permission (empty permission sets are not
52
+ * allowed)
53
+ */
54
+ const $moduleName = "@local-pkg/sui-groups::permissioned_group";
55
+ const PermissionsAdmin = new MoveTuple({
56
+ name: `${$moduleName}::PermissionsAdmin`,
57
+ fields: [bcs.bool()]
58
+ });
59
+ const ExtensionPermissionsAdmin = new MoveTuple({
60
+ name: `${$moduleName}::ExtensionPermissionsAdmin`,
61
+ fields: [bcs.bool()]
62
+ });
63
+ const ObjectAdmin = new MoveTuple({
64
+ name: `${$moduleName}::ObjectAdmin`,
65
+ fields: [bcs.bool()]
66
+ });
67
+ const GroupDeleter = new MoveTuple({
68
+ name: `${$moduleName}::GroupDeleter`,
69
+ fields: [bcs.bool()]
70
+ });
71
+ /**
72
+ * Group state mapping addresses to their granted permissions. Parameterized by `T`
73
+ * to scope permissions to a specific package.
74
+ */
75
+ function PermissionedGroup(...typeParameters) {
76
+ return new MoveStruct({
77
+ name: `${$moduleName}::PermissionedGroup<${typeParameters[0].name}>`,
78
+ fields: {
79
+ id: bcs.Address,
80
+ permissions: PermissionsTable,
81
+ permissions_admin_count: bcs.u64(),
82
+ creator: bcs.Address
83
+ }
84
+ });
85
+ }
86
+ const PausedMarker = new MoveTuple({
87
+ name: `${$moduleName}::PausedMarker`,
88
+ fields: [bcs.bool()]
89
+ });
90
+ /** Emitted when a new PermissionedGroup is created via `new`. */
91
+ function GroupCreated(...typeParameters) {
92
+ return new MoveStruct({
93
+ name: `${$moduleName}::GroupCreated<${typeParameters[0].name}>`,
94
+ fields: {
95
+ group_id: bcs.Address,
96
+ creator: bcs.Address
97
+ }
98
+ });
99
+ }
100
+ /** Emitted when a new PermissionedGroup is created via `new_derived`. */
101
+ function GroupDerived(...typeParameters) {
102
+ return new MoveStruct({
103
+ name: `${$moduleName}::GroupDerived<${typeParameters[0].name}, ${typeParameters[1].name}>`,
104
+ fields: {
105
+ group_id: bcs.Address,
106
+ creator: bcs.Address,
107
+ parent_id: bcs.Address,
108
+ derivation_key: typeParameters[1]
109
+ }
110
+ });
111
+ }
112
+ /** Emitted when a new member is added to a group via grant_permission. */
113
+ function MemberAdded(...typeParameters) {
114
+ return new MoveStruct({
115
+ name: `${$moduleName}::MemberAdded<${typeParameters[0].name}>`,
116
+ fields: {
117
+ group_id: bcs.Address,
118
+ member: bcs.Address
119
+ }
120
+ });
121
+ }
122
+ /** Emitted when a member is removed from a group. */
123
+ function MemberRemoved(...typeParameters) {
124
+ return new MoveStruct({
125
+ name: `${$moduleName}::MemberRemoved<${typeParameters[0].name}>`,
126
+ fields: {
127
+ group_id: bcs.Address,
128
+ member: bcs.Address
129
+ }
130
+ });
131
+ }
132
+ /** Emitted when permissions are granted to a member. */
133
+ function PermissionsGranted(...typeParameters) {
134
+ return new MoveStruct({
135
+ name: `${$moduleName}::PermissionsGranted<${typeParameters[0].name}>`,
136
+ fields: {
137
+ group_id: bcs.Address,
138
+ member: bcs.Address,
139
+ permissions: bcs.vector(TypeName)
140
+ }
141
+ });
142
+ }
143
+ /** Emitted when permissions are revoked from a member. */
144
+ function PermissionsRevoked(...typeParameters) {
145
+ return new MoveStruct({
146
+ name: `${$moduleName}::PermissionsRevoked<${typeParameters[0].name}>`,
147
+ fields: {
148
+ group_id: bcs.Address,
149
+ member: bcs.Address,
150
+ permissions: bcs.vector(TypeName)
151
+ }
152
+ });
153
+ }
154
+ /** Emitted when a PermissionedGroup is deleted via `delete`. */
155
+ function GroupDeleted(...typeParameters) {
156
+ return new MoveStruct({
157
+ name: `${$moduleName}::GroupDeleted<${typeParameters[0].name}>`,
158
+ fields: {
159
+ group_id: bcs.Address,
160
+ deleter: bcs.Address
161
+ }
162
+ });
163
+ }
164
+ /** Emitted when a PermissionedGroup is paused via `pause`. */
165
+ function GroupPaused(...typeParameters) {
166
+ return new MoveStruct({
167
+ name: `${$moduleName}::GroupPaused<${typeParameters[0].name}>`,
168
+ fields: {
169
+ group_id: bcs.Address,
170
+ paused_by: bcs.Address
171
+ }
172
+ });
173
+ }
174
+ /** Emitted when a PermissionedGroup is unpaused via `unpause`. */
175
+ function GroupUnpaused(...typeParameters) {
176
+ return new MoveStruct({
177
+ name: `${$moduleName}::GroupUnpaused<${typeParameters[0].name}>`,
178
+ fields: {
179
+ group_id: bcs.Address,
180
+ unpaused_by: bcs.Address
181
+ }
182
+ });
183
+ }
184
+ /**
185
+ * Deletes a PermissionedGroup, returning its components. Checks that
186
+ * `ctx.sender()` has `GroupDeleter` permission. Caller must extract any dynamic
187
+ * fields BEFORE calling this (the UID is deleted).
188
+ *
189
+ * # Type Parameters
190
+ *
191
+ * - `T`: Package witness type
192
+ *
193
+ * # Parameters
194
+ *
195
+ * - `self`: The PermissionedGroup to delete (by value)
196
+ * - `ctx`: Transaction context
197
+ *
198
+ * # Returns
199
+ *
200
+ * Tuple of (PermissionsTable, permissions_admin_count, creator)
201
+ *
202
+ * # Aborts
203
+ *
204
+ * - `ENotPermitted`: if caller doesn't have `GroupDeleter` permission
205
+ */
206
+ function _delete(options) {
207
+ const packageAddress = options.package ?? "@local-pkg/sui-groups";
208
+ const argumentsTypes = [null];
209
+ const parameterNames = ["self"];
210
+ return (tx) => tx.moveCall({
211
+ package: packageAddress,
212
+ module: "permissioned_group",
213
+ function: "delete",
214
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
215
+ typeArguments: options.typeArguments
216
+ });
217
+ }
218
+ /**
219
+ * Pauses the group, preventing all mutations. Returns an `UnpauseCap<T>` that is
220
+ * required to unpause.
221
+ *
222
+ * To use as an emergency fix: pause → fix state in a PTB → unpause. To archive
223
+ * (messaging layer): pause → store the returned cap as a DOF.
224
+ *
225
+ * # Aborts
226
+ *
227
+ * - `ENotPermitted`: if caller doesn't have `PermissionsAdmin`
228
+ * - `EAlreadyPaused`: if the group is already paused
229
+ */
230
+ function pause(options) {
231
+ const packageAddress = options.package ?? "@local-pkg/sui-groups";
232
+ const argumentsTypes = [null];
233
+ const parameterNames = ["self"];
234
+ return (tx) => tx.moveCall({
235
+ package: packageAddress,
236
+ module: "permissioned_group",
237
+ function: "pause",
238
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
239
+ typeArguments: options.typeArguments
240
+ });
241
+ }
242
+ /**
243
+ * Unpauses the group. Consumes and destroys the `UnpauseCap`.
244
+ *
245
+ * # Aborts
246
+ *
247
+ * - `EGroupIdMismatch`: if the cap belongs to a different group
248
+ */
249
+ function unpause(options) {
250
+ const packageAddress = options.package ?? "@local-pkg/sui-groups";
251
+ const argumentsTypes = [null, null];
252
+ const parameterNames = ["self", "cap"];
253
+ return (tx) => tx.moveCall({
254
+ package: packageAddress,
255
+ module: "permissioned_group",
256
+ function: "unpause",
257
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
258
+ typeArguments: options.typeArguments
259
+ });
260
+ }
261
+ /**
262
+ * Grants a permission to a member. If the member doesn't exist, they are
263
+ * automatically added to the group. Emits both `MemberAdded` (if new) and
264
+ * `PermissionsGranted` events.
265
+ *
266
+ * Permission requirements:
267
+ *
268
+ * - Core permissions: caller must have `PermissionsAdmin`
269
+ * - Extension permissions: caller must have `ExtensionPermissionsAdmin`
270
+ *
271
+ * # Type Parameters
272
+ *
273
+ * - `T`: Package witness type
274
+ * - `NewPermission`: Permission type to grant
275
+ *
276
+ * # Parameters
277
+ *
278
+ * - `self`: Mutable reference to the PermissionedGroup
279
+ * - `member`: Address of the member to grant permission to
280
+ * - `ctx`: Transaction context
281
+ *
282
+ * # Aborts
283
+ *
284
+ * - `ENotPermitted`: if caller doesn't have appropriate manager permission
285
+ */
286
+ function grantPermission(options) {
287
+ const packageAddress = options.package ?? "@local-pkg/sui-groups";
288
+ const argumentsTypes = [null, "address"];
289
+ const parameterNames = ["self", "member"];
290
+ return (tx) => tx.moveCall({
291
+ package: packageAddress,
292
+ module: "permissioned_group",
293
+ function: "grant_permission",
294
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
295
+ typeArguments: options.typeArguments
296
+ });
297
+ }
298
+ /**
299
+ * Removes a member from the PermissionedGroup. Requires `PermissionsAdmin`
300
+ * permission as this is a powerful admin operation.
301
+ *
302
+ * # Parameters
303
+ *
304
+ * - `self`: Mutable reference to the PermissionedGroup
305
+ * - `member`: Address of the member to remove
306
+ * - `ctx`: Transaction context
307
+ *
308
+ * # Aborts
309
+ *
310
+ * - `ENotPermitted`: if caller doesn't have `PermissionsAdmin` permission
311
+ * - `EMemberNotFound`: if member doesn't exist
312
+ * - `ELastPermissionsAdmin`: if removing would leave no PermissionsAdmins
313
+ */
314
+ function removeMember(options) {
315
+ const packageAddress = options.package ?? "@local-pkg/sui-groups";
316
+ const argumentsTypes = [null, "address"];
317
+ const parameterNames = ["self", "member"];
318
+ return (tx) => tx.moveCall({
319
+ package: packageAddress,
320
+ module: "permissioned_group",
321
+ function: "remove_member",
322
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
323
+ typeArguments: options.typeArguments
324
+ });
325
+ }
326
+ /**
327
+ * Revokes a permission from a member. If this is the member's last permission,
328
+ * they are automatically removed from the group. Emits `PermissionsRevoked` and
329
+ * potentially `MemberRemoved` events.
330
+ *
331
+ * Permission requirements:
332
+ *
333
+ * - Core permissions: caller must have `PermissionsAdmin`
334
+ * - Extension permissions: caller must have `ExtensionPermissionsAdmin`
335
+ *
336
+ * # Type Parameters
337
+ *
338
+ * - `T`: Package witness type
339
+ * - `ExistingPermission`: Permission type to revoke
340
+ *
341
+ * # Parameters
342
+ *
343
+ * - `self`: Mutable reference to the PermissionedGroup
344
+ * - `member`: Address of the member to revoke permission from
345
+ * - `ctx`: Transaction context
346
+ *
347
+ * # Aborts
348
+ *
349
+ * - `ENotPermitted`: if caller doesn't have appropriate manager permission
350
+ * - `EMemberNotFound`: if member doesn't exist
351
+ * - `ELastPermissionsAdmin`: if revoking `PermissionsAdmin` would leave no admins
352
+ */
353
+ function revokePermission(options) {
354
+ const packageAddress = options.package ?? "@local-pkg/sui-groups";
355
+ const argumentsTypes = [null, "address"];
356
+ const parameterNames = ["self", "member"];
357
+ return (tx) => tx.moveCall({
358
+ package: packageAddress,
359
+ module: "permissioned_group",
360
+ function: "revoke_permission",
361
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
362
+ typeArguments: options.typeArguments
363
+ });
364
+ }
365
+
366
+ //#endregion
367
+ export { ExtensionPermissionsAdmin, GroupCreated, GroupDeleted, GroupDeleter, GroupDerived, GroupPaused, GroupUnpaused, MemberAdded, MemberRemoved, ObjectAdmin, PausedMarker, PermissionedGroup, PermissionsAdmin, PermissionsGranted, PermissionsRevoked, _delete, grantPermission, pause, removeMember, revokePermission, unpause };
368
+ //# sourceMappingURL=permissioned_group.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissioned_group.mjs","names":["permissions_table.PermissionsTable","type_name.TypeName"],"sources":["../../../src/contracts/sui_groups/permissioned_group.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\n\n/**\n * Module: permissioned_group\n *\n * Generic permission system for group management.\n *\n * ## Permissions\n *\n * Core permissions (defined in this package):\n *\n * - `PermissionsAdmin`: Manages core permissions. Can grant/revoke\n * PermissionsAdmin, ExtensionPermissionsAdmin, ObjectAdmin, Destroyer. Can\n * remove members.\n * - `ExtensionPermissionsAdmin`: Manages extension permissions defined in\n * third-party packages.\n * - `ObjectAdmin`: Admin-tier permission granting raw `&mut UID` access to the\n * group object. Use cases include attaching dynamic fields or integrating with\n * external protocols (e.g. SuiNS reverse lookup). Only accessible via the\n * actor-object pattern (`object_uid` / `object_uid_mut`), which forces extending\n * contracts to explicitly reason about the implications of mutating the group\n * object.\n * - `GroupDeleter`: Permission that allows destroying the group via `delete()`.\n *\n * ## Permission Scoping\n *\n * - `PermissionsAdmin` can ONLY manage core permissions (from this package):\n * PermissionsAdmin, ExtensionPermissionsAdmin, ObjectAdmin, Destroyer\n * - `ExtensionPermissionsAdmin` can ONLY manage extension permissions (from other\n * packages)\n *\n * ## Key Concepts\n *\n * - **Membership is defined by permissions**: A member exists if and only if they\n * have at least one permission\n * - **Granting implicitly adds**: `grant_permission()` will automatically add a\n * member if they don't exist\n * - **Revoking may remove**: Revoking the last permission automatically removes\n * the member from the group\n *\n * ## Invariants\n *\n * - At least one `PermissionsAdmin` must always exist\n * - Members always have at least one permission (empty permission sets are not\n * allowed)\n */\n\nimport {\n\tMoveTuple,\n\tMoveStruct,\n\tnormalizeMoveArguments,\n\ttype RawTransactionArgument,\n} from '../utils/index.js';\nimport { bcs, type BcsType } from '@mysten/sui/bcs';\nimport { type Transaction } from '@mysten/sui/transactions';\nimport * as permissions_table from './permissions_table.js';\nimport * as type_name from './deps/std/type_name.js';\nconst $moduleName = '@local-pkg/sui-groups::permissioned_group';\nexport const PermissionsAdmin = new MoveTuple({\n\tname: `${$moduleName}::PermissionsAdmin`,\n\tfields: [bcs.bool()],\n});\nexport const ExtensionPermissionsAdmin = new MoveTuple({\n\tname: `${$moduleName}::ExtensionPermissionsAdmin`,\n\tfields: [bcs.bool()],\n});\nexport const ObjectAdmin = new MoveTuple({\n\tname: `${$moduleName}::ObjectAdmin`,\n\tfields: [bcs.bool()],\n});\nexport const GroupDeleter = new MoveTuple({\n\tname: `${$moduleName}::GroupDeleter`,\n\tfields: [bcs.bool()],\n});\n/**\n * Group state mapping addresses to their granted permissions. Parameterized by `T`\n * to scope permissions to a specific package.\n */\nexport function PermissionedGroup<T extends BcsType<any>>(...typeParameters: [T]) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::PermissionedGroup<${typeParameters[0].name as T['name']}>`,\n\t\tfields: {\n\t\t\tid: bcs.Address,\n\t\t\t/**\n\t\t\t * Maps member addresses (user or object) to their permission set. Object addresses\n\t\t\t * enable `object_*` functions for third-party \"actor\" contracts.\n\t\t\t */\n\t\t\tpermissions: permissions_table.PermissionsTable,\n\t\t\t/** Tracks `PermissionsAdmin` count to enforce at-least-one invariant. */\n\t\t\tpermissions_admin_count: bcs.u64(),\n\t\t\t/** Original creator's address */\n\t\t\tcreator: bcs.Address,\n\t\t},\n\t});\n}\nexport const PausedMarker = new MoveTuple({\n\tname: `${$moduleName}::PausedMarker`,\n\tfields: [bcs.bool()],\n});\n/** Emitted when a new PermissionedGroup is created via `new`. */\nexport function GroupCreated<T extends BcsType<any>>(...typeParameters: [T]) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::GroupCreated<${typeParameters[0].name as T['name']}>`,\n\t\tfields: {\n\t\t\t/** ID of the created group. */\n\t\t\tgroup_id: bcs.Address,\n\t\t\t/** Address of the group creator. */\n\t\t\tcreator: bcs.Address,\n\t\t},\n\t});\n}\n/** Emitted when a new PermissionedGroup is created via `new_derived`. */\nexport function GroupDerived<T extends BcsType<any>, DerivationKey extends BcsType<any>>(\n\t...typeParameters: [T, DerivationKey]\n) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::GroupDerived<${typeParameters[0].name as T['name']}, ${typeParameters[1].name as DerivationKey['name']}>`,\n\t\tfields: {\n\t\t\t/** ID of the created group. */\n\t\t\tgroup_id: bcs.Address,\n\t\t\t/** Address of the group creator. */\n\t\t\tcreator: bcs.Address,\n\t\t\t/** ID of the parent object from which the group was derived. */\n\t\t\tparent_id: bcs.Address,\n\t\t\t/** derivation key used. */\n\t\t\tderivation_key: typeParameters[1],\n\t\t},\n\t});\n}\n/** Emitted when a new member is added to a group via grant_permission. */\nexport function MemberAdded<T extends BcsType<any>>(...typeParameters: [T]) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::MemberAdded<${typeParameters[0].name as T['name']}>`,\n\t\tfields: {\n\t\t\t/** ID of the group. */\n\t\t\tgroup_id: bcs.Address,\n\t\t\t/** Address of the new member. */\n\t\t\tmember: bcs.Address,\n\t\t},\n\t});\n}\n/** Emitted when a member is removed from a group. */\nexport function MemberRemoved<T extends BcsType<any>>(...typeParameters: [T]) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::MemberRemoved<${typeParameters[0].name as T['name']}>`,\n\t\tfields: {\n\t\t\t/** ID of the group. */\n\t\t\tgroup_id: bcs.Address,\n\t\t\t/** Address of the removed member. */\n\t\t\tmember: bcs.Address,\n\t\t},\n\t});\n}\n/** Emitted when permissions are granted to a member. */\nexport function PermissionsGranted<T extends BcsType<any>>(...typeParameters: [T]) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::PermissionsGranted<${typeParameters[0].name as T['name']}>`,\n\t\tfields: {\n\t\t\t/** ID of the group. */\n\t\t\tgroup_id: bcs.Address,\n\t\t\t/** Address of the member receiving the permissions. */\n\t\t\tmember: bcs.Address,\n\t\t\t/** Type names of the granted permissions. */\n\t\t\tpermissions: bcs.vector(type_name.TypeName),\n\t\t},\n\t});\n}\n/** Emitted when permissions are revoked from a member. */\nexport function PermissionsRevoked<T extends BcsType<any>>(...typeParameters: [T]) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::PermissionsRevoked<${typeParameters[0].name as T['name']}>`,\n\t\tfields: {\n\t\t\t/** ID of the group. */\n\t\t\tgroup_id: bcs.Address,\n\t\t\t/** Address of the member losing the permissions. */\n\t\t\tmember: bcs.Address,\n\t\t\t/** Type names of the revoked permissions. */\n\t\t\tpermissions: bcs.vector(type_name.TypeName),\n\t\t},\n\t});\n}\n/** Emitted when a PermissionedGroup is deleted via `delete`. */\nexport function GroupDeleted<T extends BcsType<any>>(...typeParameters: [T]) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::GroupDeleted<${typeParameters[0].name as T['name']}>`,\n\t\tfields: {\n\t\t\t/** ID of the deleted group. */\n\t\t\tgroup_id: bcs.Address,\n\t\t\t/** Address of the caller who deleted the group. */\n\t\t\tdeleter: bcs.Address,\n\t\t},\n\t});\n}\n/** Emitted when a PermissionedGroup is paused via `pause`. */\nexport function GroupPaused<T extends BcsType<any>>(...typeParameters: [T]) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::GroupPaused<${typeParameters[0].name as T['name']}>`,\n\t\tfields: {\n\t\t\tgroup_id: bcs.Address,\n\t\t\tpaused_by: bcs.Address,\n\t\t},\n\t});\n}\n/** Emitted when a PermissionedGroup is unpaused via `unpause`. */\nexport function GroupUnpaused<T extends BcsType<any>>(...typeParameters: [T]) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::GroupUnpaused<${typeParameters[0].name as T['name']}>`,\n\t\tfields: {\n\t\t\tgroup_id: bcs.Address,\n\t\t\tunpaused_by: bcs.Address,\n\t\t},\n\t});\n}\nexport interface NewArguments<T extends BcsType<any>> {\n\tWitness: RawTransactionArgument<T>;\n}\nexport interface NewOptions<T extends BcsType<any>> {\n\tpackage?: string;\n\targuments: NewArguments<T> | [Witness: RawTransactionArgument<T>];\n\ttypeArguments: [string];\n}\n/**\n * Creates a new PermissionedGroup with the sender as initial admin. Grants\n * `PermissionsAdmin`, `ExtensionPermissionsAdmin`, and `Destroyer` to creator.\n *\n * # Type Parameters\n *\n * - `T`: Package witness type to scope permissions\n *\n * # Parameters\n *\n * - `_witness`: Instance of witness type `T` (proves caller owns the type)\n * - `ctx`: Transaction context\n *\n * # Returns\n *\n * A new `PermissionedGroup<T>` with sender having `PermissionsAdmin` and\n * `ExtensionPermissionsAdmin`.\n */\nexport function _new<T extends BcsType<any>>(options: NewOptions<T>) {\n\tconst packageAddress = options.package ?? '@local-pkg/sui-groups';\n\tconst argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[];\n\tconst parameterNames = ['Witness'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'permissioned_group',\n\t\t\tfunction: 'new',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface NewDerivedArguments<T extends BcsType<any>, DerivationKey extends BcsType<any>> {\n\tWitness: RawTransactionArgument<T>;\n\tderivationUid: RawTransactionArgument<string>;\n\tderivationKey: RawTransactionArgument<DerivationKey>;\n}\nexport interface NewDerivedOptions<T extends BcsType<any>, DerivationKey extends BcsType<any>> {\n\tpackage?: string;\n\targuments:\n\t\t| NewDerivedArguments<T, DerivationKey>\n\t\t| [\n\t\t\t\tWitness: RawTransactionArgument<T>,\n\t\t\t\tderivationUid: RawTransactionArgument<string>,\n\t\t\t\tderivationKey: RawTransactionArgument<DerivationKey>,\n\t\t ];\n\ttypeArguments: [string, string];\n}\n/**\n * Creates a new derived PermissionedGroup with deterministic address. Grants\n * `PermissionsAdmin`, `ExtensionPermissionsAdmin`, and `Destroyer` to creator.\n *\n * # Type Parameters\n *\n * - `T`: Package witness type to scope permissions\n * - `DerivationKey`: Key type for address derivation\n *\n * # Parameters\n *\n * - `_witness`: Instance of witness type `T` (proves caller owns the type)\n * - `derivation_uid`: Mutable reference to the parent UID for derivation\n * - `derivation_key`: Key used for deterministic address derivation\n * - `ctx`: Transaction context\n *\n * # Returns\n *\n * A new `PermissionedGroup<T>` with derived address.\n *\n * # Aborts\n *\n * - `EPermissionedGroupAlreadyExists`: if derived address is already claimed\n */\nexport function newDerived<T extends BcsType<any>, DerivationKey extends BcsType<any>>(\n\toptions: NewDerivedOptions<T, DerivationKey>,\n) {\n\tconst packageAddress = options.package ?? '@local-pkg/sui-groups';\n\tconst argumentsTypes = [\n\t\t`${options.typeArguments[0]}`,\n\t\t'0x2::object::ID',\n\t\t`${options.typeArguments[1]}`,\n\t] satisfies (string | null)[];\n\tconst parameterNames = ['Witness', 'derivationUid', 'derivationKey'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'permissioned_group',\n\t\t\tfunction: 'new_derived',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface DeleteArguments {\n\tself: RawTransactionArgument<string>;\n}\nexport interface DeleteOptions {\n\tpackage?: string;\n\targuments: DeleteArguments | [self: RawTransactionArgument<string>];\n\ttypeArguments: [string];\n}\n/**\n * Deletes a PermissionedGroup, returning its components. Checks that\n * `ctx.sender()` has `GroupDeleter` permission. Caller must extract any dynamic\n * fields BEFORE calling this (the UID is deleted).\n *\n * # Type Parameters\n *\n * - `T`: Package witness type\n *\n * # Parameters\n *\n * - `self`: The PermissionedGroup to delete (by value)\n * - `ctx`: Transaction context\n *\n * # Returns\n *\n * Tuple of (PermissionsTable, permissions_admin_count, creator)\n *\n * # Aborts\n *\n * - `ENotPermitted`: if caller doesn't have `GroupDeleter` permission\n */\nexport function _delete(options: DeleteOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/sui-groups';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['self'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'permissioned_group',\n\t\t\tfunction: 'delete',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface PauseArguments {\n\tself: RawTransactionArgument<string>;\n}\nexport interface PauseOptions {\n\tpackage?: string;\n\targuments: PauseArguments | [self: RawTransactionArgument<string>];\n\ttypeArguments: [string];\n}\n/**\n * Pauses the group, preventing all mutations. Returns an `UnpauseCap<T>` that is\n * required to unpause.\n *\n * To use as an emergency fix: pause → fix state in a PTB → unpause. To archive\n * (messaging layer): pause → store the returned cap as a DOF.\n *\n * # Aborts\n *\n * - `ENotPermitted`: if caller doesn't have `PermissionsAdmin`\n * - `EAlreadyPaused`: if the group is already paused\n */\nexport function pause(options: PauseOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/sui-groups';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['self'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'permissioned_group',\n\t\t\tfunction: 'pause',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface UnpauseArguments {\n\tself: RawTransactionArgument<string>;\n\tcap: RawTransactionArgument<string>;\n}\nexport interface UnpauseOptions {\n\tpackage?: string;\n\targuments:\n\t\t| UnpauseArguments\n\t\t| [self: RawTransactionArgument<string>, cap: RawTransactionArgument<string>];\n\ttypeArguments: [string];\n}\n/**\n * Unpauses the group. Consumes and destroys the `UnpauseCap`.\n *\n * # Aborts\n *\n * - `EGroupIdMismatch`: if the cap belongs to a different group\n */\nexport function unpause(options: UnpauseOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/sui-groups';\n\tconst argumentsTypes = [null, null] satisfies (string | null)[];\n\tconst parameterNames = ['self', 'cap'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'permissioned_group',\n\t\t\tfunction: 'unpause',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface IsPausedArguments {\n\tself: RawTransactionArgument<string>;\n}\nexport interface IsPausedOptions {\n\tpackage?: string;\n\targuments: IsPausedArguments | [self: RawTransactionArgument<string>];\n\ttypeArguments: [string];\n}\n/** Returns whether the group is currently paused. */\nexport function isPaused(options: IsPausedOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/sui-groups';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['self'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'permissioned_group',\n\t\t\tfunction: 'is_paused',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface GrantPermissionArguments {\n\tself: RawTransactionArgument<string>;\n\tmember: RawTransactionArgument<string>;\n}\nexport interface GrantPermissionOptions {\n\tpackage?: string;\n\targuments:\n\t\t| GrantPermissionArguments\n\t\t| [self: RawTransactionArgument<string>, member: RawTransactionArgument<string>];\n\ttypeArguments: [string, string];\n}\n/**\n * Grants a permission to a member. If the member doesn't exist, they are\n * automatically added to the group. Emits both `MemberAdded` (if new) and\n * `PermissionsGranted` events.\n *\n * Permission requirements:\n *\n * - Core permissions: caller must have `PermissionsAdmin`\n * - Extension permissions: caller must have `ExtensionPermissionsAdmin`\n *\n * # Type Parameters\n *\n * - `T`: Package witness type\n * - `NewPermission`: Permission type to grant\n *\n * # Parameters\n *\n * - `self`: Mutable reference to the PermissionedGroup\n * - `member`: Address of the member to grant permission to\n * - `ctx`: Transaction context\n *\n * # Aborts\n *\n * - `ENotPermitted`: if caller doesn't have appropriate manager permission\n */\nexport function grantPermission(options: GrantPermissionOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/sui-groups';\n\tconst argumentsTypes = [null, 'address'] satisfies (string | null)[];\n\tconst parameterNames = ['self', 'member'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'permissioned_group',\n\t\t\tfunction: 'grant_permission',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface ObjectGrantPermissionArguments {\n\tself: RawTransactionArgument<string>;\n\tactorObject: RawTransactionArgument<string>;\n\trecipient: RawTransactionArgument<string>;\n}\nexport interface ObjectGrantPermissionOptions {\n\tpackage?: string;\n\targuments:\n\t\t| ObjectGrantPermissionArguments\n\t\t| [\n\t\t\t\tself: RawTransactionArgument<string>,\n\t\t\t\tactorObject: RawTransactionArgument<string>,\n\t\t\t\trecipient: RawTransactionArgument<string>,\n\t\t ];\n\ttypeArguments: [string, string];\n}\n/**\n * Grants a permission to a recipient via an actor object. Enables third-party\n * contracts to grant permissions with custom logic. If the recipient is not\n * already a member, they are automatically added.\n *\n * Permission requirements:\n *\n * - Core permissions: actor must have `PermissionsAdmin`\n * - Extension permissions: actor must have `ExtensionPermissionsAdmin`\n *\n * # Type Parameters\n *\n * - `T`: Package witness type\n * - `NewPermission`: Permission type to grant\n *\n * # Parameters\n *\n * - `self`: Mutable reference to the PermissionedGroup\n * - `actor_object`: UID of the actor object with appropriate manager permission\n * - `recipient`: Address of the member to receive the permission\n *\n * # Aborts\n *\n * - `ENotPermitted`: if actor_object doesn't have appropriate manager permission\n */\nexport function objectGrantPermission(options: ObjectGrantPermissionOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/sui-groups';\n\tconst argumentsTypes = [null, '0x2::object::ID', 'address'] satisfies (string | null)[];\n\tconst parameterNames = ['self', 'actorObject', 'recipient'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'permissioned_group',\n\t\t\tfunction: 'object_grant_permission',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface RemoveMemberArguments {\n\tself: RawTransactionArgument<string>;\n\tmember: RawTransactionArgument<string>;\n}\nexport interface RemoveMemberOptions {\n\tpackage?: string;\n\targuments:\n\t\t| RemoveMemberArguments\n\t\t| [self: RawTransactionArgument<string>, member: RawTransactionArgument<string>];\n\ttypeArguments: [string];\n}\n/**\n * Removes a member from the PermissionedGroup. Requires `PermissionsAdmin`\n * permission as this is a powerful admin operation.\n *\n * # Parameters\n *\n * - `self`: Mutable reference to the PermissionedGroup\n * - `member`: Address of the member to remove\n * - `ctx`: Transaction context\n *\n * # Aborts\n *\n * - `ENotPermitted`: if caller doesn't have `PermissionsAdmin` permission\n * - `EMemberNotFound`: if member doesn't exist\n * - `ELastPermissionsAdmin`: if removing would leave no PermissionsAdmins\n */\nexport function removeMember(options: RemoveMemberOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/sui-groups';\n\tconst argumentsTypes = [null, 'address'] satisfies (string | null)[];\n\tconst parameterNames = ['self', 'member'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'permissioned_group',\n\t\t\tfunction: 'remove_member',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface ObjectRemoveMemberArguments {\n\tself: RawTransactionArgument<string>;\n\tactorObject: RawTransactionArgument<string>;\n\tmember: RawTransactionArgument<string>;\n}\nexport interface ObjectRemoveMemberOptions {\n\tpackage?: string;\n\targuments:\n\t\t| ObjectRemoveMemberArguments\n\t\t| [\n\t\t\t\tself: RawTransactionArgument<string>,\n\t\t\t\tactorObject: RawTransactionArgument<string>,\n\t\t\t\tmember: RawTransactionArgument<string>,\n\t\t ];\n\ttypeArguments: [string];\n}\n/**\n * Removes a member from the group via an actor object. Enables third-party\n * contracts to implement custom leave logic. The actor object must have\n * `PermissionsAdmin` permission on the group.\n *\n * # Parameters\n *\n * - `self`: Mutable reference to the PermissionedGroup\n * - `actor_object`: UID of the actor object with `PermissionsAdmin` permission\n * - `member`: Address of the member to remove\n *\n * # Aborts\n *\n * - `ENotPermitted`: if actor_object doesn't have `PermissionsAdmin` permission\n * - `EMemberNotFound`: if member is not a member\n * - `ELastPermissionsAdmin`: if removing would leave no PermissionsAdmins\n */\nexport function objectRemoveMember(options: ObjectRemoveMemberOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/sui-groups';\n\tconst argumentsTypes = [null, '0x2::object::ID', 'address'] satisfies (string | null)[];\n\tconst parameterNames = ['self', 'actorObject', 'member'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'permissioned_group',\n\t\t\tfunction: 'object_remove_member',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface RevokePermissionArguments {\n\tself: RawTransactionArgument<string>;\n\tmember: RawTransactionArgument<string>;\n}\nexport interface RevokePermissionOptions {\n\tpackage?: string;\n\targuments:\n\t\t| RevokePermissionArguments\n\t\t| [self: RawTransactionArgument<string>, member: RawTransactionArgument<string>];\n\ttypeArguments: [string, string];\n}\n/**\n * Revokes a permission from a member. If this is the member's last permission,\n * they are automatically removed from the group. Emits `PermissionsRevoked` and\n * potentially `MemberRemoved` events.\n *\n * Permission requirements:\n *\n * - Core permissions: caller must have `PermissionsAdmin`\n * - Extension permissions: caller must have `ExtensionPermissionsAdmin`\n *\n * # Type Parameters\n *\n * - `T`: Package witness type\n * - `ExistingPermission`: Permission type to revoke\n *\n * # Parameters\n *\n * - `self`: Mutable reference to the PermissionedGroup\n * - `member`: Address of the member to revoke permission from\n * - `ctx`: Transaction context\n *\n * # Aborts\n *\n * - `ENotPermitted`: if caller doesn't have appropriate manager permission\n * - `EMemberNotFound`: if member doesn't exist\n * - `ELastPermissionsAdmin`: if revoking `PermissionsAdmin` would leave no admins\n */\nexport function revokePermission(options: RevokePermissionOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/sui-groups';\n\tconst argumentsTypes = [null, 'address'] satisfies (string | null)[];\n\tconst parameterNames = ['self', 'member'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'permissioned_group',\n\t\t\tfunction: 'revoke_permission',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface ObjectRevokePermissionArguments {\n\tself: RawTransactionArgument<string>;\n\tactorObject: RawTransactionArgument<string>;\n\tmember: RawTransactionArgument<string>;\n}\nexport interface ObjectRevokePermissionOptions {\n\tpackage?: string;\n\targuments:\n\t\t| ObjectRevokePermissionArguments\n\t\t| [\n\t\t\t\tself: RawTransactionArgument<string>,\n\t\t\t\tactorObject: RawTransactionArgument<string>,\n\t\t\t\tmember: RawTransactionArgument<string>,\n\t\t ];\n\ttypeArguments: [string, string];\n}\n/**\n * Revokes a permission from a member via an actor object. Enables third-party\n * contracts to revoke permissions with custom logic. If this is the member's last\n * permission, they are automatically removed from the group.\n *\n * Permission requirements:\n *\n * - Core permissions: actor must have `PermissionsAdmin`\n * - Extension permissions: actor must have `ExtensionPermissionsAdmin`\n *\n * # Type Parameters\n *\n * - `T`: Package witness type\n * - `ExistingPermission`: Permission type to revoke\n *\n * # Parameters\n *\n * - `self`: Mutable reference to the PermissionedGroup\n * - `actor_object`: UID of the actor object with appropriate manager permission\n * - `member`: Address of the member to revoke permission from\n *\n * # Aborts\n *\n * - `ENotPermitted`: if actor_object doesn't have appropriate manager permission\n * - `EMemberNotFound`: if member is not a member\n * - `ELastPermissionsAdmin`: if revoking `PermissionsAdmin` would leave no admins\n */\nexport function objectRevokePermission(options: ObjectRevokePermissionOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/sui-groups';\n\tconst argumentsTypes = [null, '0x2::object::ID', 'address'] satisfies (string | null)[];\n\tconst parameterNames = ['self', 'actorObject', 'member'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'permissioned_group',\n\t\t\tfunction: 'object_revoke_permission',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface HasPermissionArguments {\n\tself: RawTransactionArgument<string>;\n\tmember: RawTransactionArgument<string>;\n}\nexport interface HasPermissionOptions {\n\tpackage?: string;\n\targuments:\n\t\t| HasPermissionArguments\n\t\t| [self: RawTransactionArgument<string>, member: RawTransactionArgument<string>];\n\ttypeArguments: [string, string];\n}\n/**\n * Checks if the given address has the specified permission.\n *\n * # Type Parameters\n *\n * - `T`: Package witness type\n * - `Permission`: Permission type to check\n *\n * # Parameters\n *\n * - `self`: Reference to the PermissionedGroup\n * - `member`: Address to check\n *\n * # Returns\n *\n * `true` if the address has the permission, `false` otherwise.\n */\nexport function hasPermission(options: HasPermissionOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/sui-groups';\n\tconst argumentsTypes = [null, 'address'] satisfies (string | null)[];\n\tconst parameterNames = ['self', 'member'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'permissioned_group',\n\t\t\tfunction: 'has_permission',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface IsMemberArguments {\n\tself: RawTransactionArgument<string>;\n\tmember: RawTransactionArgument<string>;\n}\nexport interface IsMemberOptions {\n\tpackage?: string;\n\targuments:\n\t\t| IsMemberArguments\n\t\t| [self: RawTransactionArgument<string>, member: RawTransactionArgument<string>];\n\ttypeArguments: [string];\n}\n/**\n * Checks if the given address is a member of the group.\n *\n * # Type Parameters\n *\n * - `T`: Package witness type\n *\n * # Parameters\n *\n * - `self`: Reference to the PermissionedGroup\n * - `member`: Address to check\n *\n * # Returns\n *\n * `true` if the address is a member, `false` otherwise.\n */\nexport function isMember(options: IsMemberOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/sui-groups';\n\tconst argumentsTypes = [null, 'address'] satisfies (string | null)[];\n\tconst parameterNames = ['self', 'member'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'permissioned_group',\n\t\t\tfunction: 'is_member',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface CreatorArguments {\n\tself: RawTransactionArgument<string>;\n}\nexport interface CreatorOptions {\n\tpackage?: string;\n\targuments: CreatorArguments | [self: RawTransactionArgument<string>];\n\ttypeArguments: [string];\n}\n/**\n * Returns the creator's address of the PermissionedGroup.\n *\n * # Parameters\n *\n * - `self`: Reference to the PermissionedGroup\n *\n * # Returns\n *\n * The address of the creator.\n */\nexport function creator(options: CreatorOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/sui-groups';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['self'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'permissioned_group',\n\t\t\tfunction: 'creator',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface ObjectUidArguments {\n\tself: RawTransactionArgument<string>;\n\tactorObject: RawTransactionArgument<string>;\n}\nexport interface ObjectUidOptions {\n\tpackage?: string;\n\targuments:\n\t\t| ObjectUidArguments\n\t\t| [self: RawTransactionArgument<string>, actorObject: RawTransactionArgument<string>];\n\ttypeArguments: [string];\n}\n/**\n * Returns a reference to the group's UID via an actor object. The actor object\n * must have `ObjectAdmin` permission on the group. Only accessible via the\n * actor-object pattern — use this to build wrapper modules that explicitly reason\n * about the implications of accessing the group UID.\n *\n * # Aborts\n *\n * - `ENotPermitted`: if actor_object doesn't have `ObjectAdmin` permission\n */\nexport function objectUid(options: ObjectUidOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/sui-groups';\n\tconst argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[];\n\tconst parameterNames = ['self', 'actorObject'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'permissioned_group',\n\t\t\tfunction: 'object_uid',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface ObjectUidMutArguments {\n\tself: RawTransactionArgument<string>;\n\tactorObject: RawTransactionArgument<string>;\n}\nexport interface ObjectUidMutOptions {\n\tpackage?: string;\n\targuments:\n\t\t| ObjectUidMutArguments\n\t\t| [self: RawTransactionArgument<string>, actorObject: RawTransactionArgument<string>];\n\ttypeArguments: [string];\n}\n/**\n * Returns a mutable reference to the group's UID via an actor object. The actor\n * object must have `ObjectAdmin` permission on the group. Only accessible via the\n * actor-object pattern — use this to build wrapper modules that explicitly reason\n * about the implications of mutating the group UID.\n *\n * # Aborts\n *\n * - `ENotPermitted`: if actor_object doesn't have `ObjectAdmin` permission\n */\nexport function objectUidMut(options: ObjectUidMutOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/sui-groups';\n\tconst argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[];\n\tconst parameterNames = ['self', 'actorObject'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'permissioned_group',\n\t\t\tfunction: 'object_uid_mut',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface PermissionsAdminCountArguments {\n\tself: RawTransactionArgument<string>;\n}\nexport interface PermissionsAdminCountOptions {\n\tpackage?: string;\n\targuments: PermissionsAdminCountArguments | [self: RawTransactionArgument<string>];\n\ttypeArguments: [string];\n}\n/**\n * Returns the number of `PermissionsAdmin`s in the PermissionedGroup.\n *\n * # Parameters\n *\n * - `self`: Reference to the PermissionedGroup\n *\n * # Returns\n *\n * The count of `PermissionsAdmin`s.\n */\nexport function permissionsAdminCount(options: PermissionsAdminCountOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/sui-groups';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['self'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'permissioned_group',\n\t\t\tfunction: 'permissions_admin_count',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface MemberCountArguments {\n\tself: RawTransactionArgument<string>;\n}\nexport interface MemberCountOptions {\n\tpackage?: string;\n\targuments: MemberCountArguments | [self: RawTransactionArgument<string>];\n\ttypeArguments: [string];\n}\n/**\n * Returns the total number of members in the PermissionedGroup.\n *\n * # Parameters\n *\n * - `self`: Reference to the PermissionedGroup\n *\n * # Returns\n *\n * The total number of members.\n */\nexport function memberCount(options: MemberCountOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/sui-groups';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['self'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'permissioned_group',\n\t\t\tfunction: 'member_count',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\n"],"mappings":"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"}
@@ -0,0 +1,26 @@
1
+ import { MoveStruct } from "../utils/index.mjs";
2
+ import { bcs } from "@mysten/sui/bcs";
3
+
4
+ //#region src/contracts/sui_groups/permissions_table.ts
5
+ /**************************************************************
6
+ * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
7
+ **************************************************************/
8
+ /**
9
+ * Module: permissions_table
10
+ *
11
+ * Internal data structure for storing member permissions. Maps
12
+ * `address -> VecSet<TypeName>` using dynamic fields on a derived object. Created
13
+ * as a child of `PermissionedGroup` for easy discoverability.
14
+ */
15
+ const $moduleName = "@local-pkg/sui-groups::permissions_table";
16
+ const PermissionsTable = new MoveStruct({
17
+ name: `${$moduleName}::PermissionsTable`,
18
+ fields: {
19
+ id: bcs.Address,
20
+ length: bcs.u64()
21
+ }
22
+ });
23
+
24
+ //#endregion
25
+ export { PermissionsTable };
26
+ //# sourceMappingURL=permissions_table.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissions_table.mjs","names":[],"sources":["../../../src/contracts/sui_groups/permissions_table.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\n\n/**\n * Module: permissions_table\n *\n * Internal data structure for storing member permissions. Maps\n * `address -> VecSet<TypeName>` using dynamic fields on a derived object. Created\n * as a child of `PermissionedGroup` for easy discoverability.\n */\n\nimport { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';\nimport { bcs } from '@mysten/sui/bcs';\nimport { type Transaction } from '@mysten/sui/transactions';\nconst $moduleName = '@local-pkg/sui-groups::permissions_table';\nexport const PermissionsTable = new MoveStruct({\n\tname: `${$moduleName}::PermissionsTable`,\n\tfields: {\n\t\tid: bcs.Address,\n\t\tlength: bcs.u64(),\n\t},\n});\nexport interface DestroyEmptyArguments {\n\tself: RawTransactionArgument<string>;\n}\nexport interface DestroyEmptyOptions {\n\tpackage?: string;\n\targuments: DestroyEmptyArguments | [self: RawTransactionArgument<string>];\n}\n/**\n * Destroys an empty PermissionsTable.\n *\n * # Aborts\n *\n * - `EPermissionsTableNotEmpty`: if the table still has members\n */\nexport function destroyEmpty(options: DestroyEmptyOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/sui-groups';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['self'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'permissions_table',\n\t\t\tfunction: 'destroy_empty',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,MAAM,cAAc;AACpB,MAAa,mBAAmB,IAAI,WAAW;CAC9C,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,IAAI,IAAI;EACR,QAAQ,IAAI,KAAK;EACjB;CACD,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { BcsStruct, BcsTuple, BcsType } from "@mysten/sui/bcs";
2
+ import { TransactionArgument } from "@mysten/sui/transactions";
3
+ import { ClientWithCoreApi, SuiClientTypes } from "@mysten/sui/client";
4
+
5
+ //#region src/contracts/utils/index.d.ts
6
+ interface GetOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> extends SuiClientTypes.GetObjectOptions<Include> {
7
+ client: ClientWithCoreApi;
8
+ }
9
+ interface GetManyOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> extends SuiClientTypes.GetObjectsOptions<Include> {
10
+ client: ClientWithCoreApi;
11
+ }
12
+ declare class MoveStruct<T extends Record<string, BcsType<any>>, const Name extends string = string> extends BcsStruct<T, Name> {
13
+ get<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({
14
+ objectId,
15
+ ...options
16
+ }: GetOptions<Include>): Promise<SuiClientTypes.Object<Include & {
17
+ content: true;
18
+ json: true;
19
+ }> & {
20
+ json: BcsStruct<T>['$inferType'];
21
+ }>;
22
+ getMany<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({
23
+ client,
24
+ ...options
25
+ }: GetManyOptions<Include>): Promise<Array<SuiClientTypes.Object<Include & {
26
+ content: true;
27
+ json: true;
28
+ }> & {
29
+ json: BcsStruct<T>['$inferType'];
30
+ }>>;
31
+ }
32
+ declare class MoveTuple<const T extends readonly BcsType<any>[], const Name extends string> extends BcsTuple<T, Name> {}
33
+ //#endregion
34
+ export { MoveStruct, MoveTuple };
35
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/contracts/utils/index.ts"],"mappings":";;;;;UAkBiB,UAAA,iBACA,IAAA,CAAK,cAAA,CAAe,aAAA,2BAC3B,cAAA,CAAe,gBAAA,CAAiB,OAAA;EACzC,MAAA,EAAQ,iBAAA;AAAA;AAAA,UAGQ,cAAA,iBACA,IAAA,CAAK,cAAA,CAAe,aAAA,2BAC3B,cAAA,CAAe,iBAAA,CAAkB,OAAA;EAC1C,MAAA,EAAQ,iBAAA;AAAA;AAAA,cAwII,UAAA,WACF,MAAA,SAAe,OAAA,oDAEhB,SAAA,CAAU,CAAA,EAAG,IAAA;EAChB,GAAA,iBAAoB,IAAA,CAAK,cAAA,CAAe,aAAA,2BAAA,CAAA;IAC7C,QAAA;IAAA,GACG;EAAA,GACD,UAAA,CAAW,OAAA,IAAW,OAAA,CACxB,cAAA,CAAe,MAAA,CAAO,OAAA;IAAY,OAAA;IAAe,IAAA;EAAA;IAChD,IAAA,EAAM,SAAA,CAAU,CAAA;EAAA;EAWZ,OAAA,iBAAwB,IAAA,CAAK,cAAA,CAAe,aAAA,2BAAA,CAAA;IACjD,MAAA;IAAA,GACG;EAAA,GACD,cAAA,CAAe,OAAA,IAAW,OAAA,CAC5B,KAAA,CACC,cAAA,CAAe,MAAA,CAAO,OAAA;IAAY,OAAA;IAAe,IAAA;EAAA;IAChD,IAAA,EAAM,SAAA,CAAU,CAAA;EAAA;AAAA;AAAA,cA8BP,SAAA,0BACa,OAAA,4CAEhB,QAAA,CAAS,CAAA,EAAG,IAAA"}
@@ -0,0 +1,119 @@
1
+ import { normalizeSuiAddress } from "@mysten/sui/utils";
2
+ import { BcsStruct, BcsTuple, TypeTagSerializer, bcs } from "@mysten/sui/bcs";
3
+ import { isArgument } from "@mysten/sui/transactions";
4
+
5
+ //#region src/contracts/utils/index.ts
6
+ const MOVE_STDLIB_ADDRESS = normalizeSuiAddress("0x1");
7
+ const SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress("0x2");
8
+ function getPureBcsSchema(typeTag) {
9
+ const parsedTag = typeof typeTag === "string" ? TypeTagSerializer.parseFromStr(typeTag) : typeTag;
10
+ if ("u8" in parsedTag) return bcs.U8;
11
+ else if ("u16" in parsedTag) return bcs.U16;
12
+ else if ("u32" in parsedTag) return bcs.U32;
13
+ else if ("u64" in parsedTag) return bcs.U64;
14
+ else if ("u128" in parsedTag) return bcs.U128;
15
+ else if ("u256" in parsedTag) return bcs.U256;
16
+ else if ("address" in parsedTag) return bcs.Address;
17
+ else if ("bool" in parsedTag) return bcs.Bool;
18
+ else if ("vector" in parsedTag) {
19
+ const type = getPureBcsSchema(parsedTag.vector);
20
+ return type ? bcs.vector(type) : null;
21
+ } else if ("struct" in parsedTag) {
22
+ const structTag = parsedTag.struct;
23
+ const pkg = normalizeSuiAddress(structTag.address);
24
+ if (pkg === MOVE_STDLIB_ADDRESS) {
25
+ if ((structTag.module === "ascii" || structTag.module === "string") && structTag.name === "String") return bcs.String;
26
+ if (structTag.module === "option" && structTag.name === "Option") {
27
+ const type = getPureBcsSchema(structTag.typeParams[0]);
28
+ return type ? bcs.option(type) : null;
29
+ }
30
+ }
31
+ if (pkg === SUI_FRAMEWORK_ADDRESS && structTag.module === "object" && (structTag.name === "ID" || structTag.name === "UID")) return bcs.Address;
32
+ }
33
+ return null;
34
+ }
35
+ function normalizeMoveArguments(args, argTypes, parameterNames) {
36
+ const argLen = Array.isArray(args) ? args.length : Object.keys(args).length;
37
+ if (parameterNames && argLen !== parameterNames.length) throw new Error(`Invalid number of arguments, expected ${parameterNames.length}, got ${argLen}`);
38
+ const normalizedArgs = [];
39
+ let index = 0;
40
+ for (const [i, argType] of argTypes.entries()) {
41
+ if (argType === "0x2::clock::Clock") {
42
+ normalizedArgs.push((tx) => tx.object.clock());
43
+ continue;
44
+ }
45
+ if (argType === "0x2::random::Random") {
46
+ normalizedArgs.push((tx) => tx.object.random());
47
+ continue;
48
+ }
49
+ if (argType === "0x2::deny_list::DenyList") {
50
+ normalizedArgs.push((tx) => tx.object.denyList());
51
+ continue;
52
+ }
53
+ if (argType === "0x3::sui_system::SuiSystemState") {
54
+ normalizedArgs.push((tx) => tx.object.system());
55
+ continue;
56
+ }
57
+ let arg;
58
+ if (Array.isArray(args)) {
59
+ if (index >= args.length) throw new Error(`Invalid number of arguments, expected at least ${index + 1}, got ${args.length}`);
60
+ arg = args[index];
61
+ } else {
62
+ if (!parameterNames) throw new Error(`Expected arguments to be passed as an array`);
63
+ const name = parameterNames[index];
64
+ arg = args[name];
65
+ if (arg === void 0) throw new Error(`Parameter ${name} is required`);
66
+ }
67
+ index += 1;
68
+ if (typeof arg === "function" || isArgument(arg)) {
69
+ normalizedArgs.push(arg);
70
+ continue;
71
+ }
72
+ const type = argTypes[i];
73
+ const bcsType = type === null ? null : getPureBcsSchema(type);
74
+ if (bcsType) {
75
+ const bytes = bcsType.serialize(arg);
76
+ normalizedArgs.push((tx) => tx.pure(bytes));
77
+ continue;
78
+ } else if (typeof arg === "string") {
79
+ normalizedArgs.push((tx) => tx.object(arg));
80
+ continue;
81
+ }
82
+ throw new Error(`Invalid argument ${stringify(arg)} for type ${type}`);
83
+ }
84
+ return normalizedArgs;
85
+ }
86
+ var MoveStruct = class extends BcsStruct {
87
+ async get({ objectId, ...options }) {
88
+ const [res] = await this.getMany({
89
+ ...options,
90
+ objectIds: [objectId]
91
+ });
92
+ return res;
93
+ }
94
+ async getMany({ client, ...options }) {
95
+ return (await client.core.getObjects({
96
+ ...options,
97
+ include: {
98
+ ...options.include,
99
+ content: true
100
+ }
101
+ })).objects.map((obj) => {
102
+ if (obj instanceof Error) throw obj;
103
+ return {
104
+ ...obj,
105
+ json: this.parse(obj.content)
106
+ };
107
+ });
108
+ }
109
+ };
110
+ var MoveTuple = class extends BcsTuple {};
111
+ function stringify(val) {
112
+ if (typeof val === "object") return JSON.stringify(val, (val) => val);
113
+ if (typeof val === "bigint") return val.toString();
114
+ return val;
115
+ }
116
+
117
+ //#endregion
118
+ export { MoveStruct, MoveTuple, normalizeMoveArguments };
119
+ //# sourceMappingURL=index.mjs.map