@talismn/balances 0.3.3 → 0.4.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/CHANGELOG.md +38 -0
- package/dist/declarations/src/BalanceModule.d.ts +41 -19
- package/dist/declarations/src/helpers.d.ts +67 -14
- package/dist/declarations/src/types/balances.d.ts +49 -2
- package/dist/declarations/src/types/balancetypes.d.ts +9 -1
- package/dist/talismn-balances.cjs.dev.js +371 -108
- package/dist/talismn-balances.cjs.prod.js +371 -108
- package/dist/talismn-balances.esm.js +363 -109
- package/package.json +15 -15
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,43 @@
|
|
1
1
|
# @talismn/balances
|
2
2
|
|
3
|
+
## 0.4.1
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- fb8ee962: feat: proxy dapp websocket requests to talisman wallet backend when available
|
8
|
+
- f7aca48b: eslint rules
|
9
|
+
- 01bf239b: feat: crowdloan and nom pool balances
|
10
|
+
- 48f0222e: fix: removed some explicit `any`s
|
11
|
+
- 01bf239b: fix: packages publishing with incorrect interdependency versions
|
12
|
+
- Updated dependencies [fb8ee962]
|
13
|
+
- Updated dependencies [c898da98]
|
14
|
+
- Updated dependencies [f7aca48b]
|
15
|
+
- Updated dependencies [01bf239b]
|
16
|
+
- Updated dependencies [48f0222e]
|
17
|
+
- Updated dependencies [01bf239b]
|
18
|
+
- @talismn/chain-connector@0.4.4
|
19
|
+
- @talismn/chain-connector-evm@0.4.4
|
20
|
+
- @talismn/chaindata-provider@0.4.4
|
21
|
+
- @talismn/token-rates@0.1.16
|
22
|
+
- @talismn/util@0.1.9
|
23
|
+
|
24
|
+
## 0.4.0
|
25
|
+
|
26
|
+
### Patch Changes
|
27
|
+
|
28
|
+
- 3068bd60: feat: stale balances and exponential rpc backoff
|
29
|
+
- 6643a4e4: fix: tokenRates in @talismn/balances-react
|
30
|
+
- 6643a4e4: fix: ported useDbCache related perf fixes to @talismn/balances-react
|
31
|
+
- Updated dependencies [3068bd60]
|
32
|
+
- Updated dependencies [6643a4e4]
|
33
|
+
- Updated dependencies [79f6ccf6]
|
34
|
+
- Updated dependencies [c24dc1fb]
|
35
|
+
- @talismn/chain-connector@0.4.3
|
36
|
+
- @talismn/util@0.1.8
|
37
|
+
- @talismn/token-rates@0.1.15
|
38
|
+
- @talismn/chaindata-provider@0.4.3
|
39
|
+
- @talismn/chain-connector-evm@0.4.3
|
40
|
+
|
3
41
|
## 0.3.3
|
4
42
|
|
5
43
|
### Patch Changes
|
@@ -1,43 +1,65 @@
|
|
1
|
+
import { UnsignedTransaction } from "@substrate/txwrapper-core";
|
1
2
|
import { ChainConnector } from "@talismn/chain-connector";
|
2
3
|
import { ChainConnectorEvm } from "@talismn/chain-connector-evm";
|
3
4
|
import { ChainId, ChaindataProvider, IToken } from "@talismn/chaindata-provider";
|
5
|
+
import { ethers } from "ethers";
|
4
6
|
import { AddressesByToken, Balances, SubscriptionCallback, UnsubscribeFn } from "./types";
|
5
|
-
export interface BalanceModule<TModuleType extends string, TTokenType extends ExtendableTokenType, TChainMeta extends ExtendableChainMeta = DefaultChainMeta, TModuleConfig extends ExtendableModuleConfig = DefaultModuleConfig> extends BalanceModuleSubstrate<TModuleType, TTokenType, TChainMeta, TModuleConfig>, BalanceModuleEvm<TModuleType, TTokenType, TChainMeta, TModuleConfig> {
|
6
|
-
}
|
7
|
-
export declare const DefaultBalanceModule: <TModuleType extends string, TTokenType extends IToken, TChainMeta extends ExtendableChainMeta = undefined, TModuleConfig extends ExtendableModuleConfig = undefined>(type: TModuleType) => BalanceModule<TModuleType, TTokenType, TChainMeta, TModuleConfig>;
|
8
7
|
export type ExtendableTokenType = IToken;
|
9
8
|
export type ExtendableChainMeta = Record<string, unknown> | undefined;
|
10
9
|
export type DefaultChainMeta = undefined;
|
11
10
|
export type ExtendableModuleConfig = Record<string, unknown> | undefined;
|
12
11
|
export type DefaultModuleConfig = undefined;
|
13
|
-
|
12
|
+
export type BaseTransferParams = {
|
13
|
+
tokenId: string;
|
14
|
+
from: string;
|
15
|
+
to: string;
|
16
|
+
amount: string;
|
17
|
+
};
|
18
|
+
export type ExtendableTransferParams = BaseTransferParams | undefined;
|
19
|
+
export type DefaultTransferParams = undefined;
|
20
|
+
export type NewTransferParamsType<T extends Record<string, unknown>> = BaseTransferParams & T;
|
21
|
+
export type TransferTokenTx = {
|
22
|
+
type: "substrate";
|
23
|
+
tx: UnsignedTransaction;
|
24
|
+
} | {
|
25
|
+
type: "evm";
|
26
|
+
tx: ethers.providers.TransactionRequest;
|
27
|
+
};
|
28
|
+
export type ChainConnectors = {
|
29
|
+
substrate?: ChainConnector;
|
30
|
+
evm?: ChainConnectorEvm;
|
31
|
+
};
|
32
|
+
export type Hydrate = {
|
33
|
+
chainConnectors: ChainConnectors;
|
34
|
+
chaindataProvider: ChaindataProvider;
|
35
|
+
};
|
36
|
+
export type NewBalanceModule<TModuleType extends string, TTokenType extends ExtendableTokenType, TChainMeta extends ExtendableChainMeta = DefaultChainMeta, TModuleConfig extends ExtendableModuleConfig = DefaultModuleConfig, TTransferParams extends ExtendableTransferParams = DefaultTransferParams> = (hydrate: Hydrate) => BalanceModule<TModuleType, TTokenType, TChainMeta, TModuleConfig, TTransferParams>;
|
37
|
+
export interface BalanceModule<TModuleType extends string, TTokenType extends ExtendableTokenType, 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> {
|
38
|
+
}
|
39
|
+
export declare const DefaultBalanceModule: <TModuleType extends string, TTokenType extends IToken, TChainMeta extends ExtendableChainMeta = undefined, TModuleConfig extends ExtendableModuleConfig = undefined, TTransferParams extends ExtendableTransferParams = undefined>(type: TModuleType) => BalanceModule<TModuleType, TTokenType, TChainMeta, TModuleConfig, TTransferParams>;
|
40
|
+
interface BalanceModuleSubstrate<TModuleType extends string, TTokenType extends ExtendableTokenType, TChainMeta extends ExtendableChainMeta = DefaultChainMeta, TModuleConfig extends ExtendableModuleConfig = DefaultModuleConfig, TTransferParams extends ExtendableTransferParams = DefaultTransferParams> extends BalanceModuleCommon<TModuleType, TTokenType, TTransferParams> {
|
14
41
|
/** Pre-processes any substrate chain metadata required by this module ahead of time */
|
15
|
-
fetchSubstrateChainMeta(
|
42
|
+
fetchSubstrateChainMeta(chainId: ChainId, moduleConfig?: TModuleConfig): Promise<TChainMeta | null>;
|
16
43
|
/** Detects which tokens are available on a given substrate chain */
|
17
|
-
fetchSubstrateChainTokens(
|
44
|
+
fetchSubstrateChainTokens(chainId: ChainId, chainMeta: TChainMeta, moduleConfig?: TModuleConfig): Promise<Record<TTokenType["id"], TTokenType>>;
|
18
45
|
}
|
19
|
-
interface BalanceModuleEvm<TModuleType extends string, TTokenType extends ExtendableTokenType, TChainMeta extends ExtendableChainMeta = DefaultChainMeta, TModuleConfig extends ExtendableModuleConfig = DefaultModuleConfig> extends BalanceModuleCommon<TModuleType, TTokenType> {
|
46
|
+
interface BalanceModuleEvm<TModuleType extends string, TTokenType extends ExtendableTokenType, TChainMeta extends ExtendableChainMeta = DefaultChainMeta, TModuleConfig extends ExtendableModuleConfig = DefaultModuleConfig, TTransferParams extends ExtendableTransferParams = DefaultTransferParams> extends BalanceModuleCommon<TModuleType, TTokenType, TTransferParams> {
|
20
47
|
/** Pre-processes any evm chain metadata required by this module ahead of time */
|
21
|
-
fetchEvmChainMeta(
|
48
|
+
fetchEvmChainMeta(chainId: ChainId, moduleConfig?: TModuleConfig): Promise<TChainMeta | null>;
|
22
49
|
/** Detects which tokens are available on a given evm chain */
|
23
|
-
fetchEvmChainTokens(
|
50
|
+
fetchEvmChainTokens(chainId: ChainId, chainMeta: TChainMeta, moduleConfig?: TModuleConfig): Promise<Record<TTokenType["id"], TTokenType>>;
|
24
51
|
}
|
25
|
-
interface BalanceModuleCommon<TModuleType extends string, TTokenType extends ExtendableTokenType> {
|
52
|
+
interface BalanceModuleCommon<TModuleType extends string, TTokenType extends ExtendableTokenType, TTransferParams extends ExtendableTransferParams> {
|
26
53
|
get type(): TModuleType;
|
27
54
|
/**
|
28
55
|
* Subscribe to balances for this module with optional filtering.
|
29
56
|
*
|
30
57
|
* If subscriptions are not possible, this function should poll at some reasonable interval.
|
31
58
|
*/
|
32
|
-
subscribeBalances(
|
33
|
-
substrate?: ChainConnector;
|
34
|
-
evm?: ChainConnectorEvm;
|
35
|
-
}, chaindataProvider: ChaindataProvider, addressesByToken: AddressesByToken<TTokenType>, callback: SubscriptionCallback<Balances>): Promise<UnsubscribeFn>;
|
59
|
+
subscribeBalances(addressesByToken: AddressesByToken<TTokenType>, callback: SubscriptionCallback<Balances>): Promise<UnsubscribeFn>;
|
36
60
|
/** Fetch balances for this module with optional filtering */
|
37
|
-
fetchBalances(
|
38
|
-
|
39
|
-
|
40
|
-
}, chaindataProvider: ChaindataProvider, addressesByToken: AddressesByToken<TTokenType>): Promise<Balances>;
|
41
|
-
[x: string | number | symbol]: unknown;
|
61
|
+
fetchBalances(addressesByToken: AddressesByToken<TTokenType>): Promise<Balances>;
|
62
|
+
/** Prepare a tx to transfer some tokens from this module */
|
63
|
+
transferToken(transferParams: TTransferParams): Promise<TransferTokenTx | null>;
|
42
64
|
}
|
43
65
|
export {};
|
@@ -1,29 +1,64 @@
|
|
1
|
-
import {
|
1
|
+
import type { Registry } from "@polkadot/types-codec/types";
|
2
2
|
import { ChainConnector } from "@talismn/chain-connector";
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import { AddressesByToken, Balance, Balances, SubscriptionCallback, UnsubscribeFn } from "./types";
|
3
|
+
import { Chain, ChainId } from "@talismn/chaindata-provider";
|
4
|
+
import { BalanceModule, DefaultChainMeta, DefaultModuleConfig, DefaultTransferParams, ExtendableChainMeta, ExtendableModuleConfig, ExtendableTokenType, ExtendableTransferParams, NewBalanceModule } from "./BalanceModule";
|
5
|
+
import { AddressesByToken, Balance, BalanceJson, Balances, SubscriptionCallback, UnsubscribeFn } from "./types";
|
7
6
|
/**
|
8
7
|
* Wraps a BalanceModule's fetch/subscribe methods with a single `balances` method.
|
9
8
|
* This `balances` method will subscribe if a callback parameter is provided, or otherwise fetch.
|
10
9
|
*/
|
11
|
-
export declare function balances<TModuleType extends string, TTokenType extends ExtendableTokenType, TChainMeta extends ExtendableChainMeta = DefaultChainMeta, TModuleConfig extends ExtendableModuleConfig = DefaultModuleConfig>(balanceModule: BalanceModule<TModuleType, TTokenType, TChainMeta, TModuleConfig>,
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
10
|
+
export declare function balances<TModuleType extends string, TTokenType extends ExtendableTokenType, TChainMeta extends ExtendableChainMeta = DefaultChainMeta, TModuleConfig extends ExtendableModuleConfig = DefaultModuleConfig, TTransferParams extends ExtendableTransferParams = DefaultTransferParams>(balanceModule: BalanceModule<TModuleType, TTokenType, TChainMeta, TModuleConfig, TTransferParams>, addressesByToken: AddressesByToken<TTokenType>): Promise<Balances>;
|
11
|
+
export declare function balances<TModuleType extends string, TTokenType extends ExtendableTokenType, TChainMeta extends ExtendableChainMeta = DefaultChainMeta, TModuleConfig extends ExtendableModuleConfig = DefaultModuleConfig, TTransferParams extends ExtendableTransferParams = DefaultTransferParams>(balanceModule: BalanceModule<TModuleType, TTokenType, TChainMeta, TModuleConfig, TTransferParams>, addressesByToken: AddressesByToken<TTokenType>, callback: SubscriptionCallback<Balances>): Promise<UnsubscribeFn>;
|
12
|
+
export type GetOrCreateTypeRegistry = (chainId: ChainId, metadataRpc?: `0x${string}`) => Registry;
|
13
|
+
export declare const createTypeRegistryCache: () => {
|
14
|
+
getOrCreateTypeRegistry: GetOrCreateTypeRegistry;
|
15
|
+
};
|
16
|
+
export type AnyBalanceModule = BalanceModule<any, any, any, any, any>;
|
17
|
+
export type AnyNewBalanceModule = NewBalanceModule<any, any, any, any, any>;
|
18
|
+
/**
|
19
|
+
* The following `Infer*` collection of generic types can be used when you want to
|
20
|
+
* extract one of the generic type arguments from an existing BalanceModule.
|
21
|
+
*
|
22
|
+
* For example, you might want to write a function which can accept any BalanceModule
|
23
|
+
* as an input, and then return the specific TokenType for that module:
|
24
|
+
* function getTokens<T extends AnyBalanceModule>(module: T): InferTokenType<T>
|
25
|
+
*
|
26
|
+
* Or for another example, you might want a function which can take any BalanceModule `type`
|
27
|
+
* string as input, and then return some data associated with that module with the correct type:
|
28
|
+
* function getChainMeta<T extends AnyBalanceModule>(type: InferModuleType<T>): InferChainMeta<T> | undefined
|
29
|
+
*/
|
30
|
+
type InferBalanceModuleTypes<T extends AnyNewBalanceModule> = T extends NewBalanceModule<infer TModuleType, infer TTokenType, infer TChainMeta, infer TModuleConfig, infer TTransferParams> ? {
|
31
|
+
TModuleType: TModuleType;
|
32
|
+
TTokenType: TTokenType;
|
33
|
+
TChainMeta: TChainMeta;
|
34
|
+
TModuleConfig: TModuleConfig;
|
35
|
+
TTransferParams: TTransferParams;
|
36
|
+
} : never;
|
37
|
+
export type InferModuleType<T extends AnyNewBalanceModule> = InferBalanceModuleTypes<T>["TModuleType"];
|
38
|
+
export type InferTokenType<T extends AnyNewBalanceModule> = InferBalanceModuleTypes<T>["TTokenType"];
|
39
|
+
export type InferChainMeta<T extends AnyNewBalanceModule> = InferBalanceModuleTypes<T>["TChainMeta"];
|
40
|
+
export type InferModuleConfig<T extends AnyNewBalanceModule> = InferBalanceModuleTypes<T>["TModuleConfig"];
|
41
|
+
export type InferTransferParams<T extends AnyNewBalanceModule> = InferBalanceModuleTypes<T>["TTransferParams"];
|
42
|
+
/**
|
43
|
+
* Given a `moduleType` and a `chain` from a chaindataProvider, this function will find the chainMeta
|
44
|
+
* associated with the given balanceModule for the given chain.
|
45
|
+
*/
|
46
|
+
export declare const findChainMeta: <TBalanceModule extends AnyNewBalanceModule>(moduleType: InferModuleType<TBalanceModule>, chain?: Chain) => InferChainMeta<TBalanceModule> | undefined;
|
19
47
|
export declare const filterMirrorTokens: (balance: Balance, i: number, balances: Balance[]) => boolean;
|
48
|
+
export declare const getValidSubscriptionIds: () => Set<string>;
|
49
|
+
export declare const createSubscriptionId: () => string;
|
50
|
+
export declare const deleteSubscriptionId: () => void;
|
51
|
+
/**
|
52
|
+
* Sets all balance statuses from `live-${string}` to either `live` or `cached`
|
53
|
+
*/
|
54
|
+
export declare const deriveStatuses: (validSubscriptionIds: string[], balances: BalanceJson[]) => BalanceJson[];
|
20
55
|
/**
|
21
56
|
* Used by a variety of balance modules to help encode and decode substrate state calls.
|
22
57
|
*/
|
23
58
|
export declare class StorageHelper {
|
24
59
|
#private;
|
25
60
|
tags: any;
|
26
|
-
constructor(registry:
|
61
|
+
constructor(registry: Registry, module: string, method: string, ...parameters: any[]);
|
27
62
|
get stateKey(): `0x${string}` | undefined;
|
28
63
|
get module(): string;
|
29
64
|
get method(): string;
|
@@ -31,3 +66,21 @@ export declare class StorageHelper {
|
|
31
66
|
tag(tags: any): this;
|
32
67
|
decode(input?: string | null): import("@polkadot/types-codec/types").Codec | undefined;
|
33
68
|
}
|
69
|
+
/**
|
70
|
+
* Pass some these into an `RpcStateQueryHelper` in order to easily batch multiple state queries into the one rpc call.
|
71
|
+
*/
|
72
|
+
export type RpcStateQuery<T> = {
|
73
|
+
chainId: string;
|
74
|
+
stateKey: string;
|
75
|
+
decodeResult: (change: string | null) => T;
|
76
|
+
};
|
77
|
+
/**
|
78
|
+
* Used by a variety of balance modules to help batch multiple state queries into the one rpc call.
|
79
|
+
*/
|
80
|
+
export declare class RpcStateQueryHelper<T> {
|
81
|
+
#private;
|
82
|
+
constructor(chainConnector: ChainConnector, queries: Array<RpcStateQuery<T>>);
|
83
|
+
subscribe(callback: SubscriptionCallback<T[]>, timeout?: number | false, subscribeMethod?: string, responseMethod?: string, unsubscribeMethod?: string): Promise<UnsubscribeFn>;
|
84
|
+
fetch(method?: string): Promise<T[]>;
|
85
|
+
}
|
86
|
+
export {};
|
@@ -61,6 +61,19 @@ export declare class Balances {
|
|
61
61
|
* @returns All balances which match the query.
|
62
62
|
*/
|
63
63
|
find: (query: BalanceSearchQuery | BalanceSearchQuery[]) => Balances;
|
64
|
+
/**
|
65
|
+
* Filters this collection to exclude token balances where the token has a `mirrorOf` field
|
66
|
+
* and another balance exists in this collection for the token specified by the `mirrorOf` field.
|
67
|
+
*/
|
68
|
+
filterMirrorTokens: () => Balances;
|
69
|
+
/**
|
70
|
+
* Filters this collection to only include balances which are not zero.
|
71
|
+
*/
|
72
|
+
filterNonZero: (type: "total" | "free" | "reserved" | "locked" | "frozen" | "transferable" | "feePayable") => Balances;
|
73
|
+
/**
|
74
|
+
* Filters this collection to only include balances which are not zero AND have a fiat conversion rate.
|
75
|
+
*/
|
76
|
+
filterNonZeroFiat: (type: "total" | "free" | "reserved" | "locked" | "frozen" | "transferable" | "feePayable", currency: TokenRateCurrency) => Balances;
|
64
77
|
/**
|
65
78
|
* Add some balances to this collection.
|
66
79
|
* Added balances take priority over existing balances.
|
@@ -80,6 +93,7 @@ export declare class Balances {
|
|
80
93
|
* @returns The new collection of balances.
|
81
94
|
*/
|
82
95
|
remove: (ids: string[] | string) => Balances;
|
96
|
+
get each(): Balance[];
|
83
97
|
/**
|
84
98
|
* Get an array of balances in this collection, sorted by chain sortIndex.
|
85
99
|
*
|
@@ -133,9 +147,21 @@ export declare class Balance {
|
|
133
147
|
get free(): BalanceFormatter;
|
134
148
|
/** The reserved balance of this token. Is included in the total. */
|
135
149
|
get reserved(): BalanceFormatter;
|
150
|
+
get reserves(): {
|
151
|
+
amount: BalanceFormatter;
|
152
|
+
label: string;
|
153
|
+
meta?: unknown;
|
154
|
+
}[];
|
136
155
|
/** The frozen balance of this token. Is included in the free amount. */
|
137
156
|
get locked(): BalanceFormatter;
|
138
|
-
|
157
|
+
get locks(): {
|
158
|
+
amount: BalanceFormatter;
|
159
|
+
label: string;
|
160
|
+
meta?: unknown;
|
161
|
+
includeInTransferable?: boolean | undefined;
|
162
|
+
excludeFromFeePayable?: boolean | undefined;
|
163
|
+
}[];
|
164
|
+
/** @deprecated Use balance.locked */
|
139
165
|
get frozen(): BalanceFormatter;
|
140
166
|
/** The transferable balance of this token. Is generally the free amount - the miscFrozen amount. */
|
141
167
|
get transferable(): BalanceFormatter;
|
@@ -150,6 +176,26 @@ export declare class BalanceFormatter {
|
|
150
176
|
get tokens(): string;
|
151
177
|
fiat(currency: TokenRateCurrency): number | null;
|
152
178
|
}
|
179
|
+
export declare class PlanckSumBalancesFormatter {
|
180
|
+
#private;
|
181
|
+
constructor(balances: Balances);
|
182
|
+
/**
|
183
|
+
* The total balance of these tokens. Includes the free and the reserved amount.
|
184
|
+
*/
|
185
|
+
get total(): bigint;
|
186
|
+
/** The non-reserved balance of these tokens. Includes the frozen amount. Is included in the total. */
|
187
|
+
get free(): bigint;
|
188
|
+
/** The reserved balance of these tokens. Is included in the total. */
|
189
|
+
get reserved(): bigint;
|
190
|
+
/** The frozen balance of these tokens. Is included in the free amount. */
|
191
|
+
get locked(): bigint;
|
192
|
+
/** @deprecated Use balances.locked */
|
193
|
+
get frozen(): bigint;
|
194
|
+
/** The transferable balance of these tokens. Is generally the free amount - the miscFrozen amount. */
|
195
|
+
get transferable(): bigint;
|
196
|
+
/** The feePayable balance of these tokens. Is generally the free amount - the feeFrozen amount. */
|
197
|
+
get feePayable(): bigint;
|
198
|
+
}
|
153
199
|
export declare class FiatSumBalancesFormatter {
|
154
200
|
#private;
|
155
201
|
constructor(balances: Balances, currency: TokenRateCurrency);
|
@@ -163,7 +209,7 @@ export declare class FiatSumBalancesFormatter {
|
|
163
209
|
get reserved(): number;
|
164
210
|
/** The frozen balance of these tokens. Is included in the free amount. */
|
165
211
|
get locked(): number;
|
166
|
-
/** @deprecated
|
212
|
+
/** @deprecated Use balances.locked */
|
167
213
|
get frozen(): number;
|
168
214
|
/** The transferable balance of these tokens. Is generally the free amount - the miscFrozen amount. */
|
169
215
|
get transferable(): number;
|
@@ -173,5 +219,6 @@ export declare class FiatSumBalancesFormatter {
|
|
173
219
|
export declare class SumBalancesFormatter {
|
174
220
|
#private;
|
175
221
|
constructor(balances: Balances);
|
222
|
+
get planck(): PlanckSumBalancesFormatter;
|
176
223
|
fiat(currency: TokenRateCurrency): FiatSumBalancesFormatter;
|
177
224
|
}
|
@@ -23,11 +23,18 @@ export type BalanceTypes = {
|
|
23
23
|
export type BalanceJson = BalanceTypes[keyof BalanceTypes] extends never ? IBalance : BalanceTypes[keyof BalanceTypes];
|
24
24
|
/** A collection of `BalanceJson` objects */
|
25
25
|
export type BalanceJsonList = Record<string, BalanceJson>;
|
26
|
-
export type
|
26
|
+
export type BalanceStatusLive = `live-${string}`;
|
27
|
+
export declare const BalanceStatusLive: (subscriptionId: string) => BalanceStatusLive;
|
28
|
+
export type BalanceStatus = BalanceStatusLive | "live" | "cache" | "stale";
|
27
29
|
/** `IBalance` is a common interface which all balance types must implement. */
|
28
30
|
export type IBalance = {
|
29
31
|
/** The module that this balance was retrieved by */
|
30
32
|
source: string;
|
33
|
+
/**
|
34
|
+
* For modules which fetch balances via module sources, this is the sub-source
|
35
|
+
* e.g. `staking` or `crowdloans`
|
36
|
+
**/
|
37
|
+
subSource?: string;
|
31
38
|
/** Has this balance never been fetched, or is it from a cache, or is it up to date? */
|
32
39
|
status: BalanceStatus;
|
33
40
|
/** The address of the account which owns this balance */
|
@@ -57,6 +64,7 @@ export type Amount = string;
|
|
57
64
|
export type AmountWithLabel<TLabel extends string> = {
|
58
65
|
label: TLabel;
|
59
66
|
amount: Amount;
|
67
|
+
meta?: unknown;
|
60
68
|
};
|
61
69
|
/** A labelled locked amount of a balance */
|
62
70
|
export type LockedAmount<TLabel extends string> = AmountWithLabel<TLabel> & {
|