Skip to content
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.

Cosmos JS #1731

Merged
54 commits merged into from Feb 22, 2022
Merged
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
9ff6edc
increase gas amplifier
alexalouit Jan 31, 2022
bb1888b
fix payload construction
alexalouit Jan 31, 2022
92f4d59
More accurate gas amplifier
alexalouit Jan 31, 2022
f29a4ae
increase gas amplifier
alexalouit Jan 31, 2022
957a48f
use same node for calculation and broadcast
alexalouit Jan 31, 2022
b120a76
fix amount payload
alexalouit Jan 31, 2022
dd45d6d
Merge remote-tracking branch 'upstream/cosmos-js' into cosmos-js
alexalouit Jan 31, 2022
aaa9494
fix fees/gas calculation
alexalouit Jan 31, 2022
67a4414
fix signature
alexalouit Feb 1, 2022
510c1e9
Merge remote-tracking branch 'upstream/cosmos-js' into cosmos-js
alexalouit Feb 1, 2022
0594ce0
Merge remote-tracking branch 'upstream/cosmos-js' into cosmos-js
alexalouit Feb 3, 2022
75bd779
fix fees regression
alexalouit Feb 3, 2022
fff173f
Merge remote-tracking branch 'upstream/cosmos-js' into cosmos-js
alexalouit Feb 3, 2022
014b551
More accurate pubkey selection
alexalouit Feb 3, 2022
bed90f0
don't use extra.tx_bytes
alexalouit Feb 3, 2022
4faf89d
fix pubkey selection
alexalouit Feb 3, 2022
a49d4ff
simplify hex serialization
alexalouit Feb 4, 2022
e8ad8f3
update transaction: more strict types
alexalouit Feb 10, 2022
a03fd8f
many things
alexalouit Feb 10, 2022
27947b3
accuracy
alexalouit Feb 10, 2022
1ea1afe
remove useless isPreValidation
alexalouit Feb 10, 2022
f941d07
fix strange edge effect of ledger live desktop
alexalouit Feb 10, 2022
cda9bc1
Update xpub during sync
alexalouit Feb 14, 2022
d65266d
temporary enable log for bot
alexalouit Feb 14, 2022
1c62e0c
Merge remote-tracking branch 'upstream/cosmos-js' into cosmos-js
alexalouit Feb 14, 2022
8df4111
LL-9159 cosmos node
alexalouit Feb 16, 2022
804fccd
Update js-signOperation.ts
alexalouit Feb 16, 2022
35ecf59
fix signature
alexalouit Feb 16, 2022
f45276e
Merge remote-tracking branch 'upstream/cosmos-js' into cosmos-js
alexalouit Feb 17, 2022
99dc488
fix redelegate payload
alexalouit Feb 17, 2022
1800f02
fix payload send transaction when sendmax
alexalouit Feb 17, 2022
3aca833
fix optimistic operation type
alexalouit Feb 18, 2022
e22a144
Merge remote-tracking branch 'upstream/cosmos-js' into cosmos-js
alexalouit Feb 18, 2022
e7fd38b
fix typo
alexalouit Feb 18, 2022
c7a0e69
bugfix
alexalouit Feb 18, 2022
b64368e
fix regression
alexalouit Feb 18, 2022
523f73f
Merge remote-tracking branch 'upstream/cosmos-js' into cosmos-js
alexalouit Feb 18, 2022
992193f
update optimistic operation
alexalouit Feb 18, 2022
e81b5d3
Merge remote-tracking branch 'upstream/cosmos-js' into cosmos-js
alexalouit Feb 18, 2022
71ea6f8
fix prettier
alexalouit Feb 18, 2022
e0f4fce
more deterministic transaction parsing
alexalouit Feb 18, 2022
96591a7
Merge remote-tracking branch 'upstream/cosmos-js' into cosmos-js
alexalouit Feb 18, 2022
0d409ca
clarify code readable
alexalouit Feb 18, 2022
2823fcd
adjust sender and recipient
alexalouit Feb 18, 2022
fd3f0aa
fix fees when is ibc transaction
alexalouit Feb 18, 2022
6685baa
fix redelegations data mapping
alexalouit Feb 19, 2022
892148b
fix mixed styles
alexalouit Feb 21, 2022
7446337
fix array cast type
alexalouit Feb 21, 2022
d0819d0
Merge remote-tracking branch 'upstream/cosmos-js' into cosmos-js
alexalouit Feb 21, 2022
890c0d4
fix more determinist operation data
alexalouit Feb 21, 2022
289ef6d
fix could not find optimisticOperation in redelegate transaction
alexalouit Feb 22, 2022
6121e72
Merge remote-tracking branch 'upstream/cosmos-js' into cosmos-js
alexalouit Feb 22, 2022
c113968
restore getStargateRewardsState methode
alexalouit Feb 22, 2022
6c72c62
Merge remote-tracking branch 'upstream/cosmos-js' into cosmos-js
alexalouit Feb 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
175 changes: 98 additions & 77 deletions src/families/cosmos/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ const getRewardsState = makeLRUCache(
);

const getStargateRewardsState = makeLRUCache(
async (_currency: CryptoCurrency) => {
// Fake numbers until Gaia fixes its endpoints
async (currency: CryptoCurrency) => {
/*
return {
targetBondedRatio: 0.01,
communityPoolCommission: 0.0,
Expand All @@ -196,81 +196,102 @@ const getStargateRewardsState = makeLRUCache(
averageDailyFees: 0,
currentValueInflation: 0.01,
};
/*
// All obtained values are strings ; so sometimes we will need to parse them as numbers
const inflationUrl = `${getBaseApiUrl(
currency
)}/cosmos/mint/v1beta1/inflation`;
const { data: inflationData } = await network({
url: inflationUrl,
method: "GET",
});
const currentValueInflation = parseFloat(inflationData.inflation);
const inflationParametersUrl = `${getBaseApiUrl(
currency
)}/cosmos/mint/v1beta1/params`;
const { data: inflationParametersData } = await network({
url: inflationParametersUrl,
method: "GET",
});
const inflationRateChange = parseFloat(
inflationParametersData.params.inflation_rate_change
);
const inflationMaxRate = parseFloat(
inflationParametersData.params.inflation_max
);
const inflationMinRate = parseFloat(
inflationParametersData.params.inflation_min
);
const targetBondedRatio = parseFloat(
inflationParametersData.params.goal_bonded
);
// Source for seconds per year : https://github.com/gavinly/CosmosParametersWiki/blob/master/Mint.md#notes-3
// 365.24 (days) * 24 (hours) * 60 (minutes) * 60 (seconds) = 31556736 seconds
const assumedTimePerBlock =
31556736.0 / parseFloat(inflationParametersData.params.blocks_per_year);
const communityTaxUrl = `${getBaseApiUrl(
currency
)}/cosmos/distribution/v1beta1/params`;
const { data: communityTax } = await network({
url: communityTaxUrl,
method: "GET",
});
const communityPoolCommission = parseFloat(
communityTax.params.community_tax
);
const supplyUrl = `${getBaseApiUrl(currency)}/cosmos/bank/v1beta1/supply/${
currency.id == "cosmos_testnet" ? "umuon" : "uatom"
}`;
const { data: totalSupplyData } = await network({
url: supplyUrl,
method: "GET",
});
const totalSupply = parseUatomStrAsAtomNumber(
totalSupplyData.amount.amount
);
const ratioUrl = `${getBaseApiUrl(currency)}/cosmos/staking/v1beta1/pool`;
const { data: ratioData } = await network({ url: ratioUrl, method: "GET" });
const actualBondedRatio =
parseUatomStrAsAtomNumber(ratioData.pool.bonded_tokens) / totalSupply;
// Arbitrary value in ATOM.
const averageDailyFees = 20;
// Arbitrary value in seconds
const averageTimePerBlock = 7.5;
return {
targetBondedRatio,
communityPoolCommission,
assumedTimePerBlock,
inflationRateChange,
inflationMaxRate,
inflationMinRate,
actualBondedRatio,
averageTimePerBlock,
totalSupply,
averageDailyFees,
currentValueInflation,
};
*/
*/

// All obtained values are strings ; so sometimes we will need to parse them as numbers
const inflationUrl = `${getBaseApiUrl(
currency
)}/cosmos/mint/v1beta1/inflation`;

const { data: inflationData } = await network({
url: inflationUrl,
method: "GET",
});

const currentValueInflation = parseFloat(inflationData.inflation);

const inflationParametersUrl = `${getBaseApiUrl(
currency
)}/cosmos/mint/v1beta1/params`;

const { data: inflationParametersData } = await network({
url: inflationParametersUrl,
method: "GET",
});

const inflationRateChange = parseFloat(
inflationParametersData.params.inflation_rate_change
);

const inflationMaxRate = parseFloat(
inflationParametersData.params.inflation_max
);

const inflationMinRate = parseFloat(
inflationParametersData.params.inflation_min
);

const targetBondedRatio = parseFloat(
inflationParametersData.params.goal_bonded
);

// Source for seconds per year : https://github.com/gavinly/CosmosParametersWiki/blob/master/Mint.md#notes-3
// 365.24 (days) * 24 (hours) * 60 (minutes) * 60 (seconds) = 31556736 seconds
const assumedTimePerBlock =
31556736.0 / parseFloat(inflationParametersData.params.blocks_per_year);

const communityTaxUrl = `${getBaseApiUrl(
currency
)}/cosmos/distribution/v1beta1/params`;

const { data: communityTax } = await network({
url: communityTaxUrl,
method: "GET",
});

const communityPoolCommission = parseFloat(
communityTax.params.community_tax
);

const supplyUrl = `${getBaseApiUrl(currency)}/cosmos/bank/v1beta1/supply/${
currency.id == "cosmos_testnet" ? "umuon" : "uatom"
}`;

const { data: totalSupplyData } = await network({
url: supplyUrl,
method: "GET",
});

const totalSupply = parseUatomStrAsAtomNumber(
totalSupplyData.amount.amount
);

const ratioUrl = `${getBaseApiUrl(currency)}/cosmos/staking/v1beta1/pool`;

const { data: ratioData } = await network({ url: ratioUrl, method: "GET" });

const actualBondedRatio =
parseUatomStrAsAtomNumber(ratioData.pool.bonded_tokens) / totalSupply;

// Arbitrary value in ATOM.
const averageDailyFees = 20;

// Arbitrary value in seconds
const averageTimePerBlock = 7.5;

return {
targetBondedRatio,
communityPoolCommission,
assumedTimePerBlock,
inflationRateChange,
inflationMaxRate,
inflationMinRate,
actualBondedRatio,
averageTimePerBlock,
totalSupply,
averageDailyFees,
currentValueInflation,
};
},
(currency: CryptoCurrency) => currency.id
);
Expand Down