Skip to content

Commit

Permalink
Merge pull request #1113 from oasisprotocol/lw/dump-bash
Browse files Browse the repository at this point in the history
Convert dump_validators from jest to bash
  • Loading branch information
lukaw3d authored Oct 27, 2022
2 parents 659c554 + cd2df49 commit 6e6fb11
Show file tree
Hide file tree
Showing 7 changed files with 6,791 additions and 2,456 deletions.
9 changes: 9 additions & 0 deletions .github/dump_validators.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

curl -s https://api.oasisscan.com/mainnet/validator/list?pageSize=500 |
jq '{
dump_timestamp: (now * 1000 | floor),
dump_timestamp_iso: (now | strftime("%Y-%m-%dT%H:%M:%SZ")),
list: .data.list
}' \
>|"$(dirname "$0")/../src/vendors/oasisscan/dump_validators.json"
8 changes: 1 addition & 7 deletions .github/workflows/dump-validators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 14.x
uses: actions/setup-node@v3
with:
node-version: 14.x
cache: 'yarn'
- run: yarn install --frozen-lockfile
- run: yarn dump-validators
- run: bash ./.github/dump_validators.sh
- name: Create Pull Request with updated dumped validators
# https://github.com/peter-evans/create-pull-request
uses: peter-evans/create-pull-request@v4
Expand Down
20 changes: 0 additions & 20 deletions internals/scripts/dump_validators.ts

This file was deleted.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
"extract-messages": "i18next-scanner --config=internals/extractMessages/i18next-scanner.config.js",
"semantic-release": "semantic-release",
"print-csp": "node ./internals/scripts/print-csp.js",
"print-extension-csp": "node ./internals/scripts/print-extension-csp.js",
"dump-validators": "CI=1 jest --roots ./internals --testMatch '<rootDir>/internals/scripts/dump_validators.ts'"
"print-extension-csp": "node ./internals/scripts/print-extension-csp.js"
},
"browserslist": {
"production": [
Expand Down
28 changes: 16 additions & 12 deletions src/app/state/staking/saga.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
stakingSaga,
} from './saga'
import { DebondingDelegation, Delegation, StakingState, Validator } from './types'
import { parseValidatorsList } from 'vendors/oasisscan'
import { ValidatorRow } from 'vendors/oasisscan/models'

const qty = (number: number) => oasis.quantity.fromBigInt(BigInt(number))

Expand Down Expand Up @@ -153,21 +155,21 @@ describe('Staking Sagas', () => {
list: [
{
rank: 1,
address: 'oasis1qq3xrq0urs8qcffhvmhfhz4p0mu7ewc8rscnlwxe',
entityAddress: 'oasis1qq3xrq0urs8qcffhvmhfhz4p0mu7ewc8rscnlwxe',
name: 'stakefish',
nodeAddress: 'oasis1qrg52ccz4ts6cct2qu4retxn7kkdlusjh5pe74ar',
status: 'active',
escrow: 2000n.toString(),
_expectedStatus: 'active' as const,
escrow: '0.2',
status: true,
_expectedStatus: true,
},
{
rank: 2,
address: 'oasis1qqekv2ymgzmd8j2s2u7g0hhc7e77e654kvwqtjwm',
entityAddress: 'oasis1qqekv2ymgzmd8j2s2u7g0hhc7e77e654kvwqtjwm',
name: 'BinanceStaking',
nodeAddress: 'oasis1qqp0h2h92eev7nsxgqctvuegt8ge3vyg0qyluc4k',
status: 'active',
escrow: 1000n.toString(),
_expectedStatus: 'inactive' as const,
escrow: '0.1',
status: true,
_expectedStatus: false,
},
],
}
Expand Down Expand Up @@ -196,10 +198,12 @@ describe('Staking Sagas', () => {
validators: {
timestamp: getMainnetDumpValidatorsMock.dump_timestamp,
network: 'mainnet',
list: getMainnetDumpValidatorsMock.list.map((v, ix) => ({
...v,
status: v._expectedStatus,
})),
list: parseValidatorsList(
getMainnetDumpValidatorsMock.list.map(({ _expectedStatus, ...v }) => ({
...v,
status: _expectedStatus,
})) as ValidatorRow[],
),
},
}),
)
Expand Down
3 changes: 2 additions & 1 deletion src/app/state/staking/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { NetworkType } from 'app/state/network/types'
import { call, put, select, takeLatest } from 'typed-redux-saga'
import { WalletError, WalletErrors } from 'types/errors'
import { sortByStatus } from 'vendors/helpers'
import { parseValidatorsList } from 'vendors/oasisscan'

import { stakingActions } from '.'
import { getExplorerAPIs, getOasisNic } from '../network/saga'
Expand Down Expand Up @@ -95,7 +96,7 @@ function* getFallbackValidators(network: NetworkType, errorApi: Error) {
fallbackValidators = {
timestamp: dump_validators.dump_timestamp,
network: 'mainnet',
list: dump_validators.list.map(v => {
list: parseValidatorsList(dump_validators.list).map(v => {
return {
...v,
status: 'unknown',
Expand Down
Loading

0 comments on commit 6e6fb11

Please sign in to comment.