Skip to content

Commit a2fa07e

Browse files
authored
Merge pull request #305 from aeternity/release/2.4.0
Release 2.4.0
2 parents f7f9597 + 41516bc commit a2fa07e

39 files changed

+1662
-552
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
TAG=v2.0.0
1+
TAG=v2.2.0

CHANGELOG.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,70 @@
22
All notable changes to this project will be documented in this file. This change
33
log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).
44

5+
## [2.4.0]
6+
### Added
7+
- Install and configure `commitizen`
8+
- Add `formatAddress` function to `Crypto`
9+
- Add Contract Compiler API stamp to `es/contract` (now using instead contract node API)
10+
- Add basic `http` client stamp (`es/utils/http`)
11+
- ACI stamp (New Contract interface base on contract ACI schema)
12+
Usage:
13+
```
14+
const contractIns = await client.getContractInstance(contractSourceCode)
15+
console.log(contract)
16+
{
17+
interface: String, // Contract interface source code
18+
aci: String, // Contract interface json schema
19+
source: String, // Contract source code
20+
compiled: String, // Compiled contract code
21+
deployInfo: { address: contractAddress } // Object with deploy transaction,
22+
// Function
23+
compile: () => this, // Compile contract,
24+
deploy: (init = [], options = { skipArgsConvert: false }) => this, // Deploy contract (compile before if needed)
25+
call: (fn, params = [], options = { skipArgsConvert: false, skipTransformDecoded: false, callStatic: false } => CallRersult: Object // Call contract function
26+
}
27+
```
28+
29+
### Changed
30+
- Extend `Account.address()` with `accountFormatter` now you can do
31+
```
32+
export const ADDRESS_FORMAT = {
33+
sophia: 1, // return address like `0xHEX_ADDRESS`
34+
api: 2, // return address like `ak_9LJ8ne9tks78hTD2Tp571f7w2MJmzQMRsiZxKCkMA2d2Sbrc4`
35+
}
36+
37+
//
38+
39+
export { ADDRESS_FORMAT } from 'es/account'
40+
await account.address(format: ADDRESS_FORMAT) // default ADDRESS_FORMAT.api
41+
```
42+
- decode node error coming from contract `call` and `callStatic`
43+
- Throw native error instead of object in chain `chain.sendTransaction`
44+
- fix arguments parsing in `Crypto.sing`
45+
- Add `{ compilerUrl }` to `Universal, Contract, Wallet` stamp initialization
46+
- Add ability to get `account/balance` on specific block `hash/height`
47+
- Fix `name hash` function arguments parsing in `Crypto`
48+
- Improve channel rpc usage
49+
- Improve channel tests and error handling
50+
- Improve state channel params handling
51+
52+
### Removed
53+
- `ContractNodeAPI` stamp
54+
55+
### Breaking Changes
56+
- Contract stamp API
57+
```
58+
1) Use Compiler instead of node API for encode/decode call-data and compile.
59+
2) Change Contract interface:
60+
- contractCallStatic (address, abi = 'sophia-address', name, { top, args = '()', call, options = {} } = {}) -> (source, address, name, args = [], { top, options = {} } = {}))
61+
- contractCall (code, abi, address, name, { args = '()', options = {}, call } = {}) -> (source, address, name, args = [], options = {})
62+
- contractDeploy (code, abi, { initState = '()', options = {} } = {}) -> (code, source, initState = [], options = {})
63+
- contractEncodeCall (code, abi, name, args, call) -> (source, name, args) // 'source' is -> Contract source code or ACI interface source
64+
```
65+
66+
### Notes and known Issues
67+
- none
68+
569
## [2.3.2]
670
### Added
771
- none
@@ -564,3 +628,4 @@ log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).
564628
[2.3.0]: https://github.com/aeternity/aepp-sdk-js/compare/2.3.0-next...2.3.0
565629
[2.3.1]: https://github.com/aeternity/aepp-sdk-js/compare/2.3.0...2.3.1
566630
[2.3.2]: https://github.com/aeternity/aepp-sdk-js/compare/2.3.1...2.3.2
631+
[2.4.0.]: https://github.com/aeternity/aepp-sdk-js/compare/2.3.2...2.4.0

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# aepp-sdk
22

3+
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
34
[![Build Status](https://ci.aepps.com/buildStatus/icon?job=aepp-sdk-js/develop)](https://ci.aepps.com/job/aepp-sdk-js/job/develop/)
45
[![npm](https://img.shields.io/npm/v/@aeternity/aepp-sdk.svg)](https://www.npmjs.com/package/@aeternity/aepp-sdk)
56
[![npm](https://img.shields.io/npm/l/@aeternity/aepp-sdk.svg)](https://www.npmjs.com/package/@aeternity/aepp-sdk)

docs/api.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
* [@aeternity/aepp-sdk/es/chain](api/chain.md)
1414
* [@aeternity/aepp-sdk/es/chain/node](api/chain/node.md)
1515
* [@aeternity/aepp-sdk/es/channel/index](api/channel/index.md)
16+
* [@aeternity/aepp-sdk/es/contract/aci](api/contract/aci.md)
17+
* [@aeternity/aepp-sdk/es/contract/compiler](api/contract/compiler.md)
1618
* [@aeternity/aepp-sdk/es/contract](api/contract.md)
17-
* [@aeternity/aepp-sdk/es/contract/node](api/contract/node.md)
1819
* [@aeternity/aepp-sdk/es/node](api/node.md)
1920
* [@aeternity/aepp-sdk/es/oracle](api/oracle.md)
2021
* [@aeternity/aepp-sdk/es/oracle/node](api/oracle/node.md)

docs/api/ae/contract.md

Lines changed: 58 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ import { Contract } from '@aeternity/aepp-sdk' (Using bundle)
1919
* [@aeternity/aepp-sdk/es/ae/contract](#module_@aeternity/aepp-sdk/es/ae/contract)
2020
* [Contract([options])](#exp_module_@aeternity/aepp-sdk/es/ae/contract--Contract)`Object`
2121
* _async_
22-
* [encodeCall(code, abi, name, args, call)](#exp_module_@aeternity/aepp-sdk/es/ae/contract--encodeCall)`Promise.<Object>`
23-
* [callStatic(address, abi, name, options, top, args, call, options)](#exp_module_@aeternity/aepp-sdk/es/ae/contract--callStatic)`Promise.<Object>`
22+
* [handleCallError(result)](#exp_module_@aeternity/aepp-sdk/es/ae/contract--handleCallError)`Promise.<void>`
23+
* [encodeCall(source, name, args)](#exp_module_@aeternity/aepp-sdk/es/ae/contract--encodeCall)`Promise.<String>`
2424
* [decode(type, data)](#exp_module_@aeternity/aepp-sdk/es/ae/contract--decode)`Promise.<String>`
25-
* [call(code, abi, address, name, [options])](#exp_module_@aeternity/aepp-sdk/es/ae/contract--call)`Promise.<Object>`
26-
* [deploy(code, abi, [options])](#exp_module_@aeternity/aepp-sdk/es/ae/contract--deploy)`Promise.<Object>`
27-
* [compile(code, options)](#exp_module_@aeternity/aepp-sdk/es/ae/contract--compile)`Promise.<Object>`
25+
* [callStatic(source, address, name, args, options, top, options)](#exp_module_@aeternity/aepp-sdk/es/ae/contract--callStatic)`Promise.<Object>`
26+
* [call(source, address, name, args, options)](#exp_module_@aeternity/aepp-sdk/es/ae/contract--call)`Promise.<Object>`
27+
* [deploy(code, source, initState, options)](#exp_module_@aeternity/aepp-sdk/es/ae/contract--deploy)`Promise.<Object>`
28+
* [compile(source, options)](#exp_module_@aeternity/aepp-sdk/es/ae/contract--compile)`Promise.<Object>`
2829

2930
<a id="exp_module_@aeternity/aepp-sdk/es/ae/contract--Contract"></a>
3031

@@ -42,41 +43,35 @@ Provide contract implementation
4243
| --- | --- | --- | --- |
4344
| [options] | `Object` | <code>{}</code> | Initializer object |
4445

45-
<a id="exp_module_@aeternity/aepp-sdk/es/ae/contract--encodeCall"></a>
46+
<a id="exp_module_@aeternity/aepp-sdk/es/ae/contract--handleCallError"></a>
4647

47-
### encodeCall(code, abi, name, args, call) ⇒ `Promise.&lt;Object&gt;`
48-
Encode call data for contract call
48+
### handleCallError(result) ⇒ `Promise.&lt;void&gt;`
49+
Handle contract call error
4950

5051
**Kind**: Exported function
5152
**Category**: async
53+
**Throws**:
54+
55+
- Error Decoded error
56+
5257

5358
| Param | Type | Description |
5459
| --- | --- | --- |
55-
| code | `String` | Contract source code or Contract address |
56-
| abi | `String` | ABI('sophia', 'sophia-address') |
57-
| name | `String` | Name of function to call |
58-
| args | `String` | Argument's for call ('()') |
59-
| call | `String` | Code of `call` contract(Pseudo code with __call => {name}({args}) function) |
60+
| result | `Object` | call result object |
6061

61-
<a id="exp_module_@aeternity/aepp-sdk/es/ae/contract--callStatic"></a>
62+
<a id="exp_module_@aeternity/aepp-sdk/es/ae/contract--encodeCall"></a>
6263

63-
### callStatic(address, abi, name, options, top, args, call, options) ⇒ `Promise.&lt;Object&gt;`
64-
Static contract call(using dry-run)
64+
### encodeCall(source, name, args) ⇒ `Promise.&lt;String&gt;`
65+
Encode call data for contract call
6566

6667
**Kind**: Exported function
67-
**Returns**: `Promise.&lt;Object&gt;` - Result object
6868
**Category**: async
6969

70-
| Param | Type | Default | Description |
71-
| --- | --- | --- | --- |
72-
| address | `String` | | Contract address |
73-
| abi | `String` | <code>sophia-address</code> | ABI('sophia', 'sophia-address') |
74-
| name | `String` | | Name of function to call |
75-
| options | `Object` | | [options={}] Options |
76-
| top | `String` | | [options.top] Block hash ob which you want to call contract |
77-
| args | `String` | | [options.args] Argument's for call function |
78-
| call | `String` | | [options.call] Code of `call` contract(Pseudo code with __call => {name}({args}) function) |
79-
| options | `String` | | [options.options] Transaction options (fee, ttl, gas, amount, deposit) |
70+
| Param | Type | Description |
71+
| --- | --- | --- |
72+
| source | `String` | Contract source code |
73+
| name | `String` | Name of function to call |
74+
| args | `Array` | Argument's for call |
8075

8176
<a id="exp_module_@aeternity/aepp-sdk/es/ae/contract--decode"></a>
8277

@@ -92,46 +87,61 @@ Decode contract call result data
9287
| type | `String` | Data type (int, string, list,...) |
9388
| data | `String` | call result data (cb_iwer89fjsdf2j93fjews_(ssdffsdfsdf...) |
9489

90+
<a id="exp_module_@aeternity/aepp-sdk/es/ae/contract--callStatic"></a>
91+
92+
### callStatic(source, address, name, args, options, top, options) ⇒ `Promise.&lt;Object&gt;`
93+
Static contract call(using dry-run)
94+
95+
**Kind**: Exported function
96+
**Returns**: `Promise.&lt;Object&gt;` - Result object
97+
**Category**: async
98+
99+
| Param | Type | Description |
100+
| --- | --- | --- |
101+
| source | `String` | Contract source code |
102+
| address | `String` | Contract address |
103+
| name | `String` | Name of function to call |
104+
| args | `Array` | Argument's for call function |
105+
| options | `Object` | [options={}] Options |
106+
| top | `String` | [options.top] Block hash on which you want to call contract |
107+
| options | `String` | [options.options] Transaction options (fee, ttl, gas, amount, deposit) |
108+
95109
<a id="exp_module_@aeternity/aepp-sdk/es/ae/contract--call"></a>
96110

97-
### call(code, abi, address, name, [options]) ⇒ `Promise.&lt;Object&gt;`
111+
### call(source, address, name, args, options) ⇒ `Promise.&lt;Object&gt;`
98112
Call contract function
99113

100114
**Kind**: Exported function
101115
**Returns**: `Promise.&lt;Object&gt;` - Result object
102116
**Category**: async
103117

104-
| Param | Type | Default | Description |
105-
| --- | --- | --- | --- |
106-
| code | `String` | | Contract source code |
107-
| abi | `String` | | ABI('sophia', 'sophia-address') |
108-
| address | `String` | | Contract address |
109-
| name | `String` | | Name of function to call |
110-
| [options] | `Object` | <code>{}</code> | options Options |
111-
| [options.args] | `String` | | args Argument's for call function |
112-
| [options.call] | `String` | | call Code of `call` contract(Pseudo code with __call => {name}({args}) function) |
113-
| [options.options] | `String` | | options Transaction options (fee, ttl, gas, amount, deposit) |
118+
| Param | Type | Description |
119+
| --- | --- | --- |
120+
| source | `String` | Contract source code |
121+
| address | `String` | Contract address |
122+
| name | `String` | Name of function to call |
123+
| args | `Array` | Argument's for call function |
124+
| options | `Object` | Transaction options (fee, ttl, gas, amount, deposit) |
114125

115126
<a id="exp_module_@aeternity/aepp-sdk/es/ae/contract--deploy"></a>
116127

117-
### deploy(code, abi, [options]) ⇒ `Promise.&lt;Object&gt;`
128+
### deploy(code, source, initState, options) ⇒ `Promise.&lt;Object&gt;`
118129
Deploy contract to the node
119130

120131
**Kind**: Exported function
121132
**Returns**: `Promise.&lt;Object&gt;` - Result object
122133
**Category**: async
123134

124-
| Param | Type | Default | Description |
125-
| --- | --- | --- | --- |
126-
| code | `String` | | Contract source code |
127-
| abi | `String` | | ABI('sophia', 'sophia-address') |
128-
| [options] | `Object` | <code>{}</code> | options Options |
129-
| [options.initState] | `String` | | initState Argument's for contract init function |
130-
| [options.options] | `String` | | options Transaction options (fee, ttl, gas, amount, deposit) |
135+
| Param | Type | Description |
136+
| --- | --- | --- |
137+
| code | `String` | Compiled contract |
138+
| source | `String` | Contract source code |
139+
| initState | `Array` | Arguments of contract constructor(init) function |
140+
| options | `Object` | Transaction options (fee, ttl, gas, amount, deposit) |
131141

132142
<a id="exp_module_@aeternity/aepp-sdk/es/ae/contract--compile"></a>
133143

134-
### compile(code, options) ⇒ `Promise.&lt;Object&gt;`
144+
### compile(source, options) ⇒ `Promise.&lt;Object&gt;`
135145
Compile contract source code
136146

137147
**Kind**: Exported function
@@ -140,6 +150,6 @@ Compile contract source code
140150

141151
| Param | Type | Description |
142152
| --- | --- | --- |
143-
| code | `String` | Contract code |
153+
| source | `String` | Contract sourece code |
144154
| options | `Object` | Transaction options (fee, ttl, gas, amount, deposit) |
145155

docs/api/chain.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import Chain from '@aeternity/aepp-sdk/es/chain'
2626
* *[.getMicroBlockTransactions()](#module_@aeternity/aepp-sdk/es/chain--Chain+getMicroBlockTransactions)`Array.&lt;Object&gt;`*
2727
* *[.getKeyBlock()](#module_@aeternity/aepp-sdk/es/chain--Chain+getKeyBlock)`Object`*
2828
* *[.getMicroBlockHeader()](#module_@aeternity/aepp-sdk/es/chain--Chain+getMicroBlockHeader)`Object`*
29+
* *[.getAccount(address, [options])](#module_@aeternity/aepp-sdk/es/chain--Chain+getAccount)`Object`*
2930
* *[.txDryRun(txs, accounts, hashOrHeight)](#module_@aeternity/aepp-sdk/es/chain--Chain+txDryRun)`Object`*
3031
* _static_
3132
* [.waitMined(bool)](#module_@aeternity/aepp-sdk/es/chain--Chain.waitMined)`Stamp`
@@ -208,6 +209,23 @@ Get micro block header
208209
**Returns**: `Object` - Micro block header
209210
**Category**: async
210211
**rtype**: `(hash) => header: Object`
212+
<a id="module_@aeternity/aepp-sdk/es/chain--Chain+getAccount"></a>
213+
214+
#### *chain.getAccount(address, [options]) ⇒ `Object`*
215+
Get account by account public key
216+
217+
**Kind**: instance abstract method of [`Chain`](#exp_module_@aeternity/aepp-sdk/es/chain--Chain)
218+
**Returns**: `Object` - Account
219+
**Category**: async
220+
**rtype**: `(address, { hash, height }) => account: Object`
221+
222+
| Param | Type | Default | Description |
223+
| --- | --- | --- | --- |
224+
| address | `String` | | Account public key |
225+
| [options] | `Object` | <code>{}</code> | Options |
226+
| [options.height] | `Number` | | Get account on specific block by block height |
227+
| [options.hash] | `String` | | Get account on specific block by block hash |
228+
211229
<a id="module_@aeternity/aepp-sdk/es/chain--Chain+txDryRun"></a>
212230

213231
#### *chain.txDryRun(txs, accounts, hashOrHeight) ⇒ `Object`*

0 commit comments

Comments
 (0)