Skip to content

Commit

Permalink
release (#381)
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

* fix cannot read propery constructor of undefined (#318)

* change terra mainnet title

* pushing something to trigger new build and to restart the node

* trying out nylira's node

* WIP: Ana/More Terra fixes (#323)

* fixing my mess

* move all rewards logic to terra

* clearly signal single denom rewards

* Revert "WIP: Ana/More Terra fixes (#323)" (#325)

This reverts commit 408186a.

* catch inside block polling function (#327)

* Fabo/disable writing validator addresses for now (#329)

* disable writing validator addresses for now

* linted

* flushing http cache (#332)

* Transaction abstraction schema (#333)

* tx abstraction proposal using union

* Use Coin type

* Cleanup, TransactionV2

* Cleanup, not multisend tx

* Unsupported tx (like multisend) don't have details

* Fabo/switch to docker swarm mode (#330)

* swtich to docker swarm mode

* typo

* Update .github/workflows/development.yml

* Ana/more terra fixes (***THE COMEBACK***) (#324)

* fixing my mess

* move all rewards logic to terra

* clearly signal single denom rewards

* error structure has changed. need to look into it

* also return denom for single denom rewards

* manage errors properly

* delete comments

* Update lib/reducers/terraV3-reducers.js

* loop through transaction messages

* doing crazy stuff

* rewrite the crazy bit

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

* cosmosv0 was missing the retry logic (#334)

* add back validator to db logic (#335)

* path_prefix added to network data (#338)

* path_prefix added to network data

* path_prefix replaced to slug

* tests fixed

* remove regen (#337)

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

* Fabo+Mario/transaction abstraction (#336)

* draft for transaction abstraction

* use lunie message types

* Add supported tx types

* WIP

* Draft new reducers

* Fix msg types

* Need to resolve type for TransactionDetails union

* debug resolver

* lint

* Fix

* Cleanup

* fix some union issues

* Almost done

* Small fixes

* Add userTransactionAddedV2

* Add userTransactionAddedV2 to resolvers

Co-authored-by: Mario Pino <[email protected]>

* emoney fixes for fiatvalue (#345)

* emoney fixes for fiatvalue

* refactor with coinreducer

* speaking functions are your friends

* refactor ugly nested code

* lint

* add denoms lookups for terra and emoney (#346)

* Ana/add only tokens gas prices 2nd attempt (#344)

* add terra and emoney gas price. terra reducer

* delete fiatvalue from get balances in cosmos

* add emoney reducer

* hyper important emoney fixes

* fix for emoney denoms

* change gas price to micro units

* add emoney denoms to denomlookup

* transform to microunit also for terra tokens

* return null for emoney gas prices

* add harcoded gas prices

* correct emoney hardcoded values

* hardcoded terra gas prices. not working

* update hardcoded values to working ones

* delete unrelated changes to gas prices

* apply suggestions except coinreducer

* they call me mr coinreducer

* change amount for price. add gas price reducer

* change naming in gas price reducer

* add error message

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

* fix rewards denoms (#351)

* updating image on deploy (#352)

* fix my mess once more (#353)

* Ana/add gas prices to other networks (#350)

* add gasprices to cosmos

* format gas prices to three decimals

* Apply suggestions from code review

* Update lib/reducers/cosmosV0-reducers.js

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

* added a tx success push, fallback (#354)

* fix cosmos gas price (#355)

* fix terra for new tmbalance (#358)

* Fabo/new emoney rewards (#357)

* intent to fix the emoney rewards

* intent to fix emoney rewards

* simplified code

* comments

* hack to fix reduce function

* eligable -> eligible

* correct reducer fix

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

* Aleksei/prevent constant db calls (#304)

* add validator addresses to db

* linted

* ignore in local dev

* revert

* fixed fetch

* comment

* refactored db into constructor

* cleanup

* prevent constant db interaction

* stored object structure changed

* remove nesting in validators

* filter validators list

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

* limit txs pages load by two pages per request (#314)

* limit txs pages load by two pages per request

* delete block from loadpaginatedtxs

* small fixes

* Update lib/source/cosmosV2-source.js

* linted

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

* linted

* linted

* Fabo/Use figment nodes (#362)

* use api keys

* add env variables for nodes

* hard code api keys (#365)

* fix ngm fiatvalue (#361)

* hardcoded urls fix (#366)

* WIP: Improve TransactionV2 implementation (#349)

* Add from field to SendTx type

* add amount to claim rewards transactions

* convert to units in string coin reducer

* fix typo

* add multidenom string coinreducer for claim amount

* Add UnknownTx to schema

* Add BlockV2 type which returns TransactionV2 txs

* Add blockV2 query that returns TransactionV2 txs

* kill handling claim rewards amount

* Update lib/reducers/cosmosV0-reducers.js

Co-Authored-By: Fabian <[email protected]>

* Update lib/reducers/cosmosV0-reducers.js

Co-Authored-By: Fabian <[email protected]>

* Cleanup

* lint

* Support claim rewards from multiple validators

* Fix, cleanup

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

* Aleksei/fix db insert (#367)

* fixed insert function to allow empty schema

* Aleksei/statistics in the api (#364)

* collecting statistics in the API

* small fixes

* fixes

* changing address to key in clearOverviewedAddresses

Co-authored-by: Aleksey Rudometov <[email protected]>

* add pageNumber to schema (#370)

* add pageNumber to schema

* file wasn't saved

* trigger ci

* added pagination to tx v2 api (#372)

* Together with 3584: Ana/change fiatvalue to object (#360)

* change fiatvalue to object

* handle when selected currency is eur

* include ngm fiatvalue fix

* Ana/amount in claim rewards in transactions v2 (#373)

* bring amount in claim rewards back to life

* change to regex

* simplify

* make the regex understandable

* Ana/add powered to networks (#377)

* add powered by

* more logical powered

* add provider address for avatar

* fix powere validation

* Fabo/add network-type for selecting addrss and signing (#378)

* add network-type for selecting addrss and signing

* adjust according to new network_type param

* add network type to network schema

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

* fix staking denom (#379)

* fix terra balances and overview (#380)

Co-authored-by: Ana G. <[email protected]>
Co-authored-by: Aleksey Rudometov <[email protected]>
Co-authored-by: Mario Pino <[email protected]>
Co-authored-by: Jordan Bibla <[email protected]>
  • Loading branch information
5 people authored Mar 2, 2020
1 parent 8e724e3 commit e719c4a
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 17 deletions.
1 change: 1 addition & 0 deletions data/networks-local.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = [
bech32_prefix: 'cosmos',
address_prefix: 'cosmos',
address_creator: 'cosmos',
network_type: 'cosmos',
ledger_app: 'cosmos',
source_class_name: 'source/cosmosV2-source',
block_listener_class_name: 'block-listeners/cosmos-node-subscription',
Expand Down
19 changes: 17 additions & 2 deletions data/networks.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = [
address_prefix: 'cosmos',
address_creator: 'cosmos',
ledger_app: 'cosmos',
network_type: 'cosmos',
source_class_name: 'source/cosmosV2-source',
block_listener_class_name: 'block-listeners/cosmos-node-subscription',
testnet: true,
Expand All @@ -32,7 +33,11 @@ module.exports = [
stakingDenom: 'MUON',
enabled: true,
icon: 'https://app.lunie.io/img/networks/cosmos-hub-mainnet.png',
slug: 'cosmos-hub-testnet'
slug: 'cosmos-hub-testnet',
powered: {
name: 'Figment',
picture: 'https://s3.amazonaws.com/keybase_processed_uploads/bd5fb87f241bd78a9c4bceaaa849ca05_360_360.jpg'
}
},
{
id: 'cosmos-hub-mainnet',
Expand All @@ -44,6 +49,7 @@ module.exports = [
bech32_prefix: 'cosmos',
address_prefix: 'cosmos',
address_creator: 'cosmos',
network_type: 'cosmos',
ledger_app: 'cosmos',
source_class_name: 'source/cosmosV2-source',
block_listener_class_name: 'block-listeners/cosmos-node-subscription',
Expand All @@ -67,7 +73,12 @@ module.exports = [
stakingDenom: 'ATOM',
enabled: true,
icon: 'https://app.lunie.io/img/networks/cosmos-hub-mainnet.png',
slug: 'cosmos-hub'
slug: 'cosmos-hub',
powered: {
name: 'Figment',
providerAddress: 'cosmosvaloper1hjct6q7npsspsg3dgvzk3sdf89spmlpfdn6m9d',
picture: 'https://s3.amazonaws.com/keybase_processed_uploads/bd5fb87f241bd78a9c4bceaaa849ca05_360_360.jpg'
}
},
{
id: 'terra-mainnet',
Expand All @@ -79,6 +90,7 @@ module.exports = [
address_prefix: 'terra',
address_creator: 'cosmos',
ledger_app: 'cosmos',
network_type: 'cosmos',
source_class_name: 'source/terraV3-source',
block_listener_class_name: 'block-listeners/cosmos-node-subscription',
testnet: false,
Expand Down Expand Up @@ -113,6 +125,7 @@ module.exports = [
address_prefix: 'terra',
address_creator: 'cosmos',
ledger_app: 'cosmos',
network_type: 'cosmos',
source_class_name: 'source/terraV3-source',
block_listener_class_name: 'block-listeners/cosmos-node-subscription',
testnet: true,
Expand Down Expand Up @@ -147,6 +160,7 @@ module.exports = [
address_prefix: 'emoney',
address_creator: 'cosmos',
ledger_app: 'cosmos',
network_type: 'cosmos',
source_class_name: 'source/emoneyV0-source',
block_listener_class_name: 'block-listeners/cosmos-node-subscription',
testnet: true,
Expand Down Expand Up @@ -181,6 +195,7 @@ module.exports = [
address_prefix: '0x',
address_creator: 'ethereum',
ledger_app: 'ethereum',
network_type: 'ethereum',
source_class_name: 'source/livepeerV0-source',
block_listener_class_name: 'block-listeners/livepeer-node-polling',
testnet: false,
Expand Down
56 changes: 49 additions & 7 deletions lib/reducers/cosmosV0-reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,25 @@ function gasPriceReducer(gasPrice) {
}
}

// delegations rewards in Tendermint are located in events as strings with this form:
// amount: {"15000umuon"}, or in multidenom networks they look like this:
// amount: {"15000ungm,100000uchf,110000ueur,2000000ujpy"}
// That is why we need this separate function to extract those amounts in this format
function rewardCoinReducer(reward, stakingDenom) {
const numBit = reward.match(/[0-9]+/gi)
const stringBit = reward.match(/[a-z]+/gi)
const multiDenomRewardsArray = reward.split(`,`)
if (multiDenomRewardsArray.length > 1) {
return multiDenomRewardsArray
.map(reward => rewardCoinReducer(reward))
.filter(({ denom }) => denom === denomLookup(stakingDenom))[0]
}
return {
denom: denomLookup(stringBit),
amount: BigNumber(numBit).div(1000000)
}
}

function balanceReducer(coin, gasPrices) {
return {
...coin,
Expand Down Expand Up @@ -558,7 +577,13 @@ function getMessageType(type) {
}

// function to map cosmos messages to our details format
function transactionDetailsReducer(type, message, reducers, transaction) {
function transactionDetailsReducer(
type,
message,
reducers,
transaction,
stakingDenom
) {
let details
switch (type) {
case lunieMessageTypes.SEND:
Expand All @@ -574,7 +599,12 @@ function transactionDetailsReducer(type, message, reducers, transaction) {
details = unstakeDetailsReducer(message, reducers)
break
case lunieMessageTypes.CLAIM_REWARDS:
details = claimRewardsDetailsReducer(transaction.tx.value.msg)
details = claimRewardsDetailsReducer(
transaction.tx.value.msg,
reducers,
transaction,
stakingDenom
)
break
case lunieMessageTypes.SUBMIT_PROPOSAL:
details = submitProposalDetailsReducer(message, reducers)
Expand Down Expand Up @@ -625,18 +655,29 @@ function unstakeDetailsReducer(message, reducers) {
}
}

function claimRewardsDetailsReducer(messages) {
function claimRewardsDetailsReducer(
messages,
reducers,
transaction,
stakingDenom
) {
return {
from: messages
.filter(msg => msg.type.split(`/`)[1] === `MsgWithdrawDelegationReward`)
.map(msg => msg.value.validator_address),
amount: {
amount: 0,
denom: ``
}
amount: claimRewardsAmountReducer(transaction, reducers, stakingDenom)
}
}

function claimRewardsAmountReducer(transaction, reducers, stakingDenom) {
return reducers.rewardCoinReducer(
transaction.events
.find(event => event.type === `transfer`)
.attributes.find(attribute => attribute.key === `amount`).value,
stakingDenom
)
}

function submitProposalDetailsReducer(message, reducers) {
return {
proposalType: message.content.type,
Expand Down Expand Up @@ -670,6 +711,7 @@ module.exports = {
delegationReducer,
coinReducer,
gasPriceReducer,
rewardCoinReducer,
balanceReducer,
transactionReducer,
undelegationReducer,
Expand Down
12 changes: 7 additions & 5 deletions lib/reducers/terraV3-reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ function undelegationEndTimeReducer(transaction) {
function balanceReducer(coin, fiatValue, gasPrices) {
return {
...coin,
fiatValue: {
amount: fiatValue.amount || 0,
denom: fiatValue.denom || '',
symbol: fiatValue.symbol || ''
},
fiatValue: fiatValue
? {
amount: fiatValue.amount || 0,
denom: fiatValue.denom || '',
symbol: fiatValue.symbol || ''
}
: null,
gasPrice: gasPriceReducer(
gasPrices.find(gasprice => denomLookup(gasprice.denom) === coin.denom)
).price
Expand Down
8 changes: 8 additions & 0 deletions lib/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ const typeDefs = gql`
bech32_prefix: String
address_prefix: String
address_creator: String
network_type: String
ledger_app: String
testnet: Boolean
feature_session: Boolean
Expand All @@ -139,6 +140,7 @@ const typeDefs = gql`
enabled: Boolean
icon: String
slug: String
powered: Powered
}
type Delegation {
Expand Down Expand Up @@ -260,6 +262,12 @@ const typeDefs = gql`
sequence: String
}
type Powered {
name: String
providerAddress: String
picture: String
}
type Overview {
networkId: String!
address: String!
Expand Down
2 changes: 1 addition & 1 deletion lib/source/cosmosV0-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class CosmosV0API extends RESTDataSource {
? this.reducers.transactionsReducerV2(
txs,
this.reducers,
this.getStakingDenom()
await this.getStakingDenom()
)
: []
}
Expand Down
4 changes: 3 additions & 1 deletion lib/source/terraV3-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ class TerraV3API extends CosmosV2API {
return coins.map(coin => {
return this.reducers.balanceReducer(
coin,
fiatBalances.find(({ denom }) => denom === coin.denom).fiatValue,
fiatBalances
? fiatBalances.find(({ denom }) => denom === coin.denom).fiatValue
: null,
this.gasPrices
)
})
Expand Down
10 changes: 9 additions & 1 deletion tests/network-configs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const schema = Joi.object({
bech32_prefix: Joi.string(),
address_prefix: Joi.string(),
address_creator: Joi.string(),
network_type: Joi.string(),
ledger_app: Joi.string(),
source_class_name: Joi.string(),
block_listener_class_name: Joi.string(),
Expand All @@ -34,7 +35,14 @@ const schema = Joi.object({
enabled: Joi.boolean(),
experimental: Joi.boolean().optional(),
icon: Joi.string().optional(),
slug: Joi.string().optional()
slug: Joi.string().optional(),
powered: Joi.object()
.keys({
name: Joi.string().optional(),
providerAddress: Joi.string().optional(),
picture: Joi.string().optional()
})
.optional()
})

describe('Network configs', function() {
Expand Down

0 comments on commit e719c4a

Please sign in to comment.