@talismn/balances 0.2.3 → 0.3.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 +31 -0
- package/dist/{BalanceModule.d.ts → declarations/src/BalanceModule.d.ts} +7 -7
- package/dist/{TalismanBalancesDatabase.d.ts → declarations/src/TalismanBalancesDatabase.d.ts} +0 -0
- package/dist/{helpers.d.ts → declarations/src/helpers.d.ts} +17 -1
- package/dist/{index.d.ts → declarations/src/index.d.ts} +0 -0
- package/dist/{log.d.ts → declarations/src/log.d.ts} +0 -0
- package/dist/{plugins.d.ts → declarations/src/plugins.d.ts} +0 -0
- package/dist/declarations/src/types/addresses.d.ts +4 -0
- package/dist/{types → declarations/src/types}/balances.d.ts +4 -4
- package/dist/{types → declarations/src/types}/balancetypes.d.ts +12 -12
- package/dist/{types → declarations/src/types}/index.d.ts +0 -0
- package/dist/{types → declarations/src/types}/subscriptions.d.ts +1 -1
- package/dist/talismn-balances.cjs.d.ts +1 -0
- package/dist/talismn-balances.cjs.dev.js +705 -0
- package/dist/talismn-balances.cjs.js +7 -0
- package/dist/talismn-balances.cjs.prod.js +705 -0
- package/dist/talismn-balances.esm.js +683 -0
- package/package.json +20 -15
- package/plugins/dist/talismn-balances-plugins.cjs.d.ts +1 -0
- package/plugins/dist/talismn-balances-plugins.cjs.dev.js +2 -0
- package/plugins/dist/talismn-balances-plugins.cjs.js +7 -0
- package/plugins/dist/talismn-balances-plugins.cjs.prod.js +2 -0
- package/plugins/dist/talismn-balances-plugins.esm.js +1 -0
- package/plugins/package.json +2 -3
- package/dist/BalanceModule.js +0 -29
- package/dist/TalismanBalancesDatabase.js +0 -23
- package/dist/helpers.js +0 -11
- package/dist/index.js +0 -31
- package/dist/log.js +0 -10
- package/dist/plugins.js +0 -2
- package/dist/types/addresses.d.ts +0 -4
- package/dist/types/addresses.js +0 -2
- package/dist/types/balances.js +0 -470
- package/dist/types/balancetypes.js +0 -34
- package/dist/types/index.js +0 -20
- package/dist/types/subscriptions.js +0 -2
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,36 @@
|
|
1
1
|
# @talismn/balances
|
2
2
|
|
3
|
+
## 0.3.1
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 8adc7f06: feat: switched build tool to preconstruct
|
8
|
+
- Updated dependencies [8adc7f06]
|
9
|
+
- Updated dependencies [cfe8d276]
|
10
|
+
- @talismn/chain-connector-evm@0.4.1
|
11
|
+
- @talismn/chaindata-provider@0.4.1
|
12
|
+
- @talismn/chain-connector@0.4.1
|
13
|
+
- @talismn/token-rates@0.1.13
|
14
|
+
- @talismn/util@0.1.6
|
15
|
+
|
16
|
+
## 0.3.0
|
17
|
+
|
18
|
+
### Minor Changes
|
19
|
+
|
20
|
+
- a63dbb3: exclude mirror tokens in sums
|
21
|
+
|
22
|
+
### Patch Changes
|
23
|
+
|
24
|
+
- 4aa691d: feat: new balance modules
|
25
|
+
- Updated dependencies [4aa691d]
|
26
|
+
- Updated dependencies [cd6a684]
|
27
|
+
- Updated dependencies [a63dbb3]
|
28
|
+
- @talismn/chain-connector-evm@0.4.0
|
29
|
+
- @talismn/chaindata-provider@0.2.1
|
30
|
+
- @talismn/chain-connector@0.2.1
|
31
|
+
- @talismn/token-rates@0.1.12
|
32
|
+
- @talismn/util@0.1.5
|
33
|
+
|
3
34
|
## 0.2.3
|
4
35
|
|
5
36
|
## 0.2.2
|
@@ -5,20 +5,20 @@ import { AddressesByToken, Balances, SubscriptionCallback, UnsubscribeFn } from
|
|
5
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
6
|
}
|
7
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
|
-
export
|
9
|
-
export
|
10
|
-
export
|
11
|
-
export
|
12
|
-
export
|
8
|
+
export type ExtendableTokenType = IToken;
|
9
|
+
export type ExtendableChainMeta = Record<string, unknown> | undefined;
|
10
|
+
export type DefaultChainMeta = undefined;
|
11
|
+
export type ExtendableModuleConfig = Record<string, unknown> | undefined;
|
12
|
+
export type DefaultModuleConfig = undefined;
|
13
13
|
interface BalanceModuleSubstrate<TModuleType extends string, TTokenType extends ExtendableTokenType, TChainMeta extends ExtendableChainMeta = DefaultChainMeta, TModuleConfig extends ExtendableModuleConfig = DefaultModuleConfig> extends BalanceModuleCommon<TModuleType, TTokenType> {
|
14
14
|
/** Pre-processes any substrate chain metadata required by this module ahead of time */
|
15
|
-
fetchSubstrateChainMeta(chainConnector: ChainConnector, chaindataProvider: ChaindataProvider, chainId: ChainId): Promise<TChainMeta | null>;
|
15
|
+
fetchSubstrateChainMeta(chainConnector: ChainConnector, chaindataProvider: ChaindataProvider, chainId: ChainId, moduleConfig: TModuleConfig | undefined): Promise<TChainMeta | null>;
|
16
16
|
/** Detects which tokens are available on a given substrate chain */
|
17
17
|
fetchSubstrateChainTokens(chainConnector: ChainConnector, chaindataProvider: ChaindataProvider, chainId: ChainId, chainMeta: TChainMeta, moduleConfig: TModuleConfig | undefined): Promise<Record<TTokenType["id"], TTokenType>>;
|
18
18
|
}
|
19
19
|
interface BalanceModuleEvm<TModuleType extends string, TTokenType extends ExtendableTokenType, TChainMeta extends ExtendableChainMeta = DefaultChainMeta, TModuleConfig extends ExtendableModuleConfig = DefaultModuleConfig> extends BalanceModuleCommon<TModuleType, TTokenType> {
|
20
20
|
/** Pre-processes any evm chain metadata required by this module ahead of time */
|
21
|
-
fetchEvmChainMeta(chainConnector: ChainConnectorEvm, chaindataProvider: ChaindataProvider, chainId: ChainId): Promise<TChainMeta | null>;
|
21
|
+
fetchEvmChainMeta(chainConnector: ChainConnectorEvm, chaindataProvider: ChaindataProvider, chainId: ChainId, moduleConfig: TModuleConfig | undefined): Promise<TChainMeta | null>;
|
22
22
|
/** Detects which tokens are available on a given evm chain */
|
23
23
|
fetchEvmChainTokens(chainConnector: ChainConnectorEvm, chaindataProvider: ChaindataProvider, chainId: ChainId, chainMeta: TChainMeta, moduleConfig: TModuleConfig | undefined): Promise<Record<TTokenType["id"], TTokenType>>;
|
24
24
|
}
|
package/dist/{TalismanBalancesDatabase.d.ts → declarations/src/TalismanBalancesDatabase.d.ts}
RENAMED
File without changes
|
@@ -1,8 +1,9 @@
|
|
1
|
+
import { TypeRegistry } from "@polkadot/types";
|
1
2
|
import { ChainConnector } from "@talismn/chain-connector";
|
2
3
|
import { ChainConnectorEvm } from "@talismn/chain-connector-evm";
|
3
4
|
import { ChaindataProvider } from "@talismn/chaindata-provider";
|
4
5
|
import { BalanceModule, DefaultChainMeta, DefaultModuleConfig, ExtendableChainMeta, ExtendableModuleConfig, ExtendableTokenType } from "./BalanceModule";
|
5
|
-
import { AddressesByToken, Balances, SubscriptionCallback, UnsubscribeFn } from "./types";
|
6
|
+
import { AddressesByToken, Balance, Balances, SubscriptionCallback, UnsubscribeFn } from "./types";
|
6
7
|
/**
|
7
8
|
* Wraps a BalanceModule's fetch/subscribe methods with a single `balances` method.
|
8
9
|
* This `balances` method will subscribe if a callback parameter is provided, or otherwise fetch.
|
@@ -15,3 +16,18 @@ export declare function balances<TModuleType extends string, TTokenType extends
|
|
15
16
|
substrate?: ChainConnector;
|
16
17
|
evm?: ChainConnectorEvm;
|
17
18
|
}, chaindataProvider: ChaindataProvider, addressesByToken: AddressesByToken<TTokenType>, callback: SubscriptionCallback<Balances>): Promise<UnsubscribeFn>;
|
19
|
+
export declare const filterMirrorTokens: (balance: Balance, i: number, balances: Balance[]) => boolean;
|
20
|
+
/**
|
21
|
+
* Used by a variety of balance modules to help encode and decode substrate state calls.
|
22
|
+
*/
|
23
|
+
export declare class StorageHelper {
|
24
|
+
#private;
|
25
|
+
tags: any;
|
26
|
+
constructor(registry: TypeRegistry, module: string, method: string, ...parameters: any[]);
|
27
|
+
get stateKey(): `0x${string}` | undefined;
|
28
|
+
get module(): string;
|
29
|
+
get method(): string;
|
30
|
+
get parameters(): any[];
|
31
|
+
tag(tags: any): this;
|
32
|
+
decode(input?: string | null): import("@polkadot/types-codec/types").Codec | undefined;
|
33
|
+
}
|
File without changes
|
File without changes
|
File without changes
|
@@ -7,18 +7,18 @@ import { BalanceJson, BalanceJsonList, IBalance } from "./balancetypes";
|
|
7
7
|
* internal global typescript context, which is then picked up on by this module.
|
8
8
|
*/
|
9
9
|
/** A utility type used to extract the underlying `BalanceType` of a specific source from a generalised `BalanceJson` */
|
10
|
-
export
|
10
|
+
export type NarrowBalanceType<S extends IBalance, P> = S extends {
|
11
11
|
source: P;
|
12
12
|
} ? S : never;
|
13
|
-
export
|
13
|
+
export type BalanceSource = BalanceJson["source"];
|
14
14
|
/** TODO: Remove this in favour of a frontend-friendly `ChaindataProvider` */
|
15
|
-
export
|
15
|
+
export type HydrateDb = Partial<{
|
16
16
|
chains: ChainList;
|
17
17
|
evmNetworks: EvmNetworkList;
|
18
18
|
tokens: TokenList;
|
19
19
|
tokenRates: TokenRatesList;
|
20
20
|
}>;
|
21
|
-
export
|
21
|
+
export type BalanceSearchQuery = Partial<NonFunctionProperties<Balance>> | ((balance: Balance) => boolean);
|
22
22
|
/**
|
23
23
|
* A collection of balances.
|
24
24
|
*/
|
@@ -1,12 +1,12 @@
|
|
1
|
+
import { PluginBalanceTypes } from "@talismn/balances/plugins";
|
1
2
|
import { ChainId, EvmNetworkId, MultiChainId, TokenId } from "@talismn/chaindata-provider";
|
2
|
-
import { PluginBalanceTypes } from "../plugins";
|
3
3
|
import { Address } from "./addresses";
|
4
4
|
/**
|
5
5
|
* `BalanceTypes` is an automatically determined sub-selection of `PluginBalanceTypes`.
|
6
6
|
*
|
7
7
|
* It is the same list, but with any invalid `BalanceType` definitions filtered out.
|
8
8
|
*/
|
9
|
-
export
|
9
|
+
export type BalanceTypes = {
|
10
10
|
[BalanceType in keyof PluginBalanceTypes]: PluginBalanceTypes[BalanceType] extends IBalance ? PluginBalanceTypes[BalanceType] : never;
|
11
11
|
};
|
12
12
|
/**
|
@@ -20,12 +20,12 @@ export declare type BalanceTypes = {
|
|
20
20
|
*
|
21
21
|
* If `BalanceTypes` is empty then `BalanceJson` will fall back to the common `IBalance` interface, which every balance must implement.
|
22
22
|
*/
|
23
|
-
export
|
23
|
+
export type BalanceJson = BalanceTypes[keyof BalanceTypes] extends never ? IBalance : BalanceTypes[keyof BalanceTypes];
|
24
24
|
/** A collection of `BalanceJson` objects */
|
25
|
-
export
|
26
|
-
export
|
25
|
+
export type BalanceJsonList = Record<string, BalanceJson>;
|
26
|
+
export type BalanceStatus = "live" | "cache";
|
27
27
|
/** `IBalance` is a common interface which all balance types must implement. */
|
28
|
-
export
|
28
|
+
export type IBalance = {
|
29
29
|
/** The module that this balance was retrieved by */
|
30
30
|
source: string;
|
31
31
|
/** Has this balance never been fetched, or is it from a cache, or is it up to date? */
|
@@ -41,7 +41,7 @@ export declare type IBalance = {
|
|
41
41
|
/** The evm chain this balance is on */
|
42
42
|
evmNetworkId?: EvmNetworkId;
|
43
43
|
} & IBalanceAmounts;
|
44
|
-
export
|
44
|
+
export type IBalanceAmounts = {
|
45
45
|
/** The portion of a balance that is not reserved. The free balance is the only balance that matters for most operations. */
|
46
46
|
free?: Amount | AmountWithLabel<string> | Array<AmountWithLabel<string>>;
|
47
47
|
/** The portion of a balance that is owned by the account but is reserved/suspended/unavailable. Reserved balance can still be slashed, but only after all the free balance has been slashed. */
|
@@ -52,14 +52,14 @@ export declare type IBalanceAmounts = {
|
|
52
52
|
extra?: ExtraAmount<string> | Array<ExtraAmount<string>>;
|
53
53
|
};
|
54
54
|
/** An unlabelled amount of a balance */
|
55
|
-
export
|
55
|
+
export type Amount = string;
|
56
56
|
/** A labelled amount of a balance */
|
57
|
-
export
|
57
|
+
export type AmountWithLabel<TLabel extends string> = {
|
58
58
|
label: TLabel;
|
59
59
|
amount: Amount;
|
60
60
|
};
|
61
61
|
/** A labelled locked amount of a balance */
|
62
|
-
export
|
62
|
+
export type LockedAmount<TLabel extends string> = AmountWithLabel<TLabel> & {
|
63
63
|
/**
|
64
64
|
* By default, the largest locked amount is subtrated from the transferable amount of this balance.
|
65
65
|
* If this property is set to true, this particular lock will be skipped when making this calculation.
|
@@ -77,12 +77,12 @@ export declare type LockedAmount<TLabel extends string> = AmountWithLabel<TLabel
|
|
77
77
|
export declare function excludeFromTransferableAmount(locks: Amount | LockedAmount<string> | Array<LockedAmount<string>>): bigint;
|
78
78
|
export declare function excludeFromFeePayableLocks(locks: Amount | LockedAmount<string> | Array<LockedAmount<string>>): Array<LockedAmount<string>>;
|
79
79
|
/** A labelled extra amount of a balance */
|
80
|
-
export
|
80
|
+
export type ExtraAmount<TLabel extends string> = AmountWithLabel<TLabel> & {
|
81
81
|
/** If set to true, this extra amount will be included in the calculation of the total amount of this balance. */
|
82
82
|
includeInTotal?: boolean;
|
83
83
|
};
|
84
84
|
export declare function includeInTotalExtraAmount(extra?: ExtraAmount<string> | Array<ExtraAmount<string>>): bigint;
|
85
85
|
/** Used by plugins to help define their custom `BalanceType` */
|
86
|
-
export
|
86
|
+
export type NewBalanceType<TModuleType extends string, T extends IBalanceAmounts> = IBalance & {
|
87
87
|
source: TModuleType;
|
88
88
|
} & T;
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./declarations/src/index";
|