Skip to content

Commit

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

* Moved events definitions to correct files

* Final touch
  • Loading branch information
markopoloparadox authored Sep 25, 2024
1 parent 83b85af commit 0dfe360
Show file tree
Hide file tree
Showing 50 changed files with 2,724 additions and 985 deletions.
1,151 changes: 958 additions & 193 deletions avail-js/docs/extrinsics/README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion avail-js/docs/extrinsics/balances_tranfer_all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const main = async () => {
process.exit(1)
}

console.log(JSON.stringify(result, null, 4))
console.log(JSON.stringify(result, null, 2))

process.exit()
}
Expand Down
2 changes: 1 addition & 1 deletion avail-js/docs/extrinsics/balances_tranfer_allow_death.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const main = async () => {
process.exit(1)
}

console.log(JSON.stringify(result, null, 4))
console.log(JSON.stringify(result, null, 2))

process.exit()
}
Expand Down
2 changes: 1 addition & 1 deletion avail-js/docs/extrinsics/balances_tranfer_keep_alive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const main = async () => {
process.exit(1)
}

console.log(JSON.stringify(result, null, 4))
console.log(JSON.stringify(result, null, 2))

process.exit()
}
Expand Down
2 changes: 1 addition & 1 deletion avail-js/docs/extrinsics/da_create_application_key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const main = async () => {
process.exit(1)
}

console.log(JSON.stringify(result, null, 4))
console.log(JSON.stringify(result, null, 2))

process.exit()
}
Expand Down
2 changes: 1 addition & 1 deletion avail-js/docs/extrinsics/da_set_aplication_key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const main = async () => {
process.exit(1)
}

console.log(JSON.stringify(result, null, 4))
console.log(JSON.stringify(result, null, 2))

process.exit()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const main = async () => {
process.exit(1)
}

console.log(JSON.stringify(result, null, 4))
console.log(JSON.stringify(result, null, 2))

process.exit()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const main = async () => {
process.exit(1)
}

console.log(JSON.stringify(result, null, 4))
console.log(JSON.stringify(result, null, 2))

process.exit()
}
Expand Down
2 changes: 1 addition & 1 deletion avail-js/docs/extrinsics/da_submit_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const main = async () => {
process.exit(1)
}

console.log(JSON.stringify(result, null, 4))
console.log(JSON.stringify(result, null, 2))
process.exit()
}
main()
21 changes: 21 additions & 0 deletions avail-js/docs/extrinsics/nomination_pools_bond_extra.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { SDK, WaitFor, Keyring, BondExtra, 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 bondExtra = { FreeBalance: amount } as BondExtra

const result = await sdk.tx.nominationPools.bondExtra(bondExtra, WaitFor.BlockInclusion, account)
if (result.isErr) {
console.log(result.reason)
process.exit(1)
}

console.log(JSON.stringify(result, null, 2))
process.exit()
}
main()
20 changes: 20 additions & 0 deletions avail-js/docs/extrinsics/nomination_pools_chill.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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 poolId = 1

const result = await sdk.tx.nominationPools.chill(poolId, WaitFor.BlockInclusion, account)
if (result.isErr) {
console.log(result.reason)
process.exit(1)
}

console.log(JSON.stringify(result, null, 2))
process.exit()
}
main()
20 changes: 20 additions & 0 deletions avail-js/docs/extrinsics/nomination_pools_claim_commission.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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 poolId = 1

const result = await sdk.tx.nominationPools.claimCommission(poolId, WaitFor.BlockInclusion, account)
if (result.isErr) {
console.log(result.reason)
process.exit(1)
}

console.log(JSON.stringify(result, null, 2))
process.exit()
}
main()
19 changes: 19 additions & 0 deletions avail-js/docs/extrinsics/nomination_pools_claim_payout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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 result = await sdk.tx.nominationPools.claimPayout(WaitFor.BlockInclusion, account)
if (result.isErr) {
console.log(result.reason)
process.exit(1)
}

console.log(JSON.stringify(result, null, 2))
process.exit()
}
main()
20 changes: 20 additions & 0 deletions avail-js/docs/extrinsics/nomination_pools_claim_payout_other.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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 other = "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty" // Bob

const result = await sdk.tx.nominationPools.claimPayoutOther(other, WaitFor.BlockInclusion, account)
if (result.isErr) {
console.log(result.reason)
process.exit(1)
}

console.log(JSON.stringify(result, null, 2))
process.exit()
}
main()
2 changes: 1 addition & 1 deletion avail-js/docs/extrinsics/nomination_pools_create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const main = async () => {
process.exit(1)
}

console.log(JSON.stringify(result, null, 4))
console.log(JSON.stringify(result, null, 2))
process.exit()
}
main()
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const main = async () => {
process.exit(1)
}

console.log(JSON.stringify(result, null, 4))
console.log(JSON.stringify(result, null, 2))
process.exit()
}
main()
2 changes: 1 addition & 1 deletion avail-js/docs/extrinsics/nomination_pools_join.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const main = async () => {
process.exit(1)
}

console.log(JSON.stringify(result, null, 4))
console.log(JSON.stringify(result, null, 2))
process.exit()
}
main()
2 changes: 1 addition & 1 deletion avail-js/docs/extrinsics/nomination_pools_nominate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const main = async () => {
process.exit(1)
}

console.log(JSON.stringify(result, null, 4))
console.log(JSON.stringify(result, null, 2))
process.exit()
}
main()
20 changes: 20 additions & 0 deletions avail-js/docs/extrinsics/nomination_pools_set_claim_permission.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { SDK, WaitFor, Keyring, ClaimPermission } 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 permission: ClaimPermission = "PermissionlessAll"

const result = await sdk.tx.nominationPools.setClaimPermission(permission, WaitFor.BlockInclusion, account)
if (result.isErr) {
console.log(result.reason)
process.exit(1)
}

console.log(JSON.stringify(result, null, 2))
process.exit()
}
main()
21 changes: 21 additions & 0 deletions avail-js/docs/extrinsics/nomination_pools_set_commission.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { SDK, WaitFor, Keyring, NewCommission } 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 poolId = 1
const newCommission: NewCommission = { amount: 25, payee: "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" }

const result = await sdk.tx.nominationPools.setCommission(poolId, newCommission, WaitFor.BlockInclusion, account)
if (result.isErr) {
console.log(result.reason)
process.exit(1)
}

console.log(JSON.stringify(result, null, 2))
process.exit()
}
main()
21 changes: 21 additions & 0 deletions avail-js/docs/extrinsics/nomination_pools_set_metadata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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 poolId = 1
const metadata = "My Metadata"

const result = await sdk.tx.nominationPools.setMetadata(poolId, metadata, WaitFor.BlockInclusion, account)
if (result.isErr) {
console.log(result.reason)
process.exit(1)
}

console.log(JSON.stringify(result, null, 2))
process.exit()
}
main()
21 changes: 21 additions & 0 deletions avail-js/docs/extrinsics/nomination_pools_set_state.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { SDK, WaitFor, Keyring, PoolState } 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 poolId = 2
const state: PoolState = "Blocked"

const result = await sdk.tx.nominationPools.setState(poolId, state, WaitFor.BlockInclusion, account)
if (result.isErr) {
console.log(result.reason)
process.exit(1)
}

console.log(JSON.stringify(result, null, 2))
process.exit()
}
main()
21 changes: 21 additions & 0 deletions avail-js/docs/extrinsics/nomination_pools_unbond.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("//Alice")
const memberAccount = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" // Alice
const unbondingPoints = new BN(10).pow(new BN(18)).mul(new BN(100)) // 100 Avail

const result = await sdk.tx.nominationPools.unbond(memberAccount, unbondingPoints, WaitFor.BlockInclusion, account)
if (result.isErr) {
console.log(result.reason)
process.exit(1)
}

console.log(JSON.stringify(result, null, 2))
process.exit()
}
main()
26 changes: 26 additions & 0 deletions avail-js/docs/extrinsics/nomination_pools_withdraw_unbonded.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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 memberAccount = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" // Alice
const numSlashingSpans = 0

const result = await sdk.tx.nominationPools.withdrawUnbonded(
memberAccount,
numSlashingSpans,
WaitFor.BlockInclusion,
account,
)
if (result.isErr) {
console.log(result.reason)
process.exit(1)
}

console.log(JSON.stringify(result, null, 2))
process.exit()
}
main()
2 changes: 1 addition & 1 deletion avail-js/docs/extrinsics/staking_bond.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const main = async () => {
process.exit(1)
}

console.log(JSON.stringify(result, null, 4))
console.log(JSON.stringify(result, null, 2))

process.exit()
}
Expand Down
2 changes: 1 addition & 1 deletion avail-js/docs/extrinsics/staking_bond_extra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const main = async () => {
process.exit(1)
}

console.log(JSON.stringify(result, null, 4))
console.log(JSON.stringify(result, null, 2))

process.exit()
}
Expand Down
2 changes: 1 addition & 1 deletion avail-js/docs/extrinsics/staking_chill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const main = async () => {
process.exit(1)
}

console.log(JSON.stringify(result, null, 4))
console.log(JSON.stringify(result, null, 2))

process.exit()
}
Expand Down
2 changes: 1 addition & 1 deletion avail-js/docs/extrinsics/staking_chill_other.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const main = async () => {
process.exit(1)
}

console.log(JSON.stringify(result, null, 4))
console.log(JSON.stringify(result, null, 2))

process.exit()
}
Expand Down
2 changes: 1 addition & 1 deletion avail-js/docs/extrinsics/staking_nominate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const main = async () => {
process.exit(1)
}

console.log(JSON.stringify(result, null, 4))
console.log(JSON.stringify(result, null, 2))

process.exit()
}
Expand Down
Loading

0 comments on commit 0dfe360

Please sign in to comment.