Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Scan: handle rate limit message on PriceHook #2666

Merged
merged 3 commits into from
Sep 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG_UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

### Scan

- (bugs) [\#2666](https://github.com/bandprotocol/bandchain/pull/2666) Handle rate limit msg when decoding
- (impv) [\#2644](https://github.com/bandprotocol/bandchain/pull/2644) Added `netlify.toml` configuration
- (feat) [\#2594](https://github.com/bandprotocol/bandchain/pull/2594) Added meta og tag to scan

Expand Down
35 changes: 21 additions & 14 deletions scan/src/rpc/PriceHook.re
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,26 @@ module CrytoCompare = {
// TODO: Find the formular to calulate this
let circulatingSupply = 20494032.;
let decode = (usdJson, btcJson) =>
JsonUtils.Decode.{
usdPrice: usdJson |> at(["RAW", "BAND", "USD", "PRICE"], JsonUtils.Decode.float),
usdMarketCap:
(usdJson |> at(["RAW", "BAND", "USD", "PRICE"], JsonUtils.Decode.float))
*. circulatingSupply,
usd24HrChange:
usdJson |> at(["RAW", "BAND", "USD", "CHANGEPCT24HOUR"], JsonUtils.Decode.float),
btcPrice: btcJson |> at(["RAW", "BAND", "BTC", "PRICE"], JsonUtils.Decode.float),
btcMarketCap:
(btcJson |> at(["RAW", "BAND", "BTC", "PRICE"], JsonUtils.Decode.float))
*. circulatingSupply,
btc24HrChange:
btcJson |> at(["RAW", "BAND", "BTC", "CHANGEPCT24HOUR"], JsonUtils.Decode.float),
switch (
JsonUtils.Decode.{
usdPrice: usdJson |> at(["RAW", "BAND", "USD", "PRICE"], JsonUtils.Decode.float),
usdMarketCap:
(usdJson |> at(["RAW", "BAND", "USD", "PRICE"], JsonUtils.Decode.float))
*. circulatingSupply,
usd24HrChange:
usdJson |> at(["RAW", "BAND", "USD", "CHANGEPCT24HOUR"], JsonUtils.Decode.float),
btcPrice: btcJson |> at(["RAW", "BAND", "BTC", "PRICE"], JsonUtils.Decode.float),
btcMarketCap:
(btcJson |> at(["RAW", "BAND", "BTC", "PRICE"], JsonUtils.Decode.float))
*. circulatingSupply,
btc24HrChange:
btcJson |> at(["RAW", "BAND", "BTC", "CHANGEPCT24HOUR"], JsonUtils.Decode.float),
}
) {
| result => Some(result)
| exception _ => None
};

let usdJsonUrl = "https://min-api.cryptocompare.com/data/pricemultifull?fsyms=BAND&tsyms=USD";
let btcJsonUrl = "https://min-api.cryptocompare.com/data/pricemultifull?fsyms=BAND&tsyms=BTC";

Expand All @@ -76,7 +82,8 @@ module CrytoCompare = {
let data = {
let%Opt usd = usdJson;
let%Opt btc = btcJson;
Some(decode(usd, btc));
let%Opt result = decode(usd, btc);
Some(result);
};

(data, reload);
Expand Down