diff --git a/.papi/metadata/pas.scale b/.papi/metadata/pas.scale new file mode 100644 index 0000000..abf959a Binary files /dev/null and b/.papi/metadata/pas.scale differ diff --git a/.papi/metadata/pasAh.scale b/.papi/metadata/pasAh.scale new file mode 100644 index 0000000..bd69d52 Binary files /dev/null and b/.papi/metadata/pasAh.scale differ diff --git a/.papi/polkadot-api.json b/.papi/polkadot-api.json index bc0f763..27d4f56 100644 --- a/.papi/polkadot-api.json +++ b/.papi/polkadot-api.json @@ -33,6 +33,14 @@ "rocAh": { "wsUrl": "wss://asset-hub-rococo-rpc.dwellir.com", "metadata": ".papi/metadata/rocAh.scale" + }, + "pas": { + "chain": "paseo", + "metadata": ".papi/metadata/pas.scale" + }, + "pasAh": { + "chain": "paseo_asset_hub", + "metadata": ".papi/metadata/pasAh.scale" } } } diff --git a/src/api/chains.ts b/src/api/chains.ts index 892f3b0..6aff8c5 100644 --- a/src/api/chains.ts +++ b/src/api/chains.ts @@ -2,9 +2,10 @@ import dot from "./dot" import ksm from "./ksm" import wnd from "./wnd" import roc from "./roc" +import pas from "./pas" import { AssetId, AssetInChain, ChainId } from "./types" -const assetsInChains = [...dot, ...ksm, ...wnd, ...roc] +const assetsInChains = [...dot, ...ksm, ...wnd, ...roc, ...pas] export const chains = new Map>() @@ -20,6 +21,7 @@ export const ASSET_DECIMALS: Record = { KSM: 12, WND: 12, ROC: 12, + PAS: 10, } export const CHAIN_NAMES: Record = { @@ -31,4 +33,6 @@ export const CHAIN_NAMES: Record = { wndAh: "Westend AssetHub", roc: "Rococo RelayChain", rocAh: "Rococo AssetHub", + pas: "Paseo RelayChain", + pasAh: "Paseo AssetHub", } diff --git a/src/api/clients/index.ts b/src/api/clients/index.ts index 3144f19..f9272fb 100644 --- a/src/api/clients/index.ts +++ b/src/api/clients/index.ts @@ -9,3 +9,6 @@ export { wndAhClient } from "./wndAh" export { rocClient } from "./roc" export { rocAhClient } from "./rocAh" + +export { pasClient } from "./pas" +export { pasAhClient } from "./pasAh" diff --git a/src/api/clients/pas.ts b/src/api/clients/pas.ts new file mode 100644 index 0000000..bf9c9d4 --- /dev/null +++ b/src/api/clients/pas.ts @@ -0,0 +1,9 @@ +import { createClient } from "polkadot-api" +import { getSmProvider } from "polkadot-api/sm-provider" +import { smoldot } from "./smoldot" + +export const pasRelayChain = import("polkadot-api/chains/paseo").then( + ({ chainSpec }) => smoldot.addChain({ chainSpec }), +) + +export const pasClient = createClient(getSmProvider(pasRelayChain)) diff --git a/src/api/clients/pasAh.ts b/src/api/clients/pasAh.ts new file mode 100644 index 0000000..8c9d038 --- /dev/null +++ b/src/api/clients/pasAh.ts @@ -0,0 +1,13 @@ +import { createClient } from "polkadot-api" +import { getSmProvider } from "polkadot-api/sm-provider" +import { smoldot } from "./smoldot" +import { pasRelayChain } from "./pas" + +const smoldotParaChain = Promise.all([ + pasRelayChain, + import("polkadot-api/chains/paseo_asset_hub"), +]).then(([relayChain, { chainSpec }]) => + smoldot.addChain({ chainSpec, potentialRelayChains: [relayChain] }), +) + +export const pasAhClient = createClient(getSmProvider(smoldotParaChain)) diff --git a/src/api/pas/ah.ts b/src/api/pas/ah.ts new file mode 100644 index 0000000..7698cab --- /dev/null +++ b/src/api/pas/ah.ts @@ -0,0 +1,19 @@ +import { pasAh as descriptors } from "@polkadot-api/descriptors" +import { pasAhClient } from "@/api/clients" +import { AssetInChain } from "../types" +import { fromAssetHubToRelay, watchAccoutFreeBalance } from "../common" + +const api = pasAhClient.getTypedApi(descriptors) + +const chain = "pasAh" +const pas: AssetInChain = { + chain, + symbol: "PAS", + watchFreeBalance: watchAccoutFreeBalance(api), + teleport: { + pas: (...args) => + api.tx.PolkadotXcm.limited_teleport_assets(fromAssetHubToRelay(...args)), + }, +} + +export default [pas] diff --git a/src/api/pas/index.ts b/src/api/pas/index.ts new file mode 100644 index 0000000..2b9dd85 --- /dev/null +++ b/src/api/pas/index.ts @@ -0,0 +1,4 @@ +import relay from "./relay" +import ah from "./ah" + +export default [...relay, ...ah] diff --git a/src/api/pas/relay.ts b/src/api/pas/relay.ts new file mode 100644 index 0000000..b7f9be2 --- /dev/null +++ b/src/api/pas/relay.ts @@ -0,0 +1,18 @@ +import { pas as descriptors } from "@polkadot-api/descriptors" +import { pasClient } from "@/api/clients" +import { AssetInChain } from "../types" +import { fromRelayToAssetHub, watchAccoutFreeBalance } from "../common" + +const api = pasClient.getTypedApi(descriptors) + +const pas: AssetInChain = { + chain: "pas", + symbol: "PAS", + watchFreeBalance: watchAccoutFreeBalance(api), + teleport: { + pasAh: (...args) => + api.tx.XcmPallet.limited_teleport_assets(fromRelayToAssetHub(...args)), + }, +} + +export default [pas] diff --git a/src/api/types.ts b/src/api/types.ts index 4cefc23..474a0c3 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -10,7 +10,9 @@ export type ChainId = | "ksmAh" | "roc" | "rocAh" -export type AssetId = "DOT" | "KSM" | "WND" | "ROC" + | "pas" + | "pasAh" +export type AssetId = "DOT" | "KSM" | "WND" | "ROC" | "PAS" export type TeleportAsset = ( from: PolkadotSigner,