Skip to content

Commit

Permalink
Merge pull request #194 from sesame-seed/master
Browse files Browse the repository at this point in the history
Sesameseed address API
  • Loading branch information
MickWang authored Aug 23, 2019
2 parents bd914d6 + 9918639 commit eca12d3
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/renderer/store/modules/NodeAuthorizationSesameseed.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@ const mutations = {
const actions = {
async fetchSSPerInfo({ commit }, address) {
try {
const baseUrl = 'https://dappnode1.ont.io:10334/api/v1/storage/a63c33d2209854feafbf40685a33d4846ee82556/'
const baseUrl = 'https://api.sesameseed.org/voting/v1/address/'

const hexAddress = utils.str2hexstr(address)
const pendingHexAddress = utils.str2hexstr('1' + address)

const pendingWithdrawalsPromise = axios.get(baseUrl + pendingHexAddress)
const votesPromise = axios.get(baseUrl + hexAddress)
const pendingWithdrawalsPromise = axios.get(baseUrl + 'unstaked/' + address)
const votesPromise = axios.get(baseUrl + 'staked/' + address)

const [pendingWithdrawalsResponse, votesResponse] = await Promise.all([pendingWithdrawalsPromise, votesPromise])

Expand All @@ -35,16 +32,12 @@ const actions = {

if (pendingWithdrawalsResponse.status === 200 && pendingWithdrawalsResponse.data) {
const resultPending = pendingWithdrawalsResponse.data
const pendingWithdrawalsHex = resultPending.Result ? resultPending.Result : 0
const reversedHex = pendingWithdrawalsHex.toString().length > 2 ? utils.reverseHex(pendingWithdrawalsHex) : pendingWithdrawalsHex
pendingWithdrawals = parseInt(reversedHex, 16)
pendingWithdrawals = resultPending.value ? resultPending.value : 0
}

if (votesResponse.status === 200 && votesResponse.data) {
const resultVotes = votesResponse.data
const votesHex = resultVotes.Result ? resultVotes.Result : 0
const reversedHex = votesHex.toString().length > 2 ? utils.reverseHex(votesHex) : votesHex
votes = parseInt(reversedHex, 16)
votes = resultVotes.value ? resultVotes.value : 0
}

commit('UPDATE_CURRENT_SS_PEER', { votes, pendingWithdrawals })
Expand Down

0 comments on commit eca12d3

Please sign in to comment.