Skip to content

Commit

Permalink
Merge pull request #41 from qianbin/tweak-decoded
Browse files Browse the repository at this point in the history
tweak Thor.Decoded definition
  • Loading branch information
qianbin authored Mar 20, 2019
2 parents c00bd7a + 6b9feb9 commit 4c24375
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
11 changes: 3 additions & 8 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,7 @@ nameMethod.call().then(output=>{
"reverted": false,
"vmError": "",
"decoded": {
"0": "VeThor",
"__length__": 1
"0": "VeThor"
}
}

Expand Down Expand Up @@ -277,7 +276,6 @@ transferMethod.call('0xd3ae78222beadb038203be21ed5ce7c9b1bff602', 1).then(output
"vmError": "",
"decoded": {
"0": true,
"__length__": 1,
"success": true
}
}
Expand Down Expand Up @@ -712,7 +710,6 @@ filter.apply(0, 1).then(logs=>{
"0": "0x7567D83b7b8d80ADdCb281A71d54Fc7B3364ffed",
"1": "0x00F34f4462c0f6a6f5E76Fb1b6D63F05A32eD2C6",
"2": "1000000000000000000",
"__length__": 3,
"_from": "0x7567D83b7b8d80ADdCb281A71d54Fc7B3364ffed",
"_to": "0x00F34f4462c0f6a6f5E76Fb1b6D63F05A32eD2C6",
"_value": "1000000000000000000"
Expand Down Expand Up @@ -1094,16 +1091,15 @@ origin
`Decoded` is a mixed object that produced by `ABI.decode` with the ABI definition of `EVENT` or `METHOD`. Decoded will be present only at the ABI definition is provided.
+ `__length__` - `number(optional)`: Count of decoded properties, not available when method call reverted
+ `string` - `any`: Decoded property based on the ABI
+ {index} - `number`: Decoded property by parameter index
+ {name} - `string`: Decoded property by parameter name if any
+ `revertReason` - `string(optional)`: Reason message when method call reverted. It's usually the second argument of `require` statement in Solidity, and helpful to diagnose contract code.
For example if a method's definition is `function name() public pure returns(string name)` after perform the simulate call `decoded` will be like following:

``` javascript
{
"0": "VeThor",
"__length__": 1,
"name": "VeThor"
}
```
Expand All @@ -1117,7 +1113,6 @@ Another example if an event's definition is `event Transfer(address indexed _fro
"0": "0x7567D83b7b8d80ADdCb281A71d54Fc7B3364ffed",
"1": "0x00F34f4462c0f6a6f5E76Fb1b6D63F05A32eD2C6",
"2": "1000000000000000000",
"__length__": 3,
"_from": "0x7567D83b7b8d80ADdCb281A71d54Fc7B3364ffed",
"_to": "0x00F34f4462c0f6a6f5E76Fb1b6D63F05A32eD2C6",
"_value": "1000000000000000000"
Expand Down
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,10 +455,10 @@ declare namespace Connex {
reverted: boolean
events: Event[]
transfers: Transfer[]
decoded?: Decoded | { revertReason: string }
decoded?: Decoded & { revertReason?: string }
}

type Decoded = { __length__: number } & { [field: string]: string }
type Decoded = { [name: string]: any } & { [index: number]: any }
}

interface Vendor {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vechain/connex",
"version": "1.2.1",
"version": "1.2.2",
"description": "Standard interface to connect DApp with VeChain and user",
"main": "",
"scripts": {},
Expand Down

0 comments on commit 4c24375

Please sign in to comment.