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

feat-issues-11: update near sdk and workspace version #12

Merged
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
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