Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:edenia/eden-spend-explorer into fix/…
Browse files Browse the repository at this point in the history
…add-missing-image-on-help-section-340
  • Loading branch information
JAMares committed Dec 22, 2022
2 parents ff3a100 + 3bd1d86 commit 39496dd
Show file tree
Hide file tree
Showing 36 changed files with 312 additions and 394 deletions.
30 changes: 18 additions & 12 deletions .github/workflows/push-dev-environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build images from latest dev branch
on:
push:
branches:
- main
- dev

jobs:
create-dev-image:
Expand All @@ -26,8 +26,10 @@ jobs:
build-docker-images \
push-docker-images
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
IMAGE_NAME_WEBAPP: eden-spending-webapp-dev
IMAGE_NAME_HAPI: eden-spending-hapi-dev
IMAGE_NAME_HASURA: eden-spending-hasura-dev
IMAGE_NAME_WALLET: eden-spending-wallet-dev
# webapp
PORT: 80
REACT_APP_TAG: ${{ github.ref }}
Expand All @@ -37,9 +39,9 @@ jobs:
REACT_APP_FOOTER_LINKS: '[]'
REACT_APP_UAL_APP_NAME: 'EOS Reports'
REACT_APP_UAL_API_PROTOCOL: 'https'
REACT_APP_UAL_API_HOST: 'eos.greymass.com'
REACT_APP_UAL_API_HOST: 'jungle4.api.eosnation.io'
REACT_APP_UAL_API_PORT: '443'
REACT_APP_UAL_CHAIN_ID: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906'
REACT_APP_UAL_CHAIN_ID: '73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d'
REACT_APP_HASURA_URL: ${{ secrets.REACT_APP_HASURA_URL }}
REACT_APP_RATE_HISTORY: ${{ secrets.REACT_APP_RATE_HISTORY }}
REACT_APP_EDEN_CONTRACT: 'genesis.eden'
Expand All @@ -52,8 +54,12 @@ jobs:
env:
# general
NAMESPACE: eden-spending
INGRESS_HOST: spending.eden.eoscommunity.org
INGRESS_GRAPHQL_HOST: graphql-spending.eden.eoscommunity.org
INGRESS_HOST: spending-eden.edenia.cloud
INGRESS_GRAPHQL_HOST: graphql-spending-eden.edenia.cloud
IMAGE_NAME_WEBAPP: eden-spending-webapp-dev
IMAGE_NAME_HAPI: eden-spending-hapi-dev
IMAGE_NAME_HASURA: eden-spending-hasura-dev
IMAGE_NAME_WALLET: eden-spending-wallet-dev
# Postgres
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
Expand All @@ -62,8 +68,8 @@ jobs:
# hapi
HAPI_SERVER_PORT: 9090
HAPI_SERVER_ADDRESS: 0.0.0.0
HAPI_NETWORK_API: 'https://eos.edenia.cloud'
HAPI_NETWORK_CHAIN_ID: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906'
HAPI_NETWORK_API: 'https://jungle4.api.eosnation.io'
HAPI_NETWORK_CHAIN_ID: '73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d'
HAPI_NETWORK_BASE_ACCOUNT: ${{ secrets.HAPI_NETWORK_BASE_ACCOUNT }}
HAPI_NETWORK_BASE_PASSWORD: ${{ secrets.HAPI_NETWORK_BASE_PASSWORD }}
HAPI_NETWORK_WALLET_URL: ${{ secrets.HAPI_NETWORK_WALLET }}
Expand All @@ -73,8 +79,8 @@ jobs:
HAPI_EDEN_ELECTION_INTERVAL: 7889400
HAPI_EDEN_HISTORIC_ELECTION: ${{secrets.HAPI_EDEN_HISTORIC_ELECTION}}
HAPI_EDEN_CONTRACT: genesis.eden
HAPI_DFUSE_API_KEY: ${{secrets.HAPI_DFUSE_API_KEY}}
HAPI_DFUSE_API: eos.dfuse.eosnation.io
HAPI_DFUSE_API_KEY:
HAPI_DFUSE_API: jungle4.dfuse.eosnation.io
HAPI_DFUSE_FIRST_BLOCK: ${{secrets.HAPI_DFUSE_FIRST_BLOCK}}
# hasura
HASURA_GRAPHQL_ENABLE_CONSOLE: true
Expand All @@ -90,4 +96,4 @@ jobs:
NAMESPACE: eden-spending
K8S_BUILD_DIR: build_k8s
with:
args: version && make deploy-kubernetes
args: version && make deploy-kubernetes
12 changes: 9 additions & 3 deletions .github/workflows/push-prod-environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ jobs:
build-docker-images \
push-docker-images
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
IMAGE_NAME_WEBAPP: eden-spending-webapp
IMAGE_NAME_HAPI: eden-spending-hapi
IMAGE_NAME_HASURA: eden-spending-hasura
IMAGE_NAME_WALLET: eden-spending-wallet
# webapp
PORT: 80
REACT_APP_TAG: ${{ github.ref }}
Expand Down Expand Up @@ -55,6 +57,10 @@ jobs:
NAMESPACE: eden-spending
INGRESS_HOST: spending.eden.eoscommunity.org
INGRESS_GRAPHQL_HOST: graphql-spending.eden.eoscommunity.org
IMAGE_NAME_WEBAPP: eden-spending-webapp
IMAGE_NAME_HAPI: eden-spending-hapi
IMAGE_NAME_HASURA: eden-spending-hasura
IMAGE_NAME_WALLET: eden-spending-wallet
# Postgres
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
Expand Down Expand Up @@ -98,4 +104,4 @@ jobs:
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
prerelease: true
prerelease: false
20 changes: 0 additions & 20 deletions hapi/src/gql/income-frontend.gql.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,6 @@ const getTotalIncomeByDelegate = async (getMany = false) => {
return getMany ? getTotalIncomeByDelegate : getTotalIncomeByDelegate[0]
}

const getPercentAllElections = async (getMany = false) => {
const query = `
query getPercentAllElections {
percent_by_all_elections_incomes {
eos_claimed
eos_unclaimed
usd_claimed
usd_unclaimed
election
}
}
`

const { percent_by_all_elections_incomes: getPercentAllElections } =
await hasuraUtil.instance.request(query)

return getMany ? getPercentAllElections : getPercentAllElections[0]
}

const getIncomeByElections = async () => {
const query = `
query getIncomeByElections {
Expand All @@ -64,6 +45,5 @@ const getIncomeByElections = async () => {

module.exports = {
getTotalIncomeByDelegate,
getPercentAllElections,
getIncomeByElections
}
7 changes: 4 additions & 3 deletions hapi/src/services/dfuse/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const {
edenHistoricElectionGql,
edenDelegatesGql
} = require('../../gql')
const { edenConfig } = require('../../config')
const { edenConfig, dfuseConfig } = require('../../config')
const { hasuraUtil, sleepUtil, dfuseUtil } = require('../../utils')

const updaters = require('./updaters')
Expand Down Expand Up @@ -71,12 +71,13 @@ const getActions = async params => {
const { data } = await dfuseUtil.client.graphql(
dfuseUtil.getfundTransferQuery(params)
)
const transactionsList = data.searchTransactionsForward.results
const transactionsList = data?.searchTransactionsForward.results || []

return {
hasMore: transactionsList.length === 1000,
actions: transactionsList,
blockNumber: transactionsList.at(-1)?.trace.block.num
blockNumber:
transactionsList.at(-1)?.trace.block.num || dfuseConfig.firstBlock
}
}

Expand Down
4 changes: 3 additions & 1 deletion hapi/src/services/eden-delegates.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { edenDelegatesGql } = require('../gql')
const { edenElectionGql } = require('../gql')
const { edenHistoricElectionGql } = require('../gql')
const { servicesConstant } = require('../constants')
const { dfuseConfig } = require('../config')

const updateEdenTable = async () => {
await communityUtil.saveNewElection(edenHistoricElectionGql)
Expand All @@ -25,7 +26,8 @@ const updateEdenTable = async () => {
if (!(member[1].election_rank > 0)) continue

const memberData = {
account: member[1].account
account: member[1].account,
last_synced_at: dfuseConfig.firstBlock
}
let registeredMember = await edenDelegatesGql.get({
account: { _eq: memberData.account }
Expand Down
16 changes: 9 additions & 7 deletions hapi/src/services/eden-historic-delegates.service.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { edenConfig } = require('../config')
const { edenConfig, dfuseConfig } = require('../config')
const { servicesConstant } = require('../constants')
const { eosUtil, dfuseUtil, communityUtil, sleepUtil } = require('../utils')
const {
Expand All @@ -24,14 +24,13 @@ const getActions = async params => {
const { data } = await dfuseUtil.client.graphql(
dfuseUtil.getfundTransferQuery(params)
)
const transactionsList = data.searchTransactionsForward.results || []

return {
hasMore: data.searchTransactionsForward.results.length === 1000,
actions: data.searchTransactionsForward.results,
hasMore: transactionsList.length === 1000,
actions: transactionsList,
blockNumber:
data.searchTransactionsForward.results[
data.searchTransactionsForward.results.length - 1
].trace.block.num
transactionsList.at(-1)?.trace.block.num || dfuseConfig.firstBlock
}
}

Expand All @@ -44,7 +43,10 @@ const registerHistoricDelegate = async (date, account, rank) => {
})

if (!registeredMember)
registeredMember = await edenDelegatesGql.save({ account })
registeredMember = await edenDelegatesGql.save({
account,
last_synced_at: dfuseConfig.firstBlock
})

const electionData = {
id_delegate: registeredMember.id,
Expand Down
30 changes: 10 additions & 20 deletions hapi/src/services/income-frontend.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,22 @@ const newDataFormatByElectionsIncome = electionsList => {
),
USD_TOTAL: Number(
dataElections[pos].usd_total + dataElections[pos + 1]?.usd_total
)
),
EOS_CLAIMED_PERCENT:
(dataElections[pos].amount /
(dataElections[pos].usd_total + dataElections[pos + 1]?.usd_total)) *
100,
EOS_UNCLAIMED_PERCENT:
(dataElections[pos + 1]?.usd_total /
(dataElections[pos].usd_total + dataElections[pos + 1]?.usd_total)) *
100
}
elections.push(election)
}

return elections
}

const newDataFormatPercentAllElections = percentAllElectionData => {
const uppercaseCategory = 'claimed'.toUpperCase()

return percentAllElectionData.map(data => ({
name: `Election ${data.election + 1}`,
[`EOS_${uppercaseCategory}_PERCENT`]:
Number(data[`eos_${'claimed'}`]) * 100,
[`EOS_UN${uppercaseCategory}_PERCENT`]:
Number(data[`eos_un${'claimed'}`]) * 100
}))
}

const newDataFormatByDelegatesIncome = transactionsList =>
transactionsList.map(data => ({
name: data.recipient,
Expand All @@ -66,17 +62,11 @@ const getData = async () => {
const totalIncomeByDelegate = newDataFormatByDelegatesIncome(
await incomeFrontend.getTotalIncomeByDelegate(true)
)

const percentAllElections = newDataFormatPercentAllElections(
await incomeFrontend.getPercentAllElections(true)
)

const incomeByElection = newDataFormatByElectionsIncome(
await incomeFrontend.getIncomeByElections(true)
)

const dataFound = {
data: [totalIncomeByDelegate, percentAllElections, incomeByElection]
data: [totalIncomeByDelegate, incomeByElection]
}

return dataFound
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ select_permissions:
- delegate_payer
- election
- eos_categorized
- eos_uncategorized
- eos_claimed
- eos_unclaimed
- exchange_rate
- usd_categorized
- usd_uncategorized
filter: {}
allow_aggregations: true
3 changes: 0 additions & 3 deletions hasura/metadata/databases/default/tables/tables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
- "!include public_historic_incomes.yaml"
- "!include public_incomes_by_delegate.yaml"
- "!include public_percent_by_all_elections_expenses.yaml"
- "!include public_percent_by_all_elections_incomes.yaml"
- "!include public_percent_by_delegates_expenses.yaml"
- "!include public_percent_by_delegates_incomes.yaml"
- "!include public_total_by_category.yaml"
- "!include public_total_by_category_and_election.yaml"
- "!include public_total_by_election.yaml"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- DROP VIEW "public"."percent_by_all_elections_incomes";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP VIEW "public"."percent_by_all_elections_incomes";
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- DROP VIEW "public"."percent_by_delegates_incomes";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP VIEW "public"."percent_by_delegates_incomes";
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- DROP VIEW "public"."percent_by_delegates_expenses";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP VIEW "public"."percent_by_delegates_expenses";
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- DROP VIEW "public"."historic_expenses";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP VIEW "public"."historic_expenses";
22 changes: 22 additions & 0 deletions hasura/migrations/default/1671577947390_run_sql_migration/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- CREATE OR REPLACE VIEW "public"."historic_expenses" AS
-- SELECT historic_expenses.delegate_payer,
-- historic_expenses.election,
-- COALESCE(( SELECT sum(transaction_by_category_and_election.amount) AS sum
-- FROM transaction_by_category_and_election
-- WHERE (((transaction_by_category_and_election.category)::text = 'claimed'::text) AND ((transaction_by_category_and_election.delegate_payer)::text = (historic_expenses.delegate_payer)::text) AND ((transaction_by_category_and_election.type)::text = 'income'::text) AND (transaction_by_category_and_election.election = historic_expenses.election))), (0)::numeric) AS eos_claimed,
-- COALESCE(( SELECT sum(transaction_by_category_and_election.amount) AS sum
-- FROM transaction_by_category_and_election
-- WHERE (((transaction_by_category_and_election.category)::text = 'unclaimed'::text) AND ((transaction_by_category_and_election.delegate_payer)::text = (historic_expenses.delegate_payer)::text) AND ((transaction_by_category_and_election.type)::text = 'income'::text) AND (transaction_by_category_and_election.election = historic_expenses.election))), (0)::numeric) AS eos_unclaimed,
-- COALESCE(( SELECT sum(transaction_by_category_and_election.amount) AS sum
-- FROM transaction_by_category_and_election
-- WHERE (((transaction_by_category_and_election.category)::text != 'uncategorized'::text) AND ((transaction_by_category_and_election.delegate_payer)::text = (historic_expenses.delegate_payer)::text) AND ((transaction_by_category_and_election.type)::text = 'expense'::text) AND (transaction_by_category_and_election.election = historic_expenses.election))), (0)::numeric) AS eos_categorized,
-- COALESCE(( SELECT sum(transaction_by_category_and_election.usd_total) AS sum
-- FROM transaction_by_category_and_election
-- WHERE (((transaction_by_category_and_election.category)::text != 'uncategorized'::text) AND ((transaction_by_category_and_election.delegate_payer)::text = (historic_expenses.delegate_payer)::text) AND ((transaction_by_category_and_election.type)::text = 'expense'::text) AND (transaction_by_category_and_election.election = historic_expenses.election))), (0)::numeric) AS usd_categorized,
-- avg(historic_expenses.exchange_rate) AS exchange_rate
-- FROM transaction_by_category_and_election historic_expenses
-- WHERE ((historic_expenses.type)::text = 'expense'::text)
-- GROUP BY historic_expenses.delegate_payer, historic_expenses.election, historic_expenses.type
-- ORDER BY historic_expenses.election;
20 changes: 20 additions & 0 deletions hasura/migrations/default/1671577947390_run_sql_migration/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
CREATE OR REPLACE VIEW "public"."historic_expenses" AS
SELECT historic_expenses.delegate_payer,
historic_expenses.election,
COALESCE(( SELECT sum(transaction_by_category_and_election.amount) AS sum
FROM transaction_by_category_and_election
WHERE (((transaction_by_category_and_election.category)::text = 'claimed'::text) AND ((transaction_by_category_and_election.delegate_payer)::text = (historic_expenses.delegate_payer)::text) AND ((transaction_by_category_and_election.type)::text = 'income'::text) AND (transaction_by_category_and_election.election = historic_expenses.election))), (0)::numeric) AS eos_claimed,
COALESCE(( SELECT sum(transaction_by_category_and_election.amount) AS sum
FROM transaction_by_category_and_election
WHERE (((transaction_by_category_and_election.category)::text = 'unclaimed'::text) AND ((transaction_by_category_and_election.delegate_payer)::text = (historic_expenses.delegate_payer)::text) AND ((transaction_by_category_and_election.type)::text = 'income'::text) AND (transaction_by_category_and_election.election = historic_expenses.election))), (0)::numeric) AS eos_unclaimed,
COALESCE(( SELECT sum(transaction_by_category_and_election.amount) AS sum
FROM transaction_by_category_and_election
WHERE (((transaction_by_category_and_election.category)::text != 'uncategorized'::text) AND ((transaction_by_category_and_election.delegate_payer)::text = (historic_expenses.delegate_payer)::text) AND ((transaction_by_category_and_election.type)::text = 'expense'::text) AND (transaction_by_category_and_election.election = historic_expenses.election))), (0)::numeric) AS eos_categorized,
COALESCE(( SELECT sum(transaction_by_category_and_election.usd_total) AS sum
FROM transaction_by_category_and_election
WHERE (((transaction_by_category_and_election.category)::text != 'uncategorized'::text) AND ((transaction_by_category_and_election.delegate_payer)::text = (historic_expenses.delegate_payer)::text) AND ((transaction_by_category_and_election.type)::text = 'expense'::text) AND (transaction_by_category_and_election.election = historic_expenses.election))), (0)::numeric) AS usd_categorized,
avg(historic_expenses.exchange_rate) AS exchange_rate
FROM transaction_by_category_and_election historic_expenses
WHERE ((historic_expenses.type)::text = 'expense'::text)
GROUP BY historic_expenses.delegate_payer, historic_expenses.election, historic_expenses.type
ORDER BY historic_expenses.election;
4 changes: 2 additions & 2 deletions kubernetes/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ spec:
name: webapp
port: 80
tls:
secretName: tls-secret
certResolver: myresolver
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
Expand Down Expand Up @@ -60,4 +60,4 @@ spec:
name: hasura
port: 8080
tls:
secretName: tls-secret
certResolver: myresolver
Loading

0 comments on commit 39496dd

Please sign in to comment.