@ledgerhq/live-common 25.2.0-next.0 → 26.0.0-next.2
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/lib/__tests__/test-helpers/setup.js +2 -0
- package/lib/__tests__/test-helpers/setup.js.map +1 -1
- package/lib/account/helpers.d.ts.map +1 -1
- package/lib/account/helpers.js +1 -0
- package/lib/account/helpers.js.map +1 -1
- package/lib/account/serialization.d.ts.map +1 -1
- package/lib/account/serialization.js +4 -0
- package/lib/account/serialization.js.map +1 -1
- package/lib/data/icons/react/index.d.ts +1 -0
- package/lib/data/icons/react/index.d.ts.map +1 -1
- package/lib/data/icons/react/index.js +7 -5
- package/lib/data/icons/react/index.js.map +1 -1
- package/lib/data/icons/react/osmo.d.ts +8 -0
- package/lib/data/icons/react/osmo.d.ts.map +1 -0
- package/lib/data/icons/react/osmo.js +39 -0
- package/lib/data/icons/react/osmo.js.map +1 -0
- package/lib/data/icons/reactNative/index.d.ts +1 -0
- package/lib/data/icons/reactNative/index.d.ts.map +1 -1
- package/lib/data/icons/reactNative/index.js +7 -5
- package/lib/data/icons/reactNative/index.js.map +1 -1
- package/lib/data/icons/reactNative/osmo.d.ts +8 -0
- package/lib/data/icons/reactNative/osmo.d.ts.map +1 -0
- package/lib/data/icons/reactNative/osmo.js +40 -0
- package/lib/data/icons/reactNative/osmo.js.map +1 -0
- package/lib/env.d.ts +15 -5
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +10 -0
- package/lib/env.js.map +1 -1
- package/lib/env.react.d.ts +1 -1
- package/lib/env.react.d.ts.map +1 -1
- package/lib/families/cosmos/CosmosValidatorsManager.d.ts +26 -0
- package/lib/families/cosmos/CosmosValidatorsManager.d.ts.map +1 -0
- package/lib/families/cosmos/CosmosValidatorsManager.js +365 -0
- package/lib/families/cosmos/CosmosValidatorsManager.js.map +1 -0
- package/lib/families/cosmos/account.d.ts +2 -2
- package/lib/families/cosmos/account.d.ts.map +1 -1
- package/lib/families/cosmos/account.js +19 -6
- package/lib/families/cosmos/account.js.map +1 -1
- package/lib/families/cosmos/api/Cosmos.d.ts +27 -15
- package/lib/families/cosmos/api/Cosmos.d.ts.map +1 -1
- package/lib/families/cosmos/api/Cosmos.js +418 -410
- package/lib/families/cosmos/api/Cosmos.js.map +1 -1
- package/lib/families/cosmos/bridge/js.d.ts.map +1 -1
- package/lib/families/cosmos/bridge/js.js +5 -5
- package/lib/families/cosmos/bridge/js.js.map +1 -1
- package/lib/families/cosmos/bridge/mock.js +1 -1
- package/lib/families/cosmos/bridge/mock.js.map +1 -1
- package/lib/families/cosmos/bridge.integration.test.js +5 -5
- package/lib/families/cosmos/bridge.integration.test.js.map +1 -1
- package/lib/families/cosmos/cli-transaction.d.ts +3 -3
- package/lib/families/cosmos/cli-transaction.d.ts.map +1 -1
- package/lib/families/cosmos/cli-transaction.js +4 -5
- package/lib/families/cosmos/cli-transaction.js.map +1 -1
- package/lib/families/cosmos/js-buildTransaction.js +3 -3
- package/lib/families/cosmos/js-buildTransaction.js.map +1 -1
- package/lib/families/cosmos/js-createTransaction.js +1 -1
- package/lib/families/cosmos/js-createTransaction.js.map +1 -1
- package/lib/families/cosmos/js-getTransactionStatus.d.ts +17 -3
- package/lib/families/cosmos/js-getTransactionStatus.d.ts.map +1 -1
- package/lib/families/cosmos/js-getTransactionStatus.js +224 -176
- package/lib/families/cosmos/js-getTransactionStatus.js.map +1 -1
- package/lib/families/cosmos/js-prepareTransaction.js +2 -2
- package/lib/families/cosmos/js-prepareTransaction.js.map +1 -1
- package/lib/families/cosmos/js-signOperation.js +3 -3
- package/lib/families/cosmos/js-signOperation.js.map +1 -1
- package/lib/families/cosmos/js-synchronisation.js +2 -2
- package/lib/families/cosmos/js-synchronisation.js.map +1 -1
- package/lib/families/cosmos/logic.js +1 -1
- package/lib/families/cosmos/logic.js.map +1 -1
- package/lib/families/cosmos/mock.js +1 -1
- package/lib/families/cosmos/mock.js.map +1 -1
- package/lib/families/cosmos/react.d.ts +4 -4
- package/lib/families/cosmos/react.d.ts.map +1 -1
- package/lib/families/cosmos/react.js +59 -26
- package/lib/families/cosmos/react.js.map +1 -1
- package/lib/families/cosmos/react.test.js +17 -15
- package/lib/families/cosmos/react.test.js.map +1 -1
- package/lib/families/cosmos/specs.js +2 -2
- package/lib/families/cosmos/specs.js.map +1 -1
- package/lib/families/cosmos/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/cosmos/speculos-deviceActions.js +1 -1
- package/lib/families/cosmos/speculos-deviceActions.js.map +1 -1
- package/lib/families/cosmos/transaction.d.ts +2 -2
- package/lib/families/cosmos/transaction.d.ts.map +1 -1
- package/lib/families/cosmos/transaction.js +4 -4
- package/lib/families/cosmos/transaction.js.map +1 -1
- package/lib/families/cosmos/types.d.ts +31 -13
- package/lib/families/cosmos/types.d.ts.map +1 -1
- package/lib/families/cosmos/utils.d.ts +1 -0
- package/lib/families/cosmos/utils.d.ts.map +1 -1
- package/lib/families/cosmos/utils.js +7 -1
- package/lib/families/cosmos/utils.js.map +1 -1
- package/lib/families/cosmos/validators.d.ts +3 -5
- package/lib/families/cosmos/validators.d.ts.map +1 -1
- package/lib/families/cosmos/validators.js +4 -317
- package/lib/families/cosmos/validators.js.map +1 -1
- package/lib/families/filecoin/bridge/account.d.ts.map +1 -1
- package/lib/families/filecoin/bridge/account.js +11 -5
- package/lib/families/filecoin/bridge/account.js.map +1 -1
- package/lib/families/osmosis/OsmosisSupplyTypes.d.ts +48 -0
- package/lib/families/osmosis/OsmosisSupplyTypes.d.ts.map +1 -0
- package/lib/families/osmosis/OsmosisSupplyTypes.js +3 -0
- package/lib/families/osmosis/OsmosisSupplyTypes.js.map +1 -0
- package/lib/families/osmosis/account.d.ts +14 -0
- package/lib/families/osmosis/account.d.ts.map +1 -0
- package/lib/families/osmosis/account.js +60 -0
- package/lib/families/osmosis/account.js.map +1 -0
- package/lib/families/osmosis/api/sdk.d.ts +35 -0
- package/lib/families/osmosis/api/sdk.d.ts.map +1 -0
- package/lib/families/osmosis/api/sdk.js +478 -0
- package/lib/families/osmosis/api/sdk.js.map +1 -0
- package/lib/families/osmosis/api/sdk.types.d.ts +57 -0
- package/lib/families/osmosis/api/sdk.types.d.ts.map +1 -0
- package/lib/families/osmosis/api/sdk.types.js +15 -0
- package/lib/families/osmosis/api/sdk.types.js.map +1 -0
- package/lib/families/osmosis/api/sdk.unit.test.d.ts +2 -0
- package/lib/families/osmosis/api/sdk.unit.test.d.ts.map +1 -0
- package/lib/families/osmosis/api/sdk.unit.test.js +50 -0
- package/lib/families/osmosis/api/sdk.unit.test.js.map +1 -0
- package/lib/families/osmosis/bridge/js.d.ts +8 -0
- package/lib/families/osmosis/bridge/js.d.ts.map +1 -0
- package/lib/families/osmosis/bridge/js.js +98 -0
- package/lib/families/osmosis/bridge/js.js.map +1 -0
- package/lib/families/osmosis/bridge.integration.test.d.ts +2 -0
- package/lib/families/osmosis/bridge.integration.test.d.ts.map +1 -0
- package/lib/families/osmosis/bridge.integration.test.js +383 -0
- package/lib/families/osmosis/bridge.integration.test.js.map +1 -0
- package/lib/families/osmosis/cli-transaction.d.ts +38 -0
- package/lib/families/osmosis/cli-transaction.d.ts.map +1 -0
- package/lib/families/osmosis/cli-transaction.js +119 -0
- package/lib/families/osmosis/cli-transaction.js.map +1 -0
- package/lib/families/osmosis/deviceTransactionConfig.d.ts +25 -0
- package/lib/families/osmosis/deviceTransactionConfig.d.ts.map +1 -0
- package/lib/families/osmosis/deviceTransactionConfig.js +132 -0
- package/lib/families/osmosis/deviceTransactionConfig.js.map +1 -0
- package/lib/families/osmosis/errors.d.ts +4 -0
- package/lib/families/osmosis/errors.d.ts.map +1 -0
- package/lib/families/osmosis/errors.js +8 -0
- package/lib/families/osmosis/errors.js.map +1 -0
- package/lib/families/osmosis/hw-getAddress.d.ts +4 -0
- package/lib/families/osmosis/hw-getAddress.d.ts.map +1 -0
- package/lib/families/osmosis/hw-getAddress.js +64 -0
- package/lib/families/osmosis/hw-getAddress.js.map +1 -0
- package/lib/families/osmosis/js-buildTransaction.d.ts +14 -0
- package/lib/families/osmosis/js-buildTransaction.d.ts.map +1 -0
- package/lib/families/osmosis/js-buildTransaction.js +303 -0
- package/lib/families/osmosis/js-buildTransaction.js.map +1 -0
- package/lib/families/osmosis/js-estimateMaxSpendable.d.ts +15 -0
- package/lib/families/osmosis/js-estimateMaxSpendable.d.ts.map +1 -0
- package/lib/families/osmosis/js-estimateMaxSpendable.js +67 -0
- package/lib/families/osmosis/js-estimateMaxSpendable.js.map +1 -0
- package/lib/families/osmosis/js-getFeesForTransaction.d.ts +15 -0
- package/lib/families/osmosis/js-getFeesForTransaction.d.ts.map +1 -0
- package/lib/families/osmosis/js-getFeesForTransaction.js +85 -0
- package/lib/families/osmosis/js-getFeesForTransaction.js.map +1 -0
- package/lib/families/osmosis/js-getTransactionStatus.d.ts +3 -0
- package/lib/families/osmosis/js-getTransactionStatus.d.ts.map +1 -0
- package/lib/families/osmosis/js-getTransactionStatus.js +10 -0
- package/lib/families/osmosis/js-getTransactionStatus.js.map +1 -0
- package/lib/families/osmosis/js-signOperation.d.ts +10 -0
- package/lib/families/osmosis/js-signOperation.d.ts.map +1 -0
- package/lib/families/osmosis/js-signOperation.js +211 -0
- package/lib/families/osmosis/js-signOperation.js.map +1 -0
- package/lib/families/osmosis/js-synchronization.d.ts +9 -0
- package/lib/families/osmosis/js-synchronization.d.ts.map +1 -0
- package/lib/families/osmosis/js-synchronization.js +176 -0
- package/lib/families/osmosis/js-synchronization.js.map +1 -0
- package/lib/families/osmosis/js-transaction.d.ts +23 -0
- package/lib/families/osmosis/js-transaction.d.ts.map +1 -0
- package/lib/families/osmosis/js-transaction.js +177 -0
- package/lib/families/osmosis/js-transaction.js.map +1 -0
- package/lib/families/osmosis/logic.d.ts +5 -0
- package/lib/families/osmosis/logic.d.ts.map +1 -0
- package/lib/families/osmosis/logic.js +22 -0
- package/lib/families/osmosis/logic.js.map +1 -0
- package/lib/families/osmosis/preloadedData.d.ts +9 -0
- package/lib/families/osmosis/preloadedData.d.ts.map +1 -0
- package/lib/families/osmosis/preloadedData.js +32 -0
- package/lib/families/osmosis/preloadedData.js.map +1 -0
- package/lib/families/osmosis/serialization.d.ts +7 -0
- package/lib/families/osmosis/serialization.d.ts.map +1 -0
- package/lib/families/osmosis/serialization.js +5 -0
- package/lib/families/osmosis/serialization.js.map +1 -0
- package/lib/families/osmosis/specs.d.ts +7 -0
- package/lib/families/osmosis/specs.d.ts.map +1 -0
- package/lib/families/osmosis/specs.js +402 -0
- package/lib/families/osmosis/specs.js.map +1 -0
- package/lib/families/osmosis/speculos-deviceActions.d.ts +7 -0
- package/lib/families/osmosis/speculos-deviceActions.d.ts.map +1 -0
- package/lib/families/osmosis/speculos-deviceActions.js +120 -0
- package/lib/families/osmosis/speculos-deviceActions.js.map +1 -0
- package/lib/families/osmosis/transaction.d.ts +10 -0
- package/lib/families/osmosis/transaction.d.ts.map +1 -0
- package/lib/families/osmosis/transaction.js +13 -0
- package/lib/families/osmosis/transaction.js.map +1 -0
- package/lib/families/osmosis/types.d.ts +38 -0
- package/lib/families/osmosis/types.d.ts.map +1 -0
- package/lib/families/osmosis/types.js +3 -0
- package/lib/families/osmosis/types.js.map +1 -0
- package/lib/families/osmosis/utils.d.ts +8 -0
- package/lib/families/osmosis/utils.d.ts.map +1 -0
- package/lib/families/osmosis/utils.js +28 -0
- package/lib/families/osmosis/utils.js.map +1 -0
- package/lib/families/osmosis/validators.d.ts +4 -0
- package/lib/families/osmosis/validators.d.ts.map +1 -0
- package/lib/families/osmosis/validators.js +131 -0
- package/lib/families/osmosis/validators.js.map +1 -0
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +3 -0
- package/lib/featureFlags/defaultFeatures.js.map +1 -1
- package/lib/generated/account.d.ts +7 -1
- package/lib/generated/account.d.ts.map +1 -1
- package/lib/generated/account.js +4 -2
- package/lib/generated/account.js.map +1 -1
- package/lib/generated/bridge/js.d.ts +4 -0
- package/lib/generated/bridge/js.d.ts.map +1 -1
- package/lib/generated/bridge/js.js +14 -12
- package/lib/generated/bridge/js.js.map +1 -1
- package/lib/generated/cli-transaction.d.ts +33 -2
- package/lib/generated/cli-transaction.d.ts.map +1 -1
- package/lib/generated/cli-transaction.js +14 -12
- package/lib/generated/cli-transaction.js.map +1 -1
- package/lib/generated/deviceTransactionConfig.d.ts +4 -1
- package/lib/generated/deviceTransactionConfig.d.ts.map +1 -1
- package/lib/generated/deviceTransactionConfig.js +14 -12
- package/lib/generated/deviceTransactionConfig.js.map +1 -1
- package/lib/generated/hw-getAddress.d.ts +1 -0
- package/lib/generated/hw-getAddress.d.ts.map +1 -1
- package/lib/generated/hw-getAddress.js +14 -12
- package/lib/generated/hw-getAddress.js.map +1 -1
- package/lib/generated/specs.d.ts +3 -0
- package/lib/generated/specs.d.ts.map +1 -1
- package/lib/generated/specs.js +14 -12
- package/lib/generated/specs.js.map +1 -1
- package/lib/generated/speculos-deviceActions.d.ts +3 -0
- package/lib/generated/speculos-deviceActions.d.ts.map +1 -1
- package/lib/generated/speculos-deviceActions.js +14 -12
- package/lib/generated/speculos-deviceActions.js.map +1 -1
- package/lib/generated/transaction.d.ts +9 -1
- package/lib/generated/transaction.d.ts.map +1 -1
- package/lib/generated/transaction.js +14 -12
- package/lib/generated/transaction.js.map +1 -1
- package/lib/generated/types.d.ts +8 -4
- package/lib/generated/types.d.ts.map +1 -1
- package/lib/reconciliation.d.ts.map +1 -1
- package/lib/reconciliation.js +9 -0
- package/lib/reconciliation.js.map +1 -1
- package/package.json +8 -3
- package/src/__tests__/test-helpers/setup.ts +2 -0
- package/src/account/helpers.ts +1 -0
- package/src/account/serialization.ts +6 -0
- package/src/data/icons/react/index.tsx +1 -0
- package/src/data/icons/react/osmo.tsx +14 -0
- package/src/data/icons/reactNative/index.tsx +1 -0
- package/src/data/icons/reactNative/osmo.tsx +15 -0
- package/src/data/icons/svg/OSMO.svg +7 -0
- package/src/env.ts +10 -0
- package/src/families/cosmos/CosmosValidatorsManager.ts +420 -0
- package/src/families/cosmos/account.ts +29 -10
- package/src/families/cosmos/api/Cosmos.ts +267 -257
- package/src/families/cosmos/bridge/js.ts +6 -7
- package/src/families/cosmos/bridge/mock.ts +1 -1
- package/src/families/cosmos/bridge.integration.test.ts +5 -5
- package/src/families/cosmos/cli-transaction.ts +7 -8
- package/src/families/cosmos/js-buildTransaction.ts +4 -4
- package/src/families/cosmos/js-createTransaction.ts +1 -1
- package/src/families/cosmos/js-getTransactionStatus.ts +276 -226
- package/src/families/cosmos/js-prepareTransaction.ts +3 -3
- package/src/families/cosmos/js-signOperation.ts +4 -4
- package/src/families/cosmos/js-synchronisation.ts +3 -3
- package/src/families/cosmos/logic.ts +1 -1
- package/src/families/cosmos/mock.ts +1 -1
- package/src/families/cosmos/react.test.ts +25 -14
- package/src/families/cosmos/react.ts +73 -21
- package/src/families/cosmos/specs.ts +2 -2
- package/src/families/cosmos/speculos-deviceActions.ts +1 -2
- package/src/families/cosmos/transaction.ts +4 -6
- package/src/families/cosmos/types.ts +41 -13
- package/src/families/cosmos/utils.ts +8 -0
- package/src/families/cosmos/validators.ts +5 -363
- package/src/families/filecoin/bridge/account.ts +12 -5
- package/src/families/osmosis/OsmosisSupplyTypes.ts +53 -0
- package/src/families/osmosis/__snapshots__/bridge.integration.test.ts.snap +852 -0
- package/src/families/osmosis/account.ts +65 -0
- package/src/families/osmosis/api/sdk.ts +530 -0
- package/src/families/osmosis/api/sdk.types.ts +65 -0
- package/src/families/osmosis/api/sdk.unit.test.ts +70 -0
- package/src/families/osmosis/bridge/js.ts +64 -0
- package/src/families/osmosis/bridge.integration.test.ts +467 -0
- package/src/families/osmosis/cli-transaction.ts +145 -0
- package/src/families/osmosis/deviceTransactionConfig.ts +174 -0
- package/src/families/osmosis/errors.ts +13 -0
- package/src/families/osmosis/hw-getAddress.ts +14 -0
- package/src/families/osmosis/js-buildTransaction.ts +306 -0
- package/src/families/osmosis/js-estimateMaxSpendable.ts +26 -0
- package/src/families/osmosis/js-getFeesForTransaction.ts +44 -0
- package/src/families/osmosis/js-getTransactionStatus.ts +9 -0
- package/src/families/osmosis/js-signOperation.ts +172 -0
- package/src/families/osmosis/js-synchronization.ts +122 -0
- package/src/families/osmosis/js-transaction.ts +96 -0
- package/src/families/osmosis/logic.ts +26 -0
- package/src/families/osmosis/preloadedData.ts +32 -0
- package/src/families/osmosis/serialization.ts +6 -0
- package/src/families/osmosis/specs.ts +393 -0
- package/src/families/osmosis/speculos-deviceActions.ts +94 -0
- package/src/families/osmosis/transaction.ts +20 -0
- package/src/families/osmosis/types.ts +48 -0
- package/src/families/osmosis/utils.ts +31 -0
- package/src/families/osmosis/validators.ts +79 -0
- package/src/featureFlags/defaultFeatures.ts +3 -0
- package/src/generated/account.ts +3 -0
- package/src/generated/bridge/js.ts +3 -0
- package/src/generated/cli-transaction.ts +3 -0
- package/src/generated/deviceTransactionConfig.ts +5 -0
- package/src/generated/hw-getAddress.ts +3 -0
- package/src/generated/specs.ts +3 -0
- package/src/generated/speculos-deviceActions.ts +3 -0
- package/src/generated/transaction.ts +3 -0
- package/src/generated/types.ts +8 -0
- package/src/reconciliation.ts +16 -0
|
@@ -1,366 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { getEnv } from "../../env";
|
|
4
|
-
import { makeLRUCache } from "../../cache";
|
|
5
|
-
import type { CosmosValidatorItem, CosmosRewardsState } from "./types";
|
|
6
|
-
import type { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
1
|
+
import { getCryptoCurrencyById } from "../../currencies";
|
|
2
|
+
import { CosmosValidatorsManager } from "./CosmosValidatorsManager";
|
|
7
3
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
return getEnv("API_COSMOS_TESTNET_BLOCKCHAIN_EXPLORER_API_ENDPOINT");
|
|
11
|
-
} else {
|
|
12
|
-
return getEnv("API_COSMOS_BLOCKCHAIN_EXPLORER_API_ENDPOINT");
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const isStargate = (currency: CryptoCurrency) => {
|
|
17
|
-
if (currency.id === "cosmos_testnet") {
|
|
18
|
-
return getEnv("API_COSMOS_TESTNET_NODE") == "STARGATE_NODE";
|
|
19
|
-
} else {
|
|
20
|
-
return getEnv("API_COSMOS_NODE") == "STARGATE_NODE";
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const namespace = "cosmos";
|
|
25
|
-
const version = "v1beta1";
|
|
26
|
-
const cacheValidators = makeLRUCache(
|
|
27
|
-
async (
|
|
28
|
-
rewardState: CosmosRewardsState,
|
|
29
|
-
currency: CryptoCurrency
|
|
30
|
-
): Promise<CosmosValidatorItem[]> => {
|
|
31
|
-
if (isStargate(currency)) {
|
|
32
|
-
const url = `${getBaseApiUrl(
|
|
33
|
-
currency
|
|
34
|
-
)}/${namespace}/staking/${version}/validators?status=BOND_STATUS_BONDED&pagination.limit=175`;
|
|
35
|
-
const { data } = await network({
|
|
36
|
-
url,
|
|
37
|
-
method: "GET",
|
|
38
|
-
});
|
|
39
|
-
const validators = data.validators.map((validator) => {
|
|
40
|
-
const commission = parseFloat(
|
|
41
|
-
validator.commission.commission_rates.rate
|
|
42
|
-
);
|
|
43
|
-
return {
|
|
44
|
-
validatorAddress: validator.operator_address,
|
|
45
|
-
name: validator.description.moniker,
|
|
46
|
-
tokens: parseFloat(validator.tokens),
|
|
47
|
-
votingPower:
|
|
48
|
-
parseFloat(validator.tokens) /
|
|
49
|
-
(rewardState.actualBondedRatio * rewardState.totalSupply * 1000000),
|
|
50
|
-
commission,
|
|
51
|
-
estimatedYearlyRewardsRate: validatorEstimatedRate(
|
|
52
|
-
commission,
|
|
53
|
-
rewardState
|
|
54
|
-
),
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
return validators;
|
|
58
|
-
} else {
|
|
59
|
-
const url = `${getBaseApiUrl(currency)}/staking/validators`;
|
|
60
|
-
const { data } = await network({
|
|
61
|
-
url,
|
|
62
|
-
method: "GET",
|
|
63
|
-
});
|
|
64
|
-
const validators = data.result.map((validator) => {
|
|
65
|
-
const commission = parseFloat(
|
|
66
|
-
validator.commission.commission_rates.rate
|
|
67
|
-
);
|
|
68
|
-
return {
|
|
69
|
-
validatorAddress: validator.operator_address,
|
|
70
|
-
name: validator.description.moniker,
|
|
71
|
-
tokens: parseFloat(validator.tokens),
|
|
72
|
-
votingPower:
|
|
73
|
-
parseFloat(validator.tokens) /
|
|
74
|
-
(rewardState.actualBondedRatio * rewardState.totalSupply * 1000000),
|
|
75
|
-
commission,
|
|
76
|
-
estimatedYearlyRewardsRate: validatorEstimatedRate(
|
|
77
|
-
commission,
|
|
78
|
-
rewardState
|
|
79
|
-
),
|
|
80
|
-
};
|
|
81
|
-
});
|
|
82
|
-
return validators;
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
(_: CosmosRewardsState, currency: CryptoCurrency) => currency.id
|
|
86
|
-
);
|
|
87
|
-
export const getValidators = async (
|
|
88
|
-
currency: CryptoCurrency
|
|
89
|
-
): Promise<CosmosValidatorItem[]> => {
|
|
90
|
-
if (isStargate(currency)) {
|
|
91
|
-
const rewardsState = await getStargateRewardsState(currency);
|
|
92
|
-
// validators need the rewardsState ONLY to compute voting power as
|
|
93
|
-
// percentage instead of raw uatoms amounts
|
|
94
|
-
return await cacheValidators(rewardsState, currency);
|
|
95
|
-
} else {
|
|
96
|
-
const rewardsState = await getRewardsState(currency);
|
|
97
|
-
// validators need the rewardsState ONLY to compute voting power as
|
|
98
|
-
// percentage instead of raw uatoms amounts
|
|
99
|
-
return await cacheValidators(rewardsState, currency);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const parseUatomStrAsAtomNumber = (uatoms: string) => {
|
|
104
|
-
return parseFloat(uatoms) / 1000000.0;
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const getRewardsState = makeLRUCache(
|
|
108
|
-
async (currency: CryptoCurrency) => {
|
|
109
|
-
// All obtained values are strings ; so sometimes we will need to parse them as numbers
|
|
110
|
-
const inflationUrl = `${getBaseApiUrl(currency)}/minting/inflation`;
|
|
111
|
-
const { data: inflationData } = await network({
|
|
112
|
-
url: inflationUrl,
|
|
113
|
-
method: "GET",
|
|
114
|
-
});
|
|
115
|
-
const currentValueInflation = parseFloat(inflationData.result);
|
|
116
|
-
const inflationParametersUrl = `${getBaseApiUrl(
|
|
117
|
-
currency
|
|
118
|
-
)}/minting/parameters`;
|
|
119
|
-
const { data: inflationParametersData } = await network({
|
|
120
|
-
url: inflationParametersUrl,
|
|
121
|
-
method: "GET",
|
|
122
|
-
});
|
|
123
|
-
const inflationRateChange = parseFloat(
|
|
124
|
-
inflationParametersData.result.inflation_rate_change
|
|
125
|
-
);
|
|
126
|
-
const inflationMaxRate = parseFloat(
|
|
127
|
-
inflationParametersData.result.inflation_max
|
|
128
|
-
);
|
|
129
|
-
const inflationMinRate = parseFloat(
|
|
130
|
-
inflationParametersData.result.inflation_min
|
|
131
|
-
);
|
|
132
|
-
const targetBondedRatio = parseFloat(
|
|
133
|
-
inflationParametersData.result.goal_bonded
|
|
134
|
-
);
|
|
135
|
-
// Source for seconds per year : https://github.com/gavinly/CosmosParametersWiki/blob/master/Mint.md#notes-3
|
|
136
|
-
// 365.24 (days) * 24 (hours) * 60 (minutes) * 60 (seconds) = 31556736 seconds
|
|
137
|
-
const assumedTimePerBlock =
|
|
138
|
-
31556736.0 / parseFloat(inflationParametersData.result.blocks_per_year);
|
|
139
|
-
const communityTaxUrl = `${getBaseApiUrl(
|
|
140
|
-
currency
|
|
141
|
-
)}/distribution/parameters`;
|
|
142
|
-
const { data: communityTax } = await network({
|
|
143
|
-
url: communityTaxUrl,
|
|
144
|
-
method: "GET",
|
|
145
|
-
});
|
|
146
|
-
const communityPoolCommission = parseFloat(
|
|
147
|
-
communityTax.result.community_tax
|
|
148
|
-
);
|
|
149
|
-
const supplyUrl = `${getBaseApiUrl(currency)}/supply/total`;
|
|
150
|
-
const { data: totalSupplyData } = await network({
|
|
151
|
-
url: supplyUrl,
|
|
152
|
-
method: "GET",
|
|
153
|
-
});
|
|
154
|
-
const totalSupply = parseUatomStrAsAtomNumber(
|
|
155
|
-
totalSupplyData.result[0].amount
|
|
156
|
-
);
|
|
157
|
-
const ratioUrl = `${getBaseApiUrl(currency)}/staking/pool`;
|
|
158
|
-
const { data: ratioData } = await network({
|
|
159
|
-
url: ratioUrl,
|
|
160
|
-
method: "GET",
|
|
161
|
-
});
|
|
162
|
-
const actualBondedRatio =
|
|
163
|
-
parseUatomStrAsAtomNumber(ratioData.result.bonded_tokens) / totalSupply;
|
|
164
|
-
// Arbitrary value in ATOM.
|
|
165
|
-
const averageDailyFees = 20;
|
|
166
|
-
// Arbitrary value in seconds
|
|
167
|
-
const averageTimePerBlock = 7.5;
|
|
168
|
-
return {
|
|
169
|
-
targetBondedRatio,
|
|
170
|
-
communityPoolCommission,
|
|
171
|
-
assumedTimePerBlock,
|
|
172
|
-
inflationRateChange,
|
|
173
|
-
inflationMaxRate,
|
|
174
|
-
inflationMinRate,
|
|
175
|
-
actualBondedRatio,
|
|
176
|
-
averageTimePerBlock,
|
|
177
|
-
totalSupply,
|
|
178
|
-
averageDailyFees,
|
|
179
|
-
currentValueInflation,
|
|
180
|
-
};
|
|
181
|
-
},
|
|
182
|
-
(currency: CryptoCurrency) => currency.id
|
|
4
|
+
const cosmosValidatorsManager = new CosmosValidatorsManager(
|
|
5
|
+
getCryptoCurrencyById("cosmos")
|
|
183
6
|
);
|
|
184
7
|
|
|
185
|
-
|
|
186
|
-
async (currency: CryptoCurrency) => {
|
|
187
|
-
/*
|
|
188
|
-
return {
|
|
189
|
-
targetBondedRatio: 0.01,
|
|
190
|
-
communityPoolCommission: 0.0,
|
|
191
|
-
assumedTimePerBlock: 7,
|
|
192
|
-
inflationRateChange: 0.01,
|
|
193
|
-
inflationMaxRate: 0.01,
|
|
194
|
-
inflationMinRate: 0.01,
|
|
195
|
-
actualBondedRatio: 0.01,
|
|
196
|
-
averageTimePerBlock: 7,
|
|
197
|
-
totalSupply: 0,
|
|
198
|
-
averageDailyFees: 0,
|
|
199
|
-
currentValueInflation: 0.01,
|
|
200
|
-
};
|
|
201
|
-
*/
|
|
202
|
-
|
|
203
|
-
// All obtained values are strings ; so sometimes we will need to parse them as numbers
|
|
204
|
-
const inflationUrl = `${getBaseApiUrl(
|
|
205
|
-
currency
|
|
206
|
-
)}/cosmos/mint/v1beta1/inflation`;
|
|
207
|
-
|
|
208
|
-
const { data: inflationData } = await network({
|
|
209
|
-
url: inflationUrl,
|
|
210
|
-
method: "GET",
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
const currentValueInflation = parseFloat(inflationData.inflation);
|
|
214
|
-
|
|
215
|
-
const inflationParametersUrl = `${getBaseApiUrl(
|
|
216
|
-
currency
|
|
217
|
-
)}/cosmos/mint/v1beta1/params`;
|
|
218
|
-
|
|
219
|
-
const { data: inflationParametersData } = await network({
|
|
220
|
-
url: inflationParametersUrl,
|
|
221
|
-
method: "GET",
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
const inflationRateChange = parseFloat(
|
|
225
|
-
inflationParametersData.params.inflation_rate_change
|
|
226
|
-
);
|
|
227
|
-
|
|
228
|
-
const inflationMaxRate = parseFloat(
|
|
229
|
-
inflationParametersData.params.inflation_max
|
|
230
|
-
);
|
|
231
|
-
|
|
232
|
-
const inflationMinRate = parseFloat(
|
|
233
|
-
inflationParametersData.params.inflation_min
|
|
234
|
-
);
|
|
235
|
-
|
|
236
|
-
const targetBondedRatio = parseFloat(
|
|
237
|
-
inflationParametersData.params.goal_bonded
|
|
238
|
-
);
|
|
239
|
-
|
|
240
|
-
// Source for seconds per year : https://github.com/gavinly/CosmosParametersWiki/blob/master/Mint.md#notes-3
|
|
241
|
-
// 365.24 (days) * 24 (hours) * 60 (minutes) * 60 (seconds) = 31556736 seconds
|
|
242
|
-
const assumedTimePerBlock =
|
|
243
|
-
31556736.0 / parseFloat(inflationParametersData.params.blocks_per_year);
|
|
244
|
-
|
|
245
|
-
const communityTaxUrl = `${getBaseApiUrl(
|
|
246
|
-
currency
|
|
247
|
-
)}/cosmos/distribution/v1beta1/params`;
|
|
248
|
-
|
|
249
|
-
const { data: communityTax } = await network({
|
|
250
|
-
url: communityTaxUrl,
|
|
251
|
-
method: "GET",
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
const communityPoolCommission = parseFloat(
|
|
255
|
-
communityTax.params.community_tax
|
|
256
|
-
);
|
|
257
|
-
|
|
258
|
-
const supplyUrl = `${getBaseApiUrl(currency)}/cosmos/bank/v1beta1/supply/${
|
|
259
|
-
currency.id == "cosmos_testnet" ? "umuon" : "uatom"
|
|
260
|
-
}`;
|
|
261
|
-
|
|
262
|
-
const { data: totalSupplyData } = await network({
|
|
263
|
-
url: supplyUrl,
|
|
264
|
-
method: "GET",
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
const totalSupply = parseUatomStrAsAtomNumber(
|
|
268
|
-
totalSupplyData.amount.amount
|
|
269
|
-
);
|
|
270
|
-
|
|
271
|
-
const ratioUrl = `${getBaseApiUrl(currency)}/cosmos/staking/v1beta1/pool`;
|
|
272
|
-
|
|
273
|
-
const { data: ratioData } = await network({ url: ratioUrl, method: "GET" });
|
|
274
|
-
|
|
275
|
-
const actualBondedRatio =
|
|
276
|
-
parseUatomStrAsAtomNumber(ratioData.pool.bonded_tokens) / totalSupply;
|
|
277
|
-
|
|
278
|
-
// Arbitrary value in ATOM.
|
|
279
|
-
const averageDailyFees = 20;
|
|
280
|
-
|
|
281
|
-
// Arbitrary value in seconds
|
|
282
|
-
const averageTimePerBlock = 7.5;
|
|
283
|
-
|
|
284
|
-
return {
|
|
285
|
-
targetBondedRatio,
|
|
286
|
-
communityPoolCommission,
|
|
287
|
-
assumedTimePerBlock,
|
|
288
|
-
inflationRateChange,
|
|
289
|
-
inflationMaxRate,
|
|
290
|
-
inflationMinRate,
|
|
291
|
-
actualBondedRatio,
|
|
292
|
-
averageTimePerBlock,
|
|
293
|
-
totalSupply,
|
|
294
|
-
averageDailyFees,
|
|
295
|
-
currentValueInflation,
|
|
296
|
-
};
|
|
297
|
-
},
|
|
298
|
-
(currency: CryptoCurrency) => currency.id
|
|
299
|
-
);
|
|
300
|
-
|
|
301
|
-
const computeAvgYearlyInflation = (rewardsState: CosmosRewardsState) => {
|
|
302
|
-
// Return invalid rewardsState if
|
|
303
|
-
// rewardsState.currentValueInflation is not between inflationMinRate and inflationMaxRate
|
|
304
|
-
const inflationSlope =
|
|
305
|
-
(1 - rewardsState.actualBondedRatio / rewardsState.targetBondedRatio) *
|
|
306
|
-
rewardsState.inflationRateChange;
|
|
307
|
-
const unrestrictedEndOfYearInflation =
|
|
308
|
-
rewardsState.currentValueInflation * (1 + inflationSlope);
|
|
309
|
-
|
|
310
|
-
if (
|
|
311
|
-
unrestrictedEndOfYearInflation <= rewardsState.inflationMaxRate &&
|
|
312
|
-
unrestrictedEndOfYearInflation >= rewardsState.inflationMinRate
|
|
313
|
-
) {
|
|
314
|
-
return (
|
|
315
|
-
(rewardsState.currentValueInflation + unrestrictedEndOfYearInflation) / 2
|
|
316
|
-
);
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
if (unrestrictedEndOfYearInflation > rewardsState.inflationMaxRate) {
|
|
320
|
-
const diffToMax =
|
|
321
|
-
rewardsState.inflationMaxRate - rewardsState.currentValueInflation;
|
|
322
|
-
const maxPoint = diffToMax / inflationSlope;
|
|
323
|
-
const averageInflation =
|
|
324
|
-
(1 - maxPoint / 2) * rewardsState.inflationMaxRate +
|
|
325
|
-
(maxPoint / 2) * rewardsState.currentValueInflation;
|
|
326
|
-
return averageInflation;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
if (unrestrictedEndOfYearInflation < rewardsState.inflationMinRate) {
|
|
330
|
-
const diffToMin =
|
|
331
|
-
rewardsState.currentValueInflation - rewardsState.inflationMinRate;
|
|
332
|
-
const minPoint = diffToMin / inflationSlope;
|
|
333
|
-
const averageInflation =
|
|
334
|
-
(1 - minPoint / 2) * rewardsState.inflationMinRate +
|
|
335
|
-
(minPoint / 2) * rewardsState.currentValueInflation;
|
|
336
|
-
return averageInflation;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
throw new Error("Unreachable code");
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
export const validatorEstimatedRate = (
|
|
343
|
-
validatorCommission: number,
|
|
344
|
-
rewardsState: CosmosRewardsState
|
|
345
|
-
): number => {
|
|
346
|
-
// This correction changes how inflation is computed vs. the value the network advertises
|
|
347
|
-
const inexactBlockTimeCorrection =
|
|
348
|
-
rewardsState.assumedTimePerBlock / rewardsState.averageTimePerBlock;
|
|
349
|
-
// This correction assumes a constant bonded_ratio, this changes the yearly inflation
|
|
350
|
-
const yearlyInflation = computeAvgYearlyInflation(rewardsState);
|
|
351
|
-
// This correction adds the fees to the rate computation
|
|
352
|
-
const yearlyFeeRate =
|
|
353
|
-
(rewardsState.averageDailyFees * 365.24) / rewardsState.totalSupply;
|
|
354
|
-
return (
|
|
355
|
-
inexactBlockTimeCorrection *
|
|
356
|
-
(yearlyInflation + yearlyFeeRate) *
|
|
357
|
-
(1 / rewardsState.actualBondedRatio) *
|
|
358
|
-
(1 - rewardsState.communityPoolCommission) *
|
|
359
|
-
(1 - validatorCommission)
|
|
360
|
-
);
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
export const hydrateValidators = (validators: CosmosValidatorItem[]): void => {
|
|
364
|
-
log("cosmos/validators", "hydrate " + validators.length + " validators");
|
|
365
|
-
cacheValidators.hydrate("", validators);
|
|
366
|
-
};
|
|
8
|
+
export default cosmosValidatorsManager;
|
|
@@ -82,12 +82,19 @@ const getTransactionStatus = async (
|
|
|
82
82
|
// This is the worst case scenario (the tx won't cost more than this value)
|
|
83
83
|
const estimatedFees = calculateEstimatedFees(gasFeeCap, gasLimit);
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
if (
|
|
87
|
-
|
|
85
|
+
let totalSpent;
|
|
86
|
+
if (useAllAmount) {
|
|
87
|
+
totalSpent = a.spendableBalance;
|
|
88
|
+
amount = totalSpent.minus(estimatedFees);
|
|
89
|
+
if (amount.lte(0) || totalSpent.gt(balance)) {
|
|
90
|
+
errors.amount = new NotEnoughBalance();
|
|
91
|
+
}
|
|
88
92
|
} else {
|
|
89
|
-
|
|
90
|
-
if (amount.
|
|
93
|
+
totalSpent = amount.plus(estimatedFees);
|
|
94
|
+
if (amount.eq(0)) {
|
|
95
|
+
errors.amount = new AmountRequired();
|
|
96
|
+
} else if (totalSpent.gt(a.spendableBalance))
|
|
97
|
+
errors.amount = new NotEnoughBalance();
|
|
91
98
|
}
|
|
92
99
|
|
|
93
100
|
// log("debug", "[getTransactionStatus] finish fn");
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export type OsmosisMintParams = {
|
|
2
|
+
mint_denom: string;
|
|
3
|
+
genesis_epoch_provisions: string;
|
|
4
|
+
epoch_identifier: string;
|
|
5
|
+
reduction_period_in_epochs: string;
|
|
6
|
+
reduction_factor: string;
|
|
7
|
+
distribution_proportions: {
|
|
8
|
+
staking: string;
|
|
9
|
+
pool_incentives: string;
|
|
10
|
+
developer_rewards: string;
|
|
11
|
+
community_pool: string;
|
|
12
|
+
};
|
|
13
|
+
weighted_developer_rewards_receivers: string[];
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type OsmosisEpochs = {
|
|
17
|
+
epochs: [
|
|
18
|
+
{
|
|
19
|
+
identifier: string;
|
|
20
|
+
start_time: string;
|
|
21
|
+
duration: string;
|
|
22
|
+
current_epoch: string;
|
|
23
|
+
current_epoch_start_time: string;
|
|
24
|
+
epoch_counting_started: boolean;
|
|
25
|
+
current_epoch_ended: boolean;
|
|
26
|
+
}
|
|
27
|
+
];
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type OsmosisEpochProvisions = {
|
|
31
|
+
epoch_provisions: string;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type OsmosisTotalSupply = {
|
|
35
|
+
denom: string;
|
|
36
|
+
amount: string;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type OsmosisMintingInflation = {
|
|
40
|
+
inflation: string;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type OsmosisPool = {
|
|
44
|
+
not_bonded_tokens: string;
|
|
45
|
+
bonded_tokens: string;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type OsmosisDistributionParams = {
|
|
49
|
+
community_tax: string;
|
|
50
|
+
base_proposer_reward: string;
|
|
51
|
+
bonus_proposer_reward: string;
|
|
52
|
+
withdraw_addr_enabled: boolean;
|
|
53
|
+
};
|