Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/v1.54.0 #258

Merged
merged 41 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
69dc9c1
Merge pull request #233 from InjectiveLabs/feat/sync_dec_with_master_…
aarmoa Aug 7, 2024
d60376e
feat: new cosmos keyring helper for injective client.
maxim-inj Sep 7, 2024
b1653df
Merge branch 'dev' into f/new-cosmos-keyring
aarmoa Sep 10, 2024
bb1f812
Remove duplicate error handling in authz_vote.go
meetrick Sep 10, 2024
fedf1a8
(feat) Add OFAC list check
shibaeff Sep 6, 2024
e009b64
fix linter
maxim-inj Sep 11, 2024
20919a1
fix pre-commit
maxim-inj Sep 11, 2024
973cf13
fix: keyring unit test when using OS keyring
maxim-inj Sep 11, 2024
f4899c9
chore: fix keyring README for grammar issues
maxim-inj Sep 11, 2024
0d5726e
Remove unused code in chain.go
shibaeff Sep 11, 2024
5f52a16
Merge pull request #236 from InjectiveLabs/ofac-list-
PavelInjective Sep 13, 2024
9dc0b69
Merge branch 'dev' into f/new-cosmos-keyring
aarmoa Sep 18, 2024
2c8f9a0
Merge pull request #235 from InjectiveLabs/f/new-cosmos-keyring
aarmoa Sep 18, 2024
1fb7e33
feat: new cosmos keyring helper for injective client.
maxim-inj Sep 7, 2024
8e504bf
fix linter
maxim-inj Sep 11, 2024
1e84488
fix pre-commit
maxim-inj Sep 11, 2024
b707ecc
fix: keyring unit test when using OS keyring
maxim-inj Sep 11, 2024
b59a66e
chore: fix keyring README for grammar issues
maxim-inj Sep 11, 2024
3b22129
Merge branch 'dev' of https://github.com/InjectiveLabs/sdk-go into fi…
aarmoa Sep 18, 2024
feafa40
Merge pull request #243 from InjectiveLabs/fix/sync_dev_after_v1_52_0
aarmoa Sep 24, 2024
17ab0d8
Merge branch 'dev' into fix/sync_dev_after_v1_52_1
aarmoa Sep 25, 2024
6e47286
Merge pull request #245 from InjectiveLabs/fix/sync_dev_after_v1_52_1
aarmoa Sep 25, 2024
48dea45
Merge branch 'dev' into 20240911_2
meetrick Sep 26, 2024
d4e225c
Merge pull request #241 from meetrick/20240911_2
aarmoa Sep 30, 2024
1ef066b
add status to tmclient
proofofze Sep 30, 2024
bb9ef54
Merge pull request #247 from InjectiveLabs/feat/add-status-to-tmclient
aarmoa Sep 30, 2024
d2c8a23
(fix) Added validation in SyncBroadcast code to avoid waiting to see …
aarmoa Oct 3, 2024
5ac7140
Merge pull request #250 from InjectiveLabs/fix/sync_dev_after_v1_52_2
PavelInjective Oct 3, 2024
213745b
(fix) Changed ofac.json file path to make it relative for compiled ap…
aarmoa Oct 9, 2024
c722ea3
(fix) Refactored OFAC tests moving them to their own file. Also impro…
aarmoa Oct 9, 2024
722a2d3
(fix) Fixed pre-commit check issue
aarmoa Oct 9, 2024
bc027f7
Merge pull request #252 from InjectiveLabs/fix/sync_dev_after_v1_53_0
aarmoa Oct 10, 2024
5aa9a30
(feat) Refactored the tokens markets initialization to get markets fr…
aarmoa Nov 11, 2024
04e9e71
(fix) Fixed ofac.json file URL and updated the local ofac.json copy
aarmoa Nov 13, 2024
c13db14
Merge branch 'master' of https://github.com/InjectiveLabs/sdk-go into…
aarmoa Nov 13, 2024
d427297
Merge pull request #257 from InjectiveLabs/feat/sync_dev_with_v1_53_1
aarmoa Nov 13, 2024
c8a8167
(fix) Renamed variable as requested in the PR review
aarmoa Nov 13, 2024
102d71e
(feat) Refactored the tokens markets initialization to get markets fr…
aarmoa Nov 11, 2024
edd6608
(fix) Renamed variable as requested in the PR review
aarmoa Nov 13, 2024
4e764e5
Merge branch 'feat/refactor_markets_tokens_initialization' of https:/…
aarmoa Nov 13, 2024
65b0d65
Merge pull request #255 from InjectiveLabs/feat/refactor_markets_toke…
aarmoa Nov 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Comment on lines +20 to +22
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Security and maintainability improvements needed for GPG key generation

Several concerns with the current implementation:

  1. The %no-protection flag makes the key vulnerable
  2. The temporary genkey file is not cleaned up
  3. The multi-line command could be more readable

Consider this more secure and maintainable approach:

-      - 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: Generate GPG key
+        run: |
+          cat > genkey <<EOF
+          Key-Type: 1
+          Key-Length: 4096
+          Subkey-Type: 1
+          Subkey-Length: 4096
+          Name-Comment: keyring_test
+          Expire-Date: 0
+          %commit
+          EOF
+          gpg --gen-key --batch genkey
+          rm genkey
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- 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: Generate GPG key
run: |
cat > genkey <<EOF
Key-Type: 1
Key-Length: 4096
Subkey-Type: 1
Subkey-Length: 4096
Name-Comment: keyring_test
Expire-Date: 0
%commit
EOF
gpg --gen-key --batch genkey
rm genkey

- name: Setup OS keystore
run: pass init keyring_test
Comment on lines +23 to +24
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling and verification for password store initialization

The current implementation doesn't handle potential failures in the prerequisite GPG key setup or verify successful initialization.

-      - name: Setup OS keystore
-        run: pass init keyring_test
+      - name: Setup OS keystore
+        run: |
+          if ! gpg --list-keys keyring_test > /dev/null 2>&1; then
+            echo "Error: GPG key 'keyring_test' not found"
+            exit 1
+          fi
+          pass init keyring_test
+          if ! pass git init > /dev/null 2>&1; then
+            echo "Error: Failed to initialize password store"
+            exit 1
+          fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Setup OS keystore
run: pass init keyring_test
- name: Setup OS keystore
run: |
if ! gpg --list-keys keyring_test > /dev/null 2>&1; then
echo "Error: GPG key 'keyring_test' not found"
exit 1
fi
pass init keyring_test
if ! pass git init > /dev/null 2>&1; then
echo "Error: Failed to initialize password store"
exit 1
fi

- 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
Loading