Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #550 from hermeznetwork/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
AlbertoElias authored Jun 18, 2021
2 parents d38346e + 97e49fa commit 658ec0a
Show file tree
Hide file tree
Showing 62 changed files with 11,922 additions and 8,637 deletions.
11 changes: 9 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
# Can be production or development
REACT_APP_ENV=development
# Needs to be always false
REACT_APP_ENABLE_HARDWARE_WALLETS=false
# If a value is present, the rewards feature is going to be enabled
REACT_APP_ENABLE_AIRDROP=true
REACT_APP_AIRDROP_API_URL=http://63.32.111.74:8092
REACT_APP_AIRDROP_ID=8
REACT_APP_ACCUMULATED_AIRDROP_IDS="1,2,3"
# Exchange rates API Key
REACT_APP_EXCHANGE_RATES_API_KEY=example
# Infura API Key
REACT_APP_INFURA_API_KEY=example
# Can be production or development
REACT_APP_ENV=development
# Env vars below should only be used when REACT_APP_ENV=development
REACT_APP_HERMEZ_API_URL=http://localhost:8086
REACT_APP_HERMEZ_CONTRACT_ADDRESS=0x10465b16615ae36F350268eb951d7B0187141D3B
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/internal-testnet-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
echo 'REACT_APP_ENV=development' >> .env
echo 'REACT_APP_ENABLE_HARDWARE_WALLETS=false' >> .env
echo 'REACT_APP_EXCHANGE_RATES_API_KEY=${{ secrets.INTERNAL_TESTNET_EXCHANGE_RATES_API_KEY }}' >> .env
echo 'REACT_APP_INFURA_API_KEY=${{ secrets.INFURA_API_KEY }}'
echo 'REACT_APP_HERMEZ_API_URL=${{ secrets.INTERNAL_TESTNET_HERMEZ_API_URL }}' >> .env
echo 'REACT_APP_HERMEZ_CONTRACT_ADDRESS=${{ secrets.INTERNAL_TESTNET_HERMEZ_CONTRACT_ADDRESS }}' >> .env
echo 'REACT_APP_WITHDRAWAL_DELAYER_CONTRACT_ADDRESS=${{ secrets.INTERNAL_TESTNET_WITHDRAWAL_DELAYER_CONTRACT_ADDRESS }}' >> .env
Expand Down
18,398 changes: 10,075 additions & 8,323 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wallet-ui",
"version": "1.0.9",
"version": "v1.1.0-rc.8",
"private": true,
"scripts": {
"start:dev": "react-scripts start",
Expand All @@ -12,12 +12,13 @@
"lint:fix": "standard --fix"
},
"dependencies": {
"@hermeznetwork/hermezjs": "^1.1.1",
"@hermeznetwork/hermezjs": "1.1.5",
"@walletconnect/web3-provider": "^1.4.1",
"axios": "^0.21.1",
"big-integer": "^1.6.48",
"clsx": "^1.1.1",
"connected-react-router": "^6.8.0",
"ethers": "5.0.24",
"ethers": "^5.1.4",
"js-sha3": "^0.8.0",
"normalize.css": "^8.0.1",
"qrcode.react": "^1.0.0",
Expand Down
21 changes: 20 additions & 1 deletion src/apis/fiat-exchange-rates.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,30 @@ const baseApiUrl = FIAT_EXCHANGE_RATES_API_URL
* @param {string[]} symbols - ISO 4217 currency codes
* @returns {Object} - USD exchange rates for the requested symbols
*/
// eslint-disable-next-line no-unused-vars
function getFiatExchangeRates (symbols) {
const params = { base: CurrencySymbol.USD.code, symbols: symbols.join(','), access_key: process.env.REACT_APP_EXCHANGE_RATES_API_KEY }

return axios.get(`${baseApiUrl}/latest`, { params })
.then(res => res.data)
}

export { getFiatExchangeRates }
/**
* Mocks the USD exchange rates for the requested currency symbols
* @param {string[]} symbols - ISO 4217 currency codes
* @returns {Object} - USD exchange rates for the requested symbols
*/
function getMockedFiatExchangeRates () {
return Promise.resolve({
success: true,
base: 'USD',
rates: {
EUR: 0.837775,
CNY: 6.446304,
JPY: 110.253954,
GBP: 0.716945
}
})
}

export { getMockedFiatExchangeRates as getFiatExchangeRates }
2 changes: 1 addition & 1 deletion src/apis/hermez-web.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const baseApiUrl = HERMEZ_WEB_URL

/**
* Fetches the status of the Hermez network
* @returns {number} - Network status of the Hermez Network
* @returns {Number} - Network status of the Hermez Network
*/
function getNetworkStatus (symbols) {
return axios.get(`${baseApiUrl}/network-status.json`)
Expand Down
73 changes: 73 additions & 0 deletions src/apis/rewards.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import axios from 'axios'

const baseApiUrl = `${process.env.REACT_APP_AIRDROP_API_URL}/airdrop/v1`
const airdropId = process.env.REACT_APP_AIRDROP_ID
const accumulatedAirdropIds = process.env.REACT_APP_ACCUMULATED_AIRDROP_IDS || ''

/**
* Fetches Airdrop data
* @param {String} ethAddr - Ethereum address
* @returns {Object} - airdrop
*/
function getReward (ethAddr) {
return axios.get(`${baseApiUrl}/airdrops/${airdropId}`)
.then(res => res.data.airdrop)
}

/**
* Fetches Airdrop earned reward
* @param {String} ethAddr - Ethereum address
* @returns {String} - earnedReward
*/
function getEarnedReward (ethAddr) {
const params = { airdropID: airdropId, ethAddr }

return axios.get(`${baseApiUrl}/earned-reward`, { params })
.then(res => res.data.earnedReward)
}

/**
* Fetches earned reward for multiple Airdrops
* @param {String} ethAddr - Ethereum address
* @returns {String} - accumulatedEarnedReward
*/
function getAccumulatedEarnedReward (ethAddr) {
const params = new URLSearchParams()

params.append('ethAddr', ethAddr)
accumulatedAirdropIds.split(',').forEach(airdropId => params.append('airdropID', airdropId))

return axios.get(`${baseApiUrl}/accumulated-earned-reward`, { params })
.then(res => res.data.earnedReward)
}

/**
* Fetches Airdrop reward percentage
* @returns {String} - rewardPercentage
*/
function getRewardPercentage () {
const params = { airdropID: airdropId }

return axios.get(`${baseApiUrl}/reward-percentage`, { params })
.then(res => res.data.percentage)
}

/**
* Checks if an Ethereum address is eligible for the reward
* @param {String} ethAddr - Ethereum address
* @returns {Boolean} - isUserEligible
*/
function getAccountEligibility (ethAddr) {
const params = { ethAddr, airdropID: airdropId }

return axios.get(`${baseApiUrl}/check-user-eligibility`, { params })
.then(res => res.data.isUserEligible)
}

export {
getReward,
getEarnedReward,
getAccumulatedEarnedReward,
getRewardPercentage,
getAccountEligibility
}
6 changes: 6 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,9 @@ export const HERMEZ_HELP_CENTER_URL = 'https://docs.hermez.io/#/faq/end-users'
export const HERMEZ_WEB_URL = 'https://hermez.io'

export const DEPOSIT_TX_TIMEOUT = 86400000 // 24h

export const AIRDROP_MORE_INFO_URL = 'https://blog.hermez.io/hermez-community-rewards'

export const HEZ_TOKEN_ID = 1

export const METAMASK_UPDATE_HELP_LINK = 'https://twitter.com/hermez_network/status/1405812176053538817'
62 changes: 62 additions & 0 deletions src/images/heztoken-mobile.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 658ec0a

Please sign in to comment.