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

Commit

Permalink
Merge pull request #2666 from bandprotocol/fix-rate-limit
Browse files Browse the repository at this point in the history
Scan: handle rate limit message on PriceHook
  • Loading branch information
Kanisorn Thongprapaisaeng authored Sep 23, 2020
2 parents 1fbeee6 + fe4791c commit 33939b5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
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

0 comments on commit 33939b5

Please sign in to comment.