@talismn/balances 0.0.0-pr595-20230305171323 → 0.0.0-pr596-20230306005809
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
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
# @talismn/balances
|
2
2
|
|
3
|
-
## 0.0.0-
|
3
|
+
## 0.0.0-pr596-20230306005809
|
4
4
|
|
5
5
|
### Patch Changes
|
6
6
|
|
7
|
-
-
|
8
|
-
|
9
|
-
|
10
|
-
- @talismn/
|
11
|
-
- @talismn/token-rates@0.0.0-pr595-20230305171323
|
7
|
+
- 6643a4e: fix: tokenRates in @talismn/balances-react
|
8
|
+
- 6643a4e: fix: ported useDbCache related perf fixes to @talismn/balances-react
|
9
|
+
- Updated dependencies [6643a4e]
|
10
|
+
- @talismn/token-rates@0.0.0-pr596-20230306005809
|
12
11
|
|
13
12
|
## 0.3.3
|
14
13
|
|
@@ -1,28 +1,46 @@
|
|
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 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> {
|
29
|
+
}
|
30
|
+
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>;
|
31
|
+
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
32
|
/** Pre-processes any substrate chain metadata required by this module ahead of time */
|
15
33
|
fetchSubstrateChainMeta(chainConnector: ChainConnector, chaindataProvider: ChaindataProvider, chainId: ChainId, moduleConfig: TModuleConfig | undefined): Promise<TChainMeta | null>;
|
16
34
|
/** Detects which tokens are available on a given substrate chain */
|
17
35
|
fetchSubstrateChainTokens(chainConnector: ChainConnector, chaindataProvider: ChaindataProvider, chainId: ChainId, chainMeta: TChainMeta, moduleConfig: TModuleConfig | undefined): Promise<Record<TTokenType["id"], TTokenType>>;
|
18
36
|
}
|
19
|
-
interface BalanceModuleEvm<TModuleType extends string, TTokenType extends ExtendableTokenType, TChainMeta extends ExtendableChainMeta = DefaultChainMeta, TModuleConfig extends ExtendableModuleConfig = DefaultModuleConfig> extends BalanceModuleCommon<TModuleType, TTokenType> {
|
37
|
+
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
38
|
/** Pre-processes any evm chain metadata required by this module ahead of time */
|
21
39
|
fetchEvmChainMeta(chainConnector: ChainConnectorEvm, chaindataProvider: ChaindataProvider, chainId: ChainId, moduleConfig: TModuleConfig | undefined): Promise<TChainMeta | null>;
|
22
40
|
/** Detects which tokens are available on a given evm chain */
|
23
41
|
fetchEvmChainTokens(chainConnector: ChainConnectorEvm, chaindataProvider: ChaindataProvider, chainId: ChainId, chainMeta: TChainMeta, moduleConfig: TModuleConfig | undefined): Promise<Record<TTokenType["id"], TTokenType>>;
|
24
42
|
}
|
25
|
-
interface BalanceModuleCommon<TModuleType extends string, TTokenType extends ExtendableTokenType> {
|
43
|
+
interface BalanceModuleCommon<TModuleType extends string, TTokenType extends ExtendableTokenType, TTransferParams extends ExtendableTransferParams> {
|
26
44
|
get type(): TModuleType;
|
27
45
|
/**
|
28
46
|
* Subscribe to balances for this module with optional filtering.
|
@@ -38,6 +56,10 @@ interface BalanceModuleCommon<TModuleType extends string, TTokenType extends Ext
|
|
38
56
|
substrate?: ChainConnector;
|
39
57
|
evm?: ChainConnectorEvm;
|
40
58
|
}, chaindataProvider: ChaindataProvider, addressesByToken: AddressesByToken<TTokenType>): Promise<Balances>;
|
59
|
+
transferToken(chainConnectors: {
|
60
|
+
substrate?: ChainConnector;
|
61
|
+
evm?: ChainConnectorEvm;
|
62
|
+
}, chaindataProvider: ChaindataProvider, transferParams: TTransferParams): Promise<TransferTokenTx | null>;
|
41
63
|
[x: string | number | symbol]: unknown;
|
42
64
|
}
|
43
65
|
export {};
|
@@ -2,17 +2,17 @@ import { TypeRegistry } from "@polkadot/types";
|
|
2
2
|
import { ChainConnector } from "@talismn/chain-connector";
|
3
3
|
import { ChainConnectorEvm } from "@talismn/chain-connector-evm";
|
4
4
|
import { ChaindataProvider } from "@talismn/chaindata-provider";
|
5
|
-
import { BalanceModule, DefaultChainMeta, DefaultModuleConfig, ExtendableChainMeta, ExtendableModuleConfig, ExtendableTokenType } from "./BalanceModule";
|
5
|
+
import { BalanceModule, DefaultChainMeta, DefaultModuleConfig, DefaultTransferParams, ExtendableChainMeta, ExtendableModuleConfig, ExtendableTokenType, ExtendableTransferParams } from "./BalanceModule";
|
6
6
|
import { AddressesByToken, Balance, Balances, SubscriptionCallback, UnsubscribeFn } from "./types";
|
7
7
|
/**
|
8
8
|
* Wraps a BalanceModule's fetch/subscribe methods with a single `balances` method.
|
9
9
|
* This `balances` method will subscribe if a callback parameter is provided, or otherwise fetch.
|
10
10
|
*/
|
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>, chainConnectors: {
|
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>, chainConnectors: {
|
12
12
|
substrate?: ChainConnector;
|
13
13
|
evm?: ChainConnectorEvm;
|
14
14
|
}, chaindataProvider: ChaindataProvider, addressesByToken: AddressesByToken<TTokenType>): Promise<Balances>;
|
15
|
-
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
|
+
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>, chainConnectors: {
|
16
16
|
substrate?: ChainConnector;
|
17
17
|
evm?: ChainConnectorEvm;
|
18
18
|
}, chaindataProvider: ChaindataProvider, addressesByToken: AddressesByToken<TTokenType>, callback: SubscriptionCallback<Balances>): Promise<UnsubscribeFn>;
|
@@ -41,6 +41,9 @@ const DefaultBalanceModule = type => ({
|
|
41
41
|
},
|
42
42
|
async fetchBalances() {
|
43
43
|
throw new Error("Balance fetching is not implemented in this module.");
|
44
|
+
},
|
45
|
+
async transferToken() {
|
46
|
+
throw new Error("Token transfers are not implemented in this module.");
|
44
47
|
}
|
45
48
|
});
|
46
49
|
|
@@ -71,7 +74,7 @@ const db = new TalismanBalancesDatabase();
|
|
71
74
|
|
72
75
|
var packageJson = {
|
73
76
|
name: "@talismn/balances",
|
74
|
-
version: "0.0.0-
|
77
|
+
version: "0.0.0-pr596-20230306005809",
|
75
78
|
author: "Talisman",
|
76
79
|
homepage: "https://talisman.xyz",
|
77
80
|
license: "UNLICENSED",
|
@@ -146,7 +149,7 @@ async function balances(balanceModule, chainConnectors, chaindataProvider, addre
|
|
146
149
|
}
|
147
150
|
const filterMirrorTokens = (balance, i, balances) => {
|
148
151
|
var _balance$token;
|
149
|
-
// TODO implement a mirrorOf property, which should be set from chaindata
|
152
|
+
// TODO: implement a mirrorOf property, which should be set from chaindata
|
150
153
|
const mirrorOf = (_balance$token = balance.token) === null || _balance$token === void 0 ? void 0 : _balance$token.mirrorOf;
|
151
154
|
return !mirrorOf || !balances.find(b => b.tokenId === mirrorOf);
|
152
155
|
};
|
@@ -41,6 +41,9 @@ const DefaultBalanceModule = type => ({
|
|
41
41
|
},
|
42
42
|
async fetchBalances() {
|
43
43
|
throw new Error("Balance fetching is not implemented in this module.");
|
44
|
+
},
|
45
|
+
async transferToken() {
|
46
|
+
throw new Error("Token transfers are not implemented in this module.");
|
44
47
|
}
|
45
48
|
});
|
46
49
|
|
@@ -71,7 +74,7 @@ const db = new TalismanBalancesDatabase();
|
|
71
74
|
|
72
75
|
var packageJson = {
|
73
76
|
name: "@talismn/balances",
|
74
|
-
version: "0.0.0-
|
77
|
+
version: "0.0.0-pr596-20230306005809",
|
75
78
|
author: "Talisman",
|
76
79
|
homepage: "https://talisman.xyz",
|
77
80
|
license: "UNLICENSED",
|
@@ -146,7 +149,7 @@ async function balances(balanceModule, chainConnectors, chaindataProvider, addre
|
|
146
149
|
}
|
147
150
|
const filterMirrorTokens = (balance, i, balances) => {
|
148
151
|
var _balance$token;
|
149
|
-
// TODO implement a mirrorOf property, which should be set from chaindata
|
152
|
+
// TODO: implement a mirrorOf property, which should be set from chaindata
|
150
153
|
const mirrorOf = (_balance$token = balance.token) === null || _balance$token === void 0 ? void 0 : _balance$token.mirrorOf;
|
151
154
|
return !mirrorOf || !balances.find(b => b.tokenId === mirrorOf);
|
152
155
|
};
|
@@ -32,6 +32,9 @@ const DefaultBalanceModule = type => ({
|
|
32
32
|
},
|
33
33
|
async fetchBalances() {
|
34
34
|
throw new Error("Balance fetching is not implemented in this module.");
|
35
|
+
},
|
36
|
+
async transferToken() {
|
37
|
+
throw new Error("Token transfers are not implemented in this module.");
|
35
38
|
}
|
36
39
|
});
|
37
40
|
|
@@ -62,7 +65,7 @@ const db = new TalismanBalancesDatabase();
|
|
62
65
|
|
63
66
|
var packageJson = {
|
64
67
|
name: "@talismn/balances",
|
65
|
-
version: "0.0.0-
|
68
|
+
version: "0.0.0-pr596-20230306005809",
|
66
69
|
author: "Talisman",
|
67
70
|
homepage: "https://talisman.xyz",
|
68
71
|
license: "UNLICENSED",
|
@@ -137,7 +140,7 @@ async function balances(balanceModule, chainConnectors, chaindataProvider, addre
|
|
137
140
|
}
|
138
141
|
const filterMirrorTokens = (balance, i, balances) => {
|
139
142
|
var _balance$token;
|
140
|
-
// TODO implement a mirrorOf property, which should be set from chaindata
|
143
|
+
// TODO: implement a mirrorOf property, which should be set from chaindata
|
141
144
|
const mirrorOf = (_balance$token = balance.token) === null || _balance$token === void 0 ? void 0 : _balance$token.mirrorOf;
|
142
145
|
return !mirrorOf || !balances.find(b => b.tokenId === mirrorOf);
|
143
146
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@talismn/balances",
|
3
|
-
"version": "0.0.0-
|
3
|
+
"version": "0.0.0-pr596-20230306005809",
|
4
4
|
"author": "Talisman",
|
5
5
|
"homepage": "https://talisman.xyz",
|
6
6
|
"license": "UNLICENSED",
|
@@ -27,10 +27,10 @@
|
|
27
27
|
"clean": "rm -rf dist && rm -rf .turbo rm -rf node_modules"
|
28
28
|
},
|
29
29
|
"dependencies": {
|
30
|
-
"@talismn/chain-connector": "^0.
|
31
|
-
"@talismn/chain-connector-evm": "^0.
|
32
|
-
"@talismn/chaindata-provider": "^0.
|
33
|
-
"@talismn/token-rates": "^0.0.0-
|
30
|
+
"@talismn/chain-connector": "^0.4.2",
|
31
|
+
"@talismn/chain-connector-evm": "^0.4.2",
|
32
|
+
"@talismn/chaindata-provider": "^0.4.2",
|
33
|
+
"@talismn/token-rates": "^0.0.0-pr596-20230306005809",
|
34
34
|
"@talismn/util": "^0.1.7",
|
35
35
|
"anylogger": "^1.0.11",
|
36
36
|
"dexie": "^3.2.3",
|