From be63531959f690e26cb6ba4645c7890b14753e91 Mon Sep 17 00:00:00 2001 From: Fabian Date: Thu, 12 Dec 2019 16:44:28 -0500 Subject: [PATCH 1/2] release (#192) * fixed a bug where a single proposal would not load (#125) * trigger ci * fixed missing terra data source (#128) * Fabo/fix missing terra db query (#130) * fixed missing terra data source * fixed missing query * Fabo/fix failing staking query for terra (#132) * fixed missing terra data source * fixed missing query * fix bech32 prefix in selfStake resolver * linted * Fabo/hide proposals on terra (#134) * fixed missing terra data source * fixed missing query * fix bech32 prefix in selfStake resolver * linted * don't show proposals on terra * Fabo/switch to yarn (#122) * switch to yarn * Update Readme * Ana/111 regen testnet production (#118) * regen is home * fix websocket link * eslint fix * delete console logs * fixed regen source (using cosmosV0) * add feature flags for regen * fix txs in regen * fix transactions per address * fix eslint errors * disable sign in * colw/Transaction Service (#120) * Obtain transaction payload, mirror back to client * Respond with request, or error if none present * Load node friendly versions of cosmos-api for dev * Send response as JSON * Successfully retrieve a gas estimate - Use node-fetch for cosmosAPIs - * Add two sub routes: /estimate and /broadcast * Add account number and sequence to overview query * Disable cors options * Add support to broadcast messages * Ignore fetch undefined * Delete package-lock.json * Fabo/simplify queries (#108) * simplified db queries Conflicts: lib/luniedb-source.js lib/queries.js * switched to yarn * clean up * clean up * Copy cosmos libraries into container (#143) * Aleksei/terra url change (#144) * terra url changed * change soju-0010 to soju-0012 * fixed db queries (#147) * Update networks.json (#149) * Fabo/events (#123) * first steps * working notification endpoint * remove push mentions * linted * fixes * updated schema * use enum for eventtype * working subscription * linted * added push to express routes * remove newer code * linted * Update lib/routes/push.js Co-Authored-By: Col * disable session for regen (#155) * Aleksei/terra url change (#146) * terra url changed * change soju-0010 to soju-0012 * cors added to caddyfiles * cors added to caddyfiles * fix missing path * Fabo/fix vote count (#157) * fixed vote count calculation * linted * Ana/handle with message proposal id error (#159) * handle undefined proposal error * fix lint errors * Ana/add endtime to undelegation tx (#150) * add liquiddate as field for tx * fix eslint errors * change name liquidDate to undelegationEndTime * fix enddelegationtime for gaia * improve reducer my way * fix lint error * move undelegationendtime to reducer * fix lint errors * no abbreviations * implement undelegation endtime reducer in both * reenable session for gaia 13006 (#165) * Ana/fix terra undelegationendtime reducer (#162) * change reducers to cosmosV2 * prevent result undefined error * add own gettransaction and txreducer for terra * fix terra undelegationendtime reducer * fix lint errors * avoid hardcoded indexes * small fix to prevent total server error * no redundancy: add reducers to transactionreducer * fix lint * trigger CI * Don't return delegations with dust amounts (#171) * Add filter to delegations * Fix filter * Simplify * add undelegations to total stake (#174) * Terra chain_id switched to soju-0013 (#176) * terra chaind_id switched to soju-0013 * changed terra node * fix issues with undelegatio end time (#175) * Fabo/fix undelegationendtime (#177) * fix issues with undelegatio end time * catch undelegation attribute not found * Fabo/fix undelegationendtime for regen (#178) * fix issues with undelegatio end time * catch undelegation attribute not found * fix regen transaction reducers * Display Deposit Period End Date correctly for proposals in deposit period (#181) * Return proposal.voting_end_time in deposit period * Return deposit_end_time instead * update to new reducers and chain-id (#182) * merge back (#186) * release (#179) * fixed a bug where a single proposal would not load (#125) * trigger ci * fixed missing terra data source (#128) * Fabo/fix missing terra db query (#130) * fixed missing terra data source * fixed missing query * Fabo/fix failing staking query for terra (#132) * fixed missing terra data source * fixed missing query * fix bech32 prefix in selfStake resolver * linted * Fabo/hide proposals on terra (#134) * fixed missing terra data source * fixed missing query * fix bech32 prefix in selfStake resolver * linted * don't show proposals on terra * Fabo/switch to yarn (#122) * switch to yarn * Update Readme * Ana/111 regen testnet production (#118) * regen is home * fix websocket link * eslint fix * delete console logs * fixed regen source (using cosmosV0) * add feature flags for regen * fix txs in regen * fix transactions per address * fix eslint errors * disable sign in * colw/Transaction Service (#120) * Obtain transaction payload, mirror back to client * Respond with request, or error if none present * Load node friendly versions of cosmos-api for dev * Send response as JSON * Successfully retrieve a gas estimate - Use node-fetch for cosmosAPIs - * Add two sub routes: /estimate and /broadcast * Add account number and sequence to overview query * Disable cors options * Add support to broadcast messages * Ignore fetch undefined * Delete package-lock.json * Fabo/simplify queries (#108) * simplified db queries Conflicts: lib/luniedb-source.js lib/queries.js * switched to yarn * clean up * clean up * Copy cosmos libraries into container (#143) * Aleksei/terra url change (#144) * terra url changed * change soju-0010 to soju-0012 * fixed db queries (#147) * Update networks.json (#149) * Fabo/events (#123) * first steps * working notification endpoint * remove push mentions * linted * fixes * updated schema * use enum for eventtype * working subscription * linted * added push to express routes * remove newer code * linted * Update lib/routes/push.js Co-Authored-By: Col * disable session for regen (#155) * Aleksei/terra url change (#146) * terra url changed * change soju-0010 to soju-0012 * cors added to caddyfiles * cors added to caddyfiles * fix missing path * Fabo/fix vote count (#157) * fixed vote count calculation * linted * Ana/handle with message proposal id error (#159) * handle undefined proposal error * fix lint errors * Ana/add endtime to undelegation tx (#150) * add liquiddate as field for tx * fix eslint errors * change name liquidDate to undelegationEndTime * fix enddelegationtime for gaia * improve reducer my way * fix lint error * move undelegationendtime to reducer * fix lint errors * no abbreviations * implement undelegation endtime reducer in both * reenable session for gaia 13006 (#165) * Ana/fix terra undelegationendtime reducer (#162) * change reducers to cosmosV2 * prevent result undefined error * add own gettransaction and txreducer for terra * fix terra undelegationendtime reducer * fix lint errors * avoid hardcoded indexes * small fix to prevent total server error * no redundancy: add reducers to transactionreducer * fix lint * trigger CI * Don't return delegations with dust amounts (#171) * Add filter to delegations * Fix filter * Simplify * add undelegations to total stake (#174) * Terra chain_id switched to soju-0013 (#176) * terra chaind_id switched to soju-0013 * changed terra node * fix issues with undelegatio end time (#175) * Fabo/fix undelegationendtime (#177) * fix issues with undelegatio end time * catch undelegation attribute not found * Fabo/fix undelegationendtime for regen (#178) * fix issues with undelegatio end time * catch undelegation attribute not found * fix regen transaction reducers * Display Deposit Period End Date correctly for proposals in deposit period (#181) * Return proposal.voting_end_time in deposit period * Return deposit_end_time instead * release (#183) * fixed a bug where a single proposal would not load (#125) * trigger ci * fixed missing terra data source (#128) * Fabo/fix missing terra db query (#130) * fixed missing terra data source * fixed missing query * Fabo/fix failing staking query for terra (#132) * fixed missing terra data source * fixed missing query * fix bech32 prefix in selfStake resolver * linted * Fabo/hide proposals on terra (#134) * fixed missing terra data source * fixed missing query * fix bech32 prefix in selfStake resolver * linted * don't show proposals on terra * Fabo/switch to yarn (#122) * switch to yarn * Update Readme * Ana/111 regen testnet production (#118) * regen is home * fix websocket link * eslint fix * delete console logs * fixed regen source (using cosmosV0) * add feature flags for regen * fix txs in regen * fix transactions per address * fix eslint errors * disable sign in * colw/Transaction Service (#120) * Obtain transaction payload, mirror back to client * Respond with request, or error if none present * Load node friendly versions of cosmos-api for dev * Send response as JSON * Successfully retrieve a gas estimate - Use node-fetch for cosmosAPIs - * Add two sub routes: /estimate and /broadcast * Add account number and sequence to overview query * Disable cors options * Add support to broadcast messages * Ignore fetch undefined * Delete package-lock.json * Fabo/simplify queries (#108) * simplified db queries Conflicts: lib/luniedb-source.js lib/queries.js * switched to yarn * clean up * clean up * Copy cosmos libraries into container (#143) * Aleksei/terra url change (#144) * terra url changed * change soju-0010 to soju-0012 * fixed db queries (#147) * Update networks.json (#149) * Fabo/events (#123) * first steps * working notification endpoint * remove push mentions * linted * fixes * updated schema * use enum for eventtype * working subscription * linted * added push to express routes * remove newer code * linted * Update lib/routes/push.js Co-Authored-By: Col * disable session for regen (#155) * Aleksei/terra url change (#146) * terra url changed * change soju-0010 to soju-0012 * cors added to caddyfiles * cors added to caddyfiles * fix missing path * Fabo/fix vote count (#157) * fixed vote count calculation * linted * Ana/handle with message proposal id error (#159) * handle undefined proposal error * fix lint errors * Ana/add endtime to undelegation tx (#150) * add liquiddate as field for tx * fix eslint errors * change name liquidDate to undelegationEndTime * fix enddelegationtime for gaia * improve reducer my way * fix lint error * move undelegationendtime to reducer * fix lint errors * no abbreviations * implement undelegation endtime reducer in both * reenable session for gaia 13006 (#165) * Ana/fix terra undelegationendtime reducer (#162) * change reducers to cosmosV2 * prevent result undefined error * add own gettransaction and txreducer for terra * fix terra undelegationendtime reducer * fix lint errors * avoid hardcoded indexes * small fix to prevent total server error * no redundancy: add reducers to transactionreducer * fix lint * trigger CI * Don't return delegations with dust amounts (#171) * Add filter to delegations * Fix filter * Simplify * add undelegations to total stake (#174) * Terra chain_id switched to soju-0013 (#176) * terra chaind_id switched to soju-0013 * changed terra node * fix issues with undelegatio end time (#175) * Fabo/fix undelegationendtime (#177) * fix issues with undelegatio end time * catch undelegation attribute not found * Fabo/fix undelegationendtime for regen (#178) * fix issues with undelegatio end time * catch undelegation attribute not found * fix regen transaction reducers * Display Deposit Period End Date correctly for proposals in deposit period (#181) * Return proposal.voting_end_time in deposit period * Return deposit_end_time instead * update to new reducers and chain-id (#182) * Fabo/fix rewards (#185) * fixed a bug where a single proposal would not load (#125) * trigger ci * fixed missing terra data source (#128) * Fabo/fix missing terra db query (#130) * fixed missing terra data source * fixed missing query * Fabo/fix failing staking query for terra (#132) * fixed missing terra data source * fixed missing query * fix bech32 prefix in selfStake resolver * linted * Fabo/hide proposals on terra (#134) * fixed missing terra data source * fixed missing query * fix bech32 prefix in selfStake resolver * linted * don't show proposals on terra * Fabo/switch to yarn (#122) * switch to yarn * Update Readme * Ana/111 regen testnet production (#118) * regen is home * fix websocket link * eslint fix * delete console logs * fixed regen source (using cosmosV0) * add feature flags for regen * fix txs in regen * fix transactions per address * fix eslint errors * disable sign in * colw/Transaction Service (#120) * Obtain transaction payload, mirror back to client * Respond with request, or error if none present * Load node friendly versions of cosmos-api for dev * Send response as JSON * Successfully retrieve a gas estimate - Use node-fetch for cosmosAPIs - * Add two sub routes: /estimate and /broadcast * Add account number and sequence to overview query * Disable cors options * Add support to broadcast messages * Ignore fetch undefined * Delete package-lock.json * Fabo/simplify queries (#108) * simplified db queries Conflicts: lib/luniedb-source.js lib/queries.js * switched to yarn * clean up * clean up * Copy cosmos libraries into container (#143) * Aleksei/terra url change (#144) * terra url changed * change soju-0010 to soju-0012 * fixed db queries (#147) * Update networks.json (#149) * Fabo/events (#123) * first steps * working notification endpoint * remove push mentions * linted * fixes * updated schema * use enum for eventtype * working subscription * linted * added push to express routes * remove newer code * linted * Update lib/routes/push.js Co-Authored-By: Col * disable session for regen (#155) * Aleksei/terra url change (#146) * terra url changed * change soju-0010 to soju-0012 * cors added to caddyfiles * cors added to caddyfiles * fix missing path * Fabo/fix vote count (#157) * fixed vote count calculation * linted * Ana/handle with message proposal id error (#159) * handle undefined proposal error * fix lint errors * Ana/add endtime to undelegation tx (#150) * add liquiddate as field for tx * fix eslint errors * change name liquidDate to undelegationEndTime * fix enddelegationtime for gaia * improve reducer my way * fix lint error * move undelegationendtime to reducer * fix lint errors * no abbreviations * implement undelegation endtime reducer in both * reenable session for gaia 13006 (#165) * Ana/fix terra undelegationendtime reducer (#162) * change reducers to cosmosV2 * prevent result undefined error * add own gettransaction and txreducer for terra * fix terra undelegationendtime reducer * fix lint errors * avoid hardcoded indexes * small fix to prevent total server error * no redundancy: add reducers to transactionreducer * fix lint * trigger CI * Don't return delegations with dust amounts (#171) * Add filter to delegations * Fix filter * Simplify * add undelegations to total stake (#174) * Terra chain_id switched to soju-0013 (#176) * terra chaind_id switched to soju-0013 * changed terra node * fix issues with undelegatio end time (#175) * Fabo/fix undelegationendtime (#177) * fix issues with undelegatio end time * catch undelegation attribute not found * Fabo/fix undelegationendtime for regen (#178) * fix issues with undelegatio end time * catch undelegation attribute not found * fix regen transaction reducers * Display Deposit Period End Date correctly for proposals in deposit period (#181) * Return proposal.voting_end_time in deposit period * Return deposit_end_time instead * update to new reducers and chain-id (#182) * fix rewards not being extracted correctly * linted * trigger deploy * Ana/105 livepeer into production (#114) * add livepeer first files * first tentative. add transcoder type and queries * progress * progress + trying * eslint fix * working * recover missing config enabletestnet * delete livepeer from resolver and schema * try getallvalidators in livepeerv0-source * todos: own subscription and own reducers * eslint fix * refactored into graphql data source * add livepeer to networks json * little hack (temporary) * fix silly eslint error * start playing * fetch works. add to apollo * fix lint * get last round id/height * fix lint * set all feature flags to false * forward. add livepeer reducer. 400 bad request * fix lint * kind of working * fix networkId * colin/ make node subscription great * use transcoders no orchestrators. getValidator * connecting to block height and validators display * minor lint * add validator name * provisory getselfstake * improve validator reducer * use bignumber lib. add getdelegatorsstake * fix lint * fix gettotal stake delegators * fix lint * clean up * get self stake * delete livepeer-queries * handle url with node url class * delete extra back ticks * invisible lint fix * better prevent than regret * delete getlastrounid function * fix total stake and self stake * remove console log * use getblockheight to find last block * get validators from db * get more names * get ALL validators * use validator query string * use bignumber instead of parseint * minor lint * fix validators names * improve condition * get all validators for real * fix search filter for operator address * fix search filter * finishing fixes (formatbech32 and bignumber) * try implementing votingpower. no api support * refactoring and renaming * enable votingpower * livepeer is mainnet * fix voting power filter (#188) * disable livepeer for now (#191) --- lib/resolvers.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/resolvers.js b/lib/resolvers.js index d7b4874638..8147cb0fd5 100644 --- a/lib/resolvers.js +++ b/lib/resolvers.js @@ -30,6 +30,7 @@ async function enrichValidator(dataSources, networkId, validator) { validator.operatorAddress, networkId ) + // TODO refactor if (validator && !validatorInfo && !validator.name) { return { ...validator, @@ -49,6 +50,7 @@ async function enrichValidator(dataSources, networkId, validator) { } else if ( validator && validatorInfo && + !validatorInfo.name && validator.operatorAddress == validatorInfo.operator_address ) { return { @@ -239,18 +241,20 @@ const resolvers = { return network }, networks: (_, __, { dataSources }) => { - const networks = Object.values(dataSources.store).map(({ network }) => { - if (network.id === 'local-cosmos-hub-testnet') { - // HACK: network.api_url for the testnet has to be different for internal - // (docker DNS to access the testnet container) and external (this frontend to - // access the docker container from the outside via it's port) - return { - ...network, - api_url: 'http://localhost:9071' + const networks = Object.values(dataSources.store) + .filter(({ network }) => network.id !== 'livepeer-mainnet') + .map(({ network }) => { + if (network.id === 'local-cosmos-hub-testnet') { + // HACK: network.api_url for the testnet has to be different for internal + // (docker DNS to access the testnet container) and external (this frontend to + // access the docker container from the outside via it's port) + return { + ...network, + api_url: 'http://localhost:9071' + } } - } - return network - }) + return network + }) return networks }, maintenance: (_, __, { dataSources }) => From fca8652aedd0a818ad1c0e804836b5bb89295c57 Mon Sep 17 00:00:00 2001 From: Fabian Date: Fri, 13 Dec 2019 00:05:15 -0500 Subject: [PATCH 2/2] release (#198) * fixed a bug where a single proposal would not load (#125) * trigger ci * fixed missing terra data source (#128) * Fabo/fix missing terra db query (#130) * fixed missing terra data source * fixed missing query * Fabo/fix failing staking query for terra (#132) * fixed missing terra data source * fixed missing query * fix bech32 prefix in selfStake resolver * linted * Fabo/hide proposals on terra (#134) * fixed missing terra data source * fixed missing query * fix bech32 prefix in selfStake resolver * linted * don't show proposals on terra * Fabo/switch to yarn (#122) * switch to yarn * Update Readme * Ana/111 regen testnet production (#118) * regen is home * fix websocket link * eslint fix * delete console logs * fixed regen source (using cosmosV0) * add feature flags for regen * fix txs in regen * fix transactions per address * fix eslint errors * disable sign in * colw/Transaction Service (#120) * Obtain transaction payload, mirror back to client * Respond with request, or error if none present * Load node friendly versions of cosmos-api for dev * Send response as JSON * Successfully retrieve a gas estimate - Use node-fetch for cosmosAPIs - * Add two sub routes: /estimate and /broadcast * Add account number and sequence to overview query * Disable cors options * Add support to broadcast messages * Ignore fetch undefined * Delete package-lock.json * Fabo/simplify queries (#108) * simplified db queries Conflicts: lib/luniedb-source.js lib/queries.js * switched to yarn * clean up * clean up * Copy cosmos libraries into container (#143) * Aleksei/terra url change (#144) * terra url changed * change soju-0010 to soju-0012 * fixed db queries (#147) * Update networks.json (#149) * Fabo/events (#123) * first steps * working notification endpoint * remove push mentions * linted * fixes * updated schema * use enum for eventtype * working subscription * linted * added push to express routes * remove newer code * linted * Update lib/routes/push.js Co-Authored-By: Col * disable session for regen (#155) * Aleksei/terra url change (#146) * terra url changed * change soju-0010 to soju-0012 * cors added to caddyfiles * cors added to caddyfiles * fix missing path * Fabo/fix vote count (#157) * fixed vote count calculation * linted * Ana/handle with message proposal id error (#159) * handle undefined proposal error * fix lint errors * Ana/add endtime to undelegation tx (#150) * add liquiddate as field for tx * fix eslint errors * change name liquidDate to undelegationEndTime * fix enddelegationtime for gaia * improve reducer my way * fix lint error * move undelegationendtime to reducer * fix lint errors * no abbreviations * implement undelegation endtime reducer in both * reenable session for gaia 13006 (#165) * Ana/fix terra undelegationendtime reducer (#162) * change reducers to cosmosV2 * prevent result undefined error * add own gettransaction and txreducer for terra * fix terra undelegationendtime reducer * fix lint errors * avoid hardcoded indexes * small fix to prevent total server error * no redundancy: add reducers to transactionreducer * fix lint * trigger CI * Don't return delegations with dust amounts (#171) * Add filter to delegations * Fix filter * Simplify * add undelegations to total stake (#174) * Terra chain_id switched to soju-0013 (#176) * terra chaind_id switched to soju-0013 * changed terra node * fix issues with undelegatio end time (#175) * Fabo/fix undelegationendtime (#177) * fix issues with undelegatio end time * catch undelegation attribute not found * Fabo/fix undelegationendtime for regen (#178) * fix issues with undelegatio end time * catch undelegation attribute not found * fix regen transaction reducers * Display Deposit Period End Date correctly for proposals in deposit period (#181) * Return proposal.voting_end_time in deposit period * Return deposit_end_time instead * update to new reducers and chain-id (#182) * merge back (#186) * release (#179) * fixed a bug where a single proposal would not load (#125) * trigger ci * fixed missing terra data source (#128) * Fabo/fix missing terra db query (#130) * fixed missing terra data source * fixed missing query * Fabo/fix failing staking query for terra (#132) * fixed missing terra data source * fixed missing query * fix bech32 prefix in selfStake resolver * linted * Fabo/hide proposals on terra (#134) * fixed missing terra data source * fixed missing query * fix bech32 prefix in selfStake resolver * linted * don't show proposals on terra * Fabo/switch to yarn (#122) * switch to yarn * Update Readme * Ana/111 regen testnet production (#118) * regen is home * fix websocket link * eslint fix * delete console logs * fixed regen source (using cosmosV0) * add feature flags for regen * fix txs in regen * fix transactions per address * fix eslint errors * disable sign in * colw/Transaction Service (#120) * Obtain transaction payload, mirror back to client * Respond with request, or error if none present * Load node friendly versions of cosmos-api for dev * Send response as JSON * Successfully retrieve a gas estimate - Use node-fetch for cosmosAPIs - * Add two sub routes: /estimate and /broadcast * Add account number and sequence to overview query * Disable cors options * Add support to broadcast messages * Ignore fetch undefined * Delete package-lock.json * Fabo/simplify queries (#108) * simplified db queries Conflicts: lib/luniedb-source.js lib/queries.js * switched to yarn * clean up * clean up * Copy cosmos libraries into container (#143) * Aleksei/terra url change (#144) * terra url changed * change soju-0010 to soju-0012 * fixed db queries (#147) * Update networks.json (#149) * Fabo/events (#123) * first steps * working notification endpoint * remove push mentions * linted * fixes * updated schema * use enum for eventtype * working subscription * linted * added push to express routes * remove newer code * linted * Update lib/routes/push.js Co-Authored-By: Col * disable session for regen (#155) * Aleksei/terra url change (#146) * terra url changed * change soju-0010 to soju-0012 * cors added to caddyfiles * cors added to caddyfiles * fix missing path * Fabo/fix vote count (#157) * fixed vote count calculation * linted * Ana/handle with message proposal id error (#159) * handle undefined proposal error * fix lint errors * Ana/add endtime to undelegation tx (#150) * add liquiddate as field for tx * fix eslint errors * change name liquidDate to undelegationEndTime * fix enddelegationtime for gaia * improve reducer my way * fix lint error * move undelegationendtime to reducer * fix lint errors * no abbreviations * implement undelegation endtime reducer in both * reenable session for gaia 13006 (#165) * Ana/fix terra undelegationendtime reducer (#162) * change reducers to cosmosV2 * prevent result undefined error * add own gettransaction and txreducer for terra * fix terra undelegationendtime reducer * fix lint errors * avoid hardcoded indexes * small fix to prevent total server error * no redundancy: add reducers to transactionreducer * fix lint * trigger CI * Don't return delegations with dust amounts (#171) * Add filter to delegations * Fix filter * Simplify * add undelegations to total stake (#174) * Terra chain_id switched to soju-0013 (#176) * terra chaind_id switched to soju-0013 * changed terra node * fix issues with undelegatio end time (#175) * Fabo/fix undelegationendtime (#177) * fix issues with undelegatio end time * catch undelegation attribute not found * Fabo/fix undelegationendtime for regen (#178) * fix issues with undelegatio end time * catch undelegation attribute not found * fix regen transaction reducers * Display Deposit Period End Date correctly for proposals in deposit period (#181) * Return proposal.voting_end_time in deposit period * Return deposit_end_time instead * release (#183) * fixed a bug where a single proposal would not load (#125) * trigger ci * fixed missing terra data source (#128) * Fabo/fix missing terra db query (#130) * fixed missing terra data source * fixed missing query * Fabo/fix failing staking query for terra (#132) * fixed missing terra data source * fixed missing query * fix bech32 prefix in selfStake resolver * linted * Fabo/hide proposals on terra (#134) * fixed missing terra data source * fixed missing query * fix bech32 prefix in selfStake resolver * linted * don't show proposals on terra * Fabo/switch to yarn (#122) * switch to yarn * Update Readme * Ana/111 regen testnet production (#118) * regen is home * fix websocket link * eslint fix * delete console logs * fixed regen source (using cosmosV0) * add feature flags for regen * fix txs in regen * fix transactions per address * fix eslint errors * disable sign in * colw/Transaction Service (#120) * Obtain transaction payload, mirror back to client * Respond with request, or error if none present * Load node friendly versions of cosmos-api for dev * Send response as JSON * Successfully retrieve a gas estimate - Use node-fetch for cosmosAPIs - * Add two sub routes: /estimate and /broadcast * Add account number and sequence to overview query * Disable cors options * Add support to broadcast messages * Ignore fetch undefined * Delete package-lock.json * Fabo/simplify queries (#108) * simplified db queries Conflicts: lib/luniedb-source.js lib/queries.js * switched to yarn * clean up * clean up * Copy cosmos libraries into container (#143) * Aleksei/terra url change (#144) * terra url changed * change soju-0010 to soju-0012 * fixed db queries (#147) * Update networks.json (#149) * Fabo/events (#123) * first steps * working notification endpoint * remove push mentions * linted * fixes * updated schema * use enum for eventtype * working subscription * linted * added push to express routes * remove newer code * linted * Update lib/routes/push.js Co-Authored-By: Col * disable session for regen (#155) * Aleksei/terra url change (#146) * terra url changed * change soju-0010 to soju-0012 * cors added to caddyfiles * cors added to caddyfiles * fix missing path * Fabo/fix vote count (#157) * fixed vote count calculation * linted * Ana/handle with message proposal id error (#159) * handle undefined proposal error * fix lint errors * Ana/add endtime to undelegation tx (#150) * add liquiddate as field for tx * fix eslint errors * change name liquidDate to undelegationEndTime * fix enddelegationtime for gaia * improve reducer my way * fix lint error * move undelegationendtime to reducer * fix lint errors * no abbreviations * implement undelegation endtime reducer in both * reenable session for gaia 13006 (#165) * Ana/fix terra undelegationendtime reducer (#162) * change reducers to cosmosV2 * prevent result undefined error * add own gettransaction and txreducer for terra * fix terra undelegationendtime reducer * fix lint errors * avoid hardcoded indexes * small fix to prevent total server error * no redundancy: add reducers to transactionreducer * fix lint * trigger CI * Don't return delegations with dust amounts (#171) * Add filter to delegations * Fix filter * Simplify * add undelegations to total stake (#174) * Terra chain_id switched to soju-0013 (#176) * terra chaind_id switched to soju-0013 * changed terra node * fix issues with undelegatio end time (#175) * Fabo/fix undelegationendtime (#177) * fix issues with undelegatio end time * catch undelegation attribute not found * Fabo/fix undelegationendtime for regen (#178) * fix issues with undelegatio end time * catch undelegation attribute not found * fix regen transaction reducers * Display Deposit Period End Date correctly for proposals in deposit period (#181) * Return proposal.voting_end_time in deposit period * Return deposit_end_time instead * update to new reducers and chain-id (#182) * Fabo/fix rewards (#185) * fixed a bug where a single proposal would not load (#125) * trigger ci * fixed missing terra data source (#128) * Fabo/fix missing terra db query (#130) * fixed missing terra data source * fixed missing query * Fabo/fix failing staking query for terra (#132) * fixed missing terra data source * fixed missing query * fix bech32 prefix in selfStake resolver * linted * Fabo/hide proposals on terra (#134) * fixed missing terra data source * fixed missing query * fix bech32 prefix in selfStake resolver * linted * don't show proposals on terra * Fabo/switch to yarn (#122) * switch to yarn * Update Readme * Ana/111 regen testnet production (#118) * regen is home * fix websocket link * eslint fix * delete console logs * fixed regen source (using cosmosV0) * add feature flags for regen * fix txs in regen * fix transactions per address * fix eslint errors * disable sign in * colw/Transaction Service (#120) * Obtain transaction payload, mirror back to client * Respond with request, or error if none present * Load node friendly versions of cosmos-api for dev * Send response as JSON * Successfully retrieve a gas estimate - Use node-fetch for cosmosAPIs - * Add two sub routes: /estimate and /broadcast * Add account number and sequence to overview query * Disable cors options * Add support to broadcast messages * Ignore fetch undefined * Delete package-lock.json * Fabo/simplify queries (#108) * simplified db queries Conflicts: lib/luniedb-source.js lib/queries.js * switched to yarn * clean up * clean up * Copy cosmos libraries into container (#143) * Aleksei/terra url change (#144) * terra url changed * change soju-0010 to soju-0012 * fixed db queries (#147) * Update networks.json (#149) * Fabo/events (#123) * first steps * working notification endpoint * remove push mentions * linted * fixes * updated schema * use enum for eventtype * working subscription * linted * added push to express routes * remove newer code * linted * Update lib/routes/push.js Co-Authored-By: Col * disable session for regen (#155) * Aleksei/terra url change (#146) * terra url changed * change soju-0010 to soju-0012 * cors added to caddyfiles * cors added to caddyfiles * fix missing path * Fabo/fix vote count (#157) * fixed vote count calculation * linted * Ana/handle with message proposal id error (#159) * handle undefined proposal error * fix lint errors * Ana/add endtime to undelegation tx (#150) * add liquiddate as field for tx * fix eslint errors * change name liquidDate to undelegationEndTime * fix enddelegationtime for gaia * improve reducer my way * fix lint error * move undelegationendtime to reducer * fix lint errors * no abbreviations * implement undelegation endtime reducer in both * reenable session for gaia 13006 (#165) * Ana/fix terra undelegationendtime reducer (#162) * change reducers to cosmosV2 * prevent result undefined error * add own gettransaction and txreducer for terra * fix terra undelegationendtime reducer * fix lint errors * avoid hardcoded indexes * small fix to prevent total server error * no redundancy: add reducers to transactionreducer * fix lint * trigger CI * Don't return delegations with dust amounts (#171) * Add filter to delegations * Fix filter * Simplify * add undelegations to total stake (#174) * Terra chain_id switched to soju-0013 (#176) * terra chaind_id switched to soju-0013 * changed terra node * fix issues with undelegatio end time (#175) * Fabo/fix undelegationendtime (#177) * fix issues with undelegatio end time * catch undelegation attribute not found * Fabo/fix undelegationendtime for regen (#178) * fix issues with undelegatio end time * catch undelegation attribute not found * fix regen transaction reducers * Display Deposit Period End Date correctly for proposals in deposit period (#181) * Return proposal.voting_end_time in deposit period * Return deposit_end_time instead * update to new reducers and chain-id (#182) * fix rewards not being extracted correctly * linted * trigger deploy * Ana/105 livepeer into production (#114) * add livepeer first files * first tentative. add transcoder type and queries * progress * progress + trying * eslint fix * working * recover missing config enabletestnet * delete livepeer from resolver and schema * try getallvalidators in livepeerv0-source * todos: own subscription and own reducers * eslint fix * refactored into graphql data source * add livepeer to networks json * little hack (temporary) * fix silly eslint error * start playing * fetch works. add to apollo * fix lint * get last round id/height * fix lint * set all feature flags to false * forward. add livepeer reducer. 400 bad request * fix lint * kind of working * fix networkId * colin/ make node subscription great * use transcoders no orchestrators. getValidator * connecting to block height and validators display * minor lint * add validator name * provisory getselfstake * improve validator reducer * use bignumber lib. add getdelegatorsstake * fix lint * fix gettotal stake delegators * fix lint * clean up * get self stake * delete livepeer-queries * handle url with node url class * delete extra back ticks * invisible lint fix * better prevent than regret * delete getlastrounid function * fix total stake and self stake * remove console log * use getblockheight to find last block * get validators from db * get more names * get ALL validators * use validator query string * use bignumber instead of parseint * minor lint * fix validators names * improve condition * get all validators for real * fix search filter for operator address * fix search filter * finishing fixes (formatbech32 and bignumber) * try implementing votingpower. no api support * refactoring and renaming * enable votingpower * livepeer is mainnet * fix voting power filter (#188) * disable livepeer for now (#191) * double the gas estimate for txs (#193) * wait for txs to be included in a block (#194) * Move expected returns to separate resolver (#172) * Move expected returns to separate resolver * Scale result by 1/1000000 --- lib/controller/transaction/index.js | 7 +++--- lib/cosmosV0-source.js | 10 +++++++++ lib/reducers/cosmosV0-reducers.js | 35 ++++++++++++----------------- lib/reducers/cosmosV2-reducers.js | 17 +++----------- lib/resolvers.js | 5 +++++ 5 files changed, 36 insertions(+), 38 deletions(-) diff --git a/lib/controller/transaction/index.js b/lib/controller/transaction/index.js index fb6271d518..c09b5a548f 100644 --- a/lib/controller/transaction/index.js +++ b/lib/controller/transaction/index.js @@ -14,7 +14,7 @@ async function estimate(tx) { const message = getMessage(tx.messageType, tx.txProperties, context) try { - const gasEstimate = await message.simulate({ memo: tx.memo }) + const gasEstimate = (await message.simulate({ memo: tx.memo })) * 2 // we double the gas to be save. rn there are several txs failing on cosmoshub-3 return { gasEstimate, success: true @@ -53,7 +53,8 @@ module.exports = { async function broadcastTransaction(url, signedTx) { // broadcast transaction with signatures included - const body = createBroadcastBody(signedTx, `sync`) + // `block` means we wait for the tx to be included into a block before returning. this helps with figuring out "out of gas" issues which only appear when the block is created + const body = createBroadcastBody(signedTx, `block`) console.log('broadcast to:', url) // eslint-disable-next-line no-undef const res = await fetch(`${url}/txs`, { @@ -69,7 +70,7 @@ async function broadcastTransaction(url, signedTx) { return res.txhash } -function createBroadcastBody(signedTx, returnType = `sync`) { +function createBroadcastBody(signedTx, returnType = `block`) { return JSON.stringify({ tx: signedTx, mode: returnType diff --git a/lib/cosmosV0-source.js b/lib/cosmosV0-source.js index 0e02099ad0..b8ebf27344 100644 --- a/lib/cosmosV0-source.js +++ b/lib/cosmosV0-source.js @@ -341,6 +341,16 @@ class CosmosV0API extends PerBlockCacheDataSource { return response } + async getExpectedReturns(validator) { + const annualProvision = await this.getAnnualProvision() + const expectedReturns = this.reducers.expectedRewardsPerToken( + validator, + validator.commission, + annualProvision + ) + return expectedReturns + } + async getRewards(delegatorAddress, validatorsDictionary, delegations = null) { if (!delegations) { delegations = await this.getDelegationsForDelegatorAddress( diff --git a/lib/reducers/cosmosV0-reducers.js b/lib/reducers/cosmosV0-reducers.js index aeb49fbbcd..15c2cd89bc 100644 --- a/lib/reducers/cosmosV0-reducers.js +++ b/lib/reducers/cosmosV0-reducers.js @@ -64,23 +64,26 @@ const calculateTokens = (validator, shares) => { /* if you don't get this, write fabian@lunie.io */ // expected rewards if delegator stakes x tokens const expectedRewardsPerToken = (validator, commission, annualProvision) => { - if (validator.status === 0 || validator.jailed === true) { + if (validator.status === 'INACTIVE' || validator.jailed === true) { return 0 } // share of all provisioned block rewards all delegators of this validator get - const totalAnnualValidatorRewards = validator.voting_power * annualProvision + const totalAnnualValidatorRewards = BigNumber(validator.votingPower).times( + annualProvision + ) // the validator takes a cut in amount of the commission - const totalAnnualDelegatorRewards = - totalAnnualValidatorRewards * (1 - commission) + const totalAnnualDelegatorRewards = totalAnnualValidatorRewards.times( + BigNumber(1).minus(commission) + ) // validator.tokens is the amount of all tokens delegated to that validator // one token delegated would receive x percentage of all delegator rewards - const delegatorSharePerToken = 1 / validator.tokens - const annualDelegatorRewardsPerToken = - totalAnnualDelegatorRewards * delegatorSharePerToken - - return annualDelegatorRewardsPerToken + const delegatorSharePerToken = BigNumber(1).div(validator.tokens) + const annualDelegatorRewardsPerToken = totalAnnualDelegatorRewards.times( + delegatorSharePerToken + ) + return annualDelegatorRewardsPerToken.div(1000000) } // reduce deposits to one number and filter by required denom @@ -188,12 +191,7 @@ function getValidatorStatus(validator) { } } -function validatorReducer( - networkId, - signedBlocksWindow, - validator, - annualProvision -) { +function validatorReducer(networkId, signedBlocksWindow, validator) { const statusInfo = getValidatorStatus(validator) let websiteURL = validator.description.website if (!websiteURL || websiteURL === '[do-not-modify]') { @@ -226,12 +224,7 @@ function validatorReducer( maxChangeCommission: validator.commission.max_change_rate, status: statusInfo.status, statusDetailed: statusInfo.status_detailed, - delegatorShares: validator.delegator_shares, // needed to calculate delegation token amounts from shares - expectedReturns: expectedRewardsPerToken( - validator, - validator.commission.rate, - annualProvision - ) + delegatorShares: validator.delegator_shares // needed to calculate delegation token amounts from shares } } diff --git a/lib/reducers/cosmosV2-reducers.js b/lib/reducers/cosmosV2-reducers.js index 80fa955fda..b343fdaf99 100644 --- a/lib/reducers/cosmosV2-reducers.js +++ b/lib/reducers/cosmosV2-reducers.js @@ -5,8 +5,7 @@ const { getDeposit, tallyReducer, atoms, - getValidatorStatus, - expectedRewardsPerToken + getValidatorStatus } = cosmosV0Reducers function proposalReducer( @@ -41,12 +40,7 @@ function delegationReducer(delegation, validator) { } } -function validatorReducer( - networkId, - signedBlocksWindow, - validator, - annualProvision -) { +function validatorReducer(networkId, signedBlocksWindow, validator) { const statusInfo = getValidatorStatus(validator) let websiteURL = validator.description.website if (!websiteURL || websiteURL === '[do-not-modify]') { @@ -83,12 +77,7 @@ function validatorReducer( maxChangeCommission: validator.commission.commission_rates.max_change_rate, status: statusInfo.status, statusDetailed: statusInfo.status_detailed, - delegatorShares: validator.delegator_shares, // needed to calculate delegation token amounts from shares - expectedReturns: expectedRewardsPerToken( - validator, - validator.commission.commission_rates.rate, - annualProvision - ) + delegatorShares: validator.delegator_shares // needed to calculate delegation token amounts from shares } } diff --git a/lib/resolvers.js b/lib/resolvers.js index 8147cb0fd5..35ed761cbe 100644 --- a/lib/resolvers.js +++ b/lib/resolvers.js @@ -200,6 +200,11 @@ const resolvers = { } }, Validator: { + expectedReturns: (validator, _, { dataSources }) => { + return selectFrom(dataSources, validator.networkId).getExpectedReturns( + validator + ) + }, selfStake: (validator, _, { dataSources }) => { return selectFrom(dataSources, validator.networkId).getSelfStake( validator