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

docs(Contract): Adjust contract docs #658

Merged
merged 1 commit into from
Sep 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
115 changes: 61 additions & 54 deletions docs/api/ae/contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ import { Contract } from '@aeternity/aepp-sdk' (Using bundle)
```

* [@aeternity/aepp-sdk/es/ae/contract](#module_@aeternity/aepp-sdk/es/ae/contract)
* [exports.Contract([options])](#exp_module_@aeternity/aepp-sdk/es/ae/contract--exports.Contract)`Object`
* [exports.ContractAPI([options])](#exp_module_@aeternity/aepp-sdk/es/ae/contract--exports.ContractAPI)`Object`
* _async_
* [handleCallError(result)](#exp_module_@aeternity/aepp-sdk/es/ae/contract--handleCallError)`Promise.<void>`
* [contractEncodeCall(source, name, args)](#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, top, 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)`Promise.<Object>`
* [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>`
* [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>`
* [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>`

<a id="exp_module_@aeternity/aepp-sdk/es/ae/contract--exports.Contract"></a>
<a id="exp_module_@aeternity/aepp-sdk/es/ae/contract--exports.ContractAPI"></a>

### exports.Contract([options]) ⇒ `Object`
### exports.ContractAPI([options]) ⇒ `Object`
Contract Stamp

Provide contract implementation
Expand Down Expand Up @@ -80,57 +80,62 @@ Handle contract call error
<a id="exp_module_@aeternity/aepp-sdk/es/ae/contract--contractEncodeCall"></a>
### contractEncodeCall(source, name, args) ⇒ `Promise.&lt;String&gt;` ⏏
### contractEncodeCall(source, name, args, [options]) ⇒ `Promise.&lt;String&gt;` ⏏
Encode call data for contract call
**Kind**: Exported function
**Category**: async
| Param | Type | Description |
| --- | --- | --- |
| source | `String` | Contract source code |
| name | `String` | Name of function to call |
| args | `Array` | Argument's for call |
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| source | `String` | | Contract source code |
| name | `String` | | Name of function to call |
| args | `Array` | | Argument's for call |
| [options] | `Object` | <code>{}</code> | Options |
| [options.filesystem] | `Object` | <code>{}</code> | Contract external namespaces map |

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

### contractDecodeData(source, fn, callValue, callResult, options) ⇒ `Promise.&lt;String&gt;`
### contractDecodeData(source, fn, callValue, callResult, [options]) ⇒ `Promise.&lt;String&gt;`
Decode contract call result data

**Kind**: Exported function
**Returns**: `Promise.&lt;String&gt;` - Result object
**Category**: async

| Param | Type | Description |
| --- | --- | --- |
| source | `String` | source code |
| fn | `String` | function name |
| callValue | `String` | result call data |
| callResult | `String` | result status |
| options | | |
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| source | `String` | | source code |
| fn | `String` | | function name |
| callValue | `String` | | result call data |
| callResult | `String` | | result status |
| [options] | `Object` | <code>{}</code> | Options |
| [options.filesystem] | `Object` | <code>{}</code> | Contract external namespaces map |

**Example**
```js
const decodedData = await client.contractDecodeData(SourceCode ,'functionName', 'cb_asdasdasd...', 'ok|revert')lt
```
<a id="exp_module_@aeternity/aepp-sdk/es/ae/contract--contractCallStatic"></a>

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

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

| Param | Type | Description |
| --- | --- | --- |
| source | `String` | Contract source code |
| address | `String` | Contract address |
| name | `String` | Name of function to call |
| args | `Array` | Argument's for call function |
| options | `Object` | [options={}] Options |
| top | `String` | [options.top] Block hash on which you want to call contract |
| options | `String` | [options.options] Transaction options (fee, ttl, gas, amount, deposit) |
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| source | `String` | | Contract source code |
| address | `String` | | Contract address |
| name | `String` | | Name of function to call |
| args | `Array` | | Argument's for call function |
| [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 |

**Example**
```js
Expand All @@ -142,20 +147,20 @@ const callResult = await client.contractCallStatic(source, address, fnName, args
```
<a id="exp_module_@aeternity/aepp-sdk/es/ae/contract--contractCall"></a>

### contractCall(source, address, name, args, options) ⇒ `Promise.&lt;Object&gt;`
### contractCall(source, address, name, args, [options])
Call contract function

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

| Param | Type | Description |
| --- | --- | --- |
| source | `String` | Contract source code |
| address | `String` | Contract address |
| name | `String` | Name of function to call |
| args | `Array` | Argument's for call function |
| options | `Object` | Transaction options (fee, ttl, gas, amount, deposit) |
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| source | `String` | | Contract source code |
| address | `String` | | Contract address |
| name | `String` | | Name of function to call |
| args | `Array` | | Argument's 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 |

**Example**
```js
Expand All @@ -168,19 +173,20 @@ const callResult = await client.contractCall(source, address, fnName, args = [],
```
<a id="exp_module_@aeternity/aepp-sdk/es/ae/contract--contractDeploy"></a>

### contractDeploy(code, source, initState, options) ⇒ `Promise.&lt;Object&gt;`
### contractDeploy(code, source, initState, [options]) ⇒ `Promise.&lt;Object&gt;`
Deploy contract to the node

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

| Param | Type | Description |
| --- | --- | --- |
| code | `String` | Compiled contract |
| source | `String` | Contract source code |
| initState | `Array` | Arguments of contract constructor(init) function |
| options | `Object` | Transaction options (fee, ttl, gas, amount, deposit) |
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| code | `String` | | Compiled contract |
| source | `String` | | Contract source code |
| initState | `Array` | | Arguments of contract constructor(init) 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 |

**Example**
```js
Expand All @@ -197,17 +203,18 @@ const deployed = await client.contractDeploy(bytecode, source, init = [], option
```
<a id="exp_module_@aeternity/aepp-sdk/es/ae/contract--contractCompile"></a>

### contractCompile(source, options) ⇒ `Promise.&lt;Object&gt;`
### contractCompile(source, [options]) ⇒ `Promise.&lt;Object&gt;`
Compile contract source code

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

| Param | Type | Description |
| --- | --- | --- |
| source | `String` | Contract sourece code |
| options | `Object` | Transaction options (fee, ttl, gas, amount, deposit) |
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| source | `String` | | Contract sourece code |
| [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 |

**Example**
```js
Expand Down
84 changes: 57 additions & 27 deletions docs/api/contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import ContractBase from '@aeternity/aepp-sdk/es/contract'

* [@aeternity/aepp-sdk/es/contract](#module_@aeternity/aepp-sdk/es/contract)
* [ContractBase([options])](#exp_module_@aeternity/aepp-sdk/es/contract--ContractBase) ⇒ `Object` ⏏
* *[.contractEncodeCallDataAPI(source, name, args)](#module_@aeternity/aepp-sdk/es/contract--ContractBase+contractEncodeCallDataAPI) ⇒ `String`*
* *[.contractGetACI(source, [options])](#module_@aeternity/aepp-sdk/es/contract--ContractBase+contractGetACI) ⇒ `Object`*
* *[.contractEncodeCallDataAPI(source, name, args, [options])](#module_@aeternity/aepp-sdk/es/contract--ContractBase+contractEncodeCallDataAPI) ⇒ `String`*
* *[.contractDecodeDataAPI(type, data)](#module_@aeternity/aepp-sdk/es/contract--ContractBase+contractDecodeDataAPI) ⇒ `String`*
* *[.contractDecodeCallResultAPI(source, fn, callValue, callResult)](#module_@aeternity/aepp-sdk/es/contract--ContractBase+contractDecodeCallResultAPI) ⇒ `String`*
* *[.contractDecodeCallDataBySourceAPI(source, function, callData)](#module_@aeternity/aepp-sdk/es/contract--ContractBase+contractDecodeCallDataBySourceAPI) ⇒ `String`*
* *[.contractDecodeCallDataByCodeAPI(code, callData)](#module_@aeternity/aepp-sdk/es/contract--ContractBase+contractDecodeCallDataByCodeAPI) ⇒ `String`*
* *[.contractDecodeCallResultAPI(source, fn, callValue, callResult, [options])](#module_@aeternity/aepp-sdk/es/contract--ContractBase+contractDecodeCallResultAPI) ⇒ `String`*
* *[.contractDecodeCallDataBySourceAPI(source, function, callData, [options])](#module_@aeternity/aepp-sdk/es/contract--ContractBase+contractDecodeCallDataBySourceAPI) ⇒ `String`*
* *[.contractDecodeCallDataByCodeAPI(code, callData, backend)](#module_@aeternity/aepp-sdk/es/contract--ContractBase+contractDecodeCallDataByCodeAPI) ⇒ `String`*
* *[.compileContractAPI(code, [options])](#module_@aeternity/aepp-sdk/es/contract--ContractBase+compileContractAPI) ⇒ `Object`*
* *[.setCompilerUrl(url)](#module_@aeternity/aepp-sdk/es/contract--ContractBase+setCompilerUrl) ⇒ `void`*
* *[.getCompilerVersion()](#module_@aeternity/aepp-sdk/es/contract--ContractBase+getCompilerVersion) ⇒ `String`*
Expand All @@ -36,21 +37,41 @@ abstract methods using composition will result in an exception.
| --- | --- | --- | --- |
| [options] | `Object` | <code>{}</code> | Initializer object |

<a id="module_@aeternity/aepp-sdk/es/contract--ContractBase+contractGetACI"></a>

#### *contractBase.contractGetACI(source, [options]) ⇒ `Object`*
Get contract ACI

**Kind**: instance abstract method of [`ContractBase`](#exp_module_@aeternity/aepp-sdk/es/contract--ContractBase)
**Returns**: `Object` - - Contract aci object
**Category**: async
**rtype**: `(source: String, options: Array) => aciObject: Promise[Object]`

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| source | `String` | | Contract source code |
| [options] | `Object` | <code>{}</code> | Options |
| [options.filesystem] | `Object` | | Contract external namespaces map |
| [options.backend] | `Object` | | Contract vm(default: aevm) |

<a id="module_@aeternity/aepp-sdk/es/contract--ContractBase+contractEncodeCallDataAPI"></a>

#### *contractBase.contractEncodeCallDataAPI(source, name, args) ⇒ `String`*
#### *contractBase.contractEncodeCallDataAPI(source, name, args, [options]) ⇒ `String`*
Encode contract data

**Kind**: instance abstract method of [`ContractBase`](#exp_module_@aeternity/aepp-sdk/es/contract--ContractBase)
**Returns**: `String` - - Contract encoded data
**Category**: async
**rtype**: `(source: String, name: String, args: Array) => callData: Promise[String]`
**rtype**: `(source: String, name: String, args: Array, options: Array) => callData: Promise[String]`

| Param | Type | Description |
| --- | --- | --- |
| source | `String` | Contract source code |
| name | `String` | Function name |
| args | `Array` | Function argument's |
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| source | `String` | | Contract source code |
| name | `String` | | Function name |
| args | `Array` | | Function argument's |
| [options] | `Object` | <code>{}</code> | Options |
| [options.filesystem] | `Object` | | Contract external namespaces map |
| [options.backend] | `Object` | | Contract vm(default: aevm) |

<a id="module_@aeternity/aepp-sdk/es/contract--ContractBase+contractDecodeDataAPI"></a>

Expand All @@ -69,40 +90,46 @@ Decode data

<a id="module_@aeternity/aepp-sdk/es/contract--ContractBase+contractDecodeCallResultAPI"></a>

#### *contractBase.contractDecodeCallResultAPI(source, fn, callValue, callResult) ⇒ `String`*
#### *contractBase.contractDecodeCallResultAPI(source, fn, callValue, callResult, [options]) ⇒ `String`*
Decode contract call result data

**Kind**: instance abstract method of [`ContractBase`](#exp_module_@aeternity/aepp-sdk/es/contract--ContractBase)
**Returns**: `String` - - Decoded contract call result
**Category**: async
**rtype**: `(source: String, fn: String, callValue: String, callResult: String) => decodedResult: Promise[String]`
**rtype**: `(source: String, fn: String, callValue: String, callResult: String, options: Array) => decodedResult: Promise[String]`

| Param | Type | Description |
| --- | --- | --- |
| source | `String` | Contract source |
| fn | `String` | Fn name |
| callValue | `String` | result data (cb_das...) |
| callResult | `String` | contract call result status('ok', 'revert', ...) |
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| source | `String` | | Contract source |
| fn | `String` | | Fn name |
| callValue | `String` | | result data (cb_das...) |
| callResult | `String` | | contract call result status('ok', 'revert', ...) |
| [options] | `Object` | <code>{}</code> | Options |
| [options.filesystem] | `Object` | | Contract external namespaces map |
| [options.backend] | `Object` | | Contract vm(default: aevm) |

<a id="module_@aeternity/aepp-sdk/es/contract--ContractBase+contractDecodeCallDataBySourceAPI"></a>

#### *contractBase.contractDecodeCallDataBySourceAPI(source, function, callData) ⇒ `String`*
#### *contractBase.contractDecodeCallDataBySourceAPI(source, function, callData, [options]) ⇒ `String`*
Decode call data by source

**Kind**: instance abstract method of [`ContractBase`](#exp_module_@aeternity/aepp-sdk/es/contract--ContractBase)
**Returns**: `String` - - Decoded contract call data
**Category**: async
**rtype**: `(source: String, function: String, callData: String) => decodedResult: Promise[String]`
**rtype**: `(source: String, function: String, callData: String, options: Array) => decodedResult: Promise[String]`

| Param | Type | Description |
| --- | --- | --- |
| source | `String` | contract source |
| function | `String` | function name |
| callData | `String` | Encoded contract call data |
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| source | `String` | | contract source |
| function | `String` | | function name |
| callData | `String` | | Encoded contract call data |
| [options] | `Object` | <code>{}</code> | Options |
| [options.filesystem] | `Object` | | Contract external namespaces map |
| [options.backend] | `Object` | | Contract vm(default: aevm) |

<a id="module_@aeternity/aepp-sdk/es/contract--ContractBase+contractDecodeCallDataByCodeAPI"></a>

#### *contractBase.contractDecodeCallDataByCodeAPI(code, callData) ⇒ `String`*
#### *contractBase.contractDecodeCallDataByCodeAPI(code, callData, backend) ⇒ `String`*
Decode call data by bytecode

**Kind**: instance abstract method of [`ContractBase`](#exp_module_@aeternity/aepp-sdk/es/contract--ContractBase)
Expand All @@ -114,6 +141,7 @@ Decode call data by bytecode
| --- | --- | --- |
| code | `String` | contract byte code |
| callData | `String` | Encoded contract call data |
| backend | `String` | Contract vm(default: aevm) |

<a id="module_@aeternity/aepp-sdk/es/contract--ContractBase+compileContractAPI"></a>

Expand All @@ -129,6 +157,8 @@ Compile contract
| --- | --- | --- | --- |
| code | `String` | | Contract source code |
| [options] | `Object` | <code>{}</code> | Options |
| [options.filesystem] | `Object` | | Contract external namespaces map |
| [options.backend] | `Object` | | Contract vm(default: aevm) |

<a id="module_@aeternity/aepp-sdk/es/contract--ContractBase+setCompilerUrl"></a>

Expand Down
15 changes: 8 additions & 7 deletions docs/api/contract/aci.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,14 @@ Generate contract ACI object with predefined js methods for contract usage - can
**Kind**: Exported function
**Returns**: `ContractInstance` - JS Contract API

| Param | Type | Description |
| --- | --- | --- |
| source | `String` | Contract source code |
| [options] | `Object` | Options object |
| [options.aci] | `Object` | Contract ACI |
| [options.contractAddress] | `Object` | Contract address |
| [options.opt] | `Object` | Contract options |
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| source | `String` | | Contract source code |
| [options] | `Object` | <code>{}</code> | Options object |
| [options.aci] | `Object` | | Contract ACI |
| [options.contractAddress] | `Object` | | Contract address |
| [options.filesystem] | `Object` | | Contact source external namespaces map |
| [options.opt] | `Object` | | Contract options |

**Example**
```js
Expand Down
Loading