Skip to content

Commit

Permalink
add address space spec
Browse files Browse the repository at this point in the history
  • Loading branch information
nohaapav committed Oct 20, 2024
1 parent 6a9acaf commit 343bd2c
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 13 deletions.
8 changes: 4 additions & 4 deletions packages/sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ Component list and current status ⬇️
| Router | API | 🧪 |
| TradeRouter | API | 🧪 |
| Twap | API ||
| XYK | Math | 🧪 |
| XYK | Pool | 🧪 |
| Omni | Math | 🧪 |
| Omni | Pool | 🧪 |
| LBP | Math | 🧪 |
| LBP | Pool | 🧪 |
| Omni | Math | 🧪 |
| Omni | Pool | 🧪 |
| Stable | Math | 🧪 |
| Stable | Pool | 🧪 |
| XYK | Math | 🧪 |
| XYK | Pool | 🧪 |
76 changes: 76 additions & 0 deletions packages/xcm-cfg/src/chains.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { AnyChain, ChainEcosystem, Parachain } from '@galacticcouncil/xcm-core';

import { chains } from './chains';

const fullAddressSpace = (chain: AnyChain): boolean => {
return (
chain instanceof Parachain &&
chain.isEvmParachain() &&
chain.usesH160Acc == false
);
};

const h160AddressSpaceOnly = (chain: AnyChain): boolean => {
return (
(chain instanceof Parachain && chain.usesH160Acc == true) ||
chain.isEvmChain()
);
};

const ss58AddressSpaceOnly = (chain: AnyChain): boolean => {
return (
chain instanceof Parachain &&
chain.isParachain() &&
chain.usesH160Acc == false
);
};

describe('chains config', () => {
describe('check address space support in polkadot ecosystem', () => {
it('should match given chains with both evm & substrate address space support', async () => {
expect(
chains
.filter((c) => c.ecosystem === ChainEcosystem.Polkadot)
.filter((c) => fullAddressSpace(c))
.map((c) => c.key)
.sort()
).toEqual(['acala', 'hydration'].sort());
});
it('should match given chains with evm only address space support', async () => {
expect(
chains
.filter((c) => c.ecosystem === ChainEcosystem.Polkadot)
.filter((c) => h160AddressSpaceOnly(c))
.map((c) => c.key)
.sort()
).toEqual(['acala-evm', 'darwinia', 'moonbeam', 'mythos'].sort());
});
it('should match given chains with substrate only address space support', async () => {
expect(
chains
.filter((c) => c.ecosystem === ChainEcosystem.Polkadot)
.filter((c) => ss58AddressSpaceOnly(c))
.map((c) => c.key)
.sort()
).toEqual(
[
'ajuna',
'assethub',
'astar',
'bifrost',
'centrifuge',
'crust',
'interlay',
'kilt',
'nodle',
'pendulum',
'phala',
'polkadot',
'subsocial',
'unique',
'zeitgeist',
].sort()
);
});
});
});
2 changes: 0 additions & 2 deletions packages/xcm-cfg/src/templates.ts

This file was deleted.

8 changes: 1 addition & 7 deletions packages/xcm-core/src/utils/account.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {
bnToU8a,
hexToU8a,
stringToU8a,
u8aToHex,
u8aToString,
} from '@polkadot/util';
import { bnToU8a, hexToU8a, stringToU8a, u8aToHex } from '@polkadot/util';

import { decodeAddress, blake2AsU8a } from '@polkadot/util-crypto';
import { TypeRegistry } from '@polkadot/types';
Expand Down

0 comments on commit 343bd2c

Please sign in to comment.