Skip to content

Commit

Permalink
feat-issues-11: update near sdk and workspace version
Browse files Browse the repository at this point in the history
  • Loading branch information
SpringChiu authored and fospring committed Jul 27, 2023
1 parent abfd124 commit 1151591
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 2,381 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
build
node_modules
node_modules
.idea
package-lock.json
7 changes: 2 additions & 5 deletions __tests__/test-template.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ test.beforeEach(async t => {
const root = worker.rootAccount;

// Deploy the counter contract.
const counter = await root.createAndDeploy(
root.getSubAccount('counter').accountId,
const counter = await root.createSubAccount("counter");
await counter.deploy(
'./build/contract.wasm'
);

// Init the contract
await counter.call(counter, 'init', {});

// Test users
const ali = await root.createSubAccount('ali');
const bob = await root.createSubAccount('bob');
Expand Down
4 changes: 2 additions & 2 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"plugins": [
"near-sdk-js/lib/build-tools/near-bindgen-exporter",
"near-sdk-js/lib/cli/build-tools/near-bindgen-exporter",
["@babel/plugin-proposal-decorators", {"version": "legacy"}]
]
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"author": "Near Inc <[email protected]>",
"license": "Apache-2.0",
"dependencies": {
"near-sdk-js": "^0.4.0-2",
"near-sdk-js": "^1.0.0",
"lodash-es": "^4.17.21"
},
"devDependencies": {
"ava": "^4.2.0",
"near-workspaces": "^2.0.0"
"near-workspaces": "^3.3.0"
}
}
20 changes: 9 additions & 11 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import { NearContract, NearBindgen, near, call, view } from 'near-sdk-js'
import { NearBindgen, near, call, view} from 'near-sdk-js'
import { isUndefined } from 'lodash-es'

@NearBindgen
class Counter extends NearContract {
constructor({ initial = 0 }) {
super()
this.count = initial
@NearBindgen({})
export class Counter {
constructor() {
this.count = 0;
}

@call
@call({})
increase({ n = 1 }) {
this.count += n
near.log(`Counter increased to ${this.count}`)
}

@call
@call({})
decrease({ n }) {
// you can use default argument `n=1` too
// this is to illustrate a npm dependency: lodash can be used
Expand All @@ -26,9 +25,8 @@ class Counter extends NearContract {
near.log(`Counter decreased to ${this.count}`)
}

@view
@view({})
getCount() {
return this.count
}
}

}
Loading

0 comments on commit 1151591

Please sign in to comment.