Skip to content

Commit

Permalink
core: cosmos & starknet LOOPP mode only
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 committed Feb 4, 2025
1 parent aa7b906 commit c395840
Show file tree
Hide file tree
Showing 43 changed files with 459 additions and 1,703 deletions.
4 changes: 2 additions & 2 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ install-plugins: ## Build & install LOOPP binaries for products and chains.
go install ./cmd/chainlink-feeds
cd $(shell go list -m -f "{{.Dir}}" github.com/smartcontractkit/chainlink-data-streams) && \
go install ./mercury/cmd/chainlink-mercury
cd $(shell go list -m -f "{{.Dir}}" github.com/smartcontractkit/chainlink-cosmos) && \
cd $(shell go mod download -json github.com/smartcontractkit/chainlink-cosmos@a8ef07bd9cd050cc29938292395603f3ccec787c | jq -r .Dir) && \
go install ./pkg/cosmos/cmd/chainlink-cosmos
cd $(shell go list -m -f "{{.Dir}}" github.com/smartcontractkit/chainlink-solana) && \
go install ./pkg/solana/cmd/chainlink-solana
cd $(shell go list -m -f "{{.Dir}}" github.com/smartcontractkit/chainlink-starknet/relayer) && \
cd $(shell go mod download -json github.com/smartcontractkit/chainlink-starknet/relayer@9a780650af4708e4bd9b75495feff2c5b4054e46 | jq -r .Dir) && \
go install ./pkg/chainlink/cmd/chainlink-starknet

.PHONY: docker ## Build the chainlink docker image
Expand Down
34 changes: 34 additions & 0 deletions core/cmd/chains_commands_integration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//go:build integration

package cmd_test

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink/v2/core/cmd"
"github.com/smartcontractkit/chainlink/v2/core/internal/cltest"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils/cosmostest"
"github.com/smartcontractkit/chainlink/v2/core/services/chainlink"
)

func TestShell_IndexCosmosChains(t *testing.T) {
t.Parallel()

chainID := cosmostest.RandomChainID()
chain := chainlink.RawConfig{
"ChainID": ptr(chainID),
"Enabled": ptr(true),
}
app := cosmosStartNewApplication(t, chain)
client, r := app.NewShellAndRenderer()

require.NoError(t, cmd.NewChainClient(client, "cosmos").IndexChains(cltest.EmptyCLIContext()))
chains := *r.Renders[0].(*cmd.ChainPresenters)
require.Len(t, chains, 1)
c := chains[0]
assert.Equal(t, chainID, c.ID)
assertTableRenders(t, r)
}
21 changes: 0 additions & 21 deletions core/cmd/chains_commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,17 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

coscfg "github.com/smartcontractkit/chainlink-cosmos/pkg/cosmos/config"
solcfg "github.com/smartcontractkit/chainlink-solana/pkg/solana/config"

"github.com/smartcontractkit/chainlink/v2/core/cmd"
"github.com/smartcontractkit/chainlink/v2/core/internal/cltest"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils/cosmostest"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils/solanatest"
"github.com/smartcontractkit/chainlink/v2/core/services/chainlink"
client2 "github.com/smartcontractkit/chainlink/v2/evm/client"
"github.com/smartcontractkit/chainlink/v2/evm/utils/big"
)

func TestShell_IndexCosmosChains(t *testing.T) {
t.Parallel()

chainID := cosmostest.RandomChainID()
chain := coscfg.TOMLConfig{
ChainID: ptr(chainID),
Enabled: ptr(true),
}
app := cosmosStartNewApplication(t, &chain)
client, r := app.NewShellAndRenderer()

require.NoError(t, cmd.NewChainClient(client, "cosmos").IndexChains(cltest.EmptyCLIContext()))
chains := *r.Renders[0].(*cmd.ChainPresenters)
require.Len(t, chains, 1)
c := chains[0]
assert.Equal(t, chainID, c.ID)
assertTableRenders(t, r)
}

func newRandChainID() *big.Big {
return big.New(testutils.NewRandomEVMChainID())
}
Expand Down
36 changes: 15 additions & 21 deletions core/cmd/cosmos_transaction_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"encoding/json"
"errors"
"fmt"
"math/big"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/urfave/cli"
"go.uber.org/multierr"

Expand Down Expand Up @@ -67,31 +67,25 @@ func (s *Shell) CosmosSendNativeToken(c *cli.Context) (err error) {
return s.errorOut(errors.New("four arguments expected: token, amount, fromAddress and toAddress"))
}

err = sdk.ValidateDenom(c.Args().Get(0))
if err != nil {
return s.errorOut(fmt.Errorf("invalid native token: %w", err))
token := c.Args().Get(0)
if token == "" {
return s.errorOut(errors.New("missing token"))
}

amount, err := sdk.NewDecFromStr(c.Args().Get(1))
if err != nil {
return s.errorOut(multierr.Combine(
fmt.Errorf("invalid coin: %w", err)))
unparsedAmount := c.Args().Get(1)
amount, ok := new(big.Int).SetString(unparsedAmount, 10)
if !ok {
return s.errorOut(fmt.Errorf("invalid int: %s", unparsedAmount))
}

unparsedFromAddress := c.Args().Get(2)
fromAddress, err := sdk.AccAddressFromBech32(unparsedFromAddress)
if err != nil {
return s.errorOut(multierr.Combine(
fmt.Errorf("while parsing withdrawal source address %v",
unparsedFromAddress), err))
if unparsedFromAddress == "" {
return s.errorOut(errors.New("missing from address"))
}

unparsedDestinationAddress := c.Args().Get(3)
destinationAddress, err := sdk.AccAddressFromBech32(unparsedDestinationAddress)
if err != nil {
return s.errorOut(multierr.Combine(
fmt.Errorf("while parsing withdrawal destination address %v",
unparsedDestinationAddress), err))
if unparsedDestinationAddress == "" {
return s.errorOut(errors.New("missing destination address"))
}

chainID := c.String("id")
Expand All @@ -100,11 +94,11 @@ func (s *Shell) CosmosSendNativeToken(c *cli.Context) (err error) {
}

request := cosmos.SendRequest{
DestinationAddress: destinationAddress,
FromAddress: fromAddress,
DestinationAddress: unparsedDestinationAddress,
FromAddress: unparsedFromAddress,
Amount: amount,
CosmosChainID: chainID,
Token: c.Args().Get(0),
Token: token,
AllowHigherAmounts: c.IsSet("force"),
}

Expand Down
132 changes: 0 additions & 132 deletions core/cmd/cosmos_transaction_commands_test.go

This file was deleted.

Loading

0 comments on commit c395840

Please sign in to comment.