Skip to content

Commit e1fdce0

Browse files
authored
fix(Contract): Add error handlinc(decoding) in low lvl contract API (#386)
1 parent dbb1ba0 commit e1fdce0

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

es/ae/contract.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -215,16 +215,20 @@ async function contractDeploy (code, source, initState = [], options = {}) {
215215
const { hash, rawTx } = await this.send(tx, opt)
216216
const result = await this.getTxInfo(hash)
217217

218-
return Object.freeze({
219-
result,
220-
owner: ownerId,
221-
transaction: hash,
222-
rawTx,
223-
address: contractId,
224-
call: async (name, args = [], options) => this.contractCall(source, contractId, name, args, options),
225-
callStatic: async (name, args = [], options) => this.contractCallStatic(source, contractId, name, args, options),
226-
createdAt: new Date()
227-
})
218+
if (result.returnType === 'ok') {
219+
return Object.freeze({
220+
result,
221+
owner: ownerId,
222+
transaction: hash,
223+
rawTx,
224+
address: contractId,
225+
call: async (name, args = [], options) => this.contractCall(source, contractId, name, args, options),
226+
callStatic: async (name, args = [], options) => this.contractCallStatic(source, contractId, name, args, options),
227+
createdAt: new Date()
228+
})
229+
} else {
230+
await this.handleCallError(result)
231+
}
228232
}
229233

230234
/**

0 commit comments

Comments
 (0)