diff --git a/avail-js/docs/extrinsics/README.md b/avail-js/docs/extrinsics/README.md index 03ce1231a..18773ad60 100644 --- a/avail-js/docs/extrinsics/README.md +++ b/avail-js/docs/extrinsics/README.md @@ -1,32 +1,33 @@ -# Data Availability +# Balances -Runtime Component: DataAvailability\ -Runtime Index: 29\ -Interface Module Name: dataAvailability +Runtime Component: Balances\ +Runtime Index: 6\ +Interface Module Name: balances -## Create Application Key +## Transfer All Origin Level: Signed ### Interface ```js -function createApplicationKey(key: string, waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function transferAll(dest: string, keepAlive: boolean, waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise>; ``` #### Parameters -| parameter | type | optional | description | -| --------- | ------------- | -------- | ----------------------------------------------- | -| key | string | false | name of the application key | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| --------- | ------------------ | -------- | ------------------------------------------------------------- | +| dest | string | false | Account that will receive funds | +| keepAlive | boolean | false | if set to false it will reap the account as well | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring } from "avail-js-sdk" +import { SDK, WaitFor, Keyring } from "../../src/index" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -34,16 +35,16 @@ const main = async () => { // Input const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") - const key = "MyAwesomeKey" + const dest = "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw" // Eve + const keepAlive = true - const result = await sdk.tx.dataAvailability.createApplicationKey(key, WaitFor.BlockInclusion, account) + const result = await sdk.tx.balances.transferAll(dest, keepAlive, WaitFor.BlockInclusion, account) if (result.isErr()) { console.log(result.error.reason) process.exit(1) } console.log(JSON.stringify(result.value, null, 2)) - process.exit() } main() @@ -57,47 +58,49 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `CreateApplicationKeyTxSuccess`. +If the operation is successful, the function will return a object of type `TransferAllTx`. -```js +```json { - "isErr": false, "event": { - "key": "0x4d79417765736f6d654b6579", - "owner": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", - "id": "10" + "from": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + "to": "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw", + "amount": "9999999873433871068464733" }, - "events": [...], - "txHash": "0x5ae9edbd2a2da96eeffc14cf9050d711082890fa6bfb8749ad2c4947565f3bd2", - "txIndex": 1, - "blockHash": "0x152338c1b0696d12664cf3d4c159af3d54beca151ba1ea8b00989a66dc8050b0", - "blockNumber": 1 + "details": { + "txResult": {...}, + "events": [...], + "txHash": "0x48b0e56ad89280f9a94d1f1ab48af2a9cf25fe4c9b41b916e0efa983fa5726c4", + "txIndex": 1, + "blockHash": "0x3a4fe6a2618db91cd1786f853c6c0548bcefa15849c810a37bbfcfb7eedb5b7f", + "blockNumber": 2 + } } ``` -## Submit Data +## Transfer All No Wait Origin Level: Signed ### Interface ```js -function submitData(data: string, waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function transferAllNoWait(dest: string, keepAlive: boolean, account: KeyringPair, options?: TransactionOptions): Promise; ``` #### Parameters -| parameter | type | optional | description | -| --------- | ------------- | -------- | ----------------------------------------------- | -| data | string | false | data to be submitted | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| --------- | ------------------ | -------- | ------------------------------------------------------------- | +| dest | string | false | Account that will receive funds | +| keepAlive | boolean | false | if set to false it will reap the account as well | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring } from "avail-js-sdk" +import { SDK, Keyring } from "../../src/index" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -105,9 +108,60 @@ const main = async () => { // Input const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") - const data = "My Awesome Data" + const dest = "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw" // Eve + const keepAlive = true + + const txHash = await sdk.tx.balances.transferAllNoWait(dest, keepAlive, account) + + console.log(txHash) + process.exit() +} +main() +``` + +### Example Output + +The function will return a object of type `H256`. + +```json +"0x3481a87e6ebfd2af2fad83fb0305c93e8cf59b6eacc7fdc37d3cf4a6ab0929b1" +``` + +## Transfer Allow Death + +Origin Level: Signed + +### Interface + +```js +function transferAllowDeath(dest: string, value: BN, waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise>; +``` + +#### Parameters + +| parameter | type | optional | description | +| --------- | ------------------ | -------- | ------------------------------------------------------------- | +| dest | string | false | Account that will receive funds | +| value | BN | false | Amount that is send. 10^18 is equal to 1 AVL | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | + +### Minimal Example + +```js +import { SDK, WaitFor, Keyring } from "../../src/index" + +const main = async () => { + const providerEndpoint = "ws://127.0.0.1:9944" + const sdk = await SDK.New(providerEndpoint) + + // Input + const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") + const dest = "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw" // Eve + const amount = SDK.oneAvail() - const result = await sdk.tx.dataAvailability.submitData(data, WaitFor.BlockInclusion, account) + const result = await sdk.tx.balances.transferAllowDeath(dest, amount, WaitFor.BlockInclusion, account) if (result.isErr()) { console.log(result.error.reason) process.exit(1) @@ -127,50 +181,49 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `SubmitDataTxSuccess`. +If the operation is successful, the function will return a object of type `TransferAllowDeathTx`. -```js +```json { - "isErr": false, - "txData": { - "data": "4d7920417765736f6d652044617461" - }, "event": { - "who": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", - "dataHash": "0x8846d900ea89aab9bce96402846c0ac74a853acc00cb99ff5ddb1a0f052594bd" + "from": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + "to": "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw", + "amount": "1000000000000000000" }, - "events": [...], - "txHash": "0xec6f9fd5e002c9ddbcd24764380f57a014de7f2007cc0e2ae11a4dda17ab8062", - "txIndex": 1, - "blockHash": "0x043c2b88ff960f2f7042521b55a943676938948febefe8684022b524795340d9", - "blockNumber": 9 + "details": { + "txResult": {...}, + "events": [...], + "txHash": "0x03218ef4ef981238f31ff83d369bbb020b5f3fd30a1009c42993c99069062731", + "txIndex": 1, + "blockHash": "0xf2f47bb6093e56a22bd23ff39c320e2c1282d397045240921546fd4dfe49fc49", + "blockNumber": 3 + } } ``` -## Submit Block Length Proposal +## Transfer Allow Death No Wait -Origin Level: Root +Origin Level: Signed ### Interface ```js -function submitBlockLengthProposal(rows: number, cols: number, waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function transferAllowDeathNoWait(dest: string, value: BN, account: KeyringPair, options?: TransactionOptions): Promise; ``` #### Parameters -| parameter | type | optional | description | -| --------- | ------------- | -------- | ----------------------------------------------- | -| rows | number | false | number of rows in block | -| cols | number | false | number of cols in block | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| --------- | ------------------ | -------- | ------------------------------------------------------------- | +| dest | string | false | Account that will receive funds | +| value | BN | false | Amount that is send. 10^18 is equal to 1 AVL | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring } from "avail-js-sdk" +import { SDK, Keyring } from "../../src/index" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -178,17 +231,12 @@ const main = async () => { // Input const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") - const rows = 128 - const cols = 128 - - const result = await sdk.tx.dataAvailability.submitBlockLengthProposal(rows, cols, WaitFor.BlockInclusion, account) - if (result.isErr()) { - console.log(result.error.reason) - process.exit(1) - } + const dest = "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw" // Eve + const amount = SDK.oneAvail() - console.log(JSON.stringify(result.value, null, 2)) + const txHash = await sdk.tx.balances.transferAllowDeathNoWait(dest, amount, account) + console.log(JSON.stringify(txHash, null, 2)) process.exit() } main() @@ -196,42 +244,36 @@ main() ### Example Output -#### On Failure - -If the operation fails, the function will return an error message indicating the nature of the issue. - -#### On Success - -If the operation is successful, the function will return a object of type `SubmitBlockLengthProposalTxSuccess`. - -```js +The function will return a object of type `H256`. +```json +"0x7ee1ba58c7e71a3222850e01d8fd3661b97935f38d959d0ad704ad632bd7e6b5" ``` -## Set Application Key +## Transfer Keep Alive -Origin Level: Root +Origin Level: Signed ### Interface ```js -function setApplicationKey(oldKey: string, newKey: string, waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function transferKeepAlive(dest: string, value: BN, waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise>; ``` #### Parameters -| parameter | type | optional | description | -| --------- | ------------- | -------- | ----------------------------------------------- | -| oldKey | string | false | application key to be replaced | -| newKey | string | false | application key that will replace the old one | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| --------- | ------------------ | -------- | ------------------------------------------------------------- | +| dest | string | false | Account that will receive funds | +| value | BN | false | Amount that is send. 10^18 is equal to 1 AVL | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring } from "avail-js-sdk" +import { SDK, WaitFor, Keyring } from "../../src/index" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -239,17 +281,16 @@ const main = async () => { // Input const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") - const oldKey = "MyNewKeyAwesome1" - const newKey = "MyNewKeyAwesome2" + const dest = "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw" // Eve + const amount = SDK.oneAvail() - const result = await sdk.tx.dataAvailability.setApplicationKey(oldKey, newKey, WaitFor.BlockInclusion, account) + const result = await sdk.tx.balances.transferKeepAlive(dest, amount, WaitFor.BlockInclusion, account) if (result.isErr()) { console.log(result.error.reason) process.exit(1) } console.log(JSON.stringify(result.value, null, 2)) - process.exit() } main() @@ -263,35 +304,104 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `SetApplicationKeyTxSuccess`. +If the operation is successful, the function will return a object of type `TransferKeepAliveTx`. + +```json +{ + "event": { + "from": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + "to": "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw", + "amount": "1000000000000000000" + }, + "details": { + "txResult": {...}, + "events": [...], + "txHash": "0x84a745ebb9642dcf382935c882519bfa6b957898365fb56a3499543d157e4b08", + "txIndex": 1, + "blockHash": "0x79e32fd8129d052b90f2c01c60c5c81e08fe461bdef1d403712df20cee5b6303", + "blockNumber": 56 + } +} +``` + +## Transfer Keep Alive No Wait + +Origin Level: Signed + +### Interface + +```js +function transferKeepAliveNoWait(dest: string, value: BN, account: KeyringPair, options?: TransactionOptions): Promise; +``` + +#### Parameters + +| parameter | type | optional | description | +| --------- | ------------------ | -------- | ------------------------------------------------------------- | +| dest | string | false | Account that will receive funds | +| value | BN | false | Amount that is send. 10^18 is equal to 1 AVL | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | + +### Minimal Example ```js +import { SDK, Keyring } from "../../src/index" + +const main = async () => { + const providerEndpoint = "ws://127.0.0.1:9944" + const sdk = await SDK.New(providerEndpoint) + // Input + const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") + const dest = "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw" // Eve + const amount = SDK.oneAvail() + + const txHash = await sdk.tx.balances.transferKeepAliveNoWait(dest, amount, account) + + console.log(JSON.stringify(txHash, null, 2)) + process.exit() +} +main() ``` -## Set Submit Data Fee Modifier +### Example Output + +The function will return a object of type `H256`. + +```json +"0xa6700ad4a056b9096c940e464b41acc7ac13c4df9ea5e214a3549794916d789a" +``` + +# Data Availability + +Runtime Component: DataAvailability\ +Runtime Index: 29\ +Interface Module Name: dataAvailability -Origin Level: Root +## Create Application Key + +Origin Level: Signed ### Interface ```js -function setSubmitDataFeeModifier(modifier: DispatchFeeModifier, waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function createApplicationKey(key: string, waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise>; ``` #### Parameters -| parameter | type | optional | description | -| --------- | ------------------- | -------- | ----------------------------------------------- | -| modifier | DispatchFeeModifier | false | new fee modifier values | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| --------- | ------------------ | -------- | ------------------------------------------------------------- | +| key | string | false | name of the application key | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring, BN, sdkTransactions } from "avail-js-sdk" +import { SDK, WaitFor, Keyring } from "../../src/index" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -299,19 +409,15 @@ const main = async () => { // Input const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") - const modifier = { - weightMaximumFee: new BN("10").pow(new BN("18")), - weightFeeDivider: 20, - } as sdkTransactions.DispatchFeeModifier + const key = "MyAwesomeKey" - const result = await sdk.tx.dataAvailability.setSubmitDataFeeModifier(modifier, WaitFor.BlockInclusion, account) + const result = await sdk.tx.dataAvailability.createApplicationKey(key, WaitFor.BlockInclusion, account) if (result.isErr()) { console.log(result.error.reason) process.exit(1) } console.log(JSON.stringify(result.value, null, 2)) - process.exit() } main() @@ -325,55 +431,96 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `SetSubmitDataFeeModifierTxSuccess`. - -```js +If the operation is successful, the function will return a object of type `CreateApplicationKeyTx`. +```json +{ + "event": { + "key": "0x4d79417765736f6d654b6579", + "owner": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + "id": "10" + }, + "details": { + "txResult": {...}, + "events": [...], + "txHash": "0x8bb6e5167bb0808a0e12236ed89aba5b8147737e2f4e35580cc157a5a17f8ae3", + "txIndex": 1, + "blockHash": "0xba5cdf11ad6847617d58d16d931436a5e1fba2191bb50f08912107dcd8440189", + "blockNumber": 94 + } +} ``` -## Type Definitions +## Create Application Key No Wait + +Origin Level: Signed + +### Interface ```js -enum WaitFor { - BlockInclusion, - BlockFinalization, -} +function createApplicationKeyNoWait(key: string, account: KeyringPair, options?: TransactionOptions): Promise; ``` +#### Parameters + +| parameter | type | optional | description | +| --------- | ------------------ | -------- | ------------------------------------------------------------- | +| key | string | false | name of the application key | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | + +### Minimal Example + ```js -type DispatchFeeModifier = { weightMaximumFee: BN | null, weightFeeDivider: number | null, weightFeeMultiplier: number | null }; +import { SDK, Keyring } from "../../src/index" + +const main = async () => { + const providerEndpoint = "ws://127.0.0.1:9944" + const sdk = await SDK.New(providerEndpoint) + + // Input + const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") + const key = "MyAwesomeKey" + + const txHash = await sdk.tx.dataAvailability.createApplicationKeyNoWait(key, account) + + console.log(JSON.stringify(txHash, null, 2)) + process.exit() +} +main() ``` -# Balances +### Example Output -Runtime Component: Balances\ -Runtime Index: 6\ -Interface Module Name: balances +The function will return a object of type `H256`. -## Transfer Keep Alive +```json +"0x8d523a3b36327651bb11e619d8a1fceaa205cb414b411e6cd00116272278042e" +``` + +## Submit Data Origin Level: Signed ### Interface ```js -function transferKeepAlive(dest: string, value: BN, waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function submitData(data: string | Bytes, waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise>; ``` #### Parameters -| parameter | type | optional | description | -| --------- | ------------- | -------- | ----------------------------------------------- | -| dest | string | false | account that will receive funds | -| value | BN | false | amount that is send. 10^18 is equal to 1 AVL | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| --------- | ------------------ | -------- | ------------------------------------------------------------- | +| data | string | false | data to be submitted | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk" +import { SDK, WaitFor, Keyring, TransactionOptions } from "../../src/index" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -381,17 +528,16 @@ const main = async () => { // Input const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") - const dest = "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw" // Eve - const amount = new BN(10).pow(new BN(18)) // one Avail + const data = "My Awesome Data" - const result = await sdk.tx.balances.transferKeepAlive(dest, amount, WaitFor.BlockInclusion, account) + const options: TransactionOptions = { app_id: 1 } + const result = await sdk.tx.dataAvailability.submitData(data, WaitFor.BlockInclusion, account, options) if (result.isErr()) { console.log(result.error.reason) process.exit(1) } console.log(JSON.stringify(result.value, null, 2)) - process.exit() } main() @@ -405,48 +551,50 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `TransferKeepAliveTxSuccess`. +If the operation is successful, the function will return a object of type `SubmitDataTx`. -```js +```json { - "isErr": false, + "txData": { + "data": "4d7920417765736f6d652044617461" + }, "event": { - "from": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", - "to": "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw", - "amount": "1000000000000000000" + "who": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + "dataHash": "0x8846d900ea89aab9bce96402846c0ac74a853acc00cb99ff5ddb1a0f052594bd" }, - "events": [...], - "txHash": "0x812a3f3960afb8df72de0e5b86ff564c8ce7d93c837182c24d1796fb68a7f5f4", - "txIndex": 1, - "blockHash": "0xfdee1faced02696d692df1d896fa2822f4eb02f260c95e11041df86b2c229dfb", - "blockNumber": 1 + "details": { + "txResult": {...}, + "events": [...], + "txHash": "0xc189150ae2a0ebe6df1ec20b8096bbffc44e2ec5c56045049ab92e3e0a781565", + "txIndex": 1, + "blockHash": "0x0221659ca85a47bb11a8926c52e9273b908193a2420644c59f65d9da3754535a", + "blockNumber": 2 + } } ``` -## Transfer Allow Death +## Submit Data No Wait Origin Level: Signed ### Interface ```js -function transferAllowDeath(dest: string, value: BN, waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function submitDataNoWait(data: string | Bytes, account: KeyringPair, options?: TransactionOptions): Promise; ``` #### Parameters -| parameter | type | optional | description | -| --------- | ------------- | -------- | ----------------------------------------------- | -| dest | string | false | account that will receive funds | -| value | BN | false | amount that is send. 10^18 is equal to 1 AVL | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| --------- | ------------------ | -------- | ------------------------------------------------------------- | +| data | string | false | data to be submitted | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk" +import { SDK, Keyring, TransactionOptions } from "../../src/index" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -454,17 +602,102 @@ const main = async () => { // Input const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") - const dest = "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw" // Eve - const amount = new BN(10).pow(new BN(18)) // one Avail + const data = "My Awesome Data" - const result = await sdk.tx.balances.transferAllowDeath(dest, amount, WaitFor.BlockInclusion, account) + const options: TransactionOptions = { app_id: 1 } + const txHash = await sdk.tx.dataAvailability.submitDataNoWait(data, account, options) + + console.log(JSON.stringify(txHash, null, 2)) + process.exit() +} +main() +``` + +### Example Output + +#### On Failure + +If the operation fails, the function will return an error message indicating the nature of the issue. + +#### On Success + +If the operation is successful, the function will return a object of type `SubmitDataTx`. + +```json +"0x8643a0f94f1928eb542aaa44aacf943c7fe50ab4949c53a934debf006049bc7e" +``` + +# Multisig + +Runtime Component: Multisig\ +Runtime Index: 34\ +Interface Module Name: multisig + +## Approving As Multi + +Origin Level: Signed + +### Interface + +```js +function approveAsMulti(threshold: number, otherSignatures: string[], timepoint: MultisigTimepoint | null, callHash: string, maxWeight: Weight, waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise>; +``` + +#### Parameters + +| parameter | type | optional | description | +| --------------- | ------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| threshold | number | false | The total number of approvals for this dispatch before it is executed. | +| otherSignatures | string[] | false | The accounts (other than the sender) who can approve this dispatch. May not be empty. | +| timepoint | MultisigTimepoint or null | false | If this is the first approval, then this must be `None`. If it is not the first approval, then it must be `Some`, with the timepoint (block number and transaction index) of the first approval transaction. | +| callHash | string | false | The hash of the call to be executed | +| maxWeight | Weight | false | This should be equal to the weight of the call | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | + +### Minimal Example + +```js +import { SDK, WaitFor, Keyring } from "./../../src/index" + +const main = async () => { + const providerEndpoint = "ws://127.0.0.1:9944" + const sdk = await SDK.New(providerEndpoint) + + // Multisig Signatures + const alice = new Keyring({ type: "sr25519" }).addFromUri("//Alice") + const bobAddress = "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty" + + // Create Multisig Account + const threshold = 2 + const multisigAddress = sdk.util.generateMultisig([alice.address, bobAddress], threshold) + + // Define what action will be taken by the multisig account + const amount = SDK.oneAvail() + const call = sdk.api.tx.balances.transferKeepAlive(multisigAddress, amount) + // Data needed for multisig approval and execution + const callHash = call.method.hash.toString() + const maxWeight = (await call.paymentInfo(alice.address)).weight + + // Create New Multisig + console.log("Alice is creating a Multisig Transaction...") + const call1signatures = sdk.util.sortMultisigAddresses([bobAddress]) + const result = await sdk.tx.multisig.approveAsMulti( + threshold, + call1signatures, + null, + callHash, + maxWeight, + WaitFor.BlockInclusion, + alice, + ) if (result.isErr()) { - console.log(result.error.reason) + console.log(result.error) process.exit(1) } console.log(JSON.stringify(result.value, null, 2)) - process.exit() } main() @@ -478,66 +711,92 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `TransferAllowDeathTxSuccess`. +If the operation is successful, the function will return a object of type `ApproveAsMultiTx`. -```js +```json { - "isErr": false, "event": { - "from": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", - "to": "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw", - "amount": "1000000000000000000" + "approving": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + "multisig": "5F3QVbS78a4aTYLiRAD8N3czjqVoNyV42L19CXyhqUMCh4Ch", + "callHash": "0x239258ef81456d5dbf5bf8a37709c7cf14c74ea7ed89961f47c7f3701de1e86b" }, - "events": [...], - "txHash": "0x63a73d2d1210ab9840341506788cca9592fd968609fecb5106cf0370c611061c", - "txIndex": 1, - "blockHash": "0xde2e95b63a4ca5927f9105931e4676b0634d12f524d4fff1048b403393419489", - "blockNumber": 2 + "details": { + "txResult": {...}, + "events": [...], + "txHash": "0x7beb1e4edb785c57533e0793f0d9051bbe6290e9551ee7e907d9c34ba9cad1a2", + "txIndex": 1, + "blockHash": "0xb23ef6eada32c5c19e75d3c0713c62ec88153613ceab70b28cac9ccd743e6b60", + "blockNumber": 103 + } } ``` -## Transfer All +## As Multi Origin Level: Signed ### Interface ```js -function transferAll(dest: string, keepAlive: boolean, waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function asMulti(threshold: number, otherSignatures: string[], timepoint: MultisigTimepoint | null, call: string, maxWeight: Weight, waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise>; ``` #### Parameters -| parameter | type | optional | description | -| --------- | ------------- | -------- | ------------------------------------------------ | -| dest | string | false | account that will receive funds | -| keepAlive | boolean | false | if set to false it will reap the account as well | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| --------------- | ------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| threshold | number | false | The total number of approvals for this dispatch before it is executed. | +| otherSignatures | string[] | false | The accounts (other than the sender) who can approve this dispatch. May not be empty. | +| timepoint | MultisigTimepoint or null | false | If this is the first approval, then this must be `None`. If it is not the first approval, then it must be `Some`, with the timepoint (block number and transaction index) of the first approval transaction. | +| call | string | false | The call to be executed. | +| maxWeight | Weight | false | This should be equal to the weight of the call | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring } from "avail-js-sdk" +import { SDK, WaitFor, Keyring, MultisigTimepoint } from "./../../src/index" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" const sdk = await SDK.New(providerEndpoint) - // Input - const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") - const dest = "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw" // Eve - const keepAlive = true - - const result = await sdk.tx.balances.transferAll(dest, keepAlive, WaitFor.BlockInclusion, account) - if (result.isErr()) { - console.log(result.error.reason) + // Multisig Signatures + const bob = new Keyring({ type: "sr25519" }).addFromUri("//Bob") + const aliceAddress = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" + + // Create Multisig Account + const threshold = 2 + const multisigAddress = sdk.util.generateMultisig([aliceAddress, bob.address], threshold) + + // Define what action will be taken by the multisig account + const amount = SDK.oneAvail() + const call = sdk.api.tx.balances.transferKeepAlive(multisigAddress, amount) + // Data needed for multisig approval and execution + const callData = call.unwrap().toHex() + const maxWeight = (await call.paymentInfo(aliceAddress)).weight + const timepoint: MultisigTimepoint = { height: 4, index: 1 } + + // Approving and executing Multisig transaction + console.log("Bob is approving and executing the existing Multisig Transaction...") + const call2signatures = sdk.util.sortMultisigAddresses([aliceAddress]) + const secondResult = await sdk.tx.multisig.asMulti( + threshold, + call2signatures, + timepoint, + callData, + maxWeight, + WaitFor.BlockInclusion, + bob, + ) + if (secondResult.isErr()) { + console.log(secondResult.error) process.exit(1) } - console.log(JSON.stringify(result.value, null, 2)) - + console.log(JSON.stringify(secondResult.value, null, 2)) process.exit() } main() @@ -551,54 +810,60 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `TransferAllTxSuccess`. +If the operation is successful, the function will return a object of type `AsMultiTx`. -```js +```json { - "isErr": false, "event": { - "from": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", - "to": "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw", - "amount": "9999999873433871068464733" + "approving": "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", + "timepoint": { + "height": 103, + "index": 1 + }, + "multisig": "5F3QVbS78a4aTYLiRAD8N3czjqVoNyV42L19CXyhqUMCh4Ch", + "callHash": "0x239258ef81456d5dbf5bf8a37709c7cf14c74ea7ed89961f47c7f3701de1e86b", + "result": "Ok" }, - "events": [...], - "txHash": "0x343d3e8890bd479b4619cb7b0f2dfa91b7b91c0cedc0646247215f85baf1f63e", - "txIndex": 1, - "blockHash": "0xaec4adfad11f8aa902e1a985abb62737fc02445072b168238a956c3a0d8820f2", - "blockNumber": 2 + "details": { + "txResult": {...}, + "events": [...], + "txHash": "0xada53aa3d7e7891404228c07251f51c86214143e57205be10b6f55b1dd63b933", + "txIndex": 1, + "blockHash": "0x84a33cb83078795f8be128835c5699f20a314119c8b6efa432cc626fa6ac8812", + "blockNumber": 150 + } } ``` -# Staking +# Nomination Pools -Runtime Component: Staking\ -Runtime Index: 10\ -Interface Module Name: staking +Runtime Component: Nomination Pools\ +Runtime Index: 36\ +Interface Module Name: nominationPools -## Bond +## Bond Extra Origin Level: Signed ### Interface ```js -function bond(value: BN, payee: StakingRewardDestination, waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function bondExtra(extra: BondExtra, waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise>; ``` #### Parameters -| parameter | type | optional | description | -| --------- | ------------------------ | -------- | ------------------------------------------------------- | -| value | BN | false | amount that is bond. 10^18 is equal to 1 AVL | -| payee | StakingRewardDestination | false | Can be: "Staked", "Stash", "None" or an account address | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| --------- | ------------------ | -------- | ------------------------------------------------------------------------------------------------------ | +| extra | BondExtra | false | Additional funds can come from either the free balance of the account, of from the accumulated rewards | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk" +import { SDK, WaitFor, Keyring, BondExtra, BN } from "../../src/index" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -606,17 +871,16 @@ const main = async () => { // Input const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") - const value = new BN(100_000).mul(new BN(10).pow(new BN("18"))) // 100 000 Avail - const payee = "Staked" + const amount = SDK.oneAvail().mul(new BN(10000)) // 10_000 Avail + const bondExtra = { FreeBalance: amount } as BondExtra - const result = await sdk.tx.staking.bond(value, payee, WaitFor.BlockInclusion, account) + const result = await sdk.tx.nominationPools.bondExtra(bondExtra, WaitFor.BlockInclusion, account) if (result.isErr()) { console.log(result.error.reason) process.exit(1) } console.log(JSON.stringify(result.value, null, 2)) - process.exit() } main() @@ -630,63 +894,66 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `BondTxSuccess`. +If the operation is successful, the function will return a object of type `BondExtraTx`. -```js +```json { - "isErr": false, "event": { - "stash": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", - "amount": "100000" + "member": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + "poolId": "1", + "bonded": "10000000000000000000000", + "joined": "false" }, - "events": [...], - "txHash": "0x3e1cc48207b02ca5d680cf1beeb270ce7cbf0d18a6191844bc963d4081a0ca90", - "txIndex": 1, - "blockHash": "0xf854e74cb428d0baf22454cb15007731a84263e57c64d019a304c0ca1bd30276", - "blockNumber": 2 + "details": { + "txResult": {...}, + "events": [...], + "txHash": "0xc09bdfbc1703763850a2f4255ccb0dd7d7e9f4b793d2f9f05782b9e3c63682d9", + "txIndex": 1, + "blockHash": "0xe06e35e61e2b59900e22d627dd8cd9cab39c87a304a40aba0fce87936e921843", + "blockNumber": 112 + } } ``` -## Bond Extra +## Chill Origin Level: Signed ### Interface ```js -function bondExtra(maxAdditional: BN, waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function chill(poolId: number, waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise>; ``` #### Parameters -| parameter | type | optional | description | -| ------------- | ------------- | -------- | ------------------------------------------------------- | -| maxAdditional | BN | false | additional amount that is bond. 10^18 is equal to 1 AVL | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| --------- | ------------------ | -------- | ------------------------------------------------------------- | +| poolId | number | false | pool id | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk" +import { SDK, WaitFor, Keyring } from "../../src/index" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" const sdk = await SDK.New(providerEndpoint) // Input - const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice//stash") - const maxAdditional = new BN(10).pow(new BN(18)) // one Avail + const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") + const poolId = 1 - const result = await sdk.tx.staking.bondExtra(maxAdditional, WaitFor.BlockInclusion, account) + const result = await sdk.tx.nominationPools.chill(poolId, WaitFor.BlockInclusion, account) if (result.isErr()) { console.log(result.error.reason) process.exit(1) } console.log(JSON.stringify(result.value, null, 2)) - process.exit() } main() @@ -700,60 +967,60 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `BondExtraTxSuccess`. +If the operation is successful, the function will return a object of type `ChillTx`. -```js +```json { - "isErr": false, - "event": { - "stash": "5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY", - "amount": "1" - }, - "events": [...], - "txHash": "0x940df5141925aeef2ab9aa767f6870689426de533f5f1d84b6d7be203e68ee77", - "txIndex": 1, - "blockHash": "0xc2a8375be07956586833f497a429ca2e29bafbb78ee5e051d5157df0ad5c8cb6", - "blockNumber": 7 + "details": { + "txResult": {...}, + "events": [...], + "txHash": "0x678fd95154114bb899598f8ef4413e3fdb5a90317a132d5a49f868ffb029cecf", + "txIndex": 1, + "blockHash": "0xa66f5eacd4c4294ba6679c868d90df11fccf5c85c773e8554856882ac64b4be7", + "blockNumber": 1106 + } } ``` -## Chill +## Claim Commission Origin Level: Signed ### Interface ```js -function chill(waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function claimCommission(poolId: number, waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise>; ``` #### Parameters -| parameter | type | optional | description | -| --------- | ------------- | -------- | ----------------------------------------------- | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| --------- | ------------------ | -------- | ------------------------------------------------------------- | +| poolId | number | false | pool id | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring } from "avail-js-sdk" +import { SDK, WaitFor, Keyring } from "../../src/index" + const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" const sdk = await SDK.New(providerEndpoint) // Input - const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice//stash") + const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") + const poolId = 1 - const result = await sdk.tx.staking.chill(WaitFor.BlockInclusion, account) + const result = await sdk.tx.nominationPools.claimCommission(poolId, WaitFor.BlockInclusion, account) if (result.isErr()) { console.log(result.error.reason) process.exit(1) } console.log(JSON.stringify(result.value, null, 2)) - process.exit() } main() @@ -767,61 +1034,64 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `ChillTxSuccess`. +If the operation is successful, the function will return a object of type `ClaimCommissionTx`. -```js +```json { - "isErr": false, "event": { - "stash": "5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY" + "poolId": "1", + "commission": "7652149502759813012" }, - "events": [...], - "txHash": "0x4572681f19af32fdfb4759c914697697b0e82fde48a5dd7e28c2b3a263772b0d", - "txIndex": 1, - "blockHash": "0xad2e5376f53e6257e7bc0c842e5b6952f1d4af6f7499319b2d1ab59bdd742628", - "blockNumber": 13 + "details": { + "txResult": {...}, + "events": [...], + "txHash": "0x52292c2af7c2505c0bd39f5f1308bc10d92db7117f1b9fec208dc778e0c49654", + "txIndex": 1, + "blockHash": "0xdceaa5b12517f9634ad568e355061e8e13a8af25074e8966381c92fcea214285", + "blockNumber": 418 + } } ``` -## Chill Other +## Claim Payout Other Origin Level: Signed ### Interface ```js -function chillOther(stash: string, waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function claimPayoutOther(other: string, waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise>; ``` #### Parameters -| parameter | type | optional | description | -| --------- | ------------- | -------- | ----------------------------------------------- | -| stash | string | false | address of stash account to chill | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| --------- | ------------------ | -------- | ------------------------------------------------------------- | +| other | &str | false | other account to claim payout | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring } from "avail-js-sdk" +import { SDK, WaitFor, Keyring } from "../../src/index" + const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" const sdk = await SDK.New(providerEndpoint) // Input - const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice//stash") - const stash = "5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY" // Alice Stash + const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") + const other = "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty" // Bob - const result = await sdk.tx.staking.chillOther(stash, WaitFor.BlockInclusion, account) + const result = await sdk.tx.nominationPools.claimPayoutOther(other, WaitFor.BlockInclusion, account) if (result.isErr()) { console.log(result.error.reason) process.exit(1) } console.log(JSON.stringify(result.value, null, 2)) - process.exit() } main() @@ -835,35 +1105,48 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `ChillOtherTxSuccess`. - -```js +If the operation is successful, the function will return a object of type `ClaimPayoutOtherTx`. +```json +{ + "event": { + "member": "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", + "poolId": "1", + "payout": "8198513381719500000" + }, + "details": { + "txResult": {...}, + "events": [...], + "txHash": "0xe14015b25afc66c4954dda18631b3fd5efaeba80989070ed12712ca312dbec40", + "txIndex": 1, + "blockHash": "0x3abde836ab66ac38bc3ca260f081d370f1c15094f43048423e0995170569a51a", + "blockNumber": 594 + } +} ``` -## Nominate +## Claim Payout Origin Level: Signed ### Interface ```js -function nominate(targets: string[], waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function claimPayout(waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise; ``` #### Parameters -| parameter | type | optional | description | -| --------- | ------------- | -------- | ----------------------------------------------- | -| targets | string[] | false | list od addresses to nominate | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| --------- | ------------------ | -------- | ------------------------------------------------------------- | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring } from "avail-js-sdk" +import { SDK, WaitFor, Keyring } from "../../src/index" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -871,19 +1154,14 @@ const main = async () => { // Input const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") - const targets = [ - "5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY", // Alice Stash - "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", // Bob - ] - const result = await sdk.tx.staking.nominate(targets, WaitFor.BlockInclusion, account) + const result = await sdk.tx.nominationPools.claimPayout(WaitFor.BlockInclusion, account) if (result.isErr()) { console.log(result.error.reason) process.exit(1) } console.log(JSON.stringify(result.value, null, 2)) - process.exit() } main() @@ -897,58 +1175,76 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `NominateTxSuccess`. +If the operation is successful, the function will return a object of type `ClaimPayoutTx`. -```js +```json { - "isErr": false, - "txData": { - "targets": [ - "5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY", - "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty" - ] + "event": { + "member": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + "poolId": "1", + "payout": "4008268787159890000" }, - "events": [...], - "txHash": "0x2f81a34f59d36eb7ada96ec1070358043026d7bd7cfb6fa5a532cc474190880b", - "txIndex": 1, - "blockHash": "0x49a57953aa2b2ba508f1c6991515309a0fe89723a79f3831f9a9263ba8c7baa4", - "blockNumber": 4 + "details": { + "txResult": {...}, + "events": [...], + "txHash": "0x15b50cb2a3885432811ba1417b7715e69e05b8d4dd8f7c9951f0b4f7a8ba5a61", + "txIndex": 1, + "blockHash": "0xdd24eca2111c6b7eea4a34c9bed02cfa6effde65c65c3dc66fb13c88e2fe6985", + "blockNumber": 426 + } } ``` -## Unbond +## Create with Pool Id Origin Level: Signed ### Interface ```js -function unbond(value: BN, waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function createWithPoolId(amount: BN, root: string, nominator: string, bouncer: string, poolId: number, waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise>; ``` #### Parameters -| parameter | type | optional | description | -| --------- | ------------- | -------- | ----------------------------------------------- | -| value | BN | false | amount of tokens to unbond | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| --------- | ------------------ | -------- | ------------------------------------------------------------- | +| amount | BN | false | The amount of funds to delegate to the pool | +| root | string | false | The account to set as [`PoolRoles::root`] | +| nominator | string | false | The account to set as the [`PoolRoles::nominator`] | +| bouncer | string | false | The account to set as the [`PoolRoles::bouncer`] | +| poolId | number | false | pool id | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk" +import { SDK, WaitFor, Keyring, BN } from "../../src/index" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" const sdk = await SDK.New(providerEndpoint) // Input - const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") - const value = new BN(10).pow(new BN(18)) // one Avail + const account = new Keyring({ type: "sr25519" }).addFromUri("//Bob") + const amount = SDK.oneAvail().mul(new BN(10000)) // 10_000 Avail - const result = await sdk.tx.staking.unbond(value, WaitFor.BlockInclusion, account) + const root: string = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" // Alice + const nominator: string = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" // Alice + const bouncer: string = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" // Alice + const poolId = 0 + + const result = await sdk.tx.nominationPools.createWithPoolId( + amount, + root, + nominator, + bouncer, + poolId, + WaitFor.BlockInclusion, + account, + ) if (result.isErr()) { console.log(result.error.reason) process.exit(1) @@ -968,47 +1264,57 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `UnbondTxSuccess`. +If the operation is successful, the function will return a object of type `CreateWithPoolIdTx`. -```js +```json { - "isErr": false, "event": { - "stash": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", - "amount": "1000000000000000000" + "depositor": "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", + "poolId": "0" + }, + "event2": { + "member": "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", + "poolId": "0", + "bonded": "10000", + "joined": "true" }, - "events": [...], - "txHash": "0xbf264e0e95885fd64a35d5c64bd4e1cc17056a1e6b05fa9207d7c777395dffdf", - "txIndex": 1, - "blockHash": "0x9ef43aaca71ba7b91a53976de5170f80d8a1ed4fe3e95fae237f7ed91f953963", - "blockNumber": 9 + "details": { + "txResult": {...}, + "events": [...], + "txHash": "0x6b50caed7950e67934cabbf88a1f7dc2e7e995ac608402f91a4db19be0da5c41", + "txIndex": 1, + "blockHash": "0xc06df7dbb1e404f54499f942479ddcffc92665c021ea07c2798fc2f354f403d3", + "blockNumber": 6 + } } ``` -## Validate +## Create Origin Level: Signed ### Interface ```js -function validate(commission: number, blocked: boolean, waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function create(amount: BN, root: string, nominator: string, bouncer: string, waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise>; ``` #### Parameters -| parameter | type | optional | description | -| ---------- | ------------- | -------- | ----------------------------------------------------- | -| commission | number | false | how much validator charge nominators in 0 - 100 range | -| blocked | boolean | false | whether or not this validator accepts nominations | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| --------- | ------------------ | -------- | ------------------------------------------------------------- | +| amount | BN | false | The amount of funds to delegate to the pool | +| root | string | false | The account to set as [`PoolRoles::root`] | +| nominator | string | false | The account to set as the [`PoolRoles::nominator`] | +| bouncer | string | false | The account to set as the [`PoolRoles::bouncer`] | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring } from "avail-js-sdk" +import { SDK, WaitFor, Keyring, BN } from "../../src/index" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -1016,17 +1322,19 @@ const main = async () => { // Input const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") - const commission = 5 // 5% - const blocked = false + const amount = SDK.oneAvail().mul(new BN(10000)) // 10_000 Avail - const result = await sdk.tx.staking.validate(commission, blocked, WaitFor.BlockInclusion, account) + const root: string = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" // Alice + const nominator: string = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" // Alice + const bouncer: string = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" // Alice + + const result = await sdk.tx.nominationPools.create(amount, root, nominator, bouncer, WaitFor.BlockInclusion, account) if (result.isErr()) { console.log(result.error.reason) process.exit(1) } console.log(JSON.stringify(result.value, null, 2)) - process.exit() } main() @@ -1040,70 +1348,66 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `ValidateTxSuccess`. +If the operation is successful, the function will return a object of type `PoolCreateTxSuccess`. -```js +```json { - "isErr": false, "event": { - "stash": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", - "commission": "50000000", - "blocked": "false" + "depositor": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + "poolId": "1" + }, + "event2": { + "member": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + "poolId": "1", + "bonded": "10000", + "joined": "true" }, - "events": [...], - "txHash": "0x31f047da16a350e32b832cc73d3351c8d5e5991625fde6e8c36fc45ebb9d2735", - "txIndex": 1, - "blockHash": "0xa7735804f52602d4b73e1dd7f718cf0ab5cc00d111c927a9f8a2b3d02b66e09a", - "blockNumber": 14 + "details": { + "txResult": {...}, + "events": [...], + "txHash": "0x9f019464c676682d9cbfb62814d019a85738e01b0ce92b18fa77878f80e16f66", + "txIndex": 1, + "blockHash": "0xdaa49f09b8c519bbd4c52ed05652d3de3f777afa3ac85db5c697cf705907e2d2", + "blockNumber": 5 + } } ``` -# Nomination Pools - -Runtime Component: Nomination Pools\ -Runtime Index: 36\ -Interface Module Name: nominationPools - -## Create +## Join Origin Level: Signed ### Interface ```js -function create(amount: BN, root: string, nominator: string, bouncer: string, waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function join(amount: BN, poolId: number, waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise>; ``` #### Parameters -| parameter | type | optional | description | -| --------- | ------------- | -------- | -------------------------------------------------- | -| amount | BN | false | The amount of funds to delegate to the pool | -| root | string | false | The account to set as [`PoolRoles::root`] | -| nominator | string | false | The account to set as the [`PoolRoles::nominator`] | -| bouncer | string | false | The account to set as the [`PoolRoles::bouncer`] | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| --------- | ------------------ | -------- | ------------------------------------------------------------- | +| amount | BN | false | The amount of funds to delegate to the pool | +| poolId | number | false | pool id | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk" +import { SDK, WaitFor, Keyring, BN } from "../../src/index" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" const sdk = await SDK.New(providerEndpoint) // Input - const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") - const amount = new BN(10).pow(new BN(18)).mul(new BN(10000)) // 10_000 Avail - - const root: string = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" // Alice - const nominator: string = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" // Alice - const bouncer: string = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" // Alice + const account = new Keyring({ type: "sr25519" }).addFromUri("//Bob") + const amount = SDK.oneAvail().mul(new BN(10000)) // 10_000 Avail + const poolId = 1 - const result = await sdk.tx.nominationPools.create(amount, root, nominator, bouncer, WaitFor.BlockInclusion, account) + const result = await sdk.tx.nominationPools.join(amount, poolId, WaitFor.BlockInclusion, account) if (result.isErr()) { console.log(result.error.reason) process.exit(1) @@ -1123,79 +1427,65 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `PoolCreateTxSuccess`. +If the operation is successful, the function will return a object of type `JoinTx`. -```js +```json { - "isErr": false, "event": { - "depositor": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", - "poolId": "1" - }, - "event2": { - "member": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + "member": "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", "poolId": "1", "bonded": "10000", "joined": "true" }, - "events": [...], - "txHash": "0x9f019464c676682d9cbfb62814d019a85738e01b0ce92b18fa77878f80e16f66", - "txIndex": 1, - "blockHash": "0xdaa49f09b8c519bbd4c52ed05652d3de3f777afa3ac85db5c697cf705907e2d2", - "blockNumber": 5 + "details": { + "txResult": {...}, + "events": [...], + "txHash": "0x06baecbb8680e90d025d1fd08044d0d251054a89e82dd460022bdf3796020050", + "txIndex": 1, + "blockHash": "0x82078130da46adacf5bdff86618ab6e1c443fda6d883d9fcf967a41a2e29d612", + "blockNumber": 19 + } } ``` -## Create with Pool Id +## Nominate Origin Level: Signed ### Interface ```js -function createWithPoolId(amount: BN, root: string, nominator: string, bouncer: string, poolId: number, waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function nominate(poolId: number, validators: string[], waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise>; ``` #### Parameters -| parameter | type | optional | description | -| --------- | ------------- | -------- | -------------------------------------------------- | -| amount | BN | false | The amount of funds to delegate to the pool | -| root | string | false | The account to set as [`PoolRoles::root`] | -| nominator | string | false | The account to set as the [`PoolRoles::nominator`] | -| bouncer | string | false | The account to set as the [`PoolRoles::bouncer`] | -| poolId | number | false | pool id | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| ---------- | ------------------ | -------- | ------------------------------------------------------------- | +| poolId | number | false | pool id | +| validators | string[] | false | list of validators to nominate | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk" +import { SDK, WaitFor, Keyring } from "../../src/index" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" const sdk = await SDK.New(providerEndpoint) // Input - const account = new Keyring({ type: "sr25519" }).addFromUri("//Bob") - const amount = new BN(10).pow(new BN(18)).mul(new BN(10000)) // 10_000 Avail - - const root: string = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" // Alice - const nominator: string = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" // Alice - const bouncer: string = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" // Alice - const poolId = 0 + const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") + const validators: string[] = [ + "5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY", + "5DAAnrj7VHTznn2AWBemMuyBwZWs6FNFjdyVXUeYum3PTXFy", + ] + const poolId = 1 - const result = await sdk.tx.nominationPools.createWithPoolId( - amount, - root, - nominator, - bouncer, - poolId, - WaitFor.BlockInclusion, - account, - ) + const result = await sdk.tx.nominationPools.nominate(poolId, validators, WaitFor.BlockInclusion, account) if (result.isErr()) { console.log(result.error.reason) process.exit(1) @@ -1215,53 +1505,44 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `PoolCreateWithPoolIdTxSuccess`. +If the operation is successful, the function will return a object of type `NominateTx`. -```js +```json { - "isErr": false, - "event": { - "depositor": "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", - "poolId": "0" - }, - "event2": { - "member": "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", - "poolId": "0", - "bonded": "10000", - "joined": "true" - }, - "events": [...], - "txHash": "0x6b50caed7950e67934cabbf88a1f7dc2e7e995ac608402f91a4db19be0da5c41", - "txIndex": 1, - "blockHash": "0xc06df7dbb1e404f54499f942479ddcffc92665c021ea07c2798fc2f354f403d3", - "blockNumber": 6 + "details": { + "txResult": {...}, + "events": [...], + "txHash": "0x98b993baf90183d85dece9357d3bc32311f4201b015b63845a13dbc22bf22370", + "txIndex": 1, + "blockHash": "0x84ef5a0ada4af71358ee701a2500bce7f6688efb554c32ba1a30c459f64d5370", + "blockNumber": 48 + } } ``` -## Join +## Set Claim Permission Origin Level: Signed ### Interface ```js -function join(amount: BN, poolId: number, waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function setClaimPermission(permission: ClaimPermission, waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise>; ``` #### Parameters -| parameter | type | optional | description | -| --------- | ------------- | -------- | ----------------------------------------------- | -| amount | BN | false | The amount of funds to delegate to the pool | -| poolId | number | false | pool id | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| ---------- | ------------------ | -------- | ------------------------------------------------------------- | +| permission | ClaimPermission | false | permission type | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk" +import { SDK, WaitFor, Keyring, ClaimPermission } from "../../src/index" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -1269,10 +1550,9 @@ const main = async () => { // Input const account = new Keyring({ type: "sr25519" }).addFromUri("//Bob") - const amount = new BN(10).pow(new BN(18)).mul(new BN(10000)) // 10_000 Avail - const poolId = 1 + const permission: ClaimPermission = "PermissionlessAll" - const result = await sdk.tx.nominationPools.join(amount, poolId, WaitFor.BlockInclusion, account) + const result = await sdk.tx.nominationPools.setClaimPermission(permission, WaitFor.BlockInclusion, account) if (result.isErr()) { console.log(result.error.reason) process.exit(1) @@ -1292,49 +1572,45 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `PoolJoinTxSuccess`. +If the operation is successful, the function will return a object of type `SetClaimPermissionTx`. -```js +```json { - "isErr": false, - "event": { - "member": "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", - "poolId": "1", - "bonded": "10000", - "joined": "true" - }, - "events": [...], - "txHash": "0x06baecbb8680e90d025d1fd08044d0d251054a89e82dd460022bdf3796020050", - "txIndex": 1, - "blockHash": "0x82078130da46adacf5bdff86618ab6e1c443fda6d883d9fcf967a41a2e29d612", - "blockNumber": 19 + "details": { + "txResult": {...}, + "events": [...], + "txHash": "0x3096fb312d22f2aa4fa51532fbae4b812a99d60c85a0750662816146bce997bc", + "txIndex": 1, + "blockHash": "0xfb41995f2e5aaa1b92126792dfc1e7b2863773fa4865eca2d96f458da17d6f82", + "blockNumber": 249 + } } ``` -## Nominate +## Set Commission Origin Level: Signed ### Interface ```js -function nominate(poolId: number, validators: string[], waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function setCommission(poolId: number, newCommission: NewCommission | null, waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise>; ``` #### Parameters -| parameter | type | optional | description | -| ---------- | ------------- | -------- | ----------------------------------------------- | -| poolId | number | false | pool id | -| validators | string[] | false | list of validators to nominate | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| ------------- | --------------------- | -------- | ---------------------------------------------------------------- | +| poolId | number | false | pool id | +| newCommission | NewCommission or Null | false | if empty it removes the existing commission otherwise it sets it | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring } from "avail-js-sdk" +import { SDK, WaitFor, Keyring, NewCommission } from "avail-js-sdk" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -1342,13 +1618,10 @@ const main = async () => { // Input const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") - const validators: string[] = [ - "5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY", - "5DAAnrj7VHTznn2AWBemMuyBwZWs6FNFjdyVXUeYum3PTXFy", - ] const poolId = 1 + const newCommission: NewCommission = { amount: 25, payee: "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" } - const result = await sdk.tx.nominationPools.nominate(poolId, validators, WaitFor.BlockInclusion, account) + const result = await sdk.tx.nominationPools.setCommission(poolId, newCommission, WaitFor.BlockInclusion, account) if (result.isErr()) { console.log(result.error.reason) process.exit(1) @@ -1368,42 +1641,49 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `PoolNominateTxSuccess`. +If the operation is successful, the function will return a object of type `CommissionTx`. -```js +```json { - "isErr": false, - "events": [...], - "txHash": "0x98b993baf90183d85dece9357d3bc32311f4201b015b63845a13dbc22bf22370", - "txIndex": 1, - "blockHash": "0x84ef5a0ada4af71358ee701a2500bce7f6688efb554c32ba1a30c459f64d5370", - "blockNumber": 48 + "event": { + "poolId": "1", + "current": "[250000000,\"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY\"]" + }, + "details": { + "txResult": {...}, + "events": [...], + "txHash": "0x8256693f9648abe0d47b12380cdcfcb56c3078080216a7487f0b34d7ff80e047", + "txIndex": 1, + "blockHash": "0xedf037ef9de56cba1a81a45bb5ed5b0ec3424725a521c6255976a68d5638015e", + "blockNumber": 552 + } } ``` -## Bond Extra +## Set Metadata Origin Level: Signed ### Interface ```js -function bondExtra(extra: BondExtra, waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function setMetadata(poolId: number, metadata: string, waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise>; ``` #### Parameters -| parameter | type | optional | description | -| --------- | ------------- | -------- | ------------------------------------------------------------------------------------------------------ | -| extra | BondExtra | false | Additional funds can come from either the free balance of the account, of from the accumulated rewards | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| --------- | ------------------ | -------- | ------------------------------------------------------------- | +| poolId | number | false | pool id | +| metadata | string | false | metadata | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring, BondExtra, BN } from "avail-js-sdk" +import { SDK, WaitFor, Keyring } from "../../src/index" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -1411,10 +1691,10 @@ const main = async () => { // Input const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") - const amount = new BN(10).pow(new BN(18)).mul(new BN(10000)) // 10_000 Avail - const bondExtra = { FreeBalance: amount } as BondExtra + const poolId = 1 + const metadata = "My Metadata" - const result = await sdk.tx.nominationPools.bondExtra(bondExtra, WaitFor.BlockInclusion, account) + const result = await sdk.tx.nominationPools.setMetadata(poolId, metadata, WaitFor.BlockInclusion, account) if (result.isErr()) { console.log(result.error.reason) process.exit(1) @@ -1434,49 +1714,45 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `PoolBondExtraTxSuccess`. +If the operation is successful, the function will return a object of type `SetMetadataTx`. -```js +```json { - "isErr": false, - "event": { - "member": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", - "poolId": "1", - "bonded": "10000000000000000000000", - "joined": "false" - }, - "events": [...], - "txHash": "0xc09bdfbc1703763850a2f4255ccb0dd7d7e9f4b793d2f9f05782b9e3c63682d9", - "txIndex": 1, - "blockHash": "0xe06e35e61e2b59900e22d627dd8cd9cab39c87a304a40aba0fce87936e921843", - "blockNumber": 112 + "details": { + "txResult": {...}, + "events": [...], + "txHash": "0x59121cd7e320acab280a1ad0d8b8385581ca7e03d973477ae812b1d967e2cb1d", + "txIndex": 1, + "blockHash": "0x6f19a8c993dc33676605a1dfabbb5a1008929ee965772a3b3edd12f9fe1eb296", + "blockNumber": 369 + } } ``` -## Set Metadata +## Set State Origin Level: Signed ### Interface ```js -function setMetadata(poolId: number, metadata: string, waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function setState(poolId: number, state: PoolState, waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise>; ``` #### Parameters -| parameter | type | optional | description | -| --------- | ------------- | -------- | ----------------------------------------------- | -| poolId | number | false | pool id | -| metadata | string | false | metadata | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| --------- | ------------------ | -------- | ------------------------------------------------------------- | +| poolId | number | false | pool id | +| state | PoolState | false | "Open" or "Blocked" or "Destroying" | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring } from "avail-js-sdk" +import { SDK, WaitFor, Keyring, PoolState } from "../../src/index" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -1484,10 +1760,10 @@ const main = async () => { // Input const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") - const poolId = 1 - const metadata = "My Metadata" + const poolId = 2 + const state: PoolState = "Blocked" - const result = await sdk.tx.nominationPools.setMetadata(poolId, metadata, WaitFor.BlockInclusion, account) + const result = await sdk.tx.nominationPools.setState(poolId, state, WaitFor.BlockInclusion, account) if (result.isErr()) { console.log(result.error.reason) process.exit(1) @@ -1507,16 +1783,22 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `PoolSetMetadataTxSuccess`. +If the operation is successful, the function will return a object of type `SetStateTx`. -```js +```json { - "isErr": false, - "events": [...], - "txHash": "0x59121cd7e320acab280a1ad0d8b8385581ca7e03d973477ae812b1d967e2cb1d", - "txIndex": 1, - "blockHash": "0x6f19a8c993dc33676605a1dfabbb5a1008929ee965772a3b3edd12f9fe1eb296", - "blockNumber": 369 + "event": { + "poolId": "1", + "newState": "Blocked" + }, + "details": { + "txResult": {...}, + "events": [...], + "txHash": "0x921a187171a1d15a0779be75b9ecadc62eb1446f798bd0f4f1542700f32c724c", + "txIndex": 1, + "blockHash": "0xf2b85aae8a41eb4a27c72dfb2c4bce258213b829ef5f97f416a24d3989e7b3da", + "blockNumber": 184 + } } ``` @@ -1527,23 +1809,23 @@ Origin Level: Signed ### Interface ```js -function unbond(memberAccount: string, unbondingPoints: BN, waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function unbond(memberAccount: string, unbondingPoints: BN, waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise>; ``` #### Parameters -| parameter | type | optional | description | -| --------------- | ------------- | -------- | ----------------------------------------------- | -| memberAccount | string | false | member account | -| unbondingPoints | BN | false | defines how many tokens will be unbond | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| --------------- | ------------------ | -------- | ------------------------------------------------------------- | +| memberAccount | string | false | member account | +| unbondingPoints | BN | false | defines how many tokens will be unbond | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk" +import { SDK, WaitFor, Keyring, BN } from "../../src/index" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -1552,7 +1834,7 @@ const main = async () => { // Input const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") const memberAccount = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" // Alice - const unbondingPoints = new BN(10).pow(new BN(18)).mul(new BN(100)) // 100 Avail + const unbondingPoints = SDK.oneAvail().mul(new BN(100)) // 100 Avail const result = await sdk.tx.nominationPools.unbond(memberAccount, unbondingPoints, WaitFor.BlockInclusion, account) if (result.isErr()) { @@ -1574,11 +1856,10 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `PoolUnbondTxSuccess`. +If the operation is successful, the function will return a object of type `UnbondTx`. -```js +```json { - "isErr": false, "event": { "member": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", "poolId": "1", @@ -1586,32 +1867,36 @@ If the operation is successful, the function will return a object of type `PoolU "points": "100000000000000000000", "era": "23" }, - "events": [], - "txHash": "0x87eeadd1dcf643b898dd46a681704565741c428fffc0fbcd0f9f587d47b43c5d", - "txIndex": 1, - "blockHash": "0xb38d12ccdc7a5c8190b8948597d40008540574150ccd96426a611695f0969115", - "blockNumber": 1032 + "details": { + "txResult": {...}, + "events": [...], + "txHash": "0x87eeadd1dcf643b898dd46a681704565741c428fffc0fbcd0f9f587d47b43c5d", + "txIndex": 1, + "blockHash": "0xb38d12ccdc7a5c8190b8948597d40008540574150ccd96426a611695f0969115", + "blockNumber": 1032 + } } ``` -## Chill +## Withdraw Unbonded Origin Level: Signed ### Interface ```js -function chill(poolId: number, waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function withdrawUnbonded(memberAccount: string, numSlashingSpans: number, waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise>; ``` #### Parameters -| parameter | type | optional | description | -| --------- | ------------- | -------- | ----------------------------------------------- | -| poolId | number | false | pool id | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| ---------------- | ------------------ | -------- | ------------------------------------------------------------- | +| memberAccount | string | false | member account | +| numSlashingSpans | number | false | number of slashing spans | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example @@ -1624,9 +1909,15 @@ const main = async () => { // Input const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") - const poolId = 1 + const memberAccount = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" // Alice + const numSlashingSpans = 0 - const result = await sdk.tx.nominationPools.chill(poolId, WaitFor.BlockInclusion, account) + const result = await sdk.tx.nominationPools.withdrawUnbonded( + memberAccount, + numSlashingSpans, + WaitFor.BlockInclusion, + account, + ) if (result.isErr()) { console.log(result.error.reason) process.exit(1) @@ -1646,52 +1937,66 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `PoolChillTxSuccess`. +If the operation is successful, the function will return a object of type `WithdrawUnbodedTx`. -```js +```json { - "isErr": false, - "events": [...], - "txHash": "0x678fd95154114bb899598f8ef4413e3fdb5a90317a132d5a49f868ffb029cecf", - "txIndex": 1, - "blockHash": "0xa66f5eacd4c4294ba6679c868d90df11fccf5c85c773e8554856882ac64b4be7", - "blockNumber": 1106 + "event": { + "member": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + "poolId": "1", + "balance": "100000000000000000000", + "points": "100000000000000000000" + }, + "details": { + "txResult": {...}, + "events": [...], + "txHash": "0xfaad26fc9bc45d02303772cbdddaf4866430fc72f1b52129aebda5fcbb50a964", + "txIndex": 1, + "blockHash": "0x1062735f5e11d1ffd1724d9d2892609dbb7b7065fadc3d0e7aa77618179016b7", + "blockNumber": 266 + } } ``` -## Set Claim Permission +# Staking + +Runtime Component: Staking\ +Runtime Index: 10\ +Interface Module Name: staking + +## Bond Extra Origin Level: Signed ### Interface ```js -function setClaimPermission(permission: ClaimPermission, waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function bondExtra(maxAdditional: BN, waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise>; ``` #### Parameters -| parameter | type | optional | description | -| ---------- | --------------- | -------- | ----------------------------------------------- | -| permission | ClaimPermission | false | permission type | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| ------------- | ------------------ | -------- | ------------------------------------------------------------- | +| maxAdditional | BN | false | Additional amount that is bond. 10^18 is equal to 1 AVL | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring, ClaimPermission } from "avail-js-sdk" +import { SDK, WaitFor, Keyring } from "../../src/index" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" const sdk = await SDK.New(providerEndpoint) // Input - const account = new Keyring({ type: "sr25519" }).addFromUri("//Bob") - const permission: ClaimPermission = "PermissionlessAll" + const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice//stash") + const maxAdditional = SDK.oneAvail() - const result = await sdk.tx.nominationPools.setClaimPermission(permission, WaitFor.BlockInclusion, account) + const result = await sdk.tx.staking.bondExtra(maxAdditional, WaitFor.BlockInclusion, account) if (result.isErr()) { console.log(result.error.reason) process.exit(1) @@ -1711,42 +2016,49 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `PoolSetClaimPermissionOtherTxSuccess`. +If the operation is successful, the function will return a object of type `BondExtraTx`. -```js +```json { - "isErr": false, - "events": [...], - "txHash": "0x3096fb312d22f2aa4fa51532fbae4b812a99d60c85a0750662816146bce997bc", - "txIndex": 1, - "blockHash": "0xfb41995f2e5aaa1b92126792dfc1e7b2863773fa4865eca2d96f458da17d6f82", - "blockNumber": 249 + "event": { + "stash": "5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY", + "amount": "1" + }, + "details": { + "txResult": {...}, + "events": [...], + "txHash": "0x940df5141925aeef2ab9aa767f6870689426de533f5f1d84b6d7be203e68ee77", + "txIndex": 1, + "blockHash": "0xc2a8375be07956586833f497a429ca2e29bafbb78ee5e051d5157df0ad5c8cb6", + "blockNumber": 7 + } } ``` -## Claim Commission +## Bond Origin Level: Signed ### Interface ```js -function claimCommission(poolId: number, waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function bond(value: BN, payee: StakingRewardDestination, waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise>; ``` #### Parameters -| parameter | type | optional | description | -| --------- | ------------- | -------- | ----------------------------------------------- | -| poolId | number | false | pool id | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| --------- | ------------------------ | -------- | ------------------------------------------------------------- | +| value | BN | false | Amount that is bond. 10^18 is equal to 1 AVL | +| payee | StakingRewardDestination | false | Can be: "Staked", "Stash", "None" or an account address | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | ccount that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring } from "avail-js-sdk" +import { SDK, WaitFor, Keyring, BN } from "../../src/index" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -1754,9 +2066,10 @@ const main = async () => { // Input const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") - const poolId = 1 + const value = SDK.oneAvail().mul(new BN(100000)) // 100_000 Avail + const payee = "Staked" - const result = await sdk.tx.nominationPools.claimCommission(poolId, WaitFor.BlockInclusion, account) + const result = await sdk.tx.staking.bond(value, payee, WaitFor.BlockInclusion, account) if (result.isErr()) { console.log(result.error.reason) process.exit(1) @@ -1776,54 +2089,57 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `PoolClaimCommissionTxSuccess`. +If the operation is successful, the function will return a object of type `BondTx`. -```js +```json { - "isErr": false, "event": { - "poolId": "1", - "commission": "7652149502759813012" + "stash": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + "amount": "100000" }, - "events": [...], - "txHash": "0x52292c2af7c2505c0bd39f5f1308bc10d92db7117f1b9fec208dc778e0c49654", - "txIndex": 1, - "blockHash": "0xdceaa5b12517f9634ad568e355061e8e13a8af25074e8966381c92fcea214285", - "blockNumber": 418 + "details": { + "txResult": {...}, + "events": [...], + "txHash": "0x3e1cc48207b02ca5d680cf1beeb270ce7cbf0d18a6191844bc963d4081a0ca90", + "txIndex": 1, + "blockHash": "0xf854e74cb428d0baf22454cb15007731a84263e57c64d019a304c0ca1bd30276", + "blockNumber": 2 + } } ``` -## Claim Payout +## Chill Other Origin Level: Signed ### Interface ```js -function claimPayout(waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function chillOther(stash: string, waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise>; ``` #### Parameters -| parameter | type | optional | description | -| --------- | ------------- | -------- | ----------------------------------------------- | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| --------- | ------------------ | -------- | ------------------------------------------------------------- | +| stash | string | false | address of stash account to chill | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring } from "avail-js-sdk" - +import { SDK, WaitFor, Keyring } from "../../src/index" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" const sdk = await SDK.New(providerEndpoint) // Input - const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") + const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice//stash") + const stash = "5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY" // Alice Stash - const result = await sdk.tx.nominationPools.claimPayout(WaitFor.BlockInclusion, account) + const result = await sdk.tx.staking.chillOther(stash, WaitFor.BlockInclusion, account) if (result.isErr()) { console.log(result.error.reason) process.exit(1) @@ -1843,57 +2159,42 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `PoolClaimPayoutTxSuccess`. +If the operation is successful, the function will return a object of type `ChillOtherTx`. + +```json -```js -{ - "isErr": false, - "event": { - "member": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", - "poolId": "1", - "payout": "4008268787159890000" - }, - "events": [...], - "txHash": "0x15b50cb2a3885432811ba1417b7715e69e05b8d4dd8f7c9951f0b4f7a8ba5a61", - "txIndex": 1, - "blockHash": "0xdd24eca2111c6b7eea4a34c9bed02cfa6effde65c65c3dc66fb13c88e2fe6985", - "blockNumber": 426 -} ``` -## Claim Payout Other +## Chill Origin Level: Signed ### Interface ```js -function claimPayoutOther(other: string, waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function chill( waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise>; ``` #### Parameters -| parameter | type | optional | description | -| --------- | ------------- | -------- | ----------------------------------------------- | -| other | &str | false | other account to claim payout | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| --------- | ------------------ | -------- | ------------------------------------------------------------- | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring } from "avail-js-sdk" - +import { SDK, WaitFor, Keyring } from "../../src/index" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" const sdk = await SDK.New(providerEndpoint) // Input - const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") - const other = "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty" // Bob + const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice//stash") - const result = await sdk.tx.nominationPools.claimPayoutOther(other, WaitFor.BlockInclusion, account) + const result = await sdk.tx.staking.chill(WaitFor.BlockInclusion, account) if (result.isErr()) { console.log(result.error.reason) process.exit(1) @@ -1913,48 +2214,47 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `PoolClaimPayoutOtherTxSuccess`. +If the operation is successful, the function will return a object of type `ChillTx`. -```js +```json { - "isErr": false, "event": { - "member": "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", - "poolId": "1", - "payout": "8198513381719500000" + "stash": "5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY" }, - "events": [...], - "txHash": "0xe14015b25afc66c4954dda18631b3fd5efaeba80989070ed12712ca312dbec40", - "txIndex": 1, - "blockHash": "0x3abde836ab66ac38bc3ca260f081d370f1c15094f43048423e0995170569a51a", - "blockNumber": 594 + "details": { + "txResult": {...}, + "events": [...], + "txHash": "0x4572681f19af32fdfb4759c914697697b0e82fde48a5dd7e28c2b3a263772b0d", + "txIndex": 1, + "blockHash": "0xad2e5376f53e6257e7bc0c842e5b6952f1d4af6f7499319b2d1ab59bdd742628", + "blockNumber": 13 + } } ``` -## Set Commission +## Nominate Origin Level: Signed ### Interface ```js -function setCommission(poolId: number, newCommission: NewCommission | null, waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function nominate(targets: string[], waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise>; ``` #### Parameters -| parameter | type | optional | description | -| ------------- | --------------------- | -------- | ---------------------------------------------------------------- | -| poolId | number | false | pool id | -| newCommission | NewCommission or Null | false | if empty it removes the existing commission otherwise it sets it | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| --------- | ------------------ | -------- | ------------------------------------------------------------- | +| targets | string[] | false | list od addresses to nominate | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring, NewCommission } from "avail-js-sdk" +import { SDK, WaitFor, Keyring } from "../../src/index" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -1962,10 +2262,12 @@ const main = async () => { // Input const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") - const poolId = 1 - const newCommission: NewCommission = { amount: 25, payee: "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" } + const targets = [ + "5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY", // Alice Stash + "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", // Bob + ] - const result = await sdk.tx.nominationPools.setCommission(poolId, newCommission, WaitFor.BlockInclusion, account) + const result = await sdk.tx.staking.nominate(targets, WaitFor.BlockInclusion, account) if (result.isErr()) { console.log(result.error.reason) process.exit(1) @@ -1985,47 +2287,50 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `PoolSetCommissionTxSuccess`. +If the operation is successful, the function will return a object of type `NominateTxSuccess`. -```js +```json { - "isErr": false, - "event": { - "poolId": "1", - "current": "[250000000,\"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY\"]" + "txData": { + "targets": [ + "5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY", + "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty" + ] }, - "events": [...], - "txHash": "0x8256693f9648abe0d47b12380cdcfcb56c3078080216a7487f0b34d7ff80e047", - "txIndex": 1, - "blockHash": "0xedf037ef9de56cba1a81a45bb5ed5b0ec3424725a521c6255976a68d5638015e", - "blockNumber": 552 + "details": { + "txResult": {...}, + "events": [...], + "txHash": "0x2f81a34f59d36eb7ada96ec1070358043026d7bd7cfb6fa5a532cc474190880b", + "txIndex": 1, + "blockHash": "0x49a57953aa2b2ba508f1c6991515309a0fe89723a79f3831f9a9263ba8c7baa4", + "blockNumber": 4 + } } ``` -## Withdraw Unbonded +## Unbond Origin Level: Signed ### Interface ```js -function withdrawUnbonded(memberAccount: string, numSlashingSpans: number, waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function unbond(value: BN, waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise>; ``` #### Parameters -| parameter | type | optional | description | -| ---------------- | ------------- | -------- | ----------------------------------------------- | -| memberAccount | string | false | member account | -| numSlashingSpans | number | false | number of slashing spans | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| --------- | ------------------ | -------- | ------------------------------------------------------------- | +| value | BN | false | amount of tokens to unbond | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring } from "avail-js-sdk" +import { SDK, WaitFor, Keyring } from "../../src/index" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -2033,15 +2338,9 @@ const main = async () => { // Input const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") - const memberAccount = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" // Alice - const numSlashingSpans = 0 + const value = SDK.oneAvail() - const result = await sdk.tx.nominationPools.withdrawUnbonded( - memberAccount, - numSlashingSpans, - WaitFor.BlockInclusion, - account, - ) + const result = await sdk.tx.staking.unbond(value, WaitFor.BlockInclusion, account) if (result.isErr()) { console.log(result.error.reason) process.exit(1) @@ -2061,49 +2360,49 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `PoolWithdrawUnbodedTxSuccess`. +If the operation is successful, the function will return a object of type `UnbondTx`. -```js +```json { - "isErr": false, "event": { - "member": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", - "poolId": "1", - "balance": "100000000000000000000", - "points": "100000000000000000000" + "stash": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + "amount": "1000000000000000000" }, - "events": [...], - "txHash": "0xfaad26fc9bc45d02303772cbdddaf4866430fc72f1b52129aebda5fcbb50a964", - "txIndex": 1, - "blockHash": "0x1062735f5e11d1ffd1724d9d2892609dbb7b7065fadc3d0e7aa77618179016b7", - "blockNumber": 266 + "details": { + "txResult": {...}, + "events": [...], + "txHash": "0xbf264e0e95885fd64a35d5c64bd4e1cc17056a1e6b05fa9207d7c777395dffdf", + "txIndex": 1, + "blockHash": "0x9ef43aaca71ba7b91a53976de5170f80d8a1ed4fe3e95fae237f7ed91f953963", + "blockNumber": 9 + } } ``` -## Set State +## Validate Origin Level: Signed ### Interface ```js -function setState(poolId: number, state: PoolState, waitFor: WaitFor, account: KeyringPair, options?: Partial): Promise; +function validate(commission: number, blocked: boolean, waitFor: WaitFor, account: KeyringPair, options?: TransactionOptions): Promise>; ``` #### Parameters -| parameter | type | optional | description | -| --------- | ------------- | -------- | ----------------------------------------------- | -| poolId | number | false | pool id | -| state | PoolState | false | "Open" or "Blocked" or "Destroying" | -| waitFor | WaitFor | false | wait for block inclusion or finalization | -| account | KeyringPair | false | account that will send and sign the transaction | -| options | SignerOptions | true | used to overwrite existing signer options | +| parameter | type | optional | description | +| ---------- | ------------------ | -------- | ------------------------------------------------------------- | +| commission | number | false | how much validator charge nominators in 0 - 100 range | +| blocked | boolean | false | whether or not this validator accepts nominations | +| waitFor | WaitFor | false | Wait for block inclusion or finalization | +| account | KeyringPair | false | Account that will send and sign the transaction | +| options | TransactionOptions | true | Can be used to set nonce, app id or other transaction options | ### Minimal Example ```js -import { SDK, WaitFor, Keyring, PoolState } from "avail-js-sdk" +import { SDK, WaitFor, Keyring } from "../../src/index" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -2111,10 +2410,10 @@ const main = async () => { // Input const account = new Keyring({ type: "sr25519" }).addFromUri("//Alice") - const poolId = 2 - const state: PoolState = "Blocked" + const commission = 5 // 5% + const blocked = false - const result = await sdk.tx.nominationPools.setState(poolId, state, WaitFor.BlockInclusion, account) + const result = await sdk.tx.staking.validate(commission, blocked, WaitFor.BlockInclusion, account) if (result.isErr()) { console.log(result.error.reason) process.exit(1) @@ -2134,19 +2433,22 @@ If the operation fails, the function will return an error message indicating the #### On Success -If the operation is successful, the function will return a object of type `PoolSetStateTxSuccess`. +If the operation is successful, the function will return a object of type `ValidateTx`. -```js +```json { - "isErr": false, "event": { - "poolId": "1", - "newState": "Blocked" + "stash": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + "commission": "50000000", + "blocked": "false" }, - "events": [...], - "txHash": "0x921a187171a1d15a0779be75b9ecadc62eb1446f798bd0f4f1542700f32c724c", - "txIndex": 1, - "blockHash": "0xf2b85aae8a41eb4a27c72dfb2c4bce258213b829ef5f97f416a24d3989e7b3da", - "blockNumber": 184 + "details": { + "txResult": {...}, + "events": [...], + "txHash": "0x31f047da16a350e32b832cc73d3351c8d5e5991625fde6e8c36fc45ebb9d2735", + "txIndex": 1, + "blockHash": "0xa7735804f52602d4b73e1dd7f718cf0ab5cc00d111c927a9f8a2b3d02b66e09a", + "blockNumber": 14 + } } ``` diff --git a/avail-js/docs/extrinsics/balances_tranfer_all_no_wait.ts b/avail-js/docs/extrinsics/balances_tranfer_all_no_wait.ts index 5a3382477..a51fd5d54 100644 --- a/avail-js/docs/extrinsics/balances_tranfer_all_no_wait.ts +++ b/avail-js/docs/extrinsics/balances_tranfer_all_no_wait.ts @@ -11,7 +11,7 @@ const main = async () => { const txHash = await sdk.tx.balances.transferAllNoWait(dest, keepAlive, account) - console.log(txHash) + console.log(JSON.stringify(txHash, null, 2)) process.exit() } main() diff --git a/avail-js/docs/extrinsics/balances_tranfer_allow_death_no_wait.ts b/avail-js/docs/extrinsics/balances_tranfer_allow_death_no_wait.ts index fd176bc72..df9bcb4f5 100644 --- a/avail-js/docs/extrinsics/balances_tranfer_allow_death_no_wait.ts +++ b/avail-js/docs/extrinsics/balances_tranfer_allow_death_no_wait.ts @@ -11,7 +11,7 @@ const main = async () => { const txHash = await sdk.tx.balances.transferAllowDeathNoWait(dest, amount, account) - console.log(txHash) + console.log(JSON.stringify(txHash, null, 2)) process.exit() } main() diff --git a/avail-js/docs/extrinsics/balances_tranfer_keep_alive_no_wait.ts b/avail-js/docs/extrinsics/balances_tranfer_keep_alive_no_wait.ts index 8a03fe912..760b79bb6 100644 --- a/avail-js/docs/extrinsics/balances_tranfer_keep_alive_no_wait.ts +++ b/avail-js/docs/extrinsics/balances_tranfer_keep_alive_no_wait.ts @@ -11,7 +11,7 @@ const main = async () => { const txHash = await sdk.tx.balances.transferKeepAliveNoWait(dest, amount, account) - console.log(txHash) + console.log(JSON.stringify(txHash, null, 2)) process.exit() } main() diff --git a/avail-js/docs/extrinsics/da_create_application_key_no_wait.ts b/avail-js/docs/extrinsics/da_create_application_key_no_wait.ts index 7ebf33bd9..440830213 100644 --- a/avail-js/docs/extrinsics/da_create_application_key_no_wait.ts +++ b/avail-js/docs/extrinsics/da_create_application_key_no_wait.ts @@ -10,7 +10,7 @@ const main = async () => { const txHash = await sdk.tx.dataAvailability.createApplicationKeyNoWait(key, account) - console.log(txHash) + console.log(JSON.stringify(txHash, null, 2)) process.exit() } main() diff --git a/avail-js/docs/extrinsics/da_submit_data_no_wait.ts b/avail-js/docs/extrinsics/da_submit_data_no_wait.ts index be39fc956..5d87ccce9 100644 --- a/avail-js/docs/extrinsics/da_submit_data_no_wait.ts +++ b/avail-js/docs/extrinsics/da_submit_data_no_wait.ts @@ -11,7 +11,7 @@ const main = async () => { const options: TransactionOptions = { app_id: 1 } const txHash = await sdk.tx.dataAvailability.submitDataNoWait(data, account, options) - console.log(txHash) + console.log(JSON.stringify(txHash, null, 2)) process.exit() } main()