Skip to content

Commit

Permalink
Merge pull request #85 from InjectiveLabs/f/v047
Browse files Browse the repository at this point in the history
fix: try bump to sdk v0.47
  • Loading branch information
albertchon authored Jun 1, 2023
2 parents 5868c94 + bcf00b4 commit 31785ad
Show file tree
Hide file tree
Showing 7 changed files with 2,853 additions and 409 deletions.
34 changes: 34 additions & 0 deletions cmd/peggo/encoding.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package main

import (
"github.com/cosmos/cosmos-sdk/client"
sdkcodec "github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/x/auth/tx"

"github.com/InjectiveLabs/sdk-go/chain/codec"
)

type EncodingConfig struct {
InterfaceRegistry types.InterfaceRegistry
Marshaler sdkcodec.Codec
TxConfig client.TxConfig
Amino *sdkcodec.LegacyAmino
}

// MakeEncodingConfig creates an EncodingConfig for testing
func MakeEncodingConfig() EncodingConfig {
cdc := sdkcodec.NewLegacyAmino()
interfaceRegistry := types.NewInterfaceRegistry()
marshaler := sdkcodec.NewProtoCodec(interfaceRegistry)
encodingConfig := EncodingConfig{
InterfaceRegistry: interfaceRegistry,
Marshaler: marshaler,
TxConfig: tx.NewTxConfig(marshaler, tx.DefaultSignModes),
Amino: cdc,
}

codec.RegisterInterfaces(encodingConfig.InterfaceRegistry)
codec.RegisterLegacyAminoCodec(encodingConfig.Amino)
return encodingConfig
}
27 changes: 19 additions & 8 deletions cmd/peggo/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
const defaultKeyringKeyName = "validator"

var emptyCosmosAddress = cosmtypes.AccAddress{}
var cdc = MakeEncodingConfig().Marshaler

func initCosmosKeyring(
cosmosKeyringDir *string,
Expand All @@ -46,6 +47,7 @@ func initCosmosKeyring(
cosmosPrivKey *string,
cosmosUseLedger *bool,
) (cosmtypes.AccAddress, keyring.Keyring, error) {

switch {
case len(*cosmosPrivKey) > 0:
if *cosmosUseLedger {
Expand Down Expand Up @@ -115,14 +117,15 @@ func initCosmosKeyring(
*cosmosKeyringBackend,
absoluteKeyringDir,
passReader,
cdc,
hd.EthSecp256k1Option(),
)
if err != nil {
err = errors.Wrap(err, "failed to init keyring")
return emptyCosmosAddress, nil, err
}

var keyInfo keyring.Info
var keyInfo *keyring.Record
if fromIsAddress {
if keyInfo, err = kb.KeyByAddress(addressFrom); err != nil {
err = errors.Wrapf(err, "couldn't find an entry for the key %s in keybase", addressFrom.String())
Expand All @@ -138,23 +141,31 @@ func initCosmosKeyring(
switch keyType := keyInfo.GetType(); keyType {
case keyring.TypeLocal:
// kb has a key and it's totally usable
return keyInfo.GetAddress(), kb, nil
addr, err := keyInfo.GetAddress()
if err != nil {
return emptyCosmosAddress, nil, err
}
return addr, kb, nil
case keyring.TypeLedger:
// the kb stores references to ledger keys, so we must explicitly
// check that. kb doesn't know how to scan HD keys - they must be added manually before
if *cosmosUseLedger {
return keyInfo.GetAddress(), kb, nil
addr, err := keyInfo.GetAddress()
if err != nil {
return emptyCosmosAddress, nil, err
}
return addr, kb, nil
}
err := errors.Errorf("'%s' key is a ledger reference, enable ledger option", keyInfo.GetName())
err := errors.Errorf("'%s' key is a ledger reference, enable ledger option", keyInfo.Name)
return emptyCosmosAddress, nil, err
case keyring.TypeOffline:
err := errors.Errorf("'%s' key is an offline key, not supported yet", keyInfo.GetName())
err := errors.Errorf("'%s' key is an offline key, not supported yet", keyInfo.Name)
return emptyCosmosAddress, nil, err
case keyring.TypeMulti:
err := errors.Errorf("'%s' key is an multisig key, not supported yet", keyInfo.GetName())
err := errors.Errorf("'%s' key is an multisig key, not supported yet", keyInfo.Name)
return emptyCosmosAddress, nil, err
default:
err := errors.Errorf("'%s' key has unsupported type: %s", keyInfo.GetName(), keyType)
err := errors.Errorf("'%s' key has unsupported type: %s", keyInfo.Name, keyType)
return emptyCosmosAddress, nil, err
}

Expand Down Expand Up @@ -385,7 +396,7 @@ func (r *passReader) Read(p []byte) (n int, err error) {
// KeyringForPrivKey creates a temporary in-mem keyring for a PrivKey.
// Allows to init Context when the key has been provided in plaintext and parsed.
func KeyringForPrivKey(name string, privKey cryptotypes.PrivKey) (keyring.Keyring, error) {
kb := keyring.NewInMemory(hd.EthSecp256k1Option())
kb := keyring.NewInMemory(cdc, hd.EthSecp256k1Option())
tmpPhrase := randPhrase(64)
armored := cosmcrypto.EncryptArmorPrivKey(privKey, tmpPhrase, privKey.Type())
err := kb.ImportPrivKey(name, armored, tmpPhrase)
Expand Down
2 changes: 1 addition & 1 deletion cmd/peggo/orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"os"
"time"

rpchttp "github.com/cometbft/cometbft/rpc/client/http"
ethcmn "github.com/ethereum/go-ethereum/common"
cli "github.com/jawher/mow.cli"
rpchttp "github.com/tendermint/tendermint/rpc/client/http"
"github.com/xlab/closer"
log "github.com/xlab/suplog"

Expand Down
5 changes: 3 additions & 2 deletions cmd/peggo/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import (
"context"
"time"

rpchttp "github.com/cometbft/cometbft/rpc/client/http"
cli "github.com/jawher/mow.cli"
rpchttp "github.com/tendermint/tendermint/rpc/client/http"
"github.com/xlab/closer"
log "github.com/xlab/suplog"

"github.com/InjectiveLabs/peggo/orchestrator/cosmos"
"github.com/InjectiveLabs/sdk-go/chain/peggy/types"
chainclient "github.com/InjectiveLabs/sdk-go/client/chain"
"github.com/InjectiveLabs/sdk-go/client/common"

"github.com/InjectiveLabs/peggo/orchestrator/cosmos"
)

// txCmdSubset contains actions that can sign and send messages to Cosmos module
Expand Down
46 changes: 17 additions & 29 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,33 @@ module github.com/InjectiveLabs/peggo
go 1.16

require (
github.com/DataDog/zstd v1.4.8 // indirect
github.com/InjectiveLabs/etherman v1.7.0
github.com/InjectiveLabs/metrics v0.0.1
github.com/InjectiveLabs/sdk-go v1.38.2
github.com/StackExchange/wmi v1.2.0 // indirect
github.com/InjectiveLabs/sdk-go v1.47.6
github.com/avast/retry-go v3.0.0+incompatible
github.com/cosmos/cosmos-sdk v0.45.2
github.com/dgraph-io/ristretto v0.1.0 // indirect
github.com/ethereum/go-ethereum v1.10.5
github.com/go-ole/go-ole v1.2.5 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/go-multierror v1.1.0
github.com/huin/goupnp v1.0.2 // indirect
github.com/cometbft/cometbft v0.37.1
github.com/cosmos/cosmos-sdk v0.47.2
github.com/ethereum/go-ethereum v1.11.5
github.com/hashicorp/go-multierror v1.1.1
github.com/jawher/mow.cli v1.2.0
github.com/karalabe/usb v0.0.0-20210518091819-4ea20957c210 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect
github.com/onsi/ginkgo v1.16.2
github.com/onsi/gomega v1.13.0
github.com/peterh/liner v1.2.1 // indirect
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.20.0
github.com/pkg/errors v0.9.1
github.com/shirou/gopsutil v3.21.6+incompatible // indirect
github.com/shopspring/decimal v1.2.0
github.com/stretchr/testify v1.7.0
github.com/tendermint/tendermint v0.34.16
github.com/tklauser/go-sysconf v0.3.7 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
github.com/stretchr/testify v1.8.3
github.com/xlab/closer v0.0.0-20190328110542-03326addb7c2
github.com/xlab/suplog v1.3.1
golang.org/x/crypto v0.0.0-20211215165025-cf75a172585e
google.golang.org/grpc v1.44.0
golang.org/x/crypto v0.7.0
google.golang.org/grpc v1.54.0
)

replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
replace (
github.com/CosmWasm/wasmd => github.com/InjectiveLabs/wasmd v0.40.0-inj
github.com/bandprotocol/bandchain-packet => github.com/InjectiveLabs/bandchain-packet v0.0.4-0.20230327115226-35199d4659d5
github.com/cometbft/cometbft => github.com/InjectiveLabs/cometbft v0.37.1-inj
github.com/cosmos/cosmos-sdk => github.com/InjectiveLabs/cosmos-sdk v0.47.2-inj-2
github.com/ethereum/go-ethereum => github.com/ethereum/go-ethereum v1.12.0

replace github.com/btcsuite/btcutil => github.com/btcsuite/btcutil v1.0.2

replace github.com/cosmos/cosmos-sdk => github.com/InjectiveLabs/cosmos-sdk v0.43.0-rc0

replace github.com/ethereum/go-ethereum => github.com/ethereum/go-ethereum v1.10.5
)
Loading

0 comments on commit 31785ad

Please sign in to comment.