Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: cosmos & starknet LOOPP mode only #16039

Merged
merged 4 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ install-ocr3-capability: ## Build & install the chainlink-ocr3-capability binary
.PHONY: install-plugins
install-plugins: ## Build & install LOOPP binaries for products and chains.
cd $(shell go list -m -f "{{.Dir}}" github.com/smartcontractkit/chainlink-feeds) && \
go install ./cmd/chainlink-feeds
go install $(GOFLAGS) ./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) && \
go install ./pkg/cosmos/cmd/chainlink-cosmos
go install $(GOFLAGS) ./mercury/cmd/chainlink-mercury
cd $(shell go mod download -json github.com/smartcontractkit/chainlink-cosmos@f740e9ae54e79762991bdaf8ad6b50363261c056 | jq -r .Dir) && \
go install $(GOFLAGS) ./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) && \
go install ./pkg/chainlink/cmd/chainlink-starknet
go install $(GOFLAGS) ./pkg/solana/cmd/chainlink-solana
cd $(shell go mod download -json github.com/smartcontractkit/chainlink-starknet/relayer@9a780650af4708e4bd9b75495feff2c5b4054e46 | jq -r .Dir) && \
go install $(GOFLAGS) ./pkg/chainlink/cmd/chainlink-starknet

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just moving these to separate files in order to gate with build tags


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": chainID,
"Nodes": []map[string]any{{
"Name": "primary",
"TendermintURL": "http://tender.mint",
}},
}
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"

client2 "github.com/smartcontractkit/chainlink-integrations/evm/client"
"github.com/smartcontractkit/chainlink-integrations/evm/utils/big"
"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"
)

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
Loading