From 4304956b6352d16bfdff56013ef6bd3a785b4eab Mon Sep 17 00:00:00 2001 From: Jaz Gulati Date: Fri, 6 May 2022 10:22:04 +1000 Subject: [PATCH] feat: ust support --- chain/terra/terra.go | 8 +++++--- multichain.go | 8 ++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/chain/terra/terra.go b/chain/terra/terra.go index ba2aa1fe..ff84eed1 100644 --- a/chain/terra/terra.go +++ b/chain/terra/terra.go @@ -66,13 +66,15 @@ func NewTxBuilder(opts TxBuilderOptions, client *Client) account.TxBuilder { type GasEstimator struct { url string + key string decimals int fallbackGas pack.U256 } -func NewHttpGasEstimator(url string, decimals int, fallbackGas pack.U256) GasEstimator { +func NewHttpGasEstimator(url, key string, decimals int, fallbackGas pack.U256) GasEstimator { return GasEstimator{ url: url, + key: key, decimals: decimals, fallbackGas: fallbackGas, } @@ -89,9 +91,9 @@ func (gasEstimator GasEstimator) EstimateGas(ctx context.Context) (pack.U256, pa if err := json.NewDecoder(response.Body).Decode(&results); err != nil { return gasEstimator.fallbackGas, gasEstimator.fallbackGas, err } - gasPriceStr, ok := results["uluna"] + gasPriceStr, ok := results[gasEstimator.key] if !ok { - return gasEstimator.fallbackGas, gasEstimator.fallbackGas, fmt.Errorf("no uluna in response") + return gasEstimator.fallbackGas, gasEstimator.fallbackGas, fmt.Errorf("no %v in response", gasEstimator.key) } gasPriceFloat, err := strconv.ParseFloat(gasPriceStr, 64) if err != nil { diff --git a/multichain.go b/multichain.go index 5be14344..9022ad9f 100644 --- a/multichain.go +++ b/multichain.go @@ -115,6 +115,7 @@ const ( LUNA = Asset("LUNA") // Luna MATIC = Asset("MATIC") // Matic PoS (Polygon) SOL = Asset("SOL") // Solana + UST = Asset("UST") // TerraUSD ZEC = Asset("ZEC") // Zcash BADGER = Asset("BADGER") // Badger DAO @@ -219,6 +220,8 @@ func (asset Asset) OriginChain() Chain { return Polygon case SOL: return Solana + case UST: + return Terra case ZEC: return Zcash @@ -251,7 +254,8 @@ func (asset Asset) ChainType() ChainType { switch asset { case BCH, BTC, DGB, DOGE, ZEC: return ChainTypeUTXOBased - case ArbETH, AVAX, BNB, CAT, ETH, FIL, FTM, GLMR, KAVA, LUNA, MATIC, SOL: + case ArbETH, AVAX, BNB, CAT, ETH, FIL, FTM, GLMR, KAVA, LUNA, MATIC, SOL, + UST: return ChainTypeAccountBased case BADGER, BUSD, CRV, DAI, EURT, FTT, ibBTC, KNC, LINK, MIM, REN, ROOK, @@ -277,7 +281,7 @@ func (asset Asset) ChainType() ChainType { // Type returns the asset-type (Native or Token) for the given asset. func (asset Asset) Type() AssetType { switch asset { - case ArbETH, AVAX, BNB, CAT, ETH, FTM, GLMR, KAVA, MATIC, SOL: + case ArbETH, AVAX, BNB, CAT, ETH, FTM, GLMR, KAVA, MATIC, SOL, UST: return AssetTypeNative case BADGER, BUSD, CRV, DAI, EURT, FTT, ibBTC, KNC, LINK, MIM, REN, ROOK,