Skip to content

Commit

Permalink
Merge pull request #15 from jplomas/master
Browse files Browse the repository at this point in the history
Add /util/mainnet/unconfirmedTxCount GET route & tidying
  • Loading branch information
jplomas authored Dec 28, 2020
2 parents f1c0bc0 + 7dad54f commit 0d385c1
Show file tree
Hide file tree
Showing 8 changed files with 1,327 additions and 156 deletions.
16 changes: 16 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"root": true,
"env": {
"browser": true,
"es6": true,
"commonjs": true,
"jquery": true
},
"plugins": ["prettier"],
"extends": ["prettier"],
"rules": {
"prettier/prettier": "error"
},
"parser": "babel-eslint",
"ignorePatterns": [".prettierrc"]
}
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"tabWidth": 2,
"useTabs": false,
"trailingComma": "es5",
"semi": false,
"singleQuote": true
}
26 changes: 26 additions & 0 deletions client/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ <h3 class="title is-3 mb-1">POST</h3>
<div class="level-item">
<code>/grpc/${network}/GetAddressState</code>
</div>
<div class="level-right">
<small>Depreciated - not recommended for use</small>
</div>
</div>
</div>
<textarea id="GetAddressState" class="textarea" placeholder="{ address: String }">{ "address": "Q0103003a218992254da652d64e3617f5ed2cf6417bf464e2a02d0a214e0050657f46f9f6796f73" }</textarea>
Expand Down Expand Up @@ -165,6 +168,29 @@ <h3 class="title is-3 mb-1">POST</h3>
</div>
<p><strong>Sends:</strong> String Query (block id, txhash or QRL address)</p>
<p><strong>Returns:</strong> Located data</p>
<p>&nbsp;</p><p>&nbsp;</p>
<div class="level">
<div class="level-left"><div class="level-item"><p class="title is-5">GetTokensByAddress</p></div>
<div class="level-item">
<code>/grpc/${network}/GetTokensByAddress</code>
</div>
</div>
</div>
<textarea id="GetTokensByAddress" class="textarea" placeholder="{ address: String, item_per_page: Integer, page_number: Integer }">{ "address": "Q010900411c50a98e65d289b51d9d4dc0f61833c26f2c6c4f3ce4df8e9968d1fcae6f6341392bea", "item_per_page": 100, "page_number": 1 }</textarea>
<div class="level is-mobile">
<div class="level-left">
<div class="level-item">
<button id="GetTokensByAddress-Testnet" class="button is-small is-primary is-light level-item">
Testnet
</button>
<button id="GetTokensByAddress-Mainnet" class="button is-small is-primary is-light level-item">
Mainnet
</button>
</div>
</div>
</div>
<p><strong>Sends:</strong> String QRL address, Integer items per page to return, Integer page number</p>
<p><strong>Returns:</strong> Token holdings information</p>
<p>&nbsp;</p><p>&nbsp;</p>
</div>
</template>
66 changes: 41 additions & 25 deletions client/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
global.Buffer = global.Buffer || require("buffer").Buffer
global.Buffer = global.Buffer || require('buffer').Buffer
import JSONFormatter from 'json-formatter-js'
import './main.html'

Expand All @@ -9,7 +9,7 @@ async function getData(url = '') {
cache: 'no-cache',
credentials: 'same-origin',
headers: {
'Content-Type': 'application/json'
'Content-Type': 'application/json',
},
redirect: 'follow',
referrerPolicy: 'no-referrer',
Expand All @@ -24,11 +24,11 @@ async function postData(url = '', data = {}) {
cache: 'no-cache',
credentials: 'same-origin',
headers: {
'Content-Type': 'application/json'
'Content-Type': 'application/json',
},
redirect: 'follow',
referrerPolicy: 'no-referrer',
body: JSON.stringify(data)
body: JSON.stringify(data),
})
return response.json()
}
Expand All @@ -43,51 +43,67 @@ function displayData(data) {

Template.get.events({
'click #GetStats-get-Testnet': () => {
getData('/grpc/testnet/GetStats')
.then(data => displayData(data))
getData('/grpc/testnet/GetStats').then((data) => displayData(data))
},
'click #GetStats-get-Mainnet': () => {
getData('/grpc/mainnet/GetStats')
.then(data => displayData(data))
getData('/grpc/mainnet/GetStats').then((data) => displayData(data))
},
})

Template.post.events({
'click #GetStats-Testnet': () => {
postData('/grpc/testnet/GetStats',
postData(
'/grpc/testnet/GetStats',
JSON.parse($('#GetStats').val())
)
.then(data => displayData(data))
).then((data) => displayData(data))
},
'click #GetStats-Mainnet': () => {
postData('/grpc/mainnet/GetStats',
postData(
'/grpc/mainnet/GetStats',
JSON.parse($('#GetStats').val())
)
.then(data => displayData(data))
).then((data) => displayData(data))
},
'click #GetAddressState-Testnet': () => {
postData('/grpc/testnet/GetAddressState',
postData(
'/grpc/testnet/GetAddressState',
JSON.parse($('#GetAddressState').val())
)
.then(data => displayData(data))
).then((data) => displayData(data))
},
'click #GetOptimizedAddressState-Testnet': () => {
postData('/grpc/testnet/GetOptimizedAddressState',
postData(
'/grpc/testnet/GetOptimizedAddressState',
JSON.parse($('#GetOptimizedAddressState').val())
)
.then(data => displayData(data))
).then((data) => displayData(data))
},
'click #GetObject-Testnet': () => {
postData('/grpc/testnet/GetObject',
postData(
'/grpc/testnet/GetObject',
JSON.parse($('#GetObject').val())
)
.then(data => displayData(data))
).then((data) => displayData(data))
},
'click #GetObject-Mainnet': () => {
postData(
'/grpc/mainnet/GetObject',
JSON.parse($('#GetObject').val())
).then((data) => displayData(data))
},
'click #GetTokensByAddress-Testnet': () => {
postData(
'/grpc/testnet/GetTokensByAddress',
JSON.parse($('#GetTokensByAddress').val())
).then((data) => displayData(data))
},
'click #GetTokensByAddress-Mainnet': () => {
postData(
'/grpc/mainnets/GetTokensByAddress',
JSON.parse($('#GetTokensByAddress').val())
).then((data) => displayData(data))
},
})

Template.modal.events({
'click .mc': () => {
$('.modal').removeClass('is-active')
$('html').removeClass('is-clipped')
}
})
},
})
Loading

0 comments on commit 0d385c1

Please sign in to comment.