This repository has been archived by the owner on Nov 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #550 from hermeznetwork/develop
Develop
- Loading branch information
Showing
62 changed files
with
11,922 additions
and
8,637 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.