Skip to content

Commit

Permalink
Babel calls use NearBindgen static methods
Browse files Browse the repository at this point in the history
  • Loading branch information
volovyks committed Aug 30, 2022
1 parent 4a1fd14 commit ab89e65
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions 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 lib/near-bindgen.d.ts

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

4 changes: 2 additions & 2 deletions lib/near-bindgen.js

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

8 changes: 4 additions & 4 deletions src/build-tools/near-bindgen-exporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ export default function () {
// let _result = _contract.method(args);
t.variableDeclaration('let', [t.variableDeclarator(t.identifier('_result'), t.callExpression(t.memberExpression(t.identifier('_contract'), t.identifier(method)), [t.identifier('_args')]))]),
contractMethods[method] === 'initialize' || contractMethods[method] === 'call' ?
// _contract._saveToStorage();
t.expressionStatement(t.callExpression(t.memberExpression(t.identifier('_contract'), t.identifier('_saveToStorage')), []))
// Counter._saveToStorage(_contract);
t.expressionStatement(t.callExpression(t.memberExpression(classId, t.identifier('_saveToStorage')), [t.identifier('_contract')]))
: t.emptyStatement(),
// if (_result !== undefined) near.valueReturn(_contract._serialize(result));
t.ifStatement(t.binaryExpression('!==', t.identifier('_result'), t.identifier('undefined')), t.expressionStatement(t.callExpression(t.memberExpression(t.identifier('near'), t.identifier('valueReturn')), [t.callExpression(t.memberExpression(t.identifier('_contract'), t.identifier('_serialize')), [t.identifier('_result')])]))),
t.ifStatement(t.binaryExpression('!==', t.identifier('_result'), t.identifier('undefined')), t.expressionStatement(t.callExpression(t.memberExpression(t.identifier('near'), t.identifier('valueReturn')), [t.callExpression(t.memberExpression(classId, t.identifier('_serialize')), [t.identifier('_result')])]))),
]))));
console.log('Near bindgen export done');
console.log(`Babel ${method} method export done`);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/near-bindgen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export function NearBindgen<T extends { new(...args: any[]): {} }>(target: T) {
return rawState ? this._deserialize(rawState) : null;
}

static _saveToStorage(): void {
near.storageWrite("STATE", this._serialize(this));
static _saveToStorage(obj: Object): void {
near.storageWrite("STATE", this._serialize(obj));
}

static _getArgs(): JSON {
Expand Down

0 comments on commit ab89e65

Please sign in to comment.