Skip to content

Commit

Permalink
parking-lot example refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
volovyks committed Aug 31, 2022
1 parent 3d8ac7c commit 579f7ca
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion examples/__tests__/test-parking-lot.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test.beforeEach(async t => {
const parkingLot = await root.devDeploy(
'build/parking-lot.wasm',
);
await parkingLot.call(parkingLot, 'init', {});


const ali = await root.createSubAccount('ali');

Expand Down
11 changes: 3 additions & 8 deletions examples/src/parking-lot.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NearContract, NearBindgen, near, call, view, LookupMap } from 'near-sdk-js'
import { NearBindgen, near, call, view, LookupMap } from 'near-sdk-js'

class CarSpecs {
id: number;
Expand Down Expand Up @@ -30,11 +30,10 @@ class Engine {
}
}

@NearBindgen
class ParkingLot extends NearContract {
@NearBindgen({})
class ParkingLot {
cars: LookupMap;
constructor() {
super()
this.cars = new LookupMap('a');
}

Expand Down Expand Up @@ -68,8 +67,4 @@ class ParkingLot extends NearContract {
let engine = new Engine(carSpecs.engine.hp)
return engine.run()
}

default() {
return new ParkingLot()
}
}
2 changes: 1 addition & 1 deletion lib/near-bindgen.d.ts

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

2 changes: 1 addition & 1 deletion src/near-bindgen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function call(target: Object, key: string | symbol, descriptor: TypedProp
export function view(target: Object, key: string | symbol, descriptor: TypedPropertyDescriptor<Function>): void {
}

export function NearBindgen({ requireInit = false }: { requireInit: boolean }) {
export function NearBindgen({ requireInit = false }: { requireInit?: boolean }) {
return <T extends { new(...args: any[]): {} }>(target: T) => {
return class extends target {
static _create() {
Expand Down

0 comments on commit 579f7ca

Please sign in to comment.