Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to work with o1js version 2.1.0 #110

Merged
merged 5 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions FungibleToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
State,
state,
Struct,
TokenContractV2,
TokenContract,
Types,
UInt64,
UInt8,
Expand Down Expand Up @@ -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<UInt8>()
@state(PublicKey)
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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<void> {
Expand All @@ -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,
)
})
Expand Down
1 change: 0 additions & 1 deletion examples/concurrent-transfer.eg.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
16 changes: 10 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mina-fungible-token",
"version": "1.0.0",
"version": "2.0.0-local",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this on purpose so that this version is not released yet?

"license": "Apache-2.0",
"type": "module",
"main": "target/index.js",
Expand All @@ -13,10 +13,13 @@
"check": "tsc --noEmit"
},
"peerDependencies": {
"o1js": "^1.6.0"
"o1js": "^2.1.0"
},
"devDependencies": {
"ts-node": "^10.9.2",
"typescript": "^5.4.3"
},
"engines": {
"node": ">=18.14.0"
}
}
32 changes: 19 additions & 13 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
{
"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,
Expand All @@ -20,15 +12,29 @@
"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": ".",
"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": ["."]
Expand Down
8 changes: 5 additions & 3 deletions words.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
MYTKN
alexa
approvable
behaviour
devnet
dprint
esbenp
feepayer
harrysolovay
kantp
keypair
Lightnet
mdbook
merkle
michaelfbryan
mina
mintable
MYTKN
nodenext
peaceiris
qwadratic
Rebasable
struct
typecheck
yzhang
zkapp
Lightnet
Rebasable