@talismn/balances 0.9.10 → 0.9.11
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/dist/declarations/src/modules/SubstrateNativeModule/index.d.ts +1 -0
- package/dist/declarations/src/modules/abis/index.d.ts +1 -0
- package/dist/declarations/src/modules/index.d.ts +1 -0
- package/dist/talismn-balances.cjs.dev.js +19 -20
- package/dist/talismn-balances.cjs.prod.js +19 -20
- package/dist/talismn-balances.esm.js +15 -24
- package/package.json +6 -6
@@ -4,4 +4,5 @@ export { filterBaseLocks, getLockTitle } from "./util/balanceLockTypes";
|
|
4
4
|
export type { BalanceLockType } from "./util/balanceLockTypes";
|
5
5
|
export { subNativeTokenId } from "./types";
|
6
6
|
export type { CustomSubNativeToken, ModuleType, SubNativeBalance, SubNativeChainMeta, SubNativeModuleConfig, SubNativeToken, SubNativeTransferParams, } from "./types";
|
7
|
+
export * from "./util/subtensor";
|
7
8
|
export declare const SubNativeModule: NewBalanceModule<ModuleType, SubNativeToken | CustomSubNativeToken, SubNativeChainMeta, SubNativeModuleConfig, SubNativeTransferParams>;
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./multicall";
|
@@ -2,11 +2,10 @@
|
|
2
2
|
|
3
3
|
var PromisePool = require('@supercharge/promise-pool');
|
4
4
|
var chaindataProvider = require('@talismn/chaindata-provider');
|
5
|
-
var
|
5
|
+
var sapi = require('@talismn/sapi');
|
6
6
|
var dexie = require('dexie');
|
7
7
|
var isEqual = require('lodash/isEqual');
|
8
8
|
var rxjs = require('rxjs');
|
9
|
-
var scaleTs = require('scale-ts');
|
10
9
|
var anylogger = require('anylogger');
|
11
10
|
var tokenRates = require('@talismn/token-rates');
|
12
11
|
var util = require('@talismn/util');
|
@@ -16,13 +15,14 @@ var utilCrypto = require('@polkadot/util-crypto');
|
|
16
15
|
var pako = require('pako');
|
17
16
|
var viem = require('viem');
|
18
17
|
var txwrapperCore = require('@substrate/txwrapper-core');
|
18
|
+
var scale = require('@talismn/scale');
|
19
19
|
var camelCase = require('lodash/camelCase');
|
20
20
|
var types = require('@polkadot/types');
|
21
21
|
var groupBy = require('lodash/groupBy');
|
22
22
|
var utils = require('@polkadot-api/utils');
|
23
23
|
var polkadotApi = require('polkadot-api');
|
24
24
|
var chainConnector = require('@talismn/chain-connector');
|
25
|
-
var
|
25
|
+
var scaleTs = require('scale-ts');
|
26
26
|
var upperFirst = require('lodash/upperFirst');
|
27
27
|
var apiContract = require('@polkadot/api-contract');
|
28
28
|
var lzString = require('lz-string');
|
@@ -1185,25 +1185,16 @@ class MiniMetadataUpdater {
|
|
1185
1185
|
if (specName === null) return;
|
1186
1186
|
if (specVersion === null) return;
|
1187
1187
|
const fetchMetadata = async () => {
|
1188
|
-
const errors = {
|
1189
|
-
v15: null,
|
1190
|
-
v14: null
|
1191
|
-
};
|
1192
1188
|
try {
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1189
|
+
return await sapi.fetchBestMetadata((method, params, isCacheable) => {
|
1190
|
+
if (!this.#chainConnectors.substrate) throw new Error("Substrate connector is not available");
|
1191
|
+
return this.#chainConnectors.substrate.send(chainId, method, params, isCacheable);
|
1192
|
+
}, true // allow v14 fallback
|
1193
|
+
);
|
1194
|
+
} catch (err) {
|
1195
|
+
log.warn(`Failed to fetch metadata for chain ${chainId}`);
|
1196
|
+
return undefined;
|
1198
1197
|
}
|
1199
|
-
try {
|
1200
|
-
const response = await this.#chainConnectors.substrate?.send(chainId, "state_getMetadata", []);
|
1201
|
-
if (response) return response;
|
1202
|
-
} catch (v14Cause) {
|
1203
|
-
errors.v14 = v14Cause;
|
1204
|
-
}
|
1205
|
-
log.warn(`Failed to fetch both metadata v15 and v14 for chain ${chainId}`, errors.v15, errors.v14);
|
1206
|
-
return null;
|
1207
1198
|
};
|
1208
1199
|
const [metadataRpc, systemProperties] = await Promise.all([fetchMetadata(), this.#chainConnectors.substrate?.send(chainId, "system_properties", [])]);
|
1209
1200
|
for (const mod of this.#balanceModules.filter(m => m.type.startsWith("substrate-"))) {
|
@@ -7520,8 +7511,12 @@ exports.EvmTokenFetcher = EvmTokenFetcher;
|
|
7520
7511
|
exports.EvmUniswapV2Module = EvmUniswapV2Module;
|
7521
7512
|
exports.FiatSumBalancesFormatter = FiatSumBalancesFormatter;
|
7522
7513
|
exports.MiniMetadataUpdater = MiniMetadataUpdater;
|
7514
|
+
exports.ONE_ALPHA_TOKEN = ONE_ALPHA_TOKEN;
|
7523
7515
|
exports.PlanckSumBalancesFormatter = PlanckSumBalancesFormatter;
|
7524
7516
|
exports.RpcStateQueryHelper = RpcStateQueryHelper;
|
7517
|
+
exports.SCALE_FACTOR = SCALE_FACTOR;
|
7518
|
+
exports.SUBTENSOR_MIN_STAKE_AMOUNT_PLANK = SUBTENSOR_MIN_STAKE_AMOUNT_PLANK;
|
7519
|
+
exports.SUBTENSOR_ROOT_NETUID = SUBTENSOR_ROOT_NETUID;
|
7525
7520
|
exports.SubAssetsModule = SubAssetsModule;
|
7526
7521
|
exports.SubEquilibriumModule = SubEquilibriumModule;
|
7527
7522
|
exports.SubForeignAssetsModule = SubForeignAssetsModule;
|
@@ -7530,8 +7525,12 @@ exports.SubPsp22Module = SubPsp22Module;
|
|
7530
7525
|
exports.SubTokensModule = SubTokensModule;
|
7531
7526
|
exports.SumBalancesFormatter = SumBalancesFormatter;
|
7532
7527
|
exports.TalismanBalancesDatabase = TalismanBalancesDatabase;
|
7528
|
+
exports.abiMulticall = abiMulticall;
|
7533
7529
|
exports.balances = balances;
|
7534
7530
|
exports.buildStorageCoders = buildStorageCoders;
|
7531
|
+
exports.calculateAlphaPrice = calculateAlphaPrice;
|
7532
|
+
exports.calculateTaoAmountFromAlpha = calculateTaoAmountFromAlpha;
|
7533
|
+
exports.calculateTaoFromDynamicInfo = calculateTaoFromDynamicInfo;
|
7535
7534
|
exports.compress = compress;
|
7536
7535
|
exports.configureStore = configureStore;
|
7537
7536
|
exports.db = db;
|
@@ -2,11 +2,10 @@
|
|
2
2
|
|
3
3
|
var PromisePool = require('@supercharge/promise-pool');
|
4
4
|
var chaindataProvider = require('@talismn/chaindata-provider');
|
5
|
-
var
|
5
|
+
var sapi = require('@talismn/sapi');
|
6
6
|
var dexie = require('dexie');
|
7
7
|
var isEqual = require('lodash/isEqual');
|
8
8
|
var rxjs = require('rxjs');
|
9
|
-
var scaleTs = require('scale-ts');
|
10
9
|
var anylogger = require('anylogger');
|
11
10
|
var tokenRates = require('@talismn/token-rates');
|
12
11
|
var util = require('@talismn/util');
|
@@ -16,13 +15,14 @@ var utilCrypto = require('@polkadot/util-crypto');
|
|
16
15
|
var pako = require('pako');
|
17
16
|
var viem = require('viem');
|
18
17
|
var txwrapperCore = require('@substrate/txwrapper-core');
|
18
|
+
var scale = require('@talismn/scale');
|
19
19
|
var camelCase = require('lodash/camelCase');
|
20
20
|
var types = require('@polkadot/types');
|
21
21
|
var groupBy = require('lodash/groupBy');
|
22
22
|
var utils = require('@polkadot-api/utils');
|
23
23
|
var polkadotApi = require('polkadot-api');
|
24
24
|
var chainConnector = require('@talismn/chain-connector');
|
25
|
-
var
|
25
|
+
var scaleTs = require('scale-ts');
|
26
26
|
var upperFirst = require('lodash/upperFirst');
|
27
27
|
var apiContract = require('@polkadot/api-contract');
|
28
28
|
var lzString = require('lz-string');
|
@@ -1185,25 +1185,16 @@ class MiniMetadataUpdater {
|
|
1185
1185
|
if (specName === null) return;
|
1186
1186
|
if (specVersion === null) return;
|
1187
1187
|
const fetchMetadata = async () => {
|
1188
|
-
const errors = {
|
1189
|
-
v15: null,
|
1190
|
-
v14: null
|
1191
|
-
};
|
1192
1188
|
try {
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1189
|
+
return await sapi.fetchBestMetadata((method, params, isCacheable) => {
|
1190
|
+
if (!this.#chainConnectors.substrate) throw new Error("Substrate connector is not available");
|
1191
|
+
return this.#chainConnectors.substrate.send(chainId, method, params, isCacheable);
|
1192
|
+
}, true // allow v14 fallback
|
1193
|
+
);
|
1194
|
+
} catch (err) {
|
1195
|
+
log.warn(`Failed to fetch metadata for chain ${chainId}`);
|
1196
|
+
return undefined;
|
1198
1197
|
}
|
1199
|
-
try {
|
1200
|
-
const response = await this.#chainConnectors.substrate?.send(chainId, "state_getMetadata", []);
|
1201
|
-
if (response) return response;
|
1202
|
-
} catch (v14Cause) {
|
1203
|
-
errors.v14 = v14Cause;
|
1204
|
-
}
|
1205
|
-
log.warn(`Failed to fetch both metadata v15 and v14 for chain ${chainId}`, errors.v15, errors.v14);
|
1206
|
-
return null;
|
1207
1198
|
};
|
1208
1199
|
const [metadataRpc, systemProperties] = await Promise.all([fetchMetadata(), this.#chainConnectors.substrate?.send(chainId, "system_properties", [])]);
|
1209
1200
|
for (const mod of this.#balanceModules.filter(m => m.type.startsWith("substrate-"))) {
|
@@ -7520,8 +7511,12 @@ exports.EvmTokenFetcher = EvmTokenFetcher;
|
|
7520
7511
|
exports.EvmUniswapV2Module = EvmUniswapV2Module;
|
7521
7512
|
exports.FiatSumBalancesFormatter = FiatSumBalancesFormatter;
|
7522
7513
|
exports.MiniMetadataUpdater = MiniMetadataUpdater;
|
7514
|
+
exports.ONE_ALPHA_TOKEN = ONE_ALPHA_TOKEN;
|
7523
7515
|
exports.PlanckSumBalancesFormatter = PlanckSumBalancesFormatter;
|
7524
7516
|
exports.RpcStateQueryHelper = RpcStateQueryHelper;
|
7517
|
+
exports.SCALE_FACTOR = SCALE_FACTOR;
|
7518
|
+
exports.SUBTENSOR_MIN_STAKE_AMOUNT_PLANK = SUBTENSOR_MIN_STAKE_AMOUNT_PLANK;
|
7519
|
+
exports.SUBTENSOR_ROOT_NETUID = SUBTENSOR_ROOT_NETUID;
|
7525
7520
|
exports.SubAssetsModule = SubAssetsModule;
|
7526
7521
|
exports.SubEquilibriumModule = SubEquilibriumModule;
|
7527
7522
|
exports.SubForeignAssetsModule = SubForeignAssetsModule;
|
@@ -7530,8 +7525,12 @@ exports.SubPsp22Module = SubPsp22Module;
|
|
7530
7525
|
exports.SubTokensModule = SubTokensModule;
|
7531
7526
|
exports.SumBalancesFormatter = SumBalancesFormatter;
|
7532
7527
|
exports.TalismanBalancesDatabase = TalismanBalancesDatabase;
|
7528
|
+
exports.abiMulticall = abiMulticall;
|
7533
7529
|
exports.balances = balances;
|
7534
7530
|
exports.buildStorageCoders = buildStorageCoders;
|
7531
|
+
exports.calculateAlphaPrice = calculateAlphaPrice;
|
7532
|
+
exports.calculateTaoAmountFromAlpha = calculateTaoAmountFromAlpha;
|
7533
|
+
exports.calculateTaoFromDynamicInfo = calculateTaoFromDynamicInfo;
|
7535
7534
|
exports.compress = compress;
|
7536
7535
|
exports.configureStore = configureStore;
|
7537
7536
|
exports.db = db;
|
@@ -1,10 +1,9 @@
|
|
1
1
|
import PromisePool$1, { PromisePool } from '@supercharge/promise-pool';
|
2
2
|
import { fetchMiniMetadatas, fetchInitMiniMetadatas, availableTokenLogoFilenames, githubTokenLogoUrl } from '@talismn/chaindata-provider';
|
3
|
-
import {
|
3
|
+
import { fetchBestMetadata, getScaleApi } from '@talismn/sapi';
|
4
4
|
import { Dexie, liveQuery } from 'dexie';
|
5
5
|
import isEqual from 'lodash/isEqual';
|
6
6
|
import { from, Observable, scan, share, map, switchAll, combineLatest, mergeMap, toArray, interval, startWith, exhaustMap, pipe, filter, shareReplay, combineLatestWith, distinctUntilChanged, firstValueFrom, BehaviorSubject, debounceTime, takeUntil, switchMap, withLatestFrom, concatMap } from 'rxjs';
|
7
|
-
import { u32, Option, Bytes, u128, Struct } from 'scale-ts';
|
8
7
|
import anylogger from 'anylogger';
|
9
8
|
import { newTokenRates } from '@talismn/token-rates';
|
10
9
|
import { isBigInt, BigMath, planckToTokens, isTruthy, isArrayOf, isEthereumAddress, hasOwnProperty, decodeAnyAddress, isNotNil, blake2Concat, firstThenDebounce, Deferred } from '@talismn/util';
|
@@ -14,13 +13,14 @@ import { xxhashAsU8a, blake2AsU8a } from '@polkadot/util-crypto';
|
|
14
13
|
import pako from 'pako';
|
15
14
|
import { parseAbi, isHex, hexToBigInt } from 'viem';
|
16
15
|
import { defineMethod } from '@substrate/txwrapper-core';
|
16
|
+
import { unifyMetadata, decAnyMetadata, getDynamicBuilder, getLookupFn, getMetadataVersion, compactMetadata, encodeMetadata, decodeScale, encodeStateKey, papiParse } from '@talismn/scale';
|
17
17
|
import camelCase from 'lodash/camelCase';
|
18
18
|
import { Metadata, TypeRegistry } from '@polkadot/types';
|
19
19
|
import groupBy from 'lodash/groupBy';
|
20
|
-
import { mergeUint8, toHex
|
20
|
+
import { mergeUint8, toHex } from '@polkadot-api/utils';
|
21
21
|
import { Binary, AccountId } from 'polkadot-api';
|
22
22
|
import { ChainConnectionError } from '@talismn/chain-connector';
|
23
|
-
import {
|
23
|
+
import { u32, u128, Struct } from 'scale-ts';
|
24
24
|
import upperFirst from 'lodash/upperFirst';
|
25
25
|
import { Abi } from '@polkadot/api-contract';
|
26
26
|
import { compressToEncodedURIComponent } from 'lz-string';
|
@@ -1172,25 +1172,16 @@ class MiniMetadataUpdater {
|
|
1172
1172
|
if (specName === null) return;
|
1173
1173
|
if (specVersion === null) return;
|
1174
1174
|
const fetchMetadata = async () => {
|
1175
|
-
const errors = {
|
1176
|
-
v15: null,
|
1177
|
-
v14: null
|
1178
|
-
};
|
1179
|
-
try {
|
1180
|
-
const response = await this.#chainConnectors.substrate?.send(chainId, "state_call", ["Metadata_metadata_at_version", toHex(u32.enc(15))]);
|
1181
|
-
const result = response ? Option(Bytes()).dec(response) : null;
|
1182
|
-
if (result) return result;
|
1183
|
-
} catch (v15Cause) {
|
1184
|
-
errors.v15 = v15Cause;
|
1185
|
-
}
|
1186
1175
|
try {
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1176
|
+
return await fetchBestMetadata((method, params, isCacheable) => {
|
1177
|
+
if (!this.#chainConnectors.substrate) throw new Error("Substrate connector is not available");
|
1178
|
+
return this.#chainConnectors.substrate.send(chainId, method, params, isCacheable);
|
1179
|
+
}, true // allow v14 fallback
|
1180
|
+
);
|
1181
|
+
} catch (err) {
|
1182
|
+
log.warn(`Failed to fetch metadata for chain ${chainId}`);
|
1183
|
+
return undefined;
|
1191
1184
|
}
|
1192
|
-
log.warn(`Failed to fetch both metadata v15 and v14 for chain ${chainId}`, errors.v15, errors.v14);
|
1193
|
-
return null;
|
1194
1185
|
};
|
1195
1186
|
const [metadataRpc, systemProperties] = await Promise.all([fetchMetadata(), this.#chainConnectors.substrate?.send(chainId, "system_properties", [])]);
|
1196
1187
|
for (const mod of this.#balanceModules.filter(m => m.type.startsWith("substrate-"))) {
|
@@ -3847,7 +3838,7 @@ const SubForeignAssetsModule = hydrate => {
|
|
3847
3838
|
const callData = Binary.fromBytes(mergeUint8([new Uint8Array(location), codec.enc(args)]));
|
3848
3839
|
return {
|
3849
3840
|
type: "substrate",
|
3850
|
-
callData: toHex
|
3841
|
+
callData: toHex(callData.asBytes())
|
3851
3842
|
};
|
3852
3843
|
} catch (cause) {
|
3853
3844
|
throw new Error(`Failed to build ${moduleType$3} transfer tx`, {
|
@@ -7368,7 +7359,7 @@ const SubTokensModule = hydrate => {
|
|
7368
7359
|
}
|
7369
7360
|
return {
|
7370
7361
|
type: "substrate",
|
7371
|
-
callData: toHex
|
7362
|
+
callData: toHex(callData.asBytes())
|
7372
7363
|
};
|
7373
7364
|
}
|
7374
7365
|
};
|
@@ -7495,4 +7486,4 @@ const updateEvmTokens = async (chaindataProvider, evmTokenFetcher) => {
|
|
7495
7486
|
await evmTokenFetcher.update(evmNetworkIds);
|
7496
7487
|
};
|
7497
7488
|
|
7498
|
-
export { Balance, BalanceFormatter, BalanceValueGetter, Balances, Change24hCurrencyFormatter, DefaultBalanceModule, EvmErc20Module, EvmNativeModule, EvmTokenFetcher, EvmUniswapV2Module, FiatSumBalancesFormatter, MiniMetadataUpdater, PlanckSumBalancesFormatter, RpcStateQueryHelper, SubAssetsModule, SubEquilibriumModule, SubForeignAssetsModule, SubNativeModule, SubPsp22Module, SubTokensModule, SumBalancesFormatter, TalismanBalancesDatabase, balances, buildStorageCoders, compress, configureStore, db, decodeOutput, decompress, defaultBalanceModules, deriveMiniMetadataId, detectTransferMethod, erc20Abi, erc20BalancesAggregatorAbi, evmErc20TokenId, evmNativeTokenId, evmUniswapV2TokenId, excludeFromFeePayableLocks, excludeFromTransferableAmount, filterBaseLocks, filterMirrorTokens, findChainMeta, getBalanceId, getLockTitle, getUniqueChainIds, getValueId, hydrateChaindataAndMiniMetadata, includeInTotalExtraAmount, makeContractCaller, subAssetTokenId, subEquilibriumTokenId, subForeignAssetTokenId, subNativeTokenId, subPsp22TokenId, subTokensTokenId, uniswapV2PairAbi, updateCustomMiniMetadata, updateEvmTokens };
|
7489
|
+
export { Balance, BalanceFormatter, BalanceValueGetter, Balances, Change24hCurrencyFormatter, DefaultBalanceModule, EvmErc20Module, EvmNativeModule, EvmTokenFetcher, EvmUniswapV2Module, FiatSumBalancesFormatter, MiniMetadataUpdater, ONE_ALPHA_TOKEN, PlanckSumBalancesFormatter, RpcStateQueryHelper, SCALE_FACTOR, SUBTENSOR_MIN_STAKE_AMOUNT_PLANK, SUBTENSOR_ROOT_NETUID, SubAssetsModule, SubEquilibriumModule, SubForeignAssetsModule, SubNativeModule, SubPsp22Module, SubTokensModule, SumBalancesFormatter, TalismanBalancesDatabase, abiMulticall, balances, buildStorageCoders, calculateAlphaPrice, calculateTaoAmountFromAlpha, calculateTaoFromDynamicInfo, compress, configureStore, db, decodeOutput, decompress, defaultBalanceModules, deriveMiniMetadataId, detectTransferMethod, erc20Abi, erc20BalancesAggregatorAbi, evmErc20TokenId, evmNativeTokenId, evmUniswapV2TokenId, excludeFromFeePayableLocks, excludeFromTransferableAmount, filterBaseLocks, filterMirrorTokens, findChainMeta, getBalanceId, getLockTitle, getUniqueChainIds, getValueId, hydrateChaindataAndMiniMetadata, includeInTotalExtraAmount, makeContractCaller, subAssetTokenId, subEquilibriumTokenId, subForeignAssetTokenId, subNativeTokenId, subPsp22TokenId, subTokensTokenId, uniswapV2PairAbi, updateCustomMiniMetadata, updateEvmTokens };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@talismn/balances",
|
3
|
-
"version": "0.9.
|
3
|
+
"version": "0.9.11",
|
4
4
|
"author": "Talisman",
|
5
5
|
"homepage": "https://talisman.xyz",
|
6
6
|
"license": "GPL-3.0-or-later",
|
@@ -34,12 +34,12 @@
|
|
34
34
|
"rxjs": "^7.8.1",
|
35
35
|
"scale-ts": "^1.6.1",
|
36
36
|
"viem": "^2.27.3",
|
37
|
-
"@talismn/chain-connector": "0.
|
38
|
-
"@talismn/chain-connector-evm": "0.
|
39
|
-
"@talismn/
|
40
|
-
"@talismn/
|
41
|
-
"@talismn/token-rates": "2.0.10",
|
37
|
+
"@talismn/chain-connector": "0.11.0",
|
38
|
+
"@talismn/chain-connector-evm": "0.11.0",
|
39
|
+
"@talismn/sapi": "0.0.5",
|
40
|
+
"@talismn/chaindata-provider": "0.11.0",
|
42
41
|
"@talismn/scale": "0.1.2",
|
42
|
+
"@talismn/token-rates": "2.0.11",
|
43
43
|
"@talismn/util": "0.4.2"
|
44
44
|
},
|
45
45
|
"devDependencies": {
|