From 109de72a951376d805c7bb6119b440b27d24d324 Mon Sep 17 00:00:00 2001 From: mrq Date: Fri, 29 Dec 2023 19:06:24 +0100 Subject: [PATCH] phala support --- packages/xcm-cfg/src/assets.ts | 6 ++++++ packages/xcm-cfg/src/chains.ts | 25 +++++++++++++++++++++++++ packages/xcm-cfg/src/configs/hydraDX.ts | 21 +++++++++++++++++++++ packages/xcm-cfg/src/configs/index.ts | 2 ++ packages/xcm-cfg/src/configs/phala.ts | 24 ++++++++++++++++++++++++ 5 files changed, 78 insertions(+) create mode 100644 packages/xcm-cfg/src/configs/phala.ts diff --git a/packages/xcm-cfg/src/assets.ts b/packages/xcm-cfg/src/assets.ts index b7006252..1e6f61bd 100644 --- a/packages/xcm-cfg/src/assets.ts +++ b/packages/xcm-cfg/src/assets.ts @@ -79,6 +79,11 @@ export const sub = new Asset({ originSymbol: 'SUB', }); +export const pha = new Asset({ + key: 'pha', + originSymbol: 'PHA', +}); + export const assets: Asset[] = [ aca, astr, @@ -102,6 +107,7 @@ export const assets: Asset[] = [ weth_awh, weth_mwh, ztg, + pha, ]; export const assetsMap = new Map( diff --git a/packages/xcm-cfg/src/chains.ts b/packages/xcm-cfg/src/chains.ts index 66780bb0..03a922ec 100644 --- a/packages/xcm-cfg/src/chains.ts +++ b/packages/xcm-cfg/src/chains.ts @@ -29,6 +29,7 @@ import { weth_awh, weth_mwh, ztg, + pha, } from './assets'; export const acala = new Parachain({ @@ -261,6 +262,11 @@ export const hydraDX = new Parachain({ id: 12, decimals: 10, }, + { + asset: pha, + id: 8, + decimals: 12, + } ], ecosystem: Ecosystem.Polkadot, genesisHash: @@ -386,6 +392,24 @@ export const zeitgeist = new Parachain({ ws: 'wss://zeitgeist-rpc.dwellir.com', }); +export const phala = new Parachain({ + assetsData: [ + // NOTE: no meta for native token + { + asset: pha, + metadataId: 99999999, + }, + ], + ecosystem: Ecosystem.Polkadot, + genesisHash: + '0x1bb969d85965e4bb5a651abbedf21a54b6b31a21f66b5401cc3f1e286268d736', + key: 'phala', + name: 'Phala', + parachainId: 2035, + ss58Format: 30, + ws: 'wss://api.phala.network/ws', +}); + export const chains: AnyChain[] = [ acala, assetHub, @@ -398,6 +422,7 @@ export const chains: AnyChain[] = [ polkadot, subsocial, zeitgeist, + phala, ]; export const chainsMap = new Map( diff --git a/packages/xcm-cfg/src/configs/hydraDX.ts b/packages/xcm-cfg/src/configs/hydraDX.ts index 6e21e341..a528929f 100644 --- a/packages/xcm-cfg/src/configs/hydraDX.ts +++ b/packages/xcm-cfg/src/configs/hydraDX.ts @@ -20,6 +20,7 @@ import { hdx, ibtc, intr, + pha, sub, usdc, usdc_mwh, @@ -41,6 +42,7 @@ import { hydraDX, interlay, moonbeam, + phala, subsocial, zeitgeist, } from '../chains'; @@ -388,6 +390,24 @@ const toZeitgeist: AssetConfig[] = [ }), ]; +const toPhala: AssetConfig[] = [ + new AssetConfig({ + asset: pha, + balance: BalanceBuilder().substrate().tokens().accounts(), + destination: phala, + destinationFee: { + amount: 0.064296, + asset: pha, + balance: BalanceBuilder().substrate().tokens().accounts(), + }, + extrinsic: ExtrinsicBuilder().xTokens().transfer(), + fee: { + asset: hdx, + balance: BalanceBuilder().substrate().system().account(), + }, + }), +]; + export const hydraDxConfig = new ChainConfig({ assets: [ ...toAcala, @@ -400,6 +420,7 @@ export const hydraDxConfig = new ChainConfig({ ...toPolkadot, ...toSubsocial, ...toZeitgeist, + ...toPhala, ], chain: hydraDX, }); diff --git a/packages/xcm-cfg/src/configs/index.ts b/packages/xcm-cfg/src/configs/index.ts index d3bb1221..48cc5953 100644 --- a/packages/xcm-cfg/src/configs/index.ts +++ b/packages/xcm-cfg/src/configs/index.ts @@ -11,6 +11,7 @@ import { moonbeamConfig } from './moonbeam'; import { polkadotConfig } from './polkadot'; import { subsocialConfig } from './subsocial'; import { zeitgeistConfig } from './zeitgeist'; +import { phalaConfig } from './phala'; export const chainsConfig: ChainConfig[] = [ acalaConfig, @@ -24,6 +25,7 @@ export const chainsConfig: ChainConfig[] = [ polkadotConfig, subsocialConfig, zeitgeistConfig, + phalaConfig, ]; export const chainsConfigMap = new Map( diff --git a/packages/xcm-cfg/src/configs/phala.ts b/packages/xcm-cfg/src/configs/phala.ts new file mode 100644 index 00000000..15385a0f --- /dev/null +++ b/packages/xcm-cfg/src/configs/phala.ts @@ -0,0 +1,24 @@ +import { + BalanceBuilder, + ExtrinsicBuilder, +} from '@moonbeam-network/xcm-builder'; +import { AssetConfig, ChainConfig } from '@moonbeam-network/xcm-config'; +import { pha } from 'assets'; +import { hydraDX, phala } from '../chains'; + +export const phalaConfig = new ChainConfig({ + assets: [ + new AssetConfig({ + asset: pha, + balance: BalanceBuilder().substrate().system().account(), + destination: hydraDX, + destinationFee: { + amount: 0.01842508453, + asset: pha, + balance: BalanceBuilder().substrate().system().account(), + }, + extrinsic: ExtrinsicBuilder().xTransfer().transfer().here(), + }), + ], + chain: phala, +});