@talismn/chaindata-provider 0.7.0 → 0.8.1
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.
- package/dist/declarations/src/ChaindataProvider.d.ts +90 -17
- package/dist/declarations/src/TalismanChaindataDatabase.d.ts +9 -0
- package/dist/declarations/src/constants.d.ts +26 -0
- package/dist/declarations/src/index.d.ts +5 -2
- package/dist/declarations/src/init/chains.d.ts +243 -0
- package/dist/declarations/src/init/evm-networks.d.ts +61 -0
- package/dist/declarations/src/init/index.d.ts +5 -0
- package/dist/declarations/src/init/mini-metadatas.d.ts +21 -0
- package/dist/declarations/src/init/tokens.d.ts +103 -0
- package/dist/declarations/src/log.d.ts +2 -0
- package/dist/declarations/src/net.d.ts +8 -0
- package/dist/declarations/src/types/Chain.d.ts +42 -5
- package/dist/declarations/src/types/ChaindataProviderInterface.d.ts +42 -0
- package/dist/declarations/src/types/EvmNetwork.d.ts +17 -4
- package/dist/declarations/src/types/Token/EvmErc20Token.d.ts +15 -0
- package/dist/declarations/src/types/Token/EvmNativeToken.d.ts +10 -0
- package/dist/declarations/src/types/Token/EvmUniswapV2Token.d.ts +22 -0
- package/dist/declarations/src/types/Token/SubstrateAssetsToken.d.ts +12 -0
- package/dist/declarations/src/types/Token/SubstrateEquilibriumToken.d.ts +11 -0
- package/dist/declarations/src/types/Token/SubstrateForeignAssetsToken.d.ts +12 -0
- package/dist/declarations/src/types/Token/SubstrateNativeToken.d.ts +13 -0
- package/dist/declarations/src/types/Token/SubstratePsp22Token.d.ts +11 -0
- package/dist/declarations/src/types/Token/SubstrateTokensToken.d.ts +11 -0
- package/dist/declarations/src/types/Token/index.d.ts +26 -0
- package/dist/declarations/src/types/Token/types.d.ts +27 -0
- package/dist/declarations/src/types/index.d.ts +1 -0
- package/dist/declarations/src/upgrades/2024-01-25-upgradeAddIsDefaultToExistingChains.d.ts +2 -0
- package/dist/declarations/src/upgrades/2024-01-25-upgradeRemoveSymbolFromNativeTokenId.d.ts +2 -0
- package/dist/declarations/src/upgrades/index.d.ts +1 -0
- package/dist/declarations/src/util.d.ts +27 -0
- package/dist/net-BE0MfrDv.cjs.dev.js +89 -0
- package/dist/net-BE0MfrDv.cjs.prod.js +89 -0
- package/dist/net-il4EYhJN.esm.js +55 -0
- package/dist/talismn-chaindata-provider.cjs.dev.js +912 -23
- package/dist/talismn-chaindata-provider.cjs.prod.js +912 -23
- package/dist/talismn-chaindata-provider.esm.js +858 -12
- package/init/chains/dist/talismn-chaindata-provider-init-chains.cjs.d.ts +1 -0
- package/init/chains/dist/talismn-chaindata-provider-init-chains.cjs.dev.js +934 -0
- package/init/chains/dist/talismn-chaindata-provider-init-chains.cjs.js +7 -0
- package/init/chains/dist/talismn-chaindata-provider-init-chains.cjs.prod.js +934 -0
- package/init/chains/dist/talismn-chaindata-provider-init-chains.esm.js +932 -0
- package/init/chains/package.json +4 -0
- package/init/evm-networks/dist/talismn-chaindata-provider-init-evm-networks.cjs.d.ts +1 -0
- package/init/evm-networks/dist/talismn-chaindata-provider-init-evm-networks.cjs.dev.js +69 -0
- package/init/evm-networks/dist/talismn-chaindata-provider-init-evm-networks.cjs.js +7 -0
- package/init/evm-networks/dist/talismn-chaindata-provider-init-evm-networks.cjs.prod.js +69 -0
- package/init/evm-networks/dist/talismn-chaindata-provider-init-evm-networks.esm.js +67 -0
- package/init/evm-networks/package.json +4 -0
- package/init/mini-metadatas/dist/talismn-chaindata-provider-init-mini-metadatas.cjs.d.ts +1 -0
- package/init/mini-metadatas/dist/talismn-chaindata-provider-init-mini-metadatas.cjs.dev.js +311 -0
- package/init/mini-metadatas/dist/talismn-chaindata-provider-init-mini-metadatas.cjs.js +7 -0
- package/init/mini-metadatas/dist/talismn-chaindata-provider-init-mini-metadatas.cjs.prod.js +311 -0
- package/init/mini-metadatas/dist/talismn-chaindata-provider-init-mini-metadatas.esm.js +309 -0
- package/init/mini-metadatas/package.json +4 -0
- package/init/tokens/dist/talismn-chaindata-provider-init-tokens.cjs.d.ts +1 -0
- package/init/tokens/dist/talismn-chaindata-provider-init-tokens.cjs.dev.js +406 -0
- package/init/tokens/dist/talismn-chaindata-provider-init-tokens.cjs.js +7 -0
- package/init/tokens/dist/talismn-chaindata-provider-init-tokens.cjs.prod.js +406 -0
- package/init/tokens/dist/talismn-chaindata-provider-init-tokens.esm.js +404 -0
- package/init/tokens/package.json +4 -0
- package/net/dist/talismn-chaindata-provider-net.cjs.d.ts +1 -0
- package/net/dist/talismn-chaindata-provider-net.cjs.dev.js +14 -0
- package/net/dist/talismn-chaindata-provider-net.cjs.js +7 -0
- package/net/dist/talismn-chaindata-provider-net.cjs.prod.js +14 -0
- package/net/dist/talismn-chaindata-provider-net.esm.js +1 -0
- package/net/package.json +4 -0
- package/package.json +27 -14
- package/CHANGELOG.md +0 -104
- package/dist/declarations/src/github.d.ts +0 -11
- package/dist/declarations/src/plugins.d.ts +0 -17
- package/dist/declarations/src/types/Token.d.ts +0 -48
- package/plugins/dist/talismn-chaindata-provider-plugins.cjs.d.ts +0 -1
- package/plugins/dist/talismn-chaindata-provider-plugins.cjs.dev.js +0 -2
- package/plugins/dist/talismn-chaindata-provider-plugins.cjs.js +0 -7
- package/plugins/dist/talismn-chaindata-provider-plugins.cjs.prod.js +0 -2
- package/plugins/dist/talismn-chaindata-provider-plugins.esm.js +0 -1
- package/plugins/package.json +0 -4
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
|
+
import { Chain, ChainId, CustomChain } from "./Chain";
|
|
3
|
+
import { CustomEvmNetwork, EvmNetwork, EvmNetworkId } from "./EvmNetwork";
|
|
4
|
+
import { Token, TokenId } from "./Token";
|
|
5
|
+
export interface IChaindataChainProvider {
|
|
6
|
+
chainsObservable: Observable<Chain[]>;
|
|
7
|
+
chains(): Promise<Chain[]>;
|
|
8
|
+
customChainsObservable: Observable<CustomChain[]>;
|
|
9
|
+
customChains(): Promise<CustomChain[]>;
|
|
10
|
+
chainIdsObservable: Observable<ChainId[]>;
|
|
11
|
+
chainIds(): Promise<ChainId[]>;
|
|
12
|
+
chainsByIdObservable: Observable<Record<ChainId, Chain>>;
|
|
13
|
+
chainsById(): Promise<Record<ChainId, Chain>>;
|
|
14
|
+
chainsByGenesisHashObservable: Observable<Record<ChainId, Chain>>;
|
|
15
|
+
chainsByGenesisHash(): Promise<Record<ChainId, Chain>>;
|
|
16
|
+
chainById(chainId: ChainId): Promise<Chain | null>;
|
|
17
|
+
chainByGenesisHash(genesisHash: `0x${string}`): Promise<Chain | null>;
|
|
18
|
+
}
|
|
19
|
+
export interface IChaindataEvmNetworkProvider {
|
|
20
|
+
evmNetworksObservable: Observable<EvmNetwork[]>;
|
|
21
|
+
evmNetworks(): Promise<EvmNetwork[]>;
|
|
22
|
+
customEvmNetworksObservable: Observable<CustomEvmNetwork[]>;
|
|
23
|
+
customEvmNetworks(): Promise<CustomEvmNetwork[]>;
|
|
24
|
+
evmNetworkIdsObservable: Observable<EvmNetworkId[]>;
|
|
25
|
+
evmNetworkIds(): Promise<EvmNetworkId[]>;
|
|
26
|
+
evmNetworksByIdObservable: Observable<Record<EvmNetworkId, EvmNetwork>>;
|
|
27
|
+
evmNetworksById(): Promise<Record<EvmNetworkId, EvmNetwork>>;
|
|
28
|
+
evmNetworkById(evmNetworkId: EvmNetworkId): Promise<EvmNetwork | null>;
|
|
29
|
+
}
|
|
30
|
+
export interface IChaindataTokenProvider {
|
|
31
|
+
tokensObservable: Observable<Token[]>;
|
|
32
|
+
tokens(): Promise<Token[]>;
|
|
33
|
+
customTokensObservable: Observable<Token[]>;
|
|
34
|
+
customTokens(): Promise<Token[]>;
|
|
35
|
+
tokenIdsObservable: Observable<TokenId[]>;
|
|
36
|
+
tokenIds(): Promise<TokenId[]>;
|
|
37
|
+
tokensByIdObservable: Observable<Record<TokenId, Token>>;
|
|
38
|
+
tokensById(): Promise<Record<TokenId, Token>>;
|
|
39
|
+
tokenById(tokenId: TokenId): Promise<Token | null>;
|
|
40
|
+
}
|
|
41
|
+
export interface IChaindataProvider extends IChaindataChainProvider, IChaindataEvmNetworkProvider, IChaindataTokenProvider {
|
|
42
|
+
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { ChainId } from "./Chain";
|
|
1
|
+
import { BalancesConfig, BalancesMetadata, ChainId } from "./Chain";
|
|
2
2
|
import { TokenId } from "./Token";
|
|
3
|
-
export type EvmNetworkList = Record<EvmNetworkId, EvmNetwork
|
|
3
|
+
export type EvmNetworkList = Record<EvmNetworkId, EvmNetwork>;
|
|
4
4
|
export type EvmNetworkId = string;
|
|
5
5
|
export type EvmNetwork = {
|
|
6
6
|
id: EvmNetworkId;
|
|
7
7
|
isTestnet: boolean;
|
|
8
|
+
isDefault: boolean;
|
|
9
|
+
forceScan: boolean;
|
|
8
10
|
sortIndex: number | null;
|
|
9
11
|
name: string | null;
|
|
10
12
|
themeColor: string | null;
|
|
@@ -12,22 +14,33 @@ export type EvmNetwork = {
|
|
|
12
14
|
nativeToken: {
|
|
13
15
|
id: TokenId;
|
|
14
16
|
} | null;
|
|
17
|
+
/** @deprecated tokens already reference their network */
|
|
15
18
|
tokens: Array<{
|
|
16
19
|
id: TokenId;
|
|
17
20
|
}> | null;
|
|
18
21
|
explorerUrl: string | null;
|
|
19
22
|
rpcs: Array<EthereumRpc> | null;
|
|
20
|
-
isHealthy: boolean;
|
|
21
23
|
substrateChain: {
|
|
22
24
|
id: ChainId;
|
|
23
25
|
} | null;
|
|
26
|
+
feeType?: "legacy" | "eip-1559";
|
|
27
|
+
l2FeeType?: {
|
|
28
|
+
type: "op-stack";
|
|
29
|
+
} | {
|
|
30
|
+
type: "scroll";
|
|
31
|
+
l1GasPriceOracle: `0x${string}`;
|
|
32
|
+
};
|
|
33
|
+
balancesConfig: Array<BalancesConfig>;
|
|
34
|
+
/** @deprecated has its own store now */
|
|
35
|
+
balancesMetadata: Array<BalancesMetadata>;
|
|
36
|
+
erc20aggregator?: `0x${string}`;
|
|
24
37
|
};
|
|
25
38
|
export type CustomEvmNetwork = EvmNetwork & {
|
|
26
39
|
isCustom: true;
|
|
27
40
|
explorerUrls: string[];
|
|
28
41
|
iconUrls: string[];
|
|
29
42
|
};
|
|
43
|
+
export type SimpleEvmNetwork = Omit<EvmNetwork | CustomEvmNetwork, "balancesConfig" | "balancesMetadata">;
|
|
30
44
|
export type EthereumRpc = {
|
|
31
45
|
url: string;
|
|
32
|
-
isHealthy: boolean;
|
|
33
46
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EvmNetworkId } from "../EvmNetwork";
|
|
2
|
+
import { NewTokenType } from "./types";
|
|
3
|
+
type ModuleType = "evm-erc20";
|
|
4
|
+
export type EvmErc20Token = NewTokenType<ModuleType, {
|
|
5
|
+
contractAddress: string;
|
|
6
|
+
evmNetwork: {
|
|
7
|
+
id: EvmNetworkId;
|
|
8
|
+
} | null;
|
|
9
|
+
isCustom?: true;
|
|
10
|
+
image?: string;
|
|
11
|
+
}>;
|
|
12
|
+
export type CustomEvmErc20Token = Omit<EvmErc20Token, "isCustom"> & {
|
|
13
|
+
isCustom: true;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EvmNetworkId } from "../EvmNetwork";
|
|
2
|
+
import { NewTokenType } from "./types";
|
|
3
|
+
type ModuleType = "evm-uniswapv2";
|
|
4
|
+
export type EvmUniswapV2Token = NewTokenType<ModuleType, {
|
|
5
|
+
contractAddress: string;
|
|
6
|
+
symbol0: string;
|
|
7
|
+
symbol1: string;
|
|
8
|
+
decimals0: number;
|
|
9
|
+
decimals1: number;
|
|
10
|
+
tokenAddress0: string;
|
|
11
|
+
tokenAddress1: string;
|
|
12
|
+
coingeckoId0?: string;
|
|
13
|
+
coingeckoId1?: string;
|
|
14
|
+
evmNetwork: {
|
|
15
|
+
id: EvmNetworkId;
|
|
16
|
+
} | null;
|
|
17
|
+
}>;
|
|
18
|
+
export type CustomEvmUniswapV2Token = Omit<EvmUniswapV2Token, "isCustom"> & {
|
|
19
|
+
isCustom: true;
|
|
20
|
+
image?: string;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ChainId } from "../Chain";
|
|
2
|
+
import { NewTokenType } from "./types";
|
|
3
|
+
type ModuleType = "substrate-assets";
|
|
4
|
+
export type SubAssetsToken = NewTokenType<ModuleType, {
|
|
5
|
+
existentialDeposit: string;
|
|
6
|
+
assetId: string;
|
|
7
|
+
isFrozen: boolean;
|
|
8
|
+
chain: {
|
|
9
|
+
id: ChainId;
|
|
10
|
+
};
|
|
11
|
+
}>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ChainId } from "../Chain";
|
|
2
|
+
import { NewTokenType } from "./types";
|
|
3
|
+
type ModuleType = "substrate-equilibrium";
|
|
4
|
+
export type SubEquilibriumToken = NewTokenType<ModuleType, {
|
|
5
|
+
existentialDeposit: string;
|
|
6
|
+
assetId: string;
|
|
7
|
+
chain: {
|
|
8
|
+
id: ChainId;
|
|
9
|
+
};
|
|
10
|
+
}>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ChainId } from "../Chain";
|
|
2
|
+
import { NewTokenType } from "./types";
|
|
3
|
+
type ModuleType = "substrate-foreignassets";
|
|
4
|
+
export type SubForeignAssetsToken = NewTokenType<ModuleType, {
|
|
5
|
+
existentialDeposit: string;
|
|
6
|
+
onChainId: string;
|
|
7
|
+
isFrozen: boolean;
|
|
8
|
+
chain: {
|
|
9
|
+
id: ChainId;
|
|
10
|
+
};
|
|
11
|
+
}>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ChainId } from "../Chain";
|
|
2
|
+
import { NewTokenType } from "./types";
|
|
3
|
+
type ModuleType = "substrate-native";
|
|
4
|
+
export type SubNativeToken = NewTokenType<ModuleType, {
|
|
5
|
+
existentialDeposit: string;
|
|
6
|
+
chain: {
|
|
7
|
+
id: ChainId;
|
|
8
|
+
};
|
|
9
|
+
}>;
|
|
10
|
+
export type CustomSubNativeToken = SubNativeToken & {
|
|
11
|
+
isCustom: true;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ChainId } from "../Chain";
|
|
2
|
+
import { NewTokenType } from "./types";
|
|
3
|
+
type ModuleType = "substrate-psp22";
|
|
4
|
+
export type SubPsp22Token = NewTokenType<ModuleType, {
|
|
5
|
+
existentialDeposit: string;
|
|
6
|
+
contractAddress: string;
|
|
7
|
+
chain: {
|
|
8
|
+
id: ChainId;
|
|
9
|
+
};
|
|
10
|
+
}>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ChainId } from "../Chain";
|
|
2
|
+
import { NewTokenType } from "./types";
|
|
3
|
+
type ModuleType = "substrate-tokens";
|
|
4
|
+
export type SubTokensToken = NewTokenType<ModuleType, {
|
|
5
|
+
existentialDeposit: string;
|
|
6
|
+
onChainId: string | number;
|
|
7
|
+
chain: {
|
|
8
|
+
id: ChainId;
|
|
9
|
+
};
|
|
10
|
+
}>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CustomEvmErc20Token, EvmErc20Token } from "./EvmErc20Token";
|
|
2
|
+
import { EvmNativeToken } from "./EvmNativeToken";
|
|
3
|
+
import { CustomEvmUniswapV2Token, EvmUniswapV2Token } from "./EvmUniswapV2Token";
|
|
4
|
+
import { SubAssetsToken } from "./SubstrateAssetsToken";
|
|
5
|
+
import { SubEquilibriumToken } from "./SubstrateEquilibriumToken";
|
|
6
|
+
import { SubForeignAssetsToken } from "./SubstrateForeignAssetsToken";
|
|
7
|
+
import { CustomSubNativeToken, SubNativeToken } from "./SubstrateNativeToken";
|
|
8
|
+
import { SubPsp22Token } from "./SubstratePsp22Token";
|
|
9
|
+
import { SubTokensToken } from "./SubstrateTokensToken";
|
|
10
|
+
import { TokenBase, TokenId } from "./types";
|
|
11
|
+
export type { TokenId } from "./types";
|
|
12
|
+
/** A collection of `Token` objects */
|
|
13
|
+
export type TokenList = Record<TokenId, Token>;
|
|
14
|
+
/**
|
|
15
|
+
* The `Token` sum type, which is a union of all of the possible `TokenTypes`.
|
|
16
|
+
*/
|
|
17
|
+
export type Token = TokenBase & (EvmErc20Token | CustomEvmErc20Token | EvmNativeToken | EvmUniswapV2Token | CustomEvmUniswapV2Token | SubAssetsToken | SubEquilibriumToken | SubForeignAssetsToken | SubNativeToken | CustomSubNativeToken | SubPsp22Token | SubTokensToken);
|
|
18
|
+
/**
|
|
19
|
+
* A selection of fields which can be set as part of the `BalancesConfig` section on chaindata for any module type.
|
|
20
|
+
*
|
|
21
|
+
* Generally speaking, these fields will override any defaults set by the module itself.
|
|
22
|
+
*
|
|
23
|
+
* E.g. if the module determines a native token to have the symbol `IBTC`, but we want to show it
|
|
24
|
+
* as `iBTC`, we can set the `symbol` field in chaindata at: `chains.interlay.balancesConfig.substrate-native.symbol`.
|
|
25
|
+
*/
|
|
26
|
+
export type BalancesConfigTokenParams = Pick<Partial<Token>, "symbol" | "coingeckoId" | "dcentName" | "mirrorOf" | "logo" | "isDefault" | "noDiscovery">;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ChainId } from "../Chain";
|
|
2
|
+
import { EvmNetworkId } from "../EvmNetwork";
|
|
3
|
+
export type TokenId = string;
|
|
4
|
+
/** `TokenBase` is a common interface which all tokens must implement. */
|
|
5
|
+
export type TokenBase = {
|
|
6
|
+
id: TokenId;
|
|
7
|
+
type: string;
|
|
8
|
+
isTestnet: boolean;
|
|
9
|
+
isDefault?: boolean;
|
|
10
|
+
symbol: string;
|
|
11
|
+
decimals: number;
|
|
12
|
+
logo: string;
|
|
13
|
+
coingeckoId?: string;
|
|
14
|
+
dcentName?: string;
|
|
15
|
+
noDiscovery?: boolean;
|
|
16
|
+
mirrorOf?: string;
|
|
17
|
+
chain?: {
|
|
18
|
+
id: ChainId;
|
|
19
|
+
} | null;
|
|
20
|
+
evmNetwork?: {
|
|
21
|
+
id: EvmNetworkId;
|
|
22
|
+
} | null;
|
|
23
|
+
};
|
|
24
|
+
/** Used by plugins to help define their custom `TokenType` */
|
|
25
|
+
export type NewTokenType<ModuleType extends string, TokenParams extends Record<string, unknown>> = TokenBase & {
|
|
26
|
+
type: ModuleType;
|
|
27
|
+
} & TokenParams;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./2024-01-25-upgradeRemoveSymbolFromNativeTokenId";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
|
+
import { Chain, CustomChain, CustomEvmNetwork, EvmNetwork, SimpleEvmNetwork, Token } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Util to add our onfinality api key to any public onfinality RPC urls in an array of chains.
|
|
5
|
+
*/
|
|
6
|
+
export declare const addCustomChainRpcs: (chains: Chain[], onfinalityApiKey?: string) => Chain[];
|
|
7
|
+
export declare const parseTokensResponse: (tokens: Token[]) => Token[];
|
|
8
|
+
export declare const isTokenPartial: (token: unknown) => token is Partial<Token>;
|
|
9
|
+
export declare const isToken: (token: Partial<Token>) => token is Token;
|
|
10
|
+
export declare const itemsToIds: <T extends {
|
|
11
|
+
id: string;
|
|
12
|
+
}>(items: T[]) => string[];
|
|
13
|
+
export declare const itemsToMapById: <T extends {
|
|
14
|
+
id: string;
|
|
15
|
+
}>(items: T[]) => Record<string, T>;
|
|
16
|
+
export declare const itemsToMapByGenesisHash: <T extends {
|
|
17
|
+
genesisHash: string | null;
|
|
18
|
+
}>(items: T[]) => Record<string, T>;
|
|
19
|
+
export declare const customChainsFilter: (chains: Array<Chain | CustomChain>) => CustomChain[];
|
|
20
|
+
export declare const customEvmNetworksFilter: (evmNetworks: Array<EvmNetwork | CustomEvmNetwork>) => CustomEvmNetwork[];
|
|
21
|
+
export declare const customTokensFilter: (tokens: Token[]) => Token[];
|
|
22
|
+
type ObservableReturnType<O> = O extends Observable<infer T> ? T : O;
|
|
23
|
+
export declare const wrapObservableWithGetter: <O extends Observable<any>>(errorReason: string, observable: O) => Promise<ObservableReturnType<O>>;
|
|
24
|
+
export declare const withErrorReason: <T>(reason: string, task: () => Promise<T> | T) => Promise<T>;
|
|
25
|
+
export declare const isCustomChain: (chain: Chain | CustomChain) => chain is CustomChain;
|
|
26
|
+
export declare const isCustomEvmNetwork: (evmNetwork: EvmNetwork | CustomEvmNetwork | SimpleEvmNetwork) => evmNetwork is CustomEvmNetwork;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/** @dev temporarily change branch here when testing changes in chaindata */
|
|
4
|
+
const CHAINDATA_BRANCH = "main";
|
|
5
|
+
|
|
6
|
+
//
|
|
7
|
+
// GitHub repo constants
|
|
8
|
+
//
|
|
9
|
+
|
|
10
|
+
const githubApi = "https://api.github.com";
|
|
11
|
+
const githubCdn = "https://raw.githubusercontent.com";
|
|
12
|
+
const githubChaindataOrg = "TalismanSociety";
|
|
13
|
+
const githubChaindataRepo = "chaindata";
|
|
14
|
+
const githubChaindataBranch = CHAINDATA_BRANCH;
|
|
15
|
+
const githubChaindataDistDir = "pub/v2";
|
|
16
|
+
const githubChaindataBaseUrl = `${githubCdn}/${githubChaindataOrg}/${githubChaindataRepo}/${githubChaindataBranch}`;
|
|
17
|
+
const githubChaindataDistUrl = `${githubChaindataBaseUrl}/${githubChaindataDistDir}`;
|
|
18
|
+
const githubChaindataChainsAssetsDir = "assets/chains";
|
|
19
|
+
const githubChaindataTokensAssetsDir = "assets/tokens";
|
|
20
|
+
const githubChainLogoUrl = chainId => `${githubChaindataBaseUrl}/${githubChaindataChainsAssetsDir}/${chainId}.svg`;
|
|
21
|
+
const githubEvmNetworkLogoUrl = networkId => `${githubChaindataBaseUrl}/${githubChaindataChainsAssetsDir}/${networkId}.svg`;
|
|
22
|
+
const githubTokenLogoUrl = tokenId => `${githubChaindataBaseUrl}/${githubChaindataTokensAssetsDir}/${tokenId}.svg`;
|
|
23
|
+
const githubUnknownChainLogoUrl = githubChainLogoUrl("unknown");
|
|
24
|
+
const githubUnknownTokenLogoUrl = githubTokenLogoUrl("unknown");
|
|
25
|
+
|
|
26
|
+
//
|
|
27
|
+
// Chaindata published files (dist folder)
|
|
28
|
+
//
|
|
29
|
+
|
|
30
|
+
const chaindataChainsAllUrl = `${githubChaindataDistUrl}/chains/all.json`;
|
|
31
|
+
const chaindataChainsSummaryUrl = `${githubChaindataDistUrl}/chains/summary.json`;
|
|
32
|
+
const chaindataChainByIdUrl = chainId => `${githubChaindataDistUrl}/chains/byId/${chainId}.json`;
|
|
33
|
+
const chaindataChainByGenesisHashUrl = genesisHash => `${githubChaindataDistUrl}/chains/byGenesisHash/${genesisHash}.json`;
|
|
34
|
+
const chaindataEvmNetworksAllUrl = `${githubChaindataDistUrl}/evmNetworks/all.json`;
|
|
35
|
+
const chaindataEvmNetworksSummaryUrl = `${githubChaindataDistUrl}/evmNetworks/summary.json`;
|
|
36
|
+
const chaindataEvmNetworkByIdUrl = evmNetworkId => `${githubChaindataDistUrl}/evmNetworks/byId/${evmNetworkId}.json`;
|
|
37
|
+
const chaindataTokensAllUrl = `${githubChaindataDistUrl}/tokens/all.json`;
|
|
38
|
+
const chaindataTokenByIdUrl = tokenId => `${githubChaindataDistUrl}/tokens/byId/${tokenId}.json`;
|
|
39
|
+
const chaindataMiniMetadatasAllUrl = `${githubChaindataDistUrl}/miniMetadatas/all.json`;
|
|
40
|
+
|
|
41
|
+
const fetchChains = async () => await (await fetch(chaindataChainsAllUrl)).json();
|
|
42
|
+
const fetchChain = async chainId => await (await fetch(chaindataChainByIdUrl(chainId))).json();
|
|
43
|
+
const fetchEvmNetworks = async () => await (await fetch(chaindataEvmNetworksAllUrl)).json();
|
|
44
|
+
const fetchEvmNetwork = async evmNetworkId => await (await fetch(chaindataEvmNetworkByIdUrl(evmNetworkId))).json();
|
|
45
|
+
const fetchSubstrateTokens = async () => await (await fetch(chaindataTokensAllUrl)).json();
|
|
46
|
+
const fetchSubstrateToken = async tokenId => await (await fetch(chaindataTokenByIdUrl(tokenId))).json();
|
|
47
|
+
|
|
48
|
+
// TODO: Move `fetchMiniMetadatas` into `@talismn/balances`,
|
|
49
|
+
// so that we don't have a circular import between `@talismn/balances` and `@talismn/chaindata-provider`.
|
|
50
|
+
const fetchMiniMetadatas = async () => await (await fetch(chaindataMiniMetadatasAllUrl)).json();
|
|
51
|
+
const availableTokenLogoFilenames = async () => (await fetch(`${githubApi}/repos/${githubChaindataOrg}/${githubChaindataRepo}/contents/${githubChaindataTokensAssetsDir}`).then(response => response.json()))?.flatMap?.(entry => {
|
|
52
|
+
if (typeof entry !== "object" || entry === null) return [];
|
|
53
|
+
if (!("name" in entry) || typeof entry.name !== "string") return [];
|
|
54
|
+
return entry.name;
|
|
55
|
+
}) ?? [];
|
|
56
|
+
|
|
57
|
+
exports.availableTokenLogoFilenames = availableTokenLogoFilenames;
|
|
58
|
+
exports.chaindataChainByGenesisHashUrl = chaindataChainByGenesisHashUrl;
|
|
59
|
+
exports.chaindataChainByIdUrl = chaindataChainByIdUrl;
|
|
60
|
+
exports.chaindataChainsAllUrl = chaindataChainsAllUrl;
|
|
61
|
+
exports.chaindataChainsSummaryUrl = chaindataChainsSummaryUrl;
|
|
62
|
+
exports.chaindataEvmNetworkByIdUrl = chaindataEvmNetworkByIdUrl;
|
|
63
|
+
exports.chaindataEvmNetworksAllUrl = chaindataEvmNetworksAllUrl;
|
|
64
|
+
exports.chaindataEvmNetworksSummaryUrl = chaindataEvmNetworksSummaryUrl;
|
|
65
|
+
exports.chaindataMiniMetadatasAllUrl = chaindataMiniMetadatasAllUrl;
|
|
66
|
+
exports.chaindataTokenByIdUrl = chaindataTokenByIdUrl;
|
|
67
|
+
exports.chaindataTokensAllUrl = chaindataTokensAllUrl;
|
|
68
|
+
exports.fetchChain = fetchChain;
|
|
69
|
+
exports.fetchChains = fetchChains;
|
|
70
|
+
exports.fetchEvmNetwork = fetchEvmNetwork;
|
|
71
|
+
exports.fetchEvmNetworks = fetchEvmNetworks;
|
|
72
|
+
exports.fetchMiniMetadatas = fetchMiniMetadatas;
|
|
73
|
+
exports.fetchSubstrateToken = fetchSubstrateToken;
|
|
74
|
+
exports.fetchSubstrateTokens = fetchSubstrateTokens;
|
|
75
|
+
exports.githubApi = githubApi;
|
|
76
|
+
exports.githubCdn = githubCdn;
|
|
77
|
+
exports.githubChainLogoUrl = githubChainLogoUrl;
|
|
78
|
+
exports.githubChaindataBaseUrl = githubChaindataBaseUrl;
|
|
79
|
+
exports.githubChaindataBranch = githubChaindataBranch;
|
|
80
|
+
exports.githubChaindataChainsAssetsDir = githubChaindataChainsAssetsDir;
|
|
81
|
+
exports.githubChaindataDistDir = githubChaindataDistDir;
|
|
82
|
+
exports.githubChaindataDistUrl = githubChaindataDistUrl;
|
|
83
|
+
exports.githubChaindataOrg = githubChaindataOrg;
|
|
84
|
+
exports.githubChaindataRepo = githubChaindataRepo;
|
|
85
|
+
exports.githubChaindataTokensAssetsDir = githubChaindataTokensAssetsDir;
|
|
86
|
+
exports.githubEvmNetworkLogoUrl = githubEvmNetworkLogoUrl;
|
|
87
|
+
exports.githubTokenLogoUrl = githubTokenLogoUrl;
|
|
88
|
+
exports.githubUnknownChainLogoUrl = githubUnknownChainLogoUrl;
|
|
89
|
+
exports.githubUnknownTokenLogoUrl = githubUnknownTokenLogoUrl;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/** @dev temporarily change branch here when testing changes in chaindata */
|
|
4
|
+
const CHAINDATA_BRANCH = "main";
|
|
5
|
+
|
|
6
|
+
//
|
|
7
|
+
// GitHub repo constants
|
|
8
|
+
//
|
|
9
|
+
|
|
10
|
+
const githubApi = "https://api.github.com";
|
|
11
|
+
const githubCdn = "https://raw.githubusercontent.com";
|
|
12
|
+
const githubChaindataOrg = "TalismanSociety";
|
|
13
|
+
const githubChaindataRepo = "chaindata";
|
|
14
|
+
const githubChaindataBranch = CHAINDATA_BRANCH;
|
|
15
|
+
const githubChaindataDistDir = "pub/v2";
|
|
16
|
+
const githubChaindataBaseUrl = `${githubCdn}/${githubChaindataOrg}/${githubChaindataRepo}/${githubChaindataBranch}`;
|
|
17
|
+
const githubChaindataDistUrl = `${githubChaindataBaseUrl}/${githubChaindataDistDir}`;
|
|
18
|
+
const githubChaindataChainsAssetsDir = "assets/chains";
|
|
19
|
+
const githubChaindataTokensAssetsDir = "assets/tokens";
|
|
20
|
+
const githubChainLogoUrl = chainId => `${githubChaindataBaseUrl}/${githubChaindataChainsAssetsDir}/${chainId}.svg`;
|
|
21
|
+
const githubEvmNetworkLogoUrl = networkId => `${githubChaindataBaseUrl}/${githubChaindataChainsAssetsDir}/${networkId}.svg`;
|
|
22
|
+
const githubTokenLogoUrl = tokenId => `${githubChaindataBaseUrl}/${githubChaindataTokensAssetsDir}/${tokenId}.svg`;
|
|
23
|
+
const githubUnknownChainLogoUrl = githubChainLogoUrl("unknown");
|
|
24
|
+
const githubUnknownTokenLogoUrl = githubTokenLogoUrl("unknown");
|
|
25
|
+
|
|
26
|
+
//
|
|
27
|
+
// Chaindata published files (dist folder)
|
|
28
|
+
//
|
|
29
|
+
|
|
30
|
+
const chaindataChainsAllUrl = `${githubChaindataDistUrl}/chains/all.json`;
|
|
31
|
+
const chaindataChainsSummaryUrl = `${githubChaindataDistUrl}/chains/summary.json`;
|
|
32
|
+
const chaindataChainByIdUrl = chainId => `${githubChaindataDistUrl}/chains/byId/${chainId}.json`;
|
|
33
|
+
const chaindataChainByGenesisHashUrl = genesisHash => `${githubChaindataDistUrl}/chains/byGenesisHash/${genesisHash}.json`;
|
|
34
|
+
const chaindataEvmNetworksAllUrl = `${githubChaindataDistUrl}/evmNetworks/all.json`;
|
|
35
|
+
const chaindataEvmNetworksSummaryUrl = `${githubChaindataDistUrl}/evmNetworks/summary.json`;
|
|
36
|
+
const chaindataEvmNetworkByIdUrl = evmNetworkId => `${githubChaindataDistUrl}/evmNetworks/byId/${evmNetworkId}.json`;
|
|
37
|
+
const chaindataTokensAllUrl = `${githubChaindataDistUrl}/tokens/all.json`;
|
|
38
|
+
const chaindataTokenByIdUrl = tokenId => `${githubChaindataDistUrl}/tokens/byId/${tokenId}.json`;
|
|
39
|
+
const chaindataMiniMetadatasAllUrl = `${githubChaindataDistUrl}/miniMetadatas/all.json`;
|
|
40
|
+
|
|
41
|
+
const fetchChains = async () => await (await fetch(chaindataChainsAllUrl)).json();
|
|
42
|
+
const fetchChain = async chainId => await (await fetch(chaindataChainByIdUrl(chainId))).json();
|
|
43
|
+
const fetchEvmNetworks = async () => await (await fetch(chaindataEvmNetworksAllUrl)).json();
|
|
44
|
+
const fetchEvmNetwork = async evmNetworkId => await (await fetch(chaindataEvmNetworkByIdUrl(evmNetworkId))).json();
|
|
45
|
+
const fetchSubstrateTokens = async () => await (await fetch(chaindataTokensAllUrl)).json();
|
|
46
|
+
const fetchSubstrateToken = async tokenId => await (await fetch(chaindataTokenByIdUrl(tokenId))).json();
|
|
47
|
+
|
|
48
|
+
// TODO: Move `fetchMiniMetadatas` into `@talismn/balances`,
|
|
49
|
+
// so that we don't have a circular import between `@talismn/balances` and `@talismn/chaindata-provider`.
|
|
50
|
+
const fetchMiniMetadatas = async () => await (await fetch(chaindataMiniMetadatasAllUrl)).json();
|
|
51
|
+
const availableTokenLogoFilenames = async () => (await fetch(`${githubApi}/repos/${githubChaindataOrg}/${githubChaindataRepo}/contents/${githubChaindataTokensAssetsDir}`).then(response => response.json()))?.flatMap?.(entry => {
|
|
52
|
+
if (typeof entry !== "object" || entry === null) return [];
|
|
53
|
+
if (!("name" in entry) || typeof entry.name !== "string") return [];
|
|
54
|
+
return entry.name;
|
|
55
|
+
}) ?? [];
|
|
56
|
+
|
|
57
|
+
exports.availableTokenLogoFilenames = availableTokenLogoFilenames;
|
|
58
|
+
exports.chaindataChainByGenesisHashUrl = chaindataChainByGenesisHashUrl;
|
|
59
|
+
exports.chaindataChainByIdUrl = chaindataChainByIdUrl;
|
|
60
|
+
exports.chaindataChainsAllUrl = chaindataChainsAllUrl;
|
|
61
|
+
exports.chaindataChainsSummaryUrl = chaindataChainsSummaryUrl;
|
|
62
|
+
exports.chaindataEvmNetworkByIdUrl = chaindataEvmNetworkByIdUrl;
|
|
63
|
+
exports.chaindataEvmNetworksAllUrl = chaindataEvmNetworksAllUrl;
|
|
64
|
+
exports.chaindataEvmNetworksSummaryUrl = chaindataEvmNetworksSummaryUrl;
|
|
65
|
+
exports.chaindataMiniMetadatasAllUrl = chaindataMiniMetadatasAllUrl;
|
|
66
|
+
exports.chaindataTokenByIdUrl = chaindataTokenByIdUrl;
|
|
67
|
+
exports.chaindataTokensAllUrl = chaindataTokensAllUrl;
|
|
68
|
+
exports.fetchChain = fetchChain;
|
|
69
|
+
exports.fetchChains = fetchChains;
|
|
70
|
+
exports.fetchEvmNetwork = fetchEvmNetwork;
|
|
71
|
+
exports.fetchEvmNetworks = fetchEvmNetworks;
|
|
72
|
+
exports.fetchMiniMetadatas = fetchMiniMetadatas;
|
|
73
|
+
exports.fetchSubstrateToken = fetchSubstrateToken;
|
|
74
|
+
exports.fetchSubstrateTokens = fetchSubstrateTokens;
|
|
75
|
+
exports.githubApi = githubApi;
|
|
76
|
+
exports.githubCdn = githubCdn;
|
|
77
|
+
exports.githubChainLogoUrl = githubChainLogoUrl;
|
|
78
|
+
exports.githubChaindataBaseUrl = githubChaindataBaseUrl;
|
|
79
|
+
exports.githubChaindataBranch = githubChaindataBranch;
|
|
80
|
+
exports.githubChaindataChainsAssetsDir = githubChaindataChainsAssetsDir;
|
|
81
|
+
exports.githubChaindataDistDir = githubChaindataDistDir;
|
|
82
|
+
exports.githubChaindataDistUrl = githubChaindataDistUrl;
|
|
83
|
+
exports.githubChaindataOrg = githubChaindataOrg;
|
|
84
|
+
exports.githubChaindataRepo = githubChaindataRepo;
|
|
85
|
+
exports.githubChaindataTokensAssetsDir = githubChaindataTokensAssetsDir;
|
|
86
|
+
exports.githubEvmNetworkLogoUrl = githubEvmNetworkLogoUrl;
|
|
87
|
+
exports.githubTokenLogoUrl = githubTokenLogoUrl;
|
|
88
|
+
exports.githubUnknownChainLogoUrl = githubUnknownChainLogoUrl;
|
|
89
|
+
exports.githubUnknownTokenLogoUrl = githubUnknownTokenLogoUrl;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** @dev temporarily change branch here when testing changes in chaindata */
|
|
2
|
+
const CHAINDATA_BRANCH = "main";
|
|
3
|
+
|
|
4
|
+
//
|
|
5
|
+
// GitHub repo constants
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
const githubApi = "https://api.github.com";
|
|
9
|
+
const githubCdn = "https://raw.githubusercontent.com";
|
|
10
|
+
const githubChaindataOrg = "TalismanSociety";
|
|
11
|
+
const githubChaindataRepo = "chaindata";
|
|
12
|
+
const githubChaindataBranch = CHAINDATA_BRANCH;
|
|
13
|
+
const githubChaindataDistDir = "pub/v2";
|
|
14
|
+
const githubChaindataBaseUrl = `${githubCdn}/${githubChaindataOrg}/${githubChaindataRepo}/${githubChaindataBranch}`;
|
|
15
|
+
const githubChaindataDistUrl = `${githubChaindataBaseUrl}/${githubChaindataDistDir}`;
|
|
16
|
+
const githubChaindataChainsAssetsDir = "assets/chains";
|
|
17
|
+
const githubChaindataTokensAssetsDir = "assets/tokens";
|
|
18
|
+
const githubChainLogoUrl = chainId => `${githubChaindataBaseUrl}/${githubChaindataChainsAssetsDir}/${chainId}.svg`;
|
|
19
|
+
const githubEvmNetworkLogoUrl = networkId => `${githubChaindataBaseUrl}/${githubChaindataChainsAssetsDir}/${networkId}.svg`;
|
|
20
|
+
const githubTokenLogoUrl = tokenId => `${githubChaindataBaseUrl}/${githubChaindataTokensAssetsDir}/${tokenId}.svg`;
|
|
21
|
+
const githubUnknownChainLogoUrl = githubChainLogoUrl("unknown");
|
|
22
|
+
const githubUnknownTokenLogoUrl = githubTokenLogoUrl("unknown");
|
|
23
|
+
|
|
24
|
+
//
|
|
25
|
+
// Chaindata published files (dist folder)
|
|
26
|
+
//
|
|
27
|
+
|
|
28
|
+
const chaindataChainsAllUrl = `${githubChaindataDistUrl}/chains/all.json`;
|
|
29
|
+
const chaindataChainsSummaryUrl = `${githubChaindataDistUrl}/chains/summary.json`;
|
|
30
|
+
const chaindataChainByIdUrl = chainId => `${githubChaindataDistUrl}/chains/byId/${chainId}.json`;
|
|
31
|
+
const chaindataChainByGenesisHashUrl = genesisHash => `${githubChaindataDistUrl}/chains/byGenesisHash/${genesisHash}.json`;
|
|
32
|
+
const chaindataEvmNetworksAllUrl = `${githubChaindataDistUrl}/evmNetworks/all.json`;
|
|
33
|
+
const chaindataEvmNetworksSummaryUrl = `${githubChaindataDistUrl}/evmNetworks/summary.json`;
|
|
34
|
+
const chaindataEvmNetworkByIdUrl = evmNetworkId => `${githubChaindataDistUrl}/evmNetworks/byId/${evmNetworkId}.json`;
|
|
35
|
+
const chaindataTokensAllUrl = `${githubChaindataDistUrl}/tokens/all.json`;
|
|
36
|
+
const chaindataTokenByIdUrl = tokenId => `${githubChaindataDistUrl}/tokens/byId/${tokenId}.json`;
|
|
37
|
+
const chaindataMiniMetadatasAllUrl = `${githubChaindataDistUrl}/miniMetadatas/all.json`;
|
|
38
|
+
|
|
39
|
+
const fetchChains = async () => await (await fetch(chaindataChainsAllUrl)).json();
|
|
40
|
+
const fetchChain = async chainId => await (await fetch(chaindataChainByIdUrl(chainId))).json();
|
|
41
|
+
const fetchEvmNetworks = async () => await (await fetch(chaindataEvmNetworksAllUrl)).json();
|
|
42
|
+
const fetchEvmNetwork = async evmNetworkId => await (await fetch(chaindataEvmNetworkByIdUrl(evmNetworkId))).json();
|
|
43
|
+
const fetchSubstrateTokens = async () => await (await fetch(chaindataTokensAllUrl)).json();
|
|
44
|
+
const fetchSubstrateToken = async tokenId => await (await fetch(chaindataTokenByIdUrl(tokenId))).json();
|
|
45
|
+
|
|
46
|
+
// TODO: Move `fetchMiniMetadatas` into `@talismn/balances`,
|
|
47
|
+
// so that we don't have a circular import between `@talismn/balances` and `@talismn/chaindata-provider`.
|
|
48
|
+
const fetchMiniMetadatas = async () => await (await fetch(chaindataMiniMetadatasAllUrl)).json();
|
|
49
|
+
const availableTokenLogoFilenames = async () => (await fetch(`${githubApi}/repos/${githubChaindataOrg}/${githubChaindataRepo}/contents/${githubChaindataTokensAssetsDir}`).then(response => response.json()))?.flatMap?.(entry => {
|
|
50
|
+
if (typeof entry !== "object" || entry === null) return [];
|
|
51
|
+
if (!("name" in entry) || typeof entry.name !== "string") return [];
|
|
52
|
+
return entry.name;
|
|
53
|
+
}) ?? [];
|
|
54
|
+
|
|
55
|
+
export { chaindataEvmNetworksSummaryUrl as A, chaindataEvmNetworkByIdUrl as B, chaindataTokensAllUrl as C, chaindataTokenByIdUrl as D, chaindataMiniMetadatasAllUrl as E, fetchMiniMetadatas as F, availableTokenLogoFilenames as G, fetchSubstrateToken as a, fetchEvmNetwork as b, fetchChains as c, fetchEvmNetworks as d, githubUnknownTokenLogoUrl as e, fetchChain as f, githubTokenLogoUrl as g, fetchSubstrateTokens as h, githubApi as i, githubCdn as j, githubChaindataOrg as k, githubChaindataRepo as l, githubChaindataBranch as m, githubChaindataDistDir as n, githubChaindataBaseUrl as o, githubChaindataDistUrl as p, githubChaindataChainsAssetsDir as q, githubChaindataTokensAssetsDir as r, githubChainLogoUrl as s, githubEvmNetworkLogoUrl as t, githubUnknownChainLogoUrl as u, chaindataChainsAllUrl as v, chaindataChainsSummaryUrl as w, chaindataChainByIdUrl as x, chaindataChainByGenesisHashUrl as y, chaindataEvmNetworksAllUrl as z };
|