From a27255b9b52c34f10c7e36e4c7bd1824b6c5a599 Mon Sep 17 00:00:00 2001 From: Philipp Kant Date: Thu, 14 Nov 2024 13:08:12 +0100 Subject: [PATCH 1/5] Update to o1js version 2.0.0 Updating the dependency, and removing the `V2` name prefix that has been dropped after the deprecated functions had been removed. --- FungibleToken.ts | 10 +++++----- package-lock.json | 15 +++++++++------ package.json | 7 +++++-- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/FungibleToken.ts b/FungibleToken.ts index 2578ea0..3d4f0bb 100644 --- a/FungibleToken.ts +++ b/FungibleToken.ts @@ -13,7 +13,7 @@ import { State, state, Struct, - TokenContractV2, + TokenContract, Types, UInt64, UInt8, @@ -43,7 +43,7 @@ export const FungibleTokenErrors = { unbalancedTransaction: "Transaction is unbalanced", } -export class FungibleToken extends TokenContractV2 { +export class FungibleToken extends TokenContract { @state(UInt8) decimals = State() @state(PublicKey) @@ -157,7 +157,7 @@ export class FungibleToken extends TokenContractV2 { from.equals(this.address).assertFalse( FungibleTokenErrors.noTransferFromCirculation, ) - circulationUpdate.balanceChange = Int64.fromUnsigned(amount).negV2() + circulationUpdate.balanceChange = Int64.fromUnsigned(amount).neg() this.emitEvent("Burn", new BurnEvent({ from, amount })) return accountUpdate } @@ -208,7 +208,7 @@ export class FungibleToken extends TokenContractV2 { /** Approve `AccountUpdate`s that have been created outside of the token contract. * - * @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. + * @argument {AccountUpdateForest} updates - The `AccountUpdate`s to approve. Note that the forest size is limited by the base token contract, @see TokenContract.MAX_ACCOUNT_UPDATES The current limit is 9. */ @method async approveBase(updates: AccountUpdateForest): Promise { @@ -227,7 +227,7 @@ export class FungibleToken extends TokenContractV2 { FungibleTokenErrors.noTransferFromCirculation, ) totalBalance = Provable.if(usesToken, totalBalance.add(update.balanceChange), totalBalance) - totalBalance.isPositiveV2().assertFalse( + totalBalance.isPositive().assertFalse( FungibleTokenErrors.flashMinting, ) }) diff --git a/package-lock.json b/package-lock.json index f5fe300..2632717 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,19 +1,22 @@ { "name": "mina-fungible-token", - "version": "1.0.0", + "version": "2.0.0-local", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "mina-fungible-token", - "version": "1.0.0", + "version": "2.0.0-local", "license": "Apache-2.0", "devDependencies": { "ts-node": "^10.9.2", "typescript": "^5.4.3" }, + "engines": { + "node": ">=18.14.0" + }, "peerDependencies": { - "o1js": "^1.6.0" + "o1js": "^2.0.0" } }, "node_modules/@cspotcode/source-map-support": { @@ -187,9 +190,9 @@ } }, "node_modules/o1js": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/o1js/-/o1js-1.6.0.tgz", - "integrity": "sha512-5pHCM0qIHG+MhLlcRJZRK8YFC7MOCjlxwSYbmrLDKER267eUip7JRDtWATytIRxtCPqOBvqKeJb0hR/mvjWxqg==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/o1js/-/o1js-2.0.0.tgz", + "integrity": "sha512-mYCxUkdCgmfF4v8JOTreYJP/PsAUXGkAbDZJn1uRxWlfZ+Eepls1O2fpTKQ5W9DC64vu0LlQZp9uqWKxW4lrVQ==", "peer": true, "dependencies": { "blakejs": "1.2.1", diff --git a/package.json b/package.json index 28bbe99..7e1367e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mina-fungible-token", - "version": "1.0.0", + "version": "2.0.0-local", "license": "Apache-2.0", "type": "module", "main": "target/index.js", @@ -13,10 +13,13 @@ "check": "tsc --noEmit" }, "peerDependencies": { - "o1js": "^1.6.0" + "o1js": "^2.0.0" }, "devDependencies": { "ts-node": "^10.9.2", "typescript": "^5.4.3" + }, + "engines": { + "node": ">=18.14.0" } } From c7cec0601ef2f2ce833a67cb0091d5aa0c293a98 Mon Sep 17 00:00:00 2001 From: Philipp Kant Date: Thu, 14 Nov 2024 14:04:50 +0100 Subject: [PATCH 2/5] Use same tsconfig settings as o1js This was creating some issues for projects using the contract on different platforms. --- tsconfig.json | 48 +++++++++++++++++++----------------------------- words.txt | 8 +++++--- 2 files changed, 24 insertions(+), 32 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 777f3b4..b23aec7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,34 +1,24 @@ { "compilerOptions": { - "allowSyntheticDefaultImports": true, - "baseUrl": ".", - "declaration": true, - "emitDecoratorMetadata": true, - "esModuleInterop": true, - "experimentalDecorators": true, - "forceConsistentCasingInFileNames": true, - "importHelpers": true, - "incremental": true, - "lib": ["DOM", "ES2022"], - "module": "ES2022", - "moduleResolution": "Node", - "noFallthroughCasesInSwitch": true, - "noImplicitAny": true, - "noImplicitReturns": true, - "noImplicitThis": true, - "noUncheckedIndexedAccess": true, - "outDir": "target", - "resolveJsonModule": true, - "skipLibCheck": true, - "sourceMap": true, - "strict": true, - "strictBindCallApply": true, - "strictFunctionTypes": true, - "strictNullChecks": true, - "strictPropertyInitialization": false, - "target": "ES2022", - "typeRoots": ["node_modules/@types"], - "useDefineForClassFields": false + "rootDir": ".", + "outDir": "dist", + "baseUrl": ".", // affects where output files end up + "target": "es2021", // goal: ship *the most modern syntax* that is supported by *all* browsers that support our Wasm + "module": "nodenext", // allow top-level await + "moduleResolution": "nodenext", // comply with node + "type": "module" + "esModuleInterop": true, // to silence jest + + "experimentalDecorators": true, // needed for decorators + "emitDecoratorMetadata": true, // needed for decorators + "useDefineForClassFields": false, // ensure correct behaviour of class fields with decorators + + "strict": true, // for the full TypeScript experience + "strictPropertyInitialization": false, // to enable generic constructors, e.g. on CircuitValue + "importHelpers": true, // reduces size + "declaration": true, // declaration files are how library consumers get our types + "noEmitOnError": false, // avoid accidentally shipping with type errors + "allowJs": true, // to use JSDoc in some places where TS would be too cumbersome + "sourceMap": true }, "exclude": ["node_modules", "target"], "include": ["."] diff --git a/words.txt b/words.txt index b1e8ad2..389983f 100644 --- a/words.txt +++ b/words.txt @@ -1,6 +1,6 @@ -MYTKN alexa approvable +behaviour devnet dprint esbenp @@ -8,16 +8,18 @@ feepayer harrysolovay kantp keypair +Lightnet mdbook merkle michaelfbryan mina mintable +MYTKN +nodenext peaceiris qwadratic +Rebasable struct typecheck yzhang zkapp -Lightnet -Rebasable From b57281a457652a792cf1744c90a1e6d2501cf4e1 Mon Sep 17 00:00:00 2001 From: Philipp Kant Date: Fri, 15 Nov 2024 17:49:50 +0100 Subject: [PATCH 3/5] Fix concurrent transfer example. --- examples/concurrent-transfer.eg.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/concurrent-transfer.eg.ts b/examples/concurrent-transfer.eg.ts index bc13859..eb749d2 100644 --- a/examples/concurrent-transfer.eg.ts +++ b/examples/concurrent-transfer.eg.ts @@ -1,5 +1,4 @@ import { AccountUpdate, Bool, Mina, PrivateKey, PublicKey, UInt64, UInt8 } from "o1js" -import { setLightnetAccountManagerEndpoint } from "o1js/dist/node/lib/mina/fetch.js" import { FungibleToken, FungibleTokenAdmin } from "../index.js" const url = "https://proxy.devnet.minaexplorer.com/graphql" From 47aea5176cc2f5573f812b01ad31d18189f66139 Mon Sep 17 00:00:00 2001 From: Philipp Kant Date: Mon, 18 Nov 2024 16:40:22 +0100 Subject: [PATCH 4/5] Fix outdir in tsconfig.json --- tsconfig.json | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index b23aec7..4d22e21 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,23 @@ { "compilerOptions": { + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "incremental": true, + "lib": ["DOM", "ES2022"], + "noFallthroughCasesInSwitch": true, + "noImplicitAny": true, + "noImplicitReturns": true, + "noImplicitThis": true, + "noUncheckedIndexedAccess": true, + "outDir": "target", + "resolveJsonModule": true, + "skipLibCheck": true, + "strictBindCallApply": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "typeRoots": ["node_modules/@types"], + "rootDir": ".", - "outDir": "dist", "baseUrl": ".", // affects where output files end up "target": "es2021", // goal: ship *the most modern syntax* that is supported by *all* browsers that support our Wasm "module": "nodenext", // allow top-level await From c8400b5db9ea683793e5f81c5a8e3cb7dae0339a Mon Sep 17 00:00:00 2001 From: Philipp Kant Date: Tue, 19 Nov 2024 13:46:38 +0100 Subject: [PATCH 5/5] Bump to o1js 2.1.0 --- package-lock.json | 9 +++++---- package.json | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2632717..4849b5f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "node": ">=18.14.0" }, "peerDependencies": { - "o1js": "^2.0.0" + "o1js": "^2.1.0" } }, "node_modules/@cspotcode/source-map-support": { @@ -190,9 +190,10 @@ } }, "node_modules/o1js": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/o1js/-/o1js-2.0.0.tgz", - "integrity": "sha512-mYCxUkdCgmfF4v8JOTreYJP/PsAUXGkAbDZJn1uRxWlfZ+Eepls1O2fpTKQ5W9DC64vu0LlQZp9uqWKxW4lrVQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/o1js/-/o1js-2.1.0.tgz", + "integrity": "sha512-d3S4ouWHlzne86gVCiMWp+jELqsNdIAzSCzV5QLqK2hyhTclHXDENivzlP/RZ44EEns/CaI7LHuwbovCPMhaCw==", + "license": "Apache-2.0", "peer": true, "dependencies": { "blakejs": "1.2.1", diff --git a/package.json b/package.json index 7e1367e..db637fa 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "check": "tsc --noEmit" }, "peerDependencies": { - "o1js": "^2.0.0" + "o1js": "^2.1.0" }, "devDependencies": { "ts-node": "^10.9.2",