Skip to content

Commit 428cbcf

Browse files
Merge pull request #258 from InjectiveLabs/release/v_1_54_0
Release/v1.54.0
2 parents 935b4ad + 65b0d65 commit 428cbcf

File tree

55 files changed

+2337
-32214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2337
-32214
lines changed

.github/workflows/run-tests.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ jobs:
1515
with:
1616
go-version-file: "go.mod"
1717
check-latest: true
18+
- name: Install pass helper
19+
run: sudo apt-get update && sudo apt-get install -y pass
20+
- name: Generate GPG key
21+
run: "
22+
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"
23+
- name: Setup OS keystore
24+
run: pass init keyring_test
1825
- name: Run test and calculate coverage
1926
run: make coverage
2027
- name: Upload coverage to Codecov

.pre-commit-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ exclude: |
22
(?x)^(
33
chain/.*|
44
exchange/.*|
5-
proto/.*
5+
proto/.*|
6+
client/keyring/testdata/.*
67
)$
78
repos:
89
- repo: https://github.com/pre-commit/pre-commit-hooks

auth_vote/authz_vote.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ func main() {
2222
panic(err)
2323
}
2424

25-
if err != nil {
26-
panic(err)
27-
}
28-
2925
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
3026
os.Getenv("HOME")+"/.injectived",
3127
"injectived",

client/cert/embed.go

Lines changed: 0 additions & 1 deletion
This file was deleted.

client/cert/mainnet.crt

Lines changed: 0 additions & 31 deletions
This file was deleted.

client/cert/testnet.crt

Lines changed: 0 additions & 31 deletions
This file was deleted.

client/chain/chain.go

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,7 @@ type ChainClient interface {
127127
SynchronizeSubaccountNonce(subaccountId ethcommon.Hash) error
128128
ComputeOrderHashes(spotOrders []exchangetypes.SpotOrder, derivativeOrders []exchangetypes.DerivativeOrder, subaccountId ethcommon.Hash) (OrderHashes, error)
129129

130-
SpotOrder(defaultSubaccountID ethcommon.Hash, network common.Network, d *SpotOrderData) *exchangetypes.SpotOrder
131130
CreateSpotOrder(defaultSubaccountID ethcommon.Hash, d *SpotOrderData, marketsAssistant MarketsAssistant) *exchangetypes.SpotOrder
132-
DerivativeOrder(defaultSubaccountID ethcommon.Hash, network common.Network, d *DerivativeOrderData) *exchangetypes.DerivativeOrder
133131
CreateDerivativeOrder(defaultSubaccountID ethcommon.Hash, d *DerivativeOrderData, marketAssistant MarketsAssistant) *exchangetypes.DerivativeOrder
134132
OrderCancel(defaultSubaccountID ethcommon.Hash, d *OrderCancelData) *exchangetypes.OrderData
135133

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

296+
GetNetwork() common.Network
298297
Close()
299298
}
300299

300+
var _ ChainClient = &chainClient{}
301+
301302
type chainClient struct {
302303
ctx client.Context
303304
network common.Network
@@ -1072,16 +1073,6 @@ func (c *chainClient) GetSubAccountNonce(ctx context.Context, subaccountId ethco
10721073
return res, err
10731074
}
10741075

1075-
// Deprecated: Use CreateSpotOrder instead
1076-
func (c *chainClient) SpotOrder(defaultSubaccountID ethcommon.Hash, network common.Network, d *SpotOrderData) *exchangetypes.SpotOrder {
1077-
assistant, err := NewMarketsAssistant(network.Name)
1078-
if err != nil {
1079-
panic(err)
1080-
}
1081-
1082-
return c.CreateSpotOrder(defaultSubaccountID, d, assistant)
1083-
}
1084-
10851076
func (c *chainClient) CreateSpotOrder(defaultSubaccountID ethcommon.Hash, d *SpotOrderData, marketsAssistant MarketsAssistant) *exchangetypes.SpotOrder {
10861077

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

1108-
// Deprecated: Use CreateDerivativeOrder instead
1109-
func (c *chainClient) DerivativeOrder(defaultSubaccountID ethcommon.Hash, network common.Network, d *DerivativeOrderData) *exchangetypes.DerivativeOrder {
1110-
1111-
assistant, err := NewMarketsAssistant(network.Name)
1112-
if err != nil {
1113-
panic(err)
1114-
}
1115-
1116-
return c.CreateDerivativeOrder(defaultSubaccountID, d, assistant)
1117-
}
1118-
11191099
func (c *chainClient) CreateDerivativeOrder(defaultSubaccountID ethcommon.Hash, d *DerivativeOrderData, marketAssistant MarketsAssistant) *exchangetypes.DerivativeOrder {
11201100
market, isPresent := marketAssistant.AllDerivativeMarkets()[d.MarketId]
11211101
if !isPresent {
@@ -2667,3 +2647,7 @@ func (c *chainClient) FetchVouchersForAddress(ctx context.Context, address strin
26672647

26682648
return res, err
26692649
}
2650+
2651+
func (c *chainClient) GetNetwork() common.Network {
2652+
return c.network
2653+
}

client/chain/chain_test_support.go

Lines changed: 55 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,11 @@ import (
55
"errors"
66
"time"
77

8-
permissionstypes "github.com/InjectiveLabs/sdk-go/chain/permissions/types"
9-
108
sdkmath "cosmossdk.io/math"
11-
12-
"github.com/cosmos/cosmos-sdk/client/grpc/cmtservice"
13-
"google.golang.org/grpc"
14-
159
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
16-
exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types"
17-
chainstreamtypes "github.com/InjectiveLabs/sdk-go/chain/stream/types"
18-
tokenfactorytypes "github.com/InjectiveLabs/sdk-go/chain/tokenfactory/types"
19-
"github.com/InjectiveLabs/sdk-go/client/common"
2010
rpchttp "github.com/cometbft/cometbft/rpc/client/http"
2111
"github.com/cosmos/cosmos-sdk/client"
12+
"github.com/cosmos/cosmos-sdk/client/grpc/cmtservice"
2213
sdk "github.com/cosmos/cosmos-sdk/types"
2314
"github.com/cosmos/cosmos-sdk/types/query"
2415
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
@@ -31,10 +22,23 @@ import (
3122
ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types"
3223
ibcchanneltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
3324
eth "github.com/ethereum/go-ethereum/common"
25+
"google.golang.org/grpc"
26+
27+
exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types"
28+
permissionstypes "github.com/InjectiveLabs/sdk-go/chain/permissions/types"
29+
chainstreamtypes "github.com/InjectiveLabs/sdk-go/chain/stream/types"
30+
tokenfactorytypes "github.com/InjectiveLabs/sdk-go/chain/tokenfactory/types"
31+
"github.com/InjectiveLabs/sdk-go/client/common"
3432
)
3533

34+
var _ ChainClient = &MockChainClient{}
35+
3636
type MockChainClient struct {
37-
DenomsMetadataResponses []*banktypes.QueryDenomsMetadataResponse
37+
Network common.Network
38+
DenomsMetadataResponses []*banktypes.QueryDenomsMetadataResponse
39+
QuerySpotMarketsResponses []*exchangetypes.QuerySpotMarketsResponse
40+
QueryDerivativeMarketsResponses []*exchangetypes.QueryDerivativeMarketsResponse
41+
QueryBinaryMarketsResponses []*exchangetypes.QueryBinaryMarketsResponse
3842
}
3943

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

194-
func (c *MockChainClient) SpotOrder(defaultSubaccountID eth.Hash, network common.Network, d *SpotOrderData) *exchangetypes.SpotOrder {
195-
return c.CreateSpotOrder(defaultSubaccountID, d, MarketsAssistant{})
196-
}
197-
198198
func (c *MockChainClient) CreateSpotOrder(defaultSubaccountID eth.Hash, d *SpotOrderData, marketsAssistant MarketsAssistant) *exchangetypes.SpotOrder {
199199
return &exchangetypes.SpotOrder{}
200200
}
201201

202-
func (c *MockChainClient) DerivativeOrder(defaultSubaccountID eth.Hash, network common.Network, d *DerivativeOrderData) *exchangetypes.DerivativeOrder {
203-
return c.CreateDerivativeOrder(defaultSubaccountID, d, MarketsAssistant{})
204-
}
205-
206202
func (c *MockChainClient) CreateDerivativeOrder(defaultSubaccountID eth.Hash, d *DerivativeOrderData, marketAssistant MarketsAssistant) *exchangetypes.DerivativeOrder {
207203
return &exchangetypes.DerivativeOrder{}
208204
}
@@ -371,7 +367,18 @@ func (c *MockChainClient) FetchDenomDecimals(ctx context.Context, denoms []strin
371367
}
372368

373369
func (c *MockChainClient) FetchChainSpotMarkets(ctx context.Context, status string, marketIDs []string) (*exchangetypes.QuerySpotMarketsResponse, error) {
374-
return &exchangetypes.QuerySpotMarketsResponse{}, nil
370+
var response *exchangetypes.QuerySpotMarketsResponse
371+
var localError error
372+
if len(c.QuerySpotMarketsResponses) > 0 {
373+
response = c.QuerySpotMarketsResponses[0]
374+
c.QuerySpotMarketsResponses = c.QuerySpotMarketsResponses[1:]
375+
localError = nil
376+
} else {
377+
response = &exchangetypes.QuerySpotMarketsResponse{}
378+
localError = errors.New("there are no responses configured")
379+
}
380+
381+
return response, localError
375382
}
376383

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

441448
func (c *MockChainClient) FetchChainDerivativeMarkets(ctx context.Context, status string, marketIDs []string, withMidPriceAndTob bool) (*exchangetypes.QueryDerivativeMarketsResponse, error) {
442-
return &exchangetypes.QueryDerivativeMarketsResponse{}, nil
449+
var response *exchangetypes.QueryDerivativeMarketsResponse
450+
var localError error
451+
if len(c.QueryDerivativeMarketsResponses) > 0 {
452+
response = c.QueryDerivativeMarketsResponses[0]
453+
c.QueryDerivativeMarketsResponses = c.QueryDerivativeMarketsResponses[1:]
454+
localError = nil
455+
} else {
456+
response = &exchangetypes.QueryDerivativeMarketsResponse{}
457+
localError = errors.New("there are no responses configured")
458+
}
459+
460+
return response, localError
443461
}
444462

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

545563
func (c *MockChainClient) FetchChainBinaryOptionsMarkets(ctx context.Context, status string) (*exchangetypes.QueryBinaryMarketsResponse, error) {
546-
return &exchangetypes.QueryBinaryMarketsResponse{}, nil
564+
var response *exchangetypes.QueryBinaryMarketsResponse
565+
var localError error
566+
if len(c.QueryBinaryMarketsResponses) > 0 {
567+
response = c.QueryBinaryMarketsResponses[0]
568+
c.QueryBinaryMarketsResponses = c.QueryBinaryMarketsResponses[1:]
569+
localError = nil
570+
} else {
571+
response = &exchangetypes.QueryBinaryMarketsResponse{}
572+
localError = errors.New("there are no responses configured")
573+
}
574+
575+
return response, localError
547576
}
548577

549578
func (c *MockChainClient) FetchTraderDerivativeConditionalOrders(ctx context.Context, subaccountId, marketId string) (*exchangetypes.QueryTraderDerivativeConditionalOrdersResponse, error) {
@@ -741,3 +770,7 @@ func (c *MockChainClient) FetchAddressesByRole(ctx context.Context, denom, role
741770
func (c *MockChainClient) FetchVouchersForAddress(ctx context.Context, address string) (*permissionstypes.QueryVouchersForAddressResponse, error) {
742771
return &permissionstypes.QueryVouchersForAddressResponse{}, nil
743772
}
773+
774+
func (c *MockChainClient) GetNetwork() common.Network {
775+
return c.Network
776+
}

0 commit comments

Comments
 (0)