Skip to content

Commit

Permalink
Merge pull request #220 from tronprotocol/feature/v4.1.0
Browse files Browse the repository at this point in the history
callback compatible for call, send methods
  • Loading branch information
unicornonea authored Jan 5, 2022
2 parents 4f389d7 + 884db21 commit 68669fc
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions src/lib/contract/method.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,35 @@ export default class Method {
rawParameter = encodeParamsV2ByABI(this.abi, args);
}
return {
call: (options = {}, cb = false) => this._call([], [], Object.assign(options, { rawParameter }), cb),
send: (options = {}, pk = this.tronWeb.defaultPrivateKey, cb = false) => this._send([], [], Object.assign(options, { rawParameter }), pk, cb),
watch: (options = {}, cb = false) => this._watch(options, cb)
call: (options = {}, callback = false) => {
if (utils.isFunction(options)) {
callback = options;
options = {};
}
options = {
...options,
rawParameter
};

return this._call([], [], options, callback);
},
send: (options = {}, privateKey = this.tronWeb.defaultPrivateKey, callback = false) => {
if (utils.isFunction(privateKey)) {
callback = privateKey;
privateKey = this.tronWeb.defaultPrivateKey;
}
if (utils.isFunction(options)) {
callback = options;
options = {};
}
options = {
...options,
rawParameter
};

return this._send([], [], options, privateKey, callback);
},
watch: (...methodArgs) => this._watch(...methodArgs)
}
}

Expand Down

0 comments on commit 68669fc

Please sign in to comment.