Skip to content

Commit

Permalink
phala support
Browse files Browse the repository at this point in the history
  • Loading branch information
mrq1911 committed Dec 29, 2023
1 parent 0762c82 commit 109de72
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/xcm-cfg/src/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -102,6 +107,7 @@ export const assets: Asset[] = [
weth_awh,
weth_mwh,
ztg,
pha,
];

export const assetsMap = new Map<string, Asset>(
Expand Down
25 changes: 25 additions & 0 deletions packages/xcm-cfg/src/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
weth_awh,
weth_mwh,
ztg,
pha,
} from './assets';

export const acala = new Parachain({
Expand Down Expand Up @@ -261,6 +262,11 @@ export const hydraDX = new Parachain({
id: 12,
decimals: 10,
},
{
asset: pha,
id: 8,
decimals: 12,
}
],
ecosystem: Ecosystem.Polkadot,
genesisHash:
Expand Down Expand Up @@ -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,
Expand All @@ -398,6 +422,7 @@ export const chains: AnyChain[] = [
polkadot,
subsocial,
zeitgeist,
phala,
];

export const chainsMap = new Map<string, AnyChain>(
Expand Down
21 changes: 21 additions & 0 deletions packages/xcm-cfg/src/configs/hydraDX.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
hdx,
ibtc,
intr,
pha,
sub,
usdc,
usdc_mwh,
Expand All @@ -41,6 +42,7 @@ import {
hydraDX,
interlay,
moonbeam,
phala,
subsocial,
zeitgeist,
} from '../chains';
Expand Down Expand Up @@ -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,
Expand All @@ -400,6 +420,7 @@ export const hydraDxConfig = new ChainConfig({
...toPolkadot,
...toSubsocial,
...toZeitgeist,
...toPhala,
],
chain: hydraDX,
});
2 changes: 2 additions & 0 deletions packages/xcm-cfg/src/configs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -24,6 +25,7 @@ export const chainsConfig: ChainConfig[] = [
polkadotConfig,
subsocialConfig,
zeitgeistConfig,
phalaConfig,
];

export const chainsConfigMap = new Map<string, ChainConfig>(
Expand Down
24 changes: 24 additions & 0 deletions packages/xcm-cfg/src/configs/phala.ts
Original file line number Diff line number Diff line change
@@ -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,
});

0 comments on commit 109de72

Please sign in to comment.