Skip to content

Commit

Permalink
feat(ACi): Make compatible with compiler 3.1.0 (#457)
Browse files Browse the repository at this point in the history
* feat(ACi): Make validation compatible with ACI 3.1.0 Breaking Changes

* feat(ACI): fir converting of return type

* feat(ACI): Add new compiler API for decoding call result

* fix lint

* feat(ACI/Contract): Add new compiler API `decodeCallResult`. Use new `decode` method in contract low

Make ACI `call` function decode result imediatly. Fix all contract tests.

BREAKING CHANGE: Change Contract low lvl API: change `contractDecodeData` interface from `(type:
String, data: String) => Any` to `(source: String, fn: String, callValue: String, callResult:
String) => Any`. * `callResult` is `callType` from call result, be `ok`, `revert`, ...

#458

* feat(ACI): Add `hash`, `signature` to ACI implementatiob

* feat(ACi): Add `bytes` type support

* all tests
  • Loading branch information
nduchak authored Jun 11, 2019
1 parent f55f52a commit d92f2c7
Show file tree
Hide file tree
Showing 5 changed files with 294 additions and 124 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
TAG=v3.0.1
COMPILER_TAG=v3.0.0
COMPILER_TAG=v3.1.0
19 changes: 11 additions & 8 deletions es/ae/contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async function handleCallError (result) {
throw Object.assign(Error(`Invocation failed: ${error}. Decoded: ${decodedError}`), R.merge(result, { error, decodedError }))
}

const decodedError = await this.contractDecodeData('string', error)
const decodedError = await this.contractDecodeDataAPI('string', error)
throw Object.assign(Error(`Invocation failed: ${error}. Decoded: ${decodedError}`), R.merge(result, { error, decodedError }))
}

Expand All @@ -73,14 +73,17 @@ async function contractEncodeCall (source, name, args) {
* @function
* @alias module:@aeternity/aepp-sdk/es/ae/contract
* @category async
* @param {String} type Data type (int, string, list,...)
* @param {String} data call result data (cb_iwer89fjsdf2j93fjews_(ssdffsdfsdf...)
* @param {String} source - source code
* @param {String } fn - function name
* @param {String} callValue - result call data
* @param {String} callResult - result status
* @return {Promise<String>} Result object
* @example
* const decodedData = await client.contractDecodeData('string' ,'cb_sf;ls43fsdfsdf...')
* const decodedData = await client.contractDecodeData(SourceCode ,'functionName', 'cb_asdasdasd...', 'ok|revert')lt
* @param options
*/
async function contractDecodeData (type, data) {
return this.contractDecodeDataAPI(type, data)
async function contractDecodeData (source, fn, callValue, callResult, options) {
return this.contractDecodeCallResultAPI(source, fn, callValue, callResult, options)
}

/**
Expand Down Expand Up @@ -132,7 +135,7 @@ async function contractCallStatic (source, address, name, args = [], { top, opti
}
return {
result: callObj,
decode: (type) => this.contractDecodeData(type, returnValue)
decode: () => this.contractDecodeData(source, name, returnValue, returnType, options)
}
}

Expand Down Expand Up @@ -172,7 +175,7 @@ async function contractCall (source, address, name, args = [], options = {}) {
hash,
rawTx,
result,
decode: (type) => this.contractDecodeData(type, result.returnValue)
decode: () => this.contractDecodeData(source, name, result.returnValue, result.returnType)
}
} else {
await this.handleCallError(result)
Expand Down
Loading

0 comments on commit d92f2c7

Please sign in to comment.