Skip to content

Commit

Permalink
feat(aens): implement aensExtendTtl function. Refactor aensUpdate (#866)
Browse files Browse the repository at this point in the history
* feat(aens): implement aensExtendTtl function. Refactor aensUpdate

aensUpdate now accept array of pointers

BREAKING CHANGE: Change aensUpdate method arguments

#865

* docs(AENS): Update JsDocs for AENS

* feat(aens): change AENS API argument from nameId to just name ('test.chain')

* docs(AENS): Fix typo

* feat(AENS): Add `pointers` extend functionality

* feat(AENS): Fix merging of pointers. Adjust tests
  • Loading branch information
nduchak authored Jan 21, 2020
1 parent 9ba2740 commit 72b073a
Show file tree
Hide file tree
Showing 4 changed files with 313 additions and 76 deletions.
142 changes: 116 additions & 26 deletions docs/api/ae/aens.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import Aens from '@aeternity/aepp-sdk/es/ae/aens'
* [Aens([options])](#exp_module_@aeternity/aepp-sdk/es/ae/aens--Aens)`Object`
* _instance_
* _async_
* [.update(nameId, target, options)](#exp_module_@aeternity/aepp-sdk/es/ae/aens--update)`Object`
* [.transfer(nameId, account, [options])](#exp_module_@aeternity/aepp-sdk/es/ae/aens--transfer)`Promise.<Object>`
* [.update(name, pointers, [options])](#exp_module_@aeternity/aepp-sdk/es/ae/aens--update)`Promise.<Object>`
* [.transfer(name, account, [options])](#exp_module_@aeternity/aepp-sdk/es/ae/aens--transfer)`Promise.<Object>`
* [.query(name, opt)](#exp_module_@aeternity/aepp-sdk/es/ae/aens--query)`Promise.<Object>`
* [.claim(name, salt, [options])](#exp_module_@aeternity/aepp-sdk/es/ae/aens--claim)`Promise.<Object>`
* [.preclaim(name, [options])](#exp_module_@aeternity/aepp-sdk/es/ae/aens--preclaim)`Promise.<Object>`
Expand All @@ -41,45 +41,94 @@ Aens provides name-system related methods atop

<a id="exp_module_@aeternity/aepp-sdk/es/ae/aens--update"></a>

### .update(nameId, target, options) ⇒ `Object`
Update an aens entry
### .update(name, pointers, [options]) ⇒ `Promise.&lt;Object&gt;`
Update an name

**Kind**: instance method of [`@aeternity/aepp-sdk/es/ae/aens`](#module_@aeternity/aepp-sdk/es/ae/aens)
**Category**: async
**Throws**:

| Param | Description |
| --- | --- |
| nameId | domain hash |
| target | new target |
| options | |
- Invalid pointer array error


| Param | Type | Default | Description |
| --- | --- | --- | --- |
| name | `String` | | AENS name |
| pointers | `Array.&lt;String&gt;` | | Array of name pointers. Can be oracle|account|contract|channel public key |
| [options] | `Object` | <code>{}</code> | |
| [options.onAccount] | `String` \| `Object` | | onAccount Make operation on specific account from sdk(you pass publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount) |
| [options.fee] | `Number` \| `String` \| `BigNumber` | | fee |
| [options.ttl] | `Number` \| `String` \| `BigNumber` | | ttl |
| [options.nonce] | `Number` \| `String` \| `BigNumber` | | nonce |
| [options.nameTtl] | `Number` \| `String` \| `BigNumber` | <code>50000</code> | nameTtl Name ttl represented in number of blocks (Max value is 50000 blocks) |
| [options.clientTtl] | `Number` \| `String` \| `BigNumber` | <code>84600</code> | clientTtl a suggestion as to how long any clients should cache this information |

**Example**
```js
const name = 'test.chain'
const pointersArray = ['ak_asd23dasdas...,' 'ct_asdf34fasdasd...']
const nameObject = await sdkInstance.aensQuery(name)

await sdkInstance.aensUpdate(name, pointersArray, { nameTtl, ttl, fee, nonce, clientTtl })
// or
await nameObject.update(pointersArray, { nameTtl, ttl, fee, nonce, clientTtl })
```
<a id="exp_module_@aeternity/aepp-sdk/es/ae/aens--transfer"></a>

### .transfer(nameId, account, [options]) ⇒ `Promise.&lt;Object&gt;`
### .transfer(name, account, [options]) ⇒ `Promise.&lt;Object&gt;`
Transfer a domain to another account

**Kind**: instance method of [`@aeternity/aepp-sdk/es/ae/aens`](#module_@aeternity/aepp-sdk/es/ae/aens)
**Returns**: `Promise.&lt;Object&gt;` - Transaction result
**Category**: async

| Param | Type | Default |
| --- | --- | --- |
| nameId | `String` | |
| account | `String` | |
| [options] | `Object` | <code>{}</code> |
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| name | `String` | | AENS name |
| account | `String` | | Recipient account publick key |
| [options] | `Object` | <code>{}</code> | |
| [options.onAccount] | `String` \| `Object` | | onAccount Make operation on specific account from sdk(you pass publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount) |
| [options.fee] | `Number` \| `String` \| `BigNumber` | | fee |
| [options.ttl] | `Number` \| `String` \| `BigNumber` | | ttl |
| [options.nonce] | `Number` \| `String` \| `BigNumber` | | nonce |

**Example**
```js
const name = 'test.chain'
const recipientPub = 'ak_asd23dasdas...'
const nameObject = await sdkInstance.aensQuery(name)

await sdkInstance.aensTransfer(name, recipientPub, { ttl, fee, nonce })
// or
await nameObject.transfer(recipientPub, { ttl, fee, nonce })
```
<a id="exp_module_@aeternity/aepp-sdk/es/ae/aens--query"></a>

### .query(name, opt) ⇒ `Promise.&lt;Object&gt;`
Query the status of an AENS registration
Query the AENS name info from the node
and return the object with info and predefined functions for manipulating name

**Kind**: instance method of [`@aeternity/aepp-sdk/es/ae/aens`](#module_@aeternity/aepp-sdk/es/ae/aens)
**Category**: async

| Param | Type | Description |
| --- | --- | --- |
| name | `string` | |
| name | `String` | |
| opt | `Object` | Options |

**Example**
```js
const nameObject = sdkInstance.aensQuery('test.chain')
console.log(nameObject)
{
id, // name hash
pointers, // array of pointers
update, // Update name function
extendTtl, // Extend Ttl name function
transfer, // Transfer name function
revoke // Revoke name function
}
```
<a id="exp_module_@aeternity/aepp-sdk/es/ae/aens--claim"></a>

### .claim(name, salt, [options]) ⇒ `Promise.&lt;Object&gt;`
Expand All @@ -93,10 +142,22 @@ preclaim step
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| name | `String` | | |
| salt | `Number` | | |
| [options] | `Record` | <code>{}</code> | |
| [options.nameFee] | `Number` \| `String` | | Name Fee |
| salt | `Number` | | Salt from pre-claim, or 0 if it's a bid |
| [options] | `Object` | <code>{}</code> | options |
| [options.onAccount] | `String` \| `Object` | | onAccount Make operation on specific account from sdk(you pass publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount) |
| [options.fee] | `Number` \| `String` \| `BigNumber` | | fee |
| [options.ttl] | `Number` \| `String` \| `BigNumber` | | ttl |
| [options.nonce] | `Number` \| `String` \| `BigNumber` | | nonce |
| [options.nameFee] | `Number` \| `String` | | Name Fee (By default calculated by sdk) |
| [options.vsn] | `Number` \| `String` | <code>2</code> | Transaction vsn from Lima is 2 |

**Example**
```js
const name = 'test.chain'
const salt = preclaimResult.salt // salt from pre-claim transaction

await sdkInstance.aensClaim(name, salt, { ttl, fee, nonce, nameFee })
```
<a id="exp_module_@aeternity/aepp-sdk/es/ae/aens--preclaim"></a>

### .preclaim(name, [options]) ⇒ `Promise.&lt;Object&gt;`
Expand All @@ -105,22 +166,51 @@ Preclaim a name. Sends a hash of the name and a random salt to the node
**Kind**: instance method of [`@aeternity/aepp-sdk/es/ae/aens`](#module_@aeternity/aepp-sdk/es/ae/aens)
**Category**: async

| Param | Type | Default |
| --- | --- | --- |
| name | `string` | |
| [options] | `Record` | <code>{}</code> |
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| name | `String` | | |
| [options] | `Object` | <code>{}</code> | |
| [options.onAccount] | `String` \| `Object` | | onAccount Make operation on specific account from sdk(you pass publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount) |
| [options.fee] | `Number` \| `String` \| `BigNumber` | | fee |
| [options.ttl] | `Number` \| `String` \| `BigNumber` | | ttl |
| [options.nonce] | `Number` \| `String` \| `BigNumber` | | nonce |

**Example**
```js
const name = 'test.chain'
const salt = preclaimResult.salt // salt from pre-claim transaction

await sdkInstance.aensPreclaim(name, { ttl, fee, nonce })
{
...transactionResult,
claim, // Claim function (options={}) => claimTransactionResult
salt,
commitmentId
}
```
<a id="exp_module_@aeternity/aepp-sdk/es/ae/aens--bid"></a>

### .bid(name, nameFee, [options]) ⇒ `Promise.&lt;Object&gt;`
Bid to name auction

**Kind**: instance method of [`@aeternity/aepp-sdk/es/ae/aens`](#module_@aeternity/aepp-sdk/es/ae/aens)
**Returns**: `Promise.&lt;Object&gt;` - Transaction result
**Category**: async

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| name | `String` | | Domain name |
| nameFee | `String` \| `Number` | | Name fee amount |
| [options] | `Record` | <code>{}</code> | |
| nameFee | `String` \| `Number` | | Name fee (bid fee) |
| [options] | `Object` | <code>{}</code> | |
| [options.onAccount] | `String` \| `Object` | | onAccount Make operation on specific account from sdk(you pass publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount) |
| [options.fee] | `Number` \| `String` \| `BigNumber` | | fee |
| [options.ttl] | `Number` \| `String` \| `BigNumber` | | ttl |
| [options.nonce] | `Number` \| `String` \| `BigNumber` | | nonce |

**Example**
```js
const name = 'test.chain'
const bidFee = computeBidFee(name, startFee, incrementPercentage)

await sdkInstance.aensBid(name, 213109412839123, { ttl, fee, nonce })
```
Loading

0 comments on commit 72b073a

Please sign in to comment.