@talismn/chaindata-provider 0.0.0-pr472-20230201082459
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/CHANGELOG.md +69 -0
- package/README.md +1 -0
- package/dist/declarations/src/ChaindataProvider.d.ts +18 -0
- package/dist/declarations/src/github.d.ts +11 -0
- package/dist/declarations/src/index.d.ts +3 -0
- package/dist/declarations/src/plugins.d.ts +20 -0
- package/dist/declarations/src/types/Chain.d.ts +44 -0
- package/dist/declarations/src/types/EvmNetwork.d.ts +32 -0
- package/dist/declarations/src/types/MultiChain.d.ts +9 -0
- package/dist/declarations/src/types/Token.d.ts +49 -0
- package/dist/declarations/src/types/index.d.ts +4 -0
- package/dist/talismn-chaindata-provider.cjs.d.ts +1 -0
- package/dist/talismn-chaindata-provider.cjs.dev.js +25 -0
- package/dist/talismn-chaindata-provider.cjs.js +7 -0
- package/dist/talismn-chaindata-provider.cjs.prod.js +25 -0
- package/dist/talismn-chaindata-provider.esm.js +12 -0
- package/package.json +50 -0
- package/plugins/dist/talismn-chaindata-provider-plugins.cjs.d.ts +1 -0
- package/plugins/dist/talismn-chaindata-provider-plugins.cjs.dev.js +2 -0
- package/plugins/dist/talismn-chaindata-provider-plugins.cjs.js +7 -0
- package/plugins/dist/talismn-chaindata-provider-plugins.cjs.prod.js +2 -0
- package/plugins/dist/talismn-chaindata-provider-plugins.esm.js +1 -0
- package/plugins/package.json +5 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# @talismn/chaindata-provider
|
|
2
|
+
|
|
3
|
+
## 0.0.0-pr472-20230201082459
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c0da9a1: feat: switched build tool to preconstruct
|
|
8
|
+
|
|
9
|
+
## 0.2.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 4aa691d: feat: new balance modules
|
|
14
|
+
|
|
15
|
+
## 0.2.0
|
|
16
|
+
|
|
17
|
+
## 0.1.10
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- fix: a variety of improvements from the wallet integration
|
|
22
|
+
|
|
23
|
+
## 0.1.9
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- 8ecb8214: fix: get token logo urls from chaindata-provider
|
|
28
|
+
|
|
29
|
+
## 0.1.8
|
|
30
|
+
|
|
31
|
+
## 0.1.7
|
|
32
|
+
|
|
33
|
+
## 0.1.6
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- ca50757: feat: implemented token fiat rates in @talismn/balances
|
|
38
|
+
|
|
39
|
+
## 0.1.5
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- d66c5bc: fix: evm native tokens
|
|
44
|
+
|
|
45
|
+
## 0.1.4
|
|
46
|
+
|
|
47
|
+
## 0.1.3
|
|
48
|
+
|
|
49
|
+
### Patch Changes
|
|
50
|
+
|
|
51
|
+
- d5f69f7: fix: migrated orml token code into substrate orml module
|
|
52
|
+
|
|
53
|
+
## 0.1.2
|
|
54
|
+
|
|
55
|
+
### Patch Changes
|
|
56
|
+
|
|
57
|
+
- 5af305c: switched build output from esm to commonjs for ecosystem compatibility
|
|
58
|
+
|
|
59
|
+
## 0.1.1
|
|
60
|
+
|
|
61
|
+
### Patch Changes
|
|
62
|
+
|
|
63
|
+
- Fixed publish config
|
|
64
|
+
|
|
65
|
+
## 0.1.0
|
|
66
|
+
|
|
67
|
+
### Minor Changes
|
|
68
|
+
|
|
69
|
+
- 43c1a3a: Initial release
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @talismn/chaindata-provider
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Chain, ChainId, ChainList, CustomChain, CustomEvmNetwork, EvmNetwork, EvmNetworkId, EvmNetworkList, Token, TokenId, TokenList } from "./types";
|
|
2
|
+
export interface ChaindataChainProvider {
|
|
3
|
+
chainIds(): Promise<ChainId[]>;
|
|
4
|
+
chains(): Promise<ChainList>;
|
|
5
|
+
getChain(chainIdOrQuery: ChainId | Partial<Chain>): Promise<Chain | CustomChain | null>;
|
|
6
|
+
}
|
|
7
|
+
export interface ChaindataEvmNetworkProvider {
|
|
8
|
+
evmNetworkIds(): Promise<EvmNetworkId[]>;
|
|
9
|
+
evmNetworks(): Promise<EvmNetworkList>;
|
|
10
|
+
getEvmNetwork(evmNetworkIdOrQuery: EvmNetworkId | Partial<EvmNetwork>): Promise<EvmNetwork | CustomEvmNetwork | null>;
|
|
11
|
+
}
|
|
12
|
+
export interface ChaindataTokenProvider {
|
|
13
|
+
tokenIds(): Promise<TokenId[]>;
|
|
14
|
+
tokens(): Promise<TokenList>;
|
|
15
|
+
getToken(tokenIdOrQuery: TokenId | Partial<Token>): Promise<Token | null>;
|
|
16
|
+
}
|
|
17
|
+
export interface ChaindataProvider extends ChaindataChainProvider, ChaindataEvmNetworkProvider, ChaindataTokenProvider {
|
|
18
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ChainId, EvmNetworkId, TokenId } from "./types";
|
|
2
|
+
export declare const githubChaindataBranch = "v3";
|
|
3
|
+
export declare const githubChaindataBaseUrl: string;
|
|
4
|
+
export declare const githubChainsUrl: string;
|
|
5
|
+
export declare const githubTestnetChainsUrl: string;
|
|
6
|
+
export declare const githubEvmNetworksUrl: string;
|
|
7
|
+
export declare const githubTokensUrl: string;
|
|
8
|
+
export declare const githubChainLogoUrl: (chainId: ChainId) => string;
|
|
9
|
+
export declare const githubEvmNetworkLogoUrl: (networkId: EvmNetworkId) => string;
|
|
10
|
+
export declare const githubTokenLogoUrl: (tokenId: TokenId) => string;
|
|
11
|
+
export declare const githubUnknownTokenLogoUrl: string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `PluginTokenTypes` is a collection of plugin-provided token definitions.
|
|
3
|
+
*
|
|
4
|
+
* By hacking declaration merging (typescript magic) we can add variants to this type from within other modules.
|
|
5
|
+
*
|
|
6
|
+
* For more details on this process, see:
|
|
7
|
+
* - https://www.typescriptlang.org/docs/handbook/declaration-merging.html
|
|
8
|
+
* - https://stackoverflow.com/a/58261244/3926156
|
|
9
|
+
* - https://stackoverflow.com/a/56099769/3926156
|
|
10
|
+
* - https://stackoverflow.com/a/56516998/3926156
|
|
11
|
+
* - https://pqina.nl/blog/typescript-interface-merging-and-extending-modules/
|
|
12
|
+
*
|
|
13
|
+
* As a result, consumers of this api will have type information for the `Token` type
|
|
14
|
+
* based on the selection of plugins they are using in their app.
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
17
|
+
declare global {
|
|
18
|
+
export interface TalismanPluginTokenTypes {
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { EvmNetworkId } from "./EvmNetwork";
|
|
2
|
+
import { TokenId } from "./Token";
|
|
3
|
+
export type ChainList = Record<ChainId, Chain | CustomChain>;
|
|
4
|
+
export type ChainId = string;
|
|
5
|
+
export type Chain = {
|
|
6
|
+
id: ChainId;
|
|
7
|
+
isTestnet: boolean;
|
|
8
|
+
sortIndex: number | null;
|
|
9
|
+
genesisHash: string | null;
|
|
10
|
+
prefix: number | null;
|
|
11
|
+
name: string | null;
|
|
12
|
+
logo: string | null;
|
|
13
|
+
chainName: string;
|
|
14
|
+
implName: string | null;
|
|
15
|
+
specName: string | null;
|
|
16
|
+
specVersion: string | null;
|
|
17
|
+
nativeToken: {
|
|
18
|
+
id: TokenId;
|
|
19
|
+
} | null;
|
|
20
|
+
tokens: Array<{
|
|
21
|
+
id: TokenId;
|
|
22
|
+
}> | null;
|
|
23
|
+
account: string | null;
|
|
24
|
+
subscanUrl: string | null;
|
|
25
|
+
rpcs: Array<SubstrateRpc> | null;
|
|
26
|
+
isHealthy: boolean;
|
|
27
|
+
evmNetworks: Array<{
|
|
28
|
+
id: EvmNetworkId;
|
|
29
|
+
}>;
|
|
30
|
+
parathreads?: Chain[];
|
|
31
|
+
paraId: number | null;
|
|
32
|
+
relay?: Chain;
|
|
33
|
+
balanceMetadata: Array<{
|
|
34
|
+
moduleType: string;
|
|
35
|
+
metadata: any;
|
|
36
|
+
}>;
|
|
37
|
+
};
|
|
38
|
+
export type CustomChain = Chain & {
|
|
39
|
+
isCustom: true;
|
|
40
|
+
};
|
|
41
|
+
export type SubstrateRpc = {
|
|
42
|
+
url: string;
|
|
43
|
+
isHealthy: boolean;
|
|
44
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ChainId } from "./Chain";
|
|
2
|
+
import { TokenId } from "./Token";
|
|
3
|
+
export type EvmNetworkList = Record<EvmNetworkId, EvmNetwork | CustomEvmNetwork>;
|
|
4
|
+
export type EvmNetworkId = string;
|
|
5
|
+
export type EvmNetwork = {
|
|
6
|
+
id: EvmNetworkId;
|
|
7
|
+
isTestnet: boolean;
|
|
8
|
+
sortIndex: number | null;
|
|
9
|
+
name: string | null;
|
|
10
|
+
logo: string | null;
|
|
11
|
+
nativeToken: {
|
|
12
|
+
id: TokenId;
|
|
13
|
+
} | null;
|
|
14
|
+
tokens: Array<{
|
|
15
|
+
id: TokenId;
|
|
16
|
+
}> | null;
|
|
17
|
+
explorerUrl: string | null;
|
|
18
|
+
rpcs: Array<EthereumRpc> | null;
|
|
19
|
+
isHealthy: boolean;
|
|
20
|
+
substrateChain: {
|
|
21
|
+
id: ChainId;
|
|
22
|
+
} | null;
|
|
23
|
+
};
|
|
24
|
+
export type CustomEvmNetwork = EvmNetwork & {
|
|
25
|
+
isCustom: true;
|
|
26
|
+
explorerUrls: string[];
|
|
27
|
+
iconUrls: string[];
|
|
28
|
+
};
|
|
29
|
+
export type EthereumRpc = {
|
|
30
|
+
url: string;
|
|
31
|
+
isHealthy: boolean;
|
|
32
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ChainId } from "./Chain";
|
|
2
|
+
import { EvmNetworkId } from "./EvmNetwork";
|
|
3
|
+
declare global {
|
|
4
|
+
export interface TalismanPluginTokenTypes {
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* `TokenTypes` is an automatically determined sub-selection of `PluginTokenTypes`.
|
|
9
|
+
*
|
|
10
|
+
* It is the same list, but with any invalid `TokenType` definitions filtered out.
|
|
11
|
+
*/
|
|
12
|
+
export type TokenTypes = {
|
|
13
|
+
[TokenType in keyof TalismanPluginTokenTypes]: TalismanPluginTokenTypes[TokenType] extends IToken ? TalismanPluginTokenTypes[TokenType] : never;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* The `Token` sum type, which is a union of all of the possible `TokenTypes`.
|
|
17
|
+
*
|
|
18
|
+
* Each variant comes from a plugin in use by the consuming app.
|
|
19
|
+
*
|
|
20
|
+
* For example, in an app with the `substrate-native`, `evm-native`, `substrate-orml` and `evm-erc20` plugins:
|
|
21
|
+
*
|
|
22
|
+
* type Token = SubNativeToken | EvmNativeToken | SubOrmlToken | EvmErc20Token
|
|
23
|
+
*
|
|
24
|
+
* If `TokenTypes` is empty then `Token` will fall back to the common `IToken` interface, which every token must implement.
|
|
25
|
+
*/
|
|
26
|
+
export type Token = TokenTypes[keyof TokenTypes] extends never ? IToken : TokenTypes[keyof TokenTypes];
|
|
27
|
+
/** A collection of `Token` objects */
|
|
28
|
+
export type TokenList = Record<TokenId, Token>;
|
|
29
|
+
export type TokenId = string;
|
|
30
|
+
/** `IToken` is a common interface which all tokens must implement. */
|
|
31
|
+
export type IToken = {
|
|
32
|
+
id: TokenId;
|
|
33
|
+
type: string;
|
|
34
|
+
isTestnet: boolean;
|
|
35
|
+
symbol: string;
|
|
36
|
+
decimals: number;
|
|
37
|
+
logo: string;
|
|
38
|
+
coingeckoId?: string;
|
|
39
|
+
chain?: {
|
|
40
|
+
id: ChainId;
|
|
41
|
+
} | null;
|
|
42
|
+
evmNetwork?: {
|
|
43
|
+
id: EvmNetworkId;
|
|
44
|
+
} | null;
|
|
45
|
+
};
|
|
46
|
+
/** Used by plugins to help define their custom `TokenType` */
|
|
47
|
+
export type NewTokenType<ModuleType extends string, TokenParams extends Record<string, unknown>> = IToken & {
|
|
48
|
+
type: ModuleType;
|
|
49
|
+
} & TokenParams;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./declarations/src/index";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const githubChaindataBranch = "v3";
|
|
6
|
+
const githubChaindataBaseUrl = `https://raw.githubusercontent.com/TalismanSociety/chaindata/${githubChaindataBranch}`;
|
|
7
|
+
const githubChainsUrl = `${githubChaindataBaseUrl}/chaindata.json`;
|
|
8
|
+
const githubTestnetChainsUrl = `${githubChaindataBaseUrl}/testnets-chaindata.json`;
|
|
9
|
+
const githubEvmNetworksUrl = `${githubChaindataBaseUrl}/evm-networks.json`;
|
|
10
|
+
const githubTokensUrl = `${githubChaindataBaseUrl}/tokens.json`;
|
|
11
|
+
const githubChainLogoUrl = chainId => `${githubChaindataBaseUrl}/assets/chains/${chainId}.svg`;
|
|
12
|
+
const githubEvmNetworkLogoUrl = networkId => `${githubChaindataBaseUrl}/assets/chains/${networkId}.svg`;
|
|
13
|
+
const githubTokenLogoUrl = tokenId => `${githubChaindataBaseUrl}/assets/tokens/${tokenId}.svg`;
|
|
14
|
+
const githubUnknownTokenLogoUrl = githubTokenLogoUrl("unknown");
|
|
15
|
+
|
|
16
|
+
exports.githubChainLogoUrl = githubChainLogoUrl;
|
|
17
|
+
exports.githubChaindataBaseUrl = githubChaindataBaseUrl;
|
|
18
|
+
exports.githubChaindataBranch = githubChaindataBranch;
|
|
19
|
+
exports.githubChainsUrl = githubChainsUrl;
|
|
20
|
+
exports.githubEvmNetworkLogoUrl = githubEvmNetworkLogoUrl;
|
|
21
|
+
exports.githubEvmNetworksUrl = githubEvmNetworksUrl;
|
|
22
|
+
exports.githubTestnetChainsUrl = githubTestnetChainsUrl;
|
|
23
|
+
exports.githubTokenLogoUrl = githubTokenLogoUrl;
|
|
24
|
+
exports.githubTokensUrl = githubTokensUrl;
|
|
25
|
+
exports.githubUnknownTokenLogoUrl = githubUnknownTokenLogoUrl;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const githubChaindataBranch = "v3";
|
|
6
|
+
const githubChaindataBaseUrl = `https://raw.githubusercontent.com/TalismanSociety/chaindata/${githubChaindataBranch}`;
|
|
7
|
+
const githubChainsUrl = `${githubChaindataBaseUrl}/chaindata.json`;
|
|
8
|
+
const githubTestnetChainsUrl = `${githubChaindataBaseUrl}/testnets-chaindata.json`;
|
|
9
|
+
const githubEvmNetworksUrl = `${githubChaindataBaseUrl}/evm-networks.json`;
|
|
10
|
+
const githubTokensUrl = `${githubChaindataBaseUrl}/tokens.json`;
|
|
11
|
+
const githubChainLogoUrl = chainId => `${githubChaindataBaseUrl}/assets/chains/${chainId}.svg`;
|
|
12
|
+
const githubEvmNetworkLogoUrl = networkId => `${githubChaindataBaseUrl}/assets/chains/${networkId}.svg`;
|
|
13
|
+
const githubTokenLogoUrl = tokenId => `${githubChaindataBaseUrl}/assets/tokens/${tokenId}.svg`;
|
|
14
|
+
const githubUnknownTokenLogoUrl = githubTokenLogoUrl("unknown");
|
|
15
|
+
|
|
16
|
+
exports.githubChainLogoUrl = githubChainLogoUrl;
|
|
17
|
+
exports.githubChaindataBaseUrl = githubChaindataBaseUrl;
|
|
18
|
+
exports.githubChaindataBranch = githubChaindataBranch;
|
|
19
|
+
exports.githubChainsUrl = githubChainsUrl;
|
|
20
|
+
exports.githubEvmNetworkLogoUrl = githubEvmNetworkLogoUrl;
|
|
21
|
+
exports.githubEvmNetworksUrl = githubEvmNetworksUrl;
|
|
22
|
+
exports.githubTestnetChainsUrl = githubTestnetChainsUrl;
|
|
23
|
+
exports.githubTokenLogoUrl = githubTokenLogoUrl;
|
|
24
|
+
exports.githubTokensUrl = githubTokensUrl;
|
|
25
|
+
exports.githubUnknownTokenLogoUrl = githubUnknownTokenLogoUrl;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const githubChaindataBranch = "v3";
|
|
2
|
+
const githubChaindataBaseUrl = `https://raw.githubusercontent.com/TalismanSociety/chaindata/${githubChaindataBranch}`;
|
|
3
|
+
const githubChainsUrl = `${githubChaindataBaseUrl}/chaindata.json`;
|
|
4
|
+
const githubTestnetChainsUrl = `${githubChaindataBaseUrl}/testnets-chaindata.json`;
|
|
5
|
+
const githubEvmNetworksUrl = `${githubChaindataBaseUrl}/evm-networks.json`;
|
|
6
|
+
const githubTokensUrl = `${githubChaindataBaseUrl}/tokens.json`;
|
|
7
|
+
const githubChainLogoUrl = chainId => `${githubChaindataBaseUrl}/assets/chains/${chainId}.svg`;
|
|
8
|
+
const githubEvmNetworkLogoUrl = networkId => `${githubChaindataBaseUrl}/assets/chains/${networkId}.svg`;
|
|
9
|
+
const githubTokenLogoUrl = tokenId => `${githubChaindataBaseUrl}/assets/tokens/${tokenId}.svg`;
|
|
10
|
+
const githubUnknownTokenLogoUrl = githubTokenLogoUrl("unknown");
|
|
11
|
+
|
|
12
|
+
export { githubChainLogoUrl, githubChaindataBaseUrl, githubChaindataBranch, githubChainsUrl, githubEvmNetworkLogoUrl, githubEvmNetworksUrl, githubTestnetChainsUrl, githubTokenLogoUrl, githubTokensUrl, githubUnknownTokenLogoUrl };
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@talismn/chaindata-provider",
|
|
3
|
+
"version": "0.0.0-pr472-20230201082459",
|
|
4
|
+
"author": "Talisman",
|
|
5
|
+
"homepage": "https://talisman.xyz",
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"directory": "packages/chaindata-provider",
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/talismansociety/talisman.git"
|
|
14
|
+
},
|
|
15
|
+
"main": "dist/talismn-chaindata-provider.cjs.js",
|
|
16
|
+
"module": "dist/talismn-chaindata-provider.esm.js",
|
|
17
|
+
"files": [
|
|
18
|
+
"/dist",
|
|
19
|
+
"/plugins"
|
|
20
|
+
],
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=14"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"test": "jest",
|
|
26
|
+
"lint": "eslint . --max-warnings 0",
|
|
27
|
+
"clean": "rm -rf dist && rm -rf .turbo rm -rf node_modules"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@talismn/eslint-config": "^0.0.0-pr472-20230201082459",
|
|
31
|
+
"@talismn/tsconfig": "^0.0.0-pr472-20230201082459",
|
|
32
|
+
"@types/jest": "^27.5.1",
|
|
33
|
+
"eslint": "^8.4.0",
|
|
34
|
+
"jest": "^28.1.0",
|
|
35
|
+
"ts-jest": "^28.0.2",
|
|
36
|
+
"typescript": "^4.6.4"
|
|
37
|
+
},
|
|
38
|
+
"preconstruct": {
|
|
39
|
+
"entrypoints": [
|
|
40
|
+
"index.ts",
|
|
41
|
+
"plugins.ts"
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
"eslintConfig": {
|
|
45
|
+
"root": true,
|
|
46
|
+
"extends": [
|
|
47
|
+
"@talismn/eslint-config/base"
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../dist/declarations/src/plugins";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|