@galacticcouncil/sdk 0.5.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/build/index.cjs +2 -0
  2. package/build/index.mjs +2 -0
  3. package/{dist → build}/types/index.d.ts +0 -3
  4. package/package.json +48 -39
  5. package/README.md +0 -134
  6. package/dist/index.esm.js +0 -4
  7. package/dist/index.js +0 -4
  8. package/dist/types/registry/Registry.d.ts +0 -20
  9. package/dist/types/registry/index.d.ts +0 -2
  10. package/dist/types/registry/types.d.ts +0 -22
  11. package/dist/types/storage/Storage.d.ts +0 -18
  12. package/dist/types/storage/index.d.ts +0 -1
  13. package/dist/types/wallet/Wallet.d.ts +0 -21
  14. package/dist/types/wallet/balance/Erc20BalanceAdapter.d.ts +0 -11
  15. package/dist/types/wallet/balance/NativeBalanceAdapter.d.ts +0 -14
  16. package/dist/types/wallet/balance/TokenBalanceAdapter.d.ts +0 -12
  17. package/dist/types/wallet/evm/AcalaEvmProvider.d.ts +0 -9
  18. package/dist/types/wallet/evm/DefaultEvmProvider.d.ts +0 -7
  19. package/dist/types/wallet/index.d.ts +0 -5
  20. package/dist/types/wallet/types.d.ts +0 -10
  21. package/dist/types/wallet/utils.d.ts +0 -19
  22. package/xcmgr.sync.mjs +0 -65
  23. /package/{dist → build}/types/api/Router.d.ts +0 -0
  24. /package/{dist → build}/types/api/TradeRouter.d.ts +0 -0
  25. /package/{dist → build}/types/api/index.d.ts +0 -0
  26. /package/{dist → build}/types/client/AssetClient.d.ts +0 -0
  27. /package/{dist → build}/types/client/BalanceClient.d.ts +0 -0
  28. /package/{dist → build}/types/client/PolkadotApi.d.ts +0 -0
  29. /package/{dist → build}/types/client/index.d.ts +0 -0
  30. /package/{dist → build}/types/consts.d.ts +0 -0
  31. /package/{dist → build}/types/errors.d.ts +0 -0
  32. /package/{dist → build}/types/pool/CachingPoolService.d.ts +0 -0
  33. /package/{dist → build}/types/pool/PoolClient.d.ts +0 -0
  34. /package/{dist → build}/types/pool/PoolFactory.d.ts +0 -0
  35. /package/{dist → build}/types/pool/PoolService.d.ts +0 -0
  36. /package/{dist → build}/types/pool/index.d.ts +0 -0
  37. /package/{dist → build}/types/pool/lbp/LbpMath.d.ts +0 -0
  38. /package/{dist → build}/types/pool/lbp/LbpPool.d.ts +0 -0
  39. /package/{dist → build}/types/pool/lbp/LbpPoolClient.d.ts +0 -0
  40. /package/{dist → build}/types/pool/omni/OmniMath.d.ts +0 -0
  41. /package/{dist → build}/types/pool/omni/OmniPool.d.ts +0 -0
  42. /package/{dist → build}/types/pool/omni/OmniPoolClient.d.ts +0 -0
  43. /package/{dist → build}/types/pool/xyk/XykMath.d.ts +0 -0
  44. /package/{dist → build}/types/pool/xyk/XykPool.d.ts +0 -0
  45. /package/{dist → build}/types/pool/xyk/XykPoolClient.d.ts +0 -0
  46. /package/{dist → build}/types/route/bfs.d.ts +0 -0
  47. /package/{dist → build}/types/route/graph.d.ts +0 -0
  48. /package/{dist → build}/types/route/index.d.ts +0 -0
  49. /package/{dist → build}/types/route/suggester.d.ts +0 -0
  50. /package/{dist → build}/types/types.d.ts +0 -0
  51. /package/{dist → build}/types/utils/Queue.d.ts +0 -0
  52. /package/{dist → build}/types/utils/Stack.d.ts +0 -0
  53. /package/{dist → build}/types/utils/bignumber.d.ts +0 -0
  54. /package/{dist → build}/types/utils/mapper.d.ts +0 -0
  55. /package/{dist → build}/types/utils/math.d.ts +0 -0
  56. /package/{dist → build}/types/utils/traversal/bfs.d.ts +0 -0
@@ -1,20 +0,0 @@
1
- import { Chain, ChainAsset } from './types';
2
- declare abstract class Registry {
3
- protected chains: Chain[];
4
- protected assets: Record<number, ChainAsset[]>;
5
- constructor();
6
- protected abstract initChains(): void;
7
- protected abstract initAssets(): void;
8
- getChains(): Chain[];
9
- getChain(chainId: number): Chain;
10
- getAssets(chainId: number): ChainAsset[];
11
- }
12
- export declare class PolkadotRegistry extends Registry {
13
- protected initChains(): void;
14
- protected initAssets(): void;
15
- }
16
- export declare class KusamaRegistry extends Registry {
17
- protected initChains(): void;
18
- protected initAssets(): void;
19
- }
20
- export {};
@@ -1,2 +0,0 @@
1
- export { PolkadotRegistry, KusamaRegistry } from './Registry';
2
- export { Chain, ChainAsset, ChainAssetType } from './types';
@@ -1,22 +0,0 @@
1
- export interface Chain {
2
- chainkey: string;
3
- name: string;
4
- id: string;
5
- paraID: number;
6
- WSEndpoints: string[];
7
- relaychain: string;
8
- }
9
- export interface ChainAssetType {
10
- Erc20: string;
11
- ForeignAsset: string;
12
- LiquidCrowdloan: string;
13
- StableAsset: string;
14
- Token: string;
15
- }
16
- export interface ChainAsset {
17
- asset: ChainAssetType;
18
- name: string;
19
- symbol: string;
20
- decimals: number;
21
- xcmInteriorKey: string;
22
- }
@@ -1,18 +0,0 @@
1
- import { ApiPromise, ApiRx } from '@polkadot/api';
2
- import { Observable } from 'rxjs';
3
- export type StorageOptions = {
4
- api: ApiPromise | ApiRx;
5
- path: string;
6
- params: any[];
7
- };
8
- export declare class Storage<T> {
9
- readonly options: StorageOptions;
10
- private subject;
11
- constructor(options: StorageOptions);
12
- static create<T>(options: StorageOptions): Storage<T>;
13
- get observable(): Observable<T>;
14
- private subscribeWithApiPromise;
15
- private subscribeWithApiRx;
16
- private getQuery;
17
- private subscribe;
18
- }
@@ -1 +0,0 @@
1
- export { Storage } from './Storage';
@@ -1,21 +0,0 @@
1
- import { ApiPromise, ApiRx } from '@polkadot/api';
2
- import { ChainAsset } from '../registry';
3
- import { BalanceAdapter, EvmProvider } from './types';
4
- import { Observable } from 'rxjs';
5
- import { AssetBalance } from '../types';
6
- interface WalletConfigs {
7
- evmProvider?: EvmProvider;
8
- }
9
- export declare class Wallet {
10
- readonly api: ApiPromise | ApiRx;
11
- readonly assets: ChainAsset[];
12
- readonly adapters: Record<string, BalanceAdapter>;
13
- constructor(api: ApiPromise | ApiRx, assets: ChainAsset[], cfg?: WalletConfigs);
14
- getAssets(): ChainAsset[];
15
- getAsset(assetSymbol: string, assetType?: string): ChainAsset | undefined;
16
- subscribeBalance(assetSymbol: string, assetType: string | undefined, address: string): Observable<AssetBalance>;
17
- getBalance(assetSymbol: string, assetType: string | undefined, address: string): Promise<AssetBalance>;
18
- private validateAsset;
19
- private validateAdapter;
20
- }
21
- export {};
@@ -1,11 +0,0 @@
1
- import { AbstractProvider } from 'ethers';
2
- import { Observable } from 'rxjs';
3
- import { AssetBalance } from '../../types';
4
- import { ChainAsset } from '../../registry';
5
- import { BalanceAdapter, EvmProvider } from '../types';
6
- export declare class Erc20BalanceAdapter implements BalanceAdapter {
7
- readonly client: AbstractProvider;
8
- readonly evmProvider: EvmProvider;
9
- constructor(evmProvider: EvmProvider);
10
- getObserver(asset: ChainAsset, address: string): Observable<AssetBalance>;
11
- }
@@ -1,14 +0,0 @@
1
- import { ApiPromise, ApiRx } from '@polkadot/api';
2
- import { AssetBalance } from '../../types';
3
- import { BigNumber } from '../../utils/bignumber';
4
- import { Observable } from 'rxjs';
5
- import { ChainAsset } from '../../registry';
6
- import { BalanceAdapter } from '../types';
7
- export declare abstract class NativeBalanceAdapter implements BalanceAdapter {
8
- readonly nativeToken: string;
9
- readonly decimals: number;
10
- readonly ed: BigNumber;
11
- constructor(api: ApiPromise | ApiRx);
12
- private getDeposit;
13
- abstract getObserver(token: ChainAsset, address: string): Observable<AssetBalance>;
14
- }
@@ -1,12 +0,0 @@
1
- import { ApiPromise, ApiRx } from '@polkadot/api';
2
- import { AssetBalance } from '../../types';
3
- import { Observable } from 'rxjs';
4
- import { ChainAsset } from '../../registry';
5
- import { NativeBalanceAdapter } from './NativeBalanceAdapter';
6
- export declare class TokenBalanceAdapter extends NativeBalanceAdapter {
7
- private storages;
8
- constructor(api: ApiPromise | ApiRx);
9
- getObserver(asset: ChainAsset, address: string): Observable<AssetBalance>;
10
- private getSystemAccountBalanceObserver;
11
- private getTokenAccountBalanceObserver;
12
- }
@@ -1,9 +0,0 @@
1
- import { ApiPromise, ApiRx } from '@polkadot/api';
2
- import { EvmProvider } from '../types';
3
- export declare class AcalaEvmProvider implements EvmProvider {
4
- readonly api: ApiPromise | ApiRx;
5
- readonly endpoint: string;
6
- constructor(api: ApiPromise | ApiRx, endpoint: string);
7
- toEvmAddress(address: string): Promise<string>;
8
- getEndpoint(): string;
9
- }
@@ -1,7 +0,0 @@
1
- import { EvmProvider } from '../types';
2
- export declare class DefaultEvmProvider implements EvmProvider {
3
- readonly endpoint: string;
4
- constructor(endpoint: string);
5
- toEvmAddress(address: string): Promise<string>;
6
- getEndpoint(): string;
7
- }
@@ -1,5 +0,0 @@
1
- export { Wallet } from './Wallet';
2
- export { TokenBalanceAdapter } from './balance/TokenBalanceAdapter';
3
- export { Erc20BalanceAdapter } from './balance/Erc20BalanceAdapter';
4
- export { DefaultEvmProvider } from './evm/DefaultEvmProvider';
5
- export { AcalaEvmProvider } from './evm/AcalaEvmProvider';
@@ -1,10 +0,0 @@
1
- import { Observable } from 'rxjs';
2
- import { AssetBalance } from '../types';
3
- import { ChainAsset } from '../registry';
4
- export interface BalanceAdapter {
5
- getObserver(asset: ChainAsset, address: string): Observable<AssetBalance>;
6
- }
7
- export interface EvmProvider {
8
- toEvmAddress(address: string): Promise<string>;
9
- getEndpoint(): string;
10
- }
@@ -1,19 +0,0 @@
1
- export declare const ADDRESS_FORMAT: {
2
- ss58: string;
3
- h160: string;
4
- snow: string;
5
- arctic: string;
6
- pubKey: string;
7
- };
8
- export declare const CHAIN_PREFIX: {
9
- snow: number;
10
- ss58: number;
11
- arctic: number;
12
- };
13
- export declare function convertH160ToSs58(h160Addr: string): string;
14
- export declare function convertSs58ToH160(ss58Addr: string): string;
15
- export declare function getPubKey(ss58addr: string): string;
16
- export declare function encodePubKey(pubKey: string, prefix: number): string;
17
- export declare function encodePolkadotAddress(addr: string, prefix: number): string;
18
- export declare function validateSs58(ss58Addr: string): void;
19
- export declare function validatePubKey(pubkey: string): void;
package/xcmgr.sync.mjs DELETED
@@ -1,65 +0,0 @@
1
- import { mkdirSync, existsSync, writeFileSync } from 'fs';
2
-
3
- const XCMGAR_REPO = 'https://raw.githubusercontent.com/colorfulnotion/xcm-global-registry/main';
4
- const RELAY_CHAINS = ['kusama', 'polkadot'];
5
- const DEST = './src/registry/data';
6
-
7
- function pairs2Map(pairs) {
8
- const result = new Map();
9
- pairs.forEach((pair) => result.set(pair[0], pair[1]));
10
- return result;
11
- }
12
-
13
- const writeJsonSync = (path, data) => {
14
- writeFileSync(path, JSON.stringify(data, null, 4));
15
- };
16
-
17
- const fetchPublicEndpoints = async (relay) => {
18
- const response = await fetch(`${XCMGAR_REPO}/publicEndpoints/${relay}_publicEndpoints.json`);
19
- return await response.json();
20
- };
21
-
22
- // TODO: Fetch XcAssets
23
- const fetchXcAssets = async (relay, chainKey) => {
24
- const response = await fetch(`${XCMGAR_REPO}/xcAssets/${relay}/${chainKey}_xcAssets.json`);
25
- return await response.json();
26
- };
27
-
28
- const fetchAssets = async (relay, chainKey) => {
29
- const response = await fetch(`${XCMGAR_REPO}/assets/${relay}/${chainKey}_assets.json`);
30
- return await response.json();
31
- };
32
-
33
- const syncAssets = async (relay, chainKeys) => {
34
- const assets = await Promise.all(
35
- chainKeys
36
- .map((chainKey) => chainKey.replace('-', '_'))
37
- .map(async (chainKey) => {
38
- let assets = [];
39
- try {
40
- assets = await fetchAssets(relay, chainKey);
41
- } catch (err) {}
42
- return [chainKey.replace(`${relay}_`, ''), assets];
43
- })
44
- );
45
-
46
- const assetMap = pairs2Map(assets);
47
- const ASSETS_FILE_PATH = `${DEST}/${relay}/assets.json`;
48
- writeJsonSync(ASSETS_FILE_PATH, Object.fromEntries(assetMap));
49
- };
50
-
51
- (async () => {
52
- RELAY_CHAINS.forEach(async (relay) => {
53
- const fld = `${DEST}/${relay}`;
54
- if (!existsSync(fld)) {
55
- mkdirSync(fld);
56
- }
57
- const ENDPOINT_FILE_PATH = `${DEST}/${relay}/endpoints.json`;
58
- const endpoints = await fetchPublicEndpoints(relay);
59
-
60
- await syncAssets(relay, Object.keys(endpoints));
61
-
62
- writeJsonSync(ENDPOINT_FILE_PATH, Object.values(endpoints));
63
- console.log(`${relay} done ✅`);
64
- });
65
- })();
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes