@talismn/balances 0.6.1 → 0.7.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/README.md +1 -5
- package/dist/declarations/src/BalanceModule.d.ts +25 -15
- package/dist/declarations/src/EvmTokenFetcher.d.ts +11 -0
- package/dist/declarations/src/MiniMetadataUpdater.d.ts +5 -6
- package/dist/declarations/src/TalismanBalancesDatabase.d.ts +5 -2
- package/dist/declarations/src/index.d.ts +2 -0
- package/dist/declarations/src/modules/EvmErc20Module.d.ts +13 -23
- package/dist/declarations/src/modules/EvmNativeModule.d.ts +10 -21
- package/dist/declarations/src/modules/EvmUniswapV2Module.d.ts +39 -0
- package/dist/declarations/src/modules/SubstrateAssetsModule.d.ts +11 -24
- package/dist/declarations/src/modules/SubstrateEquilibriumModule.d.ts +11 -22
- package/dist/declarations/src/modules/SubstrateForeignAssetsModule.d.ts +38 -0
- package/dist/declarations/src/modules/SubstrateNativeModule/index.d.ts +7 -0
- package/dist/declarations/src/modules/SubstrateNativeModule/subscribeBase.d.ts +5 -0
- package/dist/declarations/src/modules/SubstrateNativeModule/subscribeCrowdloans.d.ts +5 -0
- package/dist/declarations/src/modules/SubstrateNativeModule/subscribeNompoolStaking.d.ts +5 -0
- package/dist/declarations/src/modules/SubstrateNativeModule/subscribeSubtensorStaking.d.ts +5 -0
- package/dist/declarations/src/modules/SubstrateNativeModule/types.d.ts +49 -0
- package/dist/declarations/src/modules/SubstrateNativeModule/util/QueryCache.d.ts +13 -0
- package/dist/declarations/src/modules/SubstrateNativeModule/util/SubNativeBalanceError.d.ts +5 -0
- package/dist/declarations/src/modules/SubstrateNativeModule/util/asObservable.d.ts +10 -0
- package/dist/declarations/src/modules/SubstrateNativeModule/util/balanceLockTypes.d.ts +15 -0
- package/dist/declarations/src/modules/SubstrateNativeModule/util/buildQueries.d.ts +13 -0
- package/dist/declarations/src/modules/SubstrateNativeModule/util/crowdloanFundContributionsChildKey.d.ts +4 -0
- package/dist/declarations/src/modules/SubstrateNativeModule/util/detectMiniMetadataChanges.d.ts +2 -0
- package/dist/declarations/src/modules/SubstrateNativeModule/util/mergeBalances.d.ts +13 -0
- package/dist/declarations/src/modules/SubstrateNativeModule/util/nompoolAccountId.d.ts +5 -0
- package/dist/declarations/src/modules/SubstrateNativeModule/util/sortChains.d.ts +1 -0
- package/dist/declarations/src/modules/SubstrateNativeModule/util/subtensor.d.ts +55 -0
- package/dist/declarations/src/modules/SubstratePsp22Module.d.ts +9 -20
- package/dist/declarations/src/modules/SubstrateTokensModule.d.ts +13 -24
- package/dist/declarations/src/modules/abis/erc20BalancesAggregator.d.ts +19 -0
- package/dist/declarations/src/modules/abis/uniswapV2Pair.d.ts +560 -0
- package/dist/declarations/src/modules/index.d.ts +52 -2
- package/dist/declarations/src/modules/util/InferBalanceModuleTypes.d.ts +28 -0
- package/dist/declarations/src/modules/util/RpcStateQueryHelper.d.ts +19 -0
- package/dist/declarations/src/modules/util/balances.d.ts +8 -0
- package/dist/declarations/src/modules/util/buildStorageCoders.d.ts +26 -0
- package/dist/declarations/src/modules/util/decodeOutput.d.ts +13 -0
- package/dist/declarations/src/modules/util/detectTransferMethod.d.ts +11 -0
- package/dist/declarations/src/modules/util/findChainMeta.d.ts +8 -0
- package/dist/declarations/src/modules/util/getUniqueChainIds.d.ts +5 -0
- package/dist/declarations/src/modules/util/index.d.ts +10 -113
- package/dist/declarations/src/modules/util/makeContractCaller.d.ts +9 -0
- package/dist/declarations/src/modules/util/storageCompression.d.ts +9 -0
- package/dist/declarations/src/types/balances.d.ts +172 -22
- package/dist/declarations/src/types/balancetypes.d.ts +44 -33
- package/dist/declarations/src/upgrades/2024-01-25-upgradeRemoveSymbolFromNativeTokenId.d.ts +2 -0
- package/dist/declarations/src/upgrades/2024-03-19-upgradeBalancesDataBlob.d.ts +2 -0
- package/dist/declarations/src/upgrades/index.d.ts +2 -0
- package/dist/declarations/src/util/hydrateChaindata.d.ts +8 -0
- package/dist/declarations/src/util/index.d.ts +1 -0
- package/dist/talismn-balances.cjs.dev.js +4259 -1982
- package/dist/talismn-balances.cjs.prod.js +4259 -1982
- package/dist/talismn-balances.esm.js +4235 -1949
- package/package.json +38 -34
- package/CHANGELOG.md +0 -335
- package/dist/declarations/src/modules/SubstrateNativeModule.d.ts +0 -65
- package/dist/declarations/src/modules/util/substrate-native.d.ts +0 -33
package/README.md
CHANGED
@@ -5,7 +5,6 @@
|
|
5
5
|
[](https://github.com/TalismanSociety/talisman/blob/dev/LICENSE)
|
6
6
|
[](https://www.npmjs.com/package/@talismn/balances)
|
7
7
|
[](https://www.npmjs.com/package/@talismn/balances)
|
8
|
-
[](https://discord.gg/talisman)
|
9
8
|
|
10
9
|
**@talismn/balances** is the core of a set of packages used to subscribe to on-chain account token balances.
|
11
10
|
|
@@ -93,10 +92,7 @@ A quick rundown on each package is given below.
|
|
93
92
|
|
94
93
|
### The chaindata provider:
|
95
94
|
|
96
|
-
|
97
|
-
Will be merged into one package soon™.
|
98
|
-
|
99
|
-
**@talismn/chaindata-provider** and **@talismn/chaindata-provider-extension**
|
95
|
+
**@talismn/chaindata-provider**
|
100
96
|
|
101
97
|
- A database (powered by dexie) to store chains, evm chains and tokens in
|
102
98
|
- An interface to interact with the database
|
@@ -1,9 +1,12 @@
|
|
1
|
-
import { UnsignedTransaction } from "@substrate/txwrapper-core";
|
2
1
|
import { ChainConnector } from "@talismn/chain-connector";
|
3
2
|
import { ChainConnectorEvm } from "@talismn/chain-connector-evm";
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
export type
|
3
|
+
import { ChaindataProvider, ChainId, Token } from "@talismn/chaindata-provider";
|
4
|
+
import { AddressesByToken, BalanceJson, Balances, SubscriptionCallback, UnsubscribeFn } from "./types";
|
5
|
+
export type BalancesCommonTransferMethods = "transfer_keep_alive" | "transfer_all";
|
6
|
+
export type BalancesTransferMethods = "transfer_allow_death" | BalancesCommonTransferMethods;
|
7
|
+
export type BalancesLegacyTransferMethods = "transfer" | BalancesCommonTransferMethods;
|
8
|
+
export type BalancesAllTransferMethods = BalancesLegacyTransferMethods | BalancesTransferMethods;
|
9
|
+
export type SelectableTokenType = Token;
|
7
10
|
export type ExtendableChainMeta = Record<string, unknown> | undefined;
|
8
11
|
export type DefaultChainMeta = undefined;
|
9
12
|
export type ExtendableModuleConfig = Record<string, unknown> | undefined;
|
@@ -13,13 +16,15 @@ export type BaseTransferParams = {
|
|
13
16
|
from: string;
|
14
17
|
to: string;
|
15
18
|
amount: string;
|
19
|
+
transferMethod: BalancesAllTransferMethods;
|
20
|
+
metadataRpc: `0x${string}`;
|
16
21
|
};
|
17
22
|
export type ExtendableTransferParams = BaseTransferParams | undefined;
|
18
23
|
export type DefaultTransferParams = undefined;
|
19
24
|
export type NewTransferParamsType<T extends Record<string, unknown>> = BaseTransferParams & T;
|
20
25
|
export type TransferTokenTx = {
|
21
26
|
type: "substrate";
|
22
|
-
|
27
|
+
callData: string;
|
23
28
|
};
|
24
29
|
export type ChainConnectors = {
|
25
30
|
substrate?: ChainConnector;
|
@@ -29,32 +34,37 @@ export type Hydrate = {
|
|
29
34
|
chainConnectors: ChainConnectors;
|
30
35
|
chaindataProvider: ChaindataProvider;
|
31
36
|
};
|
32
|
-
export type NewBalanceModule<TModuleType extends string, TTokenType extends
|
33
|
-
export interface BalanceModule<TModuleType extends string, TTokenType extends
|
37
|
+
export type NewBalanceModule<TModuleType extends string, TTokenType extends SelectableTokenType, TChainMeta extends ExtendableChainMeta = DefaultChainMeta, TModuleConfig extends ExtendableModuleConfig = DefaultModuleConfig, TTransferParams extends ExtendableTransferParams = DefaultTransferParams> = (hydrate: Hydrate) => BalanceModule<TModuleType, TTokenType, TChainMeta, TModuleConfig, TTransferParams>;
|
38
|
+
export interface BalanceModule<TModuleType extends string, TTokenType extends SelectableTokenType, TChainMeta extends ExtendableChainMeta = DefaultChainMeta, TModuleConfig extends ExtendableModuleConfig = DefaultModuleConfig, TTransferParams extends ExtendableTransferParams = DefaultTransferParams> extends BalanceModuleSubstrate<TModuleType, TTokenType, TChainMeta, TModuleConfig, TTransferParams>, BalanceModuleEvm<TModuleType, TTokenType, TChainMeta, TModuleConfig, TTransferParams> {
|
34
39
|
}
|
35
|
-
export declare const DefaultBalanceModule: <TModuleType extends string, TTokenType extends
|
36
|
-
interface BalanceModuleSubstrate<TModuleType extends string, TTokenType extends
|
40
|
+
export declare const DefaultBalanceModule: <TModuleType extends string, TTokenType extends SelectableTokenType, TChainMeta extends ExtendableChainMeta = undefined, TModuleConfig extends ExtendableModuleConfig = undefined, TTransferParams extends ExtendableTransferParams = undefined>(type: TModuleType) => BalanceModule<TModuleType, TTokenType, TChainMeta, TModuleConfig, TTransferParams>;
|
41
|
+
interface BalanceModuleSubstrate<TModuleType extends string, TTokenType extends SelectableTokenType, TChainMeta extends ExtendableChainMeta = DefaultChainMeta, TModuleConfig extends ExtendableModuleConfig = DefaultModuleConfig, TTransferParams extends ExtendableTransferParams = DefaultTransferParams> extends BalanceModuleCommon<TModuleType, TTokenType, TTransferParams> {
|
37
42
|
/** Pre-processes any substrate chain metadata required by this module ahead of time */
|
38
|
-
fetchSubstrateChainMeta(chainId: ChainId, moduleConfig?: TModuleConfig, metadataRpc?: `0x${string}
|
43
|
+
fetchSubstrateChainMeta(chainId: ChainId, moduleConfig?: TModuleConfig, metadataRpc?: `0x${string}`, systemProperties?: Record<string, any>): Promise<TChainMeta | null>;
|
39
44
|
/** Detects which tokens are available on a given substrate chain */
|
40
45
|
fetchSubstrateChainTokens(chainId: ChainId, chainMeta: TChainMeta, moduleConfig?: TModuleConfig): Promise<Record<TTokenType["id"], TTokenType>>;
|
41
46
|
}
|
42
|
-
interface BalanceModuleEvm<TModuleType extends string, TTokenType extends
|
47
|
+
interface BalanceModuleEvm<TModuleType extends string, TTokenType extends SelectableTokenType, TChainMeta extends ExtendableChainMeta = DefaultChainMeta, TModuleConfig extends ExtendableModuleConfig = DefaultModuleConfig, TTransferParams extends ExtendableTransferParams = DefaultTransferParams> extends BalanceModuleCommon<TModuleType, TTokenType, TTransferParams> {
|
43
48
|
/** Pre-processes any evm chain metadata required by this module ahead of time */
|
44
49
|
fetchEvmChainMeta(chainId: ChainId, moduleConfig?: TModuleConfig): Promise<TChainMeta | null>;
|
45
50
|
/** Detects which tokens are available on a given evm chain */
|
46
51
|
fetchEvmChainTokens(chainId: ChainId, chainMeta: TChainMeta, moduleConfig?: TModuleConfig): Promise<Record<TTokenType["id"], TTokenType>>;
|
47
52
|
}
|
48
|
-
|
53
|
+
export type SubscriptionResultWithStatus = {
|
54
|
+
status: "initialising" | "live";
|
55
|
+
data: BalanceJson[];
|
56
|
+
};
|
57
|
+
interface BalanceModuleCommon<TModuleType extends string, TTokenType extends SelectableTokenType, TTransferParams extends ExtendableTransferParams> {
|
49
58
|
get type(): TModuleType;
|
50
59
|
/**
|
51
60
|
* Subscribe to balances for this module with optional filtering.
|
52
61
|
*
|
53
62
|
* If subscriptions are not possible, this function should poll at some reasonable interval.
|
54
63
|
*/
|
55
|
-
subscribeBalances(addressesByToken
|
56
|
-
|
57
|
-
|
64
|
+
subscribeBalances({ addressesByToken, initialBalances, }: {
|
65
|
+
addressesByToken: AddressesByToken<TTokenType>;
|
66
|
+
initialBalances?: BalanceJson[];
|
67
|
+
}, callback: SubscriptionCallback<Balances | SubscriptionResultWithStatus>): Promise<UnsubscribeFn>;
|
58
68
|
/** Fetch balances for this module with optional filtering */
|
59
69
|
fetchBalances(addressesByToken: AddressesByToken<TTokenType>): Promise<Balances>;
|
60
70
|
/** Prepare a tx to transfer some tokens from this module */
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { ChaindataProvider, EvmNetworkId } from "@talismn/chaindata-provider";
|
2
|
+
import { AnyBalanceModule } from "./modules/util";
|
3
|
+
/**
|
4
|
+
* Fetches tokens for EVM networks.
|
5
|
+
*/
|
6
|
+
export declare class EvmTokenFetcher {
|
7
|
+
#private;
|
8
|
+
constructor(chaindataProvider: ChaindataProvider, balanceModules: Array<AnyBalanceModule>);
|
9
|
+
update(evmNetworkIds: EvmNetworkId[]): Promise<void>;
|
10
|
+
private updateEvmNetworks;
|
11
|
+
}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import { Chain,
|
2
|
-
import { ChaindataProviderExtension } from "@talismn/chaindata-provider-extension";
|
1
|
+
import { Chain, ChaindataProvider, ChainId } from "@talismn/chaindata-provider";
|
3
2
|
import { ChainConnectors } from "./BalanceModule";
|
4
3
|
import { AnyBalanceModule } from "./modules/util";
|
5
4
|
import { MiniMetadata, MiniMetadataStatus } from "./types";
|
@@ -18,7 +17,7 @@ import { MiniMetadata, MiniMetadataStatus } from "./types";
|
|
18
17
|
* As such, the metadata can clock in at around 1-2MB per chain, which is a lot of storage
|
19
18
|
* for browser-based dapps which want to connect to lots of chains.
|
20
19
|
*
|
21
|
-
* By utilizing the wonderful [
|
20
|
+
* By utilizing the wonderful [scale-ts](https://github.com/unstoppablejs/unstoppablejs/tree/main/packages/scale-ts#readme) library,
|
22
21
|
* we can trim the chain metadata down so that it only includes the types we need for balance fetching.
|
23
22
|
*
|
24
23
|
* Each balance module has a function to do just that, `BalanceModule::fetchSubstrateChainMeta`.
|
@@ -30,15 +29,15 @@ import { MiniMetadata, MiniMetadataStatus } from "./types";
|
|
30
29
|
*/
|
31
30
|
export declare class MiniMetadataUpdater {
|
32
31
|
#private;
|
33
|
-
constructor(chainConnectors: ChainConnectors, chaindataProvider:
|
32
|
+
constructor(chainConnectors: ChainConnectors, chaindataProvider: ChaindataProvider, balanceModules: Array<AnyBalanceModule>);
|
34
33
|
/** Subscribe to the metadata for a chain */
|
35
34
|
subscribe(chainId: ChainId): import("rxjs").Observable<MiniMetadata>;
|
36
|
-
update(chainIds: ChainId[]
|
35
|
+
update(chainIds: ChainId[]): Promise<void>;
|
37
36
|
statuses(chains: Array<Pick<Chain, "id" | "specName" | "specVersion" | "balancesConfig">>): Promise<{
|
38
37
|
wantedIdsByChain: Map<string, string[]>;
|
39
38
|
statusesByChain: Map<string, MiniMetadataStatus>;
|
40
39
|
}>;
|
41
40
|
hydrateFromChaindata(): Promise<boolean>;
|
41
|
+
hydrateCustomChains(): Promise<boolean>;
|
42
42
|
private updateSubstrateChains;
|
43
|
-
private updateEvmNetworks;
|
44
43
|
}
|
@@ -1,7 +1,10 @@
|
|
1
1
|
import { Dexie } from "dexie";
|
2
|
-
import {
|
2
|
+
import { MiniMetadata } from "./types";
|
3
3
|
export declare class TalismanBalancesDatabase extends Dexie {
|
4
|
-
|
4
|
+
balancesBlob: Dexie.Table<{
|
5
|
+
data: Uint8Array;
|
6
|
+
id: string;
|
7
|
+
}, string>;
|
5
8
|
miniMetadatas: Dexie.Table<MiniMetadata, string>;
|
6
9
|
constructor();
|
7
10
|
}
|
@@ -1,26 +1,19 @@
|
|
1
|
-
import { BalancesConfigTokenParams,
|
1
|
+
import { BalancesConfigTokenParams, EvmNetworkId, Token } from "@talismn/chaindata-provider";
|
2
2
|
import { NewBalanceModule } from "../BalanceModule";
|
3
|
-
import {
|
3
|
+
import { NewBalanceType } from "../types";
|
4
4
|
import { erc20Abi } from "./abis/erc20";
|
5
|
-
|
5
|
+
import { erc20BalancesAggregatorAbi } from "./abis/erc20BalancesAggregator";
|
6
|
+
export { erc20Abi, erc20BalancesAggregatorAbi };
|
6
7
|
type ModuleType = "evm-erc20";
|
7
|
-
export
|
8
|
-
|
9
|
-
|
10
|
-
evmNetwork: {
|
11
|
-
id: EvmNetworkId;
|
12
|
-
} | null;
|
8
|
+
export type EvmErc20Token = Extract<Token, {
|
9
|
+
type: ModuleType;
|
10
|
+
isCustom?: true;
|
13
11
|
}>;
|
14
|
-
export type CustomEvmErc20Token =
|
12
|
+
export type CustomEvmErc20Token = Extract<Token, {
|
13
|
+
type: ModuleType;
|
15
14
|
isCustom: true;
|
16
|
-
|
17
|
-
|
18
|
-
declare module "@talismn/chaindata-provider/plugins" {
|
19
|
-
interface PluginTokenTypes {
|
20
|
-
EvmErc20Token: EvmErc20Token;
|
21
|
-
CustomEvmErc20Token: CustomEvmErc20Token;
|
22
|
-
}
|
23
|
-
}
|
15
|
+
}>;
|
16
|
+
export declare const evmErc20TokenId: (chainId: EvmNetworkId, tokenContractAddress: EvmErc20Token["contractAddress"]) => string;
|
24
17
|
export type EvmErc20ChainMeta = {
|
25
18
|
isTestnet: boolean;
|
26
19
|
};
|
@@ -31,13 +24,10 @@ export type EvmErc20ModuleConfig = {
|
|
31
24
|
contractAddress?: string;
|
32
25
|
} & BalancesConfigTokenParams>;
|
33
26
|
};
|
34
|
-
export type EvmErc20Balance = NewBalanceType<ModuleType,
|
35
|
-
multiChainId: EvmChainId;
|
36
|
-
free: Amount;
|
37
|
-
}>;
|
27
|
+
export type EvmErc20Balance = NewBalanceType<ModuleType, "simple", "ethereum">;
|
38
28
|
declare module "@talismn/balances/plugins" {
|
39
29
|
interface PluginBalanceTypes {
|
40
|
-
|
30
|
+
"evm-erc20": EvmErc20Balance;
|
41
31
|
}
|
42
32
|
}
|
43
33
|
export declare const EvmErc20Module: NewBalanceModule<ModuleType, EvmErc20Token | CustomEvmErc20Token, EvmErc20ChainMeta, EvmErc20ModuleConfig>;
|
@@ -1,22 +1,14 @@
|
|
1
|
-
import { BalancesConfigTokenParams,
|
1
|
+
import { BalancesConfigTokenParams, EvmNetworkId, Token } from "@talismn/chaindata-provider";
|
2
2
|
import { NewBalanceModule } from "../BalanceModule";
|
3
|
-
import {
|
3
|
+
import { NewBalanceType } from "../types";
|
4
4
|
type ModuleType = "evm-native";
|
5
|
-
export
|
6
|
-
|
7
|
-
evmNetwork: {
|
8
|
-
id: EvmNetworkId;
|
9
|
-
};
|
5
|
+
export type EvmNativeToken = Extract<Token, {
|
6
|
+
type: ModuleType;
|
10
7
|
}>;
|
11
|
-
export type CustomEvmNativeToken =
|
12
|
-
|
13
|
-
}
|
14
|
-
declare
|
15
|
-
interface PluginTokenTypes {
|
16
|
-
EvmNativeToken: EvmNativeToken;
|
17
|
-
CustomEvmNativeToken: CustomEvmNativeToken;
|
18
|
-
}
|
19
|
-
}
|
8
|
+
export type CustomEvmNativeToken = Extract<Token, {
|
9
|
+
type: ModuleType;
|
10
|
+
}>;
|
11
|
+
export declare const evmNativeTokenId: (chainId: EvmNetworkId) => string;
|
20
12
|
export type EvmNativeChainMeta = {
|
21
13
|
isTestnet: boolean;
|
22
14
|
};
|
@@ -24,13 +16,10 @@ export type EvmNativeModuleConfig = {
|
|
24
16
|
symbol?: string;
|
25
17
|
decimals?: number;
|
26
18
|
} & BalancesConfigTokenParams;
|
27
|
-
export type EvmNativeBalance = NewBalanceType<ModuleType,
|
28
|
-
multiChainId: EvmChainId;
|
29
|
-
free: Amount;
|
30
|
-
}>;
|
19
|
+
export type EvmNativeBalance = NewBalanceType<ModuleType, "simple", "ethereum">;
|
31
20
|
declare module "@talismn/balances/plugins" {
|
32
21
|
interface PluginBalanceTypes {
|
33
|
-
|
22
|
+
"evm-native": EvmNativeBalance;
|
34
23
|
}
|
35
24
|
}
|
36
25
|
export declare const EvmNativeModule: NewBalanceModule<ModuleType, EvmNativeToken | CustomEvmNativeToken, EvmNativeChainMeta, EvmNativeModuleConfig>;
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { BalancesConfigTokenParams, EvmNetworkId, Token } from "@talismn/chaindata-provider";
|
2
|
+
import { NewBalanceModule } from "../BalanceModule";
|
3
|
+
import { NewBalanceType } from "../types";
|
4
|
+
import { uniswapV2PairAbi } from "./abis/uniswapV2Pair";
|
5
|
+
export { uniswapV2PairAbi };
|
6
|
+
type ModuleType = "evm-uniswapv2";
|
7
|
+
export type EvmUniswapV2Token = Extract<Token, {
|
8
|
+
type: ModuleType;
|
9
|
+
isCustom?: true;
|
10
|
+
}>;
|
11
|
+
export type CustomEvmUniswapV2Token = Extract<Token, {
|
12
|
+
type: ModuleType;
|
13
|
+
isCustom: true;
|
14
|
+
}>;
|
15
|
+
export declare const evmUniswapV2TokenId: (chainId: EvmNetworkId, contractAddress: EvmUniswapV2Token["contractAddress"]) => string;
|
16
|
+
export type EvmUniswapV2ChainMeta = {
|
17
|
+
isTestnet: boolean;
|
18
|
+
};
|
19
|
+
export type EvmUniswapV2ModuleConfig = {
|
20
|
+
pools?: Array<{
|
21
|
+
contractAddress?: string;
|
22
|
+
decimals?: number;
|
23
|
+
symbol0?: string;
|
24
|
+
symbol1?: string;
|
25
|
+
decimals0?: number;
|
26
|
+
decimals1?: number;
|
27
|
+
tokenAddress0?: string;
|
28
|
+
tokenAddress1?: string;
|
29
|
+
coingeckoId0?: string;
|
30
|
+
coingeckoId1?: string;
|
31
|
+
} & BalancesConfigTokenParams>;
|
32
|
+
};
|
33
|
+
export type EvmUniswapV2Balance = NewBalanceType<"evm-uniswapv2", "complex", "ethereum">;
|
34
|
+
declare module "@talismn/balances/plugins" {
|
35
|
+
interface PluginBalanceTypes {
|
36
|
+
"evm-uniswapv2": EvmUniswapV2Balance;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
export declare const EvmUniswapV2Module: NewBalanceModule<ModuleType, EvmUniswapV2Token | CustomEvmUniswapV2Token, EvmUniswapV2ChainMeta, EvmUniswapV2ModuleConfig>;
|
@@ -1,51 +1,38 @@
|
|
1
1
|
import { TypeRegistry } from "@polkadot/types";
|
2
|
-
import {
|
2
|
+
import { ExtDef } from "@polkadot/types/extrinsic/signedExtensions/types";
|
3
|
+
import { BalancesConfigTokenParams, ChainId, Token } from "@talismn/chaindata-provider";
|
3
4
|
import { NewBalanceModule, NewTransferParamsType } from "../BalanceModule";
|
4
|
-
import {
|
5
|
+
import { NewBalanceType } from "../types";
|
5
6
|
type ModuleType = "substrate-assets";
|
6
|
-
export type SubAssetsToken =
|
7
|
-
|
8
|
-
assetId: string;
|
9
|
-
isFrozen: boolean;
|
10
|
-
chain: {
|
11
|
-
id: ChainId;
|
12
|
-
};
|
7
|
+
export type SubAssetsToken = Extract<Token, {
|
8
|
+
type: ModuleType;
|
13
9
|
}>;
|
14
|
-
declare
|
15
|
-
interface PluginTokenTypes {
|
16
|
-
SubAssetsToken: SubAssetsToken;
|
17
|
-
}
|
18
|
-
}
|
10
|
+
export declare const subAssetTokenId: (chainId: ChainId, assetId: string, tokenSymbol: string) => string;
|
19
11
|
export type SubAssetsChainMeta = {
|
20
12
|
isTestnet: boolean;
|
21
|
-
miniMetadata
|
22
|
-
metadataVersion
|
13
|
+
miniMetadata?: string;
|
14
|
+
metadataVersion?: number;
|
23
15
|
};
|
24
16
|
export type SubAssetsModuleConfig = {
|
25
17
|
tokens?: Array<{
|
26
18
|
assetId: string | number;
|
27
19
|
} & BalancesConfigTokenParams>;
|
28
20
|
};
|
29
|
-
export type SubAssetsBalance = NewBalanceType<ModuleType,
|
30
|
-
multiChainId: SubChainId;
|
31
|
-
free: Amount;
|
32
|
-
locks: Amount;
|
33
|
-
}>;
|
21
|
+
export type SubAssetsBalance = NewBalanceType<ModuleType, "complex", "substrate">;
|
34
22
|
declare module "@talismn/balances/plugins" {
|
35
23
|
interface PluginBalanceTypes {
|
36
|
-
|
24
|
+
"substrate-assets": SubAssetsBalance;
|
37
25
|
}
|
38
26
|
}
|
39
27
|
export type SubAssetsTransferParams = NewTransferParamsType<{
|
40
28
|
registry: TypeRegistry;
|
41
|
-
metadataRpc: `0x${string}`;
|
42
29
|
blockHash: string;
|
43
30
|
blockNumber: number;
|
44
31
|
nonce: number;
|
45
32
|
specVersion: number;
|
46
33
|
transactionVersion: number;
|
47
34
|
tip?: string;
|
48
|
-
|
35
|
+
userExtensions?: ExtDef;
|
49
36
|
}>;
|
50
37
|
export declare const SubAssetsModule: NewBalanceModule<ModuleType, SubAssetsToken, SubAssetsChainMeta, SubAssetsModuleConfig, SubAssetsTransferParams>;
|
51
38
|
export {};
|
@@ -1,24 +1,17 @@
|
|
1
1
|
import { TypeRegistry } from "@polkadot/types";
|
2
|
-
import {
|
2
|
+
import { ExtDef } from "@polkadot/types/extrinsic/signedExtensions/types";
|
3
|
+
import { BalancesConfigTokenParams, ChainId, Token } from "@talismn/chaindata-provider";
|
3
4
|
import { NewBalanceModule, NewTransferParamsType } from "../BalanceModule";
|
4
|
-
import {
|
5
|
+
import { NewBalanceType } from "../types";
|
5
6
|
type ModuleType = "substrate-equilibrium";
|
6
|
-
export type SubEquilibriumToken =
|
7
|
-
|
8
|
-
assetId: string;
|
9
|
-
chain: {
|
10
|
-
id: ChainId;
|
11
|
-
};
|
7
|
+
export type SubEquilibriumToken = Extract<Token, {
|
8
|
+
type: ModuleType;
|
12
9
|
}>;
|
13
|
-
declare
|
14
|
-
interface PluginTokenTypes {
|
15
|
-
SubEquilibriumToken: SubEquilibriumToken;
|
16
|
-
}
|
17
|
-
}
|
10
|
+
export declare const subEquilibriumTokenId: (chainId: ChainId, tokenSymbol: string) => string;
|
18
11
|
export type SubEquilibriumChainMeta = {
|
19
12
|
isTestnet: boolean;
|
20
|
-
miniMetadata
|
21
|
-
metadataVersion
|
13
|
+
miniMetadata?: string;
|
14
|
+
metadataVersion?: number;
|
22
15
|
};
|
23
16
|
export type SubEquilibriumModuleConfig = {
|
24
17
|
disable?: boolean;
|
@@ -26,25 +19,21 @@ export type SubEquilibriumModuleConfig = {
|
|
26
19
|
assetId?: string;
|
27
20
|
} & BalancesConfigTokenParams>;
|
28
21
|
};
|
29
|
-
export type SubEquilibriumBalance = NewBalanceType<ModuleType,
|
30
|
-
multiChainId: SubChainId;
|
31
|
-
free: Amount;
|
32
|
-
}>;
|
22
|
+
export type SubEquilibriumBalance = NewBalanceType<ModuleType, "simple", "substrate">;
|
33
23
|
declare module "@talismn/balances/plugins" {
|
34
24
|
interface PluginBalanceTypes {
|
35
|
-
|
25
|
+
"substrate-equilibrium": SubEquilibriumBalance;
|
36
26
|
}
|
37
27
|
}
|
38
28
|
export type SubEquilibriumTransferParams = NewTransferParamsType<{
|
39
29
|
registry: TypeRegistry;
|
40
|
-
metadataRpc: `0x${string}`;
|
41
30
|
blockHash: string;
|
42
31
|
blockNumber: number;
|
43
32
|
nonce: number;
|
44
33
|
specVersion: number;
|
45
34
|
transactionVersion: number;
|
46
35
|
tip?: string;
|
47
|
-
|
36
|
+
userExtensions?: ExtDef;
|
48
37
|
}>;
|
49
38
|
export declare const SubEquilibriumModule: NewBalanceModule<ModuleType, SubEquilibriumToken, SubEquilibriumChainMeta, SubEquilibriumModuleConfig, SubEquilibriumTransferParams>;
|
50
39
|
export {};
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import { TypeRegistry } from "@polkadot/types";
|
2
|
+
import { ExtDef } from "@polkadot/types/extrinsic/signedExtensions/types";
|
3
|
+
import { BalancesConfigTokenParams, ChainId, Token } from "@talismn/chaindata-provider";
|
4
|
+
import { NewBalanceModule, NewTransferParamsType } from "../BalanceModule";
|
5
|
+
import { NewBalanceType } from "../types";
|
6
|
+
type ModuleType = "substrate-foreignassets";
|
7
|
+
export type SubForeignAssetsToken = Extract<Token, {
|
8
|
+
type: ModuleType;
|
9
|
+
}>;
|
10
|
+
export declare const subForeignAssetTokenId: (chainId: ChainId, tokenSymbol: string) => string;
|
11
|
+
export type SubForeignAssetsChainMeta = {
|
12
|
+
isTestnet: boolean;
|
13
|
+
miniMetadata?: string;
|
14
|
+
metadataVersion?: number;
|
15
|
+
};
|
16
|
+
export type SubForeignAssetsModuleConfig = {
|
17
|
+
tokens?: Array<{
|
18
|
+
onChainId: string;
|
19
|
+
} & BalancesConfigTokenParams>;
|
20
|
+
};
|
21
|
+
export type SubForeignAssetsBalance = NewBalanceType<ModuleType, "complex", "substrate">;
|
22
|
+
declare module "@talismn/balances/plugins" {
|
23
|
+
interface PluginBalanceTypes {
|
24
|
+
"substrate-foreignassets": SubForeignAssetsBalance;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
export type SubForeignAssetsTransferParams = NewTransferParamsType<{
|
28
|
+
registry: TypeRegistry;
|
29
|
+
blockHash: string;
|
30
|
+
blockNumber: number;
|
31
|
+
nonce: number;
|
32
|
+
specVersion: number;
|
33
|
+
transactionVersion: number;
|
34
|
+
tip?: string;
|
35
|
+
userExtensions?: ExtDef;
|
36
|
+
}>;
|
37
|
+
export declare const SubForeignAssetsModule: NewBalanceModule<ModuleType, SubForeignAssetsToken, SubForeignAssetsChainMeta, SubForeignAssetsModuleConfig, SubForeignAssetsTransferParams>;
|
38
|
+
export {};
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { NewBalanceModule } from "../../BalanceModule";
|
2
|
+
import { CustomSubNativeToken, ModuleType, SubNativeChainMeta, SubNativeModuleConfig, SubNativeToken, SubNativeTransferParams } from "./types";
|
3
|
+
export { filterBaseLocks, getLockTitle } from "./util/balanceLockTypes";
|
4
|
+
export type { BalanceLockType } from "./util/balanceLockTypes";
|
5
|
+
export type { CustomSubNativeToken, ModuleType, SubNativeBalance, SubNativeChainMeta, SubNativeModuleConfig, SubNativeToken, SubNativeTransferParams, } from "./types";
|
6
|
+
export { subNativeTokenId } from "./types";
|
7
|
+
export declare const SubNativeModule: NewBalanceModule<ModuleType, SubNativeToken | CustomSubNativeToken, SubNativeChainMeta, SubNativeModuleConfig, SubNativeTransferParams>;
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { ChainConnector } from "@talismn/chain-connector";
|
2
|
+
import { SubscriptionCallback } from "../../types";
|
3
|
+
import { RpcStateQuery } from "../util";
|
4
|
+
import { SubNativeBalance } from "./types";
|
5
|
+
export declare function subscribeBase(queries: RpcStateQuery<SubNativeBalance>[], chainConnector: ChainConnector, callback: SubscriptionCallback<SubNativeBalance[]>): Promise<import("../../types").UnsubscribeFn>;
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { ChainConnector } from "@talismn/chain-connector";
|
2
|
+
import { ChaindataProvider } from "@talismn/chaindata-provider";
|
3
|
+
import { AddressesByToken, SubscriptionCallback } from "../../types";
|
4
|
+
import { CustomSubNativeToken, SubNativeBalance, SubNativeToken } from "./types";
|
5
|
+
export declare function subscribeCrowdloans(chaindataProvider: ChaindataProvider, chainConnector: ChainConnector, addressesByToken: AddressesByToken<SubNativeToken | CustomSubNativeToken>, callback: SubscriptionCallback<SubNativeBalance[]>): Promise<() => void>;
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { ChainConnector } from "@talismn/chain-connector";
|
2
|
+
import { ChaindataProvider } from "@talismn/chaindata-provider";
|
3
|
+
import { AddressesByToken, SubscriptionCallback } from "../../types";
|
4
|
+
import { SubNativeBalance, SubNativeToken } from "./types";
|
5
|
+
export declare function subscribeNompoolStaking(chaindataProvider: ChaindataProvider, chainConnector: ChainConnector, addressesByToken: AddressesByToken<SubNativeToken>, callback: SubscriptionCallback<SubNativeBalance[]>): Promise<() => void>;
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { ChainConnector } from "@talismn/chain-connector";
|
2
|
+
import { ChaindataProvider } from "@talismn/chaindata-provider";
|
3
|
+
import { AddressesByToken, SubscriptionCallback } from "../../types";
|
4
|
+
import { SubNativeBalance, SubNativeToken } from "./types";
|
5
|
+
export declare function subscribeSubtensorStaking(chaindataProvider: ChaindataProvider, chainConnector: ChainConnector, addressesByToken: AddressesByToken<SubNativeToken>, callback: SubscriptionCallback<SubNativeBalance[]>): Promise<() => void>;
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import { TypeRegistry } from "@polkadot/types";
|
2
|
+
import { ExtDef } from "@polkadot/types/extrinsic/signedExtensions/types";
|
3
|
+
import { BalancesConfigTokenParams, ChainId, Token } from "@talismn/chaindata-provider";
|
4
|
+
import { NewTransferParamsType } from "../../BalanceModule";
|
5
|
+
import { NewBalanceType } from "../../types";
|
6
|
+
export { filterBaseLocks, getLockTitle } from "./util/balanceLockTypes";
|
7
|
+
export type { BalanceLockType } from "./util/balanceLockTypes";
|
8
|
+
export type ModuleType = "substrate-native";
|
9
|
+
export declare const moduleType: ModuleType;
|
10
|
+
export type SubNativeToken = Extract<Token, {
|
11
|
+
type: ModuleType;
|
12
|
+
isCustom?: true;
|
13
|
+
}>;
|
14
|
+
export type CustomSubNativeToken = Extract<Token, {
|
15
|
+
type: ModuleType;
|
16
|
+
isCustom: true;
|
17
|
+
}>;
|
18
|
+
export declare const subNativeTokenId: (chainId: ChainId) => string;
|
19
|
+
export type SubNativeChainMeta = {
|
20
|
+
isTestnet: boolean;
|
21
|
+
useLegacyTransferableCalculation?: boolean;
|
22
|
+
symbol?: string;
|
23
|
+
decimals?: number;
|
24
|
+
existentialDeposit?: string;
|
25
|
+
nominationPoolsPalletId?: string;
|
26
|
+
crowdloanPalletId?: string;
|
27
|
+
hasSubtensorPallet?: boolean;
|
28
|
+
miniMetadata?: string;
|
29
|
+
metadataVersion?: number;
|
30
|
+
};
|
31
|
+
export type SubNativeModuleConfig = {
|
32
|
+
disable?: boolean;
|
33
|
+
} & BalancesConfigTokenParams;
|
34
|
+
export type SubNativeBalance = NewBalanceType<ModuleType, "complex", "substrate">;
|
35
|
+
declare module "@talismn/balances/plugins" {
|
36
|
+
interface PluginBalanceTypes {
|
37
|
+
"substrate-native": SubNativeBalance;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
export type SubNativeTransferParams = NewTransferParamsType<{
|
41
|
+
registry: TypeRegistry;
|
42
|
+
blockHash: string;
|
43
|
+
blockNumber: number;
|
44
|
+
nonce: number;
|
45
|
+
specVersion: number;
|
46
|
+
transactionVersion: number;
|
47
|
+
tip?: string;
|
48
|
+
userExtensions?: ExtDef;
|
49
|
+
}>;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { ChaindataProvider } from "@talismn/chaindata-provider";
|
2
|
+
import { AddressesByToken } from "../../../types";
|
3
|
+
import { RpcStateQuery } from "../../util";
|
4
|
+
import { SubNativeBalance, SubNativeToken } from "../types";
|
5
|
+
export declare class QueryCache {
|
6
|
+
private chaindataProvider;
|
7
|
+
private balanceQueryCache;
|
8
|
+
private metadataSub;
|
9
|
+
constructor(chaindataProvider: ChaindataProvider);
|
10
|
+
ensureSetup(): void;
|
11
|
+
destroy(): void;
|
12
|
+
getQueries(addressesByToken: AddressesByToken<SubNativeToken>): Promise<RpcStateQuery<SubNativeBalance>[]>;
|
13
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { Observable } from "rxjs";
|
2
|
+
import { SubscriptionCallback, UnsubscribeFn } from "../../../types";
|
3
|
+
/**
|
4
|
+
* Converts a subscription function into an Observable
|
5
|
+
*
|
6
|
+
* The type of a subscription function which can be converted into an observable:
|
7
|
+
*
|
8
|
+
* <TArgs, TResult>(...arguments: TArgs, callback: SubscriptionCallback<TResult>) => UnsubscribeFn
|
9
|
+
*/
|
10
|
+
export declare const asObservable: <T extends unknown[], R>(handler: (...args: [...T, SubscriptionCallback<R>]) => UnsubscribeFn) => (...args: T) => Observable<R>;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { Balance, BalanceFormatter, LockedAmount } from "../../../types";
|
2
|
+
export type BalanceLockType = "reserved" | "democracy" | "crowdloan" | "staking" | "nompools-staking" | "nompools-unbonding" | "subtensor-staking" | "vesting" | "dapp-staking" | `other-${string}` | "other";
|
3
|
+
/**
|
4
|
+
* For converting the value of `lock?.id?.toUtf8?.()` which is retrieved from
|
5
|
+
* the Balances.Locks storage key into a useful classification for our UI
|
6
|
+
*/
|
7
|
+
export declare const getLockedType: (input?: string) => BalanceLockType;
|
8
|
+
export declare const filterBaseLocks: (locks: Array<Omit<LockedAmount<string>, "amount"> & {
|
9
|
+
amount: BalanceFormatter;
|
10
|
+
}>) => (Omit<LockedAmount<string>, "amount"> & {
|
11
|
+
amount: BalanceFormatter;
|
12
|
+
})[];
|
13
|
+
export declare const getLockTitle: (lock: Pick<LockedAmount<string>, "label" | "meta">, { balance }?: {
|
14
|
+
balance?: Balance;
|
15
|
+
}) => string;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { Chain, Token } from "@talismn/chaindata-provider";
|
2
|
+
import { AddressesByToken, MiniMetadata } from "../../../types";
|
3
|
+
import { RpcStateQuery, StorageCoders } from "../../util";
|
4
|
+
import { SubNativeBalance, SubNativeToken } from "../types";
|
5
|
+
export type QueryKey = string;
|
6
|
+
export declare function buildQueries(chains: Record<string, Chain>, tokens: Record<string, Token>, chainStorageCoders: StorageCoders<{
|
7
|
+
base: ["System", "Account"];
|
8
|
+
stakingLedger: ["Staking", "Ledger"];
|
9
|
+
reserves: ["Balances", "Reserves"];
|
10
|
+
holds: ["Balances", "Holds"];
|
11
|
+
locks: ["Balances", "Locks"];
|
12
|
+
freezes: ["Balances", "Freezes"];
|
13
|
+
}>, miniMetadatas: Map<string, MiniMetadata>, addressesByToken: AddressesByToken<SubNativeToken>): Promise<Record<QueryKey, Array<RpcStateQuery<SubNativeBalance>>>>;
|