diff --git a/lib/build-tools/near-bindgen-exporter.js b/lib/build-tools/near-bindgen-exporter.js index 501abdfc..ac8aec0c 100644 --- a/lib/build-tools/near-bindgen-exporter.js +++ b/lib/build-tools/near-bindgen-exporter.js @@ -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`); } } } diff --git a/lib/near-bindgen.d.ts b/lib/near-bindgen.d.ts index 36d3a55a..859abb37 100644 --- a/lib/near-bindgen.d.ts +++ b/lib/near-bindgen.d.ts @@ -7,7 +7,7 @@ export declare function NearBindgen(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 {