Skip to content

Commit bdf76e2

Browse files
committed
contracts: Mark handleCallError as private, simplify arguments
1 parent c856244 commit bdf76e2

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

es/ae/contract.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ async function sendAndProcess (tx, options) {
4949
const result = await this.getTxInfo(txData.hash)
5050

5151
if (result.returnType !== 'ok') {
52-
await this.handleCallError({ result, tx: TxObject({ tx: txData.rawTx }), rawTx: txData.rawTx })
52+
await this._handleCallError(result, txData.rawTx)
5353
}
5454

5555
return { hash: txData.hash, tx: TxObject({ tx: txData.rawTx }), result, txData, rawTx: txData.rawTx }
@@ -58,22 +58,23 @@ async function sendAndProcess (tx, options) {
5858
/**
5959
* Handle contract call error
6060
* @function
61+
* @private
6162
* @alias module:@aeternity/aepp-sdk/es/ae/contract
6263
* @category async
6364
* @param {Object} result call result object
64-
* @param {Object} tx Unpacked transaction
65+
* @param {String} rawTx Raw transaction
6566
* @throws Error Decoded error
6667
* @return {Promise<void>}
6768
*/
68-
async function handleCallError ({ result, tx, rawTx }) {
69+
async function _handleCallError (result, rawTx) {
6970
const error = Buffer.from(result.returnValue).toString()
7071
const decodedError = isBase64(error.slice(3))
7172
? Buffer.from(error.slice(3), 'base64').toString()
7273
: await this.contractDecodeDataAPI('string', error)
7374
throw Object.assign(
7475
new Error(`Invocation failed: ${error}. Decoded: ${decodedError}`), {
7576
...result,
76-
tx,
77+
tx: TxObject({ tx: rawTx }),
7778
error,
7879
rawTx,
7980
decodedError
@@ -190,7 +191,7 @@ async function dryRunContractTx (tx, callerId, source, name, opt = {}) {
190191
if (status !== 'ok') throw Object.assign(new Error('Dry run error, ' + reason), { tx: TxObject({ tx }), dryRunParams: { accounts: [dryRunAccount], top } })
191192
const { returnType, returnValue } = callObj
192193
if (returnType !== 'ok') {
193-
await this.handleCallError({ result: callObj, tx: TxObject({ tx }) })
194+
await this._handleCallError(callObj, tx)
194195
}
195196
return {
196197
tx: TxObject({ tx }),
@@ -476,7 +477,7 @@ export const ContractAPI = Ae.compose(ContractBase, ContractACI, {
476477
contractEncodeCall,
477478
contractDecodeData,
478479
dryRunContractTx,
479-
handleCallError,
480+
_handleCallError,
480481
// Delegation for contract
481482
// AENS
482483
delegateSignatureCommon,

0 commit comments

Comments
 (0)