Skip to content

Commit

Permalink
Merge pull request #2102 from oasisprotocol/mz/dump
Browse files Browse the repository at this point in the history
Switch dump validators to Nexus
  • Loading branch information
buberdds authored Jan 9, 2025
2 parents 1b2bab5 + e132d2b commit 1e4327a
Show file tree
Hide file tree
Showing 10 changed files with 7,826 additions and 7,718 deletions.
1 change: 1 addition & 0 deletions .changelog/2102.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Switch dump validators to Nexus
4 changes: 3 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,6 @@ Procfile text
# Auto-generated files
src/vendors/explorer/*/** linguist-generated=true
src/vendors/oasisscan/*/** linguist-generated=true
src/vendors/oasisscan/dump_validators.json linguist-generated=true
src/vendors/oasisscan-v2/*/** linguist-generated=true
src/vendors/nexus/*/** linguist-generated=true
src/vendors/nexus/dump_validators.json linguist-generated=true
6 changes: 3 additions & 3 deletions .github/dump_validators.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/sh

curl -s https://api.oasisscan.com/mainnet/validator/list?pageSize=500 |
curl -s https://nexus.oasis.io/v1/consensus/validators?limit=500 |
jq '{
dump_timestamp: (now * 1000 | floor),
dump_timestamp_iso: (now | strftime("%Y-%m-%dT%H:%M:%SZ")),
list: .data.list
list: .validators
}' \
>|"$(dirname "$0")/../src/vendors/oasisscan/dump_validators.json"
>|"$(dirname "$0")/../src/vendors/nexus/dump_validators.json"
76 changes: 60 additions & 16 deletions src/app/state/staking/saga.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import {
stakingSaga,
} from './saga'
import { DebondingDelegation, Delegation, StakingState, Validator } from './types'
import { parseValidatorsList } from 'vendors/oasisscan'
import { ValidatorRow } from 'vendors/oasisscan/models'
import { parseValidatorsList } from 'vendors/nexus'
import { Validator as NexusValidator } from 'vendors/nexus/models'

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

Expand Down Expand Up @@ -158,21 +158,65 @@ describe('Staking Sagas', () => {
dump_timestamp_iso: '2022-03-23T00:52:41.337Z',
list: [
{
rank: 1,
entityAddress: 'oasis1qq3xrq0urs8qcffhvmhfhz4p0mu7ewc8rscnlwxe',
name: 'stakefish',
nodeAddress: 'oasis1qrg52ccz4ts6cct2qu4retxn7kkdlusjh5pe74ar',
escrow: '0.2',
status: true,
active: true,
current_commission_bound: {
epoch_end: 0,
epoch_start: 0,
lower: 0,
upper: 20000,
},
current_rate: 5000,
entity_address: 'oasis1qq3xrq0urs8qcffhvmhfhz4p0mu7ewc8rscnlwxe',
entity_id: 'eZuacXy5s3/nolB/E3gF4vqUYdvfOlVaaBXGfZcGwKc=',
escrow: {
active_balance: '153866511910432557',
active_shares: '109032182592723438',
debonding_balance: '16650100374694405',
debonding_shares: '16650100374694405',
num_delegators: 7763,
self_delegation_balance: '619388791323275',
self_delegation_shares: '438908447022946',
},
in_validator_set: true,
media: {
name: 'stakefish',
},
node_id: 'SQZZd1wsWXdFsqswUoh6hZtmzu+ejuSnrGeHtgIBJDo=',
rank: 2,
start_date: '2024-04-11T03:43:47Z',
voting_power: 9616629779339760,
voting_power_cumulative: 19271157520617090,
_expectedStatus: true,
},
{
rank: 2,
entityAddress: 'oasis1qqekv2ymgzmd8j2s2u7g0hhc7e77e654kvwqtjwm',
name: 'BinanceStaking',
nodeAddress: 'oasis1qqp0h2h92eev7nsxgqctvuegt8ge3vyg0qyluc4k',
escrow: '0.1',
status: true,
active: true,
current_commission_bound: {
epoch_end: 0,
epoch_start: 4725,
lower: 0,
upper: 25000,
},
current_rate: 10000,
entity_address: 'oasis1qqekv2ymgzmd8j2s2u7g0hhc7e77e654kvwqtjwm',
entity_id: '9sAhd+Wi6tG5nAr3LwXD0y9mUKLYqfAbS2+7SZdNHB4=',
escrow: {
active_balance: '120770371034123739',
active_shares: '94613417937776490',
debonding_balance: '3799179743582808',
debonding_shares: '3799179743582808',
num_delegators: 7199,
self_delegation_balance: '3484701686486584',
self_delegation_shares: '2729970391155567',
},
in_validator_set: true,
media: {
name: 'BinanceStaking',
},
node_id: '6wbL5/OxvFGxi55o7AxcwKmfjXbXGC1hw4lfnEZxBXA=',
rank: 5,
start_date: '2021-04-28T16:00:00Z',
voting_power: 7548126828433809,
voting_power_cumulative: 43461945454389704,
_expectedStatus: false,
},
],
Expand Down Expand Up @@ -207,8 +251,8 @@ describe('Staking Sagas', () => {
list: parseValidatorsList(
getMainnetDumpValidatorsMock.list.map(({ _expectedStatus, ...v }) => ({
...v,
status: _expectedStatus,
})) as ValidatorRow[],
active: _expectedStatus,
})) as NexusValidator[],
),
},
}),
Expand Down
4 changes: 2 additions & 2 deletions src/app/state/staking/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { addressToPublicKey, publicKeyToAddress } from 'app/lib/helpers'
import { NetworkType } from 'app/state/network/types'
import { call, put, select, takeLatest } from 'typed-redux-saga'
import { WalletError, WalletErrors } from 'types/errors'
import { parseValidatorsList } from 'vendors/oasisscan'
import { parseValidatorsList } from 'vendors/nexus'

import { stakingActions } from '.'
import { getEpoch, getExplorerAPIs, getOasisNic } from '../network/saga'
Expand Down Expand Up @@ -149,7 +149,7 @@ export function now() {
}

export async function getMainnetDumpValidators() {
return await import('vendors/oasisscan/dump_validators.json')
return await import('vendors/nexus/dump_validators.json')
}

export function* getValidatorDetails({ payload: address }: PayloadAction<string>) {
Expand Down
2 changes: 1 addition & 1 deletion src/vendors/nexus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function parseAccount(account: NexusAccount): Account {
}
}

function parseValidatorsList(validators: NexusValidator[]): Validator[] {
export function parseValidatorsList(validators: NexusValidator[]): Validator[] {
return validators.map(v => {
const parsed: Validator = {
address: v.entity_address,
Expand Down
Loading

0 comments on commit 1e4327a

Please sign in to comment.