@talismn/balances 0.0.0-pr447-20230214040957 → 0.0.0-pr447-20230222123200

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,16 +1,40 @@
1
1
  # @talismn/balances
2
2
 
3
- ## 0.0.0-pr447-20230214040957
3
+ ## 0.0.0-pr447-20230222123200
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - 8adc7f0: feat: switched build tool to preconstruct
8
- - Updated dependencies [8adc7f0]
9
- - @talismn/chain-connector-evm@0.0.0-pr447-20230214040957
10
- - @talismn/chaindata-provider@0.0.0-pr447-20230214040957
11
- - @talismn/chain-connector@0.0.0-pr447-20230214040957
12
- - @talismn/token-rates@0.0.0-pr447-20230214040957
13
- - @talismn/util@0.0.0-pr447-20230214040957
7
+ - 298aebe: fix: tokenRates in @talismn/balances-react
8
+ - 298aebe: fix: ported useDbCache related perf fixes to @talismn/balances-react
9
+ - Updated dependencies [298aebe]
10
+ - @talismn/token-rates@0.0.0-pr447-20230222123200
11
+
12
+ ## 0.3.3
13
+
14
+ ### Patch Changes
15
+
16
+ - c651551c: build: move `@polkadot` dependencies to `peerDependencies`
17
+ - Updated dependencies [c651551c]
18
+ - @talismn/chain-connector@0.4.2
19
+ - @talismn/util@0.1.7
20
+ - @talismn/chain-connector-evm@0.4.2
21
+ - @talismn/chaindata-provider@0.4.2
22
+ - @talismn/token-rates@0.1.14
23
+
24
+ ## 0.3.2
25
+
26
+ ## 0.3.1
27
+
28
+ ### Patch Changes
29
+
30
+ - 8adc7f06: feat: switched build tool to preconstruct
31
+ - Updated dependencies [8adc7f06]
32
+ - Updated dependencies [cfe8d276]
33
+ - @talismn/chain-connector-evm@0.4.1
34
+ - @talismn/chaindata-provider@0.4.1
35
+ - @talismn/chain-connector@0.4.1
36
+ - @talismn/token-rates@0.1.13
37
+ - @talismn/util@0.1.6
14
38
 
15
39
  ## 0.3.0
16
40
 
@@ -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
- interface BalanceModuleSubstrate<TModuleType extends string, TTokenType extends ExtendableTokenType, TChainMeta extends ExtendableChainMeta = DefaultChainMeta, TModuleConfig extends ExtendableModuleConfig = DefaultModuleConfig> extends BalanceModuleCommon<TModuleType, TTokenType> {
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-pr447-20230214040957",
77
+ version: "0.0.0-pr447-20230222123200",
75
78
  author: "Talisman",
76
79
  homepage: "https://talisman.xyz",
77
80
  license: "UNLICENSED",
@@ -98,18 +101,18 @@ var packageJson = {
98
101
  clean: "rm -rf dist && rm -rf .turbo rm -rf node_modules"
99
102
  },
100
103
  dependencies: {
101
- "@polkadot/types": "9.10.5",
102
104
  "@talismn/chain-connector": "workspace:^",
103
105
  "@talismn/chain-connector-evm": "workspace:^",
104
106
  "@talismn/chaindata-provider": "workspace:^",
105
107
  "@talismn/token-rates": "workspace:^",
106
108
  "@talismn/util": "workspace:^",
107
109
  anylogger: "^1.0.11",
108
- dexie: "^3.2.2",
110
+ dexie: "^3.2.3",
109
111
  lodash: "^4.17.21",
110
112
  "typescript-memoize": "^1.1.0"
111
113
  },
112
114
  devDependencies: {
115
+ "@polkadot/types": "^9.10.5",
113
116
  "@talismn/eslint-config": "workspace:^",
114
117
  "@talismn/tsconfig": "workspace:^",
115
118
  "@types/jest": "^27.5.1",
@@ -118,6 +121,9 @@ var packageJson = {
118
121
  "ts-jest": "^28.0.2",
119
122
  typescript: "^4.6.4"
120
123
  },
124
+ peerDependencies: {
125
+ "@polkadot/types": "9.x"
126
+ },
121
127
  preconstruct: {
122
128
  entrypoints: [
123
129
  "index.ts",
@@ -143,7 +149,7 @@ async function balances(balanceModule, chainConnectors, chaindataProvider, addre
143
149
  }
144
150
  const filterMirrorTokens = (balance, i, balances) => {
145
151
  var _balance$token;
146
- // TODO implement a mirrorOf property, which should be set from chaindata
152
+ // TODO: implement a mirrorOf property, which should be set from chaindata
147
153
  const mirrorOf = (_balance$token = balance.token) === null || _balance$token === void 0 ? void 0 : _balance$token.mirrorOf;
148
154
  return !mirrorOf || !balances.find(b => b.tokenId === mirrorOf);
149
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-pr447-20230214040957",
77
+ version: "0.0.0-pr447-20230222123200",
75
78
  author: "Talisman",
76
79
  homepage: "https://talisman.xyz",
77
80
  license: "UNLICENSED",
@@ -98,18 +101,18 @@ var packageJson = {
98
101
  clean: "rm -rf dist && rm -rf .turbo rm -rf node_modules"
99
102
  },
100
103
  dependencies: {
101
- "@polkadot/types": "9.10.5",
102
104
  "@talismn/chain-connector": "workspace:^",
103
105
  "@talismn/chain-connector-evm": "workspace:^",
104
106
  "@talismn/chaindata-provider": "workspace:^",
105
107
  "@talismn/token-rates": "workspace:^",
106
108
  "@talismn/util": "workspace:^",
107
109
  anylogger: "^1.0.11",
108
- dexie: "^3.2.2",
110
+ dexie: "^3.2.3",
109
111
  lodash: "^4.17.21",
110
112
  "typescript-memoize": "^1.1.0"
111
113
  },
112
114
  devDependencies: {
115
+ "@polkadot/types": "^9.10.5",
113
116
  "@talismn/eslint-config": "workspace:^",
114
117
  "@talismn/tsconfig": "workspace:^",
115
118
  "@types/jest": "^27.5.1",
@@ -118,6 +121,9 @@ var packageJson = {
118
121
  "ts-jest": "^28.0.2",
119
122
  typescript: "^4.6.4"
120
123
  },
124
+ peerDependencies: {
125
+ "@polkadot/types": "9.x"
126
+ },
121
127
  preconstruct: {
122
128
  entrypoints: [
123
129
  "index.ts",
@@ -143,7 +149,7 @@ async function balances(balanceModule, chainConnectors, chaindataProvider, addre
143
149
  }
144
150
  const filterMirrorTokens = (balance, i, balances) => {
145
151
  var _balance$token;
146
- // TODO implement a mirrorOf property, which should be set from chaindata
152
+ // TODO: implement a mirrorOf property, which should be set from chaindata
147
153
  const mirrorOf = (_balance$token = balance.token) === null || _balance$token === void 0 ? void 0 : _balance$token.mirrorOf;
148
154
  return !mirrorOf || !balances.find(b => b.tokenId === mirrorOf);
149
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-pr447-20230214040957",
68
+ version: "0.0.0-pr447-20230222123200",
66
69
  author: "Talisman",
67
70
  homepage: "https://talisman.xyz",
68
71
  license: "UNLICENSED",
@@ -89,18 +92,18 @@ var packageJson = {
89
92
  clean: "rm -rf dist && rm -rf .turbo rm -rf node_modules"
90
93
  },
91
94
  dependencies: {
92
- "@polkadot/types": "9.10.5",
93
95
  "@talismn/chain-connector": "workspace:^",
94
96
  "@talismn/chain-connector-evm": "workspace:^",
95
97
  "@talismn/chaindata-provider": "workspace:^",
96
98
  "@talismn/token-rates": "workspace:^",
97
99
  "@talismn/util": "workspace:^",
98
100
  anylogger: "^1.0.11",
99
- dexie: "^3.2.2",
101
+ dexie: "^3.2.3",
100
102
  lodash: "^4.17.21",
101
103
  "typescript-memoize": "^1.1.0"
102
104
  },
103
105
  devDependencies: {
106
+ "@polkadot/types": "^9.10.5",
104
107
  "@talismn/eslint-config": "workspace:^",
105
108
  "@talismn/tsconfig": "workspace:^",
106
109
  "@types/jest": "^27.5.1",
@@ -109,6 +112,9 @@ var packageJson = {
109
112
  "ts-jest": "^28.0.2",
110
113
  typescript: "^4.6.4"
111
114
  },
115
+ peerDependencies: {
116
+ "@polkadot/types": "9.x"
117
+ },
112
118
  preconstruct: {
113
119
  entrypoints: [
114
120
  "index.ts",
@@ -134,7 +140,7 @@ async function balances(balanceModule, chainConnectors, chaindataProvider, addre
134
140
  }
135
141
  const filterMirrorTokens = (balance, i, balances) => {
136
142
  var _balance$token;
137
- // TODO implement a mirrorOf property, which should be set from chaindata
143
+ // TODO: implement a mirrorOf property, which should be set from chaindata
138
144
  const mirrorOf = (_balance$token = balance.token) === null || _balance$token === void 0 ? void 0 : _balance$token.mirrorOf;
139
145
  return !mirrorOf || !balances.find(b => b.tokenId === mirrorOf);
140
146
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@talismn/balances",
3
- "version": "0.0.0-pr447-20230214040957",
3
+ "version": "0.0.0-pr447-20230222123200",
4
4
  "author": "Talisman",
5
5
  "homepage": "https://talisman.xyz",
6
6
  "license": "UNLICENSED",
@@ -27,26 +27,29 @@
27
27
  "clean": "rm -rf dist && rm -rf .turbo rm -rf node_modules"
28
28
  },
29
29
  "dependencies": {
30
- "@polkadot/types": "9.10.5",
31
- "@talismn/chain-connector": "^0.0.0-pr447-20230214040957",
32
- "@talismn/chain-connector-evm": "^0.0.0-pr447-20230214040957",
33
- "@talismn/chaindata-provider": "^0.0.0-pr447-20230214040957",
34
- "@talismn/token-rates": "^0.0.0-pr447-20230214040957",
35
- "@talismn/util": "^0.0.0-pr447-20230214040957",
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-pr447-20230222123200",
34
+ "@talismn/util": "^0.1.7",
36
35
  "anylogger": "^1.0.11",
37
- "dexie": "^3.2.2",
36
+ "dexie": "^3.2.3",
38
37
  "lodash": "^4.17.21",
39
38
  "typescript-memoize": "^1.1.0"
40
39
  },
41
40
  "devDependencies": {
42
- "@talismn/eslint-config": "^0.0.0-pr447-20230214040957",
43
- "@talismn/tsconfig": "^0.0.0-pr447-20230214040957",
41
+ "@polkadot/types": "^9.10.5",
42
+ "@talismn/eslint-config": "^0.0.1",
43
+ "@talismn/tsconfig": "^0.0.2",
44
44
  "@types/jest": "^27.5.1",
45
45
  "eslint": "^8.4.0",
46
46
  "jest": "^28.1.0",
47
47
  "ts-jest": "^28.0.2",
48
48
  "typescript": "^4.6.4"
49
49
  },
50
+ "peerDependencies": {
51
+ "@polkadot/types": "9.x"
52
+ },
50
53
  "preconstruct": {
51
54
  "entrypoints": [
52
55
  "index.ts",