Skip to content

Commit

Permalink
Merge pull request #258 from InjectiveLabs/release/v_1_54_0
Browse files Browse the repository at this point in the history
Release/v1.54.0
  • Loading branch information
PavelInjective authored Nov 14, 2024
2 parents 935b4ad + 65b0d65 commit 428cbcf
Show file tree
Hide file tree
Showing 55 changed files with 2,337 additions and 32,214 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ jobs:
with:
go-version-file: "go.mod"
check-latest: true
- name: Install pass helper
run: sudo apt-get update && sudo apt-get install -y pass
- name: Generate GPG key
run: "
echo \"%no-protection\nKey-Type: 1\nKey-Length: 4096\nSubkey-Type: 1\nSubkey-Length: 4096\nName-Comment: keyring_test\nExpire-Date: 0\" > genkey && gpg --gen-key --batch genkey"
- name: Setup OS keystore
run: pass init keyring_test
- name: Run test and calculate coverage
run: make coverage
- name: Upload coverage to Codecov
Expand Down
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ exclude: |
(?x)^(
chain/.*|
exchange/.*|
proto/.*
proto/.*|
client/keyring/testdata/.*
)$
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
4 changes: 0 additions & 4 deletions auth_vote/authz_vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ func main() {
panic(err)
}

if err != nil {
panic(err)
}

senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
Expand Down
1 change: 0 additions & 1 deletion client/cert/embed.go

This file was deleted.

31 changes: 0 additions & 31 deletions client/cert/mainnet.crt

This file was deleted.

31 changes: 0 additions & 31 deletions client/cert/testnet.crt

This file was deleted.

30 changes: 7 additions & 23 deletions client/chain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@ type ChainClient interface {
SynchronizeSubaccountNonce(subaccountId ethcommon.Hash) error
ComputeOrderHashes(spotOrders []exchangetypes.SpotOrder, derivativeOrders []exchangetypes.DerivativeOrder, subaccountId ethcommon.Hash) (OrderHashes, error)

SpotOrder(defaultSubaccountID ethcommon.Hash, network common.Network, d *SpotOrderData) *exchangetypes.SpotOrder
CreateSpotOrder(defaultSubaccountID ethcommon.Hash, d *SpotOrderData, marketsAssistant MarketsAssistant) *exchangetypes.SpotOrder
DerivativeOrder(defaultSubaccountID ethcommon.Hash, network common.Network, d *DerivativeOrderData) *exchangetypes.DerivativeOrder
CreateDerivativeOrder(defaultSubaccountID ethcommon.Hash, d *DerivativeOrderData, marketAssistant MarketsAssistant) *exchangetypes.DerivativeOrder
OrderCancel(defaultSubaccountID ethcommon.Hash, d *OrderCancelData) *exchangetypes.OrderData

Expand Down Expand Up @@ -295,9 +293,12 @@ type ChainClient interface {
FetchAddressesByRole(ctx context.Context, denom, role string) (*permissionstypes.QueryAddressesByRoleResponse, error)
FetchVouchersForAddress(ctx context.Context, address string) (*permissionstypes.QueryVouchersForAddressResponse, error)

GetNetwork() common.Network
Close()
}

var _ ChainClient = &chainClient{}

type chainClient struct {
ctx client.Context
network common.Network
Expand Down Expand Up @@ -1072,16 +1073,6 @@ func (c *chainClient) GetSubAccountNonce(ctx context.Context, subaccountId ethco
return res, err
}

// Deprecated: Use CreateSpotOrder instead
func (c *chainClient) SpotOrder(defaultSubaccountID ethcommon.Hash, network common.Network, d *SpotOrderData) *exchangetypes.SpotOrder {
assistant, err := NewMarketsAssistant(network.Name)
if err != nil {
panic(err)
}

return c.CreateSpotOrder(defaultSubaccountID, d, assistant)
}

func (c *chainClient) CreateSpotOrder(defaultSubaccountID ethcommon.Hash, d *SpotOrderData, marketsAssistant MarketsAssistant) *exchangetypes.SpotOrder {

market, isPresent := marketsAssistant.AllSpotMarkets()[d.MarketId]
Expand All @@ -1105,17 +1096,6 @@ func (c *chainClient) CreateSpotOrder(defaultSubaccountID ethcommon.Hash, d *Spo
}
}

// Deprecated: Use CreateDerivativeOrder instead
func (c *chainClient) DerivativeOrder(defaultSubaccountID ethcommon.Hash, network common.Network, d *DerivativeOrderData) *exchangetypes.DerivativeOrder {

assistant, err := NewMarketsAssistant(network.Name)
if err != nil {
panic(err)
}

return c.CreateDerivativeOrder(defaultSubaccountID, d, assistant)
}

func (c *chainClient) CreateDerivativeOrder(defaultSubaccountID ethcommon.Hash, d *DerivativeOrderData, marketAssistant MarketsAssistant) *exchangetypes.DerivativeOrder {
market, isPresent := marketAssistant.AllDerivativeMarkets()[d.MarketId]
if !isPresent {
Expand Down Expand Up @@ -2667,3 +2647,7 @@ func (c *chainClient) FetchVouchersForAddress(ctx context.Context, address strin

return res, err
}

func (c *chainClient) GetNetwork() common.Network {
return c.network
}
77 changes: 55 additions & 22 deletions client/chain/chain_test_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,11 @@ import (
"errors"
"time"

permissionstypes "github.com/InjectiveLabs/sdk-go/chain/permissions/types"

sdkmath "cosmossdk.io/math"

"github.com/cosmos/cosmos-sdk/client/grpc/cmtservice"
"google.golang.org/grpc"

wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types"
chainstreamtypes "github.com/InjectiveLabs/sdk-go/chain/stream/types"
tokenfactorytypes "github.com/InjectiveLabs/sdk-go/chain/tokenfactory/types"
"github.com/InjectiveLabs/sdk-go/client/common"
rpchttp "github.com/cometbft/cometbft/rpc/client/http"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/grpc/cmtservice"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/query"
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
Expand All @@ -31,10 +22,23 @@ import (
ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types"
ibcchanneltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
eth "github.com/ethereum/go-ethereum/common"
"google.golang.org/grpc"

exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types"
permissionstypes "github.com/InjectiveLabs/sdk-go/chain/permissions/types"
chainstreamtypes "github.com/InjectiveLabs/sdk-go/chain/stream/types"
tokenfactorytypes "github.com/InjectiveLabs/sdk-go/chain/tokenfactory/types"
"github.com/InjectiveLabs/sdk-go/client/common"
)

var _ ChainClient = &MockChainClient{}

type MockChainClient struct {
DenomsMetadataResponses []*banktypes.QueryDenomsMetadataResponse
Network common.Network
DenomsMetadataResponses []*banktypes.QueryDenomsMetadataResponse
QuerySpotMarketsResponses []*exchangetypes.QuerySpotMarketsResponse
QueryDerivativeMarketsResponses []*exchangetypes.QueryDerivativeMarketsResponse
QueryBinaryMarketsResponses []*exchangetypes.QueryBinaryMarketsResponse
}

func (c *MockChainClient) CanSignTransactions() bool {
Expand Down Expand Up @@ -191,18 +195,10 @@ func (c *MockChainClient) ComputeOrderHashes(spotOrders []exchangetypes.SpotOrde
return OrderHashes{}, nil
}

func (c *MockChainClient) SpotOrder(defaultSubaccountID eth.Hash, network common.Network, d *SpotOrderData) *exchangetypes.SpotOrder {
return c.CreateSpotOrder(defaultSubaccountID, d, MarketsAssistant{})
}

func (c *MockChainClient) CreateSpotOrder(defaultSubaccountID eth.Hash, d *SpotOrderData, marketsAssistant MarketsAssistant) *exchangetypes.SpotOrder {
return &exchangetypes.SpotOrder{}
}

func (c *MockChainClient) DerivativeOrder(defaultSubaccountID eth.Hash, network common.Network, d *DerivativeOrderData) *exchangetypes.DerivativeOrder {
return c.CreateDerivativeOrder(defaultSubaccountID, d, MarketsAssistant{})
}

func (c *MockChainClient) CreateDerivativeOrder(defaultSubaccountID eth.Hash, d *DerivativeOrderData, marketAssistant MarketsAssistant) *exchangetypes.DerivativeOrder {
return &exchangetypes.DerivativeOrder{}
}
Expand Down Expand Up @@ -371,7 +367,18 @@ func (c *MockChainClient) FetchDenomDecimals(ctx context.Context, denoms []strin
}

func (c *MockChainClient) FetchChainSpotMarkets(ctx context.Context, status string, marketIDs []string) (*exchangetypes.QuerySpotMarketsResponse, error) {
return &exchangetypes.QuerySpotMarketsResponse{}, nil
var response *exchangetypes.QuerySpotMarketsResponse
var localError error
if len(c.QuerySpotMarketsResponses) > 0 {
response = c.QuerySpotMarketsResponses[0]
c.QuerySpotMarketsResponses = c.QuerySpotMarketsResponses[1:]
localError = nil
} else {
response = &exchangetypes.QuerySpotMarketsResponse{}
localError = errors.New("there are no responses configured")
}

return response, localError
}

func (c *MockChainClient) FetchChainSpotMarket(ctx context.Context, marketId string) (*exchangetypes.QuerySpotMarketResponse, error) {
Expand Down Expand Up @@ -439,7 +446,18 @@ func (c *MockChainClient) FetchChainTraderDerivativeTransientOrders(ctx context.
}

func (c *MockChainClient) FetchChainDerivativeMarkets(ctx context.Context, status string, marketIDs []string, withMidPriceAndTob bool) (*exchangetypes.QueryDerivativeMarketsResponse, error) {
return &exchangetypes.QueryDerivativeMarketsResponse{}, nil
var response *exchangetypes.QueryDerivativeMarketsResponse
var localError error
if len(c.QueryDerivativeMarketsResponses) > 0 {
response = c.QueryDerivativeMarketsResponses[0]
c.QueryDerivativeMarketsResponses = c.QueryDerivativeMarketsResponses[1:]
localError = nil
} else {
response = &exchangetypes.QueryDerivativeMarketsResponse{}
localError = errors.New("there are no responses configured")
}

return response, localError
}

func (c *MockChainClient) FetchChainDerivativeMarket(ctx context.Context, marketId string) (*exchangetypes.QueryDerivativeMarketResponse, error) {
Expand Down Expand Up @@ -543,7 +561,18 @@ func (c *MockChainClient) FetchMarketVolatility(ctx context.Context, marketId st
}

func (c *MockChainClient) FetchChainBinaryOptionsMarkets(ctx context.Context, status string) (*exchangetypes.QueryBinaryMarketsResponse, error) {
return &exchangetypes.QueryBinaryMarketsResponse{}, nil
var response *exchangetypes.QueryBinaryMarketsResponse
var localError error
if len(c.QueryBinaryMarketsResponses) > 0 {
response = c.QueryBinaryMarketsResponses[0]
c.QueryBinaryMarketsResponses = c.QueryBinaryMarketsResponses[1:]
localError = nil
} else {
response = &exchangetypes.QueryBinaryMarketsResponse{}
localError = errors.New("there are no responses configured")
}

return response, localError
}

func (c *MockChainClient) FetchTraderDerivativeConditionalOrders(ctx context.Context, subaccountId, marketId string) (*exchangetypes.QueryTraderDerivativeConditionalOrdersResponse, error) {
Expand Down Expand Up @@ -741,3 +770,7 @@ func (c *MockChainClient) FetchAddressesByRole(ctx context.Context, denom, role
func (c *MockChainClient) FetchVouchersForAddress(ctx context.Context, address string) (*permissionstypes.QueryVouchersForAddressResponse, error) {
return &permissionstypes.QueryVouchersForAddressResponse{}, nil
}

func (c *MockChainClient) GetNetwork() common.Network {
return c.Network
}
Loading

0 comments on commit 428cbcf

Please sign in to comment.