@buenos_andres/contracts 0.0.1-test.26 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/access/AccessControl.compact +322 -0
  2. package/access/Ownable.compact +213 -0
  3. package/access/witnesses/AccessControlWitnesses.d.ts +2 -0
  4. package/access/witnesses/AccessControlWitnesses.js +4 -0
  5. package/access/witnesses/AccessControlWitnesses.js.map +1 -0
  6. package/access/witnesses/OwnableWitnesses.d.ts +2 -0
  7. package/access/witnesses/OwnableWitnesses.js +4 -0
  8. package/access/witnesses/OwnableWitnesses.js.map +1 -0
  9. package/package.json +1 -1
  10. package/security/Initializable.compact +60 -0
  11. package/security/Pausable.compact +89 -0
  12. package/security/witnesses/InitializableWitnesses.d.ts +2 -0
  13. package/security/witnesses/InitializableWitnesses.js +4 -0
  14. package/security/witnesses/InitializableWitnesses.js.map +1 -0
  15. package/security/witnesses/PausableWitnesses.d.ts +2 -0
  16. package/security/witnesses/PausableWitnesses.js +4 -0
  17. package/security/witnesses/PausableWitnesses.js.map +1 -0
  18. package/token/FungibleToken.compact +607 -0
  19. package/token/MultiToken.compact +546 -0
  20. package/token/NonFungibleToken.compact +806 -0
  21. package/token/witnesses/FungibleTokenWitnesses.d.ts +2 -0
  22. package/token/witnesses/FungibleTokenWitnesses.js +4 -0
  23. package/token/witnesses/FungibleTokenWitnesses.js.map +1 -0
  24. package/token/witnesses/MultiTokenWitnesses.d.ts +2 -0
  25. package/token/witnesses/MultiTokenWitnesses.js +4 -0
  26. package/token/witnesses/MultiTokenWitnesses.js.map +1 -0
  27. package/token/witnesses/NonFungibleTokenWitnesses.d.ts +2 -0
  28. package/token/witnesses/NonFungibleTokenWitnesses.js +4 -0
  29. package/token/witnesses/NonFungibleTokenWitnesses.js.map +1 -0
  30. package/utils/Utils.compact +1 -1
  31. package/utils/witnesses/UtilsWitnesses.js +1 -1
  32. package/utils/witnesses/UtilsWitnesses.js.map +1 -1
@@ -0,0 +1,322 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // MyFun Contracts v0.1.0 (access/AccessControl.compact)
3
+
4
+ pragma language_version >= 0.16.0;
5
+
6
+ /**
7
+ * @module AccessControl
8
+ * @description An unshielded AccessControl library.
9
+ * This module provides a role-based access control mechanism, where roles can be used to
10
+ * represent a set of permissions.
11
+ *
12
+ * Roles are referred to by their `Bytes<32>` identifier. These should be exposed
13
+ * in the top-level contract and be unique. One way to achieve this is by
14
+ * using `export sealed ledger` hash digests that are initialized in the top-level contract:
15
+ *
16
+ * ```typescript
17
+ * import CompactStandardLibrary;
18
+ * import "./node_modules/@openzeppelin-compact/accessControl/src/AccessControl" prefix AccessControl_;
19
+ *
20
+ * export sealed ledger MY_ROLE: Bytes<32>;
21
+ *
22
+ * constructor() {
23
+ * MY_ROLE = persistentHash<Bytes<32>>(pad(32, "MY_ROLE"));
24
+ * }
25
+ * ```
26
+ *
27
+ * To restrict access to a circuit, use {assertOnlyRole}:
28
+ *
29
+ * ```typescript
30
+ * circuit foo(): [] {
31
+ * assertOnlyRole(MY_ROLE);
32
+ * ...
33
+ * }
34
+ * ```
35
+ *
36
+ * Roles can be granted and revoked dynamically via the {grantRole} and
37
+ * {revokeRole} circuits. Each role has an associated admin role, and only
38
+ * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
39
+ *
40
+ * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
41
+ * that only accounts with this role will be able to grant or revoke other
42
+ * roles. More complex role relationships can be created by using
43
+ * {_setRoleAdmin}. To set a custom `DEFAULT_ADMIN_ROLE`, implement the `Initializable`
44
+ * module and set `DEFAULT_ADMIN_ROLE` in the `initialize()` circuit.
45
+ *
46
+ * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
47
+ * grant and revoke this role. Extra precautions should be taken to secure
48
+ * accounts that have been granted it.
49
+ *
50
+ * @notice Roles can only be granted to ZswapCoinPublicKeys
51
+ * through the main role approval circuits (`grantRole` and `_grantRole`).
52
+ * In other words, role approvals to contract addresses are disallowed through these
53
+ * circuits.
54
+ * This is because Compact currently does not support contract-to-contract calls which means
55
+ * if a contract is granted a role, the contract cannot directly call the protected
56
+ * circuit.
57
+ *
58
+ * @notice This module does offer an experimental circuit that allows roles to be granted
59
+ * to contract addresses (`_unsafeGrantRole`).
60
+ * Note that the circuit name is very explicit ("unsafe") with this experimental circuit.
61
+ * Until contract-to-contract calls are supported,
62
+ * there is no direct way for a contract to call protected circuits.
63
+ *
64
+ * @notice The unsafe circuits are planned to become deprecated once contract-to-contract calls
65
+ * are supported.
66
+ *
67
+ * @notice Missing Features and Improvements:
68
+ *
69
+ * - Role events
70
+ * - An ERC165-like interface
71
+ */
72
+ module AccessControl {
73
+ import CompactStandardLibrary;
74
+ import "../utils/Utils" prefix Utils_;
75
+
76
+ /**
77
+ * @description Mapping from a role identifier -> account -> its permissions.
78
+ * @type {Bytes<32>} roleId - A hash representing a role identifier.
79
+ * @type {Map<Either<ZswapCoinPublicKey, ContractAddress>, Boolean>} hasRole - A mapping from an account to a
80
+ * Boolean determining if the account is approved for a role.
81
+ * @type {Map<roleId, hasRole>}
82
+ * @type {Map<Bytes<32>, Map<Either<ZswapCoinPublicKey, ContractAddress>, Boolean>} _operatorRoles
83
+  */
84
+ export ledger _operatorRoles: Map<Bytes<32>, Map<Either<ZswapCoinPublicKey, ContractAddress>, Boolean>>;
85
+
86
+ /**
87
+ * @description Mapping from a role identifier to an admin role identifier.
88
+ * @type {Bytes<32>} roleId - A hash representing a role identifier.
89
+ * @type {Bytes<32>} adminId - A hash representing an admin identifier.
90
+ * @type {Map<roleId, adminId>}
91
+ * @type {Map<Bytes<32>, Bytes<32>>} _adminRoles
92
+  */
93
+ export ledger _adminRoles: Map<Bytes<32>, Bytes<32>>;
94
+
95
+ export ledger DEFAULT_ADMIN_ROLE: Bytes<32>;
96
+
97
+ /**
98
+ * @description Returns `true` if `account` has been granted `roleId`.
99
+ *
100
+ * @circuitInfo k=10, rows=487
101
+ *
102
+ * @param {Bytes<32>} roleId - The role identifier.
103
+ * @param {Either<ZswapCoinPublicKey, ContractAddress>} account - The account to query.
104
+ * @return {Boolean} - Whether the account has the specified role.
105
+   */
106
+ export circuit hasRole(roleId: Bytes<32>, account: Either<ZswapCoinPublicKey, ContractAddress>): Boolean {
107
+ if (
108
+ _operatorRoles.member(disclose(roleId)) &&
109
+ _operatorRoles
110
+ .lookup(roleId)
111
+ .member(disclose(account))
112
+ ) {
113
+ return _operatorRoles
114
+ .lookup(roleId)
115
+ .lookup(disclose(account));
116
+ } else {
117
+ return false;
118
+ }
119
+ }
120
+
121
+ /**
122
+ * @description Reverts if `ownPublicKey()` is missing `roleId`.
123
+ *
124
+ * @circuitInfo k=10, rows=345
125
+ *
126
+ * Requirements:
127
+ *
128
+ * - The caller must have `roleId`.
129
+ * - The caller must not be a ContractAddress
130
+ *
131
+ * @param {Bytes<32>} roleId - The role identifier.
132
+ * @return {[]} - Empty tuple.
133
+ */
134
+ export circuit assertOnlyRole(roleId: Bytes<32>): [] {
135
+ _checkRole(roleId, left<ZswapCoinPublicKey,ContractAddress>(ownPublicKey()));
136
+ }
137
+
138
+ /**
139
+ * @description Reverts if `account` is missing `roleId`.
140
+ *
141
+ * @circuitInfo k=10, rows=467
142
+ *
143
+ * Requirements:
144
+ *
145
+ * - `account` must have `roleId`.
146
+ *
147
+ * @param {Bytes<32>} roleId - The role identifier.
148
+ * @param {Either<ZswapCoinPublicKey, ContractAddress>} account - The account to query.
149
+ * @return {[]} - Empty tuple.
150
+ */
151
+ export circuit _checkRole(roleId: Bytes<32>, account: Either<ZswapCoinPublicKey, ContractAddress>): [] {
152
+ assert(hasRole(roleId, account), "AccessControl: unauthorized account");
153
+ }
154
+
155
+ /**
156
+ * @description Returns the admin role that controls `roleId` or
157
+ * a byte array with all zero bytes if `roleId` doesn't exist. See {grantRole} and {revokeRole}.
158
+ *
159
+ * To change a role’s admin use {_setRoleAdmin}.
160
+ *
161
+ * @circuitInfo k=10, rows=207
162
+ *
163
+ * @param {Bytes<32>} roleId - The role identifier.
164
+ * @return {Bytes<32>} roleAdmin - The admin role that controls `roleId`.
165
+ */
166
+ export circuit getRoleAdmin(roleId: Bytes<32>): Bytes<32> {
167
+ if (_adminRoles.member(disclose(roleId))) {
168
+ return _adminRoles.lookup(disclose(roleId));
169
+ }
170
+ return default<Bytes<32>>;
171
+ }
172
+
173
+ /**
174
+ * @description Grants `roleId` to `account`.
175
+ *
176
+ * @circuitInfo k=10, rows=994
177
+ *
178
+ * Requirements:
179
+ *
180
+ * - `account` must not be a ContractAddress.
181
+ * - The caller must have `roleId`'s admin role.
182
+ *
183
+ * @param {Bytes<32>} roleId - The role identifier.
184
+ * @param {Either<ZswapCoinPublicKey, ContractAddress>} account - A ZswapCoinPublicKey or ContractAddress.
185
+ * @return {[]} - Empty tuple.
186
+ */
187
+ export circuit grantRole(roleId: Bytes<32>, account: Either<ZswapCoinPublicKey, ContractAddress>): [] {
188
+ assertOnlyRole(getRoleAdmin(roleId));
189
+ _grantRole(roleId, account);
190
+ }
191
+
192
+ /**
193
+ * @description Revokes `roleId` from `account`.
194
+ *
195
+ * @circuitInfo k=10, rows=827
196
+ *
197
+ * Requirements:
198
+ *
199
+ * - The caller must have `roleId`'s admin role.
200
+ *
201
+ * @param {Bytes<32>} roleId - The role identifier.
202
+ * @param {Either<ZswapCoinPublicKey, ContractAddress>} account - A ZswapCoinPublicKey or ContractAddress.
203
+ * @return {[]} - Empty tuple.
204
+ */
205
+ export circuit revokeRole(roleId: Bytes<32>, account: Either<ZswapCoinPublicKey, ContractAddress>): [] {
206
+ assertOnlyRole(getRoleAdmin(roleId));
207
+ _revokeRole(roleId, account);
208
+ }
209
+
210
+ /**
211
+ * @description Revokes `roleId` from the calling account.
212
+ *
213
+ * @notice Roles are often managed via {grantRole} and {revokeRole}: this circuit's
214
+ * purpose is to provide a mechanism for accounts to lose their privileges
215
+ * if they are compromised (such as when a trusted device is misplaced).
216
+ *
217
+ * @circuitInfo k=10, rows=640
218
+ *
219
+ * Requirements:
220
+ *
221
+ * - The caller must be `callerConfirmation`.
222
+ * - The caller must not be a `ContractAddress`.
223
+ *
224
+ * @param {Bytes<32>} roleId - The role identifier.
225
+ * @param {Either<ZswapCoinPublicKey, ContractAddress>} callerConfirmation - A ZswapCoinPublicKey or ContractAddress.
226
+ * @return {[]} - Empty tuple.
227
+ */
228
+ export circuit renounceRole(roleId: Bytes<32>, callerConfirmation: Either<ZswapCoinPublicKey, ContractAddress>): [] {
229
+ assert(callerConfirmation == left<ZswapCoinPublicKey,ContractAddress>(ownPublicKey()), "AccessControl: bad confirmation");
230
+
231
+ _revokeRole(roleId, callerConfirmation);
232
+ }
233
+
234
+ /**
235
+ * @description Sets `adminRole` as `roleId`'s admin role.
236
+ *
237
+ * @circuitInfo k=10, rows=209
238
+ *
239
+ * @param {Bytes<32>} roleId - The role identifier.
240
+ * @param {Bytes<32>} adminRole - The admin role identifier.
241
+ * @return {[]} - Empty tuple.
242
+ */
243
+ export circuit _setRoleAdmin(roleId: Bytes<32>, adminRole: Bytes<32>): [] {
244
+ _adminRoles.insert(disclose(roleId), disclose(adminRole));
245
+ }
246
+
247
+ /**
248
+ * @description Attempts to grant `roleId` to `account` and returns a boolean indicating if `roleId` was granted.
249
+ * Internal circuit without access restriction.
250
+ *
251
+ * @circuitInfo k=10, rows=734
252
+ *
253
+ * Requirements:
254
+ *
255
+ * - `account` must not be a ContractAddress.
256
+ *
257
+ * @param {Bytes<32>} roleId - The role identifier.
258
+ * @param {Either<ZswapCoinPublicKey, ContractAddress>} account - A ZswapCoinPublicKey or ContractAddress.
259
+ * @return {Boolean} roleGranted - A boolean indicating if `roleId` was granted.
260
+ */
261
+ export circuit _grantRole(roleId: Bytes<32>, account: Either<ZswapCoinPublicKey, ContractAddress>): Boolean {
262
+ assert(!Utils_isContractAddress(account), "AccessControl: unsafe role approval");
263
+ return _unsafeGrantRole(roleId, account);
264
+ }
265
+
266
+ /**
267
+ * @description Attempts to grant `roleId` to `account` and returns a boolean indicating if `roleId` was granted.
268
+ * Internal circuit without access restriction. It does NOT check if the role is granted to a ContractAddress.
269
+ *
270
+ * @circuitInfo k=10, rows=733
271
+ *
272
+ * @notice External smart contracts cannot call the token contract at this time, so granting a role to an ContractAddress may
273
+ * render a circuit permanently inaccessible.
274
+ *
275
+ * @param {Bytes<32>} roleId - The role identifier.
276
+ * @param {Either<ZswapCoinPublicKey, ContractAddress>} account - A ZswapCoinPublicKey or ContractAddress.
277
+ * @return {Boolean} roleGranted - A boolean indicating if `role` was granted.
278
+ */
279
+ export circuit _unsafeGrantRole(roleId: Bytes<32>, account: Either<ZswapCoinPublicKey, ContractAddress>): Boolean {
280
+ if (hasRole(roleId, account)) {
281
+ return false;
282
+ }
283
+
284
+ if (!_operatorRoles.member(disclose(roleId))) {
285
+ _operatorRoles.insert(
286
+ disclose(roleId),
287
+ default<Map<
288
+ Either<ZswapCoinPublicKey, ContractAddress>,
289
+ Boolean
290
+ >>
291
+ );
292
+ _operatorRoles
293
+ .lookup(roleId)
294
+ .insert(disclose(account), true);
295
+ return true;
296
+ }
297
+
298
+ _operatorRoles.lookup(roleId).insert(disclose(account), true);
299
+ return true;
300
+ }
301
+
302
+ /**
303
+ * @description Attempts to revoke `roleId` from `account` and returns a boolean indicating if `roleId` was revoked.
304
+ * Internal circuit without access restriction.
305
+ *
306
+ * @circuitInfo k=10, rows=563
307
+ *
308
+ * @param {Bytes<32>} roleId - The role identifier.
309
+ * @param {Bytes<32>} adminRole - The admin role identifier.
310
+ * @return {Boolean} roleRevoked - A boolean indicating if `roleId` was revoked.
311
+ */
312
+ export circuit _revokeRole(roleId: Bytes<32>, account: Either<ZswapCoinPublicKey, ContractAddress>): Boolean {
313
+ if (!hasRole(roleId, account)) {
314
+ return false;
315
+ }
316
+
317
+ _operatorRoles
318
+ .lookup(roleId)
319
+ .insert(disclose(account), false);
320
+ return true;
321
+ }
322
+ }
@@ -0,0 +1,213 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // MyFun Contracts v0.1.0 (access/Ownable.compact)
3
+
4
+ pragma language_version >= 0.16.0;
5
+
6
+ /**
7
+ * @module Ownable
8
+ * @description An unshielded Ownable library.
9
+ * This modules provides a basic access control mechanism, where there is an owner
10
+ * that can be granted exclusive access to specific circuits.
11
+ * This approach is perfectly reasonable for contracts that have a single administrative user.
12
+ *
13
+ * The initial owner must be set by using the `initialize` circuit during construction.
14
+ * This can later be changed with `transferOwnership`.
15
+ *
16
+ * @notice Ownership can only be transferred to ZswapCoinPublicKeys
17
+ * through the main transfer circuits (`transferOwnership` and `_transferOwnership`).
18
+ * In other words, ownership transfers to contract addresses are disallowed through these
19
+ * circuits.
20
+ * This is because Compact currently does not support contract-to-contract calls which means
21
+ * if a contract is granted ownership, the owner contract cannot directly call the protected
22
+ * circuit.
23
+ *
24
+ * @notice This module does offer experimental circuits that allow ownership to be granted
25
+ * to contract addresses (`_unsafeTransferOwnership` and `_unsafeUncheckedTransferOwnership`).
26
+ * Note that the circuit names are very explicit ("unsafe") with these experimental circuits.
27
+ * Until contract-to-contract calls are supported,
28
+ * there is no direct way for a contract to call circuits of other contracts
29
+ * or transfer ownership back to a user.
30
+ *
31
+ * @notice The unsafe circuits are planned to become deprecated once contract-to-contract calls
32
+ * are supported.
33
+ */
34
+ module Ownable {
35
+ import CompactStandardLibrary;
36
+ import "../security/Initializable" prefix Initializable_;
37
+ import "../utils/Utils" prefix Utils_;
38
+
39
+ export ledger _owner: Either<ZswapCoinPublicKey, ContractAddress>;
40
+
41
+ /**
42
+ * @description Initializes the contract by setting the `initialOwner`.
43
+ * This must be called in the contract's constructor.
44
+ *
45
+ * @circuitInfo k=10, rows=258
46
+ *
47
+ * Requirements:
48
+ *
49
+ * - Contract is not already initialized.
50
+ * - `initialOwner` is not a ContractAddress.
51
+ * - `initialOwner` is not the zero address.
52
+ *
53
+ * @param {Either<ZswapCoinPublicKey, ContractAddress>} initialOwner - The initial owner of the contract.
54
+ * @returns {[]} Empty tuple.
55
+ */
56
+ export circuit initialize(initialOwner: Either<ZswapCoinPublicKey, ContractAddress>): [] {
57
+ Initializable_initialize();
58
+ assert(!Utils_isKeyOrAddressZero(initialOwner), "Ownable: invalid initial owner");
59
+ _transferOwnership(initialOwner);
60
+ }
61
+
62
+ /**
63
+ * @description Returns the current contract owner.
64
+ *
65
+ * @circuitInfo k=10, rows=84
66
+ *
67
+ * Requirements:
68
+ *
69
+ * - Contract is initialized.
70
+ *
71
+ * @returns {Either<ZswapCoinPublicKey, ContractAddress> } - The contract owner.
72
+ */
73
+ export circuit owner(): Either<ZswapCoinPublicKey, ContractAddress> {
74
+ Initializable_assertInitialized();
75
+ return _owner;
76
+ }
77
+
78
+ /**
79
+ * @description Transfers ownership of the contract to `newOwner`.
80
+ *
81
+ * @circuitInfo k=10, rows=338
82
+ *
83
+ * @notice Ownership transfers to contract addresses are currently disallowed until contract-to-contract
84
+ * interactions are supported in Compact.
85
+ * This restriction prevents permanently disabling access to a circuit.
86
+ *
87
+ * Requirements:
88
+ *
89
+ * - Contract is initialized.
90
+ * - The caller is the current contract owner.
91
+ * - `newOwner` is not a ContractAddress.
92
+ * - `newOwner` is not the zero address.
93
+ *
94
+ * @param {Either<ZswapCoinPublicKey, ContractAddress>} newOwner - The new owner.
95
+ * @returns {[]} Empty tuple.
96
+ */
97
+ export circuit transferOwnership(newOwner: Either<ZswapCoinPublicKey, ContractAddress>): [] {
98
+ Initializable_assertInitialized();
99
+ assert(!Utils_isContractAddress(newOwner), "Ownable: unsafe ownership transfer");
100
+ _unsafeTransferOwnership(newOwner);
101
+ }
102
+
103
+ /**
104
+ * @description Unsafe variant of `transferOwnership`.
105
+ *
106
+ * @circuitInfo k=10, rows=335
107
+ *
108
+ * @warning Ownership transfers to contract addresses are considered unsafe because contract-to-contract
109
+ * calls are not currently supported.
110
+ * Ownership privileges sent to a contract address may become uncallable.
111
+ * Once contract-to-contract calls are supported, this circuit may be deprecated.
112
+ *
113
+ * Requirements:
114
+ *
115
+ * - Contract is initialized.
116
+ * - The caller is the current contract owner.
117
+ * - `newOwner` is not the zero address.
118
+ *
119
+ * @param {Either<ZswapCoinPublicKey, ContractAddress>} newOwner - The new owner.
120
+ * @returns {[]} Empty tuple.
121
+ */
122
+ export circuit _unsafeTransferOwnership(newOwner: Either<ZswapCoinPublicKey, ContractAddress>): [] {
123
+ Initializable_assertInitialized();
124
+ assertOnlyOwner();
125
+ assert(!Utils_isKeyOrAddressZero(newOwner), "Ownable: invalid new owner");
126
+ _unsafeUncheckedTransferOwnership(newOwner);
127
+ }
128
+
129
+ /**
130
+ * @description Leaves the contract without an owner.
131
+ * It will not be possible to call `assertOnlyOnwer` circuits anymore.
132
+ * Can only be called by the current owner.
133
+ *
134
+ * @circuitInfo k=10, rows=124
135
+ *
136
+ * Requirements:
137
+ *
138
+ * - Contract is initialized.
139
+ * - The caller is the current contract owner.
140
+ *
141
+ * @returns {[]} Empty tuple.
142
+ */
143
+ export circuit renounceOwnership(): [] {
144
+ Initializable_assertInitialized();
145
+ assertOnlyOwner();
146
+ _transferOwnership(burnAddress());
147
+ }
148
+
149
+ /**
150
+ * @description Throws if called by any account other than the owner.
151
+ * Use this to restrict access of specific circuits to the owner.
152
+ *
153
+ * @circuitInfo k=10, rows=115
154
+ *
155
+ * Requirements:
156
+ *
157
+ * - Contract is initialized.
158
+ * - The caller is the current contract owner.
159
+ *
160
+ * @returns {[]} Empty tuple.
161
+ */
162
+ export circuit assertOnlyOwner(): [] {
163
+ Initializable_assertInitialized();
164
+ const caller = ownPublicKey();
165
+ assert(caller == _owner.left, "Ownable: caller is not the owner");
166
+ }
167
+
168
+ /**
169
+ * @description Transfers ownership of the contract to `newOwner` without
170
+ * enforcing permission checks on the caller.
171
+ *
172
+ * @circuitInfo k=10, rows=219
173
+ *
174
+ * @notice Ownership transfers to contract addresses are currently disallowed until contract-to-contract
175
+ * interactions are supported in Compact.
176
+ * This restriction prevents circuits from being inadvertently locked in contracts.
177
+ *
178
+ * Requirements:
179
+ *
180
+ * - Contract is initialized.
181
+ * - `newOwner` is not a ContractAddress.
182
+ *
183
+ * @param {Either<ZswapCoinPublicKey, ContractAddress>} newOwner - The new owner.
184
+ * @returns {[]} Empty tuple.
185
+ */
186
+ export circuit _transferOwnership(newOwner: Either<ZswapCoinPublicKey, ContractAddress>): [] {
187
+ Initializable_assertInitialized();
188
+ assert(!Utils_isContractAddress(newOwner), "Ownable: unsafe ownership transfer");
189
+ _unsafeUncheckedTransferOwnership(newOwner);
190
+ }
191
+
192
+ /**
193
+ * @description Unsafe variant of `_transferOwnership`.
194
+ *
195
+ * @circuitInfo k=10, rows=216
196
+ *
197
+ * @warning Ownership transfers to contract addresses are considered unsafe because contract-to-contract
198
+ * calls are not currently supported.
199
+ * Ownership privileges sent to a contract address may become uncallable.
200
+ * Once contract-to-contract calls are supported, this circuit may be deprecated.
201
+ *
202
+ * Requirements:
203
+ *
204
+ * - Contract is initialized.
205
+ *
206
+ * @param {Either<ZswapCoinPublicKey, ContractAddress>} newOwner - The new owner.
207
+ * @returns {[]} Empty tuple.
208
+ */
209
+ export circuit _unsafeUncheckedTransferOwnership(newOwner: Either<ZswapCoinPublicKey, ContractAddress>): [] {
210
+ Initializable_assertInitialized();
211
+ _owner = disclose(newOwner);
212
+ }
213
+ }
@@ -0,0 +1,2 @@
1
+ export type AccessControlPrivateState = Record<string, never>;
2
+ export declare const AccessControlWitnesses: {};
@@ -0,0 +1,4 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // MyFun Contracts v0.1.0 (access/witnesses/AccessControlWitnesses.ts)
3
+ export const AccessControlWitnesses = {};
4
+ //# sourceMappingURL=AccessControlWitnesses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccessControlWitnesses.js","sourceRoot":"","sources":["../../../src/access/witnesses/AccessControlWitnesses.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,sEAAsE;AAItE,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export type OwnablePrivateState = Record<string, never>;
2
+ export declare const OwnableWitnesses: {};
@@ -0,0 +1,4 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // MyFun Contracts v0.1.0 (access/witnesses/OwnableWitnesses.ts)
3
+ export const OwnableWitnesses = {};
4
+ //# sourceMappingURL=OwnableWitnesses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OwnableWitnesses.js","sourceRoot":"","sources":["../../../src/access/witnesses/OwnableWitnesses.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,gEAAgE;AAIhE,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buenos_andres/contracts",
3
- "version": "0.0.1-test.26",
3
+ "version": "0.1.0",
4
4
  "description": "test contract stuff",
5
5
  "keywords": [
6
6
  "foo",
@@ -0,0 +1,60 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // MyFun Contracts v0.1.0 (security/Initializable.compact)
3
+
4
+ pragma language_version >= 0.16.0;
5
+
6
+ /**
7
+ * @module Initializable
8
+ * @description Initializable provides a simple mechanism that mimics the functionality of a constructor.
9
+ */
10
+ module Initializable {
11
+ import CompactStandardLibrary;
12
+
13
+ export ledger _isInitialized: Boolean;
14
+
15
+ /**
16
+ * @description Initializes the state thus ensuring the calling circuit can only be called once.
17
+ *
18
+ * @circuitInfo k=10, rows=38
19
+ *
20
+ * Requirements:
21
+ *
22
+ * - Contract must not be initialized.
23
+ *
24
+ * @return {[]} - Empty tuple.
25
+ */
26
+ export circuit initialize(): [] {
27
+ assertNotInitialized();
28
+ _isInitialized = true;
29
+ }
30
+
31
+ /**
32
+ * @description Asserts that the contract has been initialized, throwing an error if not.
33
+ *
34
+ * @circuitInfo k=10, rows=31
35
+ *
36
+ * Requirements:
37
+ *
38
+ * - Contract must be initialized.
39
+ *
40
+ * @return {[]} - Empty tuple.
41
+ */
42
+ export circuit assertInitialized(): [] {
43
+ assert(_isInitialized, "Initializable: contract not initialized");
44
+ }
45
+
46
+ /**
47
+ * @description Asserts that the contract has not been initialized, throwing an error if it has.
48
+ *
49
+ * @circuitInfo k=10, rows=35
50
+ *
51
+ * Requirements:
52
+ *
53
+ * - Contract must not be initialized.
54
+ *
55
+ * @return {[]} - Empty tuple.
56
+ */
57
+ export circuit assertNotInitialized(): [] {
58
+ assert(!_isInitialized, "Initializable: contract already initialized");
59
+ }
60
+ }