diff --git a/avail-js/docs/README.md b/avail-js/docs/README.md index c6e4ce0fb..ecfc26bd5 100644 --- a/avail-js/docs/README.md +++ b/avail-js/docs/README.md @@ -41,845 +41,3 @@ ts-node ./docs/extrinsics/staking_nominate.ts ``` This will execute the chosen example script, showcasing how to interact with the Avail network using the avail-js-sdk. - -# Data Availability - -Runtime Component: DataAvailability\ -Runtime Index: 29\ -Interface Module Name: dataAvailability - -## Create Application Key - -Origin Level: Signed - -### Interface - -```js -function createApplicationKey(key: string, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | - -#### Return value - -On failure, a reason of failure is returned. On Success, ApplicationKeyCreated event, transaction hash and block hash is returned. - -### Minimal Example - -```js -import { Keyring } from "@polkadot/api" -import { SDK } from "avail-js-sdk" -import { WaitFor } from "avail-js-sdk/sdk/transactions" - -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 result = await sdk.tx.dataAvailability.createApplicationKey(key, WaitFor.BlockInclusion, account) - if (result.isErr) { - console.log(result.reason) - process.exit(1) - } - - console.log("Key=" + result.event.key + ", Owner=" + result.event.owner + ", Id=" + result.event.id) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) - - process.exit() -} -main() -``` - -## Submit Data - -Origin Level: Signed - -### Interface - -```js -function submitData(data: string, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | - -#### Return value - -On failure, a reason of failure is returned. On Success, DataSubmitted event, transaction data, transaction hash and block hash is returned. - -### Minimal Example - -```js -import { Keyring } from "@polkadot/api" -import { SDK } from "avail-js-sdk" -import { WaitFor } from "avail-js-sdk/sdk/transactions" - -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 data = "My Awesome Data" - - const result = await sdk.tx.dataAvailability.submitData(data, WaitFor.BlockInclusion, account) - if (result.isErr) { - console.log(result.reason) - process.exit(1) - } - - console.log("Data=" + result.txData.data) - console.log("Who=" + result.event.who + ", DataHash=" + result.event.dataHash) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) - - process.exit() -} -main() -``` - -## Submit Block Length Proposal - -Origin Level: Root - -### Interface - -```js -function submitBlockLengthProposal(rows: number, cols: number, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | - -#### Return value - -On failure, a reason of failure is returned. On Success, BlockLengthProposalSubmitted event, transaction hash and block hash is returned. - -### Minimal Example - -```js -import { Keyring } from "@polkadot/api" -import { SDK } from "avail-js-sdk" -import { WaitFor } from "avail-js-sdk/sdk/transactions" - -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 rows = 128 - const cols = 128 - - const result = await sdk.tx.dataAvailability.submitBlockLengthProposal(rows, cols, WaitFor.BlockInclusion, account) - if (result.isErr) { - console.log(result.reason) - process.exit(1) - } - - console.log("Rows=" + result.event.rows + ", Cols=" + result.event.cols) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) - - process.exit() -} -main() -``` - -## Set Application Key - -Origin Level: Root - -### Interface - -```js -function setApplicationKey(oldKey: string, newKey: string, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | - -#### Return value - -On failure, a reason of failure is returned. On Success, ApplicationKeySet event, transaction hash and block hash is returned. - -### Minimal Example - -```js -import { Keyring } from "@polkadot/api" -import { SDK } from "avail-js-sdk" -import { WaitFor } from "avail-js-sdk/sdk/transactions" - -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 oldKey = "MyNewKeyAwesome1" - const newKey = "MyNewKeyAwesome2" - - const result = await sdk.tx.dataAvailability.setApplicationKey(oldKey, newKey, WaitFor.BlockInclusion, account) - if (result.isErr) { - console.log(result.reason) - process.exit(1) - } - - console.log("OldKey=" + result.event.oldKey + ", NewKey=" + result.event.newKey) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) - - process.exit() -} -main() -``` - -## Set Submit Data Fee Modifer - -Origin Level: Root - -### Interface - -```js -function setSubmitDataFeeModifier(modifier: DispatchFeeModifier, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | - -#### Return value - -On failure, a reason of failure is returned. On Success, SubmitDataFeeModifierSet event, transaction hash and block hash is returned. - -### Minimal Example - -```js -import { Keyring } from "@polkadot/api" -import { BN } from "@polkadot/util" -import { SDK } from "avail-js-sdk" -import { WaitFor, DispatchFeeModifier } from "avail-js-sdk/sdk/transactions" - -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 modifier = { weightMaximumFee: new BN("10").pow(new BN("18")), weightFeeDivider: 20 } as DispatchFeeModifier; - - const result = await sdk.tx.dataAvailability.setSubmitDataFeeModifier(modifier, WaitFor.BlockInclusion, account); - if (result.isErr) { - console.log(result.reason); - process.exit(1); - } - - console.log( - "WeightMaximumFee=" + result.event.weightMaximumFee + ", WeightFeeMultiplier=" + result.event.weightFeeMultiplier + - ", WeightFeeDivider=" + result.event.weightFeeDivider, - ); - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash); - - process.exit(); -} -main() -``` - -## Type Definitions - -```js -enum WaitFor { - BlockInclusion, - BlockFinalization, -} -``` - -```js -type DispatchFeeModifier = { weightMaximumFee: BN | null, weightFeeDivider: number | null, weightFeeMultiplier: number | null }; -``` - -# Balances - -Runtime Component: Balances\ -Runtime Index: 6\ -Interface Module Name: balances - -## Transfer Keep Alive - -Origin Level: Signed - -### Interface - -```js -function transferKeepAlive(dest: string, value: BN, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | - -#### Return value - -On failure, a reason of failure is returned. On Success, TransferEvent event, transaction hash and block hash is returned. - -### Minimal Example - -```js -import { Keyring } from "@polkadot/api" -import { BN } from "@polkadot/util" -import { SDK } from "avail-js-sdk" -import { WaitFor } from "avail-js-sdk/sdk/transactions" - -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 = new BN(10).pow(new BN(18)) // one Avail - - const result = await sdk.tx.balances.transferKeepAlive(dest, amount, WaitFor.BlockInclusion, account) - if (result.isErr) { - console.log(result.reason) - process.exit(1) - } - - console.log("From=" + result.event.from + ", To=" + result.event.to + ", Amount=" + result.event.amount) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) - - process.exit() -} -main() -``` - -## Transfer Allow Death - -Origin Level: Signed - -### Interface - -```js -function transferAllowDeath(dest: string, value: BN, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | - -#### Return value - -On failure, a reason of failure is returned. On Success, TransferEvent event, KilledAccount (optionally) event, transaction hash and block -hash is returned. - -### Minimal Example - -```js -import { Keyring } from "@polkadot/api" -import { BN } from "@polkadot/util" -import { SDK } from "avail-js-sdk" -import { WaitFor } from "avail-js-sdk/sdk/transactions" - -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 = new BN(10).pow(new BN(18)) // one Avail - - const result = await sdk.tx.balances.transferAllowDeath(dest, amount, WaitFor.BlockInclusion, account) - if (result.isErr) { - console.log(result.reason) - process.exit(1) - } - - console.log("From=" + result.event.from + ", To=" + result.event.to + ", Amount=" + result.event.amount) - console.log("MaybeKilled=" + result.event2?.account) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) - - process.exit() -} -main() -``` - -## Transfer All - -Origin Level: Signed - -### Interface - -```js -function transferAll(dest: string, keepAlive: boolean, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | - -#### Return value - -On failure, a reason of failure is returned. On Success, TransferEvent event, KilledAccount (optionally) event, transaction hash and block -hash is returned. - -### Minimal Example - -```js -import { Keyring } from "@polkadot/api" -import { SDK } from "avail-js-sdk" -import { WaitFor } from "avail-js-sdk/sdk/transactions" - -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.reason) - process.exit(1) - } - - console.log("From=" + result.event.from + ", To=" + result.event.to + ", Amount=" + result.event.amount) - console.log("MaybeKilled=" + result.event2?.account) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) - - process.exit() -} -main() -``` - -# Staking - -Runtime Component: Staking\ -Runtime Index: 10\ -Interface Module Name: staking - -## Bond - -Origin Level: Signed - -### Interface - -```js -function bond(value: BN, payee: StakingRewardDestination, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | - -#### Return value - -On failure, a reason of failure is returned. On Success, Bonded event, transaction hash and block hash is returned. - -### Minimal Example - -```js -import { Keyring } from "@polkadot/api" -import { BN } from "@polkadot/util" -import { SDK } from "avail-js-sdk" -import { WaitFor } from "avail-js-sdk/sdk/transactions" - -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(100_000).mul(new BN(10).pow(new BN("18"))) // 100 000 Avail - const payee = "Staked" - - const result = await sdk.tx.staking.bond(value, payee, WaitFor.BlockInclusion, account) - if (result.isErr) { - console.log(result.reason) - process.exit(1) - } - - console.log("Stash=" + result.event.stash + ", Amount=" + result.event.amount) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) - - process.exit() -} -main() -``` - -## Bond Extra - -Origin Level: Signed - -### Interface - -```js -function bondExtra(maxAdditional: BN, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | - -#### Return value - -On failure, a reason of failure is returned. On Success, Bonded event, transaction hash and block hash is returned. - -### Minimal Example - -```js -import { Keyring } from "@polkadot/api" -import { BN } from "@polkadot/util" -import { SDK } from "avail-js-sdk" -import { WaitFor } from "avail-js-sdk/sdk/transactions" - -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 result = await sdk.tx.staking.bondExtra(maxAdditional, WaitFor.BlockInclusion, account) - if (result.isErr) { - console.log(result.reason) - process.exit(1) - } - - console.log("Stash=" + result.event.stash + ", Amount=" + result.event.amount) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) - - process.exit() -} -main() -``` - -## Chill - -Origin Level: Signed - -### Interface - -```js -function chill(waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | - -#### Return value - -On failure, a reason of failure is returned. On Success, Chilled event, transaction hash and block hash is returned. - -### Minimal Example - -```js -import { Keyring } from "@polkadot/api" -import { SDK } from "avail-js-sdk" -import { WaitFor } from "avail-js-sdk/sdk/transactions" - -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 result = await sdk.tx.staking.chill(WaitFor.BlockInclusion, account) - if (result.isErr) { - console.log(result.reason) - process.exit(1) - } - - console.log("Stash=" + result.event.stash) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) - - process.exit() -} -main() -``` - -## Chill Other - -Origin Level: Signed - -### Interface - -```js -function chillOther(stash: string, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | - -#### Return value - -On failure, a reason of failure is returned. On Success, Chilled event, transaction hash and block hash is returned. - -### Minimal Example - -```js -import { Keyring } from "@polkadot/api" -import { SDK } from "avail-js-sdk" -import { WaitFor } from "avail-js-sdk/sdk/transactions" - -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 result = await sdk.tx.staking.chillOther(stash, WaitFor.BlockInclusion, account) - if (result.isErr) { - console.log(result.reason) - process.exit(1) - } - - console.log("Stash=" + result.event.stash) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) - - process.exit() -} -main() -``` - -## Nominate - -Origin Level: Signed - -### Interface - -```js -function nominate(targets: string[], waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | - -#### Return value - -On failure, a reason of failure is returned. On Success, Nominate transaction data, transaction hash and block hash is returned. - -### Minimal Example - -```js -import { Keyring } from "@polkadot/api" -import { SDK } from "avail-js-sdk" -import { WaitFor } from "avail-js-sdk/sdk/transactions" - -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 targets = [ - "5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY", // Alice Stash - "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", // Bob - ] - - const result = await sdk.tx.staking.nominate(targets, WaitFor.BlockInclusion, account) - if (result.isErr) { - console.log(result.reason) - process.exit(1) - } - - console.log("TxDataTargets=" + result.txData.targets) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) - - process.exit() -} -main() -``` - -## Unbond - -Origin Level: Signed - -### Interface - -```js -function unbond(value: BN, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | - -#### Return value - -On failure, a reason of failure is returned. On Success, Unbonded event, transaction hash and block hash is returned. - -### Minimal Example - -```js -import { Keyring } from "@polkadot/api" -import { BN } from "@polkadot/util" -import { SDK } from "avail-js-sdk" -import { WaitFor } from "avail-js-sdk/sdk/transactions" - -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 result = await sdk.tx.staking.unbond(value, WaitFor.BlockInclusion, account) - if (result.isErr) { - console.log(result.reason) - process.exit(1) - } - - console.log("Stash=" + result.event.stash + ", Amount=" + result.event.amount) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) - - process.exit() -} -main() -``` - -## Validate - -Origin Level: Signed - -### Interface - -```js -function validate(commission: number, blocked: boolean, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | - -#### Return value - -On failure, a reason of failure is returned. On Success, ValidatorPrefsSet event, transaction hash and block hash is returned. - -### Minimal Example - -```js -import { Keyring } from "@polkadot/api" -import { SDK } from "avail-js-sdk" -import { WaitFor } from "avail-js-sdk/sdk/transactions" - -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 commission = 5 // 5% - const blocked = false - - const result = await sdk.tx.staking.validate(commission, blocked, WaitFor.BlockInclusion, account) - if (result.isErr) { - console.log(result.reason) - process.exit(1) - } - - console.log( - "Stash=" + result.event.stash + ", Commission=" + result.event.commission + ", Blocked=" + result.event.blocked, - ) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) - - process.exit() -} -main() -``` diff --git a/avail-js/docs/extrinsics/README.md b/avail-js/docs/extrinsics/README.md new file mode 100644 index 000000000..8188782c4 --- /dev/null +++ b/avail-js/docs/extrinsics/README.md @@ -0,0 +1,1387 @@ +# Data Availability + +Runtime Component: DataAvailability\ +Runtime Index: 29\ +Interface Module Name: dataAvailability + +## Create Application Key + +Origin Level: Signed + +### Interface + +```js +function createApplicationKey(key: string, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | + +### Minimal Example + +```js +import { SDK, WaitFor, Keyring } from "avail-js-sdk" + +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 result = await sdk.tx.dataAvailability.createApplicationKey(key, WaitFor.BlockInclusion, account) + if (result.isErr) { + console.log(result.reason) + process.exit(1) + } + + console.log(JSON.stringify(result, null, 4)) + + 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 `CreateApplicationKeyTxSuccess`. + +```js +{ + "isErr": false, + "event": { + "key": "0x4d79417765736f6d654b6579", + "owner": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + "id": "10" + }, + "events": [...], + "txHash": "0x5ae9edbd2a2da96eeffc14cf9050d711082890fa6bfb8749ad2c4947565f3bd2", + "txIndex": 1, + "blockHash": "0x152338c1b0696d12664cf3d4c159af3d54beca151ba1ea8b00989a66dc8050b0", + "blockNumber": 1 +} +``` + +## Submit Data + +Origin Level: Signed + +### Interface + +```js +function submitData(data: string, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | + +### Minimal Example + +```js +import { SDK, WaitFor, Keyring } from "avail-js-sdk" + +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 data = "My Awesome Data" + + const result = await sdk.tx.dataAvailability.submitData(data, WaitFor.BlockInclusion, account) + if (result.isErr) { + console.log(result.reason) + process.exit(1) + } + + console.log(JSON.stringify(result, null, 4)) + 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 `SubmitDataTxSuccess`. + +```js +{ + "isErr": false, + "txData": { + "data": "4d7920417765736f6d652044617461" + }, + "event": { + "who": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + "dataHash": "0x8846d900ea89aab9bce96402846c0ac74a853acc00cb99ff5ddb1a0f052594bd" + }, + "events": [...], + "txHash": "0xec6f9fd5e002c9ddbcd24764380f57a014de7f2007cc0e2ae11a4dda17ab8062", + "txIndex": 1, + "blockHash": "0x043c2b88ff960f2f7042521b55a943676938948febefe8684022b524795340d9", + "blockNumber": 9 +} +``` + +## Submit Block Length Proposal + +Origin Level: Root + +### Interface + +```js +function submitBlockLengthProposal(rows: number, cols: number, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | + +### Minimal Example + +```js +import { SDK, WaitFor, Keyring } from "avail-js-sdk" + +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 rows = 128 + const cols = 128 + + const result = await sdk.tx.dataAvailability.submitBlockLengthProposal(rows, cols, WaitFor.BlockInclusion, account) + if (result.isErr) { + console.log(result.reason) + process.exit(1) + } + + console.log(JSON.stringify(result, null, 4)) + + 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 `SubmitBlockLengthProposalTxSuccess`. + +```js + +``` + +## Set Application Key + +Origin Level: Root + +### Interface + +```js +function setApplicationKey(oldKey: string, newKey: string, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | + +### Minimal Example + +```js +import { SDK, WaitFor, Keyring } from "avail-js-sdk" + +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 oldKey = "MyNewKeyAwesome1" + const newKey = "MyNewKeyAwesome2" + + const result = await sdk.tx.dataAvailability.setApplicationKey(oldKey, newKey, WaitFor.BlockInclusion, account) + if (result.isErr) { + console.log(result.reason) + process.exit(1) + } + + console.log(JSON.stringify(result, null, 4)) + + 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 `SetApplicationKeyTxSuccess`. + +```js + +``` + +## Set Submit Data Fee Modifier + +Origin Level: Root + +### Interface + +```js +function setSubmitDataFeeModifier(modifier: DispatchFeeModifier, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | + +### Minimal Example + +```js +import { SDK, WaitFor, Keyring, BN, sdkTransactions } from "avail-js-sdk" + +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 modifier = { + weightMaximumFee: new BN("10").pow(new BN("18")), + weightFeeDivider: 20, + } as sdkTransactions.DispatchFeeModifier + + const result = await sdk.tx.dataAvailability.setSubmitDataFeeModifier(modifier, WaitFor.BlockInclusion, account) + if (result.isErr) { + console.log(result.reason) + process.exit(1) + } + + console.log(JSON.stringify(result, null, 4)) + + 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 `SetSubmitDataFeeModifierTxSuccess`. + +```js + +``` + +## Type Definitions + +```js +enum WaitFor { + BlockInclusion, + BlockFinalization, +} +``` + +```js +type DispatchFeeModifier = { weightMaximumFee: BN | null, weightFeeDivider: number | null, weightFeeMultiplier: number | null }; +``` + +# Balances + +Runtime Component: Balances\ +Runtime Index: 6\ +Interface Module Name: balances + +## Transfer Keep Alive + +Origin Level: Signed + +### Interface + +```js +function transferKeepAlive(dest: string, value: BN, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | + +### Minimal Example + +```js +import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk" + +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 = new BN(10).pow(new BN(18)) // one Avail + + const result = await sdk.tx.balances.transferKeepAlive(dest, amount, WaitFor.BlockInclusion, account) + if (result.isErr) { + console.log(result.reason) + process.exit(1) + } + + console.log(JSON.stringify(result, null, 4)) + + 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 `TransferKeepAliveTxSuccess`. + +```js +{ + "isErr": false, + "event": { + "from": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + "to": "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw", + "amount": "1000000000000000000" + }, + "events": [...], + "txHash": "0x812a3f3960afb8df72de0e5b86ff564c8ce7d93c837182c24d1796fb68a7f5f4", + "txIndex": 1, + "blockHash": "0xfdee1faced02696d692df1d896fa2822f4eb02f260c95e11041df86b2c229dfb", + "blockNumber": 1 +} +``` + +## Transfer Allow Death + +Origin Level: Signed + +### Interface + +```js +function transferAllowDeath(dest: string, value: BN, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | + +### Minimal Example + +```js +import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk" + +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 = new BN(10).pow(new BN(18)) // one Avail + + const result = await sdk.tx.balances.transferAllowDeath(dest, amount, WaitFor.BlockInclusion, account) + if (result.isErr) { + console.log(result.reason) + process.exit(1) + } + + console.log(JSON.stringify(result, null, 4)) + + 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 `TransferAllowDeathTxSuccess`. + +```js +{ + "isErr": false, + "event": { + "from": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + "to": "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw", + "amount": "1000000000000000000" + }, + "events": [...], + "txHash": "0x63a73d2d1210ab9840341506788cca9592fd968609fecb5106cf0370c611061c", + "txIndex": 1, + "blockHash": "0xde2e95b63a4ca5927f9105931e4676b0634d12f524d4fff1048b403393419489", + "blockNumber": 2 +} +``` + +## Transfer All + +Origin Level: Signed + +### Interface + +```js +function transferAll(dest: string, keepAlive: boolean, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | + +### Minimal Example + +```js +import { SDK, WaitFor, Keyring } from "avail-js-sdk" + +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.reason) + process.exit(1) + } + + console.log(JSON.stringify(result, null, 4)) + + 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 `TransferAllTxSuccess`. + +```js +{ + "isErr": false, + "event": { + "from": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + "to": "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw", + "amount": "9999999873433871068464733" + }, + "events": [...], + "txHash": "0x343d3e8890bd479b4619cb7b0f2dfa91b7b91c0cedc0646247215f85baf1f63e", + "txIndex": 1, + "blockHash": "0xaec4adfad11f8aa902e1a985abb62737fc02445072b168238a956c3a0d8820f2", + "blockNumber": 2 +} +``` + +# Staking + +Runtime Component: Staking\ +Runtime Index: 10\ +Interface Module Name: staking + +## Bond + +Origin Level: Signed + +### Interface + +```js +function bond(value: BN, payee: StakingRewardDestination, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | + +### Minimal Example + +```js +import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk" + +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(100_000).mul(new BN(10).pow(new BN("18"))) // 100 000 Avail + const payee = "Staked" + + const result = await sdk.tx.staking.bond(value, payee, WaitFor.BlockInclusion, account) + if (result.isErr) { + console.log(result.reason) + process.exit(1) + } + + console.log(JSON.stringify(result, null, 4)) + + 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 `BondTxSuccess`. + +```js +{ + "isErr": false, + "event": { + "stash": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + "amount": "100000" + }, + "events": [...], + "txHash": "0x3e1cc48207b02ca5d680cf1beeb270ce7cbf0d18a6191844bc963d4081a0ca90", + "txIndex": 1, + "blockHash": "0xf854e74cb428d0baf22454cb15007731a84263e57c64d019a304c0ca1bd30276", + "blockNumber": 2 +} +``` + +## Bond Extra + +Origin Level: Signed + +### Interface + +```js +function bondExtra(maxAdditional: BN, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | + +### Minimal Example + +```js +import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk" + +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 result = await sdk.tx.staking.bondExtra(maxAdditional, WaitFor.BlockInclusion, account) + if (result.isErr) { + console.log(result.reason) + process.exit(1) + } + + console.log(JSON.stringify(result, null, 4)) + + 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 `BondExtraTxSuccess`. + +```js +{ + "isErr": false, + "event": { + "stash": "5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY", + "amount": "1" + }, + "events": [...], + "txHash": "0x940df5141925aeef2ab9aa767f6870689426de533f5f1d84b6d7be203e68ee77", + "txIndex": 1, + "blockHash": "0xc2a8375be07956586833f497a429ca2e29bafbb78ee5e051d5157df0ad5c8cb6", + "blockNumber": 7 +} +``` + +## Chill + +Origin Level: Signed + +### Interface + +```js +function chill(waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | + +### Minimal Example + +```js +import { SDK, WaitFor, Keyring } from "avail-js-sdk" +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 result = await sdk.tx.staking.chill(WaitFor.BlockInclusion, account) + if (result.isErr) { + console.log(result.reason) + process.exit(1) + } + + console.log(JSON.stringify(result, null, 4)) + + 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 `ChillTxSuccess`. + +```js +{ + "isErr": false, + "event": { + "stash": "5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY" + }, + "events": [...], + "txHash": "0x4572681f19af32fdfb4759c914697697b0e82fde48a5dd7e28c2b3a263772b0d", + "txIndex": 1, + "blockHash": "0xad2e5376f53e6257e7bc0c842e5b6952f1d4af6f7499319b2d1ab59bdd742628", + "blockNumber": 13 +} +``` + +## Chill Other + +Origin Level: Signed + +### Interface + +```js +function chillOther(stash: string, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | + +### Minimal Example + +```js +import { SDK, WaitFor, Keyring } from "avail-js-sdk" +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 result = await sdk.tx.staking.chillOther(stash, WaitFor.BlockInclusion, account) + if (result.isErr) { + console.log(result.reason) + process.exit(1) + } + + console.log(JSON.stringify(result, null, 4)) + + 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 `ChillOtherTxSuccess`. + +```js + +``` + +## Nominate + +Origin Level: Signed + +### Interface + +```js +function nominate(targets: string[], waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | + +### Minimal Example + +```js +import { SDK, WaitFor, Keyring } from "avail-js-sdk" + +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 targets = [ + "5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY", // Alice Stash + "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", // Bob + ] + + const result = await sdk.tx.staking.nominate(targets, WaitFor.BlockInclusion, account) + if (result.isErr) { + console.log(result.reason) + process.exit(1) + } + + console.log(JSON.stringify(result, null, 4)) + + 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 `NominateTxSuccess`. + +```js +{ + "isErr": false, + "txData": { + "targets": [ + "5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY", + "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty" + ] + }, + "events": [...], + "txHash": "0x2f81a34f59d36eb7ada96ec1070358043026d7bd7cfb6fa5a532cc474190880b", + "txIndex": 1, + "blockHash": "0x49a57953aa2b2ba508f1c6991515309a0fe89723a79f3831f9a9263ba8c7baa4", + "blockNumber": 4 +} +``` + +## Unbond + +Origin Level: Signed + +### Interface + +```js +function unbond(value: BN, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | + +### Minimal Example + +```js +import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk" + +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 result = await sdk.tx.staking.unbond(value, WaitFor.BlockInclusion, account) + if (result.isErr) { + console.log(result.reason) + process.exit(1) + } + + console.log(JSON.stringify(result, null, 4)) + 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 `UnbondTxSuccess`. + +```js +{ + "isErr": false, + "event": { + "stash": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + "amount": "1000000000000000000" + }, + "events": [...], + "txHash": "0xbf264e0e95885fd64a35d5c64bd4e1cc17056a1e6b05fa9207d7c777395dffdf", + "txIndex": 1, + "blockHash": "0x9ef43aaca71ba7b91a53976de5170f80d8a1ed4fe3e95fae237f7ed91f953963", + "blockNumber": 9 +} +``` + +## Validate + +Origin Level: Signed + +### Interface + +```js +function validate(commission: number, blocked: boolean, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | + +### Minimal Example + +```js +import { SDK, WaitFor, Keyring } from "avail-js-sdk" + +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 commission = 5 // 5% + const blocked = false + + const result = await sdk.tx.staking.validate(commission, blocked, WaitFor.BlockInclusion, account) + if (result.isErr) { + console.log(result.reason) + process.exit(1) + } + + console.log(JSON.stringify(result, null, 4)) + + 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 `ValidateTxSuccess`. + +```js +{ + "isErr": false, + "event": { + "stash": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + "commission": "50000000", + "blocked": "false" + }, + "events": [...], + "txHash": "0x31f047da16a350e32b832cc73d3351c8d5e5991625fde6e8c36fc45ebb9d2735", + "txIndex": 1, + "blockHash": "0xa7735804f52602d4b73e1dd7f718cf0ab5cc00d111c927a9f8a2b3d02b66e09a", + "blockNumber": 14 +} +``` + +# Nomination Pools + +Runtime Component: Nomination Pools\ +Runtime Index: 36\ +Interface Module Name: nominationPools + +## Create + +Origin Level: Signed + +### Interface + +```js +function create(amount: BN, root: string, nominator: string, bouncer: string, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | + +### Minimal Example + +```js +import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk" + +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 result = await sdk.tx.nominationPools.create(amount, root, nominator, bouncer, WaitFor.BlockInclusion, account) + if (result.isErr) { + console.log(result.reason) + process.exit(1) + } + + console.log(JSON.stringify(result, null, 4)) + 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 `PoolCreateTxSuccess`. + +```js +{ + "isErr": false, + "event": { + "depositor": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + "poolId": "1" + }, + "event2": { + "member": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + "poolId": "1", + "bonded": "10000", + "joined": "true" + }, + "event": { + "key": "0x4d79417765736f6d654b6579", + "owner": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + "id": "10" + }, + "events": [...], + "txHash": "0x5ae9edbd2a2da96eeffc14cf9050d711082890fa6bfb8749ad2c4947565f3bd2", + "txIndex": 1, + "blockHash": "0x152338c1b0696d12664cf3d4c159af3d54beca151ba1ea8b00989a66dc8050b0", + "blockNumber": 1 +} +``` + +## Create with Pool Id + +Origin Level: Signed + +### Interface + +```js +function createWithPoolId(amount: BN, root: string, nominator: string, bouncer: string, poolId: number, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | + +### Minimal Example + +```js +import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk" + +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 result = await sdk.tx.nominationPools.createWithPoolId( + amount, + root, + nominator, + bouncer, + poolId, + WaitFor.BlockInclusion, + account, + ) + if (result.isErr) { + console.log(result.reason) + process.exit(1) + } + + console.log(JSON.stringify(result, null, 4)) + 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 `PoolCreateWithPoolIdTxSuccess`. + +```js +{ + "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 +} +``` + +## Join + +Origin Level: Signed + +### Interface + +```js +function join(amount: BN, poolId: number, waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | + +### Minimal Example + +```js +import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk" + +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 poolId = 1 + + const result = await sdk.tx.nominationPools.join(amount, poolId, WaitFor.BlockInclusion, account) + if (result.isErr) { + console.log(result.reason) + process.exit(1) + } + + console.log(JSON.stringify(result, null, 4)) + 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 `PoolJoinTxSuccess`. + +```js +{ + "isErr": false, + "event": { + "member": "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", + "poolId": "1", + "bonded": "10000", + "joined": "true" + }, + "events": [...], + "txHash": "0x06baecbb8680e90d025d1fd08044d0d251054a89e82dd460022bdf3796020050", + "txIndex": 1, + "blockHash": "0x82078130da46adacf5bdff86618ab6e1c443fda6d883d9fcf967a41a2e29d612", + "blockNumber": 19 +} +``` + +## Nominate + +Origin Level: Signed + +### Interface + +```js +function nominate(poolId: number, validators: string[], waitFor: WaitFor, account: KeyringPair, options?: Partial): 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 | + +### Minimal Example + +```js +import { SDK, WaitFor, Keyring } from "avail-js-sdk" + +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 validators: string[] = [ + "5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY", + "5DAAnrj7VHTznn2AWBemMuyBwZWs6FNFjdyVXUeYum3PTXFy", + ] + const poolId = 1 + + const result = await sdk.tx.nominationPools.nominate(poolId, validators, WaitFor.BlockInclusion, account) + if (result.isErr) { + console.log(result.reason) + process.exit(1) + } + + console.log(JSON.stringify(result, null, 4)) + 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 `PoolNominateTxSuccess`. + +```js +{ + "isErr": false, + "events": [...], + "txHash": "0x98b993baf90183d85dece9357d3bc32311f4201b015b63845a13dbc22bf22370", + "txIndex": 1, + "blockHash": "0x84ef5a0ada4af71358ee701a2500bce7f6688efb554c32ba1a30c459f64d5370", + "blockNumber": 48 +} +``` diff --git a/avail-js/docs/extrinsics/balances_tranfer_all.ts b/avail-js/docs/extrinsics/balances_tranfer_all.ts index c337619fd..a2c569503 100644 --- a/avail-js/docs/extrinsics/balances_tranfer_all.ts +++ b/avail-js/docs/extrinsics/balances_tranfer_all.ts @@ -1,6 +1,4 @@ -import { Keyring } from "@polkadot/api" -import { SDK } from "avail-js-sdk" -import { WaitFor } from "avail-js-sdk/sdk/transactions" +import { SDK, WaitFor, Keyring } from "avail-js-sdk" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -17,9 +15,7 @@ const main = async () => { process.exit(1) } - console.log("From=" + result.event.from + ", To=" + result.event.to + ", Amount=" + result.event.amount) - console.log("MaybeKilled=" + result.event2?.account) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) + console.log(JSON.stringify(result, null, 4)) process.exit() } diff --git a/avail-js/docs/extrinsics/balances_tranfer_allow_death.ts b/avail-js/docs/extrinsics/balances_tranfer_allow_death.ts index f07d68294..abee406fa 100644 --- a/avail-js/docs/extrinsics/balances_tranfer_allow_death.ts +++ b/avail-js/docs/extrinsics/balances_tranfer_allow_death.ts @@ -1,7 +1,4 @@ -import { Keyring } from "@polkadot/api" -import { BN } from "@polkadot/util" -import { SDK } from "avail-js-sdk" -import { WaitFor } from "avail-js-sdk/sdk/transactions" +import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -18,9 +15,7 @@ const main = async () => { process.exit(1) } - console.log("From=" + result.event.from + ", To=" + result.event.to + ", Amount=" + result.event.amount) - console.log("MaybeKilled=" + result.event2?.account) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) + console.log(JSON.stringify(result, null, 4)) process.exit() } diff --git a/avail-js/docs/extrinsics/balances_tranfer_keep_alive.ts b/avail-js/docs/extrinsics/balances_tranfer_keep_alive.ts index 27f838c7c..a5d09e4bc 100644 --- a/avail-js/docs/extrinsics/balances_tranfer_keep_alive.ts +++ b/avail-js/docs/extrinsics/balances_tranfer_keep_alive.ts @@ -1,7 +1,4 @@ -import { Keyring } from "@polkadot/api" -import { BN } from "@polkadot/util" -import { SDK } from "avail-js-sdk" -import { WaitFor } from "avail-js-sdk/sdk/transactions" +import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -18,8 +15,7 @@ const main = async () => { process.exit(1) } - console.log("From=" + result.event.from + ", To=" + result.event.to + ", Amount=" + result.event.amount) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) + console.log(JSON.stringify(result, null, 4)) process.exit() } diff --git a/avail-js/docs/extrinsics/da_create_application_key.ts b/avail-js/docs/extrinsics/da_create_application_key.ts index 57313fdb4..270fef6b9 100644 --- a/avail-js/docs/extrinsics/da_create_application_key.ts +++ b/avail-js/docs/extrinsics/da_create_application_key.ts @@ -1,6 +1,4 @@ -import { Keyring } from "@polkadot/api" -import { SDK } from "avail-js-sdk" -import { WaitFor } from "avail-js-sdk/sdk/transactions" +import { SDK, WaitFor, Keyring } from "avail-js-sdk" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -16,8 +14,7 @@ const main = async () => { process.exit(1) } - console.log("Key=" + result.event.key + ", Owner=" + result.event.owner + ", Id=" + result.event.id) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) + console.log(JSON.stringify(result, null, 4)) process.exit() } diff --git a/avail-js/docs/extrinsics/da_set_aplication_key.ts b/avail-js/docs/extrinsics/da_set_aplication_key.ts index 5677885a3..814130cbd 100644 --- a/avail-js/docs/extrinsics/da_set_aplication_key.ts +++ b/avail-js/docs/extrinsics/da_set_aplication_key.ts @@ -1,6 +1,4 @@ -import { Keyring } from "@polkadot/api" -import { SDK } from "avail-js-sdk" -import { WaitFor } from "avail-js-sdk/sdk/transactions" +import { SDK, WaitFor, Keyring } from "avail-js-sdk" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -17,8 +15,7 @@ const main = async () => { process.exit(1) } - console.log("OldKey=" + result.event.oldKey + ", NewKey=" + result.event.newKey) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) + console.log(JSON.stringify(result, null, 4)) process.exit() } diff --git a/avail-js/docs/extrinsics/da_set_submit_data_fee_modifier.ts b/avail-js/docs/extrinsics/da_set_submit_data_fee_modifier.ts index ecc2e47c6..76ead5ad6 100644 --- a/avail-js/docs/extrinsics/da_set_submit_data_fee_modifier.ts +++ b/avail-js/docs/extrinsics/da_set_submit_data_fee_modifier.ts @@ -1,7 +1,4 @@ -import { Keyring } from "@polkadot/api" -import { BN } from "@polkadot/util" -import { SDK } from "avail-js-sdk" -import { WaitFor, DispatchFeeModifier } from "avail-js-sdk/sdk/transactions" +import { SDK, WaitFor, Keyring, BN, sdkTransactions } from "avail-js-sdk" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -9,7 +6,10 @@ 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 DispatchFeeModifier + const modifier = { + weightMaximumFee: new BN("10").pow(new BN("18")), + weightFeeDivider: 20, + } as sdkTransactions.DispatchFeeModifier const result = await sdk.tx.dataAvailability.setSubmitDataFeeModifier(modifier, WaitFor.BlockInclusion, account) if (result.isErr) { @@ -17,15 +17,7 @@ const main = async () => { process.exit(1) } - console.log( - "WeightMaximumFee=" + - result.event.weightMaximumFee + - ", WeightFeeMultiplier=" + - result.event.weightFeeMultiplier + - ", WeightFeeDivider=" + - result.event.weightFeeDivider, - ) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) + console.log(JSON.stringify(result, null, 4)) process.exit() } diff --git a/avail-js/docs/extrinsics/da_submit_block_length_proposal.ts b/avail-js/docs/extrinsics/da_submit_block_length_proposal.ts index 71552075e..e91683e97 100644 --- a/avail-js/docs/extrinsics/da_submit_block_length_proposal.ts +++ b/avail-js/docs/extrinsics/da_submit_block_length_proposal.ts @@ -1,6 +1,4 @@ -import { Keyring } from "@polkadot/api" -import { SDK } from "avail-js-sdk" -import { WaitFor } from "avail-js-sdk/sdk/transactions" +import { SDK, WaitFor, Keyring } from "avail-js-sdk" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -17,8 +15,7 @@ const main = async () => { process.exit(1) } - console.log("Rows=" + result.event.rows + ", Cols=" + result.event.cols) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) + console.log(JSON.stringify(result, null, 4)) process.exit() } diff --git a/avail-js/docs/extrinsics/da_submit_data.ts b/avail-js/docs/extrinsics/da_submit_data.ts index c6ca6a27d..d6c8be39f 100644 --- a/avail-js/docs/extrinsics/da_submit_data.ts +++ b/avail-js/docs/extrinsics/da_submit_data.ts @@ -1,6 +1,4 @@ -import { Keyring } from "@polkadot/api" -import { SDK } from "avail-js-sdk" -import { WaitFor } from "avail-js-sdk/sdk/transactions" +import { SDK, WaitFor, Keyring } from "avail-js-sdk" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -16,10 +14,7 @@ const main = async () => { process.exit(1) } - console.log("Data=" + result.txData.data) - console.log("Who=" + result.event.who + ", DataHash=" + result.event.dataHash) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) - + console.log(JSON.stringify(result, null, 4)) process.exit() } main() diff --git a/avail-js/docs/extrinsics/nomination_pools_create.ts b/avail-js/docs/extrinsics/nomination_pools_create.ts new file mode 100644 index 000000000..304cbdcf4 --- /dev/null +++ b/avail-js/docs/extrinsics/nomination_pools_create.ts @@ -0,0 +1,24 @@ +import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk" + +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 result = await sdk.tx.nominationPools.create(amount, root, nominator, bouncer, WaitFor.BlockInclusion, account) + if (result.isErr) { + console.log(result.reason) + process.exit(1) + } + + console.log(JSON.stringify(result, null, 4)) + process.exit() +} +main() diff --git a/avail-js/docs/extrinsics/nomination_pools_create_with_pool_id.ts b/avail-js/docs/extrinsics/nomination_pools_create_with_pool_id.ts new file mode 100644 index 000000000..ff4766f0f --- /dev/null +++ b/avail-js/docs/extrinsics/nomination_pools_create_with_pool_id.ts @@ -0,0 +1,33 @@ +import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk" + +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 result = await sdk.tx.nominationPools.createWithPoolId( + amount, + root, + nominator, + bouncer, + poolId, + WaitFor.BlockInclusion, + account, + ) + if (result.isErr) { + console.log(result.reason) + process.exit(1) + } + + console.log(JSON.stringify(result, null, 4)) + process.exit() +} +main() diff --git a/avail-js/docs/extrinsics/nomination_pools_join.ts b/avail-js/docs/extrinsics/nomination_pools_join.ts new file mode 100644 index 000000000..acba16956 --- /dev/null +++ b/avail-js/docs/extrinsics/nomination_pools_join.ts @@ -0,0 +1,21 @@ +import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk" + +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 poolId = 1 + + const result = await sdk.tx.nominationPools.join(amount, poolId, WaitFor.BlockInclusion, account) + if (result.isErr) { + console.log(result.reason) + process.exit(1) + } + + console.log(JSON.stringify(result, null, 4)) + process.exit() +} +main() diff --git a/avail-js/docs/extrinsics/nomination_pools_nominate.ts b/avail-js/docs/extrinsics/nomination_pools_nominate.ts new file mode 100644 index 000000000..8d8bd58fb --- /dev/null +++ b/avail-js/docs/extrinsics/nomination_pools_nominate.ts @@ -0,0 +1,24 @@ +import { SDK, WaitFor, Keyring } from "avail-js-sdk" + +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 validators: string[] = [ + "5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY", + "5DAAnrj7VHTznn2AWBemMuyBwZWs6FNFjdyVXUeYum3PTXFy", + ] + const poolId = 1 + + const result = await sdk.tx.nominationPools.nominate(poolId, validators, WaitFor.BlockInclusion, account) + if (result.isErr) { + console.log(result.reason) + process.exit(1) + } + + console.log(JSON.stringify(result, null, 4)) + process.exit() +} +main() diff --git a/avail-js/docs/extrinsics/staking_bond.ts b/avail-js/docs/extrinsics/staking_bond.ts index 133ca8fae..d2937a00c 100644 --- a/avail-js/docs/extrinsics/staking_bond.ts +++ b/avail-js/docs/extrinsics/staking_bond.ts @@ -1,7 +1,4 @@ -import { Keyring } from "@polkadot/api" -import { BN } from "@polkadot/util" -import { SDK } from "avail-js-sdk" -import { WaitFor } from "avail-js-sdk/sdk/transactions" +import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -18,8 +15,7 @@ const main = async () => { process.exit(1) } - console.log("Stash=" + result.event.stash + ", Amount=" + result.event.amount) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) + console.log(JSON.stringify(result, null, 4)) process.exit() } diff --git a/avail-js/docs/extrinsics/staking_bond_extra.ts b/avail-js/docs/extrinsics/staking_bond_extra.ts index ef40784e0..d94a03a79 100644 --- a/avail-js/docs/extrinsics/staking_bond_extra.ts +++ b/avail-js/docs/extrinsics/staking_bond_extra.ts @@ -1,7 +1,4 @@ -import { Keyring } from "@polkadot/api" -import { BN } from "@polkadot/util" -import { SDK } from "avail-js-sdk" -import { WaitFor } from "avail-js-sdk/sdk/transactions" +import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -17,8 +14,7 @@ const main = async () => { process.exit(1) } - console.log("Stash=" + result.event.stash + ", Amount=" + result.event.amount) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) + console.log(JSON.stringify(result, null, 4)) process.exit() } diff --git a/avail-js/docs/extrinsics/staking_chill.ts b/avail-js/docs/extrinsics/staking_chill.ts index 75be63950..2ec9e848c 100644 --- a/avail-js/docs/extrinsics/staking_chill.ts +++ b/avail-js/docs/extrinsics/staking_chill.ts @@ -1,7 +1,4 @@ -import { Keyring } from "@polkadot/api" -import { SDK } from "avail-js-sdk" -import { WaitFor } from "avail-js-sdk/sdk/transactions" - +import { SDK, WaitFor, Keyring } from "avail-js-sdk" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" const sdk = await SDK.New(providerEndpoint) @@ -15,8 +12,7 @@ const main = async () => { process.exit(1) } - console.log("Stash=" + result.event.stash) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) + console.log(JSON.stringify(result, null, 4)) process.exit() } diff --git a/avail-js/docs/extrinsics/staking_chill_other.ts b/avail-js/docs/extrinsics/staking_chill_other.ts index 12b087a90..a568bb6e8 100644 --- a/avail-js/docs/extrinsics/staking_chill_other.ts +++ b/avail-js/docs/extrinsics/staking_chill_other.ts @@ -1,7 +1,4 @@ -import { Keyring } from "@polkadot/api" -import { SDK } from "avail-js-sdk" -import { WaitFor } from "avail-js-sdk/sdk/transactions" - +import { SDK, WaitFor, Keyring } from "avail-js-sdk" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" const sdk = await SDK.New(providerEndpoint) @@ -16,8 +13,7 @@ const main = async () => { process.exit(1) } - console.log("Stash=" + result.event.stash) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) + console.log(JSON.stringify(result, null, 4)) process.exit() } diff --git a/avail-js/docs/extrinsics/staking_nominate.ts b/avail-js/docs/extrinsics/staking_nominate.ts index c29aeebc1..f1b3a23f2 100644 --- a/avail-js/docs/extrinsics/staking_nominate.ts +++ b/avail-js/docs/extrinsics/staking_nominate.ts @@ -1,6 +1,4 @@ -import { Keyring } from "@polkadot/api" -import { SDK } from "avail-js-sdk" -import { WaitFor } from "avail-js-sdk/sdk/transactions" +import { SDK, WaitFor, Keyring } from "avail-js-sdk" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -19,8 +17,7 @@ const main = async () => { process.exit(1) } - console.log("TxDataTargets=" + result.txData.targets) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) + console.log(JSON.stringify(result, null, 4)) process.exit() } diff --git a/avail-js/docs/extrinsics/staking_unbond.ts b/avail-js/docs/extrinsics/staking_unbond.ts index 03ca85b11..066efc3e0 100644 --- a/avail-js/docs/extrinsics/staking_unbond.ts +++ b/avail-js/docs/extrinsics/staking_unbond.ts @@ -1,7 +1,4 @@ -import { Keyring } from "@polkadot/api" -import { BN } from "@polkadot/util" -import { SDK } from "avail-js-sdk" -import { WaitFor } from "avail-js-sdk/sdk/transactions" +import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -17,9 +14,7 @@ const main = async () => { process.exit(1) } - console.log("Stash=" + result.event.stash + ", Amount=" + result.event.amount) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) - + console.log(JSON.stringify(result, null, 4)) process.exit() } main() diff --git a/avail-js/docs/extrinsics/staking_validate.ts b/avail-js/docs/extrinsics/staking_validate.ts index 67f1407e5..385773b23 100644 --- a/avail-js/docs/extrinsics/staking_validate.ts +++ b/avail-js/docs/extrinsics/staking_validate.ts @@ -1,6 +1,4 @@ -import { Keyring } from "@polkadot/api" -import { SDK } from "avail-js-sdk" -import { WaitFor } from "avail-js-sdk/sdk/transactions" +import { SDK, WaitFor, Keyring } from "avail-js-sdk" const main = async () => { const providerEndpoint = "ws://127.0.0.1:9944" @@ -17,10 +15,7 @@ const main = async () => { process.exit(1) } - console.log( - "Stash=" + result.event.stash + ", Commission=" + result.event.commission + ", Blocked=" + result.event.blocked, - ) - console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash) + console.log(JSON.stringify(result, null, 4)) process.exit() } diff --git a/avail-js/docs/package-lock.json b/avail-js/docs/package-lock.json index 9ce05614b..57a79a496 100644 --- a/avail-js/docs/package-lock.json +++ b/avail-js/docs/package-lock.json @@ -8,7 +8,7 @@ "name": "avail-js-docs", "version": "0.0.1", "dependencies": { - "avail-js-sdk": "^0.2.15" + "avail-js-sdk": "^0.2.16" } }, "node_modules/@noble/curves": { @@ -645,9 +645,9 @@ } }, "node_modules/avail-js-sdk": { - "version": "0.2.15", - "resolved": "https://registry.npmjs.org/avail-js-sdk/-/avail-js-sdk-0.2.15.tgz", - "integrity": "sha512-9UtEzON0vEFHl9hKTFdBz+NjmN51ufsWBvpKX5oFo9VUzd5qrcQbznygaWkurM26wfFxySoX+njZElQCzxz3/g==", + "version": "0.2.16", + "resolved": "https://registry.npmjs.org/avail-js-sdk/-/avail-js-sdk-0.2.16.tgz", + "integrity": "sha512-TGJLhyRwIjNKHZ94Qe8fhd+mtMxTrt7nDjYaZ0AA6wop6ten8vingoE4oZ3RPwY+rOD87QGCPNhLlRVrmt2cSw==", "dependencies": { "@polkadot/api": "^10.11.3", "neverthrow": "^7.0.0" diff --git a/avail-js/docs/package.json b/avail-js/docs/package.json index 3659ab666..9817fdc33 100644 --- a/avail-js/docs/package.json +++ b/avail-js/docs/package.json @@ -3,7 +3,7 @@ "version": "0.0.1", "description": "Shows a basic usage of the Avail-js SDK", "dependencies": { - "avail-js-sdk": "^0.2.15" + "avail-js-sdk": "^0.2.16" }, "resolutions": { "ws": ">=8.17.1" diff --git a/avail-js/docs/storage/da_app_keys.ts b/avail-js/docs/storage/da_app_keys.ts new file mode 100644 index 000000000..61cf942fa --- /dev/null +++ b/avail-js/docs/storage/da_app_keys.ts @@ -0,0 +1,14 @@ +import { SDK } from "avail-js-sdk" + +const main = async () => { + const providerEndpoint = "ws://127.0.0.1:9944" + const sdk = await SDK.New(providerEndpoint) + + const key = "Reserved-2" + const value = await sdk.api.query.dataAvailability.appKeys(key) + console.log(value.toHuman()) + + process.exit() +} + +main() diff --git a/avail-js/docs/storage/da_app_keys_iter.ts b/avail-js/docs/storage/da_app_keys_iter.ts new file mode 100644 index 000000000..ca62fc37a --- /dev/null +++ b/avail-js/docs/storage/da_app_keys_iter.ts @@ -0,0 +1,16 @@ +import { SDK } from "avail-js-sdk" + +const main = async () => { + const providerEndpoint = "ws://127.0.0.1:9944" + const sdk = await SDK.New(providerEndpoint) + + const appKeys = await sdk.api.query.dataAvailability.appKeys.entries() + for (const [key, value] of appKeys) { + console.log(key.toHuman()) + console.log(value.toHuman()) + } + + process.exit() +} + +main() diff --git a/avail-js/docs/storage/da_next_app_id.ts b/avail-js/docs/storage/da_next_app_id.ts new file mode 100644 index 000000000..51419c71f --- /dev/null +++ b/avail-js/docs/storage/da_next_app_id.ts @@ -0,0 +1,13 @@ +import { SDK } from "avail-js-sdk" + +const main = async () => { + const providerEndpoint = "ws://127.0.0.1:9944" + const sdk = await SDK.New(providerEndpoint) + + const value = await sdk.api.query.dataAvailability.nextAppId() + console.log(value.toHuman()) + + process.exit() +} + +main() diff --git a/avail-js/docs/storage/staking_active_era.ts b/avail-js/docs/storage/staking_active_era.ts new file mode 100644 index 000000000..b9bad52b2 --- /dev/null +++ b/avail-js/docs/storage/staking_active_era.ts @@ -0,0 +1,13 @@ +import { SDK } from "avail-js-sdk" + +const main = async () => { + const providerEndpoint = "ws://127.0.0.1:9944" + const sdk = await SDK.New(providerEndpoint) + + const value = await sdk.api.query.staking.activeEra() + console.log(value.toHuman()) + + process.exit() +} + +main() diff --git a/avail-js/docs/storage/staking_bonded.ts b/avail-js/docs/storage/staking_bonded.ts new file mode 100644 index 000000000..0296ea8f6 --- /dev/null +++ b/avail-js/docs/storage/staking_bonded.ts @@ -0,0 +1,14 @@ +import { SDK } from "avail-js-sdk" + +const main = async () => { + const providerEndpoint = "ws://127.0.0.1:9944" + const sdk = await SDK.New(providerEndpoint) + + const key = "5EYCAe5ijiYfAXEth5DCfmQ9jnv4BFmdonKpbxwrc2nAw5uj" + const value = await sdk.api.query.staking.bonded(key) + console.log(value.toHuman()) + + process.exit() +} + +main() diff --git a/avail-js/docs/storage/staking_bonded_iter.ts b/avail-js/docs/storage/staking_bonded_iter.ts new file mode 100644 index 000000000..7b548f41b --- /dev/null +++ b/avail-js/docs/storage/staking_bonded_iter.ts @@ -0,0 +1,16 @@ +import { SDK } from "avail-js-sdk" + +const main = async () => { + const providerEndpoint = "ws://127.0.0.1:9944" + const sdk = await SDK.New(providerEndpoint) + + const accounts = await sdk.api.query.staking.bonded.entries() + for (const [key, value] of accounts) { + console.log(key.toHuman()) + console.log(value.toHuman()) + } + + process.exit() +} + +main() diff --git a/avail-js/docs/storage/system_account.ts b/avail-js/docs/storage/system_account.ts new file mode 100644 index 000000000..051783a4f --- /dev/null +++ b/avail-js/docs/storage/system_account.ts @@ -0,0 +1,14 @@ +import { SDK } from "avail-js-sdk" + +const main = async () => { + const providerEndpoint = "ws://127.0.0.1:9944" + const sdk = await SDK.New(providerEndpoint) + + const key = "5HKPmK9GYtE1PSLsS1qiYU9xQ9Si1NcEhdeCq9sw5bqu4ns8" + const value = await sdk.api.query.system.account(key) + console.log(value.toHuman()) + + process.exit() +} + +main() diff --git a/avail-js/docs/storage/system_account_iter.ts b/avail-js/docs/storage/system_account_iter.ts new file mode 100644 index 000000000..3d03cb1fc --- /dev/null +++ b/avail-js/docs/storage/system_account_iter.ts @@ -0,0 +1,16 @@ +import { SDK } from "avail-js-sdk" + +const main = async () => { + const providerEndpoint = "ws://127.0.0.1:9944" + const sdk = await SDK.New(providerEndpoint) + + const accounts = await sdk.api.query.system.account.entries() + for (const [key, value] of accounts) { + console.log(key.toHuman()) + console.log(value.toHuman()) + } + + process.exit() +} + +main() diff --git a/avail-js/examples/next-example/package-lock.json b/avail-js/examples/next-example/package-lock.json index a41e63014..2512b530b 100644 --- a/avail-js/examples/next-example/package-lock.json +++ b/avail-js/examples/next-example/package-lock.json @@ -14,10 +14,10 @@ "@types/react": "18.2.67", "@types/react-dom": "18.2.22", "autoprefixer": "10.4.18", - "avail-js-sdk": "^0.2.15", + "avail-js-sdk": "^0.2.16", "eslint": "8.57.0", "eslint-config-next": "14.1.4", - "next": "14.1.4", + "next": "^14.2.12", "postcss": "8.4.37", "react": "18.2.0", "react-dom": "18.2.0", @@ -227,9 +227,9 @@ "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==" }, "node_modules/@next/env": { - "version": "14.1.4", - "resolved": "https://registry.npmjs.org/@next/env/-/env-14.1.4.tgz", - "integrity": "sha512-e7X7bbn3Z6DWnDi75UWn+REgAbLEqxI8Tq2pkFOFAMpWAWApz/YCUhtWMWn410h8Q2fYiYL7Yg5OlxMOCfFjJQ==" + "version": "14.2.12", + "resolved": "https://registry.npmjs.org/@next/env/-/env-14.2.12.tgz", + "integrity": "sha512-3fP29GIetdwVIfIRyLKM7KrvJaqepv+6pVodEbx0P5CaMLYBtx+7eEg8JYO5L9sveJO87z9eCReceZLi0hxO1Q==" }, "node_modules/@next/eslint-plugin-next": { "version": "14.1.4", @@ -283,9 +283,9 @@ } }, "node_modules/@next/swc-darwin-arm64": { - "version": "14.1.4", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.1.4.tgz", - "integrity": "sha512-ubmUkbmW65nIAOmoxT1IROZdmmJMmdYvXIe8211send9ZYJu+SqxSnJM4TrPj9wmL6g9Atvj0S/2cFmMSS99jg==", + "version": "14.2.12", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.2.12.tgz", + "integrity": "sha512-crHJ9UoinXeFbHYNok6VZqjKnd8rTd7K3Z2zpyzF1ch7vVNKmhjv/V7EHxep3ILoN8JB9AdRn/EtVVyG9AkCXw==", "cpu": [ "arm64" ], @@ -298,9 +298,9 @@ } }, "node_modules/@next/swc-darwin-x64": { - "version": "14.1.4", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.1.4.tgz", - "integrity": "sha512-b0Xo1ELj3u7IkZWAKcJPJEhBop117U78l70nfoQGo4xUSvv0PJSTaV4U9xQBLvZlnjsYkc8RwQN1HoH/oQmLlQ==", + "version": "14.2.12", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.12.tgz", + "integrity": "sha512-JbEaGbWq18BuNBO+lCtKfxl563Uw9oy2TodnN2ioX00u7V1uzrsSUcg3Ep9ce+P0Z9es+JmsvL2/rLphz+Frcw==", "cpu": [ "x64" ], @@ -313,9 +313,9 @@ } }, "node_modules/@next/swc-linux-arm64-gnu": { - "version": "14.1.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.1.4.tgz", - "integrity": "sha512-457G0hcLrdYA/u1O2XkRMsDKId5VKe3uKPvrKVOyuARa6nXrdhJOOYU9hkKKyQTMru1B8qEP78IAhf/1XnVqKA==", + "version": "14.2.12", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.12.tgz", + "integrity": "sha512-qBy7OiXOqZrdp88QEl2H4fWalMGnSCrr1agT/AVDndlyw2YJQA89f3ttR/AkEIP9EkBXXeGl6cC72/EZT5r6rw==", "cpu": [ "arm64" ], @@ -328,9 +328,9 @@ } }, "node_modules/@next/swc-linux-arm64-musl": { - "version": "14.1.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.1.4.tgz", - "integrity": "sha512-l/kMG+z6MB+fKA9KdtyprkTQ1ihlJcBh66cf0HvqGP+rXBbOXX0dpJatjZbHeunvEHoBBS69GYQG5ry78JMy3g==", + "version": "14.2.12", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.12.tgz", + "integrity": "sha512-EfD9L7o9biaQxjwP1uWXnk3vYZi64NVcKUN83hpVkKocB7ogJfyH2r7o1pPnMtir6gHZiGCeHKagJ0yrNSLNHw==", "cpu": [ "arm64" ], @@ -343,9 +343,9 @@ } }, "node_modules/@next/swc-linux-x64-gnu": { - "version": "14.1.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.1.4.tgz", - "integrity": "sha512-BapIFZ3ZRnvQ1uWbmqEGJuPT9cgLwvKtxhK/L2t4QYO7l+/DxXuIGjvp1x8rvfa/x1FFSsipERZK70pewbtJtw==", + "version": "14.2.12", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.12.tgz", + "integrity": "sha512-iQ+n2pxklJew9IpE47hE/VgjmljlHqtcD5UhZVeHICTPbLyrgPehaKf2wLRNjYH75udroBNCgrSSVSVpAbNoYw==", "cpu": [ "x64" ], @@ -358,9 +358,9 @@ } }, "node_modules/@next/swc-linux-x64-musl": { - "version": "14.1.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.1.4.tgz", - "integrity": "sha512-mqVxTwk4XuBl49qn2A5UmzFImoL1iLm0KQQwtdRJRKl21ylQwwGCxJtIYo2rbfkZHoSKlh/YgztY0qH3wG1xIg==", + "version": "14.2.12", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.12.tgz", + "integrity": "sha512-rFkUkNwcQ0ODn7cxvcVdpHlcOpYxMeyMfkJuzaT74xjAa5v4fxP4xDk5OoYmPi8QNLDs3UgZPMSBmpBuv9zKWA==", "cpu": [ "x64" ], @@ -373,9 +373,9 @@ } }, "node_modules/@next/swc-win32-arm64-msvc": { - "version": "14.1.4", - "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.1.4.tgz", - "integrity": "sha512-xzxF4ErcumXjO2Pvg/wVGrtr9QQJLk3IyQX1ddAC/fi6/5jZCZ9xpuL9Tzc4KPWMFq8GGWFVDMshZOdHGdkvag==", + "version": "14.2.12", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.12.tgz", + "integrity": "sha512-PQFYUvwtHs/u0K85SG4sAdDXYIPXpETf9mcEjWc0R4JmjgMKSDwIU/qfZdavtP6MPNiMjuKGXHCtyhR/M5zo8g==", "cpu": [ "arm64" ], @@ -388,9 +388,9 @@ } }, "node_modules/@next/swc-win32-ia32-msvc": { - "version": "14.1.4", - "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.1.4.tgz", - "integrity": "sha512-WZiz8OdbkpRw6/IU/lredZWKKZopUMhcI2F+XiMAcPja0uZYdMTZQRoQ0WZcvinn9xZAidimE7tN9W5v9Yyfyw==", + "version": "14.2.12", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.12.tgz", + "integrity": "sha512-FAj2hMlcbeCV546eU2tEv41dcJb4NeqFlSXU/xL/0ehXywHnNpaYajOUvn3P8wru5WyQe6cTZ8fvckj/2XN4Vw==", "cpu": [ "ia32" ], @@ -403,9 +403,9 @@ } }, "node_modules/@next/swc-win32-x64-msvc": { - "version": "14.1.4", - "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.1.4.tgz", - "integrity": "sha512-4Rto21sPfw555sZ/XNLqfxDUNeLhNYGO2dlPqsnuCg8N8a2a9u1ltqBOPQ4vj1Gf7eJC0W2hHG2eYUHuiXgY2w==", + "version": "14.2.12", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.12.tgz", + "integrity": "sha512-yu8QvV53sBzoIVRHsxCHqeuS8jYq6Lrmdh0briivuh+Brsp6xjg80MAozUsBTAV9KNmY08KlX0KYTWz1lbPzEg==", "cpu": [ "x64" ], @@ -1138,11 +1138,17 @@ "resolved": "https://registry.npmjs.org/@substrate/ss58-registry/-/ss58-registry-1.46.0.tgz", "integrity": "sha512-rBvWnlrBeFTd5LVG7oX3rOHzR16yqyffOFHKmUiVcblpXI3D89CXOvAljW9tWlA1H/2/FegaZnHPhdObPsvi+w==" }, + "node_modules/@swc/counter": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.3.tgz", + "integrity": "sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==" + }, "node_modules/@swc/helpers": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.2.tgz", - "integrity": "sha512-E4KcWTpoLHqwPHLxidpOqQbcrZVgi0rsmmZXUle1jXmJfuIf/UWpczUJ7MZZ5tlxytgJXyp0w4PGkkeLiuIdZw==", + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.5.tgz", + "integrity": "sha512-KGYxvIOXcceOAbEk4bi/dVLEK9z8sZ0uBB3Il5b1rhfClSpcX0yfRO0KmTkqR2cnQDymwLB+25ZyMzICg/cm/A==", "dependencies": { + "@swc/counter": "^0.1.3", "tslib": "^2.4.0" } }, @@ -1558,9 +1564,9 @@ } }, "node_modules/avail-js-sdk": { - "version": "0.2.15", - "resolved": "https://registry.npmjs.org/avail-js-sdk/-/avail-js-sdk-0.2.15.tgz", - "integrity": "sha512-9UtEzON0vEFHl9hKTFdBz+NjmN51ufsWBvpKX5oFo9VUzd5qrcQbznygaWkurM26wfFxySoX+njZElQCzxz3/g==", + "version": "0.2.16", + "resolved": "https://registry.npmjs.org/avail-js-sdk/-/avail-js-sdk-0.2.16.tgz", + "integrity": "sha512-TGJLhyRwIjNKHZ94Qe8fhd+mtMxTrt7nDjYaZ0AA6wop6ten8vingoE4oZ3RPwY+rOD87QGCPNhLlRVrmt2cSw==", "dependencies": { "@polkadot/api": "^10.11.3", "neverthrow": "^7.0.0" @@ -3741,11 +3747,11 @@ } }, "node_modules/micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dependencies": { - "braces": "^3.0.2", + "braces": "^3.0.3", "picomatch": "^2.3.1" }, "engines": { @@ -3844,12 +3850,12 @@ } }, "node_modules/next": { - "version": "14.1.4", - "resolved": "https://registry.npmjs.org/next/-/next-14.1.4.tgz", - "integrity": "sha512-1WTaXeSrUwlz/XcnhGTY7+8eiaFvdet5z9u3V2jb+Ek1vFo0VhHKSAIJvDWfQpttWjnyw14kBeq28TPq7bTeEQ==", + "version": "14.2.12", + "resolved": "https://registry.npmjs.org/next/-/next-14.2.12.tgz", + "integrity": "sha512-cDOtUSIeoOvt1skKNihdExWMTybx3exnvbFbb9ecZDIxlvIbREQzt9A5Km3Zn3PfU+IFjyYGsHS+lN9VInAGKA==", "dependencies": { - "@next/env": "14.1.4", - "@swc/helpers": "0.5.2", + "@next/env": "14.2.12", + "@swc/helpers": "0.5.5", "busboy": "1.6.0", "caniuse-lite": "^1.0.30001579", "graceful-fs": "^4.2.11", @@ -3863,18 +3869,19 @@ "node": ">=18.17.0" }, "optionalDependencies": { - "@next/swc-darwin-arm64": "14.1.4", - "@next/swc-darwin-x64": "14.1.4", - "@next/swc-linux-arm64-gnu": "14.1.4", - "@next/swc-linux-arm64-musl": "14.1.4", - "@next/swc-linux-x64-gnu": "14.1.4", - "@next/swc-linux-x64-musl": "14.1.4", - "@next/swc-win32-arm64-msvc": "14.1.4", - "@next/swc-win32-ia32-msvc": "14.1.4", - "@next/swc-win32-x64-msvc": "14.1.4" + "@next/swc-darwin-arm64": "14.2.12", + "@next/swc-darwin-x64": "14.2.12", + "@next/swc-linux-arm64-gnu": "14.2.12", + "@next/swc-linux-arm64-musl": "14.2.12", + "@next/swc-linux-x64-gnu": "14.2.12", + "@next/swc-linux-x64-musl": "14.2.12", + "@next/swc-win32-arm64-msvc": "14.2.12", + "@next/swc-win32-ia32-msvc": "14.2.12", + "@next/swc-win32-x64-msvc": "14.2.12" }, "peerDependencies": { "@opentelemetry/api": "^1.1.0", + "@playwright/test": "^1.41.2", "react": "^18.2.0", "react-dom": "^18.2.0", "sass": "^1.3.0" @@ -3883,6 +3890,9 @@ "@opentelemetry/api": { "optional": true }, + "@playwright/test": { + "optional": true + }, "sass": { "optional": true } diff --git a/avail-js/examples/next-example/package.json b/avail-js/examples/next-example/package.json index cf3221d10..d82267bc8 100644 --- a/avail-js/examples/next-example/package.json +++ b/avail-js/examples/next-example/package.json @@ -15,10 +15,10 @@ "@types/react": "18.2.67", "@types/react-dom": "18.2.22", "autoprefixer": "10.4.18", - "avail-js-sdk": "^0.2.15", + "avail-js-sdk": "^0.2.16", "eslint": "8.57.0", "eslint-config-next": "14.1.4", - "next": "14.1.4", + "next": "^14.2.12", "postcss": "8.4.37", "react": "18.2.0", "react-dom": "18.2.0", diff --git a/avail-js/examples/node-examples/package-lock.json b/avail-js/examples/node-examples/package-lock.json index 53a72c758..1a34196ab 100644 --- a/avail-js/examples/node-examples/package-lock.json +++ b/avail-js/examples/node-examples/package-lock.json @@ -8,710 +8,17 @@ "name": "node-examples", "version": "0.0.1", "dependencies": { - "avail-js-sdk": "^0.2.15", - "ethers": "5.4" + "avail-js-sdk": "^0.2.16", + "ethers": "^6.13.2" }, "devDependencies": { "rimraf": "^5.0.5" } }, - "node_modules/@ethersproject/abi": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.4.1.tgz", - "integrity": "sha512-9mhbjUk76BiSluiiW4BaYyI58KSbDMMQpCLdsAR+RsT2GyATiNYxVv+pGWRrekmsIdY3I+hOqsYQSTkc8L/mcg==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/address": "^5.4.0", - "@ethersproject/bignumber": "^5.4.0", - "@ethersproject/bytes": "^5.4.0", - "@ethersproject/constants": "^5.4.0", - "@ethersproject/hash": "^5.4.0", - "@ethersproject/keccak256": "^5.4.0", - "@ethersproject/logger": "^5.4.0", - "@ethersproject/properties": "^5.4.0", - "@ethersproject/strings": "^5.4.0" - } - }, - "node_modules/@ethersproject/abstract-provider": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/@ethersproject/abstract-provider/-/abstract-provider-5.4.1.tgz", - "integrity": "sha512-3EedfKI3LVpjSKgAxoUaI+gB27frKsxzm+r21w9G60Ugk+3wVLQwhi1LsEJAKNV7WoZc8CIpNrATlL1QFABjtQ==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bignumber": "^5.4.0", - "@ethersproject/bytes": "^5.4.0", - "@ethersproject/logger": "^5.4.0", - "@ethersproject/networks": "^5.4.0", - "@ethersproject/properties": "^5.4.0", - "@ethersproject/transactions": "^5.4.0", - "@ethersproject/web": "^5.4.0" - } - }, - "node_modules/@ethersproject/abstract-signer": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/@ethersproject/abstract-signer/-/abstract-signer-5.4.1.tgz", - "integrity": "sha512-SkkFL5HVq1k4/25dM+NWP9MILgohJCgGv5xT5AcRruGz4ILpfHeBtO/y6j+Z3UN/PAjDeb4P7E51Yh8wcGNLGA==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/abstract-provider": "^5.4.0", - "@ethersproject/bignumber": "^5.4.0", - "@ethersproject/bytes": "^5.4.0", - "@ethersproject/logger": "^5.4.0", - "@ethersproject/properties": "^5.4.0" - } - }, - "node_modules/@ethersproject/address": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@ethersproject/address/-/address-5.4.0.tgz", - "integrity": "sha512-SD0VgOEkcACEG/C6xavlU1Hy3m5DGSXW3CUHkaaEHbAPPsgi0coP5oNPsxau8eTlZOk/bpa/hKeCNoK5IzVI2Q==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bignumber": "^5.4.0", - "@ethersproject/bytes": "^5.4.0", - "@ethersproject/keccak256": "^5.4.0", - "@ethersproject/logger": "^5.4.0", - "@ethersproject/rlp": "^5.4.0" - } - }, - "node_modules/@ethersproject/base64": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@ethersproject/base64/-/base64-5.4.0.tgz", - "integrity": "sha512-CjQw6E17QDSSC5jiM9YpF7N1aSCHmYGMt9bWD8PWv6YPMxjsys2/Q8xLrROKI3IWJ7sFfZ8B3flKDTM5wlWuZQ==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bytes": "^5.4.0" - } - }, - "node_modules/@ethersproject/basex": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@ethersproject/basex/-/basex-5.4.0.tgz", - "integrity": "sha512-J07+QCVJ7np2bcpxydFVf/CuYo9mZ7T73Pe7KQY4c1lRlrixMeblauMxHXD0MPwFmUHZIILDNViVkykFBZylbg==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bytes": "^5.4.0", - "@ethersproject/properties": "^5.4.0" - } - }, - "node_modules/@ethersproject/bignumber": { - "version": "5.4.2", - "resolved": "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.4.2.tgz", - "integrity": "sha512-oIBDhsKy5bs7j36JlaTzFgNPaZjiNDOXsdSgSpXRucUl+UA6L/1YLlFeI3cPAoodcenzF4nxNPV13pcy7XbWjA==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bytes": "^5.4.0", - "@ethersproject/logger": "^5.4.0", - "bn.js": "^4.11.9" - } - }, - "node_modules/@ethersproject/bignumber/node_modules/bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" - }, - "node_modules/@ethersproject/bytes": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@ethersproject/bytes/-/bytes-5.4.0.tgz", - "integrity": "sha512-H60ceqgTHbhzOj4uRc/83SCN9d+BSUnOkrr2intevqdtEMO1JFVZ1XL84OEZV+QjV36OaZYxtnt4lGmxcGsPfA==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/logger": "^5.4.0" - } - }, - "node_modules/@ethersproject/constants": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@ethersproject/constants/-/constants-5.4.0.tgz", - "integrity": "sha512-tzjn6S7sj9+DIIeKTJLjK9WGN2Tj0P++Z8ONEIlZjyoTkBuODN+0VfhAyYksKi43l1Sx9tX2VlFfzjfmr5Wl3Q==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bignumber": "^5.4.0" - } - }, - "node_modules/@ethersproject/contracts": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/@ethersproject/contracts/-/contracts-5.4.1.tgz", - "integrity": "sha512-m+z2ZgPy4pyR15Je//dUaymRUZq5MtDajF6GwFbGAVmKz/RF+DNIPwF0k5qEcL3wPGVqUjFg2/krlCRVTU4T5w==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/abi": "^5.4.0", - "@ethersproject/abstract-provider": "^5.4.0", - "@ethersproject/abstract-signer": "^5.4.0", - "@ethersproject/address": "^5.4.0", - "@ethersproject/bignumber": "^5.4.0", - "@ethersproject/bytes": "^5.4.0", - "@ethersproject/constants": "^5.4.0", - "@ethersproject/logger": "^5.4.0", - "@ethersproject/properties": "^5.4.0", - "@ethersproject/transactions": "^5.4.0" - } - }, - "node_modules/@ethersproject/hash": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@ethersproject/hash/-/hash-5.4.0.tgz", - "integrity": "sha512-xymAM9tmikKgbktOCjW60Z5sdouiIIurkZUr9oW5NOex5uwxrbsYG09kb5bMcNjlVeJD3yPivTNzViIs1GCbqA==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/abstract-signer": "^5.4.0", - "@ethersproject/address": "^5.4.0", - "@ethersproject/bignumber": "^5.4.0", - "@ethersproject/bytes": "^5.4.0", - "@ethersproject/keccak256": "^5.4.0", - "@ethersproject/logger": "^5.4.0", - "@ethersproject/properties": "^5.4.0", - "@ethersproject/strings": "^5.4.0" - } - }, - "node_modules/@ethersproject/hdnode": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@ethersproject/hdnode/-/hdnode-5.4.0.tgz", - "integrity": "sha512-pKxdS0KAaeVGfZPp1KOiDLB0jba11tG6OP1u11QnYfb7pXn6IZx0xceqWRr6ygke8+Kw74IpOoSi7/DwANhy8Q==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/abstract-signer": "^5.4.0", - "@ethersproject/basex": "^5.4.0", - "@ethersproject/bignumber": "^5.4.0", - "@ethersproject/bytes": "^5.4.0", - "@ethersproject/logger": "^5.4.0", - "@ethersproject/pbkdf2": "^5.4.0", - "@ethersproject/properties": "^5.4.0", - "@ethersproject/sha2": "^5.4.0", - "@ethersproject/signing-key": "^5.4.0", - "@ethersproject/strings": "^5.4.0", - "@ethersproject/transactions": "^5.4.0", - "@ethersproject/wordlists": "^5.4.0" - } - }, - "node_modules/@ethersproject/json-wallets": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@ethersproject/json-wallets/-/json-wallets-5.4.0.tgz", - "integrity": "sha512-igWcu3fx4aiczrzEHwG1xJZo9l1cFfQOWzTqwRw/xcvxTk58q4f9M7cjh51EKphMHvrJtcezJ1gf1q1AUOfEQQ==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/abstract-signer": "^5.4.0", - "@ethersproject/address": "^5.4.0", - "@ethersproject/bytes": "^5.4.0", - "@ethersproject/hdnode": "^5.4.0", - "@ethersproject/keccak256": "^5.4.0", - "@ethersproject/logger": "^5.4.0", - "@ethersproject/pbkdf2": "^5.4.0", - "@ethersproject/properties": "^5.4.0", - "@ethersproject/random": "^5.4.0", - "@ethersproject/strings": "^5.4.0", - "@ethersproject/transactions": "^5.4.0", - "aes-js": "3.0.0", - "scrypt-js": "3.0.1" - } - }, - "node_modules/@ethersproject/keccak256": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@ethersproject/keccak256/-/keccak256-5.4.0.tgz", - "integrity": "sha512-FBI1plWet+dPUvAzPAeHzRKiPpETQzqSUWR1wXJGHVWi4i8bOSrpC3NwpkPjgeXG7MnugVc1B42VbfnQikyC/A==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bytes": "^5.4.0", - "js-sha3": "0.5.7" - } - }, - "node_modules/@ethersproject/logger": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/@ethersproject/logger/-/logger-5.4.1.tgz", - "integrity": "sha512-DZ+bRinnYLPw1yAC64oRl0QyVZj43QeHIhVKfD/+YwSz4wsv1pfwb5SOFjz+r710YEWzU6LrhuSjpSO+6PeE4A==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ] - }, - "node_modules/@ethersproject/networks": { - "version": "5.4.2", - "resolved": "https://registry.npmjs.org/@ethersproject/networks/-/networks-5.4.2.tgz", - "integrity": "sha512-eekOhvJyBnuibfJnhtK46b8HimBc5+4gqpvd1/H9LEl7Q7/qhsIhM81dI9Fcnjpk3jB1aTy6bj0hz3cifhNeYw==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/logger": "^5.4.0" - } - }, - "node_modules/@ethersproject/pbkdf2": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@ethersproject/pbkdf2/-/pbkdf2-5.4.0.tgz", - "integrity": "sha512-x94aIv6tiA04g6BnazZSLoRXqyusawRyZWlUhKip2jvoLpzJuLb//KtMM6PEovE47pMbW+Qe1uw+68ameJjB7g==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bytes": "^5.4.0", - "@ethersproject/sha2": "^5.4.0" - } - }, - "node_modules/@ethersproject/properties": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/@ethersproject/properties/-/properties-5.4.1.tgz", - "integrity": "sha512-cyCGlF8wWlIZyizsj2PpbJ9I7rIlUAfnHYwy/T90pdkSn/NFTa5YWZx2wTJBe9V7dD65dcrrEMisCRUJiq6n3w==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/logger": "^5.4.0" - } - }, - "node_modules/@ethersproject/providers": { - "version": "5.4.5", - "resolved": "https://registry.npmjs.org/@ethersproject/providers/-/providers-5.4.5.tgz", - "integrity": "sha512-1GkrvkiAw3Fj28cwi1Sqm8ED1RtERtpdXmRfwIBGmqBSN5MoeRUHuwHPppMtbPayPgpFcvD7/Gdc9doO5fGYgw==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/abstract-provider": "^5.4.0", - "@ethersproject/abstract-signer": "^5.4.0", - "@ethersproject/address": "^5.4.0", - "@ethersproject/basex": "^5.4.0", - "@ethersproject/bignumber": "^5.4.0", - "@ethersproject/bytes": "^5.4.0", - "@ethersproject/constants": "^5.4.0", - "@ethersproject/hash": "^5.4.0", - "@ethersproject/logger": "^5.4.0", - "@ethersproject/networks": "^5.4.0", - "@ethersproject/properties": "^5.4.0", - "@ethersproject/random": "^5.4.0", - "@ethersproject/rlp": "^5.4.0", - "@ethersproject/sha2": "^5.4.0", - "@ethersproject/strings": "^5.4.0", - "@ethersproject/transactions": "^5.4.0", - "@ethersproject/web": "^5.4.0", - "bech32": "1.1.4", - "ws": "7.4.6" - } - }, - "node_modules/@ethersproject/providers/node_modules/ws": { - "version": "7.4.6", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz", - "integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==", - "engines": { - "node": ">=8.3.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - }, - "node_modules/@ethersproject/random": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@ethersproject/random/-/random-5.4.0.tgz", - "integrity": "sha512-pnpWNQlf0VAZDEOVp1rsYQosmv2o0ITS/PecNw+mS2/btF8eYdspkN0vIXrCMtkX09EAh9bdk8GoXmFXM1eAKw==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bytes": "^5.4.0", - "@ethersproject/logger": "^5.4.0" - } - }, - "node_modules/@ethersproject/rlp": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@ethersproject/rlp/-/rlp-5.4.0.tgz", - "integrity": "sha512-0I7MZKfi+T5+G8atId9QaQKHRvvasM/kqLyAH4XxBCBchAooH2EX5rL9kYZWwcm3awYV+XC7VF6nLhfeQFKVPg==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bytes": "^5.4.0", - "@ethersproject/logger": "^5.4.0" - } - }, - "node_modules/@ethersproject/sha2": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@ethersproject/sha2/-/sha2-5.4.0.tgz", - "integrity": "sha512-siheo36r1WD7Cy+bDdE1BJ8y0bDtqXCOxRMzPa4bV1TGt/eTUUt03BHoJNB6reWJD8A30E/pdJ8WFkq+/uz4Gg==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bytes": "^5.4.0", - "@ethersproject/logger": "^5.4.0", - "hash.js": "1.1.7" - } - }, - "node_modules/@ethersproject/signing-key": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@ethersproject/signing-key/-/signing-key-5.4.0.tgz", - "integrity": "sha512-q8POUeywx6AKg2/jX9qBYZIAmKSB4ubGXdQ88l40hmATj29JnG5pp331nAWwwxPn2Qao4JpWHNZsQN+bPiSW9A==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bytes": "^5.4.0", - "@ethersproject/logger": "^5.4.0", - "@ethersproject/properties": "^5.4.0", - "bn.js": "^4.11.9", - "elliptic": "6.5.4", - "hash.js": "1.1.7" - } - }, - "node_modules/@ethersproject/signing-key/node_modules/bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" - }, - "node_modules/@ethersproject/solidity": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@ethersproject/solidity/-/solidity-5.4.0.tgz", - "integrity": "sha512-XFQTZ7wFSHOhHcV1DpcWj7VXECEiSrBuv7JErJvB9Uo+KfCdc3QtUZV+Vjh/AAaYgezUEKbCtE6Khjm44seevQ==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bignumber": "^5.4.0", - "@ethersproject/bytes": "^5.4.0", - "@ethersproject/keccak256": "^5.4.0", - "@ethersproject/sha2": "^5.4.0", - "@ethersproject/strings": "^5.4.0" - } - }, - "node_modules/@ethersproject/strings": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@ethersproject/strings/-/strings-5.4.0.tgz", - "integrity": "sha512-k/9DkH5UGDhv7aReXLluFG5ExurwtIpUfnDNhQA29w896Dw3i4uDTz01Quaptbks1Uj9kI8wo9tmW73wcIEaWA==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bytes": "^5.4.0", - "@ethersproject/constants": "^5.4.0", - "@ethersproject/logger": "^5.4.0" - } - }, - "node_modules/@ethersproject/transactions": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@ethersproject/transactions/-/transactions-5.4.0.tgz", - "integrity": "sha512-s3EjZZt7xa4BkLknJZ98QGoIza94rVjaEed0rzZ/jB9WrIuu/1+tjvYCWzVrystXtDswy7TPBeIepyXwSYa4WQ==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/address": "^5.4.0", - "@ethersproject/bignumber": "^5.4.0", - "@ethersproject/bytes": "^5.4.0", - "@ethersproject/constants": "^5.4.0", - "@ethersproject/keccak256": "^5.4.0", - "@ethersproject/logger": "^5.4.0", - "@ethersproject/properties": "^5.4.0", - "@ethersproject/rlp": "^5.4.0", - "@ethersproject/signing-key": "^5.4.0" - } - }, - "node_modules/@ethersproject/units": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@ethersproject/units/-/units-5.4.0.tgz", - "integrity": "sha512-Z88krX40KCp+JqPCP5oPv5p750g+uU6gopDYRTBGcDvOASh6qhiEYCRatuM/suC4S2XW9Zz90QI35MfSrTIaFg==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bignumber": "^5.4.0", - "@ethersproject/constants": "^5.4.0", - "@ethersproject/logger": "^5.4.0" - } - }, - "node_modules/@ethersproject/wallet": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@ethersproject/wallet/-/wallet-5.4.0.tgz", - "integrity": "sha512-wU29majLjM6AjCjpat21mPPviG+EpK7wY1+jzKD0fg3ui5fgedf2zEu1RDgpfIMsfn8fJHJuzM4zXZ2+hSHaSQ==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/abstract-provider": "^5.4.0", - "@ethersproject/abstract-signer": "^5.4.0", - "@ethersproject/address": "^5.4.0", - "@ethersproject/bignumber": "^5.4.0", - "@ethersproject/bytes": "^5.4.0", - "@ethersproject/hash": "^5.4.0", - "@ethersproject/hdnode": "^5.4.0", - "@ethersproject/json-wallets": "^5.4.0", - "@ethersproject/keccak256": "^5.4.0", - "@ethersproject/logger": "^5.4.0", - "@ethersproject/properties": "^5.4.0", - "@ethersproject/random": "^5.4.0", - "@ethersproject/signing-key": "^5.4.0", - "@ethersproject/transactions": "^5.4.0", - "@ethersproject/wordlists": "^5.4.0" - } - }, - "node_modules/@ethersproject/web": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@ethersproject/web/-/web-5.4.0.tgz", - "integrity": "sha512-1bUusGmcoRLYgMn6c1BLk1tOKUIFuTg8j+6N8lYlbMpDesnle+i3pGSagGNvwjaiLo4Y5gBibwctpPRmjrh4Og==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/base64": "^5.4.0", - "@ethersproject/bytes": "^5.4.0", - "@ethersproject/logger": "^5.4.0", - "@ethersproject/properties": "^5.4.0", - "@ethersproject/strings": "^5.4.0" - } - }, - "node_modules/@ethersproject/wordlists": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@ethersproject/wordlists/-/wordlists-5.4.0.tgz", - "integrity": "sha512-FemEkf6a+EBKEPxlzeVgUaVSodU7G0Na89jqKjmWMlDB0tomoU8RlEMgUvXyqtrg8N4cwpLh8nyRnm1Nay1isA==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bytes": "^5.4.0", - "@ethersproject/hash": "^5.4.0", - "@ethersproject/logger": "^5.4.0", - "@ethersproject/properties": "^5.4.0", - "@ethersproject/strings": "^5.4.0" - } + "node_modules/@adraffy/ens-normalize": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.10.1.tgz", + "integrity": "sha512-96Z2IP3mYmF1Xg2cDm8f1gWGf/HUVedQ3FMifV4kG/PQ4yEP51xDtRAEfhVNt5f/uzpNkZHwWQuUcu6D6K+Ekw==" }, "node_modules/@isaacs/cliui": { "version": "8.0.2", @@ -1373,9 +680,9 @@ } }, "node_modules/aes-js": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.0.0.tgz", - "integrity": "sha512-H7wUZRn8WpTq9jocdxQ2c8x2sKo9ZVmzfRE13GiNJXfp7NcKYEdvl3vspKjXox6RIG2VtaRe4JFvxG4rqp2Zuw==" + "version": "4.0.0-beta.5", + "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-4.0.0-beta.5.tgz", + "integrity": "sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q==" }, "node_modules/ansi-regex": { "version": "6.0.1", @@ -1402,9 +709,9 @@ } }, "node_modules/avail-js-sdk": { - "version": "0.2.15", - "resolved": "https://registry.npmjs.org/avail-js-sdk/-/avail-js-sdk-0.2.15.tgz", - "integrity": "sha512-9UtEzON0vEFHl9hKTFdBz+NjmN51ufsWBvpKX5oFo9VUzd5qrcQbznygaWkurM26wfFxySoX+njZElQCzxz3/g==", + "version": "0.2.16", + "resolved": "https://registry.npmjs.org/avail-js-sdk/-/avail-js-sdk-0.2.16.tgz", + "integrity": "sha512-TGJLhyRwIjNKHZ94Qe8fhd+mtMxTrt7nDjYaZ0AA6wop6ten8vingoE4oZ3RPwY+rOD87QGCPNhLlRVrmt2cSw==", "dependencies": { "@polkadot/api": "^10.11.3", "neverthrow": "^7.0.0" @@ -1416,11 +723,6 @@ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "dev": true }, - "node_modules/bech32": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/bech32/-/bech32-1.1.4.tgz", - "integrity": "sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==" - }, "node_modules/bn.js": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", @@ -1435,11 +737,6 @@ "balanced-match": "^1.0.0" } }, - "node_modules/brorand": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", - "integrity": "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==" - }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -1502,25 +799,6 @@ "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", "dev": true }, - "node_modules/elliptic": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", - "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", - "dependencies": { - "bn.js": "^4.11.9", - "brorand": "^1.1.0", - "hash.js": "^1.0.0", - "hmac-drbg": "^1.0.1", - "inherits": "^2.0.4", - "minimalistic-assert": "^1.0.1", - "minimalistic-crypto-utils": "^1.0.1" - } - }, - "node_modules/elliptic/node_modules/bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" - }, "node_modules/emoji-regex": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", @@ -1528,13 +806,13 @@ "dev": true }, "node_modules/ethers": { - "version": "5.4.7", - "resolved": "https://registry.npmjs.org/ethers/-/ethers-5.4.7.tgz", - "integrity": "sha512-iZc5p2nqfWK1sj8RabwsPM28cr37Bpq7ehTQ5rWExBr2Y09Sn1lDKZOED26n+TsZMye7Y6mIgQ/1cwpSD8XZew==", + "version": "6.13.2", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.13.2.tgz", + "integrity": "sha512-9VkriTTed+/27BGuY1s0hf441kqwHJ1wtN2edksEtiRvXx+soxRX3iSXTfFqq2+YwrOqbDoTHjIhQnjJRlzKmg==", "funding": [ { "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + "url": "https://github.com/sponsors/ethers-io/" }, { "type": "individual", @@ -1542,38 +820,50 @@ } ], "dependencies": { - "@ethersproject/abi": "5.4.1", - "@ethersproject/abstract-provider": "5.4.1", - "@ethersproject/abstract-signer": "5.4.1", - "@ethersproject/address": "5.4.0", - "@ethersproject/base64": "5.4.0", - "@ethersproject/basex": "5.4.0", - "@ethersproject/bignumber": "5.4.2", - "@ethersproject/bytes": "5.4.0", - "@ethersproject/constants": "5.4.0", - "@ethersproject/contracts": "5.4.1", - "@ethersproject/hash": "5.4.0", - "@ethersproject/hdnode": "5.4.0", - "@ethersproject/json-wallets": "5.4.0", - "@ethersproject/keccak256": "5.4.0", - "@ethersproject/logger": "5.4.1", - "@ethersproject/networks": "5.4.2", - "@ethersproject/pbkdf2": "5.4.0", - "@ethersproject/properties": "5.4.1", - "@ethersproject/providers": "5.4.5", - "@ethersproject/random": "5.4.0", - "@ethersproject/rlp": "5.4.0", - "@ethersproject/sha2": "5.4.0", - "@ethersproject/signing-key": "5.4.0", - "@ethersproject/solidity": "5.4.0", - "@ethersproject/strings": "5.4.0", - "@ethersproject/transactions": "5.4.0", - "@ethersproject/units": "5.4.0", - "@ethersproject/wallet": "5.4.0", - "@ethersproject/web": "5.4.0", - "@ethersproject/wordlists": "5.4.0" + "@adraffy/ens-normalize": "1.10.1", + "@noble/curves": "1.2.0", + "@noble/hashes": "1.3.2", + "@types/node": "18.15.13", + "aes-js": "4.0.0-beta.5", + "tslib": "2.4.0", + "ws": "8.17.1" + }, + "engines": { + "node": ">=14.0.0" } }, + "node_modules/ethers/node_modules/@noble/curves": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz", + "integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==", + "dependencies": { + "@noble/hashes": "1.3.2" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/ethers/node_modules/@noble/hashes": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", + "integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/ethers/node_modules/@types/node": { + "version": "18.15.13", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.13.tgz", + "integrity": "sha512-N+0kuo9KgrUQ1Sn/ifDXsvg0TTleP7rIy4zOBGECxAljqvqfqpTfzx0Q1NUedOixRMBfe2Whhb056a42cWs26Q==" + }, + "node_modules/ethers/node_modules/tslib": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", + "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==" + }, "node_modules/eventemitter3": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", @@ -1650,30 +940,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/hash.js": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", - "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", - "dependencies": { - "inherits": "^2.0.3", - "minimalistic-assert": "^1.0.1" - } - }, - "node_modules/hmac-drbg": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", - "integrity": "sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==", - "dependencies": { - "hash.js": "^1.0.3", - "minimalistic-assert": "^1.0.0", - "minimalistic-crypto-utils": "^1.0.1" - } - }, - "node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" - }, "node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", @@ -1707,11 +973,6 @@ "@pkgjs/parseargs": "^0.11.0" } }, - "node_modules/js-sha3": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", - "integrity": "sha512-GII20kjaPX0zJ8wzkTbNDYMY7msuZcTWk8S5UOh6806Jq/wz1J8/bnr8uGU0DAUmYDjj2Mr4X1cW8v/GLYnR+g==" - }, "node_modules/json-stringify-safe": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", @@ -1726,16 +987,6 @@ "node": "14 || >=16.14" } }, - "node_modules/minimalistic-assert": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", - "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" - }, - "node_modules/minimalistic-crypto-utils": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", - "integrity": "sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==" - }, "node_modules/minimatch": { "version": "9.0.3", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", @@ -1894,11 +1145,6 @@ "integrity": "sha512-Ja5VCjNZR8TGKhUumy9clVVxcDpM+YFjAnkMuwQy68Hixio3VRRvWdE3g8T/yC+HXA0ZDQl2TGyUmtmbcVl40Q==", "optional": true }, - "node_modules/scrypt-js": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-3.0.1.tgz", - "integrity": "sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA==" - }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", diff --git a/avail-js/examples/node-examples/package.json b/avail-js/examples/node-examples/package.json index f49f79485..6c544dd5e 100644 --- a/avail-js/examples/node-examples/package.json +++ b/avail-js/examples/node-examples/package.json @@ -24,8 +24,8 @@ "validium": "npm run build && node build/node-examples/src/validium.js" }, "dependencies": { - "avail-js-sdk": "^0.2.15", - "ethers": "5.4" + "avail-js-sdk": "^0.2.16", + "ethers": "^6.13.2" }, "devDependencies": { "rimraf": "^5.0.5" diff --git a/avail-js/package-lock.json b/avail-js/package-lock.json index 85017f585..9d4931915 100644 --- a/avail-js/package-lock.json +++ b/avail-js/package-lock.json @@ -1,12 +1,12 @@ { "name": "avail-js-sdk", - "version": "0.2.15", + "version": "0.2.16", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "avail-js-sdk", - "version": "0.2.15", + "version": "0.2.16", "license": "ISC", "dependencies": { "@polkadot/api": "^10.11.3", diff --git a/avail-js/package.json b/avail-js/package.json index 1721ffc97..a2431fda4 100644 --- a/avail-js/package.json +++ b/avail-js/package.json @@ -1,6 +1,6 @@ { "name": "avail-js-sdk", - "version": "0.2.15", + "version": "0.2.16", "description": "Avail library of functions to interact with blockchain and manipulate transactions", "main": "./build/index.js", "scripts": { diff --git a/avail-js/src/sdk/events.ts b/avail-js/src/sdk/events.ts index c2d641c5c..dcb895896 100644 --- a/avail-js/src/sdk/events.ts +++ b/avail-js/src/sdk/events.ts @@ -186,3 +186,41 @@ export namespace Staking { } } } + +export namespace NominationPools { + export class Created { + constructor( + public depositor: string, + public poolId: string, + ) {} + static New(events: EventRecord[]): Created | undefined { + const ed: any = events.find((e) => e.event.method == "Created" && e.event.section == "nominationPools")?.event + .data + if (ed == undefined) { + return undefined + } + + return new Created(ed["depositor"].toString(), ed["poolId"].toString()) + } + } + + export class Bonded { + constructor( + public member: string, + public poolId: string, + public bonded: string, + public joined: string, + ) {} + static New(events: EventRecord[]): Bonded | undefined { + const ed: any = events.find((e) => e.event.method == "Bonded" && e.event.section == "nominationPools")?.event.data + if (ed == undefined) { + return undefined + } + + const bondedString = ed["bonded"].toString() + const bonded = new BN(bondedString).div(new BN(10).pow(new BN(18))).toString() + + return new Bonded(ed["member"].toString(), ed["poolId"].toString(), bonded, ed["joined"].toString()) + } + } +} diff --git a/avail-js/src/sdk/index.ts b/avail-js/src/sdk/index.ts index 4265cfd4f..63b0685da 100644 --- a/avail-js/src/sdk/index.ts +++ b/avail-js/src/sdk/index.ts @@ -6,6 +6,10 @@ export * as sdkEvents from "./events" export * as sdkTransactions from "./transactions" export * as sdkTransactionData from "./transaction_data" +export { BN } from "@polkadot/util" +export { Keyring } from "@polkadot/api" +export { WaitFor } from "./transactions" + export class SDK { api: ApiPromise tx: Transactions diff --git a/avail-js/src/sdk/transactions.ts b/avail-js/src/sdk/transactions.ts index e31e687d0..c9fbcf812 100644 --- a/avail-js/src/sdk/transactions.ts +++ b/avail-js/src/sdk/transactions.ts @@ -1,6 +1,6 @@ import { ApiPromise } from "@polkadot/api" import { ISubmittableResult } from "@polkadot/types/types/extrinsic" -import { H256 } from "@polkadot/types/interfaces/types" +import { H256, EventRecord } from "@polkadot/types/interfaces/types" import { BN } from "@polkadot/util" import { KeyringPair } from "@polkadot/keyring/types" import { err, ok, Result } from "neverthrow" @@ -29,67 +29,196 @@ type SubmitDataTxSuccess = { isErr: false txData: TransactionData.DataAvailability.SubmitData event: Events.DataAvailability.DataSubmittedEvent + events: EventRecord[] txHash: H256 + txIndex: number blockHash: H256 + blockNumber: number } type CreateApplicationKeyTxSuccess = { isErr: false event: Events.DataAvailability.ApplicationKeyCreatedEvent + events: EventRecord[] txHash: H256 + txIndex: number blockHash: H256 + blockNumber: number } type SetApplicationKeyTxSuccess = { isErr: false event: Events.DataAvailability.ApplicationKeySetEvent + events: EventRecord[] txHash: H256 + txIndex: number blockHash: H256 + blockNumber: number } type SubmitBlockLengthProposalTxSuccess = { isErr: false event: Events.DataAvailability.BlockLengthProposalSubmittedEvent + events: EventRecord[] txHash: H256 + txIndex: number blockHash: H256 + blockNumber: number } type SetSubmitDataFeeModifierTxSuccess = { isErr: false event: Events.DataAvailability.SubmitDataFeeModifierSetEvent + events: EventRecord[] txHash: H256 + txIndex: number blockHash: H256 + blockNumber: number +} +type TransferKeepAliveTxSuccess = { + isErr: false + event: Events.Balances.TransferEvent + events: EventRecord[] + txHash: H256 + txIndex: number + blockHash: H256 + blockNumber: number } -type TransferKeepAliveTxSuccess = { isErr: false; event: Events.Balances.TransferEvent; txHash: H256; blockHash: H256 } type TransferAllowDeathTxSuccess = { isErr: false event: Events.Balances.TransferEvent event2?: Events.System.KilledAccount + events: EventRecord[] txHash: H256 + txIndex: number blockHash: H256 + blockNumber: number } type TransferAllTxSuccess = { isErr: false event: Events.Balances.TransferEvent event2?: Events.System.KilledAccount + events: EventRecord[] + txHash: H256 + txIndex: number + blockHash: H256 + blockNumber: number +} +type BondTxSuccess = { + isErr: false + event: Events.Staking.Bonded + events: EventRecord[] + txHash: H256 + txIndex: number + blockHash: H256 + blockNumber: number +} +type BondExtraTxSuccess = { + isErr: false + event: Events.Staking.Bonded + events: EventRecord[] + txHash: H256 + txIndex: number + blockHash: H256 + blockNumber: number +} +type ChillTxSuccess = { + isErr: false + event: Events.Staking.Chilled + events: EventRecord[] + txHash: H256 + txIndex: number + blockHash: H256 + blockNumber: number +} +type ChillOtherTxSuccess = { + isErr: false + event: Events.Staking.Chilled + events: EventRecord[] + txHash: H256 + txIndex: number + blockHash: H256 + blockNumber: number +} +type UnbondTxSuccess = { + isErr: false + event: Events.Staking.Unbonded + events: EventRecord[] txHash: H256 + txIndex: number blockHash: H256 + blockNumber: number +} +type ValidatexSuccess = { + isErr: false + event: Events.Staking.ValidatorPrefsSet + events: EventRecord[] + txHash: H256 + txIndex: number + blockHash: H256 + blockNumber: number +} +type NominateTxSuccess = { + isErr: false + txData: TransactionData.Staking.Nominate + events: EventRecord[] + txHash: H256 + txIndex: number + blockHash: H256 + blockNumber: number +} + +// Nomination Pools struct +type PoolCreateTxSuccess = { + isErr: false + event: Events.NominationPools.Created + event2: Events.NominationPools.Bonded + events: EventRecord[] + txHash: H256 + txIndex: number + blockHash: H256 + blockNumber: number +} + +type PoolCreateWithPoolIdTxSuccess = { + isErr: false + event: Events.NominationPools.Created + event2: Events.NominationPools.Bonded + events: EventRecord[] + txHash: H256 + txIndex: number + blockHash: H256 + blockNumber: number +} + +type PoolJoinTxSuccess = { + isErr: false + event: Events.NominationPools.Bonded + events: EventRecord[] + txHash: H256 + txIndex: number + blockHash: H256 + blockNumber: number +} + +type PoolNominateTxSuccess = { + isErr: false + events: EventRecord[] + txHash: H256 + txIndex: number + blockHash: H256 + blockNumber: number } -type BondTxSuccess = { isErr: false; event: Events.Staking.Bonded; txHash: H256; blockHash: H256 } -type BondExtraTxSuccess = { isErr: false; event: Events.Staking.Bonded; txHash: H256; blockHash: H256 } -type ChillTxSuccess = { isErr: false; event: Events.Staking.Chilled; txHash: H256; blockHash: H256 } -type ChillOtherTxSuccess = { isErr: false; event: Events.Staking.Chilled; txHash: H256; blockHash: H256 } -type UnbondTxSuccess = { isErr: false; event: Events.Staking.Unbonded; txHash: H256; blockHash: H256 } -type ValidatexSuccess = { isErr: false; event: Events.Staking.ValidatorPrefsSet; txHash: H256; blockHash: H256 } -type NominateTxSuccess = { isErr: false; txData: TransactionData.Staking.Nominate; txHash: H256; blockHash: H256 } export class Transactions { private api: ApiPromise dataAvailability: DataAvailability balances: Balances staking: Staking + nominationPools: NominationPools constructor(api: ApiPromise) { this.api = api this.dataAvailability = new DataAvailability(api) this.balances = new Balances(api) this.staking = new Staking(api) + this.nominationPools = new NominationPools(api) } } @@ -111,11 +240,226 @@ function standardCallback( } } -function getBlockHashAndTxHash(result: ISubmittableResult, waitFor: WaitFor): [H256, H256] { - if (waitFor == WaitFor.BlockInclusion) { - return [result.txHash as H256, result.status.asInBlock as H256] +async function getBlockHashAndTxHash( + result: ISubmittableResult, + waitFor: WaitFor, + api: ApiPromise, +): Promise<[H256, number, H256, number]> { + const txHash = result.txHash as H256 + const txIndex: number = result.txIndex || 22 + let blockHash = txHash + if (waitFor == WaitFor.BlockFinalization) { + blockHash = result.status.asFinalized as H256 } else { - return [result.txHash as H256, result.status.asFinalized as H256] + blockHash = result.status.asInBlock as H256 + } + + const header = await api.rpc.chain.getHeader(blockHash) + const blockNumber: number = header.number.toNumber() + + return [txHash, txIndex, blockHash, blockNumber] +} + +export class NominationPools { + private api: ApiPromise + + constructor(api: ApiPromise) { + this.api = api + } + + async create( + amount: BN, + root: string, + nominator: string, + bouncer: string, + waitFor: WaitFor, + account: KeyringPair, + options?: Partial, + ): Promise { + const optionWrapper = options || {} + const maybeTxResult = await new Promise>((res, _) => { + this.api.tx.nominationPools + .create(amount, root, nominator, bouncer) + .signAndSend(account, optionWrapper, (result: ISubmittableResult) => { + standardCallback(result, res, waitFor) + }) + .catch((reason) => { + res(err(reason)) + }) + }) + + if (maybeTxResult.isErr()) { + return { isErr: true, reason: maybeTxResult.error } as GenericFailure + } + const txResult = maybeTxResult.value + + if (txResult.isError) { + return { isErr: true, reason: "The transaction was dropped or something." } as GenericFailure + } + + const events = txResult.events + const failed = events.find((e) => this.api.events.system.ExtrinsicFailed.is(e.event)) + if (failed != undefined) { + return { isErr: true, reason: decodeError(this.api, failed.event.data[0]) } as GenericFailure + } + + const event = Events.NominationPools.Created.New(txResult.events) + if (event == undefined) { + return { isErr: true, reason: "Failed to find Created event." } as GenericFailure + } + + const event2 = Events.NominationPools.Bonded.New(txResult.events) + if (event2 == undefined) { + return { isErr: true, reason: "Failed to find Bonded event." } as GenericFailure + } + + const [txHash, txIndex, blockHash, blockNumber] = await getBlockHashAndTxHash(txResult, waitFor, this.api) + + return { isErr: false, event, event2, events, txHash, txIndex, blockHash, blockNumber } as PoolCreateTxSuccess + } + + async createWithPoolId( + amount: BN, + root: string, + nominator: string, + bouncer: string, + poolId: number, + waitFor: WaitFor, + account: KeyringPair, + options?: Partial, + ): Promise { + const optionWrapper = options || {} + const maybeTxResult = await new Promise>((res, _) => { + this.api.tx.nominationPools + .createWithPoolId(amount, root, nominator, bouncer, poolId) + .signAndSend(account, optionWrapper, (result: ISubmittableResult) => { + standardCallback(result, res, waitFor) + }) + .catch((reason) => { + res(err(reason)) + }) + }) + + if (maybeTxResult.isErr()) { + return { isErr: true, reason: maybeTxResult.error } as GenericFailure + } + const txResult = maybeTxResult.value + + if (txResult.isError) { + return { isErr: true, reason: "The transaction was dropped or something." } as GenericFailure + } + + const events = txResult.events + const failed = events.find((e) => this.api.events.system.ExtrinsicFailed.is(e.event)) + if (failed != undefined) { + return { isErr: true, reason: decodeError(this.api, failed.event.data[0]) } as GenericFailure + } + + const event = Events.NominationPools.Created.New(txResult.events) + if (event == undefined) { + return { isErr: true, reason: "Failed to find Created event." } as GenericFailure + } + + const event2 = Events.NominationPools.Bonded.New(txResult.events) + if (event2 == undefined) { + return { isErr: true, reason: "Failed to find Bonded event." } as GenericFailure + } + + const [txHash, txIndex, blockHash, blockNumber] = await getBlockHashAndTxHash(txResult, waitFor, this.api) + + return { + isErr: false, + event, + event2, + events, + txHash, + txIndex, + blockHash, + blockNumber, + } as PoolCreateWithPoolIdTxSuccess + } + + async join( + amount: BN, + poolId: number, + waitFor: WaitFor, + account: KeyringPair, + options?: Partial, + ): Promise { + const optionWrapper = options || {} + const maybeTxResult = await new Promise>((res, _) => { + this.api.tx.nominationPools + .join(amount, poolId) + .signAndSend(account, optionWrapper, (result: ISubmittableResult) => { + standardCallback(result, res, waitFor) + }) + .catch((reason) => { + res(err(reason)) + }) + }) + + if (maybeTxResult.isErr()) { + return { isErr: true, reason: maybeTxResult.error } as GenericFailure + } + const txResult = maybeTxResult.value + + if (txResult.isError) { + return { isErr: true, reason: "The transaction was dropped or something." } as GenericFailure + } + + const events = txResult.events + const failed = events.find((e) => this.api.events.system.ExtrinsicFailed.is(e.event)) + if (failed != undefined) { + return { isErr: true, reason: decodeError(this.api, failed.event.data[0]) } as GenericFailure + } + + const event = Events.NominationPools.Bonded.New(txResult.events) + if (event == undefined) { + return { isErr: true, reason: "Failed to find Bonded event." } as GenericFailure + } + + const [txHash, txIndex, blockHash, blockNumber] = await getBlockHashAndTxHash(txResult, waitFor, this.api) + + return { isErr: false, event, events, txHash, txIndex, blockHash, blockNumber } as PoolJoinTxSuccess + } + + async nominate( + poolId: number, + validators: string[], + waitFor: WaitFor, + account: KeyringPair, + options?: Partial, + ): Promise { + const optionWrapper = options || {} + const maybeTxResult = await new Promise>((res, _) => { + this.api.tx.nominationPools + .nominate(poolId, validators) + .signAndSend(account, optionWrapper, (result: ISubmittableResult) => { + standardCallback(result, res, waitFor) + }) + .catch((reason) => { + res(err(reason)) + }) + }) + + if (maybeTxResult.isErr()) { + return { isErr: true, reason: maybeTxResult.error } as GenericFailure + } + const txResult = maybeTxResult.value + + if (txResult.isError) { + return { isErr: true, reason: "The transaction was dropped or something." } as GenericFailure + } + + const events = txResult.events + const failed = events.find((e) => this.api.events.system.ExtrinsicFailed.is(e.event)) + if (failed != undefined) { + return { isErr: true, reason: decodeError(this.api, failed.event.data[0]) } as GenericFailure + } + + const [txHash, txIndex, blockHash, blockNumber] = await getBlockHashAndTxHash(txResult, waitFor, this.api) + + return { isErr: false, events, txHash, txIndex, blockHash, blockNumber } as PoolNominateTxSuccess } } @@ -164,9 +508,10 @@ export class Staking { return { isErr: true, reason: "Failed to find Bonded event." } as GenericFailure } - const [txHash, blockHash] = getBlockHashAndTxHash(txResult, waitFor) + const events = txResult.events + const [txHash, txIndex, blockHash, blockNumber] = await getBlockHashAndTxHash(txResult, waitFor, this.api) - return { isErr: false, event, txHash, blockHash } as BondTxSuccess + return { isErr: false, event, events, txHash, txIndex, blockHash, blockNumber } as BondTxSuccess } async bondExtra( @@ -206,9 +551,10 @@ export class Staking { return { isErr: true, reason: "Failed to find Bonded event." } as GenericFailure } - const [txHash, blockHash] = getBlockHashAndTxHash(txResult, waitFor) + const events = txResult.events + const [txHash, txIndex, blockHash, blockNumber] = await getBlockHashAndTxHash(txResult, waitFor, this.api) - return { isErr: false, event, txHash, blockHash } as BondExtraTxSuccess + return { isErr: false, event, events, txHash, txIndex, blockHash, blockNumber } as BondExtraTxSuccess } async chill( @@ -247,9 +593,10 @@ export class Staking { return { isErr: true, reason: "Failed to find Chilled event." } as GenericFailure } - const [txHash, blockHash] = getBlockHashAndTxHash(txResult, waitFor) + const events = txResult.events + const [txHash, txIndex, blockHash, blockNumber] = await getBlockHashAndTxHash(txResult, waitFor, this.api) - return { isErr: false, event, txHash, blockHash } as ChillTxSuccess + return { isErr: false, event, events, txHash, txIndex, blockHash, blockNumber } as ChillTxSuccess } async chillOther( @@ -289,9 +636,10 @@ export class Staking { return { isErr: true, reason: "Failed to find Chilled event." } as GenericFailure } - const [txHash, blockHash] = getBlockHashAndTxHash(txResult, waitFor) + const events = txResult.events + const [txHash, txIndex, blockHash, blockNumber] = await getBlockHashAndTxHash(txResult, waitFor, this.api) - return { isErr: false, event, txHash, blockHash } as ChillOtherTxSuccess + return { isErr: false, event, events, txHash, txIndex, blockHash, blockNumber } as ChillOtherTxSuccess } async nominate( @@ -326,13 +674,23 @@ export class Staking { return { isErr: true, reason: decodeError(this.api, failed.event.data[0]) } as GenericFailure } - const [txHash, blockHash] = getBlockHashAndTxHash(txResult, waitFor) + const events = txResult.events + const [txHash, txIndex, blockHash, blockNumber] = await getBlockHashAndTxHash(txResult, waitFor, this.api) + const maybeTxData = await TransactionData.Staking.Nominate.New(this.api, txHash, blockHash) if (maybeTxData.isErr()) { return { isErr: true, reason: maybeTxData.error } as GenericFailure } - return { isErr: false, txData: maybeTxData.value, txHash, blockHash } as NominateTxSuccess + return { + isErr: false, + txData: maybeTxData.value, + events, + txHash, + txIndex, + blockHash, + blockNumber, + } as NominateTxSuccess } async unbond( @@ -372,9 +730,10 @@ export class Staking { return { isErr: true, reason: "Failed to find Unbonded event." } as GenericFailure } - const [txHash, blockHash] = getBlockHashAndTxHash(txResult, waitFor) + const events = txResult.events + const [txHash, txIndex, blockHash, blockNumber] = await getBlockHashAndTxHash(txResult, waitFor, this.api) - return { isErr: false, event, txHash, blockHash } as UnbondTxSuccess + return { isErr: false, event, events, txHash, txIndex, blockHash, blockNumber } as UnbondTxSuccess } async validate( @@ -421,9 +780,10 @@ export class Staking { return { isErr: true, reason: "Failed to find ValidatorPrefsSet event." } as GenericFailure } - const [txHash, blockHash] = getBlockHashAndTxHash(txResult, waitFor) + const events = txResult.events + const [txHash, txIndex, blockHash, blockNumber] = await getBlockHashAndTxHash(txResult, waitFor, this.api) - return { isErr: false, event, txHash, blockHash } as ValidatexSuccess + return { isErr: false, event, events, txHash, txIndex, blockHash, blockNumber } as ValidatexSuccess } } @@ -473,9 +833,10 @@ export class Balances { } const event2 = Events.System.KilledAccount.New(txResult.events) - const [txHash, blockHash] = getBlockHashAndTxHash(txResult, waitFor) + const events = txResult.events + const [txHash, txIndex, blockHash, blockNumber] = await getBlockHashAndTxHash(txResult, waitFor, this.api) - return { isErr: false, event, event2, txHash, blockHash } as TransferAllTxSuccess + return { isErr: false, event, event2, events, txHash, txIndex, blockHash, blockNumber } as TransferAllTxSuccess } async transferAllowDeath( @@ -517,9 +878,19 @@ export class Balances { } const event2 = Events.System.KilledAccount.New(txResult.events) - const [txHash, blockHash] = getBlockHashAndTxHash(txResult, waitFor) - - return { isErr: false, event, event2, txHash, blockHash } as TransferAllowDeathTxSuccess + const events = txResult.events + const [txHash, txIndex, blockHash, blockNumber] = await getBlockHashAndTxHash(txResult, waitFor, this.api) + + return { + isErr: false, + event, + event2, + events, + txHash, + txIndex, + blockHash, + blockNumber, + } as TransferAllowDeathTxSuccess } async transferKeepAlive( @@ -560,9 +931,10 @@ export class Balances { return { isErr: true, reason: "Failed to find Transfer event." } as GenericFailure } - const [txHash, blockHash] = getBlockHashAndTxHash(txResult, waitFor) + const events = txResult.events + const [txHash, txIndex, blockHash, blockNumber] = await getBlockHashAndTxHash(txResult, waitFor, this.api) - return { isErr: false, event, txHash, blockHash } as TransferKeepAliveTxSuccess + return { isErr: false, event, events, txHash, txIndex, blockHash, blockNumber } as TransferKeepAliveTxSuccess } } @@ -610,14 +982,24 @@ export class DataAvailability { return { isErr: true, reason: "Failed to find DataSubmitted event." } as GenericFailure } - const [txHash, blockHash] = getBlockHashAndTxHash(txResult, waitFor) + const events = txResult.events + const [txHash, txIndex, blockHash, blockNumber] = await getBlockHashAndTxHash(txResult, waitFor, this.api) const maybeTxData = await TransactionData.DataAvailability.SubmitData.New(this.api, txHash, blockHash) if (maybeTxData.isErr()) { return { isErr: true, reason: maybeTxData.error } as GenericFailure } - return { isErr: false, txData: maybeTxData.value, event, txHash, blockHash } as SubmitDataTxSuccess + return { + isErr: false, + txData: maybeTxData.value, + event, + events, + txHash, + txIndex, + blockHash, + blockNumber, + } as SubmitDataTxSuccess } async createApplicationKey( @@ -657,9 +1039,10 @@ export class DataAvailability { return { isErr: true, reason: "Failed to find ApplicationKeyCreated event." } as GenericFailure } - const [txHash, blockHash] = getBlockHashAndTxHash(txResult, waitFor) + const events = txResult.events + const [txHash, txIndex, blockHash, blockNumber] = await getBlockHashAndTxHash(txResult, waitFor, this.api) - return { isErr: false, event, txHash, blockHash } as CreateApplicationKeyTxSuccess + return { isErr: false, event, events, txHash, txIndex, blockHash, blockNumber } as CreateApplicationKeyTxSuccess } async setApplicationKey( @@ -711,9 +1094,10 @@ export class DataAvailability { return { isErr: true, reason: "Failed to find ApplicationKeySet event." } as GenericFailure } - const [txHash, blockHash] = getBlockHashAndTxHash(txResult, waitFor) + const events = txResult.events + const [txHash, txIndex, blockHash, blockNumber] = await getBlockHashAndTxHash(txResult, waitFor, this.api) - return { isErr: false, event, txHash, blockHash } as SetApplicationKeyTxSuccess + return { isErr: false, event, events, txHash, txIndex, blockHash, blockNumber } as SetApplicationKeyTxSuccess } async submitBlockLengthProposal( @@ -765,9 +1149,18 @@ export class DataAvailability { return { isErr: true, reason: "Failed to find BlockLengthProposalSubmitted event." } as GenericFailure } - const [txHash, blockHash] = getBlockHashAndTxHash(txResult, waitFor) + const events = txResult.events + const [txHash, txIndex, blockHash, blockNumber] = await getBlockHashAndTxHash(txResult, waitFor, this.api) - return { isErr: false, event, txHash, blockHash } as SubmitBlockLengthProposalTxSuccess + return { + isErr: false, + event, + events, + txHash, + txIndex, + blockHash, + blockNumber, + } as SubmitBlockLengthProposalTxSuccess } async setSubmitDataFeeModifier( @@ -818,8 +1211,9 @@ export class DataAvailability { return { isErr: true, reason: "Failed to find SubmitDataFeeModifierSet event." } as GenericFailure } - const [txHash, blockHash] = getBlockHashAndTxHash(txResult, waitFor) + const events = txResult.events + const [txHash, txIndex, blockHash, blockNumber] = await getBlockHashAndTxHash(txResult, waitFor, this.api) - return { isErr: false, event, txHash, blockHash } as SetSubmitDataFeeModifierTxSuccess + return { isErr: false, event, events, txHash, txIndex, blockHash, blockNumber } as SetSubmitDataFeeModifierTxSuccess } }