Skip to content

Commit b70c79f

Browse files
authored
Merge pull request #888 from aeternity/release/7.0.0
Release 7.0.0
2 parents 1a963d1 + 8f39b7e commit b70c79f

File tree

33 files changed

+14130
-132
lines changed

33 files changed

+14130
-132
lines changed

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
# [7.0.0](https://github.com/aeternity/aepp-sdk-js/compare/6.0.1...7.0.0) (2020-01-31)
2+
3+
4+
### Bug Fixes
5+
6+
* **AEX-2:** Fix firefox compatibility issue ([#882](https://github.com/aeternity/aepp-sdk-js/issues/882)) ([2e16e10](https://github.com/aeternity/aepp-sdk-js/commit/2e16e10))
7+
8+
9+
### Features
10+
11+
* **Chain:** add new method `waitFOrTxConfirm`. Add new option { confirm: 3 } to all of high lvl SDK API. Add tests. Adjust docs ([#874](https://github.com/aeternity/aepp-sdk-js/issues/874)) ([43528f9](https://github.com/aeternity/aepp-sdk-js/commit/43528f9))
12+
* **Compiler:** Add new compiler methods API ([#875](https://github.com/aeternity/aepp-sdk-js/issues/875)) ([a939395](https://github.com/aeternity/aepp-sdk-js/commit/a939395))
13+
* **network:** Throw error when can not get networkId ([#863](https://github.com/aeternity/aepp-sdk-js/issues/863)) ([41b7bd1](https://github.com/aeternity/aepp-sdk-js/commit/41b7bd1))
14+
15+
16+
### Docs
17+
18+
* **Guide** [Add 7.0.0 migration guide](https://github.com/aeternity/aepp-sdk-js/blob/develop/docs/guides/migration/migration-7.0.0.md)
19+
* **Guide:** Add [Oracle](https://github.com/aeternity/aepp-sdk-js/blob/develop/docs/guides/oracle-usage.md), [AENS](https://github.com/aeternity/aepp-sdk-js/blob/develop/docs/guides/aens-usage.md) and [Contract](https://github.com/aeternity/aepp-sdk-js/blob/develop/docs/guides/contract-aci-usage.md) guides
20+
21+
22+
### BREAKING CHANGES
23+
24+
Please check out [7.0.0 migration guide](https://github.com/aeternity/aepp-sdk-js/blob/develop/docs/guides/migration/migration-7.0.0.md)
25+
26+
This release include all changes from [7.0.0-next.1](https://github.com/aeternity/aepp-sdk-js/releases/tag/7.0.0-next.1), [7.0.0-next.2](https://github.com/aeternity/aepp-sdk-js/releases/tag/7.0.0-next.2), [7.0.0-next.3](https://github.com/aeternity/aepp-sdk-js/releases/tag/7.0.0-next.3)
27+
28+
29+
130
# [7.0.0-next.3](https://github.com/aeternity/aepp-sdk-js/compare/6.0.1...7.0.0-next.3) (2020-01-22)
231

332

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ You can use this URL with any releasee on [npmjs](https://www.npmjs.com/package/
4848
### Contract Usage
4949
- [Contract ACI](guides/contract-aci-usage.md)
5050
- [AENS usage](guides/aens-usage.md)
51+
- [AENS usage](guides/racle-usage.md)
5152

5253

5354
## Examples

docs/api/account.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import Account from '@aeternity/aepp-sdk/es/account'
1010

1111
* [@aeternity/aepp-sdk/es/account](#module_@aeternity/aepp-sdk/es/account)
1212
* [Account([options])](#exp_module_@aeternity/aepp-sdk/es/account--Account)`Object`
13-
* [.signTransaction(tx, opt)](#module_@aeternity/aepp-sdk/es/account--Account+signTransaction)`String`
1413
* [.getNetworkId()](#module_@aeternity/aepp-sdk/es/account--Account+getNetworkId)`String`
1514
* *[.sign(data)](#module_@aeternity/aepp-sdk/es/account--Account+sign)`String`*
1615
* *[.address()](#module_@aeternity/aepp-sdk/es/account--Account+address)`String`*
@@ -36,21 +35,6 @@ signing key pair.
3635
| [options] | `Object` | <code>{}</code> | Initializer object |
3736
| options.networkId | `String` | | NETWORK_ID using for signing transaction's |
3837

39-
<a id="module_@aeternity/aepp-sdk/es/account--Account+signTransaction"></a>
40-
41-
#### account.signTransaction(tx, opt) ⇒ `String`
42-
Sign encoded transaction
43-
44-
**Kind**: instance method of [`Account`](#exp_module_@aeternity/aepp-sdk/es/account--Account)
45-
**Returns**: `String` - Signed transaction
46-
**Category**: async
47-
**rtype**: `(tx: String) => tx: Promise[String], throws: Error`
48-
49-
| Param | Type | Description |
50-
| --- | --- | --- |
51-
| tx | `String` | Transaction to sign |
52-
| opt | `Object` | Options |
53-
5438
<a id="module_@aeternity/aepp-sdk/es/account--Account+getNetworkId"></a>
5539

5640
#### account.getNetworkId() ⇒ `String`

docs/api/chain.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import Chain from '@aeternity/aepp-sdk/es/chain'
2121
* *[.mempool()](#module_@aeternity/aepp-sdk/es/chain+mempool)`Array.&lt;Object&gt;`*
2222
* *[.getCurrentGeneration()](#module_@aeternity/aepp-sdk/es/chain+getCurrentGeneration)`Object`*
2323
* *[.getGeneration(hashOrHeight)](#module_@aeternity/aepp-sdk/es/chain+getGeneration)`Object`*
24+
* *[.waitForTxConfirm(txHash, [options])](#module_@aeternity/aepp-sdk/es/chain+waitForTxConfirm)`Promise.&lt;Number&gt;`*
2425
* *[.getMicroBlockTransactions()](#module_@aeternity/aepp-sdk/es/chain+getMicroBlockTransactions)`Array.&lt;Object&gt;`*
2526
* *[.getKeyBlock()](#module_@aeternity/aepp-sdk/es/chain+getKeyBlock)`Object`*
2627
* *[.getMicroBlockHeader()](#module_@aeternity/aepp-sdk/es/chain+getMicroBlockHeader)`Object`*
@@ -165,6 +166,22 @@ Get generation by hash or height
165166
| --- | --- | --- |
166167
| hashOrHeight | `String` \| `Number` | Generation hash or height |
167168

169+
<a id="module_@aeternity/aepp-sdk/es/chain+waitForTxConfirm"></a>
170+
171+
### *@aeternity/aepp-sdk/es/chain.waitForTxConfirm(txHash, [options]) ⇒ `Promise.&lt;Number&gt;`*
172+
Wait for transaction confirmation
173+
174+
**Kind**: instance abstract method of [`@aeternity/aepp-sdk/es/chain`](#module_@aeternity/aepp-sdk/es/chain)
175+
**Returns**: `Promise.&lt;Number&gt;` - Current Height
176+
**Category**: async
177+
**rtype**: `(txHash: String, { confirm: Number | Boolean } = { confirm: 3 }) => Promise<Number>`
178+
179+
| Param | Type | Default | Description |
180+
| --- | --- | --- | --- |
181+
| txHash | `String` | | Generation hash or height |
182+
| [options] | `String` | <code>{}</code> | options |
183+
| [options.confirm] | `String` | <code>3</code> | Block confirmation count |
184+
168185
<a id="module_@aeternity/aepp-sdk/es/chain+getMicroBlockTransactions"></a>
169186

170187
### *@aeternity/aepp-sdk/es/chain.getMicroBlockTransactions() ⇒ `Array.&lt;Object&gt;`*

docs/api/utils/aepp-wallet-communication/rpc/aepp-rpc.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import ContentScriptBridge from '@aeternity/aepp-sdk/es/utils/aepp-wallet-commun
1111
* [@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/aepp-rpc](#module_@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/aepp-rpc)
1212
* [exports.AeppRpc(param, onAddressChange, onDisconnect, onNetworkChange, connection)](#exp_module_@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/aepp-rpc--exports.AeppRpc)`Object`
1313
* [.connectToWallet(connection)](#module_@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/aepp-rpc--exports.AeppRpc+connectToWallet)`void`
14-
* [.disconnectWallet(force)](#module_@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/aepp-rpc--exports.AeppRpc+disconnectWallet)`void`
14+
* [.disconnectWallet(sendDisconnect)](#module_@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/aepp-rpc--exports.AeppRpc+disconnectWallet)`void`
1515
* [.askAddresses()](#module_@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/aepp-rpc--exports.AeppRpc+askAddresses)`Promise`
1616
* [.subscribeAddress(type, value)](#module_@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/aepp-rpc--exports.AeppRpc+subscribeAddress)`Promise`
1717
* [.signTransaction()](#module_@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/aepp-rpc--exports.AeppRpc+signTransaction)`Promise.&lt;String&gt;`
@@ -49,15 +49,15 @@ Connect to wallet
4949

5050
<a id="module_@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/aepp-rpc--exports.AeppRpc+disconnectWallet"></a>
5151

52-
#### exports.AeppRpc.disconnectWallet(force) ⇒ `void`
52+
#### exports.AeppRpc.disconnectWallet(sendDisconnect) ⇒ `void`
5353
Disconnect from wallet
5454

5555
**Kind**: instance method of [`exports.AeppRpc`](#exp_module_@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/aepp-rpc--exports.AeppRpc)
5656
**rtype**: `(force: Boolean = false) => void`
5757

5858
| Param | Type | Default | Description |
5959
| --- | --- | --- | --- |
60-
| force | `Boolean` | <code>false</code> | Force sending close connection message |
60+
| sendDisconnect | `Boolean` | <code>false</code> | Force sending close connection message |
6161

6262
<a id="module_@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/aepp-rpc--exports.AeppRpc+askAddresses"></a>
6363

docs/guides/low-vs-high-usage.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,24 @@ Example spend function, using aeternity's SDK abstraction
4343
Example spend function, using the SDK, talking directly to the [**API**](https://github.com/aeternity/protocol/tree/master/node/api):
4444
```js
4545
// Import necessary Modules
46-
import Tx from '@aeternity/aepp-sdk/es/tx/tx.js'
47-
import Chain from '@aeternity/aepp-sdk/es/chain/node.js'
48-
import Account from '@aeternity/aepp-sdk/es/account/memory.js'
49-
import Node from '@aeternity/aepp-sdk/es/node' // import from SDK es-modules
46+
import Universal from '@aeternity/aepp-sdk/es/ae/universal'
47+
import Node from '@aeternity/aepp-sdk/es/node'
48+
import MemoryAccount from '@aeternity/aepp-sdk/es/account/memory'
5049

5150
async function spend (amount, receiver_pub_key) {
5251
const node = await Node({ url, internalUrl })
5352
const nodes = [{ name: 'testnet-node', instance: node }]
53+
const account = MemoryAccount({ keypair: { secretKey: 'PRIV_KEY_HERE', publicKey: 'PUB_KEY_HERE'} })
54+
55+
const sdkInstance = await Universal({
56+
nodes,
57+
accounts: [account]
58+
})
5459

55-
const tx = await Tx({ nodes })
56-
const chain = await Chain({ nodes })
57-
const account = Account({keypair: {secretKey: 'PRIV_KEY_HERE', publicKey: 'PUB_KEY_HERE'}, networkId: 'NETWORK_ID_HERE'})
58-
const spendTx = await tx.spendTx({ sender: 'PUB_KEY_HERE', receiver_pub_key, amount })
60+
const spendTx = await sdkInstance.spendTx({ sender: await sdkInstance.address(), receiver_pub_key, amount })
5961

60-
const signed = await account.signTransaction(spendTx)
61-
return chain.sendTransaction(signed, opt)
62+
const signed = await sdkInstance.signTransaction(spendTx)
63+
return sdkInstance.sendTransaction(signed, opt)
6264

6365
}
6466
```
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Migration to SDK 7.0.0
2+
This guide describes the process of migrating to SDK version 7.0.0
3+
4+
## Step 1
5+
SDK will not accept `url`, `internalUrl` init arguments anymore:
6+
#### Before
7+
```js
8+
Universal({
9+
url,
10+
internalUrl
11+
})
12+
```
13+
#### After
14+
```js
15+
const nodeInstance = await Node({ url, internalUrl })
16+
Universal({
17+
nodes: [{ name: 'testnet', instance: nodeInstance }]
18+
})
19+
```
20+
21+
## Step 2
22+
Remove deprecated function `setKeypair`
23+
`SDK` will not accept `keypair` init argument anymore:
24+
#### Before
25+
```js
26+
Universal({ keypair })
27+
```
28+
#### After
29+
```js
30+
Universal({
31+
accounts: [MemoryAccount({ keypair })]
32+
})
33+
```
34+
35+
## Step 3
36+
Change all of `AENS` method's first argument from `nameId` to `name`
37+
### Before
38+
```js
39+
const client = Universal({ ... })
40+
41+
await client.aensUpdate('cm_ad1wdsa...', ...)
42+
await client.aensTransfer('cm_ad1wdsa...', ...)
43+
await client.aensRevoke('cm_ad1wdsa...', ...)
44+
```
45+
### After
46+
```js
47+
const client = Universal({ ... })
48+
49+
await client.aensUpdate('testname.chain', ...)
50+
await client.aensTransfer('testname.chain', ...)
51+
await client.aensRevoke('testname.chain', ...)
52+
```
53+
54+
## Other Breaking Changes
55+
- Add new compiler `methods` to RPC `communication` (base-app update required)
56+
- Drop compiler version to `version >= 4.0.0 && version < 5.0.0`
57+
- Change node compatibility range to `node >= 5.0.0 && node < 6.0.0`
58+
- Always `verify` transactions before sending them to the node (can be disabled using the option `verify: false`)

docs/guides/oracle-usage.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Oracle Usage
2+
3+
This guide describes the basic operations on [Oracle](https://github.com/aeternity/protocol/blob/master/oracles/oracles.md) using [Aeternity JS SDK](https://github.com/aeternity/aepp-sdk-js)
4+
5+
## Main Flow
6+
7+
- `Register` an `oracle` (prepare and broadcast `oracle-register`)
8+
```js
9+
const sdkInstance = await Universal({ ... }) // Init Universal instance
10+
11+
// First argument is oracle query format and second oracle query response format
12+
// queryFee is optional and default to 30000
13+
// oracleTll is optional and default to { type: 'delta', value: 500 }
14+
const oracle = await client.registerOracle("{'city': str}", "{'tmp': num}", { queryFee, oracleTtl })
15+
```
16+
17+
- Extend oracle (prepare and broadcast `oracle-extend` transaction)
18+
```js
19+
const ttlToExtend = { type: 'delta', value: 500 }
20+
const oracle = await sdkInstance.getOracleObject(oracleId)
21+
22+
// extend oracle ttl to 500 blocks
23+
const oracleEntended = await oracle.extendOracle(ttlToExtend)
24+
// or
25+
const oracleEntended = await sdkInstance.extendOracleTtl(oracleId, ttlToExtend, options)
26+
```
27+
28+
- Post query to oracle (prepare and broadcast `oracle-query` transaction)
29+
```js
30+
// queryFee is optional and default to 30000
31+
// queryTtl is optional and default to { type: 'delta', value: 10 }
32+
// responseTtl is optional and default to { type: 'delta', value: 10 }
33+
const options = { fee, ttl, nonce, queryFee, queryTtl, responseTtl }
34+
// Get oracle object
35+
const oracle = await sdkInstance.getOracleObject(oracleId)
36+
37+
const query = await oracle.postQuery("{'city': 'Berlin'}", options)
38+
// or
39+
const query = await sdkInstance.postQueryToOracle(oracleId, "{'city': 'Berlin'}", options)
40+
```
41+
42+
- Poll for queries
43+
```js
44+
const stopPolling = await oracle.pollQueries(
45+
(queries) => {
46+
console.log(queries) // log all new queries
47+
},
48+
{ interval: 1000 } // poll every second
49+
)
50+
```
51+
- Poll for query response
52+
```js
53+
const query = await sdkInstance.getQueryObject(oracleId, queryId)
54+
55+
// Poll for query reponse
56+
const response = await query.pollForResponse({ attempts: 2, interval: 1000 })
57+
// or
58+
const response = await sdkInstance.pollForQueryResponse(oracleId, queryId, { attempts: 2, interval: 1000 })
59+
// decode query response
60+
console.log(query.decode())
61+
```
62+
- Respond to query (prepare and broadcast `oracle-responde` transaction)
63+
```js
64+
const options = { ttl, fee, nonce, onAccount }
65+
const query = await sdkInstance.getQueryObject(oracleId, queryId)
66+
67+
await query.respond({ tmp: 10 }, options)
68+
// or
69+
await sdkInstance.respondToQuery(oracleId, queryId, { tmp: 10 }, options)
70+
```
71+
72+
## Related links
73+
- [Oracle protocol](https://github.com/aeternity/protocol/blob/master/oracles)
74+
- [Oracle SDK API Docs](https://github.com/aeternity/aepp-sdk-js/blob/develop/docs/api/ae/oracle.md)
75+

es/account/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ import * as Crypto from '../utils/crypto'
2828
import { buildTx } from '../tx/builder'
2929
import { TX_TYPE } from '../tx/builder/schema'
3030

31-
const DEFAULT_NETWORK_ID = 'ae_mainnet'
32-
3331
/**
3432
* Sign encoded transaction
3533
* @instance
@@ -57,7 +55,8 @@ async function signTransaction (tx, opt = {}) {
5755
* @return {String} NetworkId
5856
*/
5957
function getNetworkId () {
60-
return this.networkId || (this.selectedNode ? this.selectedNode.networkId : false) || DEFAULT_NETWORK_ID
58+
if (!this.networkId && !this.selectedNode.networkId) throw new Error('networkId is not provided')
59+
return this.networkId || this.selectedNode.networkId
6160
}
6261

6362
/**

es/ae/aepp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ import GeneralizeAccount from '../contract/ga'
4545
* @return {Object} Aepp instance
4646
*/
4747
export const Aepp = Ae.compose(ContractAPI, Aens, Oracle, GeneralizeAccount, Rpc)
48-
export const RpcAepp = Ae.compose(Chain, Tx, Oracle, Contract, Aens, AeppRpc)
48+
export const RpcAepp = Ae.compose(Tx, Oracle, Contract, Aens, Chain, AeppRpc)
4949
export default Aepp

0 commit comments

Comments
 (0)