Skip to content

Commit

Permalink
Updated avail js with new interfaces (#660)
Browse files Browse the repository at this point in the history
* Updated avail js with new interfaces

* change path and update package version

---------

Co-authored-by: Leouarz <[email protected]>
  • Loading branch information
markopoloparadox and Leouarz authored Sep 19, 2024
1 parent 326107b commit f25f0e5
Show file tree
Hide file tree
Showing 40 changed files with 2,255 additions and 1,864 deletions.
842 changes: 0 additions & 842 deletions avail-js/docs/README.md

Large diffs are not rendered by default.

1,387 changes: 1,387 additions & 0 deletions avail-js/docs/extrinsics/README.md

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions avail-js/docs/extrinsics/balances_tranfer_all.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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()
}
Expand Down
9 changes: 2 additions & 7 deletions avail-js/docs/extrinsics/balances_tranfer_allow_death.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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()
}
Expand Down
8 changes: 2 additions & 6 deletions avail-js/docs/extrinsics/balances_tranfer_keep_alive.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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()
}
Expand Down
7 changes: 2 additions & 5 deletions avail-js/docs/extrinsics/da_create_application_key.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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()
}
Expand Down
7 changes: 2 additions & 5 deletions avail-js/docs/extrinsics/da_set_aplication_key.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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()
}
Expand Down
20 changes: 6 additions & 14 deletions avail-js/docs/extrinsics/da_set_submit_data_fee_modifier.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,23 @@
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"
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 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(
"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()
}
Expand Down
7 changes: 2 additions & 5 deletions avail-js/docs/extrinsics/da_submit_block_length_proposal.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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()
}
Expand Down
9 changes: 2 additions & 7 deletions avail-js/docs/extrinsics/da_submit_data.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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()
24 changes: 24 additions & 0 deletions avail-js/docs/extrinsics/nomination_pools_create.ts
Original file line number Diff line number Diff line change
@@ -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()
33 changes: 33 additions & 0 deletions avail-js/docs/extrinsics/nomination_pools_create_with_pool_id.ts
Original file line number Diff line number Diff line change
@@ -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()
21 changes: 21 additions & 0 deletions avail-js/docs/extrinsics/nomination_pools_join.ts
Original file line number Diff line number Diff line change
@@ -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()
24 changes: 24 additions & 0 deletions avail-js/docs/extrinsics/nomination_pools_nominate.ts
Original file line number Diff line number Diff line change
@@ -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()
8 changes: 2 additions & 6 deletions avail-js/docs/extrinsics/staking_bond.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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()
}
Expand Down
8 changes: 2 additions & 6 deletions avail-js/docs/extrinsics/staking_bond_extra.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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()
}
Expand Down
8 changes: 2 additions & 6 deletions avail-js/docs/extrinsics/staking_chill.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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()
}
Expand Down
8 changes: 2 additions & 6 deletions avail-js/docs/extrinsics/staking_chill_other.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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()
}
Expand Down
7 changes: 2 additions & 5 deletions avail-js/docs/extrinsics/staking_nominate.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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()
}
Expand Down
9 changes: 2 additions & 7 deletions avail-js/docs/extrinsics/staking_unbond.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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()
Loading

0 comments on commit f25f0e5

Please sign in to comment.