@talismn/balances 0.3.0 → 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.
Files changed (36) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/{BalanceModule.d.ts → declarations/src/BalanceModule.d.ts} +5 -5
  3. package/dist/{TalismanBalancesDatabase.d.ts → declarations/src/TalismanBalancesDatabase.d.ts} +0 -0
  4. package/dist/{helpers.d.ts → declarations/src/helpers.d.ts} +0 -0
  5. package/dist/{index.d.ts → declarations/src/index.d.ts} +0 -0
  6. package/dist/{log.d.ts → declarations/src/log.d.ts} +0 -0
  7. package/dist/{plugins.d.ts → declarations/src/plugins.d.ts} +0 -0
  8. package/dist/declarations/src/types/addresses.d.ts +4 -0
  9. package/dist/{types → declarations/src/types}/balances.d.ts +4 -4
  10. package/dist/{types → declarations/src/types}/balancetypes.d.ts +12 -12
  11. package/dist/{types → declarations/src/types}/index.d.ts +0 -0
  12. package/dist/{types → declarations/src/types}/subscriptions.d.ts +1 -1
  13. package/dist/talismn-balances.cjs.d.ts +1 -0
  14. package/dist/talismn-balances.cjs.dev.js +705 -0
  15. package/dist/talismn-balances.cjs.js +7 -0
  16. package/dist/talismn-balances.cjs.prod.js +705 -0
  17. package/dist/talismn-balances.esm.js +683 -0
  18. package/package.json +20 -15
  19. package/plugins/dist/talismn-balances-plugins.cjs.d.ts +1 -0
  20. package/plugins/dist/talismn-balances-plugins.cjs.dev.js +2 -0
  21. package/plugins/dist/talismn-balances-plugins.cjs.js +7 -0
  22. package/plugins/dist/talismn-balances-plugins.cjs.prod.js +2 -0
  23. package/plugins/dist/talismn-balances-plugins.esm.js +1 -0
  24. package/plugins/package.json +2 -3
  25. package/dist/BalanceModule.js +0 -29
  26. package/dist/TalismanBalancesDatabase.js +0 -23
  27. package/dist/helpers.js +0 -99
  28. package/dist/index.js +0 -31
  29. package/dist/log.js +0 -10
  30. package/dist/plugins.js +0 -2
  31. package/dist/types/addresses.d.ts +0 -4
  32. package/dist/types/addresses.js +0 -2
  33. package/dist/types/balances.js +0 -471
  34. package/dist/types/balancetypes.js +0 -34
  35. package/dist/types/index.js +0 -20
  36. package/dist/types/subscriptions.js +0 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
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
+
3
16
  ## 0.3.0
4
17
 
5
18
  ### Minor Changes
@@ -5,11 +5,11 @@ 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 declare type ExtendableTokenType = IToken;
9
- export declare type ExtendableChainMeta = Record<string, unknown> | undefined;
10
- export declare type DefaultChainMeta = undefined;
11
- export declare type ExtendableModuleConfig = Record<string, unknown> | undefined;
12
- export declare type DefaultModuleConfig = undefined;
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
15
  fetchSubstrateChainMeta(chainConnector: ChainConnector, chaindataProvider: ChaindataProvider, chainId: ChainId, moduleConfig: TModuleConfig | undefined): Promise<TChainMeta | null>;
File without changes
File without changes
@@ -0,0 +1,4 @@
1
+ export type Address = string;
2
+ export type AddressesByToken<TTokenType extends {
3
+ id: string;
4
+ }> = Record<TTokenType["id"], Address[]>;
@@ -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 declare type NarrowBalanceType<S extends IBalance, P> = S extends {
10
+ export type NarrowBalanceType<S extends IBalance, P> = S extends {
11
11
  source: P;
12
12
  } ? S : never;
13
- export declare type BalanceSource = BalanceJson["source"];
13
+ export type BalanceSource = BalanceJson["source"];
14
14
  /** TODO: Remove this in favour of a frontend-friendly `ChaindataProvider` */
15
- export declare type HydrateDb = Partial<{
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 declare type BalanceSearchQuery = Partial<NonFunctionProperties<Balance>> | ((balance: Balance) => boolean);
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 declare type BalanceTypes = {
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 declare type BalanceJson = BalanceTypes[keyof BalanceTypes] extends never ? IBalance : BalanceTypes[keyof BalanceTypes];
23
+ export type BalanceJson = BalanceTypes[keyof BalanceTypes] extends never ? IBalance : BalanceTypes[keyof BalanceTypes];
24
24
  /** A collection of `BalanceJson` objects */
25
- export declare type BalanceJsonList = Record<string, BalanceJson>;
26
- export declare type BalanceStatus = "live" | "cache";
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 declare type IBalance = {
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 declare type IBalanceAmounts = {
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 declare type Amount = string;
55
+ export type Amount = string;
56
56
  /** A labelled amount of a balance */
57
- export declare type AmountWithLabel<TLabel extends string> = {
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 declare type LockedAmount<TLabel extends string> = AmountWithLabel<TLabel> & {
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 declare type ExtraAmount<TLabel extends string> = AmountWithLabel<TLabel> & {
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 declare type NewBalanceType<TModuleType extends string, T extends IBalanceAmounts> = IBalance & {
86
+ export type NewBalanceType<TModuleType extends string, T extends IBalanceAmounts> = IBalance & {
87
87
  source: TModuleType;
88
88
  } & T;
@@ -8,4 +8,4 @@ export interface SubscriptionCallback<Result> {
8
8
  /**
9
9
  * A function which cancels a subscription when called.
10
10
  */
11
- export declare type UnsubscribeFn = () => void;
11
+ export type UnsubscribeFn = () => void;
@@ -0,0 +1 @@
1
+ export * from "./declarations/src/index";