Skip to content

Commit

Permalink
Merge pull request #1408 from edenia/feat/add-fio-chain
Browse files Browse the repository at this point in the history
Add FIO Testnet
  • Loading branch information
xavier506 committed Jun 23, 2024
2 parents b2387ca + d5ebb24 commit 5337273
Show file tree
Hide file tree
Showing 20 changed files with 144 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy-airwire-testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
environment: airwire-testnet
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: 'step-log'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy-airwire.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
environment: airwire
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: 'step-log'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/deploy-fio-testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
REACT_APP_EOS_API_NETWORK_NAME: 'fio-testnet'
REACT_APP_EOS_API_NETWORK_LABEL: 'FIO Testnet'
REACT_APP_EOS_API_NETWORK_LOGO: 'https://antelope.tools/images/fio.png'
REACT_APP_EOS_API_HOSTS: '[\"fio-testnet.eosphere.io\"]'
REACT_APP_EOS_API_HOSTS: '[\"testnet.fioprotocol.io\",\"fio-testnet.eosphere.io\"]'
REACT_APP_EOS_API_PORT: '443'
REACT_APP_EOS_API_PROTOCOL: 'https'
REACT_APP_EOS_CHAIN_ID: 'b20901380af44ef59c5918439a1f9a41d83669020319a80574b804a5f95cbd7e'
Expand Down Expand Up @@ -81,8 +81,8 @@ jobs:
POSTGRES_DATA: ${{ secrets.POSTGRES_DATA }}
# hapi
HAPI_EOS_API_NETWORK_NAME: fio-testnet
HAPI_EOS_API_ENDPOINTS: '["https://fio-testnet.eosphere.io"]'
HAPI_EOS_STATE_HISTORY_PLUGIN_ENDPOINT: 'ws://'
HAPI_EOS_API_ENDPOINTS: '["https://testnet.fioprotocol.io","https://fio-testnet.eosphere.io"]'
HAPI_EOS_STATE_HISTORY_PLUGIN_ENDPOINT: ''
HAPI_EOS_MISSED_BLOCKS_ENABLED: 'false'
HAPI_EOS_BLOCK_HISTORY_DAYS: 90
HAPI_EOS_MAX_CPU_BLOCK: 250000
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy-jungle-testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
environment: jungle-testnet
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build new images and push
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy-lacchain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
environment: lacchain
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build new images and push
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy-libre-testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
environment: libre-testnet
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: 'step-log'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy-libre.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
environment: libre
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: 'step-log'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy-mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
environment: mainnet
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build new images and push
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy-telos-testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
environment: telos-testnet
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: 'step-log'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy-telos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
environment: telos
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: 'step-log'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy-ultra-testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
environment: ultra-testnet
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: 'step-log'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy-wax-testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
environment: wax-testnet
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: 'step-log'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy-wax.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
environment: wax
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: 'step-log'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy-xpr-testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
environment: proton-testnet
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: 'step-log'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy-xpr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
environment: proton
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: 'step-log'
Expand Down
File renamed without changes
84 changes: 84 additions & 0 deletions hapi/src/services/fioProducers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
const axios = require('axios');

// FIO API endpoint (replace with the correct endpoint if needed)
const FIO_API_URL = 'https://testnet.fioprotocol.io/v1/chain/get_table_rows';

const getProducers = async () => {
let producers = [];
let totalVoteWeight;
let hasMore = true;
let nextKey;

try {
while (hasMore) {
const response = await axios.post(FIO_API_URL, {
code: 'fio.system', // Contract name
table: 'producers', // Table name
scope: 'fio', // Scope
limit: 100,
json: true,
lower_bound: nextKey
});

if (response.status !== 200) {
throw new Error(`Request failed with status code ${response.status}`);
}

const {
rows,
more,
total_producer_vote_weight: _totalVoteWeight
} = response.data;

if (!rows) {
throw new Error('Response data does not contain rows');
}

hasMore = !!more;
nextKey = more;
totalVoteWeight = parseFloat(_totalVoteWeight);
producers.push(...rows);
}
} catch (error) {
console.error('PRODUCER SYNC ERROR', error.message);
return;
}

producers = producers
.filter(producer => !!producer.is_active)
.sort((a, b) => {
if (parseFloat(a.total_votes) > parseFloat(b.total_votes)) {
return -1;
}

if (parseFloat(a.total_votes) < parseFloat(b.total_votes)) {
return 1;
}

return 0;
});

producers = producers.map((producer, index) => {
return {
id: producer.id,
owner: producer.owner,
fio_address: producer.fio_address,
total_votes: producer.total_votes,
total_votes_percent: producer.total_votes / totalVoteWeight,
total_votes_eos: producer.total_votes,
rank: index + 1,
producer_public_key: producer.producer_public_key,
url: producer.url,
unpaid_blocks: producer.unpaid_blocks,
last_claim_time: producer.last_claim_time,
location: producer.location,
is_active: !!producer.is_active
};
});

console.log(producers);
return producers;
}

// Call the function to test it
getProducers();
Empty file.
Empty file.

0 comments on commit 5337273

Please sign in to comment.