|
| 1 | +import { setupContext, SetupOption } from '@acala-network/chopsticks-testing' |
| 2 | +import type { Config } from './types.js' |
| 3 | +import * as SpiritnetConfig from './spiritnet.js' |
| 4 | +import { initialBalanceHDX, initialBalanceKILT, toNumber } from '../utils.js' |
| 5 | + |
| 6 | +/// Options used to create the HydraDx context |
| 7 | +export const options: SetupOption = { |
| 8 | + endpoint: process.env.HYDRADX_WS || ['wss://hydradx-rpc.dwellir.com', 'wss://rpc.hydradx.cloud'], |
| 9 | + db: './db/hydradx.db.sqlite', |
| 10 | + port: toNumber(process.env.HYDRADX_PORT) || 9001, |
| 11 | +} |
| 12 | + |
| 13 | +export const kiltTokenId = 60 |
| 14 | + |
| 15 | +/// Sets the [TechnicalCommittee] and [Council] governance to the given accounts |
| 16 | +export function setGovernance(addr: string[]) { |
| 17 | + return { |
| 18 | + TechnicalCommittee: { Members: addr }, |
| 19 | + Council: { Members: addr }, |
| 20 | + } |
| 21 | +} |
| 22 | + |
| 23 | +/// Assigns the native tokens to an accounts |
| 24 | +export function assignNativeTokensToAccounts(addr: string[], balance: bigint = initialBalanceHDX) { |
| 25 | + return { |
| 26 | + System: { |
| 27 | + Account: addr.map((address) => [[address], { providers: 1, data: { free: balance } }]), |
| 28 | + }, |
| 29 | + } |
| 30 | +} |
| 31 | + |
| 32 | +/// Assigns KILT tokens to an accounts |
| 33 | +export function assignKiltTokensToAccounts(addr: string[], balance: bigint = initialBalanceKILT) { |
| 34 | + return { |
| 35 | + Tokens: { |
| 36 | + Accounts: addr.map((address) => [[address, kiltTokenId], { free: balance }]), |
| 37 | + }, |
| 38 | + } |
| 39 | +} |
| 40 | + |
| 41 | +/// Register KILT into HydraDX and allow KILT as payment |
| 42 | +export function registerKilt() { |
| 43 | + return { |
| 44 | + assetRegistry: { |
| 45 | + assetLocations: [[[kiltTokenId], { parents: 1, interior: { X1: { Parachain: SpiritnetConfig.paraId } } }]], |
| 46 | + assetIds: [[['KILT'], kiltTokenId]], |
| 47 | + locationAssets: [[[{ parents: 1, interior: { X1: { Parachain: SpiritnetConfig.paraId } } }], kiltTokenId]], |
| 48 | + assets: [ |
| 49 | + [ |
| 50 | + [kiltTokenId], |
| 51 | + { |
| 52 | + name: 'KILT', |
| 53 | + assetType: 'Token', |
| 54 | + existentialDeposit: 500, |
| 55 | + symbol: 'KILT', |
| 56 | + decimals: 18, |
| 57 | + xcmRateLimit: null, |
| 58 | + isSufficient: true, |
| 59 | + }, |
| 60 | + ], |
| 61 | + ], |
| 62 | + }, |
| 63 | + multiTransactionPayment: { |
| 64 | + acceptedCurrencies: [[[kiltTokenId], 100_000]], |
| 65 | + }, |
| 66 | + } |
| 67 | +} |
| 68 | + |
| 69 | +/// HydraDX ParaId |
| 70 | +export const paraId = 2034 |
| 71 | + |
| 72 | +/// OmniPool account |
| 73 | +export const omnipoolAccount = '7L53bUTBbfuj14UpdCNPwmgzzHSsrsTWBHX5pys32mVWM3C1' |
| 74 | + |
| 75 | +export async function getContext(): Promise<Config> { |
| 76 | + return setupContext(options) |
| 77 | +} |
0 commit comments