Skip to content

Commit

Permalink
(fix) Regenerated all compiled protos. Updated CreateDenom example sc…
Browse files Browse the repository at this point in the history
…ript. Updated all markets and tokens INI files
  • Loading branch information
aarmoa committed Jul 29, 2024
1 parent d45b89b commit 9ea244b
Show file tree
Hide file tree
Showing 59 changed files with 28,594 additions and 1,421 deletions.
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ copy-exchange-client:
copy-chain-types:
cp ../injective-core/injective-chain/crypto/ethsecp256k1/*.go chain/crypto/ethsecp256k1
rm -rf chain/crypto/ethsecp256k1/*test.go rm -rf chain/crypto/ethsecp256k1/*gw.go
cp ../injective-core/injective-chain/codec/types/*.go chain/codec/types
rm -rf chain/codec/types/*test.go rm -rf chain/codec/types/*gw.go
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 @@ -60,9 +62,11 @@ copy-chain-types:
cp ../injective-core/injective-chain/types/*.go chain/types
rm -rf chain/types/*test.go rm -rf chain/types/*gw.go

echo "👉 Replace injective-core/injective-chain/modules with sdk-go/chain"
echo "👉 Replace injective-core/injective-chain/types with sdk-go/chain/types"
echo "👉 Replace injective-core/injective-chain/crypto with sdk-go/chain/crypto"
@echo "👉 Replace injective-core/injective-chain/modules with sdk-go/chain"
@echo "👉 Replace injective-core/injective-chain/codec with sdk-go/chain/codec"
@echo "👉 Replace injective-core/injective-chain/codec/types with sdk-go/chain/codec/types"
@echo "👉 Replace injective-core/injective-chain/types with sdk-go/chain/types"
@echo "👉 Replace injective-core/injective-chain/crypto with sdk-go/chain/crypto"

tests:
go test -race ./client/... ./ethereum/...
Expand Down
57 changes: 57 additions & 0 deletions chain/codec/types/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package types

import (
"cosmossdk.io/x/tx/signing"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/address"
"github.com/cosmos/cosmos-sdk/codec/types"
sdktypes "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/tx"
"github.com/cosmos/gogoproto/proto"

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

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

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

injcodec.RegisterInterfaces(encodingConfig.InterfaceRegistry)
injcodec.RegisterLegacyAminoCodec(encodingConfig.Amino)
return encodingConfig
}

// NewInterfaceRegistry returns a new InterfaceRegistry
func NewInterfaceRegistry() types.InterfaceRegistry {
registry, err := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{
ProtoFiles: proto.HybridResolver,
SigningOptions: signing.Options{
AddressCodec: address.Bech32Codec{
Bech32Prefix: sdktypes.GetConfig().GetBech32AccountAddrPrefix(),
},
ValidatorAddressCodec: address.Bech32Codec{
Bech32Prefix: sdktypes.GetConfig().GetBech32ValidatorAddrPrefix(),
},
},
})
if err != nil {
panic(err)
}
return registry
}
18 changes: 11 additions & 7 deletions chain/exchange/types/fee_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ func ValidateMakerWithTakerFee(makerFeeRate, takerFeeRate, relayerFeeShareRate,
}

if !makerFeeRate.IsNegative() {
return nil
}

// if makerFeeRate is negative, must hold: takerFeeRate * (1 - relayerFeeShareRate) + makerFeeRate > minimalProtocolFeeRate
if takerFeeRate.Mul(math.LegacyOneDec().Sub(relayerFeeShareRate)).Add(makerFeeRate).LT(minimalProtocolFeeRate) {
errMsg := fmt.Sprintf("if makerFeeRate (%v) is negative, (takerFeeRate = %v) * (1 - relayerFeeShareRate = %v) + makerFeeRate < %v", makerFeeRate.String(), takerFeeRate.String(), relayerFeeShareRate.String(), minimalProtocolFeeRate.String())
return errors.Wrap(ErrFeeRatesRelation, errMsg)
// if makerFeeRate is positive, must hold: (takerFeeRate + makerFeeRate) * (1 - relayerFeeShareRate) > minimalProtocolFeeRate
if takerFeeRate.Add(makerFeeRate).Mul(math.LegacyOneDec().Sub(relayerFeeShareRate)).LT(minimalProtocolFeeRate) {
errMsg := fmt.Sprintf("if makerFeeRate (%v) is positive, (takerFeeRate = %v + makerFeeRate = %v) * (1 - relayerFeeShareRate = %v) > %v", makerFeeRate.String(), takerFeeRate.String(), makerFeeRate.String(), relayerFeeShareRate.String(), minimalProtocolFeeRate.String())
return errors.Wrap(ErrFeeRatesRelation, errMsg)
}
} else {
// if makerFeeRate is negative, must hold: takerFeeRate * (1 - relayerFeeShareRate) + makerFeeRate > minimalProtocolFeeRate
if takerFeeRate.Mul(math.LegacyOneDec().Sub(relayerFeeShareRate)).Add(makerFeeRate).LT(minimalProtocolFeeRate) {
errMsg := fmt.Sprintf("if makerFeeRate (%v) is negative, (takerFeeRate = %v) * (1 - relayerFeeShareRate = %v) + makerFeeRate < %v", makerFeeRate.String(), takerFeeRate.String(), relayerFeeShareRate.String(), minimalProtocolFeeRate.String())
return errors.Wrap(ErrFeeRatesRelation, errMsg)
}
}

return nil
Expand Down
4 changes: 3 additions & 1 deletion chain/oracle/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"github.com/cosmos/cosmos-sdk/types/msgservice"
authzcdc "github.com/cosmos/cosmos-sdk/x/authz/codec"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"

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

// RegisterLegacyAminoCodec registers the necessary x/oracle interfaces and concrete types
Expand Down Expand Up @@ -76,7 +78,7 @@ var (
// defined at the application level.
// ModuleCdc = codec.NewAminoCodec(amino)

ModuleCdc = codec.NewProtoCodec(types.NewInterfaceRegistry())
ModuleCdc = codec.NewProtoCodec(injcodectypes.NewInterfaceRegistry())
)

func init() {
Expand Down
96 changes: 68 additions & 28 deletions chain/tokenfactory/types/genesis.pb.go

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

3 changes: 2 additions & 1 deletion chain/tokenfactory/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ func (m MsgUpdateParams) GetSigners() []sdk.AccAddress {
}

// NewMsgCreateDenom creates a msg to create a new denom
func NewMsgCreateDenom(sender, subdenom, name, symbol string) *MsgCreateDenom {
func NewMsgCreateDenom(sender, subdenom, name, symbol string, decimals uint32) *MsgCreateDenom {
return &MsgCreateDenom{
Sender: sender,
Subdenom: subdenom,
Name: name,
Symbol: symbol,
Decimals: decimals,
}
}

Expand Down
Loading

0 comments on commit 9ea244b

Please sign in to comment.