chore: use sdkmath in misc packages (#14606)

Co-authored-by: atheeshp <59333759+atheeshp@users.noreply.github.com>
Co-authored-by: Marko <marbar3778@yahoo.com>
This commit is contained in:
Aleksandr Bezobchuk
2023-01-16 12:48:32 +00:00
committed by GitHub
co-authored by atheeshp Marko
parent ae1c29b8f8
commit f2b6013cee
12 changed files with 67 additions and 64 deletions
+5 -6
View File
@@ -6,7 +6,9 @@ import (
"fmt"
"reflect"
"cosmossdk.io/math"
sdkmath "cosmossdk.io/math"
crgerrs "cosmossdk.io/tools/rosetta/lib/errors"
crgtypes "cosmossdk.io/tools/rosetta/lib/types"
"github.com/btcsuite/btcd/btcec/v2"
rosettatypes "github.com/coinbase/rosetta-sdk-go/types"
abci "github.com/tendermint/tendermint/abci/types"
@@ -14,9 +16,6 @@ import (
tmcoretypes "github.com/tendermint/tendermint/rpc/core/types"
tmtypes "github.com/tendermint/tendermint/types"
crgerrs "cosmossdk.io/tools/rosetta/lib/errors"
crgtypes "cosmossdk.io/tools/rosetta/lib/types"
sdkclient "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
@@ -404,7 +403,7 @@ func sdkEventToBalanceOperations(status string, event abci.Event) (operations []
// Amounts converts []sdk.Coin to rosetta amounts
func (c converter) Amounts(ownedCoins []sdk.Coin, availableCoins sdk.Coins) []*rosettatypes.Amount {
amounts := make([]*rosettatypes.Amount, len(availableCoins))
ownedCoinsMap := make(map[string]math.Int, len(availableCoins))
ownedCoinsMap := make(map[string]sdkmath.Int, len(availableCoins))
for _, ownedCoin := range ownedCoins {
ownedCoinsMap[ownedCoin.Denom] = ownedCoin.Amount
@@ -414,7 +413,7 @@ func (c converter) Amounts(ownedCoins []sdk.Coin, availableCoins sdk.Coins) []*r
value, owned := ownedCoinsMap[coin.Denom]
if !owned {
amounts[i] = &rosettatypes.Amount{
Value: sdk.NewInt(0).String(),
Value: sdkmath.NewInt(0).String(),
Currency: &rosettatypes.Currency{
Symbol: coin.Denom,
},
@@ -7,11 +7,11 @@ import (
"strconv"
"strings"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkmath "cosmossdk.io/math"
"cosmossdk.io/tools/rosetta/lib/errors"
"github.com/coinbase/rosetta-sdk-go/types"
"cosmossdk.io/tools/rosetta/lib/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// ConstructionCombine Combine creates a network-specific transaction from an unsigned transaction
@@ -96,7 +96,7 @@ func (on OnlineNetwork) ConstructionMetadata(ctx context.Context, request *types
if gasLimit == 0 { // gas_limit is unset. skip fee suggestion
return response, nil
}
gas := sdk.NewIntFromUint64(uint64(gasLimit))
gas := sdkmath.NewIntFromUint64(uint64(gasLimit))
suggestedFee := types.Amount{
Value: strconv.FormatInt(price.Amount.MulInt64(gas.Int64()).Ceil().TruncateInt64(), 10),