@talismn/balances 0.1.7 → 0.1.9
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 +17 -0
- package/dist/BalanceModule.d.ts +11 -4
- package/dist/BalanceModule.js +1 -1
- package/dist/helpers.d.ts +9 -2
- package/dist/helpers.js +3 -3
- package/dist/types/balances.d.ts +2 -1
- package/dist/types/balances.js +1 -0
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# @talismn/balances
|
2
2
|
|
3
|
+
## 0.1.9
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- d66c5bc: fix: evm native tokens
|
8
|
+
- Updated dependencies [d66c5bc]
|
9
|
+
- @talismn/chain-connector-evm@0.1.5
|
10
|
+
- @talismn/chaindata-provider@0.1.5
|
11
|
+
- @talismn/chain-connector@0.1.5
|
12
|
+
- @talismn/token-rates@0.1.5
|
13
|
+
|
14
|
+
## 0.1.8
|
15
|
+
|
16
|
+
### Patch Changes
|
17
|
+
|
18
|
+
- 3db774a: fix: useBalances creating too many subscriptions when called from multiple components
|
19
|
+
|
3
20
|
## 0.1.7
|
4
21
|
|
5
22
|
## 0.1.6
|
package/dist/BalanceModule.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import { ChainConnector } from "@talismn/chain-connector";
|
2
|
+
import { ChainConnectorEvm } from "@talismn/chain-connector-evm";
|
2
3
|
import { ChainId, ChaindataProvider, IToken } from "@talismn/chaindata-provider";
|
3
4
|
import { AddressesByToken, Balances, SubscriptionCallback, UnsubscribeFn } from "./types";
|
4
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> {
|
@@ -17,9 +18,9 @@ interface BalanceModuleSubstrate<TModuleType extends string, TTokenType extends
|
|
17
18
|
}
|
18
19
|
interface BalanceModuleEvm<TModuleType extends string, TTokenType extends ExtendableTokenType, TChainMeta extends ExtendableChainMeta = DefaultChainMeta, TModuleConfig extends ExtendableModuleConfig = DefaultModuleConfig> extends BalanceModuleCommon<TModuleType, TTokenType> {
|
19
20
|
/** Pre-processes any evm chain metadata required by this module ahead of time */
|
20
|
-
fetchEvmChainMeta(chainConnector:
|
21
|
+
fetchEvmChainMeta(chainConnector: ChainConnectorEvm, chaindataProvider: ChaindataProvider, chainId: ChainId): Promise<TChainMeta | null>;
|
21
22
|
/** Detects which tokens are available on a given evm chain */
|
22
|
-
fetchEvmChainTokens(chainConnector:
|
23
|
+
fetchEvmChainTokens(chainConnector: ChainConnectorEvm, chaindataProvider: ChaindataProvider, chainId: ChainId, chainMeta: TChainMeta, moduleConfig: TModuleConfig): Promise<Record<TTokenType["id"], TTokenType>>;
|
23
24
|
}
|
24
25
|
interface BalanceModuleCommon<TModuleType extends string, TTokenType extends ExtendableTokenType> {
|
25
26
|
get type(): TModuleType;
|
@@ -28,9 +29,15 @@ interface BalanceModuleCommon<TModuleType extends string, TTokenType extends Ext
|
|
28
29
|
*
|
29
30
|
* If subscriptions are not possible, this function should poll at some reasonable interval.
|
30
31
|
*/
|
31
|
-
subscribeBalances(
|
32
|
+
subscribeBalances(chainConnectors: {
|
33
|
+
substrate?: ChainConnector;
|
34
|
+
evm?: ChainConnectorEvm;
|
35
|
+
}, chaindataProvider: ChaindataProvider, addressesByToken: AddressesByToken<TTokenType>, callback: SubscriptionCallback<Balances>): Promise<UnsubscribeFn>;
|
32
36
|
/** Fetch balances for this module with optional filtering */
|
33
|
-
fetchBalances(
|
37
|
+
fetchBalances(chainConnectors: {
|
38
|
+
substrate?: ChainConnector;
|
39
|
+
evm?: ChainConnectorEvm;
|
40
|
+
}, chaindataProvider: ChaindataProvider, addressesByToken: AddressesByToken<TTokenType>): Promise<Balances>;
|
34
41
|
[x: string | number | symbol]: unknown;
|
35
42
|
}
|
36
43
|
export {};
|
package/dist/BalanceModule.js
CHANGED
@@ -35,7 +35,7 @@ const DefaultBalanceModule = (type) => ({
|
|
35
35
|
return Promise.resolve({});
|
36
36
|
});
|
37
37
|
},
|
38
|
-
subscribeBalances(
|
38
|
+
subscribeBalances(_chainConnectors, _chaindataProvider, _addressesByToken, callback) {
|
39
39
|
return __awaiter(this, void 0, void 0, function* () {
|
40
40
|
callback(new Error("Balance subscriptions are not implemented in this module."));
|
41
41
|
return () => { };
|
package/dist/helpers.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import { ChainConnector } from "@talismn/chain-connector";
|
2
|
+
import { ChainConnectorEvm } from "@talismn/chain-connector-evm";
|
2
3
|
import { ChaindataProvider } from "@talismn/chaindata-provider";
|
3
4
|
import { BalanceModule, DefaultChainMeta, DefaultModuleConfig, ExtendableChainMeta, ExtendableModuleConfig, ExtendableTokenType } from "./BalanceModule";
|
4
5
|
import { AddressesByToken, Balances, SubscriptionCallback, UnsubscribeFn } from "./types";
|
@@ -6,5 +7,11 @@ import { AddressesByToken, Balances, SubscriptionCallback, UnsubscribeFn } from
|
|
6
7
|
* Wraps a BalanceModule's fetch/subscribe methods with a single `balances` method.
|
7
8
|
* This `balances` method will subscribe if a callback parameter is provided, or otherwise fetch.
|
8
9
|
*/
|
9
|
-
export declare function balances<TModuleType extends string, TTokenType extends ExtendableTokenType, TChainMeta extends ExtendableChainMeta = DefaultChainMeta, TModuleConfig extends ExtendableModuleConfig = DefaultModuleConfig>(balanceModule: BalanceModule<TModuleType, TTokenType, TChainMeta, TModuleConfig>,
|
10
|
-
|
10
|
+
export declare function balances<TModuleType extends string, TTokenType extends ExtendableTokenType, TChainMeta extends ExtendableChainMeta = DefaultChainMeta, TModuleConfig extends ExtendableModuleConfig = DefaultModuleConfig>(balanceModule: BalanceModule<TModuleType, TTokenType, TChainMeta, TModuleConfig>, chainConnectors: {
|
11
|
+
substrate?: ChainConnector;
|
12
|
+
evm?: ChainConnectorEvm;
|
13
|
+
}, chaindataProvider: ChaindataProvider, addressesByToken: AddressesByToken<TTokenType>): Promise<Balances>;
|
14
|
+
export declare function balances<TModuleType extends string, TTokenType extends ExtendableTokenType, TChainMeta extends ExtendableChainMeta = DefaultChainMeta, TModuleConfig extends ExtendableModuleConfig = DefaultModuleConfig>(balanceModule: BalanceModule<TModuleType, TTokenType, TChainMeta, TModuleConfig>, chainConnectors: {
|
15
|
+
substrate?: ChainConnector;
|
16
|
+
evm?: ChainConnectorEvm;
|
17
|
+
}, chaindataProvider: ChaindataProvider, addressesByToken: AddressesByToken<TTokenType>, callback: SubscriptionCallback<Balances>): Promise<UnsubscribeFn>;
|
package/dist/helpers.js
CHANGED
@@ -10,13 +10,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
10
10
|
};
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
12
|
exports.balances = void 0;
|
13
|
-
function balances(balanceModule,
|
13
|
+
function balances(balanceModule, chainConnectors, chaindataProvider, addressesByToken, callback) {
|
14
14
|
return __awaiter(this, void 0, void 0, function* () {
|
15
15
|
// subscription request
|
16
16
|
if (callback !== undefined)
|
17
|
-
return yield balanceModule.subscribeBalances(
|
17
|
+
return yield balanceModule.subscribeBalances(chainConnectors, chaindataProvider, addressesByToken, callback);
|
18
18
|
// one-off request
|
19
|
-
return yield balanceModule.fetchBalances(
|
19
|
+
return yield balanceModule.fetchBalances(chainConnectors, chaindataProvider, addressesByToken);
|
20
20
|
});
|
21
21
|
}
|
22
22
|
exports.balances = balances;
|
package/dist/types/balances.d.ts
CHANGED
@@ -93,6 +93,7 @@ export declare class Balances {
|
|
93
93
|
get count(): number;
|
94
94
|
/**
|
95
95
|
* Get the summed value of balances in this collection.
|
96
|
+
* TODO: Sum up token amounts AND fiat amounts
|
96
97
|
*
|
97
98
|
* @example
|
98
99
|
* // Get the sum of all transferable balances in usd.
|
@@ -115,7 +116,7 @@ export declare class Balance {
|
|
115
116
|
get address(): string;
|
116
117
|
get chainId(): string | undefined;
|
117
118
|
get chain(): import("@talismn/chaindata-provider").Chain | null;
|
118
|
-
get evmNetworkId():
|
119
|
+
get evmNetworkId(): string | undefined;
|
119
120
|
get evmNetwork(): import("@talismn/chaindata-provider").EvmNetwork | null;
|
120
121
|
get tokenId(): string;
|
121
122
|
get token(): import("@talismn/chaindata-provider").IToken | null;
|
package/dist/types/balances.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@talismn/balances",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.9",
|
4
4
|
"author": "Talisman",
|
5
5
|
"homepage": "https://talisman.xyz",
|
6
6
|
"license": "UNLICENSED",
|
@@ -31,9 +31,10 @@
|
|
31
31
|
"clean": "rm -rf dist && rm -rf .turbo rm -rf node_modules"
|
32
32
|
},
|
33
33
|
"dependencies": {
|
34
|
-
"@talismn/chain-connector": "^0.1.
|
35
|
-
"@talismn/
|
36
|
-
"@talismn/
|
34
|
+
"@talismn/chain-connector": "^0.1.5",
|
35
|
+
"@talismn/chain-connector-evm": "^0.1.5",
|
36
|
+
"@talismn/chaindata-provider": "^0.1.5",
|
37
|
+
"@talismn/token-rates": "^0.1.5",
|
37
38
|
"@talismn/util": "^0.1.3",
|
38
39
|
"lodash": "^4.17.21",
|
39
40
|
"typescript-memoize": "^1.1.0"
|