Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Realign 6.1.0 #780

Merged
merged 36 commits into from
Nov 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
081bc4e
Release/6.0.2 (#741)
mpowaga Oct 31, 2019
66cef36
removed empty lines
tarasherasymchuk Oct 31, 2019
1f801ab
style(changelog): added whitespaces to separate changelog sections
tarasherasymchuk Oct 31, 2019
1128bbd
Feat(AENS): auction name fee calculation (#706)
nduchak Oct 8, 2019
6d4078e
refactor(AENS): refactor claim (#709)
nduchak Oct 10, 2019
deed7fc
feat(state channels): make state channels compatible with node v5.0.0…
mpowaga Oct 16, 2019
9725b08
Realign 6.0.0 (#719)
nduchak Oct 17, 2019
c8ebb76
Update libsodium-wrappers-sumo to the latest version 🚀 (#721)
greenkeeper[bot] Oct 22, 2019
4ff3345
Update commander to the latest version 🚀 (#743)
greenkeeper[bot] Nov 1, 2019
b580057
Update vue-loader in group default to the latest version 🚀 (#745)
greenkeeper[bot] Nov 4, 2019
13cdd07
Update rlp to the latest version 🚀 (#744)
greenkeeper[bot] Nov 4, 2019
4c1f5e4
fix(AENS): auction end block calculation (#746)
nduchak Nov 4, 2019
fd14225
fix(AENS): Fix `produceNameId` function(Make name lowercase). Enable …
nduchak Nov 4, 2019
bf11eb6
aensQuery: Fix default value of pointers field (#735)
davidyuk Nov 4, 2019
11d8055
Update @aeternity/aepp-sdk in group default to the latest version 🚀 (…
greenkeeper[bot] Nov 4, 2019
e0166c2
Remove extra eslint exceptions (#729)
davidyuk Nov 4, 2019
232e0ab
Update babel7 in group default to the latest version 🚀 (#754)
greenkeeper[bot] Nov 6, 2019
ddc6611
feat(state channels): allow to pass metadata to transfer update (#755)
mpowaga Nov 6, 2019
ae4426e
feat(state channels): allow off chain updates to be cancelled with cu…
mpowaga Nov 6, 2019
c5f35d1
fix(state channels): wait for connection to be established before sen…
mpowaga Nov 6, 2019
c950937
feat(state channels): add round method (#763)
mpowaga Nov 6, 2019
07cb0e7
feat(ACI): Add validation for contractAddress (#764)
nduchak Nov 6, 2019
5250e75
feat(AENS): Add nameFee validation to TxValidator (#765)
nduchak Nov 7, 2019
de83204
feat(Crypto): Implement asymmetric encoding/decoding using `tweennac…
nduchak Nov 7, 2019
12aaca3
feat(Contract): Add ability to pass arguments or callData for contrac…
nduchak Nov 7, 2019
ca8b467
Update babel7 in group default to the latest version 🚀 (#771)
greenkeeper[bot] Nov 11, 2019
c5f2582
feat(AENS): Increase default nameTtl (#775)
nduchak Nov 11, 2019
87062ea
feat(Http): Assign error object to http error (#770)
nduchak Nov 11, 2019
74952aa
feat(state channels): make state channels compatible with node v5.1.0…
mpowaga Nov 11, 2019
06129de
docs(Examples): Fix contract example (#778)
nduchak Nov 11, 2019
777c012
fix(TxHelpers): Use BigNumber in auction end block calculation
nduchak Nov 11, 2019
a3e78d3
docs(Helpers): Add missed jsdocs
nduchak Nov 11, 2019
65b3111
chore(release): Bump version. Regenerate docs and CHANGELOG
nduchak Nov 11, 2019
2edf518
Merge pull request #779 from aeternity/release/6.1.0
nduchak Nov 11, 2019
d45fc42
Merge branch 'master' into realign/6.1.0
nduchak Nov 11, 2019
475f032
Merge branch 'develop' into realign/6.1.0
nduchak Nov 11, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
# [6.1.0](https://github.com/aeternity/aepp-sdk-js/compare/6.0.2...6.1.0) (2019-11-11)


### Bug Fixes

* **AENS:** auction end block calculation ([#746](https://github.com/aeternity/aepp-sdk-js/issues/746)) ([4c1f5e4](https://github.com/aeternity/aepp-sdk-js/commit/4c1f5e4))
* **AENS:** Fix `produceNameId` function(Make name lowercase). Enable … ([#750](https://github.com/aeternity/aepp-sdk-js/issues/750)) ([fd14225](https://github.com/aeternity/aepp-sdk-js/commit/fd14225))
* **state channels:** wait for connection to be established before sending generic message ([#723](https://github.com/aeternity/aepp-sdk-js/issues/723)) ([c5f35d1](https://github.com/aeternity/aepp-sdk-js/commit/c5f35d1))
* **TxHelpers:** Use BigNumber in auction end block calculation ([777c012](https://github.com/aeternity/aepp-sdk-js/commit/777c012))


### Features

* **ACI:** Add validation for contractAddress ([#764](https://github.com/aeternity/aepp-sdk-js/issues/764)) ([07cb0e7](https://github.com/aeternity/aepp-sdk-js/commit/07cb0e7))
* **AENS:** Add nameFee validation to TxValidator ([#765](https://github.com/aeternity/aepp-sdk-js/issues/765)) ([5250e75](https://github.com/aeternity/aepp-sdk-js/commit/5250e75))
* **AENS:** Increase default nameTtl ([#775](https://github.com/aeternity/aepp-sdk-js/issues/775)) ([c5f2582](https://github.com/aeternity/aepp-sdk-js/commit/c5f2582))
* **Contract:** Add ability to pass arguments or callData for contract `deploy/call/callStatic` API ([#768](https://github.com/aeternity/aepp-sdk-js/issues/768)) ([12aaca3](https://github.com/aeternity/aepp-sdk-js/commit/12aaca3))
* **Http:** Assign error object to http error ([#770](https://github.com/aeternity/aepp-sdk-js/issues/770)) ([87062ea](https://github.com/aeternity/aepp-sdk-js/commit/87062ea))
* **state channels:** add round method ([#763](https://github.com/aeternity/aepp-sdk-js/issues/763)) ([c950937](https://github.com/aeternity/aepp-sdk-js/commit/c950937))
* **state channels:** allow off chain updates to be cancelled with custom error code ([#753](https://github.com/aeternity/aepp-sdk-js/issues/753)) ([ae4426e](https://github.com/aeternity/aepp-sdk-js/commit/ae4426e))
* **state channels:** allow to pass metadata to transfer update ([#755](https://github.com/aeternity/aepp-sdk-js/issues/755)) ([ddc6611](https://github.com/aeternity/aepp-sdk-js/commit/ddc6611))
* **state channels:** make state channels compatible with node v5.0.0… ([#688](https://github.com/aeternity/aepp-sdk-js/issues/688)) ([deed7fc](https://github.com/aeternity/aepp-sdk-js/commit/deed7fc)), 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)
* **state channels:** make state channels compatible with node v5.1.0… ([#776](https://github.com/aeternity/aepp-sdk-js/issues/776)) ([74952aa](https://github.com/aeternity/aepp-sdk-js/commit/74952aa))



## [6.0.2](https://github.com/aeternity/aepp-sdk-js/compare/6.0.1...6.0.2) (2019-10-31)


Expand All @@ -17,9 +43,6 @@






# [6.0.0](https://github.com/aeternity/aepp-sdk-js/compare/4.7.0...6.0.0) (2019-10-16)


Expand Down
16 changes: 8 additions & 8 deletions docs/api/ae/contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { Contract } from '@aeternity/aepp-sdk' (Using bundle)
* [handleCallError(result)](#exp_module_@aeternity/aepp-sdk/es/ae/contract--handleCallError) ⇒ `Promise.<void>` ⏏
* [contractEncodeCall(source, name, args, [options])](#exp_module_@aeternity/aepp-sdk/es/ae/contract--contractEncodeCall) ⇒ `Promise.<String>` ⏏
* [contractDecodeData(source, fn, callValue, callResult, [options])](#exp_module_@aeternity/aepp-sdk/es/ae/contract--contractDecodeData) ⇒ `Promise.<String>` ⏏
* [contractCallStatic(source, address, name, args, [options], bytecode, options, filesystem)](#exp_module_@aeternity/aepp-sdk/es/ae/contract--contractCallStatic) ⇒ `Promise.<Object>` ⏏
* [contractCallStatic(source, address, name, args, [options])](#exp_module_@aeternity/aepp-sdk/es/ae/contract--contractCallStatic) ⇒ `Promise.<Object>` ⏏
* [contractCall(source, address, name, args, [options])](#exp_module_@aeternity/aepp-sdk/es/ae/contract--contractCall) ⏏
* [contractDeploy(code, source, initState, [options])](#exp_module_@aeternity/aepp-sdk/es/ae/contract--contractDeploy) ⇒ `Promise.<Object>` ⏏
* [contractCompile(source, [options])](#exp_module_@aeternity/aepp-sdk/es/ae/contract--contractCompile) ⇒ `Promise.<Object>` ⏏
Expand Down Expand Up @@ -118,7 +118,7 @@ const decodedData = await client.contractDecodeData(SourceCode ,'functionName',
```
<a id="exp_module_@aeternity/aepp-sdk/es/ae/contract--contractCallStatic"></a>

### contractCallStatic(source, address, name, args, [options], bytecode, options, filesystem) ⇒ `Promise.&lt;Object&gt;` ⏏
### contractCallStatic(source, address, name, args, [options]) ⇒ `Promise.&lt;Object&gt;` ⏏
Static contract call(using dry-run)

**Kind**: Exported function
Expand All @@ -130,12 +130,12 @@ Static contract call(using dry-run)
| source | `String` | | Contract source code |
| address | `String` | | Contract address |
| name | `String` | | Name of function to call |
| args | `Array` | | Argument's for call function |
| args | `Array` \| `String` | | Argument's or callData for call/deploy transaction |
| [options] | `Object` | <code>{}</code> | Options |
| [options.top] | `String` | | Block hash on which you want to call contract |
| bytecode | | | |
| options | `String` | | [options.options] Transaction options (fee, ttl, gas, amount, deposit) |
| filesystem | `Object` | | [options.options.filesystem] Contract external namespaces map |
| [options.bytecode] | `String` | | Block hash on which you want to call contract |
| [options.options] | `Object` | | Transaction options (fee, ttl, gas, amount, deposit) |
| [options.options.filesystem] | `Object` | | Contract external namespaces map |

**Example**
```js
Expand All @@ -158,7 +158,7 @@ Call contract function
| source | `String` | | Contract source code |
| address | `String` | | Contract address |
| name | `String` | | Name of function to call |
| args | `Array` | | Argument's for call function |
| args | `Array` \| `String` | | Argument's or callData for call function |
| [options] | `Object` | <code>{}</code> | Transaction options (fee, ttl, gas, amount, deposit) |
| [options.filesystem] | `Object` | <code>{}</code> | Contract external namespaces map* @return {Promise<Object>} Result object |

Expand All @@ -184,7 +184,7 @@ Deploy contract to the node
| --- | --- | --- | --- |
| code | `String` | | Compiled contract |
| source | `String` | | Contract source code |
| initState | `Array` | | Arguments of contract constructor(init) function |
| initState | `Array` \| `String` | | Arguments of contract constructor(init) function. Can be array of arguments or callData string |
| [options] | `Object` | <code>{}</code> | Transaction options (fee, ttl, gas, amount, deposit) |
| [options.filesystem] | `Object` | <code>{}</code> | Contract external namespaces map* @return {Promise<Object>} Result object |

Expand Down
5 changes: 3 additions & 2 deletions docs/api/ae/oracle.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import Oracle from '@aeternity/aepp-sdk/es/ae/oracle'
* [Oracle([options])](#exp_module_@aeternity/aepp-sdk/es/ae/oracle--Oracle) ⇒ `Object` ⏏
* _instance_
* _async_
* [.pollForQueries(oracleId, onQuery, [options])](#exp_module_@aeternity/aepp-sdk/es/ae/oracle--pollForQueries) ⇒ `function` ⏏
* [.getOracleObject(oracleId)](#exp_module_@aeternity/aepp-sdk/es/ae/oracle--getOracleObject) ⇒ `Promise.&lt;Object&gt;` ⏏
* [.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.&lt;Object&gt;` ⏏
* [.exports.pollForQueryResponse(oracleId, queryId, [options])](#exp_module_@aeternity/aepp-sdk/es/ae/oracle--exports.pollForQueryResponse) ⇒ `Promise.&lt;Object&gt;` ⏏
* [.registerOracle(queryFormat, responseFormat, [options])](#exp_module_@aeternity/aepp-sdk/es/ae/oracle--registerOracle) ⇒ `Promise.&lt;Object&gt;` ⏏
Expand Down Expand Up @@ -54,7 +55,7 @@ Poll for oracle queries
| oracleId | `String` | Oracle public key |
| onQuery | `function` | OnQuery callback |
| [options] | `Object` | Options object |
| [options.interval] | `Object` | Poll interval(default: 5000) |
| [options.interval] | `Number` | Poll interval(default: 5000) |

<a id="exp_module_@aeternity/aepp-sdk/es/ae/oracle--getQueryObject"></a>

Expand Down
28 changes: 26 additions & 2 deletions docs/api/channel/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ import Channel from '@aeternity/aepp-sdk/es/channel/index'
* [@aeternity/aepp-sdk/es/channel/index](#module_@aeternity/aepp-sdk/es/channel/index)
* [Channel(options)](#exp_module_@aeternity/aepp-sdk/es/channel/index--Channel) ⇒ `Promise.&lt;Object&gt;` ⏏
* [~on(event, callback)](#module_@aeternity/aepp-sdk/es/channel/index--Channel..on)
* [~off(event, callback)](#module_@aeternity/aepp-sdk/es/channel/index--Channel..off)
* [~disconnect()](#module_@aeternity/aepp-sdk/es/channel/index--Channel..disconnect)
* [~status()](#module_@aeternity/aepp-sdk/es/channel/index--Channel..status) ⇒ `String`
* [~state()](#module_@aeternity/aepp-sdk/es/channel/index--Channel..state) ⇒ `Promise.&lt;Object&gt;`
* [~round()](#module_@aeternity/aepp-sdk/es/channel/index--Channel..round) ⇒ `Number`
* [~id()](#module_@aeternity/aepp-sdk/es/channel/index--Channel..id) ⇒ `String`
* [~update(from, to, amount, sign)](#module_@aeternity/aepp-sdk/es/channel/index--Channel..update) ⇒ `Promise.&lt;Object&gt;`
* [~update(from, to, amount, sign, metadata)](#module_@aeternity/aepp-sdk/es/channel/index--Channel..update) ⇒ `Promise.&lt;Object&gt;`
* [~poi(addresses)](#module_@aeternity/aepp-sdk/es/channel/index--Channel..poi) ⇒ `Promise.&lt;String&gt;`
* [~balances(accounts)](#module_@aeternity/aepp-sdk/es/channel/index--Channel..balances) ⇒ `Promise.&lt;Object&gt;`
* [~leave()](#module_@aeternity/aepp-sdk/es/channel/index--Channel..leave) ⇒ `Promise.&lt;Object&gt;`
Expand Down Expand Up @@ -105,6 +107,18 @@ Possible events:
| event | `String` | Event name |
| callback | `function` | Callback function |

<a id="module_@aeternity/aepp-sdk/es/channel/index--Channel..off"></a>

#### Channel~off(event, callback)
Remove event listener function

**Kind**: inner method of [`Channel`](#exp_module_@aeternity/aepp-sdk/es/channel/index--Channel)

| Param | Type | Description |
| --- | --- | --- |
| event | `String` | Event name |
| callback | `function` | Callback function |

<a id="module_@aeternity/aepp-sdk/es/channel/index--Channel..disconnect"></a>

#### Channel~disconnect()
Expand All @@ -122,6 +136,15 @@ Get current status
#### Channel~state() ⇒ `Promise.&lt;Object&gt;`
Get current state

**Kind**: inner method of [`Channel`](#exp_module_@aeternity/aepp-sdk/es/channel/index--Channel)
<a id="module_@aeternity/aepp-sdk/es/channel/index--Channel..round"></a>

#### Channel~round() ⇒ `Number`
Get current round

If round cannot be determined (for example when channel has not been opened)
it will return `null`.

**Kind**: inner method of [`Channel`](#exp_module_@aeternity/aepp-sdk/es/channel/index--Channel)
<a id="module_@aeternity/aepp-sdk/es/channel/index--Channel..id"></a>

Expand All @@ -131,7 +154,7 @@ Get channel id
**Kind**: inner method of [`Channel`](#exp_module_@aeternity/aepp-sdk/es/channel/index--Channel)
<a id="module_@aeternity/aepp-sdk/es/channel/index--Channel..update"></a>

#### Channel~update(from, to, amount, sign) ⇒ `Promise.&lt;Object&gt;`
#### Channel~update(from, to, amount, sign, metadata) ⇒ `Promise.&lt;Object&gt;`
Trigger a transfer update

The transfer update is moving tokens from one channel account to another.
Expand All @@ -148,6 +171,7 @@ can take those roles. Any public key outside of the channel is considered invali
| to | `String` | Receiver's public address |
| amount | `Number` | Transaction amount |
| sign | `function` | Function which verifies and signs offchain transaction |
| metadata | `Array.&lt;String&gt;` | |

**Example**
```js
Expand Down
5 changes: 3 additions & 2 deletions docs/api/contract/aci.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ Generate contract ACI object with predefined js methods for contract usage - can
| --- | --- | --- | --- |
| source | `String` | | Contract source code |
| [options] | `Object` | <code>{}</code> | Options object |
| [options.aci] | `Object` | | Contract ACI |
| [options.contractAddress] | `Object` | | Contract address |
| [options.aci] | `String` | | Contract ACI |
| [options.contractAddress] | `String` | | Contract address |
| [options.filesystem] | `Object` | | Contact source external namespaces map |
| [options.forceCodeCheck] | `Boolean` | <code>false</code> | Flag to force validation of corresponding on chain bytecode |
| [options.opt] | `Object` | | Contract options |

**Example**
Expand Down
32 changes: 31 additions & 1 deletion docs/api/utils/crypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ import * as Crypto from '@aeternity/aepp-sdk/es/utils/crypto'
* [.isValidKeypair(privateKey, publicKey)](#module_@aeternity/aepp-sdk/es/utils/crypto.isValidKeypair) ⇒ `Boolean`
* [.envKeypair(env)](#module_@aeternity/aepp-sdk/es/utils/crypto.envKeypair) ⇒ `Object`
* [.deserialize(binary, opts)](#module_@aeternity/aepp-sdk/es/utils/crypto.deserialize) ⇒ `Object`
* [.encryptData(msg, publicKey)](#module_@aeternity/aepp-sdk/es/utils/crypto.encryptData) ⇒ `Object`
* [.decryptData(secretKey, encryptedData)](#module_@aeternity/aepp-sdk/es/utils/crypto.decryptData) ⇒ `Buffer` \| `null`
* _inner_
* [~Transaction](#module_@aeternity/aepp-sdk/es/utils/crypto..Transaction) : `Array`

Expand Down Expand Up @@ -213,7 +215,7 @@ Base58 encode given `input`

| Param | Type | Description |
| --- | --- | --- |
| input | `String` | Data to encode |
| input | `String` \| `Buffer` | Data to encode |

<a id="module_@aeternity/aepp-sdk/es/utils/crypto.decodeBase58Check"></a>

Expand Down Expand Up @@ -534,6 +536,34 @@ Deserialize `binary` state channel transaction
| binary | `String` | Data to deserialize |
| opts | `Object` | Options |

<a id="module_@aeternity/aepp-sdk/es/utils/crypto.encryptData"></a>

### @aeternity/aepp-sdk/es/utils/crypto.encryptData(msg, publicKey) ⇒ `Object`
This function encrypts a message using base58check encoded and 'ak' prefixed
publicKey such that only the corresponding secretKey will
be able to decrypt

**Kind**: static method of [`@aeternity/aepp-sdk/es/utils/crypto`](#module_@aeternity/aepp-sdk/es/utils/crypto)
**rtype**: `(msg: String, publicKey: String) => Object`

| Param | Type | Description |
| --- | --- | --- |
| msg | `Buffer` | Data to encode |
| publicKey | `String` | Public key |

<a id="module_@aeternity/aepp-sdk/es/utils/crypto.decryptData"></a>

### @aeternity/aepp-sdk/es/utils/crypto.decryptData(secretKey, encryptedData) ⇒ `Buffer` \| `null`
This function decrypt a message using secret key

**Kind**: static method of [`@aeternity/aepp-sdk/es/utils/crypto`](#module_@aeternity/aepp-sdk/es/utils/crypto)
**rtype**: `(secretKey: String, encryptedData: Object) => Buffer|null`

| Param | Type | Description |
| --- | --- | --- |
| secretKey | `String` | Secret key |
| encryptedData | `Object` | Encrypted data |

<a id="module_@aeternity/aepp-sdk/es/utils/crypto..Transaction"></a>

### @aeternity/aepp-sdk/es/utils/crypto~Transaction : `Array`
Expand Down
17 changes: 1 addition & 16 deletions docs/examples/node/aecrypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,22 +178,7 @@ 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\_.+/)) {
if (!tx.match(/^tx_.+/)) {
throw Error('Not a valid transaction')
}

Expand Down
4 changes: 2 additions & 2 deletions es/ae/contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ async function contractDecodeData (source, fn, callValue, callResult, options) {
* @param {Object} [options={}] Options
* @param {String} [options.top] Block hash on which you want to call contract
* @param {String} [options.bytecode] Block hash on which you want to call contract
* @param {Object} options [options.options] Transaction options (fee, ttl, gas, amount, deposit)
* @param {Object} filesystem [options.options.filesystem] Contract external namespaces map
* @param {Object} [options.options] Transaction options (fee, ttl, gas, amount, deposit)
* @param {Object} [options.options.filesystem] Contract external namespaces map
* @return {Promise<Object>} Result object
* @example
* const callResult = await client.contractCallStatic(source, address, fnName, args = [], { top, options = {} })
Expand Down
31 changes: 24 additions & 7 deletions es/tx/builder/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,23 @@ export function classify (s) {
* Get the minimum name fee for a domain
* @function
* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
* @param {string} domain the domain name to get the fee for
* @return String the minimum fee for the domain auction
* @param {String} domain the domain name to get the fee for
* @return {String} the minimum fee for the domain auction
*/
export function getMinimumNameFee (domain) {
const nameLength = domain.replace('.chain', '').length
return NAME_BID_RANGES[nameLength >= NAME_BID_MAX_LENGTH ? NAME_BID_MAX_LENGTH : nameLength]
}

/**
* Compute bid fee for AENS auction
* @function
* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
* @param {String} domain the domain name to get the fee for
* @param {Number|String} startFee Auction start fee
* @param {Number} [increment=0.5] Bid multiplier(In percentage, must be between 0 and 1)
* @return {String} Bid fee
*/
export function computeBidFee (domain, startFee = NAME_FEE, increment = NAME_FEE_BID_INCREMENT) {
if (!(Number(increment) === increment && increment % 1 !== 0)) throw new Error(`Increment must be float. Current increment ${increment}`)
if (increment < NAME_FEE_BID_INCREMENT) throw new Error(`minimum increment percentage is ${NAME_FEE_BID_INCREMENT}`)
Expand All @@ -295,13 +304,21 @@ export function computeBidFee (domain, startFee = NAME_FEE, increment = NAME_FEE
)
}

/**
* Compute auction end height
* @function
* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
* @param {String} domain the domain name to get the fee for
* @param {Number|String} claimHeight Auction starting height
* @return {String} Auction end height
*/
export function computeAuctionEndBlock (domain, claimHeight) {
return R.cond([
[R.lt(5), R.always(NAME_BID_TIMEOUTS[4] + claimHeight)],
[R.lt(9), R.always(NAME_BID_TIMEOUTS[8] + claimHeight)],
[R.lte(NAME_BID_MAX_LENGTH), R.always(NAME_BID_TIMEOUTS[12] + claimHeight)],
[R.T, R.always(claimHeight)]
])(domain.replace('.chain', '').length)
[R.lt(5), R.always(NAME_BID_TIMEOUTS[4].plus(claimHeight))],
[R.lt(9), R.always(NAME_BID_TIMEOUTS[8].plus(claimHeight))],
[R.lte(NAME_BID_MAX_LENGTH), R.always(NAME_BID_TIMEOUTS[12].plus(claimHeight))],
[R.T, R.always(BigNumber(claimHeight))]
])(domain.replace('.chain', '').length).toString(10)
}

export default {
Expand Down
8 changes: 4 additions & 4 deletions es/tx/builder/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ export const NAME_BID_RANGES = {
// # ref: https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L273
// # name bid timeouts
export const NAME_BID_TIMEOUTS = {
13: 0,
12: NAME_BID_TIMEOUT_BLOCKS, // # 480 blocks
8: 31 * NAME_BID_TIMEOUT_BLOCKS, // # 14880 blocks
4: 62 * NAME_BID_TIMEOUT_BLOCKS // # 29760 blocks
13: BigNumber(0),
12: BigNumber(NAME_BID_TIMEOUT_BLOCKS), // # 480 blocks
8: BigNumber(31).times(NAME_BID_TIMEOUT_BLOCKS), // # 14880 blocks
4: BigNumber(62).times(NAME_BID_TIMEOUT_BLOCKS) // # 29760 blocks
}

// # Tag constant for ids (type uint8)
Expand Down
Loading