Skip to content

Commit

Permalink
F/0.47 compat [DO NOT MERGE UNTIL CHAIN 0.47 READY] (#120)
Browse files Browse the repository at this point in the history
* chore: align explorer types

* chore: upgrade sdk with timestamps on portfolio stream api

* feat: move pkg usage from tendermint to cometbft

* feat: add missing files from core repo

* feat: make copy-chain-types

* feat: impl cometbft websocket client

* feat: refactor clientCtx, keyring.Info to keyring.Record

* feat: refactor keyring.Record

* feat: update chain examples

* chore: revert local test example

* chore: gofmt

* chore: register extension opt i to decode

* chore: bump go version to 1.19 (#130)

* fix: add gov V1 types, remove evm, erc20bridge, cleanup deps

* fix: nil keyring, empty tm client, minor cert issue (#131)

* fix: nil keyring and empty tm client

* chore: update example with tmclients

* chore: add back tmClient

* chore: remove tcp:// prefix to fix cert issue

* chore: re-gen

* build: align deps to chain

---------

Co-authored-by: Michele Meloni <[email protected]>
Co-authored-by: vinhphuctadang <[email protected]>
Co-authored-by: Tofel <[email protected]>
Co-authored-by: Albert Chon <[email protected]>
Co-authored-by: Phuc Ta <[email protected]>
  • Loading branch information
6 people authored May 31, 2023
1 parent a1240bb commit 53c5616
Show file tree
Hide file tree
Showing 277 changed files with 18,914 additions and 23,806 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ copy-exchange-client:
.PHONY: copy-exchange-client

copy-chain-types:
cp ../injective-core/injective-chain/types/*.go chain/types
cp ../injective-core/injective-chain/crypto/ethsecp256k1/*.go chain/crypto/ethsecp256k1
cp ../injective-core/injective-chain/modules/auction/types/*.go chain/auction/types
rm -rf chain/auction/types/*test.go rm -rf chain/auction/types/*gw.go
cp ../injective-core/injective-chain/modules/exchange/types/*.go chain/exchange/types
Expand All @@ -36,6 +38,7 @@ copy-chain-types:
cp ../injective-core/injective-chain/modules/ocr/types/*.go chain/ocr/types
rm -rf chain/ocr/types/*test.go rm -rf chain/ocr/types/*gw.go
cp ../injective-core/injective-chain/modules/oracle/types/*.go chain/oracle/types
cp -r ../injective-core/injective-chain/modules/oracle/bandchain chain/oracle
rm -rf chain/oracle/types/*test.go rm -rf chain/oracle/types/*gw.go
cp ../injective-core/injective-chain/modules/peggy/types/*.go chain/peggy/types
rm -rf chain/peggy/types/*test.go rm -rf chain/peggy/types/*gw.go
Expand Down
59 changes: 0 additions & 59 deletions bandchain/oracle/types/error.go

This file was deleted.

7 changes: 4 additions & 3 deletions chain/auction/types/auction.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions chain/auction/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ import (
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
authzcdc "github.com/cosmos/cosmos-sdk/x/authz/codec"
)

// RegisterLegacyAminoCodec registers the necessary x/auction interfaces and concrete types
// on the provided LegacyAmino codec. These types are used for Amino JSON serialization.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgBid{}, "auction/MsgBid", nil)
cdc.RegisterConcrete(&MsgUpdateParams{}, "auction/MsgUpdateParams", nil)
}

func RegisterInterfaces(registry types.InterfaceRegistry) {
registry.RegisterImplementations((*sdk.Msg)(nil),
&MsgBid{},
&MsgUpdateParams{},
)

msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
Expand All @@ -37,5 +40,7 @@ var (
func init() {
RegisterLegacyAminoCodec(amino)
cryptocodec.RegisterCrypto(amino)

RegisterLegacyAminoCodec(authzcdc.Amino)
amino.Seal()
}
6 changes: 3 additions & 3 deletions chain/auction/types/errors.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package types

import sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
import "cosmossdk.io/errors"

var (
ErrBidInvalid = sdkerrors.Register(ModuleName, 1, "invalid bid denom")
ErrBidRound = sdkerrors.Register(ModuleName, 2, "invalid bid round")
ErrBidInvalid = errors.Register(ModuleName, 1, "invalid bid denom")
ErrBidRound = errors.Register(ModuleName, 2, "invalid bid round")
)
4 changes: 2 additions & 2 deletions chain/auction/types/genesis.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions chain/auction/types/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ var (
BidsKey = []byte{0x01}
AuctionRoundKey = []byte{0x03}
KeyEndingTimeStamp = []byte{0x04}
ParamsKey = []byte{0x10}
)
50 changes: 44 additions & 6 deletions chain/auction/types/msgs.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,58 @@
package types

import (
"cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"

chaintypes "github.com/InjectiveLabs/sdk-go/chain/types"
)

const TypeMsgBid = "bid"
const (
RouterKey = ModuleName

const RouterKey = ModuleName
TypeMsgBid = "bid"
TypeMsgUpdateParams = "updateParams"
)

var (
_ sdk.Msg = &MsgBid{}
_ sdk.Msg = &MsgUpdateParams{}
)

// Route implements the sdk.Msg interface. It should return the name of the module
func (msg MsgUpdateParams) Route() string { return RouterKey }

// Type implements the sdk.Msg interface. It should return the action.
func (msg MsgUpdateParams) Type() string { return TypeMsgUpdateParams }

// ValidateBasic implements the sdk.Msg interface. It runs stateless checks on the message
func (msg MsgUpdateParams) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil {
return errors.Wrap(err, "invalid authority address")
}

if err := msg.Params.Validate(); err != nil {
return err
}

return nil
}

// GetSignBytes implements the sdk.Msg interface. It encodes the message for signing
func (msg *MsgUpdateParams) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg))
}

// GetSigners implements the sdk.Msg interface. It defines whose signature is required
func (msg MsgUpdateParams) GetSigners() []sdk.AccAddress {
sender, err := sdk.AccAddressFromBech32(msg.Authority)
if err != nil {
panic(err)
}
return []sdk.AccAddress{sender}
}

// Route implements the sdk.Msg interface. It should return the name of the module
func (msg MsgBid) Route() string { return RouterKey }

Expand All @@ -24,19 +62,19 @@ func (msg MsgBid) Type() string { return TypeMsgBid }
// ValidateBasic implements the sdk.Msg interface. It runs stateless checks on the message
func (msg MsgBid) ValidateBasic() error {
if msg.Sender == "" {
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, msg.Sender)
return errors.Wrap(sdkerrors.ErrInvalidAddress, msg.Sender)
}

if !msg.BidAmount.IsValid() {
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, msg.BidAmount.String())
return errors.Wrap(sdkerrors.ErrInvalidCoins, msg.BidAmount.String())
}

if !msg.BidAmount.IsPositive() {
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, msg.BidAmount.String())
return errors.Wrap(sdkerrors.ErrInvalidCoins, msg.BidAmount.String())
}

if msg.BidAmount.Denom != chaintypes.InjectiveCoin {
return sdkerrors.Wrap(ErrBidInvalid, msg.BidAmount.Denom)
return errors.Wrap(ErrBidInvalid, msg.BidAmount.Denom)
}

return nil
Expand Down
24 changes: 15 additions & 9 deletions chain/auction/types/query.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 53c5616

Please sign in to comment.