zkcloudworker 0.12.1 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. package/lib/ts/src/cloud/worker/cloud.d.ts +2 -2
  2. package/lib/ts/src/mina/index.d.ts +2 -0
  3. package/lib/ts/src/mina/index.js +2 -0
  4. package/lib/ts/src/mina/local/local.d.ts +2 -2
  5. package/lib/ts/src/mina/local/local.js +8 -4
  6. package/lib/ts/src/mina/token/FungibleToken.d.ts +338 -0
  7. package/lib/ts/src/mina/token/FungibleToken.js +290 -0
  8. package/lib/ts/src/mina/token/FungibleTokenAdmin.d.ts +31 -0
  9. package/lib/ts/src/mina/token/FungibleTokenAdmin.js +102 -0
  10. package/lib/ts/src/mina/token/index.d.ts +2 -0
  11. package/lib/ts/src/mina/token/index.js +18 -0
  12. package/lib/ts/src/mina/transactions/blockberry.d.ts +16 -0
  13. package/lib/ts/src/mina/transactions/blockberry.js +80 -0
  14. package/lib/ts/src/mina/transactions/chain.d.ts +1 -0
  15. package/lib/ts/src/mina/transactions/chain.js +2 -0
  16. package/lib/ts/src/mina/transactions/index.d.ts +5 -0
  17. package/lib/ts/src/mina/transactions/index.js +21 -0
  18. package/lib/ts/src/mina/transactions/nonce.d.ts +10 -0
  19. package/lib/ts/src/mina/transactions/nonce.js +60 -0
  20. package/lib/ts/src/mina/transactions/transaction.d.ts +9 -0
  21. package/lib/ts/src/mina/transactions/transaction.js +69 -0
  22. package/lib/ts/src/mina/transactions/txstatus.d.ts +8 -0
  23. package/lib/ts/src/mina/transactions/txstatus.js +18 -0
  24. package/lib/ts/src/mina/utils/fetch.js +1 -1
  25. package/lib/ts/tsconfig.tsbuildinfo +1 -1
  26. package/lib/web/src/cloud/worker/cloud.d.ts +2 -2
  27. package/lib/web/src/mina/index.d.ts +2 -0
  28. package/lib/web/src/mina/index.js +2 -0
  29. package/lib/web/src/mina/index.js.map +1 -1
  30. package/lib/web/src/mina/local/local.d.ts +2 -2
  31. package/lib/web/src/mina/local/local.js +8 -4
  32. package/lib/web/src/mina/local/local.js.map +1 -1
  33. package/lib/web/src/mina/token/FungibleToken.d.ts +338 -0
  34. package/lib/web/src/mina/token/FungibleToken.js +274 -0
  35. package/lib/web/src/mina/token/FungibleToken.js.map +1 -0
  36. package/lib/web/src/mina/token/FungibleTokenAdmin.d.ts +31 -0
  37. package/lib/web/src/mina/token/FungibleTokenAdmin.js +91 -0
  38. package/lib/web/src/mina/token/FungibleTokenAdmin.js.map +1 -0
  39. package/lib/web/src/mina/token/index.d.ts +2 -0
  40. package/lib/web/src/mina/token/index.js +3 -0
  41. package/lib/web/src/mina/token/index.js.map +1 -0
  42. package/lib/web/src/mina/transactions/blockberry.d.ts +16 -0
  43. package/lib/web/src/mina/transactions/blockberry.js +76 -0
  44. package/lib/web/src/mina/transactions/blockberry.js.map +1 -0
  45. package/lib/web/src/mina/transactions/chain.d.ts +1 -0
  46. package/lib/web/src/mina/transactions/chain.js +2 -0
  47. package/lib/web/src/mina/transactions/chain.js.map +1 -0
  48. package/lib/web/src/mina/transactions/index.d.ts +5 -0
  49. package/lib/web/src/mina/transactions/index.js +6 -0
  50. package/lib/web/src/mina/transactions/index.js.map +1 -0
  51. package/lib/web/src/mina/transactions/nonce.d.ts +10 -0
  52. package/lib/web/src/mina/transactions/nonce.js +58 -0
  53. package/lib/web/src/mina/transactions/nonce.js.map +1 -0
  54. package/lib/web/src/mina/transactions/transaction.d.ts +9 -0
  55. package/lib/web/src/mina/transactions/transaction.js +65 -0
  56. package/lib/web/src/mina/transactions/transaction.js.map +1 -0
  57. package/lib/web/src/mina/transactions/txstatus.d.ts +8 -0
  58. package/lib/web/src/mina/transactions/txstatus.js +16 -0
  59. package/lib/web/src/mina/transactions/txstatus.js.map +1 -0
  60. package/lib/web/src/mina/utils/fetch.js +1 -1
  61. package/lib/web/tsconfig.web.tsbuildinfo +1 -1
  62. package/package.json +5 -5
@@ -0,0 +1,338 @@
1
+ import { AccountUpdate, AccountUpdateForest, Bool, DeployArgs, Field, Int64, PublicKey, State, TokenContractV2, Types, UInt64, UInt8, VerificationKey } from "o1js";
2
+ import { FungibleTokenAdminBase } from "./FungibleTokenAdmin.js";
3
+ interface FungibleTokenDeployProps extends Exclude<DeployArgs, undefined> {
4
+ /** The token symbol. */
5
+ symbol: string;
6
+ /** A source code reference, which is placed within the `zkappUri` of the contract account.
7
+ * Typically a link to a file on github. */
8
+ src: string;
9
+ }
10
+ export declare const FungibleTokenErrors: {
11
+ noAdminKey: string;
12
+ noPermissionToChangeAdmin: string;
13
+ tokenPaused: string;
14
+ noPermissionToMint: string;
15
+ noPermissionToPause: string;
16
+ noPermissionToResume: string;
17
+ noTransferFromCirculation: string;
18
+ noPermissionChangeAllowed: string;
19
+ flashMinting: string;
20
+ unbalancedTransaction: string;
21
+ };
22
+ export declare class FungibleToken extends TokenContractV2 {
23
+ decimals: State<UInt8>;
24
+ admin: State<PublicKey>;
25
+ paused: State<import("o1js/dist/node/lib/provable/bool.js").Bool>;
26
+ static AdminContract: new (...args: any) => FungibleTokenAdminBase;
27
+ readonly events: {
28
+ SetAdmin: typeof SetAdminEvent;
29
+ Pause: typeof PauseEvent;
30
+ Mint: typeof MintEvent;
31
+ Burn: typeof BurnEvent;
32
+ BalanceChange: typeof BalanceChangeEvent;
33
+ };
34
+ deploy(props: FungibleTokenDeployProps): Promise<void>;
35
+ /** Update the verification key.
36
+ * Note that because we have set the permissions for setting the verification key to `impossibleDuringCurrentVersion()`, this will only be possible in case of a protocol update that requires an update.
37
+ */
38
+ updateVerificationKey(vk: VerificationKey): Promise<void>;
39
+ /** Initializes the account for tracking total circulation.
40
+ * @argument {PublicKey} admin - public key where the admin contract is deployed
41
+ * @argument {UInt8} decimals - number of decimals for the token
42
+ * @argument {Bool} startPaused - if set to `Bool(true), the contract will start in a mode where token minting and transfers are paused. This should be used for non-atomic deployments
43
+ */
44
+ initialize(admin: PublicKey, decimals: UInt8, startPaused: Bool): Promise<void>;
45
+ getAdminContract(): Promise<FungibleTokenAdminBase>;
46
+ setAdmin(admin: PublicKey): Promise<void>;
47
+ mint(recipient: PublicKey, amount: UInt64): Promise<AccountUpdate>;
48
+ burn(from: PublicKey, amount: UInt64): Promise<AccountUpdate>;
49
+ pause(): Promise<void>;
50
+ resume(): Promise<void>;
51
+ transfer(from: PublicKey, to: PublicKey, amount: UInt64): Promise<void>;
52
+ private checkPermissionsUpdate;
53
+ /** Approve `AccountUpdate`s that have been created outside of the token contract.
54
+ *
55
+ * @argument {AccountUpdateForest} updates - The `AccountUpdate`s to approve. Note that the forest size is limited by the base token contract, @see TokenContractV2.MAX_ACCOUNT_UPDATES The current limit is 9.
56
+ */
57
+ approveBase(updates: AccountUpdateForest): Promise<void>;
58
+ getBalanceOf(address: PublicKey): Promise<UInt64>;
59
+ /** Reports the current circulating supply
60
+ * This does take into account currently unreduced actions.
61
+ */
62
+ getCirculating(): Promise<UInt64>;
63
+ getDecimals(): Promise<UInt8>;
64
+ }
65
+ declare const SetAdminEvent_base: (new (value: {
66
+ adminKey: PublicKey;
67
+ }) => {
68
+ adminKey: PublicKey;
69
+ }) & {
70
+ _isStruct: true;
71
+ } & Omit<import("o1js/dist/node/lib/provable/types/provable-intf.js").Provable<{
72
+ adminKey: PublicKey;
73
+ }, {
74
+ adminKey: {
75
+ x: bigint;
76
+ isOdd: boolean;
77
+ };
78
+ }>, "fromFields"> & {
79
+ fromFields: (fields: import("o1js/dist/node/lib/provable/field.js").Field[]) => {
80
+ adminKey: PublicKey;
81
+ };
82
+ } & {
83
+ fromValue: (value: {
84
+ adminKey: PublicKey | {
85
+ x: Field | bigint;
86
+ isOdd: Bool | boolean;
87
+ };
88
+ }) => {
89
+ adminKey: PublicKey;
90
+ };
91
+ toInput: (x: {
92
+ adminKey: PublicKey;
93
+ }) => {
94
+ fields?: Field[] | undefined;
95
+ packed?: [Field, number][] | undefined;
96
+ };
97
+ toJSON: (x: {
98
+ adminKey: PublicKey;
99
+ }) => {
100
+ adminKey: string;
101
+ };
102
+ fromJSON: (x: {
103
+ adminKey: string;
104
+ }) => {
105
+ adminKey: PublicKey;
106
+ };
107
+ empty: () => {
108
+ adminKey: PublicKey;
109
+ };
110
+ };
111
+ export declare class SetAdminEvent extends SetAdminEvent_base {
112
+ }
113
+ declare const PauseEvent_base: (new (value: {
114
+ isPaused: import("o1js/dist/node/lib/provable/bool.js").Bool;
115
+ }) => {
116
+ isPaused: import("o1js/dist/node/lib/provable/bool.js").Bool;
117
+ }) & {
118
+ _isStruct: true;
119
+ } & Omit<import("o1js/dist/node/lib/provable/types/provable-intf.js").Provable<{
120
+ isPaused: import("o1js/dist/node/lib/provable/bool.js").Bool;
121
+ }, {
122
+ isPaused: boolean;
123
+ }>, "fromFields"> & {
124
+ fromFields: (fields: import("o1js/dist/node/lib/provable/field.js").Field[]) => {
125
+ isPaused: import("o1js/dist/node/lib/provable/bool.js").Bool;
126
+ };
127
+ } & {
128
+ fromValue: (value: {
129
+ isPaused: boolean | import("o1js/dist/node/lib/provable/bool.js").Bool;
130
+ }) => {
131
+ isPaused: import("o1js/dist/node/lib/provable/bool.js").Bool;
132
+ };
133
+ toInput: (x: {
134
+ isPaused: import("o1js/dist/node/lib/provable/bool.js").Bool;
135
+ }) => {
136
+ fields?: Field[] | undefined;
137
+ packed?: [Field, number][] | undefined;
138
+ };
139
+ toJSON: (x: {
140
+ isPaused: import("o1js/dist/node/lib/provable/bool.js").Bool;
141
+ }) => {
142
+ isPaused: boolean;
143
+ };
144
+ fromJSON: (x: {
145
+ isPaused: boolean;
146
+ }) => {
147
+ isPaused: import("o1js/dist/node/lib/provable/bool.js").Bool;
148
+ };
149
+ empty: () => {
150
+ isPaused: import("o1js/dist/node/lib/provable/bool.js").Bool;
151
+ };
152
+ };
153
+ export declare class PauseEvent extends PauseEvent_base {
154
+ }
155
+ declare const MintEvent_base: (new (value: {
156
+ recipient: PublicKey;
157
+ amount: Types.UInt64;
158
+ }) => {
159
+ recipient: PublicKey;
160
+ amount: Types.UInt64;
161
+ }) & {
162
+ _isStruct: true;
163
+ } & Omit<import("o1js/dist/node/lib/provable/types/provable-intf.js").Provable<{
164
+ recipient: PublicKey;
165
+ amount: Types.UInt64;
166
+ }, {
167
+ recipient: {
168
+ x: bigint;
169
+ isOdd: boolean;
170
+ };
171
+ amount: bigint;
172
+ }>, "fromFields"> & {
173
+ fromFields: (fields: import("o1js/dist/node/lib/provable/field.js").Field[]) => {
174
+ recipient: PublicKey;
175
+ amount: Types.UInt64;
176
+ };
177
+ } & {
178
+ fromValue: (value: {
179
+ recipient: PublicKey | {
180
+ x: Field | bigint;
181
+ isOdd: Bool | boolean;
182
+ };
183
+ amount: bigint | Types.UInt64;
184
+ }) => {
185
+ recipient: PublicKey;
186
+ amount: Types.UInt64;
187
+ };
188
+ toInput: (x: {
189
+ recipient: PublicKey;
190
+ amount: Types.UInt64;
191
+ }) => {
192
+ fields?: Field[] | undefined;
193
+ packed?: [Field, number][] | undefined;
194
+ };
195
+ toJSON: (x: {
196
+ recipient: PublicKey;
197
+ amount: Types.UInt64;
198
+ }) => {
199
+ recipient: string;
200
+ amount: string;
201
+ };
202
+ fromJSON: (x: {
203
+ recipient: string;
204
+ amount: string;
205
+ }) => {
206
+ recipient: PublicKey;
207
+ amount: Types.UInt64;
208
+ };
209
+ empty: () => {
210
+ recipient: PublicKey;
211
+ amount: Types.UInt64;
212
+ };
213
+ };
214
+ export declare class MintEvent extends MintEvent_base {
215
+ }
216
+ declare const BurnEvent_base: (new (value: {
217
+ from: PublicKey;
218
+ amount: Types.UInt64;
219
+ }) => {
220
+ from: PublicKey;
221
+ amount: Types.UInt64;
222
+ }) & {
223
+ _isStruct: true;
224
+ } & Omit<import("o1js/dist/node/lib/provable/types/provable-intf.js").Provable<{
225
+ from: PublicKey;
226
+ amount: Types.UInt64;
227
+ }, {
228
+ from: {
229
+ x: bigint;
230
+ isOdd: boolean;
231
+ };
232
+ amount: bigint;
233
+ }>, "fromFields"> & {
234
+ fromFields: (fields: import("o1js/dist/node/lib/provable/field.js").Field[]) => {
235
+ from: PublicKey;
236
+ amount: Types.UInt64;
237
+ };
238
+ } & {
239
+ fromValue: (value: {
240
+ from: PublicKey | {
241
+ x: Field | bigint;
242
+ isOdd: Bool | boolean;
243
+ };
244
+ amount: bigint | Types.UInt64;
245
+ }) => {
246
+ from: PublicKey;
247
+ amount: Types.UInt64;
248
+ };
249
+ toInput: (x: {
250
+ from: PublicKey;
251
+ amount: Types.UInt64;
252
+ }) => {
253
+ fields?: Field[] | undefined;
254
+ packed?: [Field, number][] | undefined;
255
+ };
256
+ toJSON: (x: {
257
+ from: PublicKey;
258
+ amount: Types.UInt64;
259
+ }) => {
260
+ from: string;
261
+ amount: string;
262
+ };
263
+ fromJSON: (x: {
264
+ from: string;
265
+ amount: string;
266
+ }) => {
267
+ from: PublicKey;
268
+ amount: Types.UInt64;
269
+ };
270
+ empty: () => {
271
+ from: PublicKey;
272
+ amount: Types.UInt64;
273
+ };
274
+ };
275
+ export declare class BurnEvent extends BurnEvent_base {
276
+ }
277
+ declare const BalanceChangeEvent_base: (new (value: {
278
+ address: PublicKey;
279
+ amount: Int64;
280
+ }) => {
281
+ address: PublicKey;
282
+ amount: Int64;
283
+ }) & {
284
+ _isStruct: true;
285
+ } & Omit<import("o1js/dist/node/lib/provable/types/provable-intf.js").Provable<{
286
+ address: PublicKey;
287
+ amount: Int64;
288
+ }, {
289
+ address: {
290
+ x: bigint;
291
+ isOdd: boolean;
292
+ };
293
+ amount: any;
294
+ }>, "fromFields"> & {
295
+ fromFields: (fields: import("o1js/dist/node/lib/provable/field.js").Field[]) => {
296
+ address: PublicKey;
297
+ amount: Int64;
298
+ };
299
+ } & {
300
+ fromValue: (value: {
301
+ address: PublicKey | {
302
+ x: Field | bigint;
303
+ isOdd: Bool | boolean;
304
+ };
305
+ amount: any;
306
+ }) => {
307
+ address: PublicKey;
308
+ amount: Int64;
309
+ };
310
+ toInput: (x: {
311
+ address: PublicKey;
312
+ amount: Int64;
313
+ }) => {
314
+ fields?: Field[] | undefined;
315
+ packed?: [Field, number][] | undefined;
316
+ };
317
+ toJSON: (x: {
318
+ address: PublicKey;
319
+ amount: Int64;
320
+ }) => {
321
+ address: string;
322
+ amount: any;
323
+ };
324
+ fromJSON: (x: {
325
+ address: string;
326
+ amount: any;
327
+ }) => {
328
+ address: PublicKey;
329
+ amount: Int64;
330
+ };
331
+ empty: () => {
332
+ address: PublicKey;
333
+ amount: Int64;
334
+ };
335
+ };
336
+ export declare class BalanceChangeEvent extends BalanceChangeEvent_base {
337
+ }
338
+ export {};
@@ -0,0 +1,274 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { AccountUpdate, AccountUpdateForest, assert, Bool, Int64, method, Permissions, Provable, PublicKey, State, state, Struct, TokenContractV2, Types, UInt64, UInt8, VerificationKey, } from "o1js";
3
+ import { FungibleTokenAdmin } from "./FungibleTokenAdmin.js";
4
+ export const FungibleTokenErrors = {
5
+ noAdminKey: "could not fetch admin contract key",
6
+ noPermissionToChangeAdmin: "Not allowed to change admin contract",
7
+ tokenPaused: "Token is currently paused",
8
+ noPermissionToMint: "Not allowed to mint tokens",
9
+ noPermissionToPause: "Not allowed to pause token",
10
+ noPermissionToResume: "Not allowed to resume token",
11
+ noTransferFromCirculation: "Can't transfer to/from the circulation account",
12
+ noPermissionChangeAllowed: "Can't change permissions for access or receive on token accounts",
13
+ flashMinting: "Flash-minting or unbalanced transaction detected. Please make sure that your transaction is balanced, and that your `AccountUpdate`s are ordered properly, so that tokens are not received before they are sent.",
14
+ unbalancedTransaction: "Transaction is unbalanced",
15
+ };
16
+ export class FungibleToken extends TokenContractV2 {
17
+ constructor() {
18
+ super(...arguments);
19
+ this.decimals = State();
20
+ this.admin = State();
21
+ this.paused = State();
22
+ this.events = {
23
+ SetAdmin: SetAdminEvent,
24
+ Pause: PauseEvent,
25
+ Mint: MintEvent,
26
+ Burn: BurnEvent,
27
+ BalanceChange: BalanceChangeEvent,
28
+ };
29
+ }
30
+ async deploy(props) {
31
+ await super.deploy(props);
32
+ this.paused.set(Bool(true));
33
+ this.account.zkappUri.set(props.src);
34
+ this.account.tokenSymbol.set(props.symbol);
35
+ this.account.permissions.set({
36
+ ...Permissions.default(),
37
+ setVerificationKey: Permissions.VerificationKey.impossibleDuringCurrentVersion(),
38
+ setPermissions: Permissions.impossible(),
39
+ access: Permissions.proof(),
40
+ });
41
+ }
42
+ /** Update the verification key.
43
+ * Note that because we have set the permissions for setting the verification key to `impossibleDuringCurrentVersion()`, this will only be possible in case of a protocol update that requires an update.
44
+ */
45
+ async updateVerificationKey(vk) {
46
+ this.account.verificationKey.set(vk);
47
+ }
48
+ /** Initializes the account for tracking total circulation.
49
+ * @argument {PublicKey} admin - public key where the admin contract is deployed
50
+ * @argument {UInt8} decimals - number of decimals for the token
51
+ * @argument {Bool} startPaused - if set to `Bool(true), the contract will start in a mode where token minting and transfers are paused. This should be used for non-atomic deployments
52
+ */
53
+ async initialize(admin, decimals, startPaused) {
54
+ this.account.provedState.requireEquals(Bool(false));
55
+ this.admin.set(admin);
56
+ this.decimals.set(decimals);
57
+ this.paused.set(Bool(false));
58
+ this.paused.set(startPaused);
59
+ const accountUpdate = AccountUpdate.createSigned(this.address, this.deriveTokenId());
60
+ let permissions = Permissions.default();
61
+ // This is necessary in order to allow token holders to burn.
62
+ permissions.send = Permissions.none();
63
+ permissions.setPermissions = Permissions.impossible();
64
+ accountUpdate.account.permissions.set(permissions);
65
+ }
66
+ async getAdminContract() {
67
+ const admin = await Provable.witnessAsync(PublicKey, async () => {
68
+ let pk = await this.admin.fetch();
69
+ assert(pk !== undefined, FungibleTokenErrors.noAdminKey);
70
+ return pk;
71
+ });
72
+ this.admin.requireEquals(admin);
73
+ return (new FungibleToken.AdminContract(admin));
74
+ }
75
+ async setAdmin(admin) {
76
+ const adminContract = await this.getAdminContract();
77
+ const canChangeAdmin = await adminContract.canChangeAdmin(admin);
78
+ canChangeAdmin.assertTrue(FungibleTokenErrors.noPermissionToChangeAdmin);
79
+ this.admin.set(admin);
80
+ this.emitEvent("SetAdmin", new SetAdminEvent({ adminKey: admin }));
81
+ }
82
+ async mint(recipient, amount) {
83
+ this.paused.getAndRequireEquals().assertFalse(FungibleTokenErrors.tokenPaused);
84
+ const accountUpdate = this.internal.mint({ address: recipient, amount });
85
+ const adminContract = await this.getAdminContract();
86
+ const canMint = await adminContract.canMint(accountUpdate);
87
+ canMint.assertTrue(FungibleTokenErrors.noPermissionToMint);
88
+ recipient.equals(this.address).assertFalse(FungibleTokenErrors.noTransferFromCirculation);
89
+ this.approve(accountUpdate);
90
+ this.emitEvent("Mint", new MintEvent({ recipient, amount }));
91
+ const circulationUpdate = AccountUpdate.create(this.address, this.deriveTokenId());
92
+ circulationUpdate.balanceChange = Int64.fromUnsigned(amount);
93
+ return accountUpdate;
94
+ }
95
+ async burn(from, amount) {
96
+ this.paused.getAndRequireEquals().assertFalse(FungibleTokenErrors.tokenPaused);
97
+ const accountUpdate = this.internal.burn({ address: from, amount });
98
+ const circulationUpdate = AccountUpdate.create(this.address, this.deriveTokenId());
99
+ from.equals(this.address).assertFalse(FungibleTokenErrors.noTransferFromCirculation);
100
+ circulationUpdate.balanceChange = Int64.fromUnsigned(amount).negV2();
101
+ this.emitEvent("Burn", new BurnEvent({ from, amount }));
102
+ return accountUpdate;
103
+ }
104
+ async pause() {
105
+ const adminContract = await this.getAdminContract();
106
+ const canPause = await adminContract.canPause();
107
+ canPause.assertTrue(FungibleTokenErrors.noPermissionToPause);
108
+ this.paused.set(Bool(true));
109
+ this.emitEvent("Pause", new PauseEvent({ isPaused: Bool(true) }));
110
+ }
111
+ async resume() {
112
+ const adminContract = await this.getAdminContract();
113
+ const canResume = await adminContract.canResume();
114
+ canResume.assertTrue(FungibleTokenErrors.noPermissionToResume);
115
+ this.paused.set(Bool(false));
116
+ this.emitEvent("Pause", new PauseEvent({ isPaused: Bool(false) }));
117
+ }
118
+ async transfer(from, to, amount) {
119
+ this.paused.getAndRequireEquals().assertFalse(FungibleTokenErrors.tokenPaused);
120
+ from.equals(this.address).assertFalse(FungibleTokenErrors.noTransferFromCirculation);
121
+ to.equals(this.address).assertFalse(FungibleTokenErrors.noTransferFromCirculation);
122
+ this.internal.send({ from, to, amount });
123
+ }
124
+ checkPermissionsUpdate(update) {
125
+ let permissions = update.update.permissions;
126
+ let { access, receive } = permissions.value;
127
+ let accessIsNone = Provable.equal(Types.AuthRequired, access, Permissions.none());
128
+ let receiveIsNone = Provable.equal(Types.AuthRequired, receive, Permissions.none());
129
+ let updateAllowed = accessIsNone.and(receiveIsNone);
130
+ assert(updateAllowed.or(permissions.isSome.not()), FungibleTokenErrors.noPermissionChangeAllowed);
131
+ }
132
+ /** Approve `AccountUpdate`s that have been created outside of the token contract.
133
+ *
134
+ * @argument {AccountUpdateForest} updates - The `AccountUpdate`s to approve. Note that the forest size is limited by the base token contract, @see TokenContractV2.MAX_ACCOUNT_UPDATES The current limit is 9.
135
+ */
136
+ async approveBase(updates) {
137
+ this.paused.getAndRequireEquals().assertFalse(FungibleTokenErrors.tokenPaused);
138
+ let totalBalance = Int64.from(0);
139
+ this.forEachUpdate(updates, (update, usesToken) => {
140
+ // Make sure that the account permissions are not changed
141
+ this.checkPermissionsUpdate(update);
142
+ this.emitEventIf(usesToken, "BalanceChange", new BalanceChangeEvent({ address: update.publicKey, amount: update.balanceChange }));
143
+ // Don't allow transfers to/from the account that's tracking circulation
144
+ update.publicKey.equals(this.address).and(usesToken).assertFalse(FungibleTokenErrors.noTransferFromCirculation);
145
+ totalBalance = Provable.if(usesToken, totalBalance.add(update.balanceChange), totalBalance);
146
+ totalBalance.isPositiveV2().assertFalse(FungibleTokenErrors.flashMinting);
147
+ });
148
+ totalBalance.assertEquals(Int64.zero, FungibleTokenErrors.unbalancedTransaction);
149
+ }
150
+ async getBalanceOf(address) {
151
+ const account = AccountUpdate.create(address, this.deriveTokenId()).account;
152
+ const balance = account.balance.get();
153
+ account.balance.requireEquals(balance);
154
+ return balance;
155
+ }
156
+ /** Reports the current circulating supply
157
+ * This does take into account currently unreduced actions.
158
+ */
159
+ async getCirculating() {
160
+ let circulating = await this.getBalanceOf(this.address);
161
+ return circulating;
162
+ }
163
+ async getDecimals() {
164
+ return this.decimals.getAndRequireEquals();
165
+ }
166
+ }
167
+ // This defines the type of the contract that is used to control access to administrative actions.
168
+ // If you want to have a custom contract, overwrite this by setting FungibleToken.AdminContract to
169
+ // your own implementation of FungibleTokenAdminBase.
170
+ FungibleToken.AdminContract = FungibleTokenAdmin;
171
+ __decorate([
172
+ state(UInt8),
173
+ __metadata("design:type", Object)
174
+ ], FungibleToken.prototype, "decimals", void 0);
175
+ __decorate([
176
+ state(PublicKey),
177
+ __metadata("design:type", Object)
178
+ ], FungibleToken.prototype, "admin", void 0);
179
+ __decorate([
180
+ state(Bool),
181
+ __metadata("design:type", Object)
182
+ ], FungibleToken.prototype, "paused", void 0);
183
+ __decorate([
184
+ method,
185
+ __metadata("design:type", Function),
186
+ __metadata("design:paramtypes", [VerificationKey]),
187
+ __metadata("design:returntype", Promise)
188
+ ], FungibleToken.prototype, "updateVerificationKey", null);
189
+ __decorate([
190
+ method,
191
+ __metadata("design:type", Function),
192
+ __metadata("design:paramtypes", [PublicKey,
193
+ UInt8,
194
+ Bool]),
195
+ __metadata("design:returntype", Promise)
196
+ ], FungibleToken.prototype, "initialize", null);
197
+ __decorate([
198
+ method,
199
+ __metadata("design:type", Function),
200
+ __metadata("design:paramtypes", [PublicKey]),
201
+ __metadata("design:returntype", Promise)
202
+ ], FungibleToken.prototype, "setAdmin", null);
203
+ __decorate([
204
+ method.returns(AccountUpdate),
205
+ __metadata("design:type", Function),
206
+ __metadata("design:paramtypes", [PublicKey, UInt64]),
207
+ __metadata("design:returntype", Promise)
208
+ ], FungibleToken.prototype, "mint", null);
209
+ __decorate([
210
+ method.returns(AccountUpdate),
211
+ __metadata("design:type", Function),
212
+ __metadata("design:paramtypes", [PublicKey, UInt64]),
213
+ __metadata("design:returntype", Promise)
214
+ ], FungibleToken.prototype, "burn", null);
215
+ __decorate([
216
+ method,
217
+ __metadata("design:type", Function),
218
+ __metadata("design:paramtypes", []),
219
+ __metadata("design:returntype", Promise)
220
+ ], FungibleToken.prototype, "pause", null);
221
+ __decorate([
222
+ method,
223
+ __metadata("design:type", Function),
224
+ __metadata("design:paramtypes", []),
225
+ __metadata("design:returntype", Promise)
226
+ ], FungibleToken.prototype, "resume", null);
227
+ __decorate([
228
+ method,
229
+ __metadata("design:type", Function),
230
+ __metadata("design:paramtypes", [PublicKey, PublicKey, UInt64]),
231
+ __metadata("design:returntype", Promise)
232
+ ], FungibleToken.prototype, "transfer", null);
233
+ __decorate([
234
+ method,
235
+ __metadata("design:type", Function),
236
+ __metadata("design:paramtypes", [AccountUpdateForest]),
237
+ __metadata("design:returntype", Promise)
238
+ ], FungibleToken.prototype, "approveBase", null);
239
+ __decorate([
240
+ method.returns(UInt64),
241
+ __metadata("design:type", Function),
242
+ __metadata("design:paramtypes", [PublicKey]),
243
+ __metadata("design:returntype", Promise)
244
+ ], FungibleToken.prototype, "getBalanceOf", null);
245
+ __decorate([
246
+ method.returns(UInt8),
247
+ __metadata("design:type", Function),
248
+ __metadata("design:paramtypes", []),
249
+ __metadata("design:returntype", Promise)
250
+ ], FungibleToken.prototype, "getDecimals", null);
251
+ export class SetAdminEvent extends Struct({
252
+ adminKey: PublicKey,
253
+ }) {
254
+ }
255
+ export class PauseEvent extends Struct({
256
+ isPaused: Bool,
257
+ }) {
258
+ }
259
+ export class MintEvent extends Struct({
260
+ recipient: PublicKey,
261
+ amount: UInt64,
262
+ }) {
263
+ }
264
+ export class BurnEvent extends Struct({
265
+ from: PublicKey,
266
+ amount: UInt64,
267
+ }) {
268
+ }
269
+ export class BalanceChangeEvent extends Struct({
270
+ address: PublicKey,
271
+ amount: Int64,
272
+ }) {
273
+ }
274
+ //# sourceMappingURL=FungibleToken.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FungibleToken.js","sourceRoot":"","sources":["../../../../../../src/mina/token/FungibleToken.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,E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AAQ,MAAM,CAAC;IAC7C,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,KAAK;CACd,CAAC;CAAG"}
@@ -0,0 +1,31 @@
1
+ import { AccountUpdate, Bool, DeployArgs, PublicKey, SmartContract, VerificationKey } from "o1js";
2
+ export type FungibleTokenAdminBase = SmartContract & {
3
+ canMint(accountUpdate: AccountUpdate): Promise<Bool>;
4
+ canChangeAdmin(admin: PublicKey): Promise<Bool>;
5
+ canPause(): Promise<Bool>;
6
+ canResume(): Promise<Bool>;
7
+ };
8
+ export interface FungibleTokenAdminDeployProps extends Exclude<DeployArgs, undefined> {
9
+ adminPublicKey: PublicKey;
10
+ }
11
+ /** A contract that grants permissions for administrative actions on a token.
12
+ *
13
+ * We separate this out into a dedicated contract. That way, when issuing a token, a user can
14
+ * specify their own rules for administrative actions, without changing the token contract itself.
15
+ *
16
+ * The advantage is that third party applications that only use the token in a non-privileged way
17
+ * can integrate against the unchanged token contract.
18
+ */
19
+ export declare class FungibleTokenAdmin extends SmartContract implements FungibleTokenAdminBase {
20
+ private adminPublicKey;
21
+ deploy(props: FungibleTokenAdminDeployProps): Promise<void>;
22
+ /** Update the verification key.
23
+ * Note that because we have set the permissions for setting the verification key to `impossibleDuringCurrentVersion()`, this will only be possible in case of a protocol update that requires an update.
24
+ */
25
+ updateVerificationKey(vk: VerificationKey): Promise<void>;
26
+ private ensureAdminSignature;
27
+ canMint(_accountUpdate: AccountUpdate): Promise<import("o1js/dist/node/lib/provable/bool").Bool>;
28
+ canChangeAdmin(_admin: PublicKey): Promise<import("o1js/dist/node/lib/provable/bool").Bool>;
29
+ canPause(): Promise<Bool>;
30
+ canResume(): Promise<Bool>;
31
+ }