Skip to content

Commit

Permalink
show current hashpower
Browse files Browse the repository at this point in the history
  • Loading branch information
admazzola committed May 14, 2022
1 parent d508dd4 commit cce8c22
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 15 deletions.
64 changes: 56 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"dependencies": {
"@fortawesome/fontawesome-free": "^5.14.0",
"@maticnetwork/maticjs": "2.0.6-beta.0",
"axios": "^0.27.2",
"core-js": "^2.6.5",
"gh-pages": "^3.1.0",
"gray-matter": "^4.0.2",
Expand Down
29 changes: 29 additions & 0 deletions src/js/rest-api-helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@


//import axios from "axios";
const axios = require('axios')

const envmode = process.env.NODE_ENV


export async function resolveRestQuery(uri, inputData){

return new Promise( (resolve, reject) => {

axios.post(uri, inputData )
.then((res) => {

console.log('res.data',res.data)
let results = res.data


resolve(results)

}) .catch((error) => {
console.error('rest error', error)
reject(error)
})

});

}
38 changes: 36 additions & 2 deletions src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
<div class="text-block-11 mt-20 lg:mt-0">Pure Mined ● Native ERC20</div>
</div>
<div class="w-col w-col-6">
<div v-if="latestBlockData" class="border-2 border-black m-8 p-4 inline" style="background: #666d">

Current Hashpower ⛏️: {{getCurrentHashrate()}} TH/s

</div>

</div>
</div>
<div class="div-block">
Expand Down Expand Up @@ -174,17 +180,45 @@ import Navbar from './components/Navbar.vue';
import Carousel from './components/Carousel.vue';
import Footer from './components/Footer.vue';
import {resolveRestQuery} from '../js/rest-api-helper'
export default {
name: 'Home',
props: [],
components: {Navbar,Carousel,Footer},
data() {
return {
latestBlockData: null
}
},
created(){
this.fetchLatestBlockData()
setInterval( this.fetchLatestBlockData().bind(this) , 60 * 1000 )
},
methods: {
async fetchLatestBlockData(){
let baseURI = 'https://api.0xbtc.io/api/v1/'
let result = await resolveRestQuery(`${baseURI}`,{requestType: "ERC20_mints",input:{contractAddress:"0xb6ed7644c69416d67b522e20bc294a9a9b405b31"}})
if(result && result.success){
this.latestBlockData = result.output[0]
}
},
getCurrentHashrate(){
let rawHashrate = this.latestBlockData.hashrate_avg8mint
return ( rawHashrate / 1000000000000 ).toFixed(2)
}
},
}
}
</script>
28 changes: 23 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1889,6 +1889,14 @@
"resolved" "https://registry.npmjs.org/aws4/-/aws4-1.10.1.tgz"
"version" "1.10.1"

"axios@^0.27.2":
"integrity" "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ=="
"resolved" "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz"
"version" "0.27.2"
dependencies:
"follow-redirects" "^1.14.9"
"form-data" "^4.0.0"

"babel-code-frame@^6.22.0", "babel-code-frame@^6.26.0":
"integrity" "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s="
"resolved" "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz"
Expand Down Expand Up @@ -2861,7 +2869,7 @@
"resolved" "https://registry.npmjs.org/colorette/-/colorette-1.2.1.tgz"
"version" "1.2.1"

"combined-stream@^1.0.6", "combined-stream@~1.0.6":
"combined-stream@^1.0.6", "combined-stream@^1.0.8", "combined-stream@~1.0.6":
"integrity" "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg=="
"resolved" "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz"
"version" "1.0.8"
Expand Down Expand Up @@ -5058,10 +5066,10 @@
"inherits" "^2.0.3"
"readable-stream" "^2.3.6"

"follow-redirects@^1.0.0":
"integrity" "sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA=="
"resolved" "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.0.tgz"
"version" "1.13.0"
"follow-redirects@^1.0.0", "follow-redirects@^1.14.9":
"integrity" "sha512-aExlJShTV4qOUOL7yF1U5tvLCB0xQuudbf6toyYA0E/acBNw71mvjFTnLaRp50aQaYocMR0a/RMMBIHeZnGyjQ=="
"resolved" "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.0.tgz"
"version" "1.15.0"

"for-in@^1.0.2":
"integrity" "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA="
Expand All @@ -5073,6 +5081,15 @@
"resolved" "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz"
"version" "0.6.1"

"form-data@^4.0.0":
"integrity" "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww=="
"resolved" "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz"
"version" "4.0.0"
dependencies:
"asynckit" "^0.4.0"
"combined-stream" "^1.0.8"
"mime-types" "^2.1.12"

"form-data@~2.3.2":
"integrity" "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ=="
"resolved" "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz"
Expand Down Expand Up @@ -11289,6 +11306,7 @@
"yaeti" "^0.0.6"

"websocket@github:web3-js/WebSocket-Node#polyfill/globalThis":
"integrity" "sha512-fS64f2anyRmFjuEVoqTbtgtV4Ay1dQ6kP078yM1RxnF0+9hNYk4iirrtII6FIoNoNgmhhIqzQaadEU6ZRpGoEw=="
"resolved" "git+ssh://[email protected]/web3-js/WebSocket-Node.git#ef5ea2f41daf4a2113b80c9223df884b4d56c400"
"version" "1.0.29"
dependencies:
Expand Down

0 comments on commit cce8c22

Please sign in to comment.