Skip to content

Commit

Permalink
requireInit works
Browse files Browse the repository at this point in the history
  • Loading branch information
volovyks committed Aug 30, 2022
1 parent b37222e commit 49b2a46
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions examples/src/clean-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class CleanState {

@view
get({ key }) {

return near.storageRead(key)
}
}
2 changes: 1 addition & 1 deletion lib/build-tools/near-bindgen-exporter.js

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

2 changes: 1 addition & 1 deletion src/build-tools/near-bindgen-exporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function () {
: t.emptyStatement(),
contractMethods[method] === 'call' || contractMethods[method] === 'view' ?
// if (!_state) { throw new Error('Contract must be initialized'); }
t.ifStatement(t.unaryExpression('!', t.identifier('_state')), t.throwStatement(t.newExpression(t.identifier('Error'), [t.stringLiteral('Contract must be initialized')])))
t.ifStatement(t.logicalExpression('&&', t.unaryExpression('!', t.identifier('_state')), t.callExpression(t.memberExpression(classId, t.identifier('_requireInit')), [])), t.blockStatement([t.throwStatement(t.newExpression(t.identifier('Error'), [t.stringLiteral('Contract must be initialized')]))]))
: t.emptyStatement(),
// let _contract = Counter._create();
t.variableDeclaration('let', [t.variableDeclarator(t.identifier('_contract'), t.callExpression(t.memberExpression(classId, t.identifier('_create')), []))]),
Expand Down

0 comments on commit 49b2a46

Please sign in to comment.