@talismn/balances 0.7.1 → 0.8.0
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.
@@ -2,6 +2,7 @@ export declare const SUBTENSOR_ROOT_NETUID = 0;
|
|
2
2
|
export declare const SUBTENSOR_MIN_STAKE_AMOUNT_PLANK = 1000000n;
|
3
3
|
export declare const SCALE_FACTOR: bigint;
|
4
4
|
export declare const ONE_ALPHA_TOKEN: bigint;
|
5
|
+
export declare const BITTENSOR_TESTNET_CHAIN_ID = "bittensor-testnet";
|
5
6
|
export declare const EncodeParams_GetStakeInfoForColdkey: (address: string) => string;
|
6
7
|
export declare const DecodeResult_GetStakeInfoForColdkey: (result: string) => {
|
7
8
|
hotkey: import("polkadot-api").SS58String;
|
@@ -109,7 +109,7 @@ class EvmTokenFetcher {
|
|
109
109
|
|
110
110
|
var packageJson = {
|
111
111
|
name: "@talismn/balances",
|
112
|
-
version: "0.
|
112
|
+
version: "0.8.0",
|
113
113
|
author: "Talisman",
|
114
114
|
homepage: "https://talisman.xyz",
|
115
115
|
license: "GPL-3.0-or-later",
|
@@ -980,8 +980,7 @@ const getValueId = amount => {
|
|
980
980
|
hotkey,
|
981
981
|
netuid
|
982
982
|
} = meta;
|
983
|
-
if (hotkey && netuid) return `${hotkey.toString()}${netuid.toString()}`;
|
984
|
-
return "";
|
983
|
+
if (hotkey && netuid !== undefined) return `${hotkey.toString()}${netuid.toString()}`;
|
985
984
|
}
|
986
985
|
return "";
|
987
986
|
};
|
@@ -4691,6 +4690,7 @@ const SUBTENSOR_MIN_STAKE_AMOUNT_PLANK = 1000000n;
|
|
4691
4690
|
const TAO_DECIMALS = 9n;
|
4692
4691
|
const SCALE_FACTOR = 10n ** TAO_DECIMALS; // Equivalent to 10e9 for precision
|
4693
4692
|
const ONE_ALPHA_TOKEN = SCALE_FACTOR;
|
4693
|
+
const BITTENSOR_TESTNET_CHAIN_ID = "bittensor-testnet";
|
4694
4694
|
const BittensorAccountPrefix = 42;
|
4695
4695
|
const BittensorAccountId = polkadotApi.AccountId(BittensorAccountPrefix);
|
4696
4696
|
|
@@ -4882,10 +4882,10 @@ async function subscribeSubtensorStaking(chaindataProvider, chainConnector, addr
|
|
4882
4882
|
dynamicInfoCache.set(netuid, decodedResult); // Cache successful response
|
4883
4883
|
return decodedResult;
|
4884
4884
|
} catch (error) {
|
4885
|
-
log.
|
4885
|
+
log.trace(`Attempt ${attempt} failed for netuid ${netuid}:`, error);
|
4886
4886
|
if (attempt < MAX_RETRIES) {
|
4887
4887
|
const backoffTime = RETRY_DELAY_MS * 2 ** (attempt - 1);
|
4888
|
-
log.
|
4888
|
+
log.trace(`Retrying in ${backoffTime}ms...`);
|
4889
4889
|
await delay(backoffTime);
|
4890
4890
|
}
|
4891
4891
|
}
|
@@ -4893,7 +4893,7 @@ async function subscribeSubtensorStaking(chaindataProvider, chainConnector, addr
|
|
4893
4893
|
if (dynamicInfoCache.has(netuid)) {
|
4894
4894
|
return dynamicInfoCache.get(netuid); // Use cached value on failure
|
4895
4895
|
}
|
4896
|
-
log.
|
4896
|
+
log.trace(`Failed to fetch dynamic info for netuid ${netuid} after ${MAX_RETRIES} attempts.`);
|
4897
4897
|
return null;
|
4898
4898
|
};
|
4899
4899
|
return Promise.all(uniqueNetuids.map(fetchInfo));
|
@@ -4902,6 +4902,7 @@ async function subscribeSubtensorStaking(chaindataProvider, chainConnector, addr
|
|
4902
4902
|
// mergeMap lets us run N concurrent queries, where N is the value of `concurrency`
|
4903
4903
|
rxjs.mergeMap(async address => {
|
4904
4904
|
const queryMethods = [async () => {
|
4905
|
+
if (chainId === BITTENSOR_TESTNET_CHAIN_ID) return [];
|
4905
4906
|
const method = "StakeInfoRuntimeApi_get_stake_info_for_coldkey";
|
4906
4907
|
const params = EncodeParams_GetStakeInfoForColdkey(address);
|
4907
4908
|
const response = await chainConnector.send(chainId, "state_call", [method, params], undefined, {
|
@@ -109,7 +109,7 @@ class EvmTokenFetcher {
|
|
109
109
|
|
110
110
|
var packageJson = {
|
111
111
|
name: "@talismn/balances",
|
112
|
-
version: "0.
|
112
|
+
version: "0.8.0",
|
113
113
|
author: "Talisman",
|
114
114
|
homepage: "https://talisman.xyz",
|
115
115
|
license: "GPL-3.0-or-later",
|
@@ -980,8 +980,7 @@ const getValueId = amount => {
|
|
980
980
|
hotkey,
|
981
981
|
netuid
|
982
982
|
} = meta;
|
983
|
-
if (hotkey && netuid) return `${hotkey.toString()}${netuid.toString()}`;
|
984
|
-
return "";
|
983
|
+
if (hotkey && netuid !== undefined) return `${hotkey.toString()}${netuid.toString()}`;
|
985
984
|
}
|
986
985
|
return "";
|
987
986
|
};
|
@@ -4691,6 +4690,7 @@ const SUBTENSOR_MIN_STAKE_AMOUNT_PLANK = 1000000n;
|
|
4691
4690
|
const TAO_DECIMALS = 9n;
|
4692
4691
|
const SCALE_FACTOR = 10n ** TAO_DECIMALS; // Equivalent to 10e9 for precision
|
4693
4692
|
const ONE_ALPHA_TOKEN = SCALE_FACTOR;
|
4693
|
+
const BITTENSOR_TESTNET_CHAIN_ID = "bittensor-testnet";
|
4694
4694
|
const BittensorAccountPrefix = 42;
|
4695
4695
|
const BittensorAccountId = polkadotApi.AccountId(BittensorAccountPrefix);
|
4696
4696
|
|
@@ -4882,10 +4882,10 @@ async function subscribeSubtensorStaking(chaindataProvider, chainConnector, addr
|
|
4882
4882
|
dynamicInfoCache.set(netuid, decodedResult); // Cache successful response
|
4883
4883
|
return decodedResult;
|
4884
4884
|
} catch (error) {
|
4885
|
-
log.
|
4885
|
+
log.trace(`Attempt ${attempt} failed for netuid ${netuid}:`, error);
|
4886
4886
|
if (attempt < MAX_RETRIES) {
|
4887
4887
|
const backoffTime = RETRY_DELAY_MS * 2 ** (attempt - 1);
|
4888
|
-
log.
|
4888
|
+
log.trace(`Retrying in ${backoffTime}ms...`);
|
4889
4889
|
await delay(backoffTime);
|
4890
4890
|
}
|
4891
4891
|
}
|
@@ -4893,7 +4893,7 @@ async function subscribeSubtensorStaking(chaindataProvider, chainConnector, addr
|
|
4893
4893
|
if (dynamicInfoCache.has(netuid)) {
|
4894
4894
|
return dynamicInfoCache.get(netuid); // Use cached value on failure
|
4895
4895
|
}
|
4896
|
-
log.
|
4896
|
+
log.trace(`Failed to fetch dynamic info for netuid ${netuid} after ${MAX_RETRIES} attempts.`);
|
4897
4897
|
return null;
|
4898
4898
|
};
|
4899
4899
|
return Promise.all(uniqueNetuids.map(fetchInfo));
|
@@ -4902,6 +4902,7 @@ async function subscribeSubtensorStaking(chaindataProvider, chainConnector, addr
|
|
4902
4902
|
// mergeMap lets us run N concurrent queries, where N is the value of `concurrency`
|
4903
4903
|
rxjs.mergeMap(async address => {
|
4904
4904
|
const queryMethods = [async () => {
|
4905
|
+
if (chainId === BITTENSOR_TESTNET_CHAIN_ID) return [];
|
4905
4906
|
const method = "StakeInfoRuntimeApi_get_stake_info_for_coldkey";
|
4906
4907
|
const params = EncodeParams_GetStakeInfoForColdkey(address);
|
4907
4908
|
const response = await chainConnector.send(chainId, "state_call", [method, params], undefined, {
|
@@ -96,7 +96,7 @@ class EvmTokenFetcher {
|
|
96
96
|
|
97
97
|
var packageJson = {
|
98
98
|
name: "@talismn/balances",
|
99
|
-
version: "0.
|
99
|
+
version: "0.8.0",
|
100
100
|
author: "Talisman",
|
101
101
|
homepage: "https://talisman.xyz",
|
102
102
|
license: "GPL-3.0-or-later",
|
@@ -967,8 +967,7 @@ const getValueId = amount => {
|
|
967
967
|
hotkey,
|
968
968
|
netuid
|
969
969
|
} = meta;
|
970
|
-
if (hotkey && netuid) return `${hotkey.toString()}${netuid.toString()}`;
|
971
|
-
return "";
|
970
|
+
if (hotkey && netuid !== undefined) return `${hotkey.toString()}${netuid.toString()}`;
|
972
971
|
}
|
973
972
|
return "";
|
974
973
|
};
|
@@ -4678,6 +4677,7 @@ const SUBTENSOR_MIN_STAKE_AMOUNT_PLANK = 1000000n;
|
|
4678
4677
|
const TAO_DECIMALS = 9n;
|
4679
4678
|
const SCALE_FACTOR = 10n ** TAO_DECIMALS; // Equivalent to 10e9 for precision
|
4680
4679
|
const ONE_ALPHA_TOKEN = SCALE_FACTOR;
|
4680
|
+
const BITTENSOR_TESTNET_CHAIN_ID = "bittensor-testnet";
|
4681
4681
|
const BittensorAccountPrefix = 42;
|
4682
4682
|
const BittensorAccountId = AccountId(BittensorAccountPrefix);
|
4683
4683
|
|
@@ -4869,10 +4869,10 @@ async function subscribeSubtensorStaking(chaindataProvider, chainConnector, addr
|
|
4869
4869
|
dynamicInfoCache.set(netuid, decodedResult); // Cache successful response
|
4870
4870
|
return decodedResult;
|
4871
4871
|
} catch (error) {
|
4872
|
-
log.
|
4872
|
+
log.trace(`Attempt ${attempt} failed for netuid ${netuid}:`, error);
|
4873
4873
|
if (attempt < MAX_RETRIES) {
|
4874
4874
|
const backoffTime = RETRY_DELAY_MS * 2 ** (attempt - 1);
|
4875
|
-
log.
|
4875
|
+
log.trace(`Retrying in ${backoffTime}ms...`);
|
4876
4876
|
await delay(backoffTime);
|
4877
4877
|
}
|
4878
4878
|
}
|
@@ -4880,7 +4880,7 @@ async function subscribeSubtensorStaking(chaindataProvider, chainConnector, addr
|
|
4880
4880
|
if (dynamicInfoCache.has(netuid)) {
|
4881
4881
|
return dynamicInfoCache.get(netuid); // Use cached value on failure
|
4882
4882
|
}
|
4883
|
-
log.
|
4883
|
+
log.trace(`Failed to fetch dynamic info for netuid ${netuid} after ${MAX_RETRIES} attempts.`);
|
4884
4884
|
return null;
|
4885
4885
|
};
|
4886
4886
|
return Promise.all(uniqueNetuids.map(fetchInfo));
|
@@ -4889,6 +4889,7 @@ async function subscribeSubtensorStaking(chaindataProvider, chainConnector, addr
|
|
4889
4889
|
// mergeMap lets us run N concurrent queries, where N is the value of `concurrency`
|
4890
4890
|
mergeMap(async address => {
|
4891
4891
|
const queryMethods = [async () => {
|
4892
|
+
if (chainId === BITTENSOR_TESTNET_CHAIN_ID) return [];
|
4892
4893
|
const method = "StakeInfoRuntimeApi_get_stake_info_for_coldkey";
|
4893
4894
|
const params = EncodeParams_GetStakeInfoForColdkey(address);
|
4894
4895
|
const response = await chainConnector.send(chainId, "state_call", [method, params], undefined, {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@talismn/balances",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.8.0",
|
4
4
|
"author": "Talisman",
|
5
5
|
"homepage": "https://talisman.xyz",
|
6
6
|
"license": "GPL-3.0-or-later",
|
@@ -33,12 +33,12 @@
|
|
33
33
|
"rxjs": "^7.8.1",
|
34
34
|
"scale-ts": "^1.6.1",
|
35
35
|
"viem": "^2.21.34",
|
36
|
-
"@talismn/chain-connector": "0.8.
|
37
|
-
"@talismn/
|
38
|
-
"@talismn/
|
36
|
+
"@talismn/chain-connector": "0.8.2",
|
37
|
+
"@talismn/chaindata-provider": "0.8.2",
|
38
|
+
"@talismn/token-rates": "1.0.2",
|
39
|
+
"@talismn/chain-connector-evm": "0.8.2",
|
39
40
|
"@talismn/scale": "0.1.0",
|
40
|
-
"@talismn/util": "0.3.1"
|
41
|
-
"@talismn/token-rates": "1.0.1"
|
41
|
+
"@talismn/util": "0.3.1"
|
42
42
|
},
|
43
43
|
"devDependencies": {
|
44
44
|
"@polkadot/api-contract": "15.8.1",
|
@@ -53,8 +53,8 @@
|
|
53
53
|
"jest": "^29.7.0",
|
54
54
|
"ts-jest": "^29.2.5",
|
55
55
|
"typescript": "^5.6.3",
|
56
|
-
"@talismn/
|
57
|
-
"@talismn/
|
56
|
+
"@talismn/tsconfig": "0.0.2",
|
57
|
+
"@talismn/eslint-config": "0.0.3"
|
58
58
|
},
|
59
59
|
"peerDependencies": {
|
60
60
|
"@polkadot/api-contract": "*",
|