Skip to content

Commit

Permalink
release (#317)
Browse files Browse the repository at this point in the history
* Fabo/fix gas (#250)

* fix gas estimate

* linted

* fixed test

* do not keep data sources (#251)

* track failing transactions in Sentry (#249)

* correctly set the tx schema for a failing tx (#248)

* Fabo/remove per block caching as not working (#247)

* remove per block caching as not working

* fix memoized results

Co-authored-by: Ana G. <[email protected]>

* delete perblockcachedatasource (#253)

* Ana/fix balances in actionmodal (#255)

* fix action modal available balance

* include regen

* use dictionary for denomlookup

* use correct events for received txs (#257)

* enable account creation for some networks (#252)

* network update time metric added (#256)

* network update time metric added

* added missing dep

Co-authored-by: Fabian <[email protected]>

* Fix proposal deposit (#261)

* Remove denom handling from getDeposit()

* Revert undesired change

* delete package-lock.json

* localtestnet config change (#265)

* Ana/handle "address not from this network" error (#263)

* add check address function for all queries

* apply suggestions

* Ana/add fiatvalue to balances query (e-Money) (#262)

* preparation

* more preparation

* add fiatvalue field to balances query

* fix get account info

* apply suggestions

* apply one last suggestion

* suggestions+

Co-authored-by: Fabian <[email protected]>

* Ana/emoney fix expected returns with inflation and totalbacked (#243)

* fix expected returns with inflation and supply

* minor fixes. dictionary

* query exchange rates from emoney api

* fix infinite expected returns

* convert api url to const

* add eur value to totalbackedvalue. totalngm gains

* add important comment

* finish calculation

* lint

* catch errors with sentry

Co-authored-by: Fabian <[email protected]>

* readd coin conversion (#268)

* delete amount field (#274)

* Fabo/increase gas again (#271)

* icrease gas again

* fixed test

* Fabo/load all txs (even if more then first page in response) (#270)

* load all txs (even if more then first page in response)

* improved handling of txs

* missing renaming

* fixed paginated load

* add pagination fix also to cosmosV0-source

Co-authored-by: iambeone <[email protected]>
Co-authored-by: Ana G. <[email protected]>

* fixing issue with multiple senders in one event (#273)

* fixing issue with multiple senders in one event

* Update lib/source/cosmosV2-source.js

Co-authored-by: Fabian <[email protected]>

* Fabo/allow signing for terra + emoney (#267)

* allow signing for terra

* readd coin conversion

* enable actions for terra

* fix correct terra testnet url

* comments and guards

* enabled more txs for emoney and fixed broadcasting

* added a catch for wrongly formatted broadcast urls

* recover default field. change some network titles (#277)

* Fabo/add network data to API (#278)

* non desctructive introduction of better address prefix wording

* added address creator to API

* adjusted test

* added ledger app to networks config

* add icon property to schema (#281)

* add icon property to schema

* fix network schema validation

Co-authored-by: Ana G. <[email protected]>

* filter out validator specific txs (#279)

* Ana/balances coinreducer good fix (#269)

* balances coinreducer good fix

* refactored fiat value logic

Co-authored-by: Fabian <[email protected]>

* Create network_integration.md

* Update network_integration.md

* Update network_integration.md

* Fabo/avoid 500 errors (#288)

* avoid using the latest query

* cleanup

* Ana/filter validator tx cross network and add txvalue reducer (#285)

* filter validators cross network

* add value reducer. necessary for multi claim txs

* add validator txs filter also for cosmosv0 source

* filter and make array only claim rewards msg value

* filter txs by whitelist

* change length in multi claim reward reducer

* add withdrawvalidators

* replace dictionary for set

* refactor transaction snippet. avoid repetition

* Ana/emoney upgrade (mergeable) (#282)

* update emoney api_url

* fix denom. add default fiat currency

* fix rpc endpoint

* fix value (my bad) (#293)

* fix value (my bad)

* trigger another ci flow

* erase space

* set correct new chain id (#294)

* restart API

* restart API

* fix pr alert (#297)

* Fabo/298 tendermint reconnect (#300)

* reconnect on tendermint disconnect

* cleanup

* comments

* Update cosmos-node-subscription.js

* Fabo/299 trigger a chain hangup error (#301)

* trigger a chain hangup error

* increase chain hangup time

* Apply suggestions from code review

* Fabo/store validator addresses (#296)

* add validator addresses to db

* linted

* ignore in local dev

* revert

* fixed fetch

* comment

* refactored db into constructor

* cleanup

* add clearTimeout to avoid reconnection hell (#306)

* add clearTimeout to avoid reconnection hell

* removed console.log

* Aleksei/luniedb replaced (#303)

* add validator addresses to db

* linted

* ignore in local dev

* revert

* fixed fetch

* comment

* refactored db into constructor

* cleanup

* replaced luniedb

* linted

Co-authored-by: Fabian <[email protected]>

* disable reconnection logic

* clear polling interval for tendermint connection

* simple api fixes (#310)

* Fabo/remove tendermint (#311)

* remove tendermint

*  fixed empty blockHeight issue

* small refactoring

* catch on fetches to get logging

* delay block updates

* add retry logic

* refactored getBlockByHeight

* remove pm2 dep

* validator profiles were returned as array (#312)

* remove pr github action (#316)

* fixing caching issue and more (#315)

* fixing caching issue and more

* clear chain hangup timeout

* timeout fixed

* Update lib/block-listeners/cosmos-node-subscription.js

Co-authored-by: Jordan Bibla <[email protected]>

* added terra_mainnet to networks (#309)

* added terra_mainnet to networks

* errors fix reverted

* Ana/add multidenom rewards. necessary for emoney (#308)

* add multidenom rewards. necessary for emoney

* add rewards to overview. improve code location

* lint

* add filter rewards for multidenom

* important fix

* another important fix

Co-authored-by: Fabian <[email protected]>
Co-authored-by: Ana G. <[email protected]>
Co-authored-by: Aleksey Rudometov <[email protected]>
Co-authored-by: Mario Pino <[email protected]>
  • Loading branch information
5 people authored Feb 13, 2020
1 parent 406a364 commit c48e881
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 48 deletions.
39 changes: 0 additions & 39 deletions .github/workflows/pr.yml

This file was deleted.

33 changes: 33 additions & 0 deletions data/networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,39 @@
"enabled": true,
"icon": "https://app.lunie.io/img/networks/regen-testnet.png"
},
{
"id": "terra-mainnet",
"title": "Terra mainnet",
"chain_id": "columbus-3",
"api_url": "https://fcd.terra.dev/",
"rpc_url": "ws://52.78.43.42:26657/websocket",
"bech32_prefix": "terra",
"address_prefix": "terra",
"address_creator": "cosmos",
"ledger_app": "cosmos",
"source_class_name": "source/terraV3-source",
"block_listener_class_name": "block-listeners/cosmos-node-subscription",
"testnet": false,
"feature_session": true,
"feature_explore": true,
"feature_portfolio": true,
"feature_validators": true,
"feature_proposals": true,
"feature_activity": true,
"feature_explorer": true,
"action_send": true,
"action_claim_rewards": true,
"action_delegate": true,
"action_redelegate": true,
"action_undelegate": true,
"action_deposit": false,
"action_vote": false,
"action_proposal": false,
"default": false,
"stakingDenom": "LUNA",
"enabled": true,
"icon": "https://app.lunie.io/img/networks/terra-mainnet.png"
},
{
"id": "terra-testnet",
"title": "Terra Testnet",
Expand Down
4 changes: 3 additions & 1 deletion lib/block-listeners/cosmos-node-subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ class CosmosNodeSubscription {
async pollForNewBlock() {
this.pollingTimeout = setTimeout(async () => {
const block = await this.cosmosAPI.getBlockByHeight()

if (this.height !== block.height) {
// apparently the cosmos db takes a while to serve the content after a block has been updated
// if we don't do this, we run into errors as the data is not yet available
setTimeout(() => this.newBlockHandler(block), COSMOS_DB_DELAY)
this.height = block.height // this needs to be set somewhere

// we are safe, that the chain produced a block so it didn't hang up
if (this.chainHangup) clearTimeout(this.chainHangup)
Expand All @@ -47,6 +47,8 @@ class CosmosNodeSubscription {

// if there are no new blocks for some time, trigger an error
// TODO: show this error automatically in the UI
// clearing previous timeout, otherwise it will execute
if (this.chainHangup) clearTimeout(this.chainHangup)
this.chainHangup = setTimeout(() => {
console.error(`Chain ${this.network.id} seems to have halted.`)
Sentry.captureException(
Expand Down
14 changes: 12 additions & 2 deletions lib/reducers/cosmosV0-reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ function undelegationReducer(undelegation, validator) {
function rewardReducer(reward, validator) {
return {
amount: atoms(reward.amount),
denom: reward.denom,
validator
}
}
Expand All @@ -312,11 +313,17 @@ function overviewReducer(
delegations,
undelegations,
rewards,
stakingDenom
stakingDenom,
reducers
) {
stakingDenom = denomLookup(stakingDenom)

const totalRewards = _.flatten(rewards)
// this filter is here for multidenom networks. If there is the field denoms inside rewards, we filter
// only the staking denom rewards for 'totalRewards'
.filter(reward =>
reward.denom ? denomLookup(reward.denom) === stakingDenom : reward
)
.reduce((sum, { amount }) => BigNumber(sum).plus(amount), 0)
.toFixed(6)
const liquidStake = BigNumber(
Expand All @@ -336,7 +343,10 @@ function overviewReducer(
)

return {
// rewards,
rewards:
rewards[0].constructor === Array
? reducers.rewardReducer(rewards)
: rewards,
totalRewards: totalRewards,
liquidStake: liquidStake,
totalStake: liquidStake.plus(delegatedStake).plus(undelegatingStake)
Expand Down
25 changes: 24 additions & 1 deletion lib/reducers/emoneyV0-reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const _ = require('lodash')
const EMoneyAPIUrl = `https://api.e-money.com/v1/`
const exchangeAPIURL = `https://api.exchangeratesapi.io/latest?`
const Sentry = require('@sentry/node')
const { atoms } = terraV3Reducers

async function totalBackedValueReducer(totalBackedValue) {
const exchangeRates = await fetchTokenExchangeRates()
Expand Down Expand Up @@ -119,8 +120,30 @@ async function expectedRewardsPerToken(
return expectedReturns / 100
}

function rewardReducer(rewards, validatorsDictionary) {
const formattedRewards = rewards.map(
reward =>
(reward = {
reward: reward.reward,
validator: validatorsDictionary[reward.validator_address]
})
)
let multiDenomRewardsArray = []
formattedRewards.map(({ reward, validator }) =>
reward.forEach(denomReward => {
multiDenomRewardsArray.push({
denom: denomReward.denom,
amount: atoms(denomReward.amount),
validator: validator
})
})
)
return multiDenomRewardsArray
}

module.exports = {
...terraV3Reducers,
expectedRewardsPerToken,
totalBackedValueReducer
totalBackedValueReducer,
rewardReducer
}
14 changes: 11 additions & 3 deletions lib/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,17 @@ const resolvers = {

// filter to a specific validator
if (operatorAddress) {
rewards = rewards.filter(
({ validator }) => validator.operatorAddress === operatorAddress
)
rewards = rewards.filter(reward => {
// multidenom rewards
if (reward.validator === undefined) {
return reward.filter(
({ validator }) => validator.operatorAddress === operatorAddress
)
// non multidenom rewards
} else {
return reward.validator.operatorAddress === operatorAddress
}
})
}
return rewards
},
Expand Down
2 changes: 2 additions & 0 deletions lib/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const typeDefs = gql`
type Reward {
validator: Validator
denom: String
amount: String
}
Expand Down Expand Up @@ -176,6 +177,7 @@ const typeDefs = gql`
totalStake: String!
liquidStake: String!
totalRewards: String!
rewards: [Reward]
accountInformation: AccountInformation
}
Expand Down
7 changes: 5 additions & 2 deletions lib/source/cosmosV0-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ class CosmosV0API extends RESTDataSource {
}

async getRetry(url, intent = 0) {
// cleareing memoizedResults
this.memoizedResults.clear()
try {
return await this.get(url)
return await this.get(url, null, { cacheOptions: { ttl: 1 } }) // normally setting cacheOptions should be enought, but...
} catch (error) {
// give up
if (intent >= 3) {
Expand Down Expand Up @@ -468,7 +470,8 @@ class CosmosV0API extends RESTDataSource {
delegations,
undelegations,
rewards,
stakingDenom
stakingDenom,
this.reducers
)
}

Expand Down
11 changes: 11 additions & 0 deletions lib/source/emoneyV0-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,17 @@ class EMoneyV0API extends TerraV3API {
return `?`
}
}

async getRewards(delegatorAddress, validatorsDictionary) {
this.checkAddress(delegatorAddress)
const result = await this.query(
`distribution/delegators/${delegatorAddress}/rewards`
)
const rewards = (result.rewards || []).filter(
({ reward }) => reward && reward.length > 0
)
return this.reducers.rewardReducer(rewards, validatorsDictionary)
}
}

module.exports = EMoneyV0API

0 comments on commit c48e881

Please sign in to comment.