Skip to content

Commit

Permalink
Merge branch 'master' into disable-quicksilver-amino-withdraw-commission
Browse files Browse the repository at this point in the history
  • Loading branch information
tombeynon authored Oct 24, 2023
2 parents 2bcffd1 + fce068c commit 9ebff7d
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 28 deletions.
4 changes: 2 additions & 2 deletions src/components/OperatorLastRestakeAlert.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ function OperatorLastRestakeAlert(props) {
if (!showWarning()) return null

return (
<AlertMessage variant="danger" dismissible={false}>
<AlertMessage variant="secondary" dismissible={false}>
This validator has not REStaked recently.
</AlertMessage>
)
}

export default OperatorLastRestakeAlert
export default OperatorLastRestakeAlert
4 changes: 2 additions & 2 deletions src/components/ValidatorStake.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,15 +305,15 @@ function ValidatorStake(props) {
<OperatorLastRestake operator={operator} lastExec={lastExec} />
</td>
</tr>
<tr>
{/* <tr>
<td scope="row">Next REStake</td>
<td>
<CountdownRestake
network={network}
operator={operator}
/>
</td>
</tr>
</tr> */}
</>
)}
<tr>
Expand Down
6 changes: 5 additions & 1 deletion src/networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@
"authzAminoExecPreventTypes": [
"/cosmos.gov.",
"/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission"
]
],
"authzAminoGenericOnly": true
},
{
"name": "cheqd"
Expand Down Expand Up @@ -281,5 +282,8 @@
"authzAminoExecPreventTypes": [
"/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission"
]
},
{
"name": "qwoyn"
}
]
58 changes: 35 additions & 23 deletions src/utils/Operator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,25 @@ const Operator = (network, data) => {

function missedRunCount(lastExec){
if(lastExec === false) return 9999
let count = 0
let times = runTimes().reverse()
let date = times[0]
while(date && date.isAfter(lastExec)){
times.forEach(time => {
if(time.isBefore() && time.isAfter(lastExec)){
count++
}
})
times = runTimes(date.subtract(1, 'day').startOf('day')).reverse()
date = times[0]
if(isInterval()){
const interval = parse(runTime[0].replace('every ', ''))
const count = Math.floor(moment().diff(lastExec, 'milliseconds') / interval)
return count
}else{
let count = 0
let times = runTimes().reverse()
let date = times[0]
while(date && date.isAfter(lastExec)){
times.forEach(time => {
if(time.isBefore() && time.isAfter(lastExec)){
count++
}
})
times = runTimes(date.subtract(1, 'day').startOf('day')).reverse()
date = times[0]
}
return count
}
return count
}

function isInterval(){
Expand All @@ -49,14 +55,20 @@ const Operator = (network, data) => {
let date = start.clone()
let [hours, minutes, seconds] = time.split(':')
if(parseInt(hours) >= 24) hours = 0
date.utc(true).add({hours, minutes, seconds})
date.utc(true).add({hours, minutes, seconds})
return date
}
}).flat()).sort((a, b) => a.valueOf() - b.valueOf())
}

function runsPerDay(max) {
let runs = runTimes().length
let runs
if(isInterval()){
const interval = parse(runTime[0].replace('every ', ''))
runs = parse('1d') / interval
}else{
runs = runTimes().length
}
return max && runs > max ? max : runs
}

Expand All @@ -82,14 +94,14 @@ const Operator = (network, data) => {
}
}

function nextRun() {
const today = runTimes()
const tomorrow = runTimes(moment().startOf('day').add(1, 'day'))
return [
...today,
...tomorrow
].find(el => el.isAfter())
}
// function nextRun() {
// const today = runTimes()
// const tomorrow = runTimes(moment().startOf('day').add(1, 'day'))
// return [
// ...today,
// ...tomorrow
// ].find(el => el.isAfter())
// }

return {
address,
Expand All @@ -99,7 +111,7 @@ const Operator = (network, data) => {
moniker: data.description?.moniker,
description: data.description,
data,
nextRun,
// nextRun,
frequency,
runTimes,
runTimesString,
Expand Down

0 comments on commit 9ebff7d

Please sign in to comment.