Skip to content

Commit

Permalink
Move Cosmos denom utils to chainlink-cosmos (#9674)
Browse files Browse the repository at this point in the history
* move cosmos denom utils to chainlink-cosmos

* update chainlink-cosmos version

* go mod tidy
  • Loading branch information
calvwang9 authored Jul 17, 2023
1 parent ae4faa5 commit f863d94
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 67 deletions.
22 changes: 0 additions & 22 deletions core/chains/cosmos/denom/denom.go

This file was deleted.

41 changes: 0 additions & 41 deletions core/chains/cosmos/denom/denom_test.go

This file was deleted.

4 changes: 2 additions & 2 deletions core/cmd/cosmos_transaction_commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import (

cosmosclient "github.com/smartcontractkit/chainlink-cosmos/pkg/cosmos/client"
cosmosdb "github.com/smartcontractkit/chainlink-cosmos/pkg/cosmos/db"
"github.com/smartcontractkit/chainlink-cosmos/pkg/cosmos/denom"

"github.com/smartcontractkit/chainlink/v2/core/chains/cosmos/cosmostxm"
"github.com/smartcontractkit/chainlink/v2/core/chains/cosmos/denom"
"github.com/smartcontractkit/chainlink/v2/core/cmd"
"github.com/smartcontractkit/chainlink/v2/core/internal/cltest"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils"
Expand Down Expand Up @@ -134,7 +134,7 @@ func TestShell_SendCosmosCoins(t *testing.T) {
require.NoError(t, err)
if assert.NotNil(t, startBal) && assert.NotNil(t, endBal) {
diff := startBal.Sub(*endBal).Amount
sent, err := denom.DecCoinToUAtom(sdk.NewDecCoinFromDec("atom", sdk.MustNewDecFromStr(tt.amount)))
sent, err := denom.ConvertDecCoinToDenom(sdk.NewDecCoinFromDec("atom", sdk.MustNewDecFromStr(tt.amount)), "uatom")
require.NoError(t, err)
if assert.True(t, diff.IsInt64()) && assert.True(t, sent.Amount.IsInt64()) {
require.Greater(t, diff.Int64(), sent.Amount.Int64())
Expand Down
4 changes: 2 additions & 2 deletions core/web/cosmos_transfer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"github.com/pkg/errors"

"github.com/smartcontractkit/chainlink-cosmos/pkg/cosmos/client"
"github.com/smartcontractkit/chainlink-cosmos/pkg/cosmos/denom"

"github.com/smartcontractkit/chainlink/v2/core/chains/cosmos"
"github.com/smartcontractkit/chainlink/v2/core/chains/cosmos/denom"
"github.com/smartcontractkit/chainlink/v2/core/logger/audit"
"github.com/smartcontractkit/chainlink/v2/core/services/chainlink"
cosmosmodels "github.com/smartcontractkit/chainlink/v2/core/store/models/cosmos"
Expand Down Expand Up @@ -57,7 +57,7 @@ func (tc *CosmosTransfersController) Create(c *gin.Context) {
return
}

coin, err := denom.DecCoinToUAtom(sdk.NewDecCoinFromDec("atom", tr.Amount))
coin, err := denom.ConvertDecCoinToDenom(sdk.NewDecCoinFromDec("atom", tr.Amount), "uatom")
if err != nil {
jsonAPIError(c, http.StatusBadRequest, errors.Errorf("unable to convert to uatom: %v", err))
return
Expand Down

0 comments on commit f863d94

Please sign in to comment.