-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
243 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.DS_Store | ||
|
||
# ignore everything in the root except the "wp-content" directory. | ||
!wp-content/ | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* hep.css */ | ||
|
||
div.hep_widget_container { | ||
text-align: center; | ||
box-sizing: border-box; | ||
-moz-box-sizing: border-box; | ||
-webkit-box-sizing: border-box; | ||
border: 1px solid #969696; | ||
/*background-color: #EBEBEB;*/ | ||
} | ||
|
||
div.hep_widget_container h4 { | ||
margin: 0px; | ||
} | ||
|
||
div.hep_widget_container h5 { | ||
margin-top: 20px; | ||
margin-bottom: 20px; | ||
} | ||
|
||
div.hep_widget_container h6 { | ||
margin: 0px; | ||
} | ||
|
||
div.hep_widget_header { | ||
/*background-color: #277da1ff;*/ | ||
} | ||
|
||
div.hep_widget_content { | ||
/*background-color: #EBEBEB;*/ | ||
|
||
padding-left: 10px; | ||
padding-right: 10px; | ||
} | ||
|
||
div.hep_widget_exchanges { | ||
display:inline-block; | ||
width: 100%; | ||
border-top: 1px solid #969696; | ||
min-width: 127px; | ||
/*background-color: #EBEBEB;*/ | ||
} | ||
|
||
div.hep_widget_exchanges > a { | ||
padding: 10px; | ||
margin-left: auto; | ||
margin-right: auto; | ||
display: inline-block; | ||
} |
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,66 @@ | ||
// hive-engine-price.js | ||
|
||
const rpc = 'https://api.hive-engine.com/rpc/contracts'; | ||
|
||
function getSellBook(token) { | ||
return new Promise((resolve, reject) => { | ||
const query = {'id': 1, | ||
jsonrpc: '2.0', | ||
method: 'find', | ||
params: { | ||
contract: 'market', | ||
table: 'sellBook', | ||
query: { | ||
symbol: token | ||
} | ||
}} | ||
let nextBlock = false | ||
axios.post(rpc, query).then((result) => { | ||
return resolve(result.data.result) | ||
}).catch((err) => { | ||
console.log(err) | ||
return reject(err) | ||
}) | ||
}) | ||
} | ||
|
||
function getHivePrice() { | ||
return new Promise((resolve, reject) => { | ||
const coingecko_api = 'https://api.coingecko.com/api/v3/simple/price?ids=hive&vs_currencies=USD' | ||
axios.get(coingecko_api).then((result) => { | ||
return resolve(result.data.hive.usd) | ||
}).catch((err) => { | ||
console.log(err) | ||
return reject(err) | ||
}) | ||
}) | ||
} | ||
|
||
function getTokenPrice(token, content_div_id) { | ||
var hivePrice = getHivePrice() | ||
var sellBook = getSellBook(token) | ||
|
||
Promise.all([hivePrice,sellBook]).then((result) => { | ||
let hivePrice = result[0] | ||
|
||
let sellBook = result[1] | ||
sellBook = sellBook.sort( (a,b) => Number(a.price) - Number(b.price) ) | ||
|
||
var targetDiv = document.querySelector('div#' + content_div_id) | ||
|
||
let sellOrder = sellBook[0] | ||
|
||
let quantity = sellOrder.quantity | ||
let symbol = sellOrder.symbol | ||
let price = sellOrder.price | ||
targetDiv.innerHTML = (`${Number(price).toFixed(3)} HIVE <br> ${(price * hivePrice).toFixed(3)} USD`) | ||
}) | ||
} | ||
|
||
Array.from(document.querySelectorAll('div.hep_widget_content')).forEach( (div) => { | ||
let token_name = div.getAttribute('data-token-name') | ||
let div_id = div.getAttribute('id') | ||
getTokenPrice(token_name.toUpperCase(), div_id) | ||
}) | ||
|
||
|
Oops, something went wrong.