From c1e681df9b353343582a6e5d8efbdc8b1d6180c6 Mon Sep 17 00:00:00 2001 From: Verin1005 Date: Thu, 20 Jun 2024 11:40:12 +0800 Subject: [PATCH] getTokenInfo for brc20 --- .../contracts/token_holding_amount/BRC20.sol | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/tee-worker/litentry/core/assertion-build/src/dynamic/contracts/token_holding_amount/BRC20.sol b/tee-worker/litentry/core/assertion-build/src/dynamic/contracts/token_holding_amount/BRC20.sol index f63e36c9c3..92494dc984 100644 --- a/tee-worker/litentry/core/assertion-build/src/dynamic/contracts/token_holding_amount/BRC20.sol +++ b/tee-worker/litentry/core/assertion-build/src/dynamic/contracts/token_holding_amount/BRC20.sol @@ -22,8 +22,7 @@ import "../libraries/Identities.sol"; import "../libraries/Http.sol"; import "../libraries/Utils.sol"; import { TokenHoldingAmount } from "./TokenHoldingAmount.sol"; -import { Btcs } from "./brc20/Btcs.sol"; -import { Cats } from "./brc20/Cats.sol"; +import "./brc20/BRC20TokenLibrary.sol"; contract BRC20 is TokenHoldingAmount { function getTokenDecimals() internal pure override returns (uint8) { return 18; @@ -41,9 +40,9 @@ contract BRC20 is TokenHoldingAmount { // https://geniidata.readme.io/reference/get-brc20-tick-list-copy string memory url = string( abi.encodePacked( - "https://api.geniidata.com/api/1/brc20/balance", + // "https://api.geniidata.com/api/1/brc20/balance", // below url is used for test against mock server - // "http://localhost:19529/api/1/brc20/balance", + "http://localhost:19529/api/1/brc20/balance", "?tick=", tokenName, "&address=", @@ -92,15 +91,24 @@ contract BRC20 is TokenHoldingAmount { string memory tokenBscAddress = ""; string memory tokenEthereumAddress = ""; - if (Utils.isStringsEqual(decodedParams, "Btcs")) { - tokenName = Btcs.getTokenName(); - ranges = Btcs.getTokenRanges(); - } else if (Utils.isStringsEqual(decodedParams, "Cats")) { - tokenName = Cats.getTokenName(); - ranges = Cats.getTokenRanges(); + if (Utils.isStringsEqual(decodedParams, "btcs")) { + (tokenName, ranges) = BRC0TokenLibrary.getBtcsInfo(); + } else if (Utils.isStringsEqual(decodedParams, "cats")) { + (tokenName, ranges) = BRC0TokenLibrary.getCatsInfo(); + } else if (Utils.isStringsEqual(decodedParams, "long")) { + (tokenName, ranges) = BRC0TokenLibrary.getLongInfo(); + } else if (Utils.isStringsEqual(decodedParams, "mmss")) { + (tokenName, ranges) = BRC0TokenLibrary.getMmssInfo(); + } else if (Utils.isStringsEqual(decodedParams, "ordi")) { + (tokenName, ranges) = BRC0TokenLibrary.getOrdiInfo(); + } else if (Utils.isStringsEqual(decodedParams, "rats")) { + (tokenName, ranges) = BRC0TokenLibrary.getRatsInfo(); + } else if (Utils.isStringsEqual(decodedParams, "sats")) { + (tokenName, ranges) = BRC0TokenLibrary.getSatsInfo(); } else { revert("Unsupported token"); } + return (tokenName, ranges, tokenBscAddress, tokenEthereumAddress); } }