package com.table.transfer.util.ether;

import com.table.transfer.module.enpty.ChainCoinDetail;
import com.table.transfer.module.enpty.TransferRequest;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ChainCoinDetailManager {
    public static final Map<String, ChainCoinDetail> chainCoinDetailMap = new HashMap<>();
    private static final String ethNode = "https://billowing-greatest-feather.quiknode.pro/591e36c78f14e843e629d72c07a3fb39c5955541";
    private static final String bscNode = "https://empty-quiet-sunset.bsc.quiknode.pro/69b72a1ee6e3efe4ad03d31b04a9a1b0c8a6e6d3";

    static {
        List<ChainCoinDetail> ChainCoinDetailList = new ArrayList<>();
        ChainCoinDetailList.add(new ChainCoinDetail(1, "ETH", "USDT", "0xdAC17F958D2ee523a2206206994597C13D831ec7", 6, BigInteger.valueOf(800000000L), BigInteger.valueOf(20000000000L), ethNode));
        ChainCoinDetailList.add(new ChainCoinDetail(1, "ETH", "ETH", null, 18, BigInteger.valueOf(800000000L), BigInteger.valueOf(20000000000L), ethNode));
        ChainCoinDetailList.add(new ChainCoinDetail(56, "BSC", "USDT", "0x55d398326f99059fF775485246999027B3197955", 18, BigInteger.valueOf(100000000L), BigInteger.valueOf(1000000000L), bscNode));
        ChainCoinDetailList.add(new ChainCoinDetail(56, "BSC", "BNB", null, 18,  BigInteger.valueOf(100000000L), BigInteger.valueOf(1000000000L), bscNode));
        ChainCoinDetailList.add(new ChainCoinDetail(56, "BSC", "TRX", "0xCE7de646e7208a4Ef112cb6ed5038FA6cC6b12e3", 6, BigInteger.valueOf(100000000L), BigInteger.valueOf(1000000000L), bscNode));
        ChainCoinDetailList.add(new ChainCoinDetail(56, "BSC", "ETH", "0x2170Ed0880ac9A755fd29B2688956BD959F933F8", 18, BigInteger.valueOf(100000000L), BigInteger.valueOf(1000000000L), bscNode));
        ChainCoinDetailList.add(new ChainCoinDetail(56, "BSC", "WBNB", "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c", 18, BigInteger.valueOf(100000000L), BigInteger.valueOf(1000000000L), bscNode));
        ChainCoinDetailList.add(new ChainCoinDetail(56, "BSC", "WBTC", "0x0555E30da8f98308EdB960aa94C0Db47230d2B9c", 8, BigInteger.valueOf(100000000L), BigInteger.valueOf(1000000000L), bscNode));

        for (ChainCoinDetail one : ChainCoinDetailList) {
            chainCoinDetailMap.put(one.getAssetCode(), one);
        }

    }
    public static ChainCoinDetail getChainCoinDetail(TransferRequest transferRequest) {
        return chainCoinDetailMap.get(transferRequest.getAssetCode());
    }

    public static ChainCoinDetail getChainCoinDetail(String assetCode) {
        return chainCoinDetailMap.get(assetCode);
    }
    public static int getDecimal(TransferRequest transferRequest) {
       return chainCoinDetailMap.get(transferRequest.getAssetCode()).getDecimal();
    }

}
