Skip to content

Commit

Permalink
Merge pull request ava-labs#133 from ava-labs/bug/explorer_api
Browse files Browse the repository at this point in the history
Bug/explorer api
  • Loading branch information
kanatliemre authored Jan 11, 2021
2 parents d15c540 + e2a8a56 commit 2b7fd17
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 33 deletions.
17 changes: 3 additions & 14 deletions src/components/misc/Spinner.vue
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
<template>
<div class="spinner">
<p
class="spinner"
:style="{
color: color,
}"
>
<p class="spinner">
<fa icon="spinner"></fa>
</p>
</div>
</template>
<script>
export default {
props: {
color: {
type: String,
default: '#fff',
},
},
}
export default {}
</script>
<style scoped lang="scss">
.spinner {
Expand All @@ -32,6 +20,7 @@ export default {
transform-origin: center;
display: flex;
justify-content: center;
color: var(--primary-color);
align-items: center;
}
@keyframes spin {
Expand Down
4 changes: 4 additions & 0 deletions src/components/wallet/advanced/SignMessage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ select {
}
}
option {
background-color: var(--bg-wallet);
}
label {
display: block;
text-align: left;
Expand Down
2 changes: 1 addition & 1 deletion src/components/wallet/earn/Delegate/AddDelegator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
<p v-else>{{ txStatus }}</p>
</div>
<div class="status_icon">
<Spinner v-if="!txStatus" style="color: var(--primary-color)"></Spinner>
<Spinner v-if="!txStatus"></Spinner>
<p style="color: var(--success)" v-if="txStatus === 'Committed'">
<fa icon="check-circle"></fa>
</p>
Expand Down
37 changes: 20 additions & 17 deletions src/explorer_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,22 @@ async function getAddressHistory(
limit = 20,
chainID: string
): Promise<ITransactionData[]> {
let selection = addrs.slice(0, 512)
let remaining = addrs.slice(512)
const ADDR_SIZE = 1024
let selection = addrs.slice(0, ADDR_SIZE)
let remaining = addrs.slice(ADDR_SIZE)

let query = selection.map((val) => {
let raw = val.split('-')[1]
return `address=${raw}`
let addrsRaw = selection.map((addr) => {
return addr.split('-')[1]
})

// Get history for all addresses of the active HD wallet
let url = `v2/transactions?${query.join(
'&'
)}&limit=${limit}&sort=timestamp-desc&disableCount=1&chainID=${chainID}`

let res = await explorer_api.get(url)
let rootUrl = 'v2/transactions'
let res = await explorer_api.post(rootUrl, {
address: addrsRaw,
limit: [limit.toString()],
sort: ['timestamp-desc'],
disableCount: ['1'],
chainID: [chainID],
})
let txs = res.data.transactions

if (txs === null) txs = []
Expand Down Expand Up @@ -69,15 +71,16 @@ async function getAddressDetailX(addr: string) {

async function getAddressChains(addrs: string[]) {
// Strip the prefix
let cleanAddrs = addrs.map((addr) => {
let clean = 'address=' + addr.split('-')[1]
return clean
let rawAddrs = addrs.map((addr) => {
return addr.split('-')[1]
})

let joined = cleanAddrs.join('&')
let url = `/v2/addressChains?${joined}&disableCount=1`
let urlRoot = `/v2/addressChains`

let res = await explorer_api.get(url)
let res = await explorer_api.post(urlRoot, {
address: rawAddrs,
disableCount: ['1'],
})

return res.data.addressChains
}
Expand Down
2 changes: 1 addition & 1 deletion src/js/HdHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ class HdHelper {
// Scans the address space of this hd path and finds the last used index using the
// explorer API.
async findAvailableIndexExplorer(startIndex = 0): Promise<number> {
let upTo = 300
let upTo = 512

let addrs = this.getAllDerivedAddresses(startIndex + upTo, startIndex)
let addrChains = await getAddressChains(addrs)
Expand Down

0 comments on commit 2b7fd17

Please sign in to comment.