From fb06741366ef5cc166901679431500acee7850f7 Mon Sep 17 00:00:00 2001 From: naz_dou Date: Fri, 4 Oct 2019 15:55:05 +0300 Subject: [PATCH 1/6] chrome(Release): Bump version 5.0.0. Regenerate docs --- docs/api/account.md | 1 - docs/api/account/memory.md | 1 - docs/api/account/selector.md | 1 - docs/api/accounts.md | 1 - docs/api/ae.md | 29 ++++++++++++++++++++++------- docs/api/ae/aens.md | 20 +++++++++++++++++++- docs/api/ae/aepp.md | 1 - docs/api/ae/contract.md | 3 ++- docs/api/ae/oracle.md | 18 +++++++++++++++++- docs/api/ae/universal.md | 1 - docs/api/chain.md | 1 - docs/api/chain/node.md | 1 - docs/api/channel/index.md | 1 - docs/api/contract/aci.md | 1 - docs/api/contract/compiler.md | 1 - docs/api/contract/ga.md | 2 +- docs/api/node.md | 1 - docs/api/oracle.md | 1 - docs/api/oracle/node.md | 1 - docs/api/rpc/client.md | 1 - docs/api/tx.md | 1 - docs/api/tx/builder.md | 1 - docs/api/tx/builder/helpers.md | 1 - docs/api/tx/builder/schema.md | 1 - docs/api/tx/tx.md | 1 - docs/api/tx/validator.md | 1 - docs/api/utils/swagger.md | 16 +++++++++++++++- docs/examples/node/aecrypto.md | 17 ++++++++++++++++- package.json | 2 +- 29 files changed, 93 insertions(+), 35 deletions(-) diff --git a/docs/api/account.md b/docs/api/account.md index 78052f2148..29738947e9 100644 --- a/docs/api/account.md +++ b/docs/api/account.md @@ -3,7 +3,6 @@ ## @aeternity/aepp-sdk/es/account Account module -**Export**: Account **Example** ```js import Account from '@aeternity/aepp-sdk/es/account' diff --git a/docs/api/account/memory.md b/docs/api/account/memory.md index 264ce55716..2e3fa0cd1f 100644 --- a/docs/api/account/memory.md +++ b/docs/api/account/memory.md @@ -3,7 +3,6 @@ ## @aeternity/aepp-sdk/es/account/memory Memory Account module -**Export**: MemoryAccount **Example** ```js import MemoryAccount from '@aeternity/aepp-sdk/es/account/memory' diff --git a/docs/api/account/selector.md b/docs/api/account/selector.md index a270959d7f..316ccc2ac6 100644 --- a/docs/api/account/selector.md +++ b/docs/api/account/selector.md @@ -5,7 +5,6 @@ Accounts Selector module This is the complement to [@aeternity/aepp-sdk/es/accounts](#module_@aeternity/aepp-sdk/es/accounts). -**Export**: Selector **Example** ```js import Selector from '@aeternity/aepp-sdk/es/account/selector' diff --git a/docs/api/accounts.md b/docs/api/accounts.md index f507246bed..88bb506b60 100644 --- a/docs/api/accounts.md +++ b/docs/api/accounts.md @@ -3,7 +3,6 @@ ## @aeternity/aepp-sdk/es/accounts Accounts module -**Export**: Accounts **Example** ```js import Accounts from '@aeternity/aepp-sdk/es/accounts' diff --git a/docs/api/ae.md b/docs/api/ae.md index 5e79fc6f81..41686321d7 100644 --- a/docs/api/ae.md +++ b/docs/api/ae.md @@ -3,7 +3,6 @@ ## @aeternity/aepp-sdk/es/ae Ae module -**Export**: Ae **Example** ```js import Ae from '@aeternity/aepp-sdk/es/ae' @@ -11,11 +10,14 @@ import Ae from '@aeternity/aepp-sdk/es/ae' * [@aeternity/aepp-sdk/es/ae](#module_@aeternity/aepp-sdk/es/ae) * [Ae([options])](#exp_module_@aeternity/aepp-sdk/es/ae--Ae) ⇒ `Object` ⏏ - * [.destroyInstance()](#module_@aeternity/aepp-sdk/es/ae--Ae+destroyInstance) ⇒ `void` - * _async_ - * [.send(tx, [options])](#module_@aeternity/aepp-sdk/es/ae--Ae+send) ⇒ `String` \| `String` - * [.spend(amount, recipientId, options)](#module_@aeternity/aepp-sdk/es/ae--Ae+spend) ⇒ `String` \| `String` - * [.transferFunds(percentage, recipientId, options)](#module_@aeternity/aepp-sdk/es/ae--Ae+transferFunds) ⇒ `String` \| `String` + * _instance_ + * [.destroyInstance()](#module_@aeternity/aepp-sdk/es/ae--Ae+destroyInstance) ⇒ `void` + * _async_ + * [.send(tx, [options])](#module_@aeternity/aepp-sdk/es/ae--Ae+send) ⇒ `String` \| `String` + * [.spend(amount, recipientId, options)](#module_@aeternity/aepp-sdk/es/ae--Ae+spend) ⇒ `String` \| `String` + * [.transferFunds(percentage, recipientId, options)](#module_@aeternity/aepp-sdk/es/ae--Ae+transferFunds) ⇒ `String` \| `String` + * _inner_ + * [~resolveRecipientName(nameOrAddress, verify)](#module_@aeternity/aepp-sdk/es/ae--Ae..resolveRecipientName) ⇒ `String` @@ -76,7 +78,7 @@ Send tokens to another account | Param | Type | Description | | --- | --- | --- | | amount | `Number` \| `String` | Amount to spend | -| recipientId | `String` | Address of recipient account | +| recipientId | `String` | Address or Name of recipient account | | options | `Object` | Options | @@ -95,3 +97,16 @@ Send a percentage of funds to another account | recipientId | `String` | Address of recipient account | | options | `Object` | Options | + + +#### Ae~resolveRecipientName(nameOrAddress, verify) ⇒ `String` +Resolve AENS name and return name hash + +**Kind**: inner method of [`Ae`](#exp_module_@aeternity/aepp-sdk/es/ae--Ae) +**Returns**: `String` - Address or AENS name hash + +| Param | Type | +| --- | --- | +| nameOrAddress | `String` | +| verify | | + diff --git a/docs/api/ae/aens.md b/docs/api/ae/aens.md index cf7dd0aac9..3190ef29c5 100644 --- a/docs/api/ae/aens.md +++ b/docs/api/ae/aens.md @@ -7,7 +7,6 @@ The high-level description of the naming system is https://github.com/aeternity/protocol/blob/master/AENS.md in the protocol repository. -**Export**: Aens **Example** ```js import Aens from '@aeternity/aepp-sdk/es/ae/aens' @@ -15,6 +14,8 @@ import Aens from '@aeternity/aepp-sdk/es/ae/aens' * [@aeternity/aepp-sdk/es/ae/aens](#module_@aeternity/aepp-sdk/es/ae/aens) * [Aens([options])](#exp_module_@aeternity/aepp-sdk/es/ae/aens--Aens) ⇒ `Object` ⏏ + * _global_ + * [exports.isNameValid(name, [throwError])](#exp_module_@aeternity/aepp-sdk/es/ae/aens--exports.isNameValid) ⇒ ⏏ * _instance_ * [.update(nameId, target, options)](#exp_module_@aeternity/aepp-sdk/es/ae/aens--update) ⇒ `Object` ⏏ * [.query(name)](#exp_module_@aeternity/aepp-sdk/es/ae/aens--query) ⇒ `Promise.<Object>` ⏏ @@ -40,6 +41,23 @@ Aens provides name-system related methods atop | --- | --- | --- | --- | | [options] | `Object` | {} | Initializer object | + + +### exports.isNameValid(name, [throwError]) ⇒ ⏏ +Is name valid + +**Kind**: global method of [`@aeternity/aepp-sdk/es/ae/aens`](#module_@aeternity/aepp-sdk/es/ae/aens) +**Returns**: Boolean +**Throws**: + +- Error + + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| name | `string` | | | +| [throwError] | `boolean` | true | Throw error on invalid | + ### .update(nameId, target, options) ⇒ `Object` ⏏ diff --git a/docs/api/ae/aepp.md b/docs/api/ae/aepp.md index b39d6cd4a0..16f59e8f6e 100644 --- a/docs/api/ae/aepp.md +++ b/docs/api/ae/aepp.md @@ -3,7 +3,6 @@ ## @aeternity/aepp-sdk/es/ae/aepp Aepp module -**Export**: Aepp **Example** ```js import Ae from '@aeternity/aepp-sdk/es/ae/aepp' diff --git a/docs/api/ae/contract.md b/docs/api/ae/contract.md index 21de19f06e..8292ecb9e7 100644 --- a/docs/api/ae/contract.md +++ b/docs/api/ae/contract.md @@ -6,7 +6,6 @@ Contract module - routines to interact with the æternity contract High level documentation of the contracts are available at https://github.com/aeternity/protocol/tree/master/contracts and -**Export**: Contract **Example** ```js import Contract from '@aeternity/aepp-sdk/es/ae/contract' (Using tree-shaking) @@ -93,6 +92,7 @@ Encode call data for contract call | args | `Array` | | Argument's for call | | [options] | `Object` | {} | Options | | [options.filesystem] | `Object` | {} | Contract external namespaces map | +| [options.backend] | `Object` | 'fate' | Compiler backend | @@ -215,6 +215,7 @@ Compile contract source code | source | `String` | | Contract sourece code | | [options] | `Object` | {} | Transaction options (fee, ttl, gas, amount, deposit) | | [options.filesystem] | `Object` | {} | Contract external namespaces map* @return {Promise} Result object | +| [options.backend] | `Object` | 'aevm' | Contract backend version (aevm|fate) | **Example** ```js diff --git a/docs/api/ae/oracle.md b/docs/api/ae/oracle.md index a93dffd1d6..ab523b7c27 100644 --- a/docs/api/ae/oracle.md +++ b/docs/api/ae/oracle.md @@ -7,7 +7,6 @@ The high-level description of the oracle system is https://github.com/aeternity/protocol/blob/master/ORACLE.md in the protocol repository. -**Export**: Oracle **Example** ```js import Oracle from '@aeternity/aepp-sdk/es/ae/oracle' @@ -18,6 +17,7 @@ import Oracle from '@aeternity/aepp-sdk/es/ae/oracle' * _instance_ * _async_ * [.getOracleObject(oracleId)](#exp_module_@aeternity/aepp-sdk/es/ae/oracle--getOracleObject) ⇒ `Promise.<Object>` ⏏ + * [.exports.pollForQueries(oracleId, onQuery, [options])](#exp_module_@aeternity/aepp-sdk/es/ae/oracle--exports.pollForQueries) ⇒ `function` ⏏ * [.getQueryObject(oracleId, queryId)](#exp_module_@aeternity/aepp-sdk/es/ae/oracle--getQueryObject) ⇒ `Promise.<Object>` ⏏ * [.exports.pollForQueryResponse(oracleId, queryId, [options])](#exp_module_@aeternity/aepp-sdk/es/ae/oracle--exports.pollForQueryResponse) ⇒ `Promise.<Object>` ⏏ * [.registerOracle(queryFormat, responseFormat, [options])](#exp_module_@aeternity/aepp-sdk/es/ae/oracle--registerOracle) ⇒ `Promise.<Object>` ⏏ @@ -54,6 +54,22 @@ Constructor for Oracle Object (helper object for using Oracle) | --- | --- | --- | | oracleId | `String` | Oracle public key | + + +### .exports.pollForQueries(oracleId, onQuery, [options]) ⇒ `function` ⏏ +Poll for oracle queries + +**Kind**: instance method of [`@aeternity/aepp-sdk/es/ae/oracle`](#module_@aeternity/aepp-sdk/es/ae/oracle) +**Returns**: `function` - stopPolling - Stop polling function +**Category**: async + +| Param | Type | Description | +| --- | --- | --- | +| oracleId | `String` | Oracle public key | +| onQuery | `function` | OnQuery callback | +| [options] | `Object` | Options object | +| [options.interval] | `Object` | Poll interval(default: 5000) | + ### .getQueryObject(oracleId, queryId) ⇒ `Promise.<Object>` ⏏ diff --git a/docs/api/ae/universal.md b/docs/api/ae/universal.md index c3578edde1..19c73c33e7 100644 --- a/docs/api/ae/universal.md +++ b/docs/api/ae/universal.md @@ -3,7 +3,6 @@ ## @aeternity/aepp-sdk/es/ae/universal Universal module -**Export**: Universal **Example** ```js import Ae from '@aeternity/aepp-sdk/es/ae/universal' diff --git a/docs/api/chain.md b/docs/api/chain.md index 8d9f6b1292..c23ebad674 100644 --- a/docs/api/chain.md +++ b/docs/api/chain.md @@ -3,7 +3,6 @@ ## @aeternity/aepp-sdk/es/chain Chain module -**Export**: Chain **Example** ```js import Chain from '@aeternity/aepp-sdk/es/chain' diff --git a/docs/api/chain/node.md b/docs/api/chain/node.md index 26a152dc3b..85f2ff8bd6 100644 --- a/docs/api/chain/node.md +++ b/docs/api/chain/node.md @@ -5,7 +5,6 @@ ChainNode module This is the complement to [@aeternity/aepp-sdk/es/chain](#module_@aeternity/aepp-sdk/es/chain). -**Export**: ChainNode **Example** ```js import ChainNode from '@aeternity/aepp-sdk/es/chain/node' diff --git a/docs/api/channel/index.md b/docs/api/channel/index.md index 432490fc16..5f900cea64 100644 --- a/docs/api/channel/index.md +++ b/docs/api/channel/index.md @@ -3,7 +3,6 @@ ## @aeternity/aepp-sdk/es/channel/index Channel module -**Export**: Channel **Example** ```js import Channel from '@aeternity/aepp-sdk/es/channel/index' diff --git a/docs/api/contract/aci.md b/docs/api/contract/aci.md index 30c93f6c17..e4cd0564f5 100644 --- a/docs/api/contract/aci.md +++ b/docs/api/contract/aci.md @@ -3,7 +3,6 @@ ## @aeternity/aepp-sdk/es/contract/aci ContractACI module -**Export**: ContractACI **Example** ```js import ContractACI from '@aeternity/aepp-sdk/es/contract/aci' diff --git a/docs/api/contract/compiler.md b/docs/api/contract/compiler.md index 6a7d209717..70105feb9c 100644 --- a/docs/api/contract/compiler.md +++ b/docs/api/contract/compiler.md @@ -5,7 +5,6 @@ ContractCompilerAPI module This is the complement to [@aeternity/aepp-sdk/es/contract](#module_@aeternity/aepp-sdk/es/contract). -**Export**: ContractCompilerAPI **Example** ```js import ContractCompilerAPI from '@aeternity/aepp-sdk/es/contract/compiler' diff --git a/docs/api/contract/ga.md b/docs/api/contract/ga.md index 4eb92f52fe..74fae2afb3 100644 --- a/docs/api/contract/ga.md +++ b/docs/api/contract/ga.md @@ -23,7 +23,7 @@ import { GeneralizeAccount } from '@aeternity/aepp-sdk' (Using bundle) GeneralizeAccount Stamp Provide Generalize Account implementation -[module:@aeternity/aepp-sdk/es/contract.ga](module:@aeternity/aepp-sdk/es/contract.ga) clients. +[@aeternity/aepp-sdk/es/contract/ga](#module_@aeternity/aepp-sdk/es/contract/ga) clients. **Kind**: Exported function **Returns**: `Object` - GeneralizeAccount instance diff --git a/docs/api/node.md b/docs/api/node.md index 4bbbdbcd40..abd0e8e37c 100644 --- a/docs/api/node.md +++ b/docs/api/node.md @@ -3,7 +3,6 @@ ## @aeternity/aepp-sdk/es/node Node module -**Export**: Node **Example** ```js import Node from '@aeternity/aepp-sdk/es/node' diff --git a/docs/api/oracle.md b/docs/api/oracle.md index fbb8ce6698..4468e5f5fd 100644 --- a/docs/api/oracle.md +++ b/docs/api/oracle.md @@ -3,7 +3,6 @@ ## @aeternity/aepp-sdk/es/oracle Oracle Base module -**Export**: Contract **Example** ```js import ContractBase from '@aeternity/aepp-sdk/es/oracle' diff --git a/docs/api/oracle/node.md b/docs/api/oracle/node.md index 7718b6f6bc..fc6d4e6c67 100644 --- a/docs/api/oracle/node.md +++ b/docs/api/oracle/node.md @@ -5,7 +5,6 @@ OracleNodeAPI module This is the complement to [@aeternity/aepp-sdk/es/oracle](#module_@aeternity/aepp-sdk/es/oracle). -**Export**: OracleNodeAPI **Example** ```js import OracleNodeAPI from '@aeternity/aepp-sdk/es/oracle/node' diff --git a/docs/api/rpc/client.md b/docs/api/rpc/client.md index 5fe8e5101c..333b2bb052 100644 --- a/docs/api/rpc/client.md +++ b/docs/api/rpc/client.md @@ -3,7 +3,6 @@ ## @aeternity/aepp-sdk/es/rpc/client RPC client module -**Export**: RpcClient **Example** ```js import RpcClient from '@aeternity/aepp-sdk/es/rpc/client' diff --git a/docs/api/tx.md b/docs/api/tx.md index d235d133ec..100bcab7bb 100644 --- a/docs/api/tx.md +++ b/docs/api/tx.md @@ -3,7 +3,6 @@ ## @aeternity/aepp-sdk/es/tx Tx module -**Export**: Tx **Example** ```js import Tx from '@aeternity/aepp-sdk/es/tx' diff --git a/docs/api/tx/builder.md b/docs/api/tx/builder.md index 33b4bbf907..631840f8d7 100644 --- a/docs/api/tx/builder.md +++ b/docs/api/tx/builder.md @@ -3,7 +3,6 @@ ## @aeternity/aepp-sdk/es/tx/builder JavaScript-based Transaction builder -**Export**: TxBuilder **Example** ```js import Transaction from '@aeternity/aepp-sdk/es/tx/builder' diff --git a/docs/api/tx/builder/helpers.md b/docs/api/tx/builder/helpers.md index 92312d6d4a..1acef0522b 100644 --- a/docs/api/tx/builder/helpers.md +++ b/docs/api/tx/builder/helpers.md @@ -3,7 +3,6 @@ ## @aeternity/aepp-sdk/es/tx/builder/helpers JavaScript-based Transaction builder helper function's -**Export**: TxBuilderHelper **Example** ```js import TxBuilderHelper from '@aeternity/aepp-sdk/es/tx/builder/helpers' diff --git a/docs/api/tx/builder/schema.md b/docs/api/tx/builder/schema.md index 982b969517..ccf1a5ddf3 100644 --- a/docs/api/tx/builder/schema.md +++ b/docs/api/tx/builder/schema.md @@ -3,7 +3,6 @@ ## @aeternity/aepp-sdk/es/tx/builder/schema Transaction Schema for TxBuilder -**Export**: TxSchema **Example** ```js import TxSchema from '@aeternity/aepp-sdk/es/tx/builder/schema' diff --git a/docs/api/tx/tx.md b/docs/api/tx/tx.md index 2268687bfe..4b1f8389c0 100644 --- a/docs/api/tx/tx.md +++ b/docs/api/tx/tx.md @@ -3,7 +3,6 @@ ## @aeternity/aepp-sdk/es/tx/tx Transaction module -**Export**: Transaction **Example** ```js import Transaction from '@aeternity/aepp-sdk/es/tx/tx' diff --git a/docs/api/tx/validator.md b/docs/api/tx/validator.md index 465dfbc75f..b131cdf75e 100644 --- a/docs/api/tx/validator.md +++ b/docs/api/tx/validator.md @@ -3,7 +3,6 @@ ## @aeternity/aepp-sdk/es/tx/validator Transaction validator -**Export**: TransactionValidator **Example** ```js import TransactionValidator from '@aeternity/aepp-sdk/es/tx/validator' diff --git a/docs/api/utils/swagger.md b/docs/api/utils/swagger.md index 706c19b18b..dbb3bc22dc 100644 --- a/docs/api/utils/swagger.md +++ b/docs/api/utils/swagger.md @@ -3,7 +3,6 @@ ## @aeternity/aepp-sdk/es/utils/swagger Swagger module -**Export**: Swagger **Example** ```js import Swagger from '@aeternity/aepp-sdk/es/utils/swagger' @@ -30,6 +29,7 @@ import Swagger from '@aeternity/aepp-sdk/es/utils/swagger' * [~pascalizeParameters(parameters)](#module_@aeternity/aepp-sdk/es/utils/swagger--Swagger..pascalizeParameters) ⇒ `Array.<Object>` * [~operationSignature(name, req, opts)](#module_@aeternity/aepp-sdk/es/utils/swagger--Swagger..operationSignature) ⇒ `String` * [~destructureClientError(error)](#module_@aeternity/aepp-sdk/es/utils/swagger--Swagger..destructureClientError) ⇒ `String` + * [~resolveRef(ref, swag)](#module_@aeternity/aepp-sdk/es/utils/swagger--Swagger..resolveRef) ⇒ `Object` @@ -277,3 +277,17 @@ Destructure HTTP client `error` | --- | --- | | error | `Error` | + + +#### Swagger~resolveRef(ref, swag) ⇒ `Object` +Resolve reference + +**Kind**: inner method of [`Swagger`](#exp_module_@aeternity/aepp-sdk/es/utils/swagger--Swagger) +**Returns**: `Object` - Resolved reference definition +**rtype**: `(ref: String, swag: Object) => Object` + +| Param | Type | Description | +| --- | --- | --- | +| ref | `String` | Reference to resolve | +| swag | `Object` | | + diff --git a/docs/examples/node/aecrypto.md b/docs/examples/node/aecrypto.md index b65d0e57bb..545f51d118 100644 --- a/docs/examples/node/aecrypto.md +++ b/docs/examples/node/aecrypto.md @@ -115,7 +115,7 @@ const promptSchema = { function extractReadableKeys (dir, options) { const pwd = options.input prompt.start() - prompt.get(promptSchema, (err, { password }) => { + prompt.get(promptSchema, (_, { password }) => { const key = fs.readFileSync(path.join(pwd, dir, 'sign_key')) const pubKey = fs.readFileSync(path.join(pwd, dir, 'sign_key.pub')) @@ -178,6 +178,21 @@ transaction and turn it into an RLP-encoded tuple ready for mining ```js function signTx (tx, privKey) { + +``` + + + + + + + +eslint-disable-next-line no-useless-escape + + + + +```js if (!tx.match(/^tx\_.+/)) { throw Error('Not a valid transaction') } diff --git a/package.json b/package.json index 95a76458e2..46ce5216d0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@aeternity/aepp-sdk", - "version": "5.0.0-next.1", + "version": "5.0.0", "description": "SDK for the æternity blockchain", "main": "dist/aepp-sdk.js", "browser": "dist/aepp-sdk.browser.js", From 30756eaf3767eef823fe033926198f72e9ea5e56 Mon Sep 17 00:00:00 2001 From: naz_dou Date: Fri, 4 Oct 2019 16:17:11 +0300 Subject: [PATCH 2/6] chrome(Release): Prepare CHANGELOG. Regenerate lock file --- CHANGELOG.md | 37 +++++++++++++++++++++++++++++++++++++ package-lock.json | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff0bc29701..bf26f71035 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,40 @@ +# [5.0.0](https://github.com/aeternity/aepp-sdk-js/compare/4.7.0...5.0.0) (2019-10-04) + + +### Bug Fixes + +* **rpc:** fix resolution rpc ops ([#669](https://github.com/aeternity/aepp-sdk-js/issues/669)) ([abd7c56](https://github.com/aeternity/aepp-sdk-js/commit/abd7c56)) + + +### Code Refactoring + +* **ACI:** rework Sophia Option type representation ([#691](https://github.com/aeternity/aepp-sdk-js/issues/691)) ([0dbb2fe](https://github.com/aeternity/aepp-sdk-js/commit/0dbb2fe)) + + +### Features + +* **AENS:** Add ability to spend by name ([#682](https://github.com/aeternity/aepp-sdk-js/issues/682)) ([0d43804](https://github.com/aeternity/aepp-sdk-js/commit/0d43804)) +* **AENS:** Add ability to claim contract, oracle, SC ([#671](https://github.com/aeternity/aepp-sdk-js/issues/671)) ([49fd0fd](https://github.com/aeternity/aepp-sdk-js/commit/49fd0fd)) +* **GA:** enbale GA ([#692](https://github.com/aeternity/aepp-sdk-js/issues/692)) ([eded912](https://github.com/aeternity/aepp-sdk-js/commit/eded912)) +* **Lima:** Lima compatibility ([#683](https://github.com/aeternity/aepp-sdk-js/issues/683)) ([a88042e](https://github.com/aeternity/aepp-sdk-js/commit/a88042e)), closes [#632](https://github.com/aeternity/aepp-sdk-js/issues/632) [#653](https://github.com/aeternity/aepp-sdk-js/issues/653) [#658](https://github.com/aeternity/aepp-sdk-js/issues/658) [#660](https://github.com/aeternity/aepp-sdk-js/issues/660) [#680](https://github.com/aeternity/aepp-sdk-js/issues/680) [#693](https://github.com/aeternity/aepp-sdk-js/issues/693) [#687](https://github.com/aeternity/aepp-sdk-js/issues/687) + - AENS auction support + - compiler 4.0.0 support + - node 5.0.0 support + - SDK use `FATE` for contract by default +* **AE**: Add pointers verification for spend by name + +### BREAKING CHANGES + +* **aci:** Change Sophia option type representation in ACI +```js +// from +await contract.methods.optionFn(Promise.resolve(1) || Promise.reject()) +// to +await contract.methods.optionFn(1 || undefined) +``` + + + # [5.0.0-next.1](https://github.com/aeternity/aepp-sdk-js/compare/4.6.0...4.7.0-next.1) (2019-09-10) diff --git a/package-lock.json b/package-lock.json index f23ed82310..910d4e1c7e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@aeternity/aepp-sdk", - "version": "5.0.0-next.1", + "version": "5.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { From f343cf7fd233bb440dfac45fde81688b2e04c0cc Mon Sep 17 00:00:00 2001 From: naz_dou Date: Wed, 9 Oct 2019 18:40:28 +0300 Subject: [PATCH 3/6] refactor(constants): Move const to shema. Improve isAddressValid. --- es/ae/aens.js | 8 +++++++- es/tx/builder/schema.js | 4 +++- es/tx/tx.js | 4 ++-- es/utils/crypto.js | 5 +++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/es/ae/aens.js b/es/ae/aens.js index 91d8ab69b5..e69310203f 100644 --- a/es/ae/aens.js +++ b/es/ae/aens.js @@ -169,6 +169,12 @@ async function query (name, opt = {}) { * @return {Promise} the result of the claim */ async function claim (name, salt, options = {}) { + // Todo remove cross compatibility + const { version } = this.getNodeInfo() + const [majorVersion] = version.split('.') + const vsn = +majorVersion === 5 && version !== '5.0.0-rc.1' ? 2 : 1 + options.vsn = options.vsn || vsn + isNameValid(name) const opt = R.merge(this.Ae.defaults, options) @@ -187,7 +193,7 @@ async function claim (name, salt, options = {}) { })) const result = await this.send(claimTx, opt) - if (opt.vsn === 1) { + if (opt.vsn === 1 || name.length - 4 > 12) { const nameInter = this.Chain.defaults.waitMined ? await this.aensQuery(name, opt) : {} return Object.assign(result, nameInter) } diff --git a/es/tx/builder/schema.js b/es/tx/builder/schema.js index e749eea866..eff1aefe8d 100644 --- a/es/tx/builder/schema.js +++ b/es/tx/builder/schema.js @@ -13,10 +13,12 @@ import BigNumber from 'bignumber.js' export const VSN = 1 export const VSN_2 = 2 +// # TRANSACTION DEFAULT TTL +export const TX_TTL = 0 + // # AENS export const AENS_NAME_DOMAINS = ['aet', 'test'] export const NAME_TTL = 500 -// # Aens // # max number of block into the future that the name is going to be available // # https://github.com/aeternity/protocol/blob/epoch-v0.22.0/AENS.md#update // # https://github.com/aeternity/protocol/blob/44a93d3aab957ca820183c3520b9daf6b0fedff4/AENS.md#aens-entry diff --git a/es/tx/tx.js b/es/tx/tx.js index 30a1dfa8dc..1e4d2a702b 100644 --- a/es/tx/tx.js +++ b/es/tx/tx.js @@ -28,7 +28,7 @@ import ChainNode from '../chain/node' import Tx from './' import { buildTx, calculateFee } from './builder' -import { ABI_VERSIONS, MIN_GAS_PRICE, PROTOCOL_VM_ABI, TX_TYPE, VM_TYPE } from './builder/schema' +import { ABI_VERSIONS, MIN_GAS_PRICE, PROTOCOL_VM_ABI, TX_TYPE, VM_TYPE, TX_TTL } from './builder/schema' import { buildContractId, oracleQueryId } from './builder/helpers' async function spendTx ({ senderId, recipientId, amount, payload = '' }) { @@ -392,7 +392,7 @@ function getVmVersion (txType, { vmVersion, abiVersion, backend } = {}) { * @param {boolean} relative ttl is absolute or relative(default: true(relative)) * @return {number} Absolute Ttl */ -async function calculateTtl (ttl = 0, relative = true) { +async function calculateTtl (ttl = TX_TTL, relative = true) { if (ttl === 0) return 0 if (ttl < 0) throw new Error('ttl must be greater than 0') diff --git a/es/utils/crypto.js b/es/utils/crypto.js index 2f20486e6f..c17559413d 100644 --- a/es/utils/crypto.js +++ b/es/utils/crypto.js @@ -70,12 +70,13 @@ export function formatAddress (format = ADDRESS_FORMAT.api, address) { * Check if address is valid * @rtype (input: String) => valid: Boolean * @param {String} address - Address + * @param {String} prefix Transaction prefix. Default: 'ak' * @return {Boolean} valid */ -export function isAddressValid (address) { +export function isAddressValid (address, prefix = 'ak') { let isValid try { - isValid = decodeBase58Check(assertedType(address, 'ak')).length === 32 + isValid = decodeBase58Check(assertedType(address, prefix)).length === 32 } catch (e) { isValid = false } From 914397eb617675ca1f264c5a73faf006ce15fa2b Mon Sep 17 00:00:00 2001 From: naz_dou Date: Wed, 9 Oct 2019 18:40:28 +0300 Subject: [PATCH 4/6] refactor(constants): Move const to shema. Improve isAddressValid. --- es/ae/aens.js | 9 ++++++++- es/tx/builder/schema.js | 4 +++- es/tx/tx.js | 4 ++-- es/utils/crypto.js | 5 +++-- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/es/ae/aens.js b/es/ae/aens.js index 91d8ab69b5..3aae73265f 100644 --- a/es/ae/aens.js +++ b/es/ae/aens.js @@ -169,6 +169,12 @@ async function query (name, opt = {}) { * @return {Promise} the result of the claim */ async function claim (name, salt, options = {}) { + // Todo remove cross compatibility + const { version } = this.getNodeInfo() + const [majorVersion] = version.split('.') + const vsn = +majorVersion === 5 && version !== '5.0.0-rc.1' ? 2 : 1 + options.vsn = options.vsn || vsn + isNameValid(name) const opt = R.merge(this.Ae.defaults, options) @@ -187,7 +193,8 @@ async function claim (name, salt, options = {}) { })) const result = await this.send(claimTx, opt) - if (opt.vsn === 1) { + if (opt.vsn === 1 || name.length - 4 > 12) { + delete opt.vsn const nameInter = this.Chain.defaults.waitMined ? await this.aensQuery(name, opt) : {} return Object.assign(result, nameInter) } diff --git a/es/tx/builder/schema.js b/es/tx/builder/schema.js index e749eea866..eff1aefe8d 100644 --- a/es/tx/builder/schema.js +++ b/es/tx/builder/schema.js @@ -13,10 +13,12 @@ import BigNumber from 'bignumber.js' export const VSN = 1 export const VSN_2 = 2 +// # TRANSACTION DEFAULT TTL +export const TX_TTL = 0 + // # AENS export const AENS_NAME_DOMAINS = ['aet', 'test'] export const NAME_TTL = 500 -// # Aens // # max number of block into the future that the name is going to be available // # https://github.com/aeternity/protocol/blob/epoch-v0.22.0/AENS.md#update // # https://github.com/aeternity/protocol/blob/44a93d3aab957ca820183c3520b9daf6b0fedff4/AENS.md#aens-entry diff --git a/es/tx/tx.js b/es/tx/tx.js index 30a1dfa8dc..1e4d2a702b 100644 --- a/es/tx/tx.js +++ b/es/tx/tx.js @@ -28,7 +28,7 @@ import ChainNode from '../chain/node' import Tx from './' import { buildTx, calculateFee } from './builder' -import { ABI_VERSIONS, MIN_GAS_PRICE, PROTOCOL_VM_ABI, TX_TYPE, VM_TYPE } from './builder/schema' +import { ABI_VERSIONS, MIN_GAS_PRICE, PROTOCOL_VM_ABI, TX_TYPE, VM_TYPE, TX_TTL } from './builder/schema' import { buildContractId, oracleQueryId } from './builder/helpers' async function spendTx ({ senderId, recipientId, amount, payload = '' }) { @@ -392,7 +392,7 @@ function getVmVersion (txType, { vmVersion, abiVersion, backend } = {}) { * @param {boolean} relative ttl is absolute or relative(default: true(relative)) * @return {number} Absolute Ttl */ -async function calculateTtl (ttl = 0, relative = true) { +async function calculateTtl (ttl = TX_TTL, relative = true) { if (ttl === 0) return 0 if (ttl < 0) throw new Error('ttl must be greater than 0') diff --git a/es/utils/crypto.js b/es/utils/crypto.js index 2f20486e6f..c17559413d 100644 --- a/es/utils/crypto.js +++ b/es/utils/crypto.js @@ -70,12 +70,13 @@ export function formatAddress (format = ADDRESS_FORMAT.api, address) { * Check if address is valid * @rtype (input: String) => valid: Boolean * @param {String} address - Address + * @param {String} prefix Transaction prefix. Default: 'ak' * @return {Boolean} valid */ -export function isAddressValid (address) { +export function isAddressValid (address, prefix = 'ak') { let isValid try { - isValid = decodeBase58Check(assertedType(address, 'ak')).length === 32 + isValid = decodeBase58Check(assertedType(address, prefix)).length === 32 } catch (e) { isValid = false } From bcdc1e26d33acde7ff541656d812f3a41b7d1592 Mon Sep 17 00:00:00 2001 From: naz_dou Date: Thu, 10 Oct 2019 15:43:20 +0300 Subject: [PATCH 5/6] refactor(AENS): Remove `prelimaCommitmentId`. Add function for generating `nameId` --- es/ae/aens.js | 13 +++---------- es/tx/builder/helpers.js | 30 +++++++++++++++--------------- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/es/ae/aens.js b/es/ae/aens.js index 3aae73265f..7834b2b2ce 100644 --- a/es/ae/aens.js +++ b/es/ae/aens.js @@ -28,7 +28,7 @@ import * as R from 'ramda' import { encodeBase58Check, salt } from '../utils/crypto' -import { commitmentHash, prelimaCommitmentHash, isNameValid, getMinimumNameFee } from '../tx/builder/helpers' +import { commitmentHash, isNameValid, getMinimumNameFee } from '../tx/builder/helpers' import Ae from './' import { CLIENT_TTL, NAME_FEE, NAME_TTL } from '../tx/builder/schema' @@ -211,18 +211,11 @@ async function claim (name, salt, options = {}) { * @return {Promise} */ async function preclaim (name, options = {}) { - // TODO remove cross compatibility - const { version } = this.getNodeInfo() - const [majorVersion] = version.split('.') - const vsn = +majorVersion === 5 && version !== '5.0.0-rc.1' ? 2 : 1 - isNameValid(name) const opt = R.merge(this.Ae.defaults, options) const _salt = salt() const height = await this.height() - const hash = vsn === 1 - ? await prelimaCommitmentHash(name, _salt) - : await commitmentHash(name, _salt) + const hash = commitmentHash(name, _salt) const preclaimTx = await this.namePreclaimTx(R.merge(opt, { accountId: await this.address(opt), @@ -234,7 +227,7 @@ async function preclaim (name, options = {}) { return Object.freeze({ ...result, height, - claim: options => this.aensClaim(name, _salt, { ...options, onAccount: opt.onAccount, vsn }), + claim: options => this.aensClaim(name, _salt, { ...options, onAccount: opt.onAccount }), salt: _salt, commitmentId: hash }) diff --git a/es/tx/builder/helpers.js b/es/tx/builder/helpers.js index 7305a6223b..2320e3253c 100644 --- a/es/tx/builder/helpers.js +++ b/es/tx/builder/helpers.js @@ -7,7 +7,7 @@ import { decodeBase64Check, encodeBase58Check, encodeBase64Check, hash, - nameId, + nameId as nameHash, salt } from '../../utils/crypto' import { toBytes } from '../../utils/bytes' @@ -89,19 +89,16 @@ export function formatSalt (salt) { } /** - * Generate the commitment hash by hashing the formatted salt and - * name, base 58 encoding the result and prepending 'cm_' - * + * Encode a domain name + * @function * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers - * @function prelimaCommitmentHash - * @category async - * @rtype (name: String, salt?: String) => hash: Promise[String] - * @param {String} name - Name to be registered - * @param {Number} salt Random salt - * @return {String} Commitment hash + * @param {String} name Name to encode + * @return {String} `nm_` prefixed encoded domain name */ -export async function prelimaCommitmentHash (name, salt = createSalt()) { - return `cm_${encodeBase58Check(hash(Buffer.concat([nameId(name.toLowerCase()), formatSalt(salt)])))}` +export function produceNameId (name) { + const namespace = R.last(name.split('.')) + if (namespace === 'aet') return encode(hash(name.toLowerCase()), 'nm') + return encode(nameHash(name), 'nm') } /** @@ -116,8 +113,10 @@ export async function prelimaCommitmentHash (name, salt = createSalt()) { * @param {Number} salt Random salt * @return {String} Commitment hash */ -export async function commitmentHash (name, salt = createSalt()) { - return `cm_${encodeBase58Check(hash(Buffer.concat([Buffer.from(name), formatSalt(salt)])))}` +export function commitmentHash (name, salt = createSalt()) { + const namespace = R.last(name.split('.')) + if (namespace === 'aet') return `cm_${encodeBase58Check(hash(Buffer.concat([Buffer.from(name), formatSalt(salt)])))}` + return `cm_${encodeBase58Check(hash(Buffer.concat([nameHash(name.toLowerCase()), formatSalt(salt)])))}` } /** @@ -293,5 +292,6 @@ export default { oracleQueryId, createSalt, buildHash, - isNameValid + isNameValid, + produceNameId } From 09a470f2a0e101b7f5c6de6fc225d8a76668d58d Mon Sep 17 00:00:00 2001 From: naz_dou Date: Thu, 10 Oct 2019 15:58:04 +0300 Subject: [PATCH 6/6] refactor(AE): Generate nameId in spend by name function instead of calling node --- es/ae/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/es/ae/index.js b/es/ae/index.js index 56d111e725..6606e31254 100644 --- a/es/ae/index.js +++ b/es/ae/index.js @@ -30,7 +30,7 @@ import TxBuilder from '../tx/builder' import * as R from 'ramda' import { BigNumber } from 'bignumber.js' import { isAddressValid } from '../utils/crypto' -import { isNameValid } from '../tx/builder/helpers' +import { isNameValid, produceNameId } from '../tx/builder/helpers' /** * Sign and post a transaction to the chain @@ -84,10 +84,12 @@ async function spend (amount, recipientId, options = {}) { async function resolveRecipientName (nameOrAddress, { verify = false }) { if (isAddressValid(nameOrAddress)) return nameOrAddress if (isNameValid(nameOrAddress)) { - const { id, pointers } = await this.getName(nameOrAddress) // Validation - if (verify && !pointers.find(({ id }) => id.split('_')[0] === 'ak')) throw new Error(`Name ${nameOrAddress} do not have pointers for account`) - return id + if (verify) { + const { pointers } = await this.getName(nameOrAddress) + if (!pointers.find(({ id }) => id.split('_')[0] === 'ak')) throw new Error(`Name ${nameOrAddress} do not have pointers for account`) + } + return produceNameId(nameOrAddress) } }