Skip to content

Commit 6e6fb11

Browse files
author
Luka Jeran
authored
Merge pull request #1113 from oasisprotocol/lw/dump-bash
Convert dump_validators from jest to bash
2 parents 659c554 + cd2df49 commit 6e6fb11

File tree

7 files changed

+6791
-2456
lines changed

7 files changed

+6791
-2456
lines changed

.github/dump_validators.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
curl -s https://api.oasisscan.com/mainnet/validator/list?pageSize=500 |
4+
jq '{
5+
dump_timestamp: (now * 1000 | floor),
6+
dump_timestamp_iso: (now | strftime("%Y-%m-%dT%H:%M:%SZ")),
7+
list: .data.list
8+
}' \
9+
>|"$(dirname "$0")/../src/vendors/oasisscan/dump_validators.json"

.github/workflows/dump-validators.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v3
15-
- name: Use Node.js 14.x
16-
uses: actions/setup-node@v3
17-
with:
18-
node-version: 14.x
19-
cache: 'yarn'
20-
- run: yarn install --frozen-lockfile
21-
- run: yarn dump-validators
15+
- run: bash ./.github/dump_validators.sh
2216
- name: Create Pull Request with updated dumped validators
2317
# https://github.com/peter-evans/create-pull-request
2418
uses: peter-evans/create-pull-request@v4

internals/scripts/dump_validators.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
"extract-messages": "i18next-scanner --config=internals/extractMessages/i18next-scanner.config.js",
2929
"semantic-release": "semantic-release",
3030
"print-csp": "node ./internals/scripts/print-csp.js",
31-
"print-extension-csp": "node ./internals/scripts/print-extension-csp.js",
32-
"dump-validators": "CI=1 jest --roots ./internals --testMatch '<rootDir>/internals/scripts/dump_validators.ts'"
31+
"print-extension-csp": "node ./internals/scripts/print-extension-csp.js"
3332
},
3433
"browserslist": {
3534
"production": [

src/app/state/staking/saga.test.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import {
1717
stakingSaga,
1818
} from './saga'
1919
import { DebondingDelegation, Delegation, StakingState, Validator } from './types'
20+
import { parseValidatorsList } from 'vendors/oasisscan'
21+
import { ValidatorRow } from 'vendors/oasisscan/models'
2022

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

@@ -153,21 +155,21 @@ describe('Staking Sagas', () => {
153155
list: [
154156
{
155157
rank: 1,
156-
address: 'oasis1qq3xrq0urs8qcffhvmhfhz4p0mu7ewc8rscnlwxe',
158+
entityAddress: 'oasis1qq3xrq0urs8qcffhvmhfhz4p0mu7ewc8rscnlwxe',
157159
name: 'stakefish',
158160
nodeAddress: 'oasis1qrg52ccz4ts6cct2qu4retxn7kkdlusjh5pe74ar',
159-
status: 'active',
160-
escrow: 2000n.toString(),
161-
_expectedStatus: 'active' as const,
161+
escrow: '0.2',
162+
status: true,
163+
_expectedStatus: true,
162164
},
163165
{
164166
rank: 2,
165-
address: 'oasis1qqekv2ymgzmd8j2s2u7g0hhc7e77e654kvwqtjwm',
167+
entityAddress: 'oasis1qqekv2ymgzmd8j2s2u7g0hhc7e77e654kvwqtjwm',
166168
name: 'BinanceStaking',
167169
nodeAddress: 'oasis1qqp0h2h92eev7nsxgqctvuegt8ge3vyg0qyluc4k',
168-
status: 'active',
169-
escrow: 1000n.toString(),
170-
_expectedStatus: 'inactive' as const,
170+
escrow: '0.1',
171+
status: true,
172+
_expectedStatus: false,
171173
},
172174
],
173175
}
@@ -196,10 +198,12 @@ describe('Staking Sagas', () => {
196198
validators: {
197199
timestamp: getMainnetDumpValidatorsMock.dump_timestamp,
198200
network: 'mainnet',
199-
list: getMainnetDumpValidatorsMock.list.map((v, ix) => ({
200-
...v,
201-
status: v._expectedStatus,
202-
})),
201+
list: parseValidatorsList(
202+
getMainnetDumpValidatorsMock.list.map(({ _expectedStatus, ...v }) => ({
203+
...v,
204+
status: _expectedStatus,
205+
})) as ValidatorRow[],
206+
),
203207
},
204208
}),
205209
)

src/app/state/staking/saga.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { NetworkType } from 'app/state/network/types'
66
import { call, put, select, takeLatest } from 'typed-redux-saga'
77
import { WalletError, WalletErrors } from 'types/errors'
88
import { sortByStatus } from 'vendors/helpers'
9+
import { parseValidatorsList } from 'vendors/oasisscan'
910

1011
import { stakingActions } from '.'
1112
import { getExplorerAPIs, getOasisNic } from '../network/saga'
@@ -95,7 +96,7 @@ function* getFallbackValidators(network: NetworkType, errorApi: Error) {
9596
fallbackValidators = {
9697
timestamp: dump_validators.dump_timestamp,
9798
network: 'mainnet',
98-
list: dump_validators.list.map(v => {
99+
list: parseValidatorsList(dump_validators.list).map(v => {
99100
return {
100101
...v,
101102
status: 'unknown',

0 commit comments

Comments
 (0)