@talismn/balances 0.6.0 → 0.6.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 +41 -0
- package/README.md +126 -0
- package/dist/declarations/src/BalanceModule.d.ts +4 -6
- package/dist/declarations/src/MiniMetadataUpdater.d.ts +44 -0
- package/dist/declarations/src/TalismanBalancesDatabase.d.ts +2 -1
- package/dist/declarations/src/index.d.ts +2 -1
- package/dist/declarations/src/modules/EvmErc20Module.d.ts +43 -0
- package/dist/declarations/src/modules/EvmNativeModule.d.ts +37 -0
- package/dist/declarations/src/modules/SubstrateAssetsModule.d.ts +51 -0
- package/dist/declarations/src/modules/SubstrateEquilibriumModule.d.ts +50 -0
- package/dist/declarations/src/modules/SubstrateNativeModule.d.ts +65 -0
- package/dist/declarations/src/modules/SubstratePsp22Module.d.ts +50 -0
- package/dist/declarations/src/modules/SubstrateTokensModule.d.ts +54 -0
- package/dist/declarations/src/modules/abis/erc20.d.ts +227 -0
- package/dist/declarations/src/modules/abis/multicall.d.ts +276 -0
- package/dist/declarations/src/modules/index.d.ts +10 -0
- package/dist/declarations/src/{helpers.d.ts → modules/util/index.d.ts} +33 -6
- package/dist/declarations/src/modules/util/substrate-native.d.ts +33 -0
- package/dist/declarations/src/types/balances.d.ts +3 -2
- package/dist/declarations/src/types/balancetypes.d.ts +3 -3
- package/dist/declarations/src/types/index.d.ts +1 -0
- package/dist/declarations/src/types/minimetadatas.d.ts +33 -0
- package/dist/talismn-balances.cjs.dev.js +4899 -332
- package/dist/talismn-balances.cjs.prod.js +4899 -332
- package/dist/talismn-balances.esm.js +4853 -334
- package/package.json +28 -14
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,46 @@
|
|
1
1
|
# @talismn/balances
|
2
2
|
|
3
|
+
## 0.6.1
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 771a5be: fix: incorrect cached/stale balances for evm accounts
|
8
|
+
- d2ccdaf: fix: balance subscriptions never update registry cache with new metadata
|
9
|
+
- 372f995: replace ethers by viem
|
10
|
+
- c4d5967: bump typescript version
|
11
|
+
- a916db0: docs: added @talismn/balances readme
|
12
|
+
- a3a1bd7: feat: psp22 balances module
|
13
|
+
- c36375f: Use Balances::transfer_allow_death as default method for substrate balance transfers
|
14
|
+
- 620b7eb: Dependency updates
|
15
|
+
- 5aadf99: fix: renamed renamed Unknown -> Unit for tokens with no symbol
|
16
|
+
- 5aadf99: feat: native token balances on custom networks
|
17
|
+
- Updated dependencies [123647e]
|
18
|
+
- Updated dependencies [03939d5]
|
19
|
+
- Updated dependencies [d2ccdaf]
|
20
|
+
- Updated dependencies [123647e]
|
21
|
+
- Updated dependencies [be0d19e]
|
22
|
+
- Updated dependencies [e0eb84a]
|
23
|
+
- Updated dependencies [ade2908]
|
24
|
+
- Updated dependencies [372f995]
|
25
|
+
- Updated dependencies [c4d5967]
|
26
|
+
- Updated dependencies [776432e]
|
27
|
+
- Updated dependencies [23f0d3a]
|
28
|
+
- Updated dependencies [e0eb84a]
|
29
|
+
- Updated dependencies [620b7eb]
|
30
|
+
- Updated dependencies [850381a]
|
31
|
+
- Updated dependencies [5aadf99]
|
32
|
+
- Updated dependencies [4cace80]
|
33
|
+
- Updated dependencies [a6c1b2a]
|
34
|
+
- Updated dependencies [372f995]
|
35
|
+
- Updated dependencies [9ebcd93]
|
36
|
+
- @talismn/token-rates@0.3.0
|
37
|
+
- @talismn/chaindata-provider@0.8.0
|
38
|
+
- @talismn/chaindata-provider-extension@0.8.0
|
39
|
+
- @talismn/chain-connector-evm@0.8.0
|
40
|
+
- @talismn/chain-connector@0.8.0
|
41
|
+
- @talismn/util@0.2.1
|
42
|
+
- @talismn/scale@0.0.2
|
43
|
+
|
3
44
|
## 0.6.0
|
4
45
|
|
5
46
|
### Minor Changes
|
package/README.md
CHANGED
@@ -1 +1,127 @@
|
|
1
1
|
# @talismn/balances
|
2
|
+
|
3
|
+
<img src="talisman.svg" alt="Talisman" width="15%" align="right" />
|
4
|
+
|
5
|
+
[](https://github.com/TalismanSociety/talisman/blob/dev/LICENSE)
|
6
|
+
[](https://www.npmjs.com/package/@talismn/balances)
|
7
|
+
[](https://www.npmjs.com/package/@talismn/balances)
|
8
|
+
[](https://discord.gg/talisman)
|
9
|
+
|
10
|
+
**@talismn/balances** is the core of a set of packages used to subscribe to on-chain account token balances.
|
11
|
+
|
12
|
+
A quick rundown on each package is given below.
|
13
|
+
|
14
|
+
### This (the core) package:
|
15
|
+
|
16
|
+
**@talismn/balances** (this package) includes:
|
17
|
+
|
18
|
+
- An API which wallets / dapps can use to access balances
|
19
|
+
- An interface for balance modules to implement
|
20
|
+
- A shared database (powered by dexie) for balance modules to store balances in
|
21
|
+
- Helpers (utility functions) for balance modules to use
|
22
|
+
- Provides a plugin architecture, which is used by the balance module packages to specify their balance types
|
23
|
+
|
24
|
+
### The react API for wallets & dapps:
|
25
|
+
|
26
|
+
**@talismn/balances-react** includes:
|
27
|
+
|
28
|
+
- React hooks for subscribing to on-chain account token balances
|
29
|
+
- (soon™): recoil atoms for on-chain account token balances
|
30
|
+
|
31
|
+
### The balance modules:
|
32
|
+
|
33
|
+
**@talismn/balances-default-modules**
|
34
|
+
|
35
|
+
- Collates the default balance modules (which can be found below) into a single package
|
36
|
+
|
37
|
+
**@talismn/substrate-native**
|
38
|
+
|
39
|
+
- A balance module for substrate native tokens
|
40
|
+
- Subscribes to the `system.account` state query balance for each token
|
41
|
+
- Also subscribes to the crowdloans pallet balances
|
42
|
+
- Also subscribes to the nompools pallet balances
|
43
|
+
|
44
|
+
**@talismn/substrate-orml**
|
45
|
+
|
46
|
+
- A proof-of-concept balance module for ORML token pallet tokens
|
47
|
+
- Attempts to auto-detect tokens
|
48
|
+
- **You should use @talismn/substrate-tokens instead**
|
49
|
+
|
50
|
+
**@talismn/substrate-tokens**
|
51
|
+
|
52
|
+
- A balance module for substrate ORML token pallet tokens
|
53
|
+
- Supports any token which can be queried via the `tokens.accounts` state query
|
54
|
+
- Requires configuration for each token (no auto-detection)
|
55
|
+
- We recommend that you use this module for ORML tokens
|
56
|
+
|
57
|
+
**@talismn/substrate-assets**
|
58
|
+
|
59
|
+
- A balance module for substrate assets pallet tokens
|
60
|
+
- Supports any token which can be queried via the `assets.account` state query
|
61
|
+
- Requires configuration for each token (no auto-detection)
|
62
|
+
|
63
|
+
**@talismn/substrate-equilibrium**
|
64
|
+
|
65
|
+
- A balance module for substrate eqBalances pallet tokens
|
66
|
+
- Used by [Equilibrium](https://equilibrium.io/) and [Genshiro](https://genshiro.io/)
|
67
|
+
- Supports auto-detection
|
68
|
+
|
69
|
+
**@talismn/evm-native**
|
70
|
+
|
71
|
+
- A balance module for evm native tokens
|
72
|
+
|
73
|
+
**@talismn/evm-erc20**
|
74
|
+
|
75
|
+
- A balance module for evm erc20 tokens
|
76
|
+
|
77
|
+
### The chain connectors:
|
78
|
+
|
79
|
+
**@talismn/chain-connector**
|
80
|
+
|
81
|
+
- A package which manages the open RPC connections to substrate chains
|
82
|
+
- Allows developers to say "Send this query to the chain with this id", without them needing to specify which RPCs to use
|
83
|
+
- Ensures that connections are only opened to the chains which are in use by the wallet/dapp
|
84
|
+
- Ensures that only one connection is open per chain
|
85
|
+
- Handles exponential backoff in the case of network failures
|
86
|
+
- Provides an interface which can be shared between a serviceworker and frontend, which enables the two to share the pool of open connections
|
87
|
+
- Provides an interface which mimics a polkadot-js `WsProvider`, which can be plugged into polkadot-js to make it use the shared pool of open connections
|
88
|
+
|
89
|
+
**@talismn/chain-connector-evm**
|
90
|
+
|
91
|
+
- A package which manages the connections to evm chains
|
92
|
+
- Allows developers to say "Send this query to the chain with this id", without them needing to specify which RPC to use
|
93
|
+
|
94
|
+
### The chaindata provider:
|
95
|
+
|
96
|
+
Currently split into two packages because we initially intended to write several implementations of the chaindata interface.
|
97
|
+
Will be merged into one package soon™.
|
98
|
+
|
99
|
+
**@talismn/chaindata-provider** and **@talismn/chaindata-provider-extension**
|
100
|
+
|
101
|
+
- A database (powered by dexie) to store chains, evm chains and tokens in
|
102
|
+
- An interface to interact with the database
|
103
|
+
- Syncs with the list in the [chaindata repository](https://github.com/talismansociety/chaindata) via graphql
|
104
|
+
- Supports custom (end-user-defined) chains and rpc overrides
|
105
|
+
- Provides a plugin architecture, which is used by the balance module packages to specify their token types
|
106
|
+
|
107
|
+
### The remaining packages:
|
108
|
+
|
109
|
+
**@talismn/connection-meta**
|
110
|
+
|
111
|
+
- Contains a small db which is used to optimise network performance in the wallet.
|
112
|
+
- Two metrics are kept:
|
113
|
+
- chainPriorityRpc (the last known well-behaved RPC for a chain)
|
114
|
+
- chainBackoffInterval (the amount of time the wallet should wait before attempting to connect to a unreachable chain again)
|
115
|
+
|
116
|
+
**@talismn/mutate-metadata**
|
117
|
+
|
118
|
+
- A package which can splice a chain's metadata into smaller pieces
|
119
|
+
- Enables us to make state queries across many chains at once without using all of the browser's memory
|
120
|
+
|
121
|
+
**@talismn/token-rates**
|
122
|
+
|
123
|
+
- Fetches and stores coingecko rates for each token in the @talismn/chaindata-provider database
|
124
|
+
|
125
|
+
**@talismn/util**
|
126
|
+
|
127
|
+
- Utility functions shared by the other packages, as well as the wallet and the portal
|
@@ -2,8 +2,7 @@ import { UnsignedTransaction } from "@substrate/txwrapper-core";
|
|
2
2
|
import { ChainConnector } from "@talismn/chain-connector";
|
3
3
|
import { ChainConnectorEvm } from "@talismn/chain-connector-evm";
|
4
4
|
import { ChainId, ChaindataProvider, IToken } from "@talismn/chaindata-provider";
|
5
|
-
import {
|
6
|
-
import { AddressesByToken, Balances, SubscriptionCallback, UnsubscribeFn } from "./types";
|
5
|
+
import { Address, AddressesByToken, BalanceJson, Balances, SubscriptionCallback, UnsubscribeFn } from "./types";
|
7
6
|
export type ExtendableTokenType = IToken;
|
8
7
|
export type ExtendableChainMeta = Record<string, unknown> | undefined;
|
9
8
|
export type DefaultChainMeta = undefined;
|
@@ -21,9 +20,6 @@ export type NewTransferParamsType<T extends Record<string, unknown>> = BaseTrans
|
|
21
20
|
export type TransferTokenTx = {
|
22
21
|
type: "substrate";
|
23
22
|
tx: UnsignedTransaction;
|
24
|
-
} | {
|
25
|
-
type: "evm";
|
26
|
-
tx: ethers.providers.TransactionRequest;
|
27
23
|
};
|
28
24
|
export type ChainConnectors = {
|
29
25
|
substrate?: ChainConnector;
|
@@ -39,7 +35,7 @@ export interface BalanceModule<TModuleType extends string, TTokenType extends Ex
|
|
39
35
|
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
36
|
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> {
|
41
37
|
/** Pre-processes any substrate chain metadata required by this module ahead of time */
|
42
|
-
fetchSubstrateChainMeta(chainId: ChainId, moduleConfig?: TModuleConfig): Promise<TChainMeta | null>;
|
38
|
+
fetchSubstrateChainMeta(chainId: ChainId, moduleConfig?: TModuleConfig, metadataRpc?: `0x${string}`): Promise<TChainMeta | null>;
|
43
39
|
/** Detects which tokens are available on a given substrate chain */
|
44
40
|
fetchSubstrateChainTokens(chainId: ChainId, chainMeta: TChainMeta, moduleConfig?: TModuleConfig): Promise<Record<TTokenType["id"], TTokenType>>;
|
45
41
|
}
|
@@ -57,6 +53,8 @@ interface BalanceModuleCommon<TModuleType extends string, TTokenType extends Ext
|
|
57
53
|
* If subscriptions are not possible, this function should poll at some reasonable interval.
|
58
54
|
*/
|
59
55
|
subscribeBalances(addressesByToken: AddressesByToken<TTokenType>, callback: SubscriptionCallback<Balances>): Promise<UnsubscribeFn>;
|
56
|
+
/** Used to provision balances in db while they are fetching for the first time */
|
57
|
+
getPlaceholderBalance(tokenId: TTokenType["id"], address: Address): BalanceJson;
|
60
58
|
/** Fetch balances for this module with optional filtering */
|
61
59
|
fetchBalances(addressesByToken: AddressesByToken<TTokenType>): Promise<Balances>;
|
62
60
|
/** Prepare a tx to transfer some tokens from this module */
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import { Chain, ChainId, EvmNetworkId } from "@talismn/chaindata-provider";
|
2
|
+
import { ChaindataProviderExtension } from "@talismn/chaindata-provider-extension";
|
3
|
+
import { ChainConnectors } from "./BalanceModule";
|
4
|
+
import { AnyBalanceModule } from "./modules/util";
|
5
|
+
import { MiniMetadata, MiniMetadataStatus } from "./types";
|
6
|
+
/**
|
7
|
+
* A substrate dapp needs access to a set of types when it wants to communicate with a blockchain node.
|
8
|
+
*
|
9
|
+
* These types are used to encode requests & decode responses via the SCALE codec.
|
10
|
+
* Each chain generally has its own set of types.
|
11
|
+
*
|
12
|
+
* Substrate provides a construct to retrieve these types from a blockchain node.
|
13
|
+
* The chain metadata.
|
14
|
+
*
|
15
|
+
* The metadata includes the types required for any communication with the chain,
|
16
|
+
* including lots of methods which are not relevant to balance fetching.
|
17
|
+
*
|
18
|
+
* As such, the metadata can clock in at around 1-2MB per chain, which is a lot of storage
|
19
|
+
* for browser-based dapps which want to connect to lots of chains.
|
20
|
+
*
|
21
|
+
* By utilizing the wonderful [subshape](https://github.com/paritytech/subshape) library,
|
22
|
+
* we can trim the chain metadata down so that it only includes the types we need for balance fetching.
|
23
|
+
*
|
24
|
+
* Each balance module has a function to do just that, `BalanceModule::fetchSubstrateChainMeta`.
|
25
|
+
*
|
26
|
+
* But, we only want to run this operation when necessary.
|
27
|
+
*
|
28
|
+
* The purpose of this class, `MiniMetadataUpdater`, is to maintain a local cache of
|
29
|
+
* trimmed-down metadatas, which we'll refer to as `MiniMetadatas`.
|
30
|
+
*/
|
31
|
+
export declare class MiniMetadataUpdater {
|
32
|
+
#private;
|
33
|
+
constructor(chainConnectors: ChainConnectors, chaindataProvider: ChaindataProviderExtension, balanceModules: Array<AnyBalanceModule>);
|
34
|
+
/** Subscribe to the metadata for a chain */
|
35
|
+
subscribe(chainId: ChainId): import("rxjs").Observable<MiniMetadata>;
|
36
|
+
update(chainIds: ChainId[], evmNetworkIds: EvmNetworkId[]): Promise<void>;
|
37
|
+
statuses(chains: Array<Pick<Chain, "id" | "specName" | "specVersion" | "balancesConfig">>): Promise<{
|
38
|
+
wantedIdsByChain: Map<string, string[]>;
|
39
|
+
statusesByChain: Map<string, MiniMetadataStatus>;
|
40
|
+
}>;
|
41
|
+
hydrateFromChaindata(): Promise<boolean>;
|
42
|
+
private updateSubstrateChains;
|
43
|
+
private updateEvmNetworks;
|
44
|
+
}
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import { Dexie } from "dexie";
|
2
|
-
import { BalanceJson } from "./types";
|
2
|
+
import { BalanceJson, MiniMetadata } from "./types";
|
3
3
|
export declare class TalismanBalancesDatabase extends Dexie {
|
4
4
|
balances: Dexie.Table<BalanceJson, string>;
|
5
|
+
miniMetadatas: Dexie.Table<MiniMetadata, string>;
|
5
6
|
constructor();
|
6
7
|
}
|
7
8
|
export declare const db: TalismanBalancesDatabase;
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import { BalancesConfigTokenParams, EvmChainId, EvmNetworkId, NewTokenType } from "@talismn/chaindata-provider";
|
2
|
+
import { NewBalanceModule } from "../BalanceModule";
|
3
|
+
import { Amount, NewBalanceType } from "../types";
|
4
|
+
import { erc20Abi } from "./abis/erc20";
|
5
|
+
export { erc20Abi };
|
6
|
+
type ModuleType = "evm-erc20";
|
7
|
+
export declare const evmErc20TokenId: (chainId: EvmNetworkId, tokenContractAddress: EvmErc20Token["contractAddress"]) => string;
|
8
|
+
export type EvmErc20Token = NewTokenType<ModuleType, {
|
9
|
+
contractAddress: string;
|
10
|
+
evmNetwork: {
|
11
|
+
id: EvmNetworkId;
|
12
|
+
} | null;
|
13
|
+
}>;
|
14
|
+
export type CustomEvmErc20Token = EvmErc20Token & {
|
15
|
+
isCustom: true;
|
16
|
+
image?: string;
|
17
|
+
};
|
18
|
+
declare module "@talismn/chaindata-provider/plugins" {
|
19
|
+
interface PluginTokenTypes {
|
20
|
+
EvmErc20Token: EvmErc20Token;
|
21
|
+
CustomEvmErc20Token: CustomEvmErc20Token;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
export type EvmErc20ChainMeta = {
|
25
|
+
isTestnet: boolean;
|
26
|
+
};
|
27
|
+
export type EvmErc20ModuleConfig = {
|
28
|
+
tokens?: Array<{
|
29
|
+
symbol?: string;
|
30
|
+
decimals?: number;
|
31
|
+
contractAddress?: string;
|
32
|
+
} & BalancesConfigTokenParams>;
|
33
|
+
};
|
34
|
+
export type EvmErc20Balance = NewBalanceType<ModuleType, {
|
35
|
+
multiChainId: EvmChainId;
|
36
|
+
free: Amount;
|
37
|
+
}>;
|
38
|
+
declare module "@talismn/balances/plugins" {
|
39
|
+
interface PluginBalanceTypes {
|
40
|
+
EvmErc20Balance: EvmErc20Balance;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
export declare const EvmErc20Module: NewBalanceModule<ModuleType, EvmErc20Token | CustomEvmErc20Token, EvmErc20ChainMeta, EvmErc20ModuleConfig>;
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { BalancesConfigTokenParams, EvmChainId, EvmNetworkId, NewTokenType } from "@talismn/chaindata-provider";
|
2
|
+
import { NewBalanceModule } from "../BalanceModule";
|
3
|
+
import { Amount, NewBalanceType } from "../types";
|
4
|
+
type ModuleType = "evm-native";
|
5
|
+
export declare const evmNativeTokenId: (chainId: EvmNetworkId, tokenSymbol: string) => string;
|
6
|
+
export type EvmNativeToken = NewTokenType<ModuleType, {
|
7
|
+
evmNetwork: {
|
8
|
+
id: EvmNetworkId;
|
9
|
+
};
|
10
|
+
}>;
|
11
|
+
export type CustomEvmNativeToken = EvmNativeToken & {
|
12
|
+
isCustom: true;
|
13
|
+
};
|
14
|
+
declare module "@talismn/chaindata-provider/plugins" {
|
15
|
+
interface PluginTokenTypes {
|
16
|
+
EvmNativeToken: EvmNativeToken;
|
17
|
+
CustomEvmNativeToken: CustomEvmNativeToken;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
export type EvmNativeChainMeta = {
|
21
|
+
isTestnet: boolean;
|
22
|
+
};
|
23
|
+
export type EvmNativeModuleConfig = {
|
24
|
+
symbol?: string;
|
25
|
+
decimals?: number;
|
26
|
+
} & BalancesConfigTokenParams;
|
27
|
+
export type EvmNativeBalance = NewBalanceType<ModuleType, {
|
28
|
+
multiChainId: EvmChainId;
|
29
|
+
free: Amount;
|
30
|
+
}>;
|
31
|
+
declare module "@talismn/balances/plugins" {
|
32
|
+
interface PluginBalanceTypes {
|
33
|
+
EvmNativeBalance: EvmNativeBalance;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
export declare const EvmNativeModule: NewBalanceModule<ModuleType, EvmNativeToken | CustomEvmNativeToken, EvmNativeChainMeta, EvmNativeModuleConfig>;
|
37
|
+
export {};
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import { TypeRegistry } from "@polkadot/types";
|
2
|
+
import { BalancesConfigTokenParams, ChainId, NewTokenType, SubChainId } from "@talismn/chaindata-provider";
|
3
|
+
import { NewBalanceModule, NewTransferParamsType } from "../BalanceModule";
|
4
|
+
import { Amount, NewBalanceType } from "../types";
|
5
|
+
type ModuleType = "substrate-assets";
|
6
|
+
export type SubAssetsToken = NewTokenType<ModuleType, {
|
7
|
+
existentialDeposit: string;
|
8
|
+
assetId: string;
|
9
|
+
isFrozen: boolean;
|
10
|
+
chain: {
|
11
|
+
id: ChainId;
|
12
|
+
};
|
13
|
+
}>;
|
14
|
+
declare module "@talismn/chaindata-provider/plugins" {
|
15
|
+
interface PluginTokenTypes {
|
16
|
+
SubAssetsToken: SubAssetsToken;
|
17
|
+
}
|
18
|
+
}
|
19
|
+
export type SubAssetsChainMeta = {
|
20
|
+
isTestnet: boolean;
|
21
|
+
miniMetadata: `0x${string}` | null;
|
22
|
+
metadataVersion: number;
|
23
|
+
};
|
24
|
+
export type SubAssetsModuleConfig = {
|
25
|
+
tokens?: Array<{
|
26
|
+
assetId: string | number;
|
27
|
+
} & BalancesConfigTokenParams>;
|
28
|
+
};
|
29
|
+
export type SubAssetsBalance = NewBalanceType<ModuleType, {
|
30
|
+
multiChainId: SubChainId;
|
31
|
+
free: Amount;
|
32
|
+
locks: Amount;
|
33
|
+
}>;
|
34
|
+
declare module "@talismn/balances/plugins" {
|
35
|
+
interface PluginBalanceTypes {
|
36
|
+
SubAssetsBalance: SubAssetsBalance;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
export type SubAssetsTransferParams = NewTransferParamsType<{
|
40
|
+
registry: TypeRegistry;
|
41
|
+
metadataRpc: `0x${string}`;
|
42
|
+
blockHash: string;
|
43
|
+
blockNumber: number;
|
44
|
+
nonce: number;
|
45
|
+
specVersion: number;
|
46
|
+
transactionVersion: number;
|
47
|
+
tip?: string;
|
48
|
+
transferMethod: "transfer" | "transferKeepAlive" | "transferAll";
|
49
|
+
}>;
|
50
|
+
export declare const SubAssetsModule: NewBalanceModule<ModuleType, SubAssetsToken, SubAssetsChainMeta, SubAssetsModuleConfig, SubAssetsTransferParams>;
|
51
|
+
export {};
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import { TypeRegistry } from "@polkadot/types";
|
2
|
+
import { BalancesConfigTokenParams, ChainId, NewTokenType, SubChainId } from "@talismn/chaindata-provider";
|
3
|
+
import { NewBalanceModule, NewTransferParamsType } from "../BalanceModule";
|
4
|
+
import { Amount, NewBalanceType } from "../types";
|
5
|
+
type ModuleType = "substrate-equilibrium";
|
6
|
+
export type SubEquilibriumToken = NewTokenType<ModuleType, {
|
7
|
+
existentialDeposit: string;
|
8
|
+
assetId: string;
|
9
|
+
chain: {
|
10
|
+
id: ChainId;
|
11
|
+
};
|
12
|
+
}>;
|
13
|
+
declare module "@talismn/chaindata-provider/plugins" {
|
14
|
+
interface PluginTokenTypes {
|
15
|
+
SubEquilibriumToken: SubEquilibriumToken;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
export type SubEquilibriumChainMeta = {
|
19
|
+
isTestnet: boolean;
|
20
|
+
miniMetadata: `0x${string}` | null;
|
21
|
+
metadataVersion: number;
|
22
|
+
};
|
23
|
+
export type SubEquilibriumModuleConfig = {
|
24
|
+
disable?: boolean;
|
25
|
+
tokens?: Array<{
|
26
|
+
assetId?: string;
|
27
|
+
} & BalancesConfigTokenParams>;
|
28
|
+
};
|
29
|
+
export type SubEquilibriumBalance = NewBalanceType<ModuleType, {
|
30
|
+
multiChainId: SubChainId;
|
31
|
+
free: Amount;
|
32
|
+
}>;
|
33
|
+
declare module "@talismn/balances/plugins" {
|
34
|
+
interface PluginBalanceTypes {
|
35
|
+
SubEquilibriumBalance: SubEquilibriumBalance;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
export type SubEquilibriumTransferParams = NewTransferParamsType<{
|
39
|
+
registry: TypeRegistry;
|
40
|
+
metadataRpc: `0x${string}`;
|
41
|
+
blockHash: string;
|
42
|
+
blockNumber: number;
|
43
|
+
nonce: number;
|
44
|
+
specVersion: number;
|
45
|
+
transactionVersion: number;
|
46
|
+
tip?: string;
|
47
|
+
transferMethod: "transfer" | "transferKeepAlive" | "transferAll";
|
48
|
+
}>;
|
49
|
+
export declare const SubEquilibriumModule: NewBalanceModule<ModuleType, SubEquilibriumToken, SubEquilibriumChainMeta, SubEquilibriumModuleConfig, SubEquilibriumTransferParams>;
|
50
|
+
export {};
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import { TypeRegistry } from "@polkadot/types";
|
2
|
+
import { ChainConnector } from "@talismn/chain-connector";
|
3
|
+
import { BalancesConfigTokenParams, ChainId, ChaindataProvider, NewTokenType, SubChainId } from "@talismn/chaindata-provider";
|
4
|
+
import { NewBalanceModule, NewTransferParamsType } from "../BalanceModule";
|
5
|
+
import { AddressesByToken, Amount, AmountWithLabel, Balances, LockedAmount, NewBalanceType, SubscriptionCallback } from "../types";
|
6
|
+
import { GetOrCreateTypeRegistry } from "./util";
|
7
|
+
type ModuleType = "substrate-native";
|
8
|
+
export declare const subNativeTokenId: (chainId: ChainId, tokenSymbol: string) => string;
|
9
|
+
export type SubNativeToken = NewTokenType<ModuleType, {
|
10
|
+
existentialDeposit: string;
|
11
|
+
chain: {
|
12
|
+
id: ChainId;
|
13
|
+
};
|
14
|
+
}>;
|
15
|
+
export type CustomSubNativeToken = SubNativeToken & {
|
16
|
+
isCustom: true;
|
17
|
+
};
|
18
|
+
declare module "@talismn/chaindata-provider/plugins" {
|
19
|
+
interface PluginTokenTypes {
|
20
|
+
SubNativeToken: SubNativeToken;
|
21
|
+
CustomSubNativeToken: CustomSubNativeToken;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
export type SubNativeChainMeta = {
|
25
|
+
isTestnet: boolean;
|
26
|
+
symbol: string;
|
27
|
+
decimals: number;
|
28
|
+
existentialDeposit: string | null;
|
29
|
+
nominationPoolsPalletId: string | null;
|
30
|
+
crowdloanPalletId: string | null;
|
31
|
+
miniMetadata: `0x${string}` | null;
|
32
|
+
metadataVersion: number;
|
33
|
+
};
|
34
|
+
export type SubNativeModuleConfig = {
|
35
|
+
disable?: boolean;
|
36
|
+
} & BalancesConfigTokenParams;
|
37
|
+
export type SubNativeBalance = NewBalanceType<ModuleType, {
|
38
|
+
multiChainId: SubChainId;
|
39
|
+
free: Amount;
|
40
|
+
reserves: [AmountWithLabel<"reserved">, ...Array<AmountWithLabel<string>>];
|
41
|
+
locks: [LockedAmount<"fees">, LockedAmount<"misc">, ...Array<LockedAmount<string>>];
|
42
|
+
}>;
|
43
|
+
declare module "@talismn/balances/plugins" {
|
44
|
+
interface PluginBalanceTypes {
|
45
|
+
SubNativeBalance: SubNativeBalance;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
export type BalancesCommonTransferMethods = "transferKeepAlive" | "transferAll";
|
49
|
+
export type BalancesTransferMethods = "transferAllowDeath" | BalancesCommonTransferMethods;
|
50
|
+
export type BalancesLegacyTransferMethods = "transfer" | BalancesCommonTransferMethods;
|
51
|
+
export type BalancesAllTransferMethods = BalancesLegacyTransferMethods | BalancesTransferMethods;
|
52
|
+
export type SubNativeTransferParams = NewTransferParamsType<{
|
53
|
+
registry: TypeRegistry;
|
54
|
+
metadataRpc: `0x${string}`;
|
55
|
+
blockHash: string;
|
56
|
+
blockNumber: number;
|
57
|
+
nonce: number;
|
58
|
+
specVersion: number;
|
59
|
+
transactionVersion: number;
|
60
|
+
tip?: string;
|
61
|
+
transferMethod: BalancesAllTransferMethods;
|
62
|
+
}>;
|
63
|
+
export declare const SubNativeModule: NewBalanceModule<ModuleType, SubNativeToken | CustomSubNativeToken, SubNativeChainMeta, SubNativeModuleConfig, SubNativeTransferParams>;
|
64
|
+
export declare function subscribeNompoolStaking(chaindataProvider: ChaindataProvider, chainConnector: ChainConnector, getOrCreateTypeRegistry: GetOrCreateTypeRegistry, addressesByToken: AddressesByToken<SubNativeToken | CustomSubNativeToken>, callback: SubscriptionCallback<Balances>, callerUnsubscribed: Promise<unknown>): Promise<void>;
|
65
|
+
export {};
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import { TypeRegistry } from "@polkadot/types";
|
2
|
+
import { BalancesConfigTokenParams, ChainId, NewTokenType, SubChainId } from "@talismn/chaindata-provider";
|
3
|
+
import { NewBalanceModule, NewTransferParamsType } from "../BalanceModule";
|
4
|
+
import { Amount, NewBalanceType } from "../types";
|
5
|
+
type ModuleType = "substrate-psp22";
|
6
|
+
export type SubPsp22Token = NewTokenType<ModuleType, {
|
7
|
+
existentialDeposit: string;
|
8
|
+
contractAddress: string;
|
9
|
+
chain: {
|
10
|
+
id: ChainId;
|
11
|
+
};
|
12
|
+
}>;
|
13
|
+
declare module "@talismn/chaindata-provider/plugins" {
|
14
|
+
interface PluginTokenTypes {
|
15
|
+
SubPsp22Token: SubPsp22Token;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
export type SubPsp22ChainMeta = {
|
19
|
+
isTestnet: boolean;
|
20
|
+
};
|
21
|
+
export type SubPsp22ModuleConfig = {
|
22
|
+
tokens?: Array<{
|
23
|
+
symbol?: string;
|
24
|
+
decimals?: number;
|
25
|
+
ed?: string;
|
26
|
+
contractAddress?: string;
|
27
|
+
} & BalancesConfigTokenParams>;
|
28
|
+
};
|
29
|
+
export type SubPsp22Balance = NewBalanceType<ModuleType, {
|
30
|
+
multiChainId: SubChainId;
|
31
|
+
free: Amount;
|
32
|
+
}>;
|
33
|
+
declare module "@talismn/balances/plugins" {
|
34
|
+
interface PluginBalanceTypes {
|
35
|
+
SubPsp22Balance: SubPsp22Balance;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
export type SubPsp22TransferParams = NewTransferParamsType<{
|
39
|
+
registry: TypeRegistry;
|
40
|
+
metadataRpc: `0x${string}`;
|
41
|
+
blockHash: string;
|
42
|
+
blockNumber: number;
|
43
|
+
nonce: number;
|
44
|
+
specVersion: number;
|
45
|
+
transactionVersion: number;
|
46
|
+
tip?: string;
|
47
|
+
transferMethod: "transfer" | "transferKeepAlive" | "transferAll";
|
48
|
+
}>;
|
49
|
+
export declare const SubPsp22Module: NewBalanceModule<ModuleType, SubPsp22Token, SubPsp22ChainMeta, SubPsp22ModuleConfig, SubPsp22TransferParams>;
|
50
|
+
export {};
|
@@ -0,0 +1,54 @@
|
|
1
|
+
import { TypeRegistry } from "@polkadot/types";
|
2
|
+
import { BalancesConfigTokenParams, ChainId, NewTokenType, SubChainId } from "@talismn/chaindata-provider";
|
3
|
+
import { NewBalanceModule, NewTransferParamsType } from "../BalanceModule";
|
4
|
+
import { Amount, NewBalanceType } from "../types";
|
5
|
+
type ModuleType = "substrate-tokens";
|
6
|
+
export type SubTokensToken = NewTokenType<ModuleType, {
|
7
|
+
existentialDeposit: string;
|
8
|
+
onChainId: string | number;
|
9
|
+
chain: {
|
10
|
+
id: ChainId;
|
11
|
+
};
|
12
|
+
}>;
|
13
|
+
declare module "@talismn/chaindata-provider/plugins" {
|
14
|
+
interface PluginTokenTypes {
|
15
|
+
SubTokensToken: SubTokensToken;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
export type SubTokensChainMeta = {
|
19
|
+
isTestnet: boolean;
|
20
|
+
miniMetadata: `0x${string}` | null;
|
21
|
+
metadataVersion: number;
|
22
|
+
};
|
23
|
+
export type SubTokensModuleConfig = {
|
24
|
+
tokens?: Array<{
|
25
|
+
symbol?: string;
|
26
|
+
decimals?: number;
|
27
|
+
ed?: string;
|
28
|
+
onChainId?: string | number;
|
29
|
+
} & BalancesConfigTokenParams>;
|
30
|
+
};
|
31
|
+
export type SubTokensBalance = NewBalanceType<ModuleType, {
|
32
|
+
multiChainId: SubChainId;
|
33
|
+
free: Amount;
|
34
|
+
reserves: Amount;
|
35
|
+
locks: Amount;
|
36
|
+
}>;
|
37
|
+
declare module "@talismn/balances/plugins" {
|
38
|
+
interface PluginBalanceTypes {
|
39
|
+
SubTokensBalance: SubTokensBalance;
|
40
|
+
}
|
41
|
+
}
|
42
|
+
export type SubTokensTransferParams = NewTransferParamsType<{
|
43
|
+
registry: TypeRegistry;
|
44
|
+
metadataRpc: `0x${string}`;
|
45
|
+
blockHash: string;
|
46
|
+
blockNumber: number;
|
47
|
+
nonce: number;
|
48
|
+
specVersion: number;
|
49
|
+
transactionVersion: number;
|
50
|
+
tip?: string;
|
51
|
+
transferMethod: "transfer" | "transferKeepAlive" | "transferAll";
|
52
|
+
}>;
|
53
|
+
export declare const SubTokensModule: NewBalanceModule<ModuleType, SubTokensToken, SubTokensChainMeta, SubTokensModuleConfig, SubTokensTransferParams>;
|
54
|
+
export {};
|