Skip to content

Commit

Permalink
release (#179)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* 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
  • Loading branch information
faboweb authored Dec 11, 2019
1 parent b2683ab commit 52b9e2c
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 28 deletions.
6 changes: 3 additions & 3 deletions data/networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@
"terra-testnet": {
"id": "terra-testnet",
"title": "Terra",
"chain_id": "soju-0012",
"api_url": "http://terra-soju-0012.lunie.io/",
"rpc_url": "wss://terra-soju-0012.lunie.io/websocket",
"chain_id": "soju-0013",
"api_url": "http://terra-testnet.lunie.io/",
"rpc_url": "wss://terra-testnet.lunie.io/websocket",
"bech32_prefix": "terra",
"testnet": true,
"feature_session": false,
Expand Down
12 changes: 11 additions & 1 deletion lib/cosmosV0-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,21 @@ class CosmosV0API extends PerBlockCacheDataSource {
}

async getOverview(delegatorAddress, validatorsDictionary) {
const [balances, delegations, stakingDenom] = await Promise.all([
const [
balances,
delegations,
undelegations,
stakingDenom
] = await Promise.all([
this.getBalancesFromAddress(delegatorAddress),
this.getDelegationsForDelegatorAddress(
delegatorAddress,
validatorsDictionary
),
this.getUndelegationsForDelegatorAddress(
delegatorAddress,
validatorsDictionary
),
this.getStakinDenom()
])
const rewards = await this.getRewards(
Expand All @@ -381,6 +390,7 @@ class CosmosV0API extends PerBlockCacheDataSource {
return this.reducers.overviewReducer(
balances,
delegations,
undelegations,
rewards,
stakingDenom
)
Expand Down
16 changes: 13 additions & 3 deletions lib/reducers/cosmosV0-reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function proposalBeginTime(proposal) {
function proposalEndTime(proposal) {
switch (proposal.proposal_status.toLowerCase()) {
case 'depositperiod':
return proposal.voting_start_time
return proposal.deposit_end_time
case 'votingperiod':
// the end time lives in the past already if the proposal is finalized
// eslint-disable-next-line no-fallthrough
Expand Down Expand Up @@ -299,7 +299,13 @@ function rewardReducer(reward, validator) {
}
}

function overviewReducer(balances, delegations, rewards, stakingDenom) {
function overviewReducer(
balances,
delegations,
undelegations,
rewards,
stakingDenom
) {
stakingDenom = denomLookup(stakingDenom)

const totalRewards = _.flatten(rewards)
Expand All @@ -316,12 +322,16 @@ function overviewReducer(balances, delegations, rewards, stakingDenom) {
(sum, { amount }) => BigNumber(sum).plus(amount),
0
)
const undelegatingStake = undelegations.reduce(
(sum, { amount }) => BigNumber(sum).plus(amount),
0
)

return {
// rewards,
totalRewards: totalRewards,
liquidStake: liquidStake,
totalStake: liquidStake.plus(delegatedStake)
totalStake: liquidStake.plus(delegatedStake).plus(undelegatingStake)
}
}

Expand Down
17 changes: 11 additions & 6 deletions lib/reducers/cosmosV2-reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,17 @@ function validatorReducer(
}

function undelegationEndTimeReducer(transaction) {
if (
transaction.events[1].attributes.find(tx => tx.key === `completion_time`)
) {
return transaction.events[1].attributes.filter(
tx => tx.key === `completion_time`
)[0].value
if (transaction.events) {
let completionTimeAttribute
transaction.events.find(({ attributes }) => {
if (attributes) {
completionTimeAttribute = attributes.find(
tx => tx.key === `completion_time`
)
}
return !!completionTimeAttribute
})
return completionTimeAttribute ? completionTimeAttribute.value : undefined
} else {
return null
}
Expand Down
31 changes: 18 additions & 13 deletions lib/reducers/terraV3-reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,24 @@ const cosmosV2Reducers = require('./cosmosV2-reducers')

// Terra has a slightly different structure and needs its own undelegationEndTimeReducer
function undelegationEndTimeReducer(transaction) {
if (transaction.logs[0].events.length > 2) {
let endTime
const attributes = Object.values(transaction.logs[0].events).map(
event => event.attributes
)
attributes.forEach(attribute =>
attribute.map(tx => {
if (tx.key === `completion_time`) {
endTime = tx.value
}
})
)
return endTime ? endTime : null
if (transaction.logs) {
let completionTimeAttribute
transaction.logs.find(({ events }) => {
if (events) {
events.find(({ attributes }) => {
if (attributes) {
completionTimeAttribute = attributes.find(
tx => tx.key === `completion_time`
)
}
return !!completionTimeAttribute
})
}
return !!completionTimeAttribute
})
return completionTimeAttribute ? completionTimeAttribute.value : undefined
} else {
return null
}
}

Expand Down
8 changes: 6 additions & 2 deletions lib/regenV0-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class RegenV0API extends CosmosV0API {
async getTransactionsByHeight(height) {
const { txs } = await this.get(`txs?tx.height=${height}`)
return Array.isArray(txs)
? txs.map(transaction => this.reducers.transactionReducer(transaction))
? txs.map(transaction =>
this.reducers.transactionReducer(transaction, this.reducers)
)
: []
}

Expand All @@ -31,7 +33,9 @@ class RegenV0API extends CosmosV0API {
const dupFreeTxs = uniqWith(txs, (a, b) => a.txhash === b.txhash)
const sortedTxs = sortBy(dupFreeTxs, ['timestamp'])
const reversedTxs = reverse(sortedTxs)
return reversedTxs.map(transactionReducer)
return reversedTxs.map(transaction =>
transactionReducer(transaction, this.reducers)
)
}
}

Expand Down

0 comments on commit 52b9e2c

Please sign in to comment.