diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 00000000..e822c838 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,19 @@ +name: pre-commit +on: + pull_request: + push: + branches: [master, dev] + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/setup-python@v4 + - uses: actions/setup-go@v5 + with: + go-version: 1.19 + - run: go install golang.org/x/tools/cmd/goimports@latest + - run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s - -b $(go env GOPATH)/bin v1.49.0 + - run: echo "PATH=$PATH:/home/runner/go/bin" >> $GITHUB_ENV + - uses: actions/checkout@v3 + - uses: pre-commit/action@v2.0.2 diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 00000000..c95973fc --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,20 @@ +name: run-tests +on: + pull_request: + push: + branches: [ master, dev ] + +jobs: + run-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 2 + - uses: actions/setup-go@v5 + with: + go-version: 1.19 + - name: Run test and calculate coverage + run: make coverage + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 diff --git a/.gitignore b/.gitignore index 23bbb47f..8f38a601 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .idea/ .chain_cookie .exchange_cookie +coverage.out diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..f35e0ca6 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,20 @@ +exclude: | + (?x)^( + proto/.*| + exchange/.* + )$ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: end-of-file-fixer + - id: check-yaml + - repo: https://github.com/dnephin/pre-commit-golang + rev: v0.5.0 + hooks: + - id: go-fmt + - id: go-imports + - id: golangci-lint + args: [--timeout=15m] diff --git a/LICENSE.md b/LICENSE.md index fd30af8c..1d5c5b7c 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -200,4 +200,4 @@ Copyright © 2020 - 2022 Injective Labs Inc. (https://injectivelabs.org/) distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file + limitations under the License. diff --git a/Makefile b/Makefile index a0ceca7c..627437a9 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ copy-exchange-client: cp -r ../injective-indexer/api/gen/grpc/injective_derivative_exchange_rpc/pb exchange/derivative_exchange_rpc/pb cp -r ../injective-indexer/api/gen/grpc/injective_portfolio_rpc/pb exchange/portfolio_rpc/pb -.PHONY: copy-exchange-client +.PHONY: copy-exchange-client tests coverage copy-chain-types: cp ../injective-core/injective-chain/types/*.go chain/types @@ -53,3 +53,8 @@ copy-chain-types: 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" + +tests: + go test -race ./client/... ./ethereum/... +coverage: + go test -race -coverprofile=coverage.out -covermode=atomic ./client/... ./ethereum/... diff --git a/NOTICE.md b/NOTICE.md index 68e8c372..9e73b26c 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -5,4 +5,4 @@ Copyright © 2020 - 2022 Injective Labs Inc. (https://injectivelabs.org/) Originally released by Injective Labs Inc. under:
Apache License
Version 2.0, January 2004
-http://www.apache.org/licenses/ +http://www.apache.org/licenses/ diff --git a/README.md b/README.md index b5f92d4d..1ab21609 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Injective Protocol Golang SDK 🌟 +[![codecov](https://codecov.io/gh/InjectiveLabs/sdk-go/graph/badge.svg?token=XDGZV265EE)](https://codecov.io/gh/InjectiveLabs/sdk-go) + --- ## 📚 Getting Started @@ -65,4 +67,4 @@ Copyright © 2020 - 2022 Injective Labs Inc. (https://injectivelabs.org/) Originally released by Injective Labs Inc. under:
Apache License
Version 2.0, January 2004
-http://www.apache.org/licenses/ +http://www.apache.org/licenses/ diff --git a/chain/auction/types/auction.pb.go b/chain/auction/types/auction.pb.go index d0d2e780..0d7b6220 100644 --- a/chain/auction/types/auction.pb.go +++ b/chain/auction/types/auction.pb.go @@ -5,13 +5,14 @@ package types import ( fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/auction/types/genesis.pb.go b/chain/auction/types/genesis.pb.go index d1452e2a..c7c3ab27 100644 --- a/chain/auction/types/genesis.pb.go +++ b/chain/auction/types/genesis.pb.go @@ -5,11 +5,12 @@ package types import ( fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" io "io" math "math" math_bits "math/bits" + + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/auction/types/query.pb.go b/chain/auction/types/query.pb.go index ec9d8b68..bde86cb4 100644 --- a/chain/auction/types/query.pb.go +++ b/chain/auction/types/query.pb.go @@ -6,6 +6,10 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" @@ -15,9 +19,6 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/auction/types/tx.pb.go b/chain/auction/types/tx.pb.go index 57d3be57..b592915e 100644 --- a/chain/auction/types/tx.pb.go +++ b/chain/auction/types/tx.pb.go @@ -6,6 +6,10 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + _ "github.com/cosmos/cosmos-proto" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/msgservice" @@ -15,9 +19,6 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/crypto/ethsecp256k1/keys.pb.go b/chain/crypto/ethsecp256k1/keys.pb.go index c445cb5b..1f19c66a 100644 --- a/chain/crypto/ethsecp256k1/keys.pb.go +++ b/chain/crypto/ethsecp256k1/keys.pb.go @@ -5,11 +5,12 @@ package ethsecp256k1 import ( fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" io "io" math "math" math_bits "math/bits" + + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/exchange/types/authz.pb.go b/chain/exchange/types/authz.pb.go index e97e8a78..7989416a 100644 --- a/chain/exchange/types/authz.pb.go +++ b/chain/exchange/types/authz.pb.go @@ -5,11 +5,12 @@ package types import ( fmt "fmt" - _ "github.com/cosmos/cosmos-proto" - proto "github.com/cosmos/gogoproto/proto" io "io" math "math" math_bits "math/bits" + + _ "github.com/cosmos/cosmos-proto" + proto "github.com/cosmos/gogoproto/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/exchange/types/events.pb.go b/chain/exchange/types/events.pb.go index fde0ea75..0b05ad3a 100644 --- a/chain/exchange/types/events.pb.go +++ b/chain/exchange/types/events.pb.go @@ -5,14 +5,15 @@ package types import ( fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + _ "github.com/InjectiveLabs/sdk-go/chain/oracle/types" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/exchange/types/exchange.pb.go b/chain/exchange/types/exchange.pb.go index d462df25..1db8e74d 100644 --- a/chain/exchange/types/exchange.pb.go +++ b/chain/exchange/types/exchange.pb.go @@ -5,14 +5,15 @@ package types import ( fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + types1 "github.com/InjectiveLabs/sdk-go/chain/oracle/types" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/exchange/types/genesis.pb.go b/chain/exchange/types/genesis.pb.go index 92998d1d..d83d83f7 100644 --- a/chain/exchange/types/genesis.pb.go +++ b/chain/exchange/types/genesis.pb.go @@ -5,12 +5,13 @@ package types import ( fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" io "io" math "math" math_bits "math/bits" + + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/exchange/types/proposal.pb.go b/chain/exchange/types/proposal.pb.go index 6f3eee76..8ec78f6e 100644 --- a/chain/exchange/types/proposal.pb.go +++ b/chain/exchange/types/proposal.pb.go @@ -5,6 +5,10 @@ package types import ( fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + types "github.com/InjectiveLabs/sdk-go/chain/oracle/types" _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/cosmos-sdk/types" @@ -13,9 +17,6 @@ import ( types1 "github.com/cosmos/cosmos-sdk/x/distribution/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/exchange/types/query.pb.go b/chain/exchange/types/query.pb.go index b4111c76..d95ca74e 100644 --- a/chain/exchange/types/query.pb.go +++ b/chain/exchange/types/query.pb.go @@ -6,6 +6,10 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + types "github.com/InjectiveLabs/sdk-go/chain/oracle/types" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" @@ -15,9 +19,6 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/exchange/types/tx.pb.go b/chain/exchange/types/tx.pb.go index 682a9a23..b36abb8e 100644 --- a/chain/exchange/types/tx.pb.go +++ b/chain/exchange/types/tx.pb.go @@ -6,6 +6,10 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + types1 "github.com/InjectiveLabs/sdk-go/chain/oracle/types" _ "github.com/cosmos/cosmos-proto" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" @@ -18,9 +22,6 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/exchange/types/wasm_maker_contract.go b/chain/exchange/types/wasm_maker_contract.go index ca0a9227..8b75eb9f 100644 --- a/chain/exchange/types/wasm_maker_contract.go +++ b/chain/exchange/types/wasm_maker_contract.go @@ -1,7 +1,7 @@ package types import ( - sdk "github.com/cosmos/cosmos-sdk/types" + "cosmossdk.io/math" ) type MintToUser struct { @@ -13,7 +13,7 @@ type MintToUserMsg struct { MintToUser MintToUser `json:"mint_to_user"` } -func NewMintToUserMsg(subaccountIDSender string, amount sdk.Int) MintToUserMsg { +func NewMintToUserMsg(subaccountIDSender string, amount math.Int) MintToUserMsg { return MintToUserMsg{ MintToUser: MintToUser{ SubaccountIDSender: subaccountIDSender, diff --git a/chain/insurance/types/genesis.pb.go b/chain/insurance/types/genesis.pb.go index 2bd30a00..09aa4be5 100644 --- a/chain/insurance/types/genesis.pb.go +++ b/chain/insurance/types/genesis.pb.go @@ -5,11 +5,12 @@ package types import ( fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" io "io" math "math" math_bits "math/bits" + + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/insurance/types/insurance.pb.go b/chain/insurance/types/insurance.pb.go index ba256531..bf9d978e 100644 --- a/chain/insurance/types/insurance.pb.go +++ b/chain/insurance/types/insurance.pb.go @@ -5,6 +5,11 @@ package types import ( fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + time "time" + types "github.com/InjectiveLabs/sdk-go/chain/oracle/types" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types1 "github.com/cosmos/cosmos-sdk/types" @@ -13,10 +18,6 @@ import ( github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" _ "google.golang.org/protobuf/types/known/durationpb" _ "google.golang.org/protobuf/types/known/timestamppb" - io "io" - math "math" - math_bits "math/bits" - time "time" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/insurance/types/query.pb.go b/chain/insurance/types/query.pb.go index 4b79acab..37fdf2bd 100644 --- a/chain/insurance/types/query.pb.go +++ b/chain/insurance/types/query.pb.go @@ -6,6 +6,10 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" @@ -14,9 +18,6 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/insurance/types/tx.pb.go b/chain/insurance/types/tx.pb.go index 846919ee..1113a9f8 100644 --- a/chain/insurance/types/tx.pb.go +++ b/chain/insurance/types/tx.pb.go @@ -6,6 +6,10 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + types "github.com/InjectiveLabs/sdk-go/chain/oracle/types" _ "github.com/cosmos/cosmos-proto" types1 "github.com/cosmos/cosmos-sdk/types" @@ -16,9 +20,6 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/ocr/types/genesis.pb.go b/chain/ocr/types/genesis.pb.go index 210d8023..68aee64a 100644 --- a/chain/ocr/types/genesis.pb.go +++ b/chain/ocr/types/genesis.pb.go @@ -5,12 +5,13 @@ package types import ( fmt "fmt" - types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" io "io" math "math" math_bits "math/bits" + + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/ocr/types/ocr.pb.go b/chain/ocr/types/ocr.pb.go index d80ac284..4c0279d4 100644 --- a/chain/ocr/types/ocr.pb.go +++ b/chain/ocr/types/ocr.pb.go @@ -5,6 +5,11 @@ package types import ( fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + time "time" + _ "github.com/cosmos/cosmos-proto" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" @@ -12,10 +17,6 @@ import ( proto "github.com/cosmos/gogoproto/proto" github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" _ "google.golang.org/protobuf/types/known/timestamppb" - io "io" - math "math" - math_bits "math/bits" - time "time" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/ocr/types/query.pb.go b/chain/ocr/types/query.pb.go index 5320b68e..3000c85e 100644 --- a/chain/ocr/types/query.pb.go +++ b/chain/ocr/types/query.pb.go @@ -6,6 +6,10 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" @@ -14,9 +18,6 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/ocr/types/tx.pb.go b/chain/ocr/types/tx.pb.go index 76af8a8c..b1574018 100644 --- a/chain/ocr/types/tx.pb.go +++ b/chain/ocr/types/tx.pb.go @@ -6,6 +6,10 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + _ "github.com/cosmos/cosmos-proto" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" @@ -16,9 +20,6 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/oracle/types/events.pb.go b/chain/oracle/types/events.pb.go index d8b8118e..4f5e3139 100644 --- a/chain/oracle/types/events.pb.go +++ b/chain/oracle/types/events.pb.go @@ -5,13 +5,14 @@ package types import ( fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + _ "github.com/cosmos/cosmos-sdk/types" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/oracle/types/genesis.pb.go b/chain/oracle/types/genesis.pb.go index 04cb607c..df592e98 100644 --- a/chain/oracle/types/genesis.pb.go +++ b/chain/oracle/types/genesis.pb.go @@ -5,11 +5,12 @@ package types import ( fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" io "io" math "math" math_bits "math/bits" + + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/oracle/types/oracle.pb.go b/chain/oracle/types/oracle.pb.go index 156c1208..65482710 100644 --- a/chain/oracle/types/oracle.pb.go +++ b/chain/oracle/types/oracle.pb.go @@ -5,14 +5,15 @@ package types import ( fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" golang_proto "github.com/golang/protobuf/proto" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/oracle/types/proposal.pb.go b/chain/oracle/types/proposal.pb.go index 2606c3f3..ae4c5169 100644 --- a/chain/oracle/types/proposal.pb.go +++ b/chain/oracle/types/proposal.pb.go @@ -5,13 +5,14 @@ package types import ( fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/oracle/types/query.pb.go b/chain/oracle/types/query.pb.go index d82bee6f..4581b81c 100644 --- a/chain/oracle/types/query.pb.go +++ b/chain/oracle/types/query.pb.go @@ -6,6 +6,10 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" @@ -14,9 +18,6 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/oracle/types/tx.pb.go b/chain/oracle/types/tx.pb.go index c993e9d9..165fcf35 100644 --- a/chain/oracle/types/tx.pb.go +++ b/chain/oracle/types/tx.pb.go @@ -6,6 +6,10 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + _ "github.com/cosmos/cosmos-proto" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/msgservice" @@ -15,9 +19,6 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/peggy/types/attestation.pb.go b/chain/peggy/types/attestation.pb.go index 0d591bd2..3ea675f8 100644 --- a/chain/peggy/types/attestation.pb.go +++ b/chain/peggy/types/attestation.pb.go @@ -5,13 +5,14 @@ package types import ( fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + types "github.com/cosmos/cosmos-sdk/codec/types" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/peggy/types/batch.pb.go b/chain/peggy/types/batch.pb.go index 083ea8c7..65fac894 100644 --- a/chain/peggy/types/batch.pb.go +++ b/chain/peggy/types/batch.pb.go @@ -5,10 +5,11 @@ package types import ( fmt "fmt" - proto "github.com/cosmos/gogoproto/proto" io "io" math "math" math_bits "math/bits" + + proto "github.com/cosmos/gogoproto/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/peggy/types/ethereum_signer.pb.go b/chain/peggy/types/ethereum_signer.pb.go index d52e1b45..08af7a8a 100644 --- a/chain/peggy/types/ethereum_signer.pb.go +++ b/chain/peggy/types/ethereum_signer.pb.go @@ -5,9 +5,10 @@ package types import ( fmt "fmt" + math "math" + _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" - math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/peggy/types/events.pb.go b/chain/peggy/types/events.pb.go index 13168705..571bb00b 100644 --- a/chain/peggy/types/events.pb.go +++ b/chain/peggy/types/events.pb.go @@ -5,12 +5,13 @@ package types import ( fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" io "io" math "math" math_bits "math/bits" + + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/peggy/types/genesis.pb.go b/chain/peggy/types/genesis.pb.go index 197630ab..e4baffbc 100644 --- a/chain/peggy/types/genesis.pb.go +++ b/chain/peggy/types/genesis.pb.go @@ -5,12 +5,13 @@ package types import ( fmt "fmt" - _ "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" io "io" math "math" math_bits "math/bits" + + _ "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/peggy/types/msgs.pb.go b/chain/peggy/types/msgs.pb.go index 6bf0619c..7797fcfe 100644 --- a/chain/peggy/types/msgs.pb.go +++ b/chain/peggy/types/msgs.pb.go @@ -6,6 +6,10 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + _ "github.com/cosmos/cosmos-proto" types1 "github.com/cosmos/cosmos-sdk/codec/types" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" @@ -18,9 +22,6 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/peggy/types/params.pb.go b/chain/peggy/types/params.pb.go index f7932952..7afc74dd 100644 --- a/chain/peggy/types/params.pb.go +++ b/chain/peggy/types/params.pb.go @@ -5,13 +5,14 @@ package types import ( fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/peggy/types/pool.pb.go b/chain/peggy/types/pool.pb.go index a7eabb67..68e76b1a 100644 --- a/chain/peggy/types/pool.pb.go +++ b/chain/peggy/types/pool.pb.go @@ -5,12 +5,13 @@ package types import ( fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" io "io" math "math" math_bits "math/bits" + + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/peggy/types/proposal.pb.go b/chain/peggy/types/proposal.pb.go index dd9ece2a..242fd142 100644 --- a/chain/peggy/types/proposal.pb.go +++ b/chain/peggy/types/proposal.pb.go @@ -5,12 +5,13 @@ package types import ( fmt "fmt" - _ "github.com/cosmos/cosmos-proto" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" io "io" math "math" math_bits "math/bits" + + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/peggy/types/query.pb.go b/chain/peggy/types/query.pb.go index 56cc080b..daac4c68 100644 --- a/chain/peggy/types/query.pb.go +++ b/chain/peggy/types/query.pb.go @@ -6,6 +6,10 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" @@ -13,9 +17,6 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/peggy/types/types.pb.go b/chain/peggy/types/types.pb.go index 66673a3c..29281874 100644 --- a/chain/peggy/types/types.pb.go +++ b/chain/peggy/types/types.pb.go @@ -5,12 +5,13 @@ package types import ( fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" io "io" math "math" math_bits "math/bits" + + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/stream/types/query.pb.go b/chain/stream/types/query.pb.go index 1e7e3f0c..fcbb41c6 100644 --- a/chain/stream/types/query.pb.go +++ b/chain/stream/types/query.pb.go @@ -6,6 +6,10 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + types "github.com/InjectiveLabs/sdk-go/chain/exchange/types" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types1 "github.com/cosmos/cosmos-sdk/types" @@ -15,9 +19,6 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/tokenfactory/types/authorityMetadata.pb.go b/chain/tokenfactory/types/authorityMetadata.pb.go index 51337590..8ee31dd6 100644 --- a/chain/tokenfactory/types/authorityMetadata.pb.go +++ b/chain/tokenfactory/types/authorityMetadata.pb.go @@ -5,12 +5,13 @@ package types import ( fmt "fmt" - _ "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" io "io" math "math" math_bits "math/bits" + + _ "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/tokenfactory/types/events.pb.go b/chain/tokenfactory/types/events.pb.go index 96598dc0..17d0804f 100644 --- a/chain/tokenfactory/types/events.pb.go +++ b/chain/tokenfactory/types/events.pb.go @@ -5,13 +5,14 @@ package types import ( fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + types "github.com/cosmos/cosmos-sdk/types" types1 "github.com/cosmos/cosmos-sdk/x/bank/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/tokenfactory/types/genesis.pb.go b/chain/tokenfactory/types/genesis.pb.go index 85a59947..9f623873 100644 --- a/chain/tokenfactory/types/genesis.pb.go +++ b/chain/tokenfactory/types/genesis.pb.go @@ -5,11 +5,12 @@ package types import ( fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" io "io" math "math" math_bits "math/bits" + + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/tokenfactory/types/params.pb.go b/chain/tokenfactory/types/params.pb.go index 9d705d9c..089844bc 100644 --- a/chain/tokenfactory/types/params.pb.go +++ b/chain/tokenfactory/types/params.pb.go @@ -5,14 +5,15 @@ package types import ( fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + _ "github.com/cosmos/cosmos-proto" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/tokenfactory/types/query.pb.go b/chain/tokenfactory/types/query.pb.go index 9d7f5742..f8afd710 100644 --- a/chain/tokenfactory/types/query.pb.go +++ b/chain/tokenfactory/types/query.pb.go @@ -6,6 +6,10 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + _ "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" @@ -14,9 +18,6 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/tokenfactory/types/tx.pb.go b/chain/tokenfactory/types/tx.pb.go index 214084f8..33e4eb33 100644 --- a/chain/tokenfactory/types/tx.pb.go +++ b/chain/tokenfactory/types/tx.pb.go @@ -6,6 +6,10 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + _ "github.com/cosmos/cosmos-proto" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/msgservice" @@ -16,9 +20,6 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/types/account.pb.go b/chain/types/account.pb.go index cb352b87..59afd490 100644 --- a/chain/types/account.pb.go +++ b/chain/types/account.pb.go @@ -5,13 +5,14 @@ package types import ( fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + _ "github.com/cosmos/cosmos-proto" types "github.com/cosmos/cosmos-sdk/x/auth/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/types/tx_ext.pb.go b/chain/types/tx_ext.pb.go index 3b5e02ae..5f48212a 100644 --- a/chain/types/tx_ext.pb.go +++ b/chain/types/tx_ext.pb.go @@ -5,11 +5,12 @@ package types import ( fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" io "io" math "math" math_bits "math/bits" + + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/types/tx_response.pb.go b/chain/types/tx_response.pb.go index e4d2327b..de584707 100644 --- a/chain/types/tx_response.pb.go +++ b/chain/types/tx_response.pb.go @@ -5,10 +5,11 @@ package types import ( fmt "fmt" - proto "github.com/cosmos/gogoproto/proto" io "io" math "math" math_bits "math/bits" + + proto "github.com/cosmos/gogoproto/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/wasmx/types/events.pb.go b/chain/wasmx/types/events.pb.go index 9f3f7471..a211e66a 100644 --- a/chain/wasmx/types/events.pb.go +++ b/chain/wasmx/types/events.pb.go @@ -5,11 +5,12 @@ package types import ( fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" io "io" math "math" math_bits "math/bits" + + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/wasmx/types/genesis.pb.go b/chain/wasmx/types/genesis.pb.go index fe9147ae..c9405de5 100644 --- a/chain/wasmx/types/genesis.pb.go +++ b/chain/wasmx/types/genesis.pb.go @@ -5,11 +5,12 @@ package types import ( fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" io "io" math "math" math_bits "math/bits" + + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/wasmx/types/proposal.pb.go b/chain/wasmx/types/proposal.pb.go index 128ae2cc..4e85c1c3 100644 --- a/chain/wasmx/types/proposal.pb.go +++ b/chain/wasmx/types/proposal.pb.go @@ -5,13 +5,14 @@ package types import ( fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + types "github.com/CosmWasm/wasmd/x/wasm/types" _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/wasmx/types/query.pb.go b/chain/wasmx/types/query.pb.go index a94efce7..1b1f4cdb 100644 --- a/chain/wasmx/types/query.pb.go +++ b/chain/wasmx/types/query.pb.go @@ -6,6 +6,10 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" @@ -13,9 +17,6 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/wasmx/types/tx.pb.go b/chain/wasmx/types/tx.pb.go index 02545b39..908d6219 100644 --- a/chain/wasmx/types/tx.pb.go +++ b/chain/wasmx/types/tx.pb.go @@ -6,6 +6,10 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/cosmos-sdk/codec/types" _ "github.com/cosmos/cosmos-sdk/types/msgservice" @@ -15,9 +19,6 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/chain/wasmx/types/wasmx.pb.go b/chain/wasmx/types/wasmx.pb.go index 053a0a76..e3e8dee8 100644 --- a/chain/wasmx/types/wasmx.pb.go +++ b/chain/wasmx/types/wasmx.pb.go @@ -5,11 +5,12 @@ package types import ( fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" io "io" math "math" math_bits "math/bits" + + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/client/chain/chain.go b/client/chain/chain.go index d921cab5..31dd4a65 100644 --- a/client/chain/chain.go +++ b/client/chain/chain.go @@ -6,7 +6,6 @@ import ( "encoding/hex" "encoding/json" "fmt" - "github.com/cosmos/cosmos-sdk/types/query" "math" "os" "strconv" @@ -15,6 +14,10 @@ import ( "sync/atomic" "time" + "github.com/cosmos/cosmos-sdk/types/query" + + "google.golang.org/grpc/credentials/insecure" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" log "github.com/InjectiveLabs/suplog" rpchttp "github.com/cometbft/cometbft/rpc/client/http" @@ -162,10 +165,9 @@ type chainClient struct { chainStreamConn *grpc.ClientConn txFactory tx.Factory - fromAddress sdk.AccAddress - doneC chan bool - msgC chan sdk.Msg - syncMux *sync.Mutex + doneC chan bool + msgC chan sdk.Msg + syncMux *sync.Mutex cancelCtx context.Context cancelFn func() @@ -228,7 +230,7 @@ func NewChainClient( if opts.TLSCert != nil { conn, err = grpc.Dial(network.ChainGrpcEndpoint, grpc.WithTransportCredentials(opts.TLSCert), grpc.WithContextDialer(common.DialerFunc)) } else { - conn, err = grpc.Dial(network.ChainGrpcEndpoint, grpc.WithInsecure(), grpc.WithContextDialer(common.DialerFunc)) + conn, err = grpc.Dial(network.ChainGrpcEndpoint, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithContextDialer(common.DialerFunc)) stickySessionEnabled = false } if err != nil { @@ -240,7 +242,7 @@ func NewChainClient( if opts.TLSCert != nil { chainStreamConn, err = grpc.Dial(network.ChainStreamGrpcEndpoint, grpc.WithTransportCredentials(opts.TLSCert), grpc.WithContextDialer(common.DialerFunc)) } else { - chainStreamConn, err = grpc.Dial(network.ChainStreamGrpcEndpoint, grpc.WithInsecure(), grpc.WithContextDialer(common.DialerFunc)) + chainStreamConn, err = grpc.Dial(network.ChainStreamGrpcEndpoint, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithContextDialer(common.DialerFunc)) } if err != nil { err = errors.Wrapf(err, "failed to connect to the chain stream gRPC: %s", network.ChainStreamGrpcEndpoint) @@ -389,7 +391,10 @@ func (c *chainClient) getAccSeq() uint64 { func (c *chainClient) requestCookie() metadata.MD { var header metadata.MD - c.txClient.GetTx(context.Background(), &txtypes.GetTxRequest{}, grpc.Header(&header)) + _, err := c.txClient.GetTx(context.Background(), &txtypes.GetTxRequest{}, grpc.Header(&header)) + if err != nil { + panic(err) + } return header } @@ -527,16 +532,18 @@ func (c *chainClient) SyncBroadcastMsg(msgs ...sdk.Msg) (*txtypes.BroadcastTxRes c.syncMux.Lock() defer c.syncMux.Unlock() - c.txFactory = c.txFactory.WithSequence(c.accSeq) + sequence := c.getAccSeq() + c.txFactory = c.txFactory.WithSequence(sequence) c.txFactory = c.txFactory.WithAccountNumber(c.accNum) res, err := c.broadcastTx(c.ctx, c.txFactory, true, msgs...) if err != nil { if strings.Contains(err.Error(), "account sequence mismatch") { c.syncNonce() - c.txFactory = c.txFactory.WithSequence(c.accSeq) + sequence := c.getAccSeq() + c.txFactory = c.txFactory.WithSequence(sequence) c.txFactory = c.txFactory.WithAccountNumber(c.accNum) - log.Debugln("retrying broadcastTx with nonce", c.accSeq) + log.Debugln("retrying broadcastTx with nonce", sequence) res, err = c.broadcastTx(c.ctx, c.txFactory, true, msgs...) } if err != nil { @@ -546,8 +553,6 @@ func (c *chainClient) SyncBroadcastMsg(msgs ...sdk.Msg) (*txtypes.BroadcastTxRes } } - c.accSeq++ - return res, nil } @@ -591,15 +596,17 @@ func (c *chainClient) AsyncBroadcastMsg(msgs ...sdk.Msg) (*txtypes.BroadcastTxRe c.syncMux.Lock() defer c.syncMux.Unlock() - c.txFactory = c.txFactory.WithSequence(c.accSeq) + sequence := c.getAccSeq() + c.txFactory = c.txFactory.WithSequence(sequence) c.txFactory = c.txFactory.WithAccountNumber(c.accNum) res, err := c.broadcastTx(c.ctx, c.txFactory, false, msgs...) if err != nil { if strings.Contains(err.Error(), "account sequence mismatch") { c.syncNonce() - c.txFactory = c.txFactory.WithSequence(c.accSeq) + sequence := c.getAccSeq() + c.txFactory = c.txFactory.WithSequence(sequence) c.txFactory = c.txFactory.WithAccountNumber(c.accNum) - log.Debugln("retrying broadcastTx with nonce", c.accSeq) + log.Debugln("retrying broadcastTx with nonce", sequence) res, err = c.broadcastTx(c.ctx, c.txFactory, false, msgs...) } if err != nil { @@ -609,8 +616,6 @@ func (c *chainClient) AsyncBroadcastMsg(msgs ...sdk.Msg) (*txtypes.BroadcastTxRe } } - c.accSeq++ - return res, nil } @@ -847,16 +852,18 @@ func (c *chainClient) runBatchBroadcast() { submitBatch := func(toSubmit []sdk.Msg) { c.syncMux.Lock() defer c.syncMux.Unlock() - c.txFactory = c.txFactory.WithSequence(c.accSeq) + sequence := c.getAccSeq() + c.txFactory = c.txFactory.WithSequence(sequence) c.txFactory = c.txFactory.WithAccountNumber(c.accNum) - log.Debugln("broadcastTx with nonce", c.accSeq) + log.Debugln("broadcastTx with nonce", sequence) res, err := c.broadcastTx(c.ctx, c.txFactory, true, toSubmit...) if err != nil { if strings.Contains(err.Error(), "account sequence mismatch") { c.syncNonce() - c.txFactory = c.txFactory.WithSequence(c.accSeq) + sequence := c.getAccSeq() + c.txFactory = c.txFactory.WithSequence(sequence) c.txFactory = c.txFactory.WithAccountNumber(c.accNum) - log.Debugln("retrying broadcastTx with nonce", c.accSeq) + log.Debugln("retrying broadcastTx with nonce", sequence) res, err = c.broadcastTx(c.ctx, c.txFactory, true, toSubmit...) } if err != nil { @@ -873,8 +880,6 @@ func (c *chainClient) runBatchBroadcast() { log.WithField("txHash", res.TxResponse.TxHash).Debugln("msg batch broadcasted successfully at height", res.TxResponse.Height) } - c.accSeq++ - log.Debugln("nonce incremented to", c.accSeq) log.Debugln("gas wanted: ", c.gasWanted) } @@ -1221,7 +1226,12 @@ func (c *chainClient) StreamEventOrderFail(sender string, failEventCh chan map[s panic(err) } } - defer cometbftClient.Stop() + defer func() { + err := cometbftClient.Stop() + if err != nil { + panic(err) + } + }() c.StreamEventOrderFailWithWebsocket(sender, cometbftClient, failEventCh) } @@ -1275,7 +1285,12 @@ func (c *chainClient) StreamOrderbookUpdateEvents(orderbookType OrderbookType, m panic(err) } } - defer cometbftClient.Stop() + defer func() { + err := cometbftClient.Stop() + if err != nil { + panic(err) + } + }() c.StreamOrderbookUpdateEventsWithWebsocket(orderbookType, marketIds, cometbftClient, orderbookCh) diff --git a/client/chain/chain_test.go b/client/chain/chain_test.go index 0ec9bde8..ed55ed2a 100644 --- a/client/chain/chain_test.go +++ b/client/chain/chain_test.go @@ -1,14 +1,15 @@ package chain import ( + "os" + "testing" + "github.com/InjectiveLabs/sdk-go/client" "github.com/InjectiveLabs/sdk-go/client/common" rpchttp "github.com/cometbft/cometbft/rpc/client/http" "github.com/cosmos/cosmos-sdk/crypto/keyring" cosmtypes "github.com/cosmos/cosmos-sdk/types" eth "github.com/ethereum/go-ethereum/common" - "os" - "testing" ) func accountForTests() (cosmtypes.AccAddress, keyring.Keyring, error) { diff --git a/client/chain/chain_test_support.go b/client/chain/chain_test_support.go index eba8af44..402541b8 100644 --- a/client/chain/chain_test_support.go +++ b/client/chain/chain_test_support.go @@ -3,6 +3,8 @@ package chain import ( "context" "errors" + "time" + 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" @@ -17,7 +19,6 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" eth "github.com/ethereum/go-ethereum/common" "google.golang.org/grpc" - "time" ) type MockChainClient struct { diff --git a/client/chain/markets_assistant.go b/client/chain/markets_assistant.go index f4d87b32..10b2b188 100644 --- a/client/chain/markets_assistant.go +++ b/client/chain/markets_assistant.go @@ -3,18 +3,19 @@ package chain import ( "context" "fmt" + "path" + "runtime" + "strings" + "sync" + "github.com/InjectiveLabs/sdk-go/client/core" "github.com/InjectiveLabs/sdk-go/client/exchange" - injective_derivative_exchange_rpcpb "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" - injective_spot_exchange_rpcpb "github.com/InjectiveLabs/sdk-go/exchange/spot_exchange_rpc/pb" + derivativeExchangePB "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" + spotExchangePB "github.com/InjectiveLabs/sdk-go/exchange/spot_exchange_rpc/pb" "github.com/cosmos/cosmos-sdk/types/query" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/shopspring/decimal" "gopkg.in/ini.v1" - "path" - "runtime" - "strings" - "sync" ) var legacyMarketAssistantLazyInitialization sync.Once @@ -139,10 +140,10 @@ func NewMarketsAssistant(networkName string) (MarketsAssistant, error) { func NewMarketsAssistantInitializedFromChain(ctx context.Context, exchangeClient exchange.ExchangeClient) (MarketsAssistant, error) { assistant := newMarketsAssistant() - spotMarketsRequest := injective_spot_exchange_rpcpb.MarketsRequest{ + spotMarketsRequest := spotExchangePB.MarketsRequest{ MarketStatus: "active", } - spotMarkets, err := exchangeClient.GetSpotMarkets(ctx, spotMarketsRequest) + spotMarkets, err := exchangeClient.GetSpotMarkets(ctx, &spotMarketsRequest) if err != nil { return assistant, err @@ -185,10 +186,10 @@ func NewMarketsAssistantInitializedFromChain(ctx context.Context, exchangeClient } } - derivativeMarketsRequest := injective_derivative_exchange_rpcpb.MarketsRequest{ + derivativeMarketsRequest := derivativeExchangePB.MarketsRequest{ MarketStatus: "active", } - derivativeMarkets, err := exchangeClient.GetDerivativeMarkets(ctx, derivativeMarketsRequest) + derivativeMarkets, err := exchangeClient.GetDerivativeMarkets(ctx, &derivativeMarketsRequest) if err != nil { return assistant, err @@ -264,7 +265,7 @@ func uniqueSymbol(symbol string, denom string, tokenMetaSymbol string, tokenMeta return uniqueSymbol } -func spotTokenRepresentation(symbol string, tokenMeta *injective_spot_exchange_rpcpb.TokenMeta, denom string, assistant *MarketsAssistant) core.Token { +func spotTokenRepresentation(symbol string, tokenMeta *spotExchangePB.TokenMeta, denom string, assistant *MarketsAssistant) core.Token { _, isPresent := assistant.tokensByDenom[denom] if !isPresent { @@ -287,7 +288,7 @@ func spotTokenRepresentation(symbol string, tokenMeta *injective_spot_exchange_r return assistant.tokensByDenom[denom] } -func derivativeTokenRepresentation(symbol string, tokenMeta *injective_derivative_exchange_rpcpb.TokenMeta, denom string, assistant *MarketsAssistant) core.Token { +func derivativeTokenRepresentation(symbol string, tokenMeta *derivativeExchangePB.TokenMeta, denom string, assistant *MarketsAssistant) core.Token { _, isPresent := assistant.tokensByDenom[denom] if !isPresent { diff --git a/client/chain/markets_assistant_test.go b/client/chain/markets_assistant_test.go index 2195b9c9..12ffb0bd 100644 --- a/client/chain/markets_assistant_test.go +++ b/client/chain/markets_assistant_test.go @@ -2,13 +2,14 @@ package chain import ( "context" + "strings" + "testing" + "github.com/InjectiveLabs/sdk-go/client/exchange" derivativeExchangePB "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" spotExchangePB "github.com/InjectiveLabs/sdk-go/exchange/spot_exchange_rpc/pb" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/stretchr/testify/assert" - "strings" - "testing" ) func TestMarketAssistantCreationUsingMarketsFromExchange(t *testing.T) { @@ -19,14 +20,14 @@ func TestMarketAssistantCreationUsingMarketsFromExchange(t *testing.T) { apeUsdtSpotMarketInfo := createAPEUSDTSpotMarketInfo() btcUsdtDerivativeMarketInfo := createBTCUSDTDerivativeMarketInfo() - spotMarketInfos = append(spotMarketInfos, &injUsdtSpotMarketInfo) - spotMarketInfos = append(spotMarketInfos, &apeUsdtSpotMarketInfo) - derivativeMarketInfos = append(derivativeMarketInfos, &btcUsdtDerivativeMarketInfo) + spotMarketInfos = append(spotMarketInfos, injUsdtSpotMarketInfo) + spotMarketInfos = append(spotMarketInfos, apeUsdtSpotMarketInfo) + derivativeMarketInfos = append(derivativeMarketInfos, btcUsdtDerivativeMarketInfo) - mockExchange.SpotMarketsResponses = append(mockExchange.SpotMarketsResponses, spotExchangePB.MarketsResponse{ + mockExchange.SpotMarketsResponses = append(mockExchange.SpotMarketsResponses, &spotExchangePB.MarketsResponse{ Markets: spotMarketInfos, }) - mockExchange.DerivativeMarketsResponses = append(mockExchange.DerivativeMarketsResponses, derivativeExchangePB.MarketsResponse{ + mockExchange.DerivativeMarketsResponses = append(mockExchange.DerivativeMarketsResponses, &derivativeExchangePB.MarketsResponse{ Markets: derivativeMarketInfos, }) @@ -77,8 +78,8 @@ func TestMarketAssistantCreationWithAllTokens(t *testing.T) { mockChain := MockChainClient{} smartDenomMetadata := createSmartDenomMetadata() - mockExchange.SpotMarketsResponses = append(mockExchange.SpotMarketsResponses, spotExchangePB.MarketsResponse{}) - mockExchange.DerivativeMarketsResponses = append(mockExchange.DerivativeMarketsResponses, derivativeExchangePB.MarketsResponse{}) + mockExchange.SpotMarketsResponses = append(mockExchange.SpotMarketsResponses, &spotExchangePB.MarketsResponse{}) + mockExchange.DerivativeMarketsResponses = append(mockExchange.DerivativeMarketsResponses, &derivativeExchangePB.MarketsResponse{}) mockChain.DenomsMetadataResponses = append(mockChain.DenomsMetadataResponses, &banktypes.QueryDenomsMetadataResponse{ Metadatas: []banktypes.Metadata{smartDenomMetadata}, diff --git a/client/chain/markets_assistant_test_support.go b/client/chain/markets_assistant_test_support.go index 6df42c1d..d926f585 100644 --- a/client/chain/markets_assistant_test_support.go +++ b/client/chain/markets_assistant_test_support.go @@ -50,7 +50,7 @@ func createUSDTPerpTokenMeta() derivativeExchangePB.TokenMeta { } } -func createINJUSDTSpotMarketInfo() spotExchangePB.SpotMarketInfo { +func createINJUSDTSpotMarketInfo() *spotExchangePB.SpotMarketInfo { injTokenMeta := createINJTokenMeta() usdtTokenMeta := createUSDTTokenMeta() marketInfo := spotExchangePB.SpotMarketInfo{ @@ -68,10 +68,10 @@ func createINJUSDTSpotMarketInfo() spotExchangePB.SpotMarketInfo { MinQuantityTickSize: "1000000000000000", } - return marketInfo + return &marketInfo } -func createAPEUSDTSpotMarketInfo() spotExchangePB.SpotMarketInfo { +func createAPEUSDTSpotMarketInfo() *spotExchangePB.SpotMarketInfo { apeTokenMeta := createAPETokenMeta() usdtTokenMeta := createUSDTTokenMeta() marketInfo := spotExchangePB.SpotMarketInfo{ @@ -89,10 +89,10 @@ func createAPEUSDTSpotMarketInfo() spotExchangePB.SpotMarketInfo { MinQuantityTickSize: "1000000000000000", } - return marketInfo + return &marketInfo } -func createBTCUSDTDerivativeMarketInfo() derivativeExchangePB.DerivativeMarketInfo { +func createBTCUSDTDerivativeMarketInfo() *derivativeExchangePB.DerivativeMarketInfo { usdtPerpTokenMeta := createUSDTPerpTokenMeta() perpetualMarketInfo := derivativeExchangePB.PerpetualMarketInfo{ @@ -130,7 +130,7 @@ func createBTCUSDTDerivativeMarketInfo() derivativeExchangePB.DerivativeMarketIn PerpetualMarketFunding: &perpetualmarketFunding, } - return marketInfo + return &marketInfo } func createSmartDenomMetadata() types.Metadata { diff --git a/client/common/embeded.go b/client/common/embeded.go index b22554cf..d1c7d7e6 100644 --- a/client/common/embeded.go +++ b/client/common/embeded.go @@ -1,4 +1,6 @@ package common -import _ "github.com/InjectiveLabs/sdk-go/client/cert" -import _ "github.com/InjectiveLabs/sdk-go/client/metadata/assets" +import ( + _ "github.com/InjectiveLabs/sdk-go/client/cert" + _ "github.com/InjectiveLabs/sdk-go/client/metadata/assets" +) diff --git a/client/common/network.go b/client/common/network.go index 7095823b..ec50a01b 100644 --- a/client/common/network.go +++ b/client/common/network.go @@ -4,14 +4,13 @@ import ( "context" "crypto/tls" "fmt" - "google.golang.org/grpc/metadata" "net" "net/http" - "path" - "runtime" "strings" "time" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/credentials" ) @@ -74,7 +73,7 @@ func (assistant *ExpiringCookieAssistant) checkCookieExpiration() { expirationTime, err := time.Parse(assistant.timeLayout, cookie.Value) if err == nil { - timestampDiff := expirationTime.Sub(time.Now()) + timestampDiff := time.Until(expirationTime) if timestampDiff < SessionRenewalOffset { assistant.cookie = "" } @@ -175,11 +174,6 @@ func (network *Network) ExplorerMetadata(provider MetadataProvider) (string, err return network.explorerCookieAssistant.Metadata(provider) } -func getFileAbsPath(relativePath string) string { - _, filename, _, _ := runtime.Caller(0) - return path.Join(path.Dir(filename), relativePath) -} - func LoadNetwork(name string, node string) Network { switch name { diff --git a/client/common/network_test.go b/client/common/network_test.go index cf63efcd..235c580e 100644 --- a/client/common/network_test.go +++ b/client/common/network_test.go @@ -2,9 +2,10 @@ package common import ( "fmt" - "google.golang.org/grpc/metadata" "testing" "time" + + "google.golang.org/grpc/metadata" ) func TestMainnetKubernetesLoadBalancedCookieAssistant(t *testing.T) { diff --git a/client/common/util.go b/client/common/util.go index 6f6af8ee..f7e0c9bc 100644 --- a/client/common/util.go +++ b/client/common/util.go @@ -5,7 +5,7 @@ import ( "crypto/x509" "encoding/hex" "fmt" - "io/ioutil" + "os" "strings" chaintypes "github.com/InjectiveLabs/sdk-go/chain/types" @@ -13,9 +13,7 @@ import ( ) func HexToBytes(str string) ([]byte, error) { - if strings.HasPrefix(str, "0x") { - str = str[2:] - } + str = strings.TrimPrefix(str, "0x") data, err := hex.DecodeString(str) if err != nil { @@ -31,7 +29,7 @@ func LoadTlsCert(path string, serverName string) credentials.TransportCredential } // build cert obj - rootCert, err := ioutil.ReadFile(path) + rootCert, err := os.ReadFile(path) if err != nil { fmt.Println(err, "cannot load tls cert from path") return nil diff --git a/client/core/market_test.go b/client/core/market_test.go index 0c56fe31..3ee77ea8 100644 --- a/client/core/market_test.go +++ b/client/core/market_test.go @@ -1,10 +1,11 @@ package core import ( + "testing" + "github.com/cosmos/cosmos-sdk/types" "github.com/huandu/go-assert" "github.com/shopspring/decimal" - "testing" ) func createINJUSDTSpotMarket() SpotMarket { diff --git a/client/core/token_test.go b/client/core/token_test.go index 7ced75cd..ceb72366 100644 --- a/client/core/token_test.go +++ b/client/core/token_test.go @@ -1,9 +1,10 @@ package core import ( + "testing" + "github.com/huandu/go-assert" "github.com/shopspring/decimal" - "testing" ) func createINJToken() Token { diff --git a/client/exchange/exchange.go b/client/exchange/exchange.go index 59552049..17577000 100644 --- a/client/exchange/exchange.go +++ b/client/exchange/exchange.go @@ -3,6 +3,10 @@ package exchange import ( "context" "fmt" + "time" + + "google.golang.org/grpc/credentials/insecure" + "github.com/InjectiveLabs/sdk-go/client/common" accountPB "github.com/InjectiveLabs/sdk-go/exchange/accounts_rpc/pb" auctionPB "github.com/InjectiveLabs/sdk-go/exchange/auction_rpc/pb" @@ -22,74 +26,74 @@ import ( type ExchangeClient interface { QueryClient() *grpc.ClientConn - GetDerivativeMarket(ctx context.Context, marketId string) (derivativeExchangePB.MarketResponse, error) - GetDerivativeOrderbookV2(ctx context.Context, marketId string) (derivativeExchangePB.OrderbookV2Response, error) - GetDerivativeOrderbooksV2(ctx context.Context, marketIds []string) (derivativeExchangePB.OrderbooksV2Response, error) + GetDerivativeMarket(ctx context.Context, marketId string) (*derivativeExchangePB.MarketResponse, error) + GetDerivativeOrderbookV2(ctx context.Context, marketId string) (*derivativeExchangePB.OrderbookV2Response, error) + GetDerivativeOrderbooksV2(ctx context.Context, marketIds []string) (*derivativeExchangePB.OrderbooksV2Response, error) // StreamDerivativeOrderbook deprecated API StreamDerivativeOrderbookV2(ctx context.Context, marketIds []string) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamOrderbookV2Client, error) StreamDerivativeOrderbookUpdate(ctx context.Context, marketIds []string) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamOrderbookUpdateClient, error) StreamDerivativeMarket(ctx context.Context, marketIds []string) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamMarketClient, error) - GetDerivativeOrders(ctx context.Context, req derivativeExchangePB.OrdersRequest) (derivativeExchangePB.OrdersResponse, error) - GetDerivativeMarkets(ctx context.Context, req derivativeExchangePB.MarketsRequest) (derivativeExchangePB.MarketsResponse, error) - GetDerivativePositions(ctx context.Context, req derivativeExchangePB.PositionsRequest) (derivativeExchangePB.PositionsResponse, error) - GetDerivativePositionsV2(ctx context.Context, req derivativeExchangePB.PositionsV2Request) (derivativeExchangePB.PositionsV2Response, error) - GetDerivativeLiquidablePositions(ctx context.Context, req derivativeExchangePB.LiquidablePositionsRequest) (derivativeExchangePB.LiquidablePositionsResponse, error) - StreamDerivativePositions(ctx context.Context, req derivativeExchangePB.StreamPositionsRequest) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamPositionsClient, error) - StreamDerivativeOrders(ctx context.Context, req derivativeExchangePB.StreamOrdersRequest) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamOrdersClient, error) - GetDerivativeTrades(ctx context.Context, req derivativeExchangePB.TradesRequest) (derivativeExchangePB.TradesResponse, error) - GetDerivativeTradesV2(ctx context.Context, req derivativeExchangePB.TradesV2Request) (derivativeExchangePB.TradesV2Response, error) - StreamDerivativeTrades(ctx context.Context, req derivativeExchangePB.StreamTradesRequest) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamTradesClient, error) - StreamDerivativeV2Trades(ctx context.Context, req derivativeExchangePB.StreamTradesV2Request) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamTradesV2Client, error) - GetSubaccountDerivativeOrdersList(ctx context.Context, req derivativeExchangePB.SubaccountOrdersListRequest) (derivativeExchangePB.SubaccountOrdersListResponse, error) - GetSubaccountDerivativeTradesList(ctx context.Context, req derivativeExchangePB.SubaccountTradesListRequest) (derivativeExchangePB.SubaccountTradesListResponse, error) - GetHistoricalDerivativeOrders(ctx context.Context, req derivativeExchangePB.OrdersHistoryRequest) (derivativeExchangePB.OrdersHistoryResponse, error) - StreamHistoricalDerivativeOrders(ctx context.Context, req derivativeExchangePB.StreamOrdersHistoryRequest) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamOrdersHistoryClient, error) - GetDerivativeFundingPayments(ctx context.Context, req derivativeExchangePB.FundingPaymentsRequest) (derivativeExchangePB.FundingPaymentsResponse, error) - GetDerivativeFundingRates(ctx context.Context, req derivativeExchangePB.FundingRatesRequest) (derivativeExchangePB.FundingRatesResponse, error) - GetPrice(ctx context.Context, baseSymbol string, quoteSymbol string, oracleType string, oracleScaleFactor uint32) (oraclePB.PriceResponse, error) - GetOracleList(ctx context.Context) (oraclePB.OracleListResponse, error) + GetDerivativeOrders(ctx context.Context, req *derivativeExchangePB.OrdersRequest) (*derivativeExchangePB.OrdersResponse, error) + GetDerivativeMarkets(ctx context.Context, req *derivativeExchangePB.MarketsRequest) (*derivativeExchangePB.MarketsResponse, error) + GetDerivativePositions(ctx context.Context, req *derivativeExchangePB.PositionsRequest) (*derivativeExchangePB.PositionsResponse, error) + GetDerivativePositionsV2(ctx context.Context, req *derivativeExchangePB.PositionsV2Request) (*derivativeExchangePB.PositionsV2Response, error) + GetDerivativeLiquidablePositions(ctx context.Context, req *derivativeExchangePB.LiquidablePositionsRequest) (*derivativeExchangePB.LiquidablePositionsResponse, error) + StreamDerivativePositions(ctx context.Context, req *derivativeExchangePB.StreamPositionsRequest) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamPositionsClient, error) + StreamDerivativeOrders(ctx context.Context, req *derivativeExchangePB.StreamOrdersRequest) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamOrdersClient, error) + GetDerivativeTrades(ctx context.Context, req *derivativeExchangePB.TradesRequest) (*derivativeExchangePB.TradesResponse, error) + GetDerivativeTradesV2(ctx context.Context, req *derivativeExchangePB.TradesV2Request) (*derivativeExchangePB.TradesV2Response, error) + StreamDerivativeTrades(ctx context.Context, req *derivativeExchangePB.StreamTradesRequest) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamTradesClient, error) + StreamDerivativeV2Trades(ctx context.Context, req *derivativeExchangePB.StreamTradesV2Request) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamTradesV2Client, error) + GetSubaccountDerivativeOrdersList(ctx context.Context, req *derivativeExchangePB.SubaccountOrdersListRequest) (*derivativeExchangePB.SubaccountOrdersListResponse, error) + GetSubaccountDerivativeTradesList(ctx context.Context, req *derivativeExchangePB.SubaccountTradesListRequest) (*derivativeExchangePB.SubaccountTradesListResponse, error) + GetHistoricalDerivativeOrders(ctx context.Context, req *derivativeExchangePB.OrdersHistoryRequest) (*derivativeExchangePB.OrdersHistoryResponse, error) + StreamHistoricalDerivativeOrders(ctx context.Context, req *derivativeExchangePB.StreamOrdersHistoryRequest) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamOrdersHistoryClient, error) + GetDerivativeFundingPayments(ctx context.Context, req *derivativeExchangePB.FundingPaymentsRequest) (*derivativeExchangePB.FundingPaymentsResponse, error) + GetDerivativeFundingRates(ctx context.Context, req *derivativeExchangePB.FundingRatesRequest) (*derivativeExchangePB.FundingRatesResponse, error) + GetPrice(ctx context.Context, baseSymbol string, quoteSymbol string, oracleType string, oracleScaleFactor uint32) (*oraclePB.PriceResponse, error) + GetOracleList(ctx context.Context) (*oraclePB.OracleListResponse, error) StreamPrices(ctx context.Context, baseSymbol string, quoteSymbol string, oracleType string) (oraclePB.InjectiveOracleRPC_StreamPricesClient, error) - GetAuction(ctx context.Context, round int64) (auctionPB.AuctionEndpointResponse, error) - GetAuctions(ctx context.Context) (auctionPB.AuctionsResponse, error) + GetAuction(ctx context.Context, round int64) (*auctionPB.AuctionEndpointResponse, error) + GetAuctions(ctx context.Context) (*auctionPB.AuctionsResponse, error) StreamBids(ctx context.Context) (auctionPB.InjectiveAuctionRPC_StreamBidsClient, error) - GetSubaccountsList(ctx context.Context, accountAddress string) (accountPB.SubaccountsListResponse, error) - GetSubaccountBalance(ctx context.Context, subaccountId string, denom string) (accountPB.SubaccountBalanceEndpointResponse, error) + GetSubaccountsList(ctx context.Context, accountAddress string) (*accountPB.SubaccountsListResponse, error) + GetSubaccountBalance(ctx context.Context, subaccountId string, denom string) (*accountPB.SubaccountBalanceEndpointResponse, error) StreamSubaccountBalance(ctx context.Context, subaccountId string) (accountPB.InjectiveAccountsRPC_StreamSubaccountBalanceClient, error) - GetSubaccountBalancesList(ctx context.Context, subaccountId string) (accountPB.SubaccountBalancesListResponse, error) - GetSubaccountHistory(ctx context.Context, req accountPB.SubaccountHistoryRequest) (accountPB.SubaccountHistoryResponse, error) - GetSubaccountOrderSummary(ctx context.Context, req accountPB.SubaccountOrderSummaryRequest) (accountPB.SubaccountOrderSummaryResponse, error) - GetOrderStates(ctx context.Context, req accountPB.OrderStatesRequest) (accountPB.OrderStatesResponse, error) - GetPortfolio(ctx context.Context, accountAddress string) (accountPB.PortfolioResponse, error) - GetRewards(ctx context.Context, req accountPB.RewardsRequest) (accountPB.RewardsResponse, error) - GetSpotOrders(ctx context.Context, req spotExchangePB.OrdersRequest) (spotExchangePB.OrdersResponse, error) - GetSpotOrderbookV2(ctx context.Context, marketId string) (spotExchangePB.OrderbookV2Response, error) - GetSpotOrderbooksV2(ctx context.Context, marketIds []string) (spotExchangePB.OrderbooksV2Response, error) + GetSubaccountBalancesList(ctx context.Context, subaccountId string) (*accountPB.SubaccountBalancesListResponse, error) + GetSubaccountHistory(ctx context.Context, req *accountPB.SubaccountHistoryRequest) (*accountPB.SubaccountHistoryResponse, error) + GetSubaccountOrderSummary(ctx context.Context, req *accountPB.SubaccountOrderSummaryRequest) (*accountPB.SubaccountOrderSummaryResponse, error) + GetOrderStates(ctx context.Context, req *accountPB.OrderStatesRequest) (*accountPB.OrderStatesResponse, error) + GetPortfolio(ctx context.Context, accountAddress string) (*accountPB.PortfolioResponse, error) + GetRewards(ctx context.Context, req *accountPB.RewardsRequest) (*accountPB.RewardsResponse, error) + GetSpotOrders(ctx context.Context, req *spotExchangePB.OrdersRequest) (*spotExchangePB.OrdersResponse, error) + GetSpotOrderbookV2(ctx context.Context, marketId string) (*spotExchangePB.OrderbookV2Response, error) + GetSpotOrderbooksV2(ctx context.Context, marketIds []string) (*spotExchangePB.OrderbooksV2Response, error) // StreamSpotOrderbook deprecated API StreamSpotOrderbookV2(ctx context.Context, marketIds []string) (spotExchangePB.InjectiveSpotExchangeRPC_StreamOrderbookV2Client, error) StreamSpotOrderbookUpdate(ctx context.Context, marketIds []string) (spotExchangePB.InjectiveSpotExchangeRPC_StreamOrderbookUpdateClient, error) - GetSpotMarkets(ctx context.Context, req spotExchangePB.MarketsRequest) (spotExchangePB.MarketsResponse, error) - GetSpotMarket(ctx context.Context, marketId string) (spotExchangePB.MarketResponse, error) + GetSpotMarkets(ctx context.Context, req *spotExchangePB.MarketsRequest) (*spotExchangePB.MarketsResponse, error) + GetSpotMarket(ctx context.Context, marketId string) (*spotExchangePB.MarketResponse, error) StreamSpotMarket(ctx context.Context, marketIds []string) (spotExchangePB.InjectiveSpotExchangeRPC_StreamMarketsClient, error) - StreamSpotOrders(ctx context.Context, req spotExchangePB.StreamOrdersRequest) (spotExchangePB.InjectiveSpotExchangeRPC_StreamOrdersClient, error) - GetSpotTrades(ctx context.Context, req spotExchangePB.TradesRequest) (spotExchangePB.TradesResponse, error) - GetSpotTradesV2(ctx context.Context, req spotExchangePB.TradesV2Request) (spotExchangePB.TradesV2Response, error) - StreamSpotTrades(ctx context.Context, req spotExchangePB.StreamTradesRequest) (spotExchangePB.InjectiveSpotExchangeRPC_StreamTradesClient, error) - StreamSpotTradesV2(ctx context.Context, req spotExchangePB.StreamTradesV2Request) (spotExchangePB.InjectiveSpotExchangeRPC_StreamTradesV2Client, error) - GetSubaccountSpotOrdersList(ctx context.Context, req spotExchangePB.SubaccountOrdersListRequest) (spotExchangePB.SubaccountOrdersListResponse, error) - GetSubaccountSpotTradesList(ctx context.Context, req spotExchangePB.SubaccountTradesListRequest) (spotExchangePB.SubaccountTradesListResponse, error) - GetHistoricalSpotOrders(ctx context.Context, req spotExchangePB.OrdersHistoryRequest) (spotExchangePB.OrdersHistoryResponse, error) - StreamHistoricalSpotOrders(ctx context.Context, req spotExchangePB.StreamOrdersHistoryRequest) (spotExchangePB.InjectiveSpotExchangeRPC_StreamOrdersHistoryClient, error) - GetInsuranceFunds(ctx context.Context, req insurancePB.FundsRequest) (insurancePB.FundsResponse, error) - GetRedemptions(ctx context.Context, req insurancePB.RedemptionsRequest) (insurancePB.RedemptionsResponse, error) - - GetAccountPortfolio(ctx context.Context, accountAddress string) (portfolioExchangePB.AccountPortfolioResponse, error) - GetAccountPortfolioBalances(ctx context.Context, accountAddress string) (portfolioExchangePB.AccountPortfolioBalancesResponse, error) + StreamSpotOrders(ctx context.Context, req *spotExchangePB.StreamOrdersRequest) (spotExchangePB.InjectiveSpotExchangeRPC_StreamOrdersClient, error) + GetSpotTrades(ctx context.Context, req *spotExchangePB.TradesRequest) (*spotExchangePB.TradesResponse, error) + GetSpotTradesV2(ctx context.Context, req *spotExchangePB.TradesV2Request) (*spotExchangePB.TradesV2Response, error) + StreamSpotTrades(ctx context.Context, req *spotExchangePB.StreamTradesRequest) (spotExchangePB.InjectiveSpotExchangeRPC_StreamTradesClient, error) + StreamSpotTradesV2(ctx context.Context, req *spotExchangePB.StreamTradesV2Request) (spotExchangePB.InjectiveSpotExchangeRPC_StreamTradesV2Client, error) + GetSubaccountSpotOrdersList(ctx context.Context, req *spotExchangePB.SubaccountOrdersListRequest) (*spotExchangePB.SubaccountOrdersListResponse, error) + GetSubaccountSpotTradesList(ctx context.Context, req *spotExchangePB.SubaccountTradesListRequest) (*spotExchangePB.SubaccountTradesListResponse, error) + GetHistoricalSpotOrders(ctx context.Context, req *spotExchangePB.OrdersHistoryRequest) (*spotExchangePB.OrdersHistoryResponse, error) + StreamHistoricalSpotOrders(ctx context.Context, req *spotExchangePB.StreamOrdersHistoryRequest) (spotExchangePB.InjectiveSpotExchangeRPC_StreamOrdersHistoryClient, error) + GetInsuranceFunds(ctx context.Context, req *insurancePB.FundsRequest) (*insurancePB.FundsResponse, error) + GetRedemptions(ctx context.Context, req *insurancePB.RedemptionsRequest) (*insurancePB.RedemptionsResponse, error) + + GetAccountPortfolio(ctx context.Context, accountAddress string) (*portfolioExchangePB.AccountPortfolioResponse, error) + GetAccountPortfolioBalances(ctx context.Context, accountAddress string) (*portfolioExchangePB.AccountPortfolioBalancesResponse, error) StreamAccountPortfolio(ctx context.Context, accountAddress string, subaccountId, balanceType string) (portfolioExchangePB.InjectivePortfolioRPC_StreamAccountPortfolioClient, error) StreamKeepalive(ctx context.Context) (metaPB.InjectiveMetaRPC_StreamKeepaliveClient, error) - GetInfo(ctx context.Context, req metaPB.InfoRequest) (metaPB.InfoResponse, error) - GetVersion(ctx context.Context, req metaPB.VersionRequest) (metaPB.VersionResponse, error) - Ping(ctx context.Context, req metaPB.PingRequest) (metaPB.PingResponse, error) + GetInfo(ctx context.Context, req *metaPB.InfoRequest) (*metaPB.InfoResponse, error) + GetVersion(ctx context.Context, req *metaPB.VersionRequest) (*metaPB.VersionResponse, error) + Ping(ctx context.Context, req *metaPB.PingRequest) (*metaPB.PingResponse, error) Close() } @@ -113,7 +117,7 @@ func NewExchangeClient(network common.Network, options ...common.ClientOption) ( conn, err = grpc.Dial(network.ExchangeGrpcEndpoint, grpc.WithTransportCredentials(opts.TLSCert), grpc.WithContextDialer(common.DialerFunc)) } else { - conn, err = grpc.Dial(network.ExchangeGrpcEndpoint, grpc.WithInsecure(), grpc.WithContextDialer(common.DialerFunc)) + conn, err = grpc.Dial(network.ExchangeGrpcEndpoint, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithContextDialer(common.DialerFunc)) } if err != nil { err := errors.Wrapf(err, "failed to connect to the gRPC: %s", network.ExchangeGrpcEndpoint) @@ -150,9 +154,6 @@ type exchangeClient struct { network common.Network conn *grpc.ClientConn logger log.Logger - client *grpc.ClientConn - - sessionCookie string metaClient metaPB.InjectiveMetaRPCClient explorerClient explorerPB.InjectiveExplorerRPCClient @@ -163,14 +164,15 @@ type exchangeClient struct { spotExchangeClient spotExchangePB.InjectiveSpotExchangeRPCClient derivativeExchangeClient derivativeExchangePB.InjectiveDerivativeExchangeRPCClient portfolioExchangeClient portfolioExchangePB.InjectivePortfolioRPCClient - - closed int64 } func (c *exchangeClient) requestCookie() metadata.MD { var header metadata.MD - req := metaPB.InfoRequest{} - c.metaClient.Info(context.Background(), &req, grpc.Header(&header)) + req := metaPB.InfoRequest{Timestamp: time.Now().UnixMilli()} + _, err := c.metaClient.Info(context.Background(), &req, grpc.Header(&header)) + if err != nil { + panic(err) + } return header } @@ -186,52 +188,52 @@ func (c *exchangeClient) QueryClient() *grpc.ClientConn { // Derivatives RPC -func (c *exchangeClient) GetDerivativeOrders(ctx context.Context, req derivativeExchangePB.OrdersRequest) (derivativeExchangePB.OrdersResponse, error) { +func (c *exchangeClient) GetDerivativeOrders(ctx context.Context, req *derivativeExchangePB.OrdersRequest) (*derivativeExchangePB.OrdersResponse, error) { ctx = c.getCookie(ctx) - res, err := c.derivativeExchangeClient.Orders(ctx, &req) + res, err := c.derivativeExchangeClient.Orders(ctx, req) if err != nil { fmt.Println(err) - return derivativeExchangePB.OrdersResponse{}, err + return &derivativeExchangePB.OrdersResponse{}, err } - return *res, nil + return res, nil } // Deprecated: Use GetDerivativePositionsV2 instead. -func (c *exchangeClient) GetDerivativePositions(ctx context.Context, req derivativeExchangePB.PositionsRequest) (derivativeExchangePB.PositionsResponse, error) { +func (c *exchangeClient) GetDerivativePositions(ctx context.Context, req *derivativeExchangePB.PositionsRequest) (*derivativeExchangePB.PositionsResponse, error) { ctx = c.getCookie(ctx) - res, err := c.derivativeExchangeClient.Positions(ctx, &req) + res, err := c.derivativeExchangeClient.Positions(ctx, req) if err != nil { fmt.Println(err) - return derivativeExchangePB.PositionsResponse{}, err + return &derivativeExchangePB.PositionsResponse{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) GetDerivativePositionsV2(ctx context.Context, req derivativeExchangePB.PositionsV2Request) (derivativeExchangePB.PositionsV2Response, error) { +func (c *exchangeClient) GetDerivativePositionsV2(ctx context.Context, req *derivativeExchangePB.PositionsV2Request) (*derivativeExchangePB.PositionsV2Response, error) { ctx = c.getCookie(ctx) - res, err := c.derivativeExchangeClient.PositionsV2(ctx, &req) + res, err := c.derivativeExchangeClient.PositionsV2(ctx, req) if err != nil { fmt.Println(err) - return derivativeExchangePB.PositionsV2Response{}, err + return &derivativeExchangePB.PositionsV2Response{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) GetDerivativeLiquidablePositions(ctx context.Context, req derivativeExchangePB.LiquidablePositionsRequest) (derivativeExchangePB.LiquidablePositionsResponse, error) { +func (c *exchangeClient) GetDerivativeLiquidablePositions(ctx context.Context, req *derivativeExchangePB.LiquidablePositionsRequest) (*derivativeExchangePB.LiquidablePositionsResponse, error) { ctx = c.getCookie(ctx) - res, err := c.derivativeExchangeClient.LiquidablePositions(ctx, &req) + res, err := c.derivativeExchangeClient.LiquidablePositions(ctx, req) if err != nil { fmt.Println(err) - return derivativeExchangePB.LiquidablePositionsResponse{}, err + return &derivativeExchangePB.LiquidablePositionsResponse{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) GetDerivativeOrderbookV2(ctx context.Context, marketId string) (derivativeExchangePB.OrderbookV2Response, error) { +func (c *exchangeClient) GetDerivativeOrderbookV2(ctx context.Context, marketId string) (*derivativeExchangePB.OrderbookV2Response, error) { req := derivativeExchangePB.OrderbookV2Request{ MarketId: marketId, } @@ -240,13 +242,13 @@ func (c *exchangeClient) GetDerivativeOrderbookV2(ctx context.Context, marketId res, err := c.derivativeExchangeClient.OrderbookV2(ctx, &req) if err != nil { fmt.Println(err) - return derivativeExchangePB.OrderbookV2Response{}, err + return &derivativeExchangePB.OrderbookV2Response{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) GetDerivativeOrderbooksV2(ctx context.Context, marketIds []string) (derivativeExchangePB.OrderbooksV2Response, error) { +func (c *exchangeClient) GetDerivativeOrderbooksV2(ctx context.Context, marketIds []string) (*derivativeExchangePB.OrderbooksV2Response, error) { req := derivativeExchangePB.OrderbooksV2Request{ MarketIds: marketIds, } @@ -255,10 +257,10 @@ func (c *exchangeClient) GetDerivativeOrderbooksV2(ctx context.Context, marketId res, err := c.derivativeExchangeClient.OrderbooksV2(ctx, &req) if err != nil { fmt.Println(err) - return derivativeExchangePB.OrderbooksV2Response{}, err + return &derivativeExchangePB.OrderbooksV2Response{}, err } - return *res, nil + return res, nil } func (c *exchangeClient) StreamDerivativeOrderbookV2(ctx context.Context, marketIds []string) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamOrderbookV2Client, error) { @@ -291,18 +293,18 @@ func (c *exchangeClient) StreamDerivativeOrderbookUpdate(ctx context.Context, ma return stream, nil } -func (c *exchangeClient) GetDerivativeMarkets(ctx context.Context, req derivativeExchangePB.MarketsRequest) (derivativeExchangePB.MarketsResponse, error) { +func (c *exchangeClient) GetDerivativeMarkets(ctx context.Context, req *derivativeExchangePB.MarketsRequest) (*derivativeExchangePB.MarketsResponse, error) { ctx = c.getCookie(ctx) - res, err := c.derivativeExchangeClient.Markets(ctx, &req) + res, err := c.derivativeExchangeClient.Markets(ctx, req) if err != nil { fmt.Println(err) - return derivativeExchangePB.MarketsResponse{}, err + return &derivativeExchangePB.MarketsResponse{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) GetDerivativeMarket(ctx context.Context, marketId string) (derivativeExchangePB.MarketResponse, error) { +func (c *exchangeClient) GetDerivativeMarket(ctx context.Context, marketId string) (*derivativeExchangePB.MarketResponse, error) { req := derivativeExchangePB.MarketRequest{ MarketId: marketId, } @@ -311,10 +313,10 @@ func (c *exchangeClient) GetDerivativeMarket(ctx context.Context, marketId strin res, err := c.derivativeExchangeClient.Market(ctx, &req) if err != nil { fmt.Println(err) - return derivativeExchangePB.MarketResponse{}, err + return &derivativeExchangePB.MarketResponse{}, err } - return *res, nil + return res, nil } func (c *exchangeClient) StreamDerivativeMarket(ctx context.Context, marketIds []string) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamMarketClient, error) { @@ -332,9 +334,9 @@ func (c *exchangeClient) StreamDerivativeMarket(ctx context.Context, marketIds [ return stream, nil } -func (c *exchangeClient) StreamDerivativePositions(ctx context.Context, req derivativeExchangePB.StreamPositionsRequest) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamPositionsClient, error) { +func (c *exchangeClient) StreamDerivativePositions(ctx context.Context, req *derivativeExchangePB.StreamPositionsRequest) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamPositionsClient, error) { ctx = c.getCookie(ctx) - stream, err := c.derivativeExchangeClient.StreamPositions(ctx, &req) + stream, err := c.derivativeExchangeClient.StreamPositions(ctx, req) if err != nil { fmt.Println(err) return nil, err @@ -343,9 +345,9 @@ func (c *exchangeClient) StreamDerivativePositions(ctx context.Context, req deri return stream, nil } -func (c *exchangeClient) StreamDerivativeOrders(ctx context.Context, req derivativeExchangePB.StreamOrdersRequest) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamOrdersClient, error) { +func (c *exchangeClient) StreamDerivativeOrders(ctx context.Context, req *derivativeExchangePB.StreamOrdersRequest) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamOrdersClient, error) { ctx = c.getCookie(ctx) - stream, err := c.derivativeExchangeClient.StreamOrders(ctx, &req) + stream, err := c.derivativeExchangeClient.StreamOrders(ctx, req) if err != nil { fmt.Println(err) return nil, err @@ -354,31 +356,31 @@ func (c *exchangeClient) StreamDerivativeOrders(ctx context.Context, req derivat return stream, nil } -func (c *exchangeClient) GetDerivativeTrades(ctx context.Context, req derivativeExchangePB.TradesRequest) (derivativeExchangePB.TradesResponse, error) { +func (c *exchangeClient) GetDerivativeTrades(ctx context.Context, req *derivativeExchangePB.TradesRequest) (*derivativeExchangePB.TradesResponse, error) { ctx = c.getCookie(ctx) - res, err := c.derivativeExchangeClient.Trades(ctx, &req) + res, err := c.derivativeExchangeClient.Trades(ctx, req) if err != nil { fmt.Println(err) - return derivativeExchangePB.TradesResponse{}, err + return &derivativeExchangePB.TradesResponse{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) GetDerivativeTradesV2(ctx context.Context, req derivativeExchangePB.TradesV2Request) (derivativeExchangePB.TradesV2Response, error) { +func (c *exchangeClient) GetDerivativeTradesV2(ctx context.Context, req *derivativeExchangePB.TradesV2Request) (*derivativeExchangePB.TradesV2Response, error) { ctx = c.getCookie(ctx) - res, err := c.derivativeExchangeClient.TradesV2(ctx, &req) + res, err := c.derivativeExchangeClient.TradesV2(ctx, req) if err != nil { fmt.Println(err) - return derivativeExchangePB.TradesV2Response{}, err + return &derivativeExchangePB.TradesV2Response{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) StreamDerivativeTrades(ctx context.Context, req derivativeExchangePB.StreamTradesRequest) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamTradesClient, error) { +func (c *exchangeClient) StreamDerivativeTrades(ctx context.Context, req *derivativeExchangePB.StreamTradesRequest) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamTradesClient, error) { ctx = c.getCookie(ctx) - stream, err := c.derivativeExchangeClient.StreamTrades(ctx, &req) + stream, err := c.derivativeExchangeClient.StreamTrades(ctx, req) if err != nil { fmt.Println(err) return nil, err @@ -387,9 +389,9 @@ func (c *exchangeClient) StreamDerivativeTrades(ctx context.Context, req derivat return stream, nil } -func (c *exchangeClient) StreamDerivativeV2Trades(ctx context.Context, req derivativeExchangePB.StreamTradesV2Request) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamTradesV2Client, error) { +func (c *exchangeClient) StreamDerivativeV2Trades(ctx context.Context, req *derivativeExchangePB.StreamTradesV2Request) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamTradesV2Client, error) { ctx = c.getCookie(ctx) - stream, err := c.derivativeExchangeClient.StreamTradesV2(ctx, &req) + stream, err := c.derivativeExchangeClient.StreamTradesV2(ctx, req) if err != nil { fmt.Println(err) return nil, err @@ -398,41 +400,41 @@ func (c *exchangeClient) StreamDerivativeV2Trades(ctx context.Context, req deriv return stream, nil } -func (c *exchangeClient) GetSubaccountDerivativeOrdersList(ctx context.Context, req derivativeExchangePB.SubaccountOrdersListRequest) (derivativeExchangePB.SubaccountOrdersListResponse, error) { +func (c *exchangeClient) GetSubaccountDerivativeOrdersList(ctx context.Context, req *derivativeExchangePB.SubaccountOrdersListRequest) (*derivativeExchangePB.SubaccountOrdersListResponse, error) { ctx = c.getCookie(ctx) - res, err := c.derivativeExchangeClient.SubaccountOrdersList(ctx, &req) + res, err := c.derivativeExchangeClient.SubaccountOrdersList(ctx, req) if err != nil { fmt.Println(err) - return derivativeExchangePB.SubaccountOrdersListResponse{}, err + return &derivativeExchangePB.SubaccountOrdersListResponse{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) GetSubaccountDerivativeTradesList(ctx context.Context, req derivativeExchangePB.SubaccountTradesListRequest) (derivativeExchangePB.SubaccountTradesListResponse, error) { +func (c *exchangeClient) GetSubaccountDerivativeTradesList(ctx context.Context, req *derivativeExchangePB.SubaccountTradesListRequest) (*derivativeExchangePB.SubaccountTradesListResponse, error) { ctx = c.getCookie(ctx) - res, err := c.derivativeExchangeClient.SubaccountTradesList(ctx, &req) + res, err := c.derivativeExchangeClient.SubaccountTradesList(ctx, req) if err != nil { fmt.Println(err) - return derivativeExchangePB.SubaccountTradesListResponse{}, err + return &derivativeExchangePB.SubaccountTradesListResponse{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) GetHistoricalDerivativeOrders(ctx context.Context, req derivativeExchangePB.OrdersHistoryRequest) (derivativeExchangePB.OrdersHistoryResponse, error) { +func (c *exchangeClient) GetHistoricalDerivativeOrders(ctx context.Context, req *derivativeExchangePB.OrdersHistoryRequest) (*derivativeExchangePB.OrdersHistoryResponse, error) { ctx = c.getCookie(ctx) - res, err := c.derivativeExchangeClient.OrdersHistory(ctx, &req) + res, err := c.derivativeExchangeClient.OrdersHistory(ctx, req) if err != nil { - return derivativeExchangePB.OrdersHistoryResponse{}, err + return &derivativeExchangePB.OrdersHistoryResponse{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) StreamHistoricalDerivativeOrders(ctx context.Context, req derivativeExchangePB.StreamOrdersHistoryRequest) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamOrdersHistoryClient, error) { +func (c *exchangeClient) StreamHistoricalDerivativeOrders(ctx context.Context, req *derivativeExchangePB.StreamOrdersHistoryRequest) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamOrdersHistoryClient, error) { ctx = c.getCookie(ctx) - stream, err := c.derivativeExchangeClient.StreamOrdersHistory(ctx, &req) + stream, err := c.derivativeExchangeClient.StreamOrdersHistory(ctx, req) if err != nil { fmt.Println(err) return nil, err @@ -441,31 +443,31 @@ func (c *exchangeClient) StreamHistoricalDerivativeOrders(ctx context.Context, r return stream, nil } -func (c *exchangeClient) GetDerivativeFundingPayments(ctx context.Context, req derivativeExchangePB.FundingPaymentsRequest) (derivativeExchangePB.FundingPaymentsResponse, error) { +func (c *exchangeClient) GetDerivativeFundingPayments(ctx context.Context, req *derivativeExchangePB.FundingPaymentsRequest) (*derivativeExchangePB.FundingPaymentsResponse, error) { ctx = c.getCookie(ctx) - res, err := c.derivativeExchangeClient.FundingPayments(ctx, &req) + res, err := c.derivativeExchangeClient.FundingPayments(ctx, req) if err != nil { fmt.Println(err) - return derivativeExchangePB.FundingPaymentsResponse{}, err + return &derivativeExchangePB.FundingPaymentsResponse{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) GetDerivativeFundingRates(ctx context.Context, req derivativeExchangePB.FundingRatesRequest) (derivativeExchangePB.FundingRatesResponse, error) { +func (c *exchangeClient) GetDerivativeFundingRates(ctx context.Context, req *derivativeExchangePB.FundingRatesRequest) (*derivativeExchangePB.FundingRatesResponse, error) { ctx = c.getCookie(ctx) - res, err := c.derivativeExchangeClient.FundingRates(ctx, &req) + res, err := c.derivativeExchangeClient.FundingRates(ctx, req) if err != nil { fmt.Println(err) - return derivativeExchangePB.FundingRatesResponse{}, err + return &derivativeExchangePB.FundingRatesResponse{}, err } - return *res, nil + return res, nil } // Oracle RPC -func (c *exchangeClient) GetPrice(ctx context.Context, baseSymbol string, quoteSymbol string, oracleType string, oracleScaleFactor uint32) (oraclePB.PriceResponse, error) { +func (c *exchangeClient) GetPrice(ctx context.Context, baseSymbol string, quoteSymbol string, oracleType string, oracleScaleFactor uint32) (*oraclePB.PriceResponse, error) { req := oraclePB.PriceRequest{ BaseSymbol: baseSymbol, QuoteSymbol: quoteSymbol, @@ -477,23 +479,23 @@ func (c *exchangeClient) GetPrice(ctx context.Context, baseSymbol string, quoteS res, err := c.oracleClient.Price(ctx, &req) if err != nil { fmt.Println(err) - return oraclePB.PriceResponse{}, err + return &oraclePB.PriceResponse{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) GetOracleList(ctx context.Context) (oraclePB.OracleListResponse, error) { +func (c *exchangeClient) GetOracleList(ctx context.Context) (*oraclePB.OracleListResponse, error) { req := oraclePB.OracleListRequest{} ctx = c.getCookie(ctx) res, err := c.oracleClient.OracleList(ctx, &req) if err != nil { fmt.Println(err) - return oraclePB.OracleListResponse{}, err + return &oraclePB.OracleListResponse{}, err } - return *res, nil + return res, nil } func (c *exchangeClient) StreamPrices(ctx context.Context, baseSymbol string, quoteSymbol string, oracleType string) (oraclePB.InjectiveOracleRPC_StreamPricesClient, error) { @@ -515,7 +517,7 @@ func (c *exchangeClient) StreamPrices(ctx context.Context, baseSymbol string, qu // Auction RPC -func (c *exchangeClient) GetAuction(ctx context.Context, round int64) (auctionPB.AuctionEndpointResponse, error) { +func (c *exchangeClient) GetAuction(ctx context.Context, round int64) (*auctionPB.AuctionEndpointResponse, error) { req := auctionPB.AuctionEndpointRequest{ Round: round, } @@ -524,23 +526,23 @@ func (c *exchangeClient) GetAuction(ctx context.Context, round int64) (auctionPB res, err := c.auctionClient.AuctionEndpoint(ctx, &req) if err != nil { fmt.Println(err) - return auctionPB.AuctionEndpointResponse{}, err + return &auctionPB.AuctionEndpointResponse{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) GetAuctions(ctx context.Context) (auctionPB.AuctionsResponse, error) { +func (c *exchangeClient) GetAuctions(ctx context.Context) (*auctionPB.AuctionsResponse, error) { req := auctionPB.AuctionsRequest{} ctx = c.getCookie(ctx) res, err := c.auctionClient.Auctions(ctx, &req) if err != nil { fmt.Println(err) - return auctionPB.AuctionsResponse{}, err + return &auctionPB.AuctionsResponse{}, err } - return *res, nil + return res, nil } func (c *exchangeClient) StreamBids(ctx context.Context) (auctionPB.InjectiveAuctionRPC_StreamBidsClient, error) { @@ -558,7 +560,7 @@ func (c *exchangeClient) StreamBids(ctx context.Context) (auctionPB.InjectiveAuc // Accounts RPC -func (c *exchangeClient) GetSubaccountsList(ctx context.Context, accountAddress string) (accountPB.SubaccountsListResponse, error) { +func (c *exchangeClient) GetSubaccountsList(ctx context.Context, accountAddress string) (*accountPB.SubaccountsListResponse, error) { req := accountPB.SubaccountsListRequest{ AccountAddress: accountAddress, } @@ -567,13 +569,13 @@ func (c *exchangeClient) GetSubaccountsList(ctx context.Context, accountAddress res, err := c.accountClient.SubaccountsList(ctx, &req) if err != nil { fmt.Println(err) - return accountPB.SubaccountsListResponse{}, err + return &accountPB.SubaccountsListResponse{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) GetSubaccountBalance(ctx context.Context, subaccountId string, denom string) (accountPB.SubaccountBalanceEndpointResponse, error) { +func (c *exchangeClient) GetSubaccountBalance(ctx context.Context, subaccountId string, denom string) (*accountPB.SubaccountBalanceEndpointResponse, error) { req := accountPB.SubaccountBalanceEndpointRequest{ SubaccountId: subaccountId, Denom: denom, @@ -583,10 +585,10 @@ func (c *exchangeClient) GetSubaccountBalance(ctx context.Context, subaccountId res, err := c.accountClient.SubaccountBalanceEndpoint(ctx, &req) if err != nil { fmt.Println(err) - return accountPB.SubaccountBalanceEndpointResponse{}, err + return &accountPB.SubaccountBalanceEndpointResponse{}, err } - return *res, nil + return res, nil } func (c *exchangeClient) StreamSubaccountBalance(ctx context.Context, subaccountId string) (accountPB.InjectiveAccountsRPC_StreamSubaccountBalanceClient, error) { @@ -604,7 +606,7 @@ func (c *exchangeClient) StreamSubaccountBalance(ctx context.Context, subaccount return stream, nil } -func (c *exchangeClient) GetSubaccountBalancesList(ctx context.Context, subaccountId string) (accountPB.SubaccountBalancesListResponse, error) { +func (c *exchangeClient) GetSubaccountBalancesList(ctx context.Context, subaccountId string) (*accountPB.SubaccountBalancesListResponse, error) { req := accountPB.SubaccountBalancesListRequest{ SubaccountId: subaccountId, } @@ -613,46 +615,46 @@ func (c *exchangeClient) GetSubaccountBalancesList(ctx context.Context, subaccou res, err := c.accountClient.SubaccountBalancesList(ctx, &req) if err != nil { fmt.Println(err) - return accountPB.SubaccountBalancesListResponse{}, err + return &accountPB.SubaccountBalancesListResponse{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) GetSubaccountHistory(ctx context.Context, req accountPB.SubaccountHistoryRequest) (accountPB.SubaccountHistoryResponse, error) { +func (c *exchangeClient) GetSubaccountHistory(ctx context.Context, req *accountPB.SubaccountHistoryRequest) (*accountPB.SubaccountHistoryResponse, error) { ctx = c.getCookie(ctx) - res, err := c.accountClient.SubaccountHistory(ctx, &req) + res, err := c.accountClient.SubaccountHistory(ctx, req) if err != nil { fmt.Println(err) - return accountPB.SubaccountHistoryResponse{}, err + return &accountPB.SubaccountHistoryResponse{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) GetSubaccountOrderSummary(ctx context.Context, req accountPB.SubaccountOrderSummaryRequest) (accountPB.SubaccountOrderSummaryResponse, error) { +func (c *exchangeClient) GetSubaccountOrderSummary(ctx context.Context, req *accountPB.SubaccountOrderSummaryRequest) (*accountPB.SubaccountOrderSummaryResponse, error) { ctx = c.getCookie(ctx) - res, err := c.accountClient.SubaccountOrderSummary(ctx, &req) + res, err := c.accountClient.SubaccountOrderSummary(ctx, req) if err != nil { fmt.Println(err) - return accountPB.SubaccountOrderSummaryResponse{}, err + return &accountPB.SubaccountOrderSummaryResponse{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) GetOrderStates(ctx context.Context, req accountPB.OrderStatesRequest) (accountPB.OrderStatesResponse, error) { +func (c *exchangeClient) GetOrderStates(ctx context.Context, req *accountPB.OrderStatesRequest) (*accountPB.OrderStatesResponse, error) { ctx = c.getCookie(ctx) - res, err := c.accountClient.OrderStates(ctx, &req) + res, err := c.accountClient.OrderStates(ctx, req) if err != nil { fmt.Println(err) - return accountPB.OrderStatesResponse{}, err + return &accountPB.OrderStatesResponse{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) GetPortfolio(ctx context.Context, accountAddress string) (accountPB.PortfolioResponse, error) { +func (c *exchangeClient) GetPortfolio(ctx context.Context, accountAddress string) (*accountPB.PortfolioResponse, error) { req := accountPB.PortfolioRequest{ AccountAddress: accountAddress, } @@ -661,37 +663,37 @@ func (c *exchangeClient) GetPortfolio(ctx context.Context, accountAddress string res, err := c.accountClient.Portfolio(ctx, &req) if err != nil { fmt.Println(err) - return accountPB.PortfolioResponse{}, err + return &accountPB.PortfolioResponse{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) GetRewards(ctx context.Context, req accountPB.RewardsRequest) (accountPB.RewardsResponse, error) { +func (c *exchangeClient) GetRewards(ctx context.Context, req *accountPB.RewardsRequest) (*accountPB.RewardsResponse, error) { ctx = c.getCookie(ctx) - res, err := c.accountClient.Rewards(ctx, &req) + res, err := c.accountClient.Rewards(ctx, req) if err != nil { fmt.Println(err) - return accountPB.RewardsResponse{}, err + return &accountPB.RewardsResponse{}, err } - return *res, nil + return res, nil } // Spot RPC -func (c *exchangeClient) GetSpotOrders(ctx context.Context, req spotExchangePB.OrdersRequest) (spotExchangePB.OrdersResponse, error) { +func (c *exchangeClient) GetSpotOrders(ctx context.Context, req *spotExchangePB.OrdersRequest) (*spotExchangePB.OrdersResponse, error) { ctx = c.getCookie(ctx) - res, err := c.spotExchangeClient.Orders(ctx, &req) + res, err := c.spotExchangeClient.Orders(ctx, req) if err != nil { fmt.Println(err) - return spotExchangePB.OrdersResponse{}, err + return &spotExchangePB.OrdersResponse{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) GetSpotOrderbookV2(ctx context.Context, marketId string) (spotExchangePB.OrderbookV2Response, error) { +func (c *exchangeClient) GetSpotOrderbookV2(ctx context.Context, marketId string) (*spotExchangePB.OrderbookV2Response, error) { req := spotExchangePB.OrderbookV2Request{ MarketId: marketId, } @@ -700,13 +702,13 @@ func (c *exchangeClient) GetSpotOrderbookV2(ctx context.Context, marketId string res, err := c.spotExchangeClient.OrderbookV2(ctx, &req) if err != nil { fmt.Println(err) - return spotExchangePB.OrderbookV2Response{}, err + return &spotExchangePB.OrderbookV2Response{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) GetSpotOrderbooksV2(ctx context.Context, marketIds []string) (spotExchangePB.OrderbooksV2Response, error) { +func (c *exchangeClient) GetSpotOrderbooksV2(ctx context.Context, marketIds []string) (*spotExchangePB.OrderbooksV2Response, error) { req := spotExchangePB.OrderbooksV2Request{ MarketIds: marketIds, } @@ -715,10 +717,10 @@ func (c *exchangeClient) GetSpotOrderbooksV2(ctx context.Context, marketIds []st res, err := c.spotExchangeClient.OrderbooksV2(ctx, &req) if err != nil { fmt.Println(err) - return spotExchangePB.OrderbooksV2Response{}, err + return &spotExchangePB.OrderbooksV2Response{}, err } - return *res, nil + return res, nil } func (c *exchangeClient) StreamSpotOrderbookUpdate(ctx context.Context, marketIds []string) (spotExchangePB.InjectiveSpotExchangeRPC_StreamOrderbookUpdateClient, error) { @@ -751,18 +753,18 @@ func (c *exchangeClient) StreamSpotOrderbookV2(ctx context.Context, marketIds [] return stream, nil } -func (c *exchangeClient) GetSpotMarkets(ctx context.Context, req spotExchangePB.MarketsRequest) (spotExchangePB.MarketsResponse, error) { +func (c *exchangeClient) GetSpotMarkets(ctx context.Context, req *spotExchangePB.MarketsRequest) (*spotExchangePB.MarketsResponse, error) { ctx = c.getCookie(ctx) - res, err := c.spotExchangeClient.Markets(ctx, &req) + res, err := c.spotExchangeClient.Markets(ctx, req) if err != nil { fmt.Println(err) - return spotExchangePB.MarketsResponse{}, err + return &spotExchangePB.MarketsResponse{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) GetSpotMarket(ctx context.Context, marketId string) (spotExchangePB.MarketResponse, error) { +func (c *exchangeClient) GetSpotMarket(ctx context.Context, marketId string) (*spotExchangePB.MarketResponse, error) { req := spotExchangePB.MarketRequest{ MarketId: marketId, } @@ -771,10 +773,10 @@ func (c *exchangeClient) GetSpotMarket(ctx context.Context, marketId string) (sp res, err := c.spotExchangeClient.Market(ctx, &req) if err != nil { fmt.Println(err) - return spotExchangePB.MarketResponse{}, err + return &spotExchangePB.MarketResponse{}, err } - return *res, nil + return res, nil } func (c *exchangeClient) StreamSpotMarket(ctx context.Context, marketIds []string) (spotExchangePB.InjectiveSpotExchangeRPC_StreamMarketsClient, error) { @@ -792,9 +794,9 @@ func (c *exchangeClient) StreamSpotMarket(ctx context.Context, marketIds []strin return stream, nil } -func (c *exchangeClient) StreamSpotOrders(ctx context.Context, req spotExchangePB.StreamOrdersRequest) (spotExchangePB.InjectiveSpotExchangeRPC_StreamOrdersClient, error) { +func (c *exchangeClient) StreamSpotOrders(ctx context.Context, req *spotExchangePB.StreamOrdersRequest) (spotExchangePB.InjectiveSpotExchangeRPC_StreamOrdersClient, error) { ctx = c.getCookie(ctx) - stream, err := c.spotExchangeClient.StreamOrders(ctx, &req) + stream, err := c.spotExchangeClient.StreamOrders(ctx, req) if err != nil { fmt.Println(err) return nil, err @@ -803,31 +805,31 @@ func (c *exchangeClient) StreamSpotOrders(ctx context.Context, req spotExchangeP return stream, nil } -func (c *exchangeClient) GetSpotTrades(ctx context.Context, req spotExchangePB.TradesRequest) (spotExchangePB.TradesResponse, error) { +func (c *exchangeClient) GetSpotTrades(ctx context.Context, req *spotExchangePB.TradesRequest) (*spotExchangePB.TradesResponse, error) { ctx = c.getCookie(ctx) - res, err := c.spotExchangeClient.Trades(ctx, &req) + res, err := c.spotExchangeClient.Trades(ctx, req) if err != nil { fmt.Println(err) - return spotExchangePB.TradesResponse{}, err + return &spotExchangePB.TradesResponse{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) GetSpotTradesV2(ctx context.Context, req spotExchangePB.TradesV2Request) (spotExchangePB.TradesV2Response, error) { +func (c *exchangeClient) GetSpotTradesV2(ctx context.Context, req *spotExchangePB.TradesV2Request) (*spotExchangePB.TradesV2Response, error) { ctx = c.getCookie(ctx) - res, err := c.spotExchangeClient.TradesV2(ctx, &req) + res, err := c.spotExchangeClient.TradesV2(ctx, req) if err != nil { fmt.Println(err) - return spotExchangePB.TradesV2Response{}, err + return &spotExchangePB.TradesV2Response{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) StreamSpotTrades(ctx context.Context, req spotExchangePB.StreamTradesRequest) (spotExchangePB.InjectiveSpotExchangeRPC_StreamTradesClient, error) { +func (c *exchangeClient) StreamSpotTrades(ctx context.Context, req *spotExchangePB.StreamTradesRequest) (spotExchangePB.InjectiveSpotExchangeRPC_StreamTradesClient, error) { ctx = c.getCookie(ctx) - stream, err := c.spotExchangeClient.StreamTrades(ctx, &req) + stream, err := c.spotExchangeClient.StreamTrades(ctx, req) if err != nil { fmt.Println(err) return nil, err @@ -836,9 +838,9 @@ func (c *exchangeClient) StreamSpotTrades(ctx context.Context, req spotExchangeP return stream, nil } -func (c *exchangeClient) StreamSpotTradesV2(ctx context.Context, req spotExchangePB.StreamTradesV2Request) (spotExchangePB.InjectiveSpotExchangeRPC_StreamTradesV2Client, error) { +func (c *exchangeClient) StreamSpotTradesV2(ctx context.Context, req *spotExchangePB.StreamTradesV2Request) (spotExchangePB.InjectiveSpotExchangeRPC_StreamTradesV2Client, error) { ctx = c.getCookie(ctx) - stream, err := c.spotExchangeClient.StreamTradesV2(ctx, &req) + stream, err := c.spotExchangeClient.StreamTradesV2(ctx, req) if err != nil { fmt.Println(err) return nil, err @@ -847,41 +849,41 @@ func (c *exchangeClient) StreamSpotTradesV2(ctx context.Context, req spotExchang return stream, nil } -func (c *exchangeClient) GetSubaccountSpotOrdersList(ctx context.Context, req spotExchangePB.SubaccountOrdersListRequest) (spotExchangePB.SubaccountOrdersListResponse, error) { +func (c *exchangeClient) GetSubaccountSpotOrdersList(ctx context.Context, req *spotExchangePB.SubaccountOrdersListRequest) (*spotExchangePB.SubaccountOrdersListResponse, error) { ctx = c.getCookie(ctx) - res, err := c.spotExchangeClient.SubaccountOrdersList(ctx, &req) + res, err := c.spotExchangeClient.SubaccountOrdersList(ctx, req) if err != nil { fmt.Println(err) - return spotExchangePB.SubaccountOrdersListResponse{}, err + return &spotExchangePB.SubaccountOrdersListResponse{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) GetSubaccountSpotTradesList(ctx context.Context, req spotExchangePB.SubaccountTradesListRequest) (spotExchangePB.SubaccountTradesListResponse, error) { +func (c *exchangeClient) GetSubaccountSpotTradesList(ctx context.Context, req *spotExchangePB.SubaccountTradesListRequest) (*spotExchangePB.SubaccountTradesListResponse, error) { ctx = c.getCookie(ctx) - res, err := c.spotExchangeClient.SubaccountTradesList(ctx, &req) + res, err := c.spotExchangeClient.SubaccountTradesList(ctx, req) if err != nil { fmt.Println(err) - return spotExchangePB.SubaccountTradesListResponse{}, err + return &spotExchangePB.SubaccountTradesListResponse{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) GetHistoricalSpotOrders(ctx context.Context, req spotExchangePB.OrdersHistoryRequest) (spotExchangePB.OrdersHistoryResponse, error) { +func (c *exchangeClient) GetHistoricalSpotOrders(ctx context.Context, req *spotExchangePB.OrdersHistoryRequest) (*spotExchangePB.OrdersHistoryResponse, error) { ctx = c.getCookie(ctx) - res, err := c.spotExchangeClient.OrdersHistory(ctx, &req) + res, err := c.spotExchangeClient.OrdersHistory(ctx, req) if err != nil { - return spotExchangePB.OrdersHistoryResponse{}, err + return &spotExchangePB.OrdersHistoryResponse{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) StreamHistoricalSpotOrders(ctx context.Context, req spotExchangePB.StreamOrdersHistoryRequest) (spotExchangePB.InjectiveSpotExchangeRPC_StreamOrdersHistoryClient, error) { +func (c *exchangeClient) StreamHistoricalSpotOrders(ctx context.Context, req *spotExchangePB.StreamOrdersHistoryRequest) (spotExchangePB.InjectiveSpotExchangeRPC_StreamOrdersHistoryClient, error) { ctx = c.getCookie(ctx) - stream, err := c.spotExchangeClient.StreamOrdersHistory(ctx, &req) + stream, err := c.spotExchangeClient.StreamOrdersHistory(ctx, req) if err != nil { fmt.Println(err) return nil, err @@ -890,59 +892,59 @@ func (c *exchangeClient) StreamHistoricalSpotOrders(ctx context.Context, req spo return stream, nil } -func (c *exchangeClient) GetInsuranceFunds(ctx context.Context, req insurancePB.FundsRequest) (insurancePB.FundsResponse, error) { +func (c *exchangeClient) GetInsuranceFunds(ctx context.Context, req *insurancePB.FundsRequest) (*insurancePB.FundsResponse, error) { ctx = c.getCookie(ctx) - res, err := c.insuranceClient.Funds(ctx, &req) + res, err := c.insuranceClient.Funds(ctx, req) if err != nil { fmt.Println(err) - return insurancePB.FundsResponse{}, err + return &insurancePB.FundsResponse{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) GetRedemptions(ctx context.Context, req insurancePB.RedemptionsRequest) (insurancePB.RedemptionsResponse, error) { +func (c *exchangeClient) GetRedemptions(ctx context.Context, req *insurancePB.RedemptionsRequest) (*insurancePB.RedemptionsResponse, error) { ctx = c.getCookie(ctx) - res, err := c.insuranceClient.Redemptions(ctx, &req) + res, err := c.insuranceClient.Redemptions(ctx, req) if err != nil { fmt.Println(err) - return insurancePB.RedemptionsResponse{}, err + return &insurancePB.RedemptionsResponse{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) Ping(ctx context.Context, req metaPB.PingRequest) (metaPB.PingResponse, error) { +func (c *exchangeClient) Ping(ctx context.Context, req *metaPB.PingRequest) (*metaPB.PingResponse, error) { ctx = c.getCookie(ctx) - res, err := c.metaClient.Ping(ctx, &req) + res, err := c.metaClient.Ping(ctx, req) if err != nil { fmt.Println(err) - return metaPB.PingResponse{}, err + return &metaPB.PingResponse{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) GetVersion(ctx context.Context, req metaPB.VersionRequest) (metaPB.VersionResponse, error) { +func (c *exchangeClient) GetVersion(ctx context.Context, req *metaPB.VersionRequest) (*metaPB.VersionResponse, error) { ctx = c.getCookie(ctx) - res, err := c.metaClient.Version(ctx, &req) + res, err := c.metaClient.Version(ctx, req) if err != nil { fmt.Println(err) - return metaPB.VersionResponse{}, err + return &metaPB.VersionResponse{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) GetInfo(ctx context.Context, req metaPB.InfoRequest) (metaPB.InfoResponse, error) { +func (c *exchangeClient) GetInfo(ctx context.Context, req *metaPB.InfoRequest) (*metaPB.InfoResponse, error) { ctx = c.getCookie(ctx) - res, err := c.metaClient.Info(ctx, &req) + res, err := c.metaClient.Info(ctx, req) if err != nil { fmt.Println(err) - return metaPB.InfoResponse{}, err + return &metaPB.InfoResponse{}, err } - return *res, nil + return res, nil } func (c *exchangeClient) StreamKeepalive(ctx context.Context) (metaPB.InjectiveMetaRPC_StreamKeepaliveClient, error) { @@ -959,30 +961,30 @@ func (c *exchangeClient) StreamKeepalive(ctx context.Context) (metaPB.InjectiveM } // Deprecated: Use GetAccountPortfolioBalances instead. -func (c *exchangeClient) GetAccountPortfolio(ctx context.Context, accountAddress string) (portfolioExchangePB.AccountPortfolioResponse, error) { +func (c *exchangeClient) GetAccountPortfolio(ctx context.Context, accountAddress string) (*portfolioExchangePB.AccountPortfolioResponse, error) { ctx = c.getCookie(ctx) res, err := c.portfolioExchangeClient.AccountPortfolio(ctx, &portfolioExchangePB.AccountPortfolioRequest{ AccountAddress: accountAddress, }) if err != nil { fmt.Println(err) - return portfolioExchangePB.AccountPortfolioResponse{}, err + return &portfolioExchangePB.AccountPortfolioResponse{}, err } - return *res, nil + return res, nil } -func (c *exchangeClient) GetAccountPortfolioBalances(ctx context.Context, accountAddress string) (portfolioExchangePB.AccountPortfolioBalancesResponse, error) { +func (c *exchangeClient) GetAccountPortfolioBalances(ctx context.Context, accountAddress string) (*portfolioExchangePB.AccountPortfolioBalancesResponse, error) { ctx = c.getCookie(ctx) res, err := c.portfolioExchangeClient.AccountPortfolioBalances(ctx, &portfolioExchangePB.AccountPortfolioBalancesRequest{ AccountAddress: accountAddress, }) if err != nil { fmt.Println(err) - return portfolioExchangePB.AccountPortfolioBalancesResponse{}, err + return &portfolioExchangePB.AccountPortfolioBalancesResponse{}, err } - return *res, nil + return res, nil } func (c *exchangeClient) StreamAccountPortfolio(ctx context.Context, accountAddress string, subaccountId, balanceType string) (portfolioExchangePB.InjectivePortfolioRPC_StreamAccountPortfolioClient, error) { diff --git a/client/exchange/exchange_test_support.go b/client/exchange/exchange_test_support.go index a4e2b4a4..2b37623a 100644 --- a/client/exchange/exchange_test_support.go +++ b/client/exchange/exchange_test_support.go @@ -3,6 +3,7 @@ package exchange import ( "context" "errors" + accountPB "github.com/InjectiveLabs/sdk-go/exchange/accounts_rpc/pb" auctionPB "github.com/InjectiveLabs/sdk-go/exchange/auction_rpc/pb" derivativeExchangePB "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" @@ -15,8 +16,8 @@ import ( ) type MockExchangeClient struct { - SpotMarketsResponses []spotExchangePB.MarketsResponse - DerivativeMarketsResponses []derivativeExchangePB.MarketsResponse + SpotMarketsResponses []*spotExchangePB.MarketsResponse + DerivativeMarketsResponses []*derivativeExchangePB.MarketsResponse } func (e *MockExchangeClient) QueryClient() *grpc.ClientConn { @@ -24,16 +25,16 @@ func (e *MockExchangeClient) QueryClient() *grpc.ClientConn { return &dummyConnection } -func (e *MockExchangeClient) GetDerivativeMarket(ctx context.Context, marketId string) (derivativeExchangePB.MarketResponse, error) { - return derivativeExchangePB.MarketResponse{}, nil +func (e *MockExchangeClient) GetDerivativeMarket(ctx context.Context, marketId string) (*derivativeExchangePB.MarketResponse, error) { + return &derivativeExchangePB.MarketResponse{}, nil } -func (e *MockExchangeClient) GetDerivativeOrderbookV2(ctx context.Context, marketId string) (derivativeExchangePB.OrderbookV2Response, error) { - return derivativeExchangePB.OrderbookV2Response{}, nil +func (e *MockExchangeClient) GetDerivativeOrderbookV2(ctx context.Context, marketId string) (*derivativeExchangePB.OrderbookV2Response, error) { + return &derivativeExchangePB.OrderbookV2Response{}, nil } -func (e *MockExchangeClient) GetDerivativeOrderbooksV2(ctx context.Context, marketIds []string) (derivativeExchangePB.OrderbooksV2Response, error) { - return derivativeExchangePB.OrderbooksV2Response{}, nil +func (e *MockExchangeClient) GetDerivativeOrderbooksV2(ctx context.Context, marketIds []string) (*derivativeExchangePB.OrderbooksV2Response, error) { + return &derivativeExchangePB.OrderbooksV2Response{}, nil } func (e *MockExchangeClient) StreamDerivativeOrderbookV2(ctx context.Context, marketIds []string) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamOrderbookV2Client, error) { @@ -48,155 +49,155 @@ func (e *MockExchangeClient) StreamDerivativeMarket(ctx context.Context, marketI return nil, nil } -func (e *MockExchangeClient) GetDerivativeOrders(ctx context.Context, req derivativeExchangePB.OrdersRequest) (derivativeExchangePB.OrdersResponse, error) { - return derivativeExchangePB.OrdersResponse{}, nil +func (e *MockExchangeClient) GetDerivativeOrders(ctx context.Context, req *derivativeExchangePB.OrdersRequest) (*derivativeExchangePB.OrdersResponse, error) { + return &derivativeExchangePB.OrdersResponse{}, nil } -func (e *MockExchangeClient) GetDerivativeMarkets(ctx context.Context, req derivativeExchangePB.MarketsRequest) (derivativeExchangePB.MarketsResponse, error) { - var response derivativeExchangePB.MarketsResponse +func (e *MockExchangeClient) GetDerivativeMarkets(ctx context.Context, req *derivativeExchangePB.MarketsRequest) (*derivativeExchangePB.MarketsResponse, error) { + var response *derivativeExchangePB.MarketsResponse var localError error if len(e.DerivativeMarketsResponses) > 0 { response = e.DerivativeMarketsResponses[0] e.DerivativeMarketsResponses = e.DerivativeMarketsResponses[1:] localError = nil } else { - response = derivativeExchangePB.MarketsResponse{} + response = &derivativeExchangePB.MarketsResponse{} localError = errors.New("There are no responses configured") } return response, localError } -func (e *MockExchangeClient) GetDerivativePositions(ctx context.Context, req derivativeExchangePB.PositionsRequest) (derivativeExchangePB.PositionsResponse, error) { - return derivativeExchangePB.PositionsResponse{}, nil +func (e *MockExchangeClient) GetDerivativePositions(ctx context.Context, req *derivativeExchangePB.PositionsRequest) (*derivativeExchangePB.PositionsResponse, error) { + return &derivativeExchangePB.PositionsResponse{}, nil } -func (e *MockExchangeClient) GetDerivativePositionsV2(ctx context.Context, req derivativeExchangePB.PositionsV2Request) (derivativeExchangePB.PositionsV2Response, error) { - return derivativeExchangePB.PositionsV2Response{}, nil +func (e *MockExchangeClient) GetDerivativePositionsV2(ctx context.Context, req *derivativeExchangePB.PositionsV2Request) (*derivativeExchangePB.PositionsV2Response, error) { + return &derivativeExchangePB.PositionsV2Response{}, nil } -func (e *MockExchangeClient) GetDerivativeLiquidablePositions(ctx context.Context, req derivativeExchangePB.LiquidablePositionsRequest) (derivativeExchangePB.LiquidablePositionsResponse, error) { - return derivativeExchangePB.LiquidablePositionsResponse{}, nil +func (e *MockExchangeClient) GetDerivativeLiquidablePositions(ctx context.Context, req *derivativeExchangePB.LiquidablePositionsRequest) (*derivativeExchangePB.LiquidablePositionsResponse, error) { + return &derivativeExchangePB.LiquidablePositionsResponse{}, nil } -func (e *MockExchangeClient) StreamDerivativePositions(ctx context.Context, req derivativeExchangePB.StreamPositionsRequest) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamPositionsClient, error) { +func (e *MockExchangeClient) StreamDerivativePositions(ctx context.Context, req *derivativeExchangePB.StreamPositionsRequest) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamPositionsClient, error) { return nil, nil } -func (e *MockExchangeClient) StreamDerivativeOrders(ctx context.Context, req derivativeExchangePB.StreamOrdersRequest) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamOrdersClient, error) { +func (e *MockExchangeClient) StreamDerivativeOrders(ctx context.Context, req *derivativeExchangePB.StreamOrdersRequest) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamOrdersClient, error) { return nil, nil } -func (e *MockExchangeClient) GetDerivativeTrades(ctx context.Context, req derivativeExchangePB.TradesRequest) (derivativeExchangePB.TradesResponse, error) { - return derivativeExchangePB.TradesResponse{}, nil +func (e *MockExchangeClient) GetDerivativeTrades(ctx context.Context, req *derivativeExchangePB.TradesRequest) (*derivativeExchangePB.TradesResponse, error) { + return &derivativeExchangePB.TradesResponse{}, nil } -func (e *MockExchangeClient) GetDerivativeTradesV2(ctx context.Context, req derivativeExchangePB.TradesV2Request) (derivativeExchangePB.TradesV2Response, error) { - return derivativeExchangePB.TradesV2Response{}, nil +func (e *MockExchangeClient) GetDerivativeTradesV2(ctx context.Context, req *derivativeExchangePB.TradesV2Request) (*derivativeExchangePB.TradesV2Response, error) { + return &derivativeExchangePB.TradesV2Response{}, nil } -func (e *MockExchangeClient) StreamDerivativeTrades(ctx context.Context, req derivativeExchangePB.StreamTradesRequest) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamTradesClient, error) { +func (e *MockExchangeClient) StreamDerivativeTrades(ctx context.Context, req *derivativeExchangePB.StreamTradesRequest) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamTradesClient, error) { return nil, nil } -func (e *MockExchangeClient) StreamDerivativeV2Trades(ctx context.Context, req derivativeExchangePB.StreamTradesV2Request) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamTradesV2Client, error) { +func (e *MockExchangeClient) StreamDerivativeV2Trades(ctx context.Context, req *derivativeExchangePB.StreamTradesV2Request) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamTradesV2Client, error) { return nil, nil } -func (e *MockExchangeClient) GetSubaccountDerivativeOrdersList(ctx context.Context, req derivativeExchangePB.SubaccountOrdersListRequest) (derivativeExchangePB.SubaccountOrdersListResponse, error) { - return derivativeExchangePB.SubaccountOrdersListResponse{}, nil +func (e *MockExchangeClient) GetSubaccountDerivativeOrdersList(ctx context.Context, req *derivativeExchangePB.SubaccountOrdersListRequest) (*derivativeExchangePB.SubaccountOrdersListResponse, error) { + return &derivativeExchangePB.SubaccountOrdersListResponse{}, nil } -func (e *MockExchangeClient) GetSubaccountDerivativeTradesList(ctx context.Context, req derivativeExchangePB.SubaccountTradesListRequest) (derivativeExchangePB.SubaccountTradesListResponse, error) { - return derivativeExchangePB.SubaccountTradesListResponse{}, nil +func (e *MockExchangeClient) GetSubaccountDerivativeTradesList(ctx context.Context, req *derivativeExchangePB.SubaccountTradesListRequest) (*derivativeExchangePB.SubaccountTradesListResponse, error) { + return &derivativeExchangePB.SubaccountTradesListResponse{}, nil } -func (e *MockExchangeClient) GetHistoricalDerivativeOrders(ctx context.Context, req derivativeExchangePB.OrdersHistoryRequest) (derivativeExchangePB.OrdersHistoryResponse, error) { - return derivativeExchangePB.OrdersHistoryResponse{}, nil +func (e *MockExchangeClient) GetHistoricalDerivativeOrders(ctx context.Context, req *derivativeExchangePB.OrdersHistoryRequest) (*derivativeExchangePB.OrdersHistoryResponse, error) { + return &derivativeExchangePB.OrdersHistoryResponse{}, nil } -func (e *MockExchangeClient) StreamHistoricalDerivativeOrders(ctx context.Context, req derivativeExchangePB.StreamOrdersHistoryRequest) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamOrdersHistoryClient, error) { +func (e *MockExchangeClient) StreamHistoricalDerivativeOrders(ctx context.Context, req *derivativeExchangePB.StreamOrdersHistoryRequest) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamOrdersHistoryClient, error) { return nil, nil } -func (e *MockExchangeClient) GetDerivativeFundingPayments(ctx context.Context, req derivativeExchangePB.FundingPaymentsRequest) (derivativeExchangePB.FundingPaymentsResponse, error) { - return derivativeExchangePB.FundingPaymentsResponse{}, nil +func (e *MockExchangeClient) GetDerivativeFundingPayments(ctx context.Context, req *derivativeExchangePB.FundingPaymentsRequest) (*derivativeExchangePB.FundingPaymentsResponse, error) { + return &derivativeExchangePB.FundingPaymentsResponse{}, nil } -func (e *MockExchangeClient) GetDerivativeFundingRates(ctx context.Context, req derivativeExchangePB.FundingRatesRequest) (derivativeExchangePB.FundingRatesResponse, error) { - return derivativeExchangePB.FundingRatesResponse{}, nil +func (e *MockExchangeClient) GetDerivativeFundingRates(ctx context.Context, req *derivativeExchangePB.FundingRatesRequest) (*derivativeExchangePB.FundingRatesResponse, error) { + return &derivativeExchangePB.FundingRatesResponse{}, nil } -func (e *MockExchangeClient) GetPrice(ctx context.Context, baseSymbol string, quoteSymbol string, oracleType string, oracleScaleFactor uint32) (oraclePB.PriceResponse, error) { - return oraclePB.PriceResponse{}, nil +func (e *MockExchangeClient) GetPrice(ctx context.Context, baseSymbol string, quoteSymbol string, oracleType string, oracleScaleFactor uint32) (*oraclePB.PriceResponse, error) { + return &oraclePB.PriceResponse{}, nil } -func (e *MockExchangeClient) GetOracleList(ctx context.Context) (oraclePB.OracleListResponse, error) { - return oraclePB.OracleListResponse{}, nil +func (e *MockExchangeClient) GetOracleList(ctx context.Context) (*oraclePB.OracleListResponse, error) { + return &oraclePB.OracleListResponse{}, nil } func (e *MockExchangeClient) StreamPrices(ctx context.Context, baseSymbol string, quoteSymbol string, oracleType string) (oraclePB.InjectiveOracleRPC_StreamPricesClient, error) { return nil, nil } -func (e *MockExchangeClient) GetAuction(ctx context.Context, round int64) (auctionPB.AuctionEndpointResponse, error) { - return auctionPB.AuctionEndpointResponse{}, nil +func (e *MockExchangeClient) GetAuction(ctx context.Context, round int64) (*auctionPB.AuctionEndpointResponse, error) { + return &auctionPB.AuctionEndpointResponse{}, nil } -func (e *MockExchangeClient) GetAuctions(ctx context.Context) (auctionPB.AuctionsResponse, error) { - return auctionPB.AuctionsResponse{}, nil +func (e *MockExchangeClient) GetAuctions(ctx context.Context) (*auctionPB.AuctionsResponse, error) { + return &auctionPB.AuctionsResponse{}, nil } func (e *MockExchangeClient) StreamBids(ctx context.Context) (auctionPB.InjectiveAuctionRPC_StreamBidsClient, error) { return nil, nil } -func (e *MockExchangeClient) GetSubaccountsList(ctx context.Context, accountAddress string) (accountPB.SubaccountsListResponse, error) { - return accountPB.SubaccountsListResponse{}, nil +func (e *MockExchangeClient) GetSubaccountsList(ctx context.Context, accountAddress string) (*accountPB.SubaccountsListResponse, error) { + return &accountPB.SubaccountsListResponse{}, nil } -func (e *MockExchangeClient) GetSubaccountBalance(ctx context.Context, subaccountId string, denom string) (accountPB.SubaccountBalanceEndpointResponse, error) { - return accountPB.SubaccountBalanceEndpointResponse{}, nil +func (e *MockExchangeClient) GetSubaccountBalance(ctx context.Context, subaccountId string, denom string) (*accountPB.SubaccountBalanceEndpointResponse, error) { + return &accountPB.SubaccountBalanceEndpointResponse{}, nil } func (e *MockExchangeClient) StreamSubaccountBalance(ctx context.Context, subaccountId string) (accountPB.InjectiveAccountsRPC_StreamSubaccountBalanceClient, error) { return nil, nil } -func (e *MockExchangeClient) GetSubaccountBalancesList(ctx context.Context, subaccountId string) (accountPB.SubaccountBalancesListResponse, error) { - return accountPB.SubaccountBalancesListResponse{}, nil +func (e *MockExchangeClient) GetSubaccountBalancesList(ctx context.Context, subaccountId string) (*accountPB.SubaccountBalancesListResponse, error) { + return &accountPB.SubaccountBalancesListResponse{}, nil } -func (e *MockExchangeClient) GetSubaccountHistory(ctx context.Context, req accountPB.SubaccountHistoryRequest) (accountPB.SubaccountHistoryResponse, error) { - return accountPB.SubaccountHistoryResponse{}, nil +func (e *MockExchangeClient) GetSubaccountHistory(ctx context.Context, req *accountPB.SubaccountHistoryRequest) (*accountPB.SubaccountHistoryResponse, error) { + return &accountPB.SubaccountHistoryResponse{}, nil } -func (e *MockExchangeClient) GetSubaccountOrderSummary(ctx context.Context, req accountPB.SubaccountOrderSummaryRequest) (accountPB.SubaccountOrderSummaryResponse, error) { - return accountPB.SubaccountOrderSummaryResponse{}, nil +func (e *MockExchangeClient) GetSubaccountOrderSummary(ctx context.Context, req *accountPB.SubaccountOrderSummaryRequest) (*accountPB.SubaccountOrderSummaryResponse, error) { + return &accountPB.SubaccountOrderSummaryResponse{}, nil } -func (e *MockExchangeClient) GetOrderStates(ctx context.Context, req accountPB.OrderStatesRequest) (accountPB.OrderStatesResponse, error) { - return accountPB.OrderStatesResponse{}, nil +func (e *MockExchangeClient) GetOrderStates(ctx context.Context, req *accountPB.OrderStatesRequest) (*accountPB.OrderStatesResponse, error) { + return &accountPB.OrderStatesResponse{}, nil } -func (e *MockExchangeClient) GetPortfolio(ctx context.Context, accountAddress string) (accountPB.PortfolioResponse, error) { - return accountPB.PortfolioResponse{}, nil +func (e *MockExchangeClient) GetPortfolio(ctx context.Context, accountAddress string) (*accountPB.PortfolioResponse, error) { + return &accountPB.PortfolioResponse{}, nil } -func (e *MockExchangeClient) GetRewards(ctx context.Context, req accountPB.RewardsRequest) (accountPB.RewardsResponse, error) { - return accountPB.RewardsResponse{}, nil +func (e *MockExchangeClient) GetRewards(ctx context.Context, req *accountPB.RewardsRequest) (*accountPB.RewardsResponse, error) { + return &accountPB.RewardsResponse{}, nil } -func (e *MockExchangeClient) GetSpotOrders(ctx context.Context, req spotExchangePB.OrdersRequest) (spotExchangePB.OrdersResponse, error) { - return spotExchangePB.OrdersResponse{}, nil +func (e *MockExchangeClient) GetSpotOrders(ctx context.Context, req *spotExchangePB.OrdersRequest) (*spotExchangePB.OrdersResponse, error) { + return &spotExchangePB.OrdersResponse{}, nil } -func (e *MockExchangeClient) GetSpotOrderbookV2(ctx context.Context, marketId string) (spotExchangePB.OrderbookV2Response, error) { - return spotExchangePB.OrderbookV2Response{}, nil +func (e *MockExchangeClient) GetSpotOrderbookV2(ctx context.Context, marketId string) (*spotExchangePB.OrderbookV2Response, error) { + return &spotExchangePB.OrderbookV2Response{}, nil } -func (e *MockExchangeClient) GetSpotOrderbooksV2(ctx context.Context, marketIds []string) (spotExchangePB.OrderbooksV2Response, error) { - return spotExchangePB.OrderbooksV2Response{}, nil +func (e *MockExchangeClient) GetSpotOrderbooksV2(ctx context.Context, marketIds []string) (*spotExchangePB.OrderbooksV2Response, error) { + return &spotExchangePB.OrderbooksV2Response{}, nil } func (e *MockExchangeClient) StreamSpotOrderbookV2(ctx context.Context, marketIds []string) (spotExchangePB.InjectiveSpotExchangeRPC_StreamOrderbookV2Client, error) { @@ -207,79 +208,79 @@ func (e *MockExchangeClient) StreamSpotOrderbookUpdate(ctx context.Context, mark return nil, nil } -func (e *MockExchangeClient) GetSpotMarkets(ctx context.Context, req spotExchangePB.MarketsRequest) (spotExchangePB.MarketsResponse, error) { - var response spotExchangePB.MarketsResponse +func (e *MockExchangeClient) GetSpotMarkets(ctx context.Context, req *spotExchangePB.MarketsRequest) (*spotExchangePB.MarketsResponse, error) { + var response *spotExchangePB.MarketsResponse var localError error if len(e.SpotMarketsResponses) > 0 { response = e.SpotMarketsResponses[0] e.SpotMarketsResponses = e.SpotMarketsResponses[1:] localError = nil } else { - response = spotExchangePB.MarketsResponse{} + response = &spotExchangePB.MarketsResponse{} localError = errors.New("There are no responses configured") } return response, localError } -func (e *MockExchangeClient) GetSpotMarket(ctx context.Context, marketId string) (spotExchangePB.MarketResponse, error) { - return spotExchangePB.MarketResponse{}, nil +func (e *MockExchangeClient) GetSpotMarket(ctx context.Context, marketId string) (*spotExchangePB.MarketResponse, error) { + return &spotExchangePB.MarketResponse{}, nil } func (e *MockExchangeClient) StreamSpotMarket(ctx context.Context, marketIds []string) (spotExchangePB.InjectiveSpotExchangeRPC_StreamMarketsClient, error) { return nil, nil } -func (e *MockExchangeClient) StreamSpotOrders(ctx context.Context, req spotExchangePB.StreamOrdersRequest) (spotExchangePB.InjectiveSpotExchangeRPC_StreamOrdersClient, error) { +func (e *MockExchangeClient) StreamSpotOrders(ctx context.Context, req *spotExchangePB.StreamOrdersRequest) (spotExchangePB.InjectiveSpotExchangeRPC_StreamOrdersClient, error) { return nil, nil } -func (e *MockExchangeClient) GetSpotTrades(ctx context.Context, req spotExchangePB.TradesRequest) (spotExchangePB.TradesResponse, error) { - return spotExchangePB.TradesResponse{}, nil +func (e *MockExchangeClient) GetSpotTrades(ctx context.Context, req *spotExchangePB.TradesRequest) (*spotExchangePB.TradesResponse, error) { + return &spotExchangePB.TradesResponse{}, nil } -func (e *MockExchangeClient) GetSpotTradesV2(ctx context.Context, req spotExchangePB.TradesV2Request) (spotExchangePB.TradesV2Response, error) { - return spotExchangePB.TradesV2Response{}, nil +func (e *MockExchangeClient) GetSpotTradesV2(ctx context.Context, req *spotExchangePB.TradesV2Request) (*spotExchangePB.TradesV2Response, error) { + return &spotExchangePB.TradesV2Response{}, nil } -func (e *MockExchangeClient) StreamSpotTrades(ctx context.Context, req spotExchangePB.StreamTradesRequest) (spotExchangePB.InjectiveSpotExchangeRPC_StreamTradesClient, error) { +func (e *MockExchangeClient) StreamSpotTrades(ctx context.Context, req *spotExchangePB.StreamTradesRequest) (spotExchangePB.InjectiveSpotExchangeRPC_StreamTradesClient, error) { return nil, nil } -func (e *MockExchangeClient) StreamSpotTradesV2(ctx context.Context, req spotExchangePB.StreamTradesV2Request) (spotExchangePB.InjectiveSpotExchangeRPC_StreamTradesV2Client, error) { +func (e *MockExchangeClient) StreamSpotTradesV2(ctx context.Context, req *spotExchangePB.StreamTradesV2Request) (spotExchangePB.InjectiveSpotExchangeRPC_StreamTradesV2Client, error) { return nil, nil } -func (e *MockExchangeClient) GetSubaccountSpotOrdersList(ctx context.Context, req spotExchangePB.SubaccountOrdersListRequest) (spotExchangePB.SubaccountOrdersListResponse, error) { - return spotExchangePB.SubaccountOrdersListResponse{}, nil +func (e *MockExchangeClient) GetSubaccountSpotOrdersList(ctx context.Context, req *spotExchangePB.SubaccountOrdersListRequest) (*spotExchangePB.SubaccountOrdersListResponse, error) { + return &spotExchangePB.SubaccountOrdersListResponse{}, nil } -func (e *MockExchangeClient) GetSubaccountSpotTradesList(ctx context.Context, req spotExchangePB.SubaccountTradesListRequest) (spotExchangePB.SubaccountTradesListResponse, error) { - return spotExchangePB.SubaccountTradesListResponse{}, nil +func (e *MockExchangeClient) GetSubaccountSpotTradesList(ctx context.Context, req *spotExchangePB.SubaccountTradesListRequest) (*spotExchangePB.SubaccountTradesListResponse, error) { + return &spotExchangePB.SubaccountTradesListResponse{}, nil } -func (e *MockExchangeClient) GetHistoricalSpotOrders(ctx context.Context, req spotExchangePB.OrdersHistoryRequest) (spotExchangePB.OrdersHistoryResponse, error) { - return spotExchangePB.OrdersHistoryResponse{}, nil +func (e *MockExchangeClient) GetHistoricalSpotOrders(ctx context.Context, req *spotExchangePB.OrdersHistoryRequest) (*spotExchangePB.OrdersHistoryResponse, error) { + return &spotExchangePB.OrdersHistoryResponse{}, nil } -func (e *MockExchangeClient) StreamHistoricalSpotOrders(ctx context.Context, req spotExchangePB.StreamOrdersHistoryRequest) (spotExchangePB.InjectiveSpotExchangeRPC_StreamOrdersHistoryClient, error) { +func (e *MockExchangeClient) StreamHistoricalSpotOrders(ctx context.Context, req *spotExchangePB.StreamOrdersHistoryRequest) (spotExchangePB.InjectiveSpotExchangeRPC_StreamOrdersHistoryClient, error) { return nil, nil } -func (e *MockExchangeClient) GetInsuranceFunds(ctx context.Context, req insurancePB.FundsRequest) (insurancePB.FundsResponse, error) { - return insurancePB.FundsResponse{}, nil +func (e *MockExchangeClient) GetInsuranceFunds(ctx context.Context, req *insurancePB.FundsRequest) (*insurancePB.FundsResponse, error) { + return &insurancePB.FundsResponse{}, nil } -func (e *MockExchangeClient) GetRedemptions(ctx context.Context, req insurancePB.RedemptionsRequest) (insurancePB.RedemptionsResponse, error) { - return insurancePB.RedemptionsResponse{}, nil +func (e *MockExchangeClient) GetRedemptions(ctx context.Context, req *insurancePB.RedemptionsRequest) (*insurancePB.RedemptionsResponse, error) { + return &insurancePB.RedemptionsResponse{}, nil } -func (e *MockExchangeClient) GetAccountPortfolio(ctx context.Context, accountAddress string) (portfolioExchangePB.AccountPortfolioResponse, error) { - return portfolioExchangePB.AccountPortfolioResponse{}, nil +func (e *MockExchangeClient) GetAccountPortfolio(ctx context.Context, accountAddress string) (*portfolioExchangePB.AccountPortfolioResponse, error) { + return &portfolioExchangePB.AccountPortfolioResponse{}, nil } -func (e *MockExchangeClient) GetAccountPortfolioBalances(ctx context.Context, accountAddress string) (portfolioExchangePB.AccountPortfolioBalancesResponse, error) { - return portfolioExchangePB.AccountPortfolioBalancesResponse{}, nil +func (e *MockExchangeClient) GetAccountPortfolioBalances(ctx context.Context, accountAddress string) (*portfolioExchangePB.AccountPortfolioBalancesResponse, error) { + return &portfolioExchangePB.AccountPortfolioBalancesResponse{}, nil } func (e *MockExchangeClient) StreamAccountPortfolio(ctx context.Context, accountAddress string, subaccountId, balanceType string) (portfolioExchangePB.InjectivePortfolioRPC_StreamAccountPortfolioClient, error) { @@ -290,16 +291,16 @@ func (e *MockExchangeClient) StreamKeepalive(ctx context.Context) (metaPB.Inject return nil, nil } -func (e *MockExchangeClient) GetInfo(ctx context.Context, req metaPB.InfoRequest) (metaPB.InfoResponse, error) { - return metaPB.InfoResponse{}, nil +func (e *MockExchangeClient) GetInfo(ctx context.Context, req *metaPB.InfoRequest) (*metaPB.InfoResponse, error) { + return &metaPB.InfoResponse{}, nil } -func (e *MockExchangeClient) GetVersion(ctx context.Context, req metaPB.VersionRequest) (metaPB.VersionResponse, error) { - return metaPB.VersionResponse{}, nil +func (e *MockExchangeClient) GetVersion(ctx context.Context, req *metaPB.VersionRequest) (*metaPB.VersionResponse, error) { + return &metaPB.VersionResponse{}, nil } -func (e *MockExchangeClient) Ping(ctx context.Context, req metaPB.PingRequest) (metaPB.PingResponse, error) { - return metaPB.PingResponse{}, nil +func (e *MockExchangeClient) Ping(ctx context.Context, req *metaPB.PingRequest) (*metaPB.PingResponse, error) { + return &metaPB.PingResponse{}, nil } func (e *MockExchangeClient) Close() { diff --git a/client/explorer/explorer.go b/client/explorer/explorer.go index e5fcef53..00c76fc6 100644 --- a/client/explorer/explorer.go +++ b/client/explorer/explorer.go @@ -3,6 +3,9 @@ package exchange import ( "context" "fmt" + + "google.golang.org/grpc/credentials/insecure" + "github.com/InjectiveLabs/sdk-go/client/common" explorerPB "github.com/InjectiveLabs/sdk-go/exchange/explorer_rpc/pb" "google.golang.org/grpc/metadata" @@ -14,21 +17,21 @@ import ( type ExplorerClient interface { QueryClient() *grpc.ClientConn - GetTxByTxHash(ctx context.Context, hash string) (explorerPB.GetTxByTxHashResponse, error) - GetTxs(ctx context.Context, req explorerPB.GetTxsRequest) (explorerPB.GetTxsResponse, error) - GetBlock(ctx context.Context, blockHeight string) (explorerPB.GetBlockResponse, error) - GetBlocks(ctx context.Context) (explorerPB.GetBlocksResponse, error) - GetAccountTxs(ctx context.Context, req explorerPB.GetAccountTxsRequest) (explorerPB.GetAccountTxsResponse, error) - GetPeggyDeposits(ctx context.Context, req explorerPB.GetPeggyDepositTxsRequest) (explorerPB.GetPeggyDepositTxsResponse, error) - GetPeggyWithdrawals(ctx context.Context, req explorerPB.GetPeggyWithdrawalTxsRequest) (explorerPB.GetPeggyWithdrawalTxsResponse, error) - GetIBCTransfers(ctx context.Context, req explorerPB.GetIBCTransferTxsRequest) (explorerPB.GetIBCTransferTxsResponse, error) + GetTxByTxHash(ctx context.Context, hash string) (*explorerPB.GetTxByTxHashResponse, error) + GetTxs(ctx context.Context, req *explorerPB.GetTxsRequest) (*explorerPB.GetTxsResponse, error) + GetBlock(ctx context.Context, blockHeight string) (*explorerPB.GetBlockResponse, error) + GetBlocks(ctx context.Context) (*explorerPB.GetBlocksResponse, error) + GetAccountTxs(ctx context.Context, req *explorerPB.GetAccountTxsRequest) (*explorerPB.GetAccountTxsResponse, error) + GetPeggyDeposits(ctx context.Context, req *explorerPB.GetPeggyDepositTxsRequest) (*explorerPB.GetPeggyDepositTxsResponse, error) + GetPeggyWithdrawals(ctx context.Context, req *explorerPB.GetPeggyWithdrawalTxsRequest) (*explorerPB.GetPeggyWithdrawalTxsResponse, error) + GetIBCTransfers(ctx context.Context, req *explorerPB.GetIBCTransferTxsRequest) (*explorerPB.GetIBCTransferTxsResponse, error) StreamTxs(ctx context.Context) (explorerPB.InjectiveExplorerRPC_StreamTxsClient, error) StreamBlocks(ctx context.Context) (explorerPB.InjectiveExplorerRPC_StreamBlocksClient, error) - GetWasmCodes(ctx context.Context, req explorerPB.GetWasmCodesRequest) (explorerPB.GetWasmCodesResponse, error) - GetWasmCodeByID(ctx context.Context, req explorerPB.GetWasmCodeByIDRequest) (explorerPB.GetWasmCodeByIDResponse, error) - GetWasmContracts(ctx context.Context, req explorerPB.GetWasmContractsRequest) (explorerPB.GetWasmContractsResponse, error) - GetWasmContractByAddress(ctx context.Context, req explorerPB.GetWasmContractByAddressRequest) (explorerPB.GetWasmContractByAddressResponse, error) - GetCW20Balance(ctx context.Context, req explorerPB.GetCw20BalanceRequest) (explorerPB.GetCw20BalanceResponse, error) + GetWasmCodes(ctx context.Context, req *explorerPB.GetWasmCodesRequest) (*explorerPB.GetWasmCodesResponse, error) + GetWasmCodeByID(ctx context.Context, req *explorerPB.GetWasmCodeByIDRequest) (*explorerPB.GetWasmCodeByIDResponse, error) + GetWasmContracts(ctx context.Context, req *explorerPB.GetWasmContractsRequest) (*explorerPB.GetWasmContractsResponse, error) + GetWasmContractByAddress(ctx context.Context, req *explorerPB.GetWasmContractByAddressRequest) (*explorerPB.GetWasmContractByAddressResponse, error) + GetCW20Balance(ctx context.Context, req *explorerPB.GetCw20BalanceRequest) (*explorerPB.GetCw20BalanceResponse, error) Close() } @@ -51,7 +54,7 @@ func NewExplorerClient(network common.Network, options ...common.ClientOption) ( if opts.TLSCert != nil { conn, err = grpc.Dial(network.ExplorerGrpcEndpoint, grpc.WithTransportCredentials(opts.TLSCert), grpc.WithContextDialer(common.DialerFunc)) } else { - conn, err = grpc.Dial(network.ExplorerGrpcEndpoint, grpc.WithInsecure(), grpc.WithContextDialer(common.DialerFunc)) + conn, err = grpc.Dial(network.ExplorerGrpcEndpoint, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithContextDialer(common.DialerFunc)) } if err != nil { err := errors.Wrapf(err, "failed to connect to the gRPC: %s", network.ExplorerGrpcEndpoint) @@ -80,14 +83,16 @@ type explorerClient struct { conn *grpc.ClientConn logger log.Logger - sessionCookie string explorerClient explorerPB.InjectiveExplorerRPCClient } func (c *explorerClient) requestCookie() metadata.MD { var header metadata.MD req := explorerPB.GetTxsRequest{} - c.explorerClient.GetTxs(context.Background(), &req, grpc.Header(&header)) + _, err := c.explorerClient.GetTxs(context.Background(), &req, grpc.Header(&header)) + if err != nil { + panic(err) + } return header } @@ -97,18 +102,11 @@ func (c *explorerClient) getCookie(ctx context.Context) context.Context { return metadata.AppendToOutgoingContext(ctx, "cookie", cookie) } -func (c *explorerClient) setCookie(metadata metadata.MD) { - md := metadata.Get("set-cookie") - if len(md) > 0 { - c.sessionCookie = md[0] - } -} - func (c *explorerClient) QueryClient() *grpc.ClientConn { return c.conn } -func (c *explorerClient) GetTxByTxHash(ctx context.Context, hash string) (explorerPB.GetTxByTxHashResponse, error) { +func (c *explorerClient) GetTxByTxHash(ctx context.Context, hash string) (*explorerPB.GetTxByTxHashResponse, error) { req := explorerPB.GetTxByTxHashRequest{ Hash: hash, } @@ -117,37 +115,37 @@ func (c *explorerClient) GetTxByTxHash(ctx context.Context, hash string) (explor res, err := c.explorerClient.GetTxByTxHash(ctx, &req) if err != nil { fmt.Println(err) - return explorerPB.GetTxByTxHashResponse{}, err + return &explorerPB.GetTxByTxHashResponse{}, err } - return *res, nil + return res, nil } -func (c *explorerClient) GetAccountTxs(ctx context.Context, req explorerPB.GetAccountTxsRequest) (explorerPB.GetAccountTxsResponse, error) { +func (c *explorerClient) GetAccountTxs(ctx context.Context, req *explorerPB.GetAccountTxsRequest) (*explorerPB.GetAccountTxsResponse, error) { ctx = c.getCookie(ctx) - res, err := c.explorerClient.GetAccountTxs(ctx, &req) + res, err := c.explorerClient.GetAccountTxs(ctx, req) if err != nil { fmt.Println(err) - return explorerPB.GetAccountTxsResponse{}, err + return &explorerPB.GetAccountTxsResponse{}, err } - return *res, nil + return res, nil } -func (c *explorerClient) GetBlocks(ctx context.Context) (explorerPB.GetBlocksResponse, error) { +func (c *explorerClient) GetBlocks(ctx context.Context) (*explorerPB.GetBlocksResponse, error) { req := explorerPB.GetBlocksRequest{} ctx = c.getCookie(ctx) res, err := c.explorerClient.GetBlocks(ctx, &req) if err != nil { fmt.Println(err) - return explorerPB.GetBlocksResponse{}, err + return &explorerPB.GetBlocksResponse{}, err } - return *res, nil + return res, nil } -func (c *explorerClient) GetBlock(ctx context.Context, blockHeight string) (explorerPB.GetBlockResponse, error) { +func (c *explorerClient) GetBlock(ctx context.Context, blockHeight string) (*explorerPB.GetBlockResponse, error) { req := explorerPB.GetBlockRequest{ Id: blockHeight, } @@ -156,54 +154,54 @@ func (c *explorerClient) GetBlock(ctx context.Context, blockHeight string) (expl res, err := c.explorerClient.GetBlock(ctx, &req) if err != nil { fmt.Println(err) - return explorerPB.GetBlockResponse{}, err + return &explorerPB.GetBlockResponse{}, err } - return *res, nil + return res, nil } -func (c *explorerClient) GetTxs(ctx context.Context, req explorerPB.GetTxsRequest) (explorerPB.GetTxsResponse, error) { +func (c *explorerClient) GetTxs(ctx context.Context, req *explorerPB.GetTxsRequest) (*explorerPB.GetTxsResponse, error) { ctx = c.getCookie(ctx) - res, err := c.explorerClient.GetTxs(ctx, &req) + res, err := c.explorerClient.GetTxs(ctx, req) if err != nil { fmt.Println(err) - return explorerPB.GetTxsResponse{}, err + return &explorerPB.GetTxsResponse{}, err } - return *res, nil + return res, nil } -func (c *explorerClient) GetPeggyDeposits(ctx context.Context, req explorerPB.GetPeggyDepositTxsRequest) (explorerPB.GetPeggyDepositTxsResponse, error) { +func (c *explorerClient) GetPeggyDeposits(ctx context.Context, req *explorerPB.GetPeggyDepositTxsRequest) (*explorerPB.GetPeggyDepositTxsResponse, error) { ctx = c.getCookie(ctx) - res, err := c.explorerClient.GetPeggyDepositTxs(ctx, &req) + res, err := c.explorerClient.GetPeggyDepositTxs(ctx, req) if err != nil { fmt.Println(err) - return explorerPB.GetPeggyDepositTxsResponse{}, err + return &explorerPB.GetPeggyDepositTxsResponse{}, err } - return *res, nil + return res, nil } -func (c *explorerClient) GetPeggyWithdrawals(ctx context.Context, req explorerPB.GetPeggyWithdrawalTxsRequest) (explorerPB.GetPeggyWithdrawalTxsResponse, error) { +func (c *explorerClient) GetPeggyWithdrawals(ctx context.Context, req *explorerPB.GetPeggyWithdrawalTxsRequest) (*explorerPB.GetPeggyWithdrawalTxsResponse, error) { ctx = c.getCookie(ctx) - res, err := c.explorerClient.GetPeggyWithdrawalTxs(ctx, &req) + res, err := c.explorerClient.GetPeggyWithdrawalTxs(ctx, req) if err != nil { fmt.Println(err) - return explorerPB.GetPeggyWithdrawalTxsResponse{}, err + return &explorerPB.GetPeggyWithdrawalTxsResponse{}, err } - return *res, nil + return res, nil } -func (c *explorerClient) GetIBCTransfers(ctx context.Context, req explorerPB.GetIBCTransferTxsRequest) (explorerPB.GetIBCTransferTxsResponse, error) { +func (c *explorerClient) GetIBCTransfers(ctx context.Context, req *explorerPB.GetIBCTransferTxsRequest) (*explorerPB.GetIBCTransferTxsResponse, error) { ctx = c.getCookie(ctx) - res, err := c.explorerClient.GetIBCTransferTxs(ctx, &req) + res, err := c.explorerClient.GetIBCTransferTxs(ctx, req) if err != nil { fmt.Println(err) - return explorerPB.GetIBCTransferTxsResponse{}, err + return &explorerPB.GetIBCTransferTxsResponse{}, err } - return *res, nil + return res, nil } func (c *explorerClient) StreamTxs(ctx context.Context) (explorerPB.InjectiveExplorerRPC_StreamTxsClient, error) { @@ -232,59 +230,59 @@ func (c *explorerClient) StreamBlocks(ctx context.Context) (explorerPB.Injective return stream, nil } -func (c *explorerClient) GetWasmCodes(ctx context.Context, req explorerPB.GetWasmCodesRequest) (explorerPB.GetWasmCodesResponse, error) { +func (c *explorerClient) GetWasmCodes(ctx context.Context, req *explorerPB.GetWasmCodesRequest) (*explorerPB.GetWasmCodesResponse, error) { ctx = c.getCookie(ctx) - res, err := c.explorerClient.GetWasmCodes(ctx, &req) + res, err := c.explorerClient.GetWasmCodes(ctx, req) if err != nil { fmt.Println(err) - return explorerPB.GetWasmCodesResponse{}, err + return &explorerPB.GetWasmCodesResponse{}, err } - return *res, nil + return res, nil } -func (c *explorerClient) GetWasmCodeByID(ctx context.Context, req explorerPB.GetWasmCodeByIDRequest) (explorerPB.GetWasmCodeByIDResponse, error) { +func (c *explorerClient) GetWasmCodeByID(ctx context.Context, req *explorerPB.GetWasmCodeByIDRequest) (*explorerPB.GetWasmCodeByIDResponse, error) { ctx = c.getCookie(ctx) - res, err := c.explorerClient.GetWasmCodeByID(ctx, &req) + res, err := c.explorerClient.GetWasmCodeByID(ctx, req) if err != nil { fmt.Println(err) - return explorerPB.GetWasmCodeByIDResponse{}, err + return &explorerPB.GetWasmCodeByIDResponse{}, err } - return *res, nil + return res, nil } -func (c *explorerClient) GetWasmContracts(ctx context.Context, req explorerPB.GetWasmContractsRequest) (explorerPB.GetWasmContractsResponse, error) { +func (c *explorerClient) GetWasmContracts(ctx context.Context, req *explorerPB.GetWasmContractsRequest) (*explorerPB.GetWasmContractsResponse, error) { ctx = c.getCookie(ctx) - res, err := c.explorerClient.GetWasmContracts(ctx, &req) + res, err := c.explorerClient.GetWasmContracts(ctx, req) if err != nil { fmt.Println(err) - return explorerPB.GetWasmContractsResponse{}, err + return &explorerPB.GetWasmContractsResponse{}, err } - return *res, nil + return res, nil } -func (c *explorerClient) GetWasmContractByAddress(ctx context.Context, req explorerPB.GetWasmContractByAddressRequest) (explorerPB.GetWasmContractByAddressResponse, error) { +func (c *explorerClient) GetWasmContractByAddress(ctx context.Context, req *explorerPB.GetWasmContractByAddressRequest) (*explorerPB.GetWasmContractByAddressResponse, error) { ctx = c.getCookie(ctx) - res, err := c.explorerClient.GetWasmContractByAddress(ctx, &req) + res, err := c.explorerClient.GetWasmContractByAddress(ctx, req) if err != nil { fmt.Println(err) - return explorerPB.GetWasmContractByAddressResponse{}, err + return &explorerPB.GetWasmContractByAddressResponse{}, err } - return *res, nil + return res, nil } -func (c *explorerClient) GetCW20Balance(ctx context.Context, req explorerPB.GetCw20BalanceRequest) (explorerPB.GetCw20BalanceResponse, error) { +func (c *explorerClient) GetCW20Balance(ctx context.Context, req *explorerPB.GetCw20BalanceRequest) (*explorerPB.GetCw20BalanceResponse, error) { ctx = c.getCookie(ctx) - res, err := c.explorerClient.GetCw20Balance(ctx, &req) + res, err := c.explorerClient.GetCw20Balance(ctx, req) if err != nil { fmt.Println(err) - return explorerPB.GetCw20BalanceResponse{}, err + return &explorerPB.GetCw20BalanceResponse{}, err } - return *res, nil + return res, nil } func (c *explorerClient) Close() { diff --git a/client/metadata/assets/devnet-1.ini b/client/metadata/assets/devnet-1.ini index ea7462f8..5d4c12cb 100644 --- a/client/metadata/assets/devnet-1.ini +++ b/client/metadata/assets/devnet-1.ini @@ -255,4 +255,3 @@ decimals = 18 [USDC] peggy_denom = peggy0xdAC17F958D2ee523a2206206994597C13D831ec7 decimals = 6 - diff --git a/client/metadata/fetch_metadata.go b/client/metadata/fetch_metadata.go index 4e9d02bb..cb4f08b0 100644 --- a/client/metadata/fetch_metadata.go +++ b/client/metadata/fetch_metadata.go @@ -3,25 +3,18 @@ package main import ( "context" "fmt" + "os" + "github.com/InjectiveLabs/sdk-go/client/common" exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" derivativeExchangePB "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" - "os" //derivativeExchangePB "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" - spotExchangePB "github.com/InjectiveLabs/sdk-go/exchange/spot_exchange_rpc/pb" "math" "strconv" -) -func find(slice []string, val string) bool { - for _, item := range slice { - if item == val { - return true - } - } - return false -} + spotExchangePB "github.com/InjectiveLabs/sdk-go/exchange/spot_exchange_rpc/pb" +) var metadataTemplate = `[%s] description = '%s %s %s' @@ -50,7 +43,7 @@ func FetchDenom(network common.Network) { // fetch spot markets spotMarketsReq := spotExchangePB.MarketsRequest{MarketStatus: "active"} ctx := context.Background() - spotRes, err := exchangeClient.GetSpotMarkets(ctx, spotMarketsReq) + spotRes, err := exchangeClient.GetSpotMarkets(ctx, &spotMarketsReq) if err != nil { panic(err) } @@ -90,7 +83,7 @@ func FetchDenom(network common.Network) { //fetch derivative markets derivativeMarketsReq := derivativeExchangePB.MarketsRequest{MarketStatus: "active"} - derivativeRes, err := exchangeClient.GetDerivativeMarkets(ctx, derivativeMarketsReq) + derivativeRes, err := exchangeClient.GetDerivativeMarkets(ctx, &derivativeMarketsReq) if err != nil { panic(err) } diff --git a/ethereum/util/amounts.go b/ethereum/util/amounts.go index b195b404..1435beaa 100644 --- a/ethereum/util/amounts.go +++ b/ethereum/util/amounts.go @@ -27,11 +27,11 @@ func (w *Wei) Scan(v interface{}) error { return nil } var source string - switch v.(type) { + switch value := v.(type) { case string: - source = v.(string) + source = value case []byte: - source = string(v.([]byte)) + source = string(value) default: return fmt.Errorf("incompatible type for decimal.Decimal: %T", v) } diff --git a/examples/chain/0_LocalOrderHash/example.go b/examples/chain/0_LocalOrderHash/example.go index 4ef82e54..4e36982f 100644 --- a/examples/chain/0_LocalOrderHash/example.go +++ b/examples/chain/0_LocalOrderHash/example.go @@ -3,11 +3,12 @@ package main import ( "context" "fmt" - exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" - "github.com/google/uuid" "os" "time" + exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" + "github.com/google/uuid" + exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" "github.com/InjectiveLabs/sdk-go/client" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" diff --git a/examples/chain/10_MsgBatchCancelDerivativeOrders/example.go b/examples/chain/10_MsgBatchCancelDerivativeOrders/example.go index b0341a84..d59a188e 100644 --- a/examples/chain/10_MsgBatchCancelDerivativeOrders/example.go +++ b/examples/chain/10_MsgBatchCancelDerivativeOrders/example.go @@ -2,10 +2,11 @@ package main import ( "fmt" - "github.com/InjectiveLabs/sdk-go/client" "os" "time" + "github.com/InjectiveLabs/sdk-go/client" + "github.com/InjectiveLabs/sdk-go/client/common" exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" diff --git a/examples/chain/11_MsgBatchCreateSpotLimitOrders/example.go b/examples/chain/11_MsgBatchCreateSpotLimitOrders/example.go index 511fdd13..8cb5e33a 100644 --- a/examples/chain/11_MsgBatchCreateSpotLimitOrders/example.go +++ b/examples/chain/11_MsgBatchCreateSpotLimitOrders/example.go @@ -3,11 +3,12 @@ package main import ( "context" "fmt" - exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" - "github.com/google/uuid" "os" "time" + exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" + "github.com/google/uuid" + "github.com/InjectiveLabs/sdk-go/client/common" "github.com/shopspring/decimal" diff --git a/examples/chain/12_MsgBatchCreateDerivativeLimitOrders/example.go b/examples/chain/12_MsgBatchCreateDerivativeLimitOrders/example.go index c1f87007..cd6ce01e 100644 --- a/examples/chain/12_MsgBatchCreateDerivativeLimitOrders/example.go +++ b/examples/chain/12_MsgBatchCreateDerivativeLimitOrders/example.go @@ -3,11 +3,12 @@ package main import ( "context" "fmt" - exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" - "github.com/google/uuid" "os" "time" + exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" + "github.com/google/uuid" + "github.com/InjectiveLabs/sdk-go/client/common" "github.com/shopspring/decimal" diff --git a/examples/chain/13_MsgIncreasePositionMargin/example.go b/examples/chain/13_MsgIncreasePositionMargin/example.go index 1510d521..578d9243 100644 --- a/examples/chain/13_MsgIncreasePositionMargin/example.go +++ b/examples/chain/13_MsgIncreasePositionMargin/example.go @@ -2,10 +2,11 @@ package main import ( "fmt" - "github.com/InjectiveLabs/sdk-go/client" "os" "time" + "github.com/InjectiveLabs/sdk-go/client" + "github.com/InjectiveLabs/sdk-go/client/common" exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" diff --git a/examples/chain/17_MsgBatchUpdateOrders/example.go b/examples/chain/17_MsgBatchUpdateOrders/example.go index cf1d399a..4f10490c 100644 --- a/examples/chain/17_MsgBatchUpdateOrders/example.go +++ b/examples/chain/17_MsgBatchUpdateOrders/example.go @@ -3,11 +3,12 @@ package main import ( "context" "fmt" - exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" - "github.com/google/uuid" "os" "time" + exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" + "github.com/google/uuid" + "github.com/InjectiveLabs/sdk-go/client" "github.com/InjectiveLabs/sdk-go/client/common" "github.com/shopspring/decimal" diff --git a/examples/chain/19_MsgGrant/example.go b/examples/chain/19_MsgGrant/example.go index 8989068e..02f5116e 100644 --- a/examples/chain/19_MsgGrant/example.go +++ b/examples/chain/19_MsgGrant/example.go @@ -2,10 +2,11 @@ package main import ( "fmt" - "github.com/InjectiveLabs/sdk-go/client" "os" "time" + "github.com/InjectiveLabs/sdk-go/client" + "github.com/InjectiveLabs/sdk-go/client/common" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" diff --git a/examples/chain/1_MsgSend/example.go b/examples/chain/1_MsgSend/example.go index 80aee16e..d49591a3 100644 --- a/examples/chain/1_MsgSend/example.go +++ b/examples/chain/1_MsgSend/example.go @@ -2,10 +2,11 @@ package main import ( "fmt" - "github.com/InjectiveLabs/sdk-go/client" "os" "time" + "github.com/InjectiveLabs/sdk-go/client" + "github.com/InjectiveLabs/sdk-go/client/common" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" diff --git a/examples/chain/20_MsgExec/example.go b/examples/chain/20_MsgExec/example.go index 78b3136a..ccb0e8f5 100644 --- a/examples/chain/20_MsgExec/example.go +++ b/examples/chain/20_MsgExec/example.go @@ -3,10 +3,11 @@ package main import ( "context" "fmt" - exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" "os" "time" + exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" + "github.com/InjectiveLabs/sdk-go/client" "github.com/InjectiveLabs/sdk-go/client/common" "github.com/shopspring/decimal" diff --git a/examples/chain/27_QueryAuthzGrants/example.go b/examples/chain/27_QueryAuthzGrants/example.go index 9756bb57..a50706a2 100644 --- a/examples/chain/27_QueryAuthzGrants/example.go +++ b/examples/chain/27_QueryAuthzGrants/example.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/InjectiveLabs/sdk-go/client" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" diff --git a/examples/chain/28_BankBalances/example.go b/examples/chain/28_BankBalances/example.go index d43253fe..a183fcc7 100644 --- a/examples/chain/28_BankBalances/example.go +++ b/examples/chain/28_BankBalances/example.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/InjectiveLabs/sdk-go/client" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" "github.com/InjectiveLabs/sdk-go/client/common" diff --git a/examples/chain/29_BankBalance/example.go b/examples/chain/29_BankBalance/example.go index 941d00a5..98c48cca 100644 --- a/examples/chain/29_BankBalance/example.go +++ b/examples/chain/29_BankBalance/example.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/InjectiveLabs/sdk-go/client" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" diff --git a/examples/chain/2_MsgDeposit/example.go b/examples/chain/2_MsgDeposit/example.go index 78ba72d5..abf339a4 100644 --- a/examples/chain/2_MsgDeposit/example.go +++ b/examples/chain/2_MsgDeposit/example.go @@ -2,10 +2,11 @@ package main import ( "fmt" - "github.com/InjectiveLabs/sdk-go/client" "os" "time" + "github.com/InjectiveLabs/sdk-go/client" + "github.com/InjectiveLabs/sdk-go/client/common" sdktypes "github.com/cosmos/cosmos-sdk/types" diff --git a/examples/chain/33_GetBlock/example.go b/examples/chain/33_GetBlock/example.go index a0e70672..35e195dd 100644 --- a/examples/chain/33_GetBlock/example.go +++ b/examples/chain/33_GetBlock/example.go @@ -3,6 +3,7 @@ package main import ( "context" "fmt" + "github.com/InjectiveLabs/sdk-go/client/common" tmclient "github.com/InjectiveLabs/sdk-go/client/tm" ) diff --git a/examples/chain/34_OfflineSigning/example.go b/examples/chain/34_OfflineSigning/example.go index 83529e69..8b6d50a4 100644 --- a/examples/chain/34_OfflineSigning/example.go +++ b/examples/chain/34_OfflineSigning/example.go @@ -4,10 +4,11 @@ package main import ( "context" "fmt" - exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" "io/ioutil" "os" + exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" + "github.com/InjectiveLabs/sdk-go/client" "github.com/InjectiveLabs/sdk-go/client/common" "github.com/shopspring/decimal" diff --git a/examples/chain/35_StreamEventOrderFail/example.go b/examples/chain/35_StreamEventOrderFail/example.go index 15843847..91be988a 100644 --- a/examples/chain/35_StreamEventOrderFail/example.go +++ b/examples/chain/35_StreamEventOrderFail/example.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "github.com/InjectiveLabs/sdk-go/client" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" diff --git a/examples/chain/36_StreamEventOrderbookUpdate/example.go b/examples/chain/36_StreamEventOrderbookUpdate/example.go index 027831ce..21a669fe 100644 --- a/examples/chain/36_StreamEventOrderbookUpdate/example.go +++ b/examples/chain/36_StreamEventOrderbookUpdate/example.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "github.com/InjectiveLabs/sdk-go/client" exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" diff --git a/examples/chain/37_DecodeTx/37_decode_tx.go b/examples/chain/37_DecodeTx/37_decode_tx.go index b444eb18..f72f564c 100644 --- a/examples/chain/37_DecodeTx/37_decode_tx.go +++ b/examples/chain/37_DecodeTx/37_decode_tx.go @@ -3,6 +3,7 @@ package main import ( "encoding/base64" "fmt" + cosmostxpb "github.com/cosmos/cosmos-sdk/types/tx" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) diff --git a/examples/chain/3_MsgCreateSpotLimitOrder/example.go b/examples/chain/3_MsgCreateSpotLimitOrder/example.go index 17839fdf..0f228f36 100644 --- a/examples/chain/3_MsgCreateSpotLimitOrder/example.go +++ b/examples/chain/3_MsgCreateSpotLimitOrder/example.go @@ -3,11 +3,12 @@ package main import ( "context" "fmt" - exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" - "github.com/google/uuid" "os" "time" + exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" + "github.com/google/uuid" + "github.com/InjectiveLabs/sdk-go/client" "github.com/InjectiveLabs/sdk-go/client/common" "github.com/shopspring/decimal" diff --git a/examples/chain/40_ChainStream/example.go b/examples/chain/40_ChainStream/example.go index 2b62d21f..7279f0e2 100644 --- a/examples/chain/40_ChainStream/example.go +++ b/examples/chain/40_ChainStream/example.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + chainStreamModule "github.com/InjectiveLabs/sdk-go/chain/stream/types" "github.com/InjectiveLabs/sdk-go/client" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" diff --git a/examples/chain/41_BroadcastMsgWithoutSimulation/example.go b/examples/chain/41_BroadcastMsgWithoutSimulation/example.go index 589dcaee..044e2e4f 100644 --- a/examples/chain/41_BroadcastMsgWithoutSimulation/example.go +++ b/examples/chain/41_BroadcastMsgWithoutSimulation/example.go @@ -3,12 +3,13 @@ package main import ( "context" "fmt" + "os" + "github.com/InjectiveLabs/sdk-go/client" "github.com/InjectiveLabs/sdk-go/client/common" exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" "github.com/google/uuid" "github.com/shopspring/decimal" - "os" exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" diff --git a/examples/chain/42_BankSpendableBalances/example.go b/examples/chain/42_BankSpendableBalances/example.go index 43e9c372..46dfb55e 100644 --- a/examples/chain/42_BankSpendableBalances/example.go +++ b/examples/chain/42_BankSpendableBalances/example.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/InjectiveLabs/sdk-go/client" "github.com/cosmos/cosmos-sdk/types/query" diff --git a/examples/chain/43_BankSpendableBalancesByDenom/example.go b/examples/chain/43_BankSpendableBalancesByDenom/example.go index 1ca380b4..e087f283 100644 --- a/examples/chain/43_BankSpendableBalancesByDenom/example.go +++ b/examples/chain/43_BankSpendableBalancesByDenom/example.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/InjectiveLabs/sdk-go/client" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" "github.com/InjectiveLabs/sdk-go/client/common" diff --git a/examples/chain/44_BankTotalSupply/example.go b/examples/chain/44_BankTotalSupply/example.go index 8eed8f36..092bf82f 100644 --- a/examples/chain/44_BankTotalSupply/example.go +++ b/examples/chain/44_BankTotalSupply/example.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/InjectiveLabs/sdk-go/client" "github.com/cosmos/cosmos-sdk/types/query" diff --git a/examples/chain/45_BankSupplyOf/example.go b/examples/chain/45_BankSupplyOf/example.go index 40d51d4d..869c791d 100644 --- a/examples/chain/45_BankSupplyOf/example.go +++ b/examples/chain/45_BankSupplyOf/example.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/InjectiveLabs/sdk-go/client" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" "github.com/InjectiveLabs/sdk-go/client/common" diff --git a/examples/chain/46_DenomMetadata/example.go b/examples/chain/46_DenomMetadata/example.go index 70a3ce7d..15a37935 100644 --- a/examples/chain/46_DenomMetadata/example.go +++ b/examples/chain/46_DenomMetadata/example.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/InjectiveLabs/sdk-go/client" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" "github.com/InjectiveLabs/sdk-go/client/common" diff --git a/examples/chain/47_DenomsMetadata/example.go b/examples/chain/47_DenomsMetadata/example.go index 4bd59040..f456f333 100644 --- a/examples/chain/47_DenomsMetadata/example.go +++ b/examples/chain/47_DenomsMetadata/example.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/InjectiveLabs/sdk-go/client" "github.com/cosmos/cosmos-sdk/types/query" diff --git a/examples/chain/48_DenomOwners/example.go b/examples/chain/48_DenomOwners/example.go index 1c8edf7e..e40b1d82 100644 --- a/examples/chain/48_DenomOwners/example.go +++ b/examples/chain/48_DenomOwners/example.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/InjectiveLabs/sdk-go/client" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" "github.com/InjectiveLabs/sdk-go/client/common" diff --git a/examples/chain/50_BankSendEnabled/example.go b/examples/chain/49_BankSendEnabled/example.go similarity index 99% rename from examples/chain/50_BankSendEnabled/example.go rename to examples/chain/49_BankSendEnabled/example.go index 501314c6..69ae56fd 100644 --- a/examples/chain/50_BankSendEnabled/example.go +++ b/examples/chain/49_BankSendEnabled/example.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/InjectiveLabs/sdk-go/client" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" "github.com/InjectiveLabs/sdk-go/client/common" diff --git a/examples/chain/49_DenomOwners/example.go b/examples/chain/49_DenomOwners/example.go deleted file mode 100644 index 1c8edf7e..00000000 --- a/examples/chain/49_DenomOwners/example.go +++ /dev/null @@ -1,71 +0,0 @@ -package main - -import ( - "context" - "encoding/json" - "fmt" - "github.com/InjectiveLabs/sdk-go/client" - chainclient "github.com/InjectiveLabs/sdk-go/client/chain" - "github.com/InjectiveLabs/sdk-go/client/common" - rpchttp "github.com/cometbft/cometbft/rpc/client/http" - "github.com/cosmos/cosmos-sdk/types/query" - - "os" -) - -func main() { - network := common.LoadNetwork("testnet", "lb") - tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") - if err != nil { - panic(err) - } - - senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( - os.Getenv("HOME")+"/.injectived", - "injectived", - "file", - "inj-user", - "12345678", - "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided - false, - ) - - if err != nil { - panic(err) - } - - clientCtx, err := chainclient.NewClientContext( - network.ChainId, - senderAddress.String(), - cosmosKeyring, - ) - - if err != nil { - panic(err) - } - - clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) - - chainClient, err := chainclient.NewChainClient( - clientCtx, - network, - common.OptionGasPrices(client.DefaultGasPriceWithDenom), - ) - - if err != nil { - panic(err) - } - - denom := "factory/inj107aqkjc3t5r3l9j4n9lgrma5tm3jav8qgppz6m/position" - pagination := query.PageRequest{Limit: 10} - ctx := context.Background() - - res, err := chainClient.GetDenomOwners(ctx, denom, &pagination) - if err != nil { - fmt.Println(err) - } - - str, _ := json.MarshalIndent(res, "", " ") - fmt.Print(string(str)) - -} diff --git a/examples/chain/4_MsgCreateSpotMarketOrder/example.go b/examples/chain/4_MsgCreateSpotMarketOrder/example.go index ee756e3e..8c9f30e6 100644 --- a/examples/chain/4_MsgCreateSpotMarketOrder/example.go +++ b/examples/chain/4_MsgCreateSpotMarketOrder/example.go @@ -3,11 +3,12 @@ package main import ( "context" "fmt" - exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" - "github.com/google/uuid" "os" "time" + exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" + "github.com/google/uuid" + "github.com/InjectiveLabs/sdk-go/client" "github.com/InjectiveLabs/sdk-go/client/common" "github.com/shopspring/decimal" diff --git a/examples/chain/5_MsgCancelSpotOrder/example.go b/examples/chain/5_MsgCancelSpotOrder/example.go index a259c4b7..f42ec5cc 100644 --- a/examples/chain/5_MsgCancelSpotOrder/example.go +++ b/examples/chain/5_MsgCancelSpotOrder/example.go @@ -2,10 +2,11 @@ package main import ( "fmt" - "github.com/InjectiveLabs/sdk-go/client" "os" "time" + "github.com/InjectiveLabs/sdk-go/client" + "github.com/InjectiveLabs/sdk-go/client/common" exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" diff --git a/examples/chain/6_MsgCreateDerivativeLimitOrder/example.go b/examples/chain/6_MsgCreateDerivativeLimitOrder/example.go index 8609c76d..57f615e9 100644 --- a/examples/chain/6_MsgCreateDerivativeLimitOrder/example.go +++ b/examples/chain/6_MsgCreateDerivativeLimitOrder/example.go @@ -3,11 +3,12 @@ package main import ( "context" "fmt" - exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" - "github.com/google/uuid" "os" "time" + exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" + "github.com/google/uuid" + "github.com/InjectiveLabs/sdk-go/client/common" "github.com/shopspring/decimal" diff --git a/examples/chain/7_MsgCreateDerivativeMarketOrder/example.go b/examples/chain/7_MsgCreateDerivativeMarketOrder/example.go index 8d9ca8d7..5eae8eee 100644 --- a/examples/chain/7_MsgCreateDerivativeMarketOrder/example.go +++ b/examples/chain/7_MsgCreateDerivativeMarketOrder/example.go @@ -3,11 +3,12 @@ package main import ( "context" "fmt" - exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" - "github.com/google/uuid" "os" "time" + exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" + "github.com/google/uuid" + "github.com/InjectiveLabs/sdk-go/client/common" "github.com/shopspring/decimal" diff --git a/examples/chain/8_MsgCancelDerivativeOrder/example.go b/examples/chain/8_MsgCancelDerivativeOrder/example.go index 05943605..dd5972d2 100644 --- a/examples/chain/8_MsgCancelDerivativeOrder/example.go +++ b/examples/chain/8_MsgCancelDerivativeOrder/example.go @@ -2,10 +2,11 @@ package main import ( "fmt" - "github.com/InjectiveLabs/sdk-go/client" "os" "time" + "github.com/InjectiveLabs/sdk-go/client" + "github.com/InjectiveLabs/sdk-go/client/common" exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" diff --git a/examples/chain/9_MsgBatchCancelSpotOrders/example.go b/examples/chain/9_MsgBatchCancelSpotOrders/example.go index 0f1594a6..2734d9f8 100644 --- a/examples/chain/9_MsgBatchCancelSpotOrders/example.go +++ b/examples/chain/9_MsgBatchCancelSpotOrders/example.go @@ -2,10 +2,11 @@ package main import ( "fmt" - "github.com/InjectiveLabs/sdk-go/client" "os" "time" + "github.com/InjectiveLabs/sdk-go/client" + "github.com/InjectiveLabs/sdk-go/client/common" exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" diff --git a/examples/exchange/accounts/5_SubaccountHistory/example.go b/examples/exchange/accounts/5_SubaccountHistory/example.go index b8b54798..8dc67c4a 100644 --- a/examples/exchange/accounts/5_SubaccountHistory/example.go +++ b/examples/exchange/accounts/5_SubaccountHistory/example.go @@ -32,7 +32,7 @@ func main() { Limit: limit, } - res, err := exchangeClient.GetSubaccountHistory(ctx, req) + res, err := exchangeClient.GetSubaccountHistory(ctx, &req) if err != nil { fmt.Println(err) } diff --git a/examples/exchange/accounts/6_SubaccountOrderSummary/example.go b/examples/exchange/accounts/6_SubaccountOrderSummary/example.go index 01176ee3..bc8da227 100644 --- a/examples/exchange/accounts/6_SubaccountOrderSummary/example.go +++ b/examples/exchange/accounts/6_SubaccountOrderSummary/example.go @@ -27,7 +27,7 @@ func main() { OrderDirection: orderDirection, } - res, err := exchangeClient.GetSubaccountOrderSummary(ctx, req) + res, err := exchangeClient.GetSubaccountOrderSummary(ctx, &req) if err != nil { fmt.Println(err) } diff --git a/examples/exchange/accounts/7_OrderStates/example.go b/examples/exchange/accounts/7_OrderStates/example.go index 1db56f65..f6b849da 100644 --- a/examples/exchange/accounts/7_OrderStates/example.go +++ b/examples/exchange/accounts/7_OrderStates/example.go @@ -26,7 +26,7 @@ func main() { DerivativeOrderHashes: derivativeOrderHashes, } - res, err := exchangeClient.GetOrderStates(ctx, req) + res, err := exchangeClient.GetOrderStates(ctx, &req) if err != nil { fmt.Println(err) } diff --git a/examples/exchange/accounts/9_Rewards/example.go b/examples/exchange/accounts/9_Rewards/example.go index af024703..3cdc0330 100644 --- a/examples/exchange/accounts/9_Rewards/example.go +++ b/examples/exchange/accounts/9_Rewards/example.go @@ -26,7 +26,7 @@ func main() { AccountAddress: accountAddress, } - res, err := exchangeClient.GetRewards(ctx, req) + res, err := exchangeClient.GetRewards(ctx, &req) if err != nil { fmt.Println(err) } diff --git a/examples/exchange/derivatives/10_StreamPositions/example.go b/examples/exchange/derivatives/10_StreamPositions/example.go index 23f38139..af23ee70 100644 --- a/examples/exchange/derivatives/10_StreamPositions/example.go +++ b/examples/exchange/derivatives/10_StreamPositions/example.go @@ -25,7 +25,7 @@ func main() { MarketId: marketId, SubaccountId: subaccountId, } - stream, err := exchangeClient.StreamDerivativePositions(ctx, req) + stream, err := exchangeClient.StreamDerivativePositions(ctx, &req) if err != nil { panic(err) } diff --git a/examples/exchange/derivatives/11_StreamOrders/example.go b/examples/exchange/derivatives/11_StreamOrders/example.go index 393bc86b..245d6f69 100644 --- a/examples/exchange/derivatives/11_StreamOrders/example.go +++ b/examples/exchange/derivatives/11_StreamOrders/example.go @@ -27,7 +27,7 @@ func main() { SubaccountId: subaccountId, OrderSide: orderSide, } - stream, err := exchangeClient.StreamDerivativeOrders(ctx, req) + stream, err := exchangeClient.StreamDerivativeOrders(ctx, &req) if err != nil { panic(err) } diff --git a/examples/exchange/derivatives/12_Trades/example.go b/examples/exchange/derivatives/12_Trades/example.go index 48377621..2a5712c8 100644 --- a/examples/exchange/derivatives/12_Trades/example.go +++ b/examples/exchange/derivatives/12_Trades/example.go @@ -26,7 +26,7 @@ func main() { SubaccountId: subaccountId, } - res, err := exchangeClient.GetDerivativeTrades(ctx, req) + res, err := exchangeClient.GetDerivativeTrades(ctx, &req) if err != nil { panic(err) } diff --git a/examples/exchange/derivatives/13_StreamTrades/example.go b/examples/exchange/derivatives/13_StreamTrades/example.go index a94c49f7..02239ad5 100644 --- a/examples/exchange/derivatives/13_StreamTrades/example.go +++ b/examples/exchange/derivatives/13_StreamTrades/example.go @@ -26,7 +26,7 @@ func main() { MarketId: marketId, SubaccountId: subaccountId, } - stream, err := exchangeClient.StreamDerivativeTrades(ctx, req) + stream, err := exchangeClient.StreamDerivativeTrades(ctx, &req) if err != nil { panic(err) } diff --git a/examples/exchange/derivatives/14_SubaccountOrdersList/example.go b/examples/exchange/derivatives/14_SubaccountOrdersList/example.go index c8cd6db6..0177193e 100644 --- a/examples/exchange/derivatives/14_SubaccountOrdersList/example.go +++ b/examples/exchange/derivatives/14_SubaccountOrdersList/example.go @@ -31,7 +31,7 @@ func main() { Limit: limit, } - res, err := exchangeClient.GetSubaccountDerivativeOrdersList(ctx, req) + res, err := exchangeClient.GetSubaccountDerivativeOrdersList(ctx, &req) if err != nil { panic(err) } diff --git a/examples/exchange/derivatives/15_SubaccountTradesList/example.go b/examples/exchange/derivatives/15_SubaccountTradesList/example.go index 2b8a1d04..2bf30a1e 100644 --- a/examples/exchange/derivatives/15_SubaccountTradesList/example.go +++ b/examples/exchange/derivatives/15_SubaccountTradesList/example.go @@ -31,7 +31,7 @@ func main() { Limit: limit, } - res, err := exchangeClient.GetSubaccountDerivativeTradesList(ctx, req) + res, err := exchangeClient.GetSubaccountDerivativeTradesList(ctx, &req) if err != nil { panic(err) } diff --git a/examples/exchange/derivatives/16_FundingPayments/example.go b/examples/exchange/derivatives/16_FundingPayments/example.go index d1d960e0..8aa286c9 100644 --- a/examples/exchange/derivatives/16_FundingPayments/example.go +++ b/examples/exchange/derivatives/16_FundingPayments/example.go @@ -27,7 +27,7 @@ func main() { SubaccountId: subaccountId, } - res, err := exchangeClient.GetDerivativeFundingPayments(ctx, req) + res, err := exchangeClient.GetDerivativeFundingPayments(ctx, &req) if err != nil { panic(err) } diff --git a/examples/exchange/derivatives/17_FundingRates/example.go b/examples/exchange/derivatives/17_FundingRates/example.go index 53c799af..0512f91a 100644 --- a/examples/exchange/derivatives/17_FundingRates/example.go +++ b/examples/exchange/derivatives/17_FundingRates/example.go @@ -25,7 +25,7 @@ func main() { MarketId: marketId, } - res, err := exchangeClient.GetDerivativeFundingRates(ctx, req) + res, err := exchangeClient.GetDerivativeFundingRates(ctx, &req) if err != nil { panic(err) } diff --git a/examples/exchange/derivatives/18_HistoricalOrders/example.go b/examples/exchange/derivatives/18_HistoricalOrders/example.go index 2b39b069..718b6c00 100644 --- a/examples/exchange/derivatives/18_HistoricalOrders/example.go +++ b/examples/exchange/derivatives/18_HistoricalOrders/example.go @@ -32,7 +32,7 @@ func main() { IsConditional: isConditional, } - res, err := exchangeClient.GetHistoricalDerivativeOrders(ctx, req) + res, err := exchangeClient.GetHistoricalDerivativeOrders(ctx, &req) if err != nil { panic(err) } diff --git a/examples/exchange/derivatives/19_StreamHistoricalOrders/example.go b/examples/exchange/derivatives/19_StreamHistoricalOrders/example.go index e3260f6c..3c49b01d 100644 --- a/examples/exchange/derivatives/19_StreamHistoricalOrders/example.go +++ b/examples/exchange/derivatives/19_StreamHistoricalOrders/example.go @@ -27,7 +27,7 @@ func main() { SubaccountId: subaccountId, Direction: direction, } - stream, err := exchangeClient.StreamHistoricalDerivativeOrders(ctx, req) + stream, err := exchangeClient.StreamHistoricalDerivativeOrders(ctx, &req) if err != nil { panic(err) } diff --git a/examples/exchange/derivatives/20_LiquidablePositions/example.go b/examples/exchange/derivatives/20_LiquidablePositions/example.go index 0759019a..3b28112d 100644 --- a/examples/exchange/derivatives/20_LiquidablePositions/example.go +++ b/examples/exchange/derivatives/20_LiquidablePositions/example.go @@ -28,7 +28,7 @@ func main() { Limit: limit, } - res, err := exchangeClient.GetDerivativeLiquidablePositions(ctx, req) + res, err := exchangeClient.GetDerivativeLiquidablePositions(ctx, &req) if err != nil { panic(err) } diff --git a/examples/exchange/derivatives/21_TradesV2/example.go b/examples/exchange/derivatives/21_TradesV2/example.go index 51ea10cb..1edf4d98 100644 --- a/examples/exchange/derivatives/21_TradesV2/example.go +++ b/examples/exchange/derivatives/21_TradesV2/example.go @@ -26,7 +26,7 @@ func main() { SubaccountId: subaccountId, } - res, err := exchangeClient.GetDerivativeTradesV2(ctx, req) + res, err := exchangeClient.GetDerivativeTradesV2(ctx, &req) if err != nil { panic(err) } diff --git a/examples/exchange/derivatives/22_StreamTradesV2/example.go b/examples/exchange/derivatives/22_StreamTradesV2/example.go index e771be2f..3d78df5d 100644 --- a/examples/exchange/derivatives/22_StreamTradesV2/example.go +++ b/examples/exchange/derivatives/22_StreamTradesV2/example.go @@ -25,7 +25,7 @@ func main() { MarketId: marketId, SubaccountId: subaccountId, } - stream, err := exchangeClient.StreamDerivativeV2Trades(ctx, req) + stream, err := exchangeClient.StreamDerivativeV2Trades(ctx, &req) if err != nil { panic(err) } diff --git a/examples/exchange/derivatives/2_Markets/example.go b/examples/exchange/derivatives/2_Markets/example.go index c4654980..97618d7a 100644 --- a/examples/exchange/derivatives/2_Markets/example.go +++ b/examples/exchange/derivatives/2_Markets/example.go @@ -27,7 +27,7 @@ func main() { QuoteDenom: quoteDenom, } - res, err := exchangeClient.GetDerivativeMarkets(ctx, req) + res, err := exchangeClient.GetDerivativeMarkets(ctx, &req) if err != nil { panic(err) } diff --git a/examples/exchange/derivatives/8_Positions/example.go b/examples/exchange/derivatives/8_Positions/example.go index b3ec5878..3b11e289 100644 --- a/examples/exchange/derivatives/8_Positions/example.go +++ b/examples/exchange/derivatives/8_Positions/example.go @@ -31,7 +31,7 @@ func main() { Limit: limit, } - res, err := exchangeClient.GetDerivativePositionsV2(ctx, req) + res, err := exchangeClient.GetDerivativePositionsV2(ctx, &req) if err != nil { panic(err) } diff --git a/examples/exchange/derivatives/9_Orders/example.go b/examples/exchange/derivatives/9_Orders/example.go index 30d07946..824ebd28 100644 --- a/examples/exchange/derivatives/9_Orders/example.go +++ b/examples/exchange/derivatives/9_Orders/example.go @@ -29,7 +29,7 @@ func main() { Limit: limit, } - res, err := exchangeClient.GetDerivativeOrders(ctx, req) + res, err := exchangeClient.GetDerivativeOrders(ctx, &req) if err != nil { panic(err) } diff --git a/examples/exchange/insurance/1_InsuranceFunds/example.go b/examples/exchange/insurance/1_InsuranceFunds/example.go index 1d1d00df..63abd806 100644 --- a/examples/exchange/insurance/1_InsuranceFunds/example.go +++ b/examples/exchange/insurance/1_InsuranceFunds/example.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/InjectiveLabs/sdk-go/client/common" exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" insurancePB "github.com/InjectiveLabs/sdk-go/exchange/insurance_rpc/pb" @@ -21,7 +22,7 @@ func main() { req := insurancePB.FundsRequest{} - res, err := exchangeClient.GetInsuranceFunds(ctx, req) + res, err := exchangeClient.GetInsuranceFunds(ctx, &req) if err != nil { fmt.Println(err) } diff --git a/examples/exchange/insurance/2_Redemptions/example.go b/examples/exchange/insurance/2_Redemptions/example.go index 1fbb965e..e109cc7d 100644 --- a/examples/exchange/insurance/2_Redemptions/example.go +++ b/examples/exchange/insurance/2_Redemptions/example.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/InjectiveLabs/sdk-go/client/common" exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" insurancePB "github.com/InjectiveLabs/sdk-go/exchange/insurance_rpc/pb" @@ -21,7 +22,7 @@ func main() { req := insurancePB.RedemptionsRequest{} - res, err := exchangeClient.GetRedemptions(ctx, req) + res, err := exchangeClient.GetRedemptions(ctx, &req) if err != nil { fmt.Println(err) } diff --git a/examples/exchange/meta/1_Ping/example.go b/examples/exchange/meta/1_Ping/example.go index f6acbeaf..15172af0 100644 --- a/examples/exchange/meta/1_Ping/example.go +++ b/examples/exchange/meta/1_Ping/example.go @@ -22,7 +22,7 @@ func main() { req := metaPB.PingRequest{} - res, err := exchangeClient.Ping(ctx, req) + res, err := exchangeClient.Ping(ctx, &req) if err != nil { fmt.Println(err) } diff --git a/examples/exchange/meta/2_Version/example.go b/examples/exchange/meta/2_Version/example.go index 688de7d5..f9f9ef15 100644 --- a/examples/exchange/meta/2_Version/example.go +++ b/examples/exchange/meta/2_Version/example.go @@ -22,7 +22,7 @@ func main() { req := metaPB.VersionRequest{} - res, err := exchangeClient.GetVersion(ctx, req) + res, err := exchangeClient.GetVersion(ctx, &req) if err != nil { fmt.Println(err) } diff --git a/examples/exchange/meta/3_Info/example.go b/examples/exchange/meta/3_Info/example.go index f7ee0227..571c3b6c 100644 --- a/examples/exchange/meta/3_Info/example.go +++ b/examples/exchange/meta/3_Info/example.go @@ -22,7 +22,7 @@ func main() { req := metaPB.InfoRequest{} - res, err := exchangeClient.GetInfo(ctx, req) + res, err := exchangeClient.GetInfo(ctx, &req) if err != nil { fmt.Println(err) } diff --git a/examples/exchange/meta/4_StreamKeepAlive/example.go b/examples/exchange/meta/4_StreamKeepAlive/example.go index 47da7ea2..c76a8605 100644 --- a/examples/exchange/meta/4_StreamKeepAlive/example.go +++ b/examples/exchange/meta/4_StreamKeepAlive/example.go @@ -29,7 +29,7 @@ func main() { case <-ctx.Done(): return default: - res, err := stream.Recv() + res, err := (*stream).Recv() if err != nil { fmt.Println(err) return diff --git a/examples/exchange/oracle/2_Price/example.go b/examples/exchange/oracle/2_Price/example.go index 9207e299..fe8840b1 100644 --- a/examples/exchange/oracle/2_Price/example.go +++ b/examples/exchange/oracle/2_Price/example.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/InjectiveLabs/sdk-go/client/common" exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" ) diff --git a/examples/exchange/portfolio/2_StreamAccountPortfolioBankBalances/example.go b/examples/exchange/portfolio/2_StreamAccountPortfolioBankBalances/example.go index 570d0db9..4880fa69 100644 --- a/examples/exchange/portfolio/2_StreamAccountPortfolioBankBalances/example.go +++ b/examples/exchange/portfolio/2_StreamAccountPortfolioBankBalances/example.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/InjectiveLabs/sdk-go/client/common" exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" diff --git a/examples/exchange/spot/10_StreamTrades/example.go b/examples/exchange/spot/10_StreamTrades/example.go index a5040113..48d160c1 100644 --- a/examples/exchange/spot/10_StreamTrades/example.go +++ b/examples/exchange/spot/10_StreamTrades/example.go @@ -26,7 +26,7 @@ func main() { MarketId: marketId, SubaccountId: subaccountId, } - stream, err := exchangeClient.StreamSpotTrades(ctx, req) + stream, err := exchangeClient.StreamSpotTrades(ctx, &req) if err != nil { panic(err) } diff --git a/examples/exchange/spot/11_SubaccountOrdersList/example.go b/examples/exchange/spot/11_SubaccountOrdersList/example.go index 0b4fe839..6bb6d48b 100644 --- a/examples/exchange/spot/11_SubaccountOrdersList/example.go +++ b/examples/exchange/spot/11_SubaccountOrdersList/example.go @@ -31,7 +31,7 @@ func main() { Limit: limit, } - res, err := exchangeClient.GetSubaccountSpotOrdersList(ctx, req) + res, err := exchangeClient.GetSubaccountSpotOrdersList(ctx, &req) if err != nil { fmt.Println(err) } diff --git a/examples/exchange/spot/12_SubaccountTradesList/example.go b/examples/exchange/spot/12_SubaccountTradesList/example.go index 887ca1ae..401e981d 100644 --- a/examples/exchange/spot/12_SubaccountTradesList/example.go +++ b/examples/exchange/spot/12_SubaccountTradesList/example.go @@ -31,7 +31,7 @@ func main() { Limit: limit, } - res, err := exchangeClient.GetSubaccountSpotTradesList(ctx, req) + res, err := exchangeClient.GetSubaccountSpotTradesList(ctx, &req) if err != nil { fmt.Println(err) } diff --git a/examples/exchange/spot/14_HistoricalOrders/example.go b/examples/exchange/spot/14_HistoricalOrders/example.go index 027855c3..288781b3 100644 --- a/examples/exchange/spot/14_HistoricalOrders/example.go +++ b/examples/exchange/spot/14_HistoricalOrders/example.go @@ -32,7 +32,7 @@ func main() { OrderTypes: orderTypes, } - res, err := exchangeClient.GetHistoricalSpotOrders(ctx, req) + res, err := exchangeClient.GetHistoricalSpotOrders(ctx, &req) if err != nil { panic(err) } diff --git a/examples/exchange/spot/15_StreamHistoricalOrders/example.go b/examples/exchange/spot/15_StreamHistoricalOrders/example.go index 0cfcf4c8..45c59723 100644 --- a/examples/exchange/spot/15_StreamHistoricalOrders/example.go +++ b/examples/exchange/spot/15_StreamHistoricalOrders/example.go @@ -27,7 +27,7 @@ func main() { SubaccountId: subaccountId, Direction: direction, } - stream, err := exchangeClient.StreamHistoricalSpotOrders(ctx, req) + stream, err := exchangeClient.StreamHistoricalSpotOrders(ctx, &req) if err != nil { panic(err) } diff --git a/examples/exchange/spot/16_TradesV2/example.go b/examples/exchange/spot/16_TradesV2/example.go index c4bf53cc..851dee00 100644 --- a/examples/exchange/spot/16_TradesV2/example.go +++ b/examples/exchange/spot/16_TradesV2/example.go @@ -26,7 +26,7 @@ func main() { SubaccountId: subaccountId, } - res, err := exchangeClient.GetSpotTradesV2(ctx, req) + res, err := exchangeClient.GetSpotTradesV2(ctx, &req) if err != nil { panic(err) } diff --git a/examples/exchange/spot/17_StreamTradesV2/example.go b/examples/exchange/spot/17_StreamTradesV2/example.go index 11855061..c5a5af87 100644 --- a/examples/exchange/spot/17_StreamTradesV2/example.go +++ b/examples/exchange/spot/17_StreamTradesV2/example.go @@ -25,7 +25,7 @@ func main() { MarketId: marketId, SubaccountId: subaccountId, } - stream, err := exchangeClient.StreamSpotTradesV2(ctx, req) + stream, err := exchangeClient.StreamSpotTradesV2(ctx, &req) if err != nil { panic(err) } diff --git a/examples/exchange/spot/2_Markets/example.go b/examples/exchange/spot/2_Markets/example.go index 8c4dbf40..e11b3b6d 100644 --- a/examples/exchange/spot/2_Markets/example.go +++ b/examples/exchange/spot/2_Markets/example.go @@ -27,7 +27,7 @@ func main() { QuoteDenom: quoteDenom, } - res, err := exchangeClient.GetSpotMarkets(ctx, req) + res, err := exchangeClient.GetSpotMarkets(ctx, &req) if err != nil { fmt.Println(err) } diff --git a/examples/exchange/spot/5_Orders/example.go b/examples/exchange/spot/5_Orders/example.go index 816bace4..4fe513c8 100644 --- a/examples/exchange/spot/5_Orders/example.go +++ b/examples/exchange/spot/5_Orders/example.go @@ -12,7 +12,7 @@ import ( func main() { //network := common.LoadNetwork("mainnet", "k8s") - network := common.LoadNetwork("testnet", "lb") + network := common.LoadNetwork("mainnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { panic(err) @@ -29,7 +29,7 @@ func main() { Limit: limit, } - res, err := exchangeClient.GetSpotOrders(ctx, req) + res, err := exchangeClient.GetSpotOrders(ctx, &req) if err != nil { fmt.Println(err) } diff --git a/examples/exchange/spot/6_Trades/example.go b/examples/exchange/spot/6_Trades/example.go index 655146d2..9fce3efc 100644 --- a/examples/exchange/spot/6_Trades/example.go +++ b/examples/exchange/spot/6_Trades/example.go @@ -26,7 +26,7 @@ func main() { SubaccountId: subaccountId, } - res, err := exchangeClient.GetSpotTrades(ctx, req) + res, err := exchangeClient.GetSpotTrades(ctx, &req) if err != nil { panic(err) } diff --git a/examples/exchange/spot/9_StreamOrders/example.go b/examples/exchange/spot/9_StreamOrders/example.go index 5f73916e..cb4cfffb 100644 --- a/examples/exchange/spot/9_StreamOrders/example.go +++ b/examples/exchange/spot/9_StreamOrders/example.go @@ -28,7 +28,7 @@ func main() { SubaccountId: subaccountId, OrderSide: orderSide, } - stream, err := exchangeClient.StreamSpotOrders(ctx, req) + stream, err := exchangeClient.StreamSpotOrders(ctx, &req) if err != nil { panic(err) } diff --git a/examples/explorer/10_IBCTransfers/example.go b/examples/explorer/10_IBCTransfers/example.go index d17ad7ff..ad3a08dc 100644 --- a/examples/explorer/10_IBCTransfers/example.go +++ b/examples/explorer/10_IBCTransfers/example.go @@ -25,7 +25,7 @@ func main() { Receiver: receiver, } - res, err := explorerClient.GetIBCTransfers(ctx, req) + res, err := explorerClient.GetIBCTransfers(ctx, &req) if err != nil { fmt.Println(err) } diff --git a/examples/explorer/11_GetWasmCodes/example.go b/examples/explorer/11_GetWasmCodes/example.go index b2e47810..ea298b34 100644 --- a/examples/explorer/11_GetWasmCodes/example.go +++ b/examples/explorer/11_GetWasmCodes/example.go @@ -24,7 +24,7 @@ func main() { Limit: 10, } - res, err := explorerClient.GetWasmCodes(ctx, req) + res, err := explorerClient.GetWasmCodes(ctx, &req) if err != nil { fmt.Println(err) } diff --git a/examples/explorer/12_GetWasmCodeById/example.go b/examples/explorer/12_GetWasmCodeById/example.go index 26a92ba3..b8b932fa 100644 --- a/examples/explorer/12_GetWasmCodeById/example.go +++ b/examples/explorer/12_GetWasmCodeById/example.go @@ -24,7 +24,7 @@ func main() { CodeId: 10, } - res, err := explorerClient.GetWasmCodeByID(ctx, req) + res, err := explorerClient.GetWasmCodeByID(ctx, &req) if err != nil { fmt.Println(err) } diff --git a/examples/explorer/13_GetWasmContracts/example.go b/examples/explorer/13_GetWasmContracts/example.go index d4153e2f..33f7df07 100644 --- a/examples/explorer/13_GetWasmContracts/example.go +++ b/examples/explorer/13_GetWasmContracts/example.go @@ -22,7 +22,7 @@ func main() { req := explorerPB.GetWasmContractsRequest{} - res, err := explorerClient.GetWasmContracts(ctx, req) + res, err := explorerClient.GetWasmContracts(ctx, &req) if err != nil { fmt.Println(err) } diff --git a/examples/explorer/14_GetWasmContractByAddress/example.go b/examples/explorer/14_GetWasmContractByAddress/example.go index 5c142671..d3a880c2 100644 --- a/examples/explorer/14_GetWasmContractByAddress/example.go +++ b/examples/explorer/14_GetWasmContractByAddress/example.go @@ -23,7 +23,7 @@ func main() { req := explorerPB.GetWasmContractByAddressRequest{ ContractAddress: "inj1ru9nhdjtjtz8u8wrwxmcl9zsns4fh2838yr5ga", } - res, err := explorerClient.GetWasmContractByAddress(ctx, req) + res, err := explorerClient.GetWasmContractByAddress(ctx, &req) if err != nil { fmt.Println(err) } diff --git a/examples/explorer/15_GetCW20Balance/example.go b/examples/explorer/15_GetCW20Balance/example.go index 6a82495e..da38564d 100644 --- a/examples/explorer/15_GetCW20Balance/example.go +++ b/examples/explorer/15_GetCW20Balance/example.go @@ -23,7 +23,7 @@ func main() { req := explorerPB.GetCw20BalanceRequest{ Address: "inj1dc6rrxhfjaxexzdcrec5w3ryl4jn6x5t7t9j3z", } - res, err := explorerClient.GetCW20Balance(ctx, req) + res, err := explorerClient.GetCW20Balance(ctx, &req) if err != nil { fmt.Println(err) } diff --git a/examples/explorer/2_AccountTxs/example.go b/examples/explorer/2_AccountTxs/example.go index 8bce4684..3bbb56dc 100644 --- a/examples/explorer/2_AccountTxs/example.go +++ b/examples/explorer/2_AccountTxs/example.go @@ -27,7 +27,7 @@ func main() { } ctx := context.Background() - res, err := explorerClient.GetAccountTxs(ctx, req) + res, err := explorerClient.GetAccountTxs(ctx, &req) if err != nil { fmt.Println(err) } diff --git a/examples/explorer/5_TxsRequest/example.go b/examples/explorer/5_TxsRequest/example.go index 8ebbe1a2..dd57bfe8 100644 --- a/examples/explorer/5_TxsRequest/example.go +++ b/examples/explorer/5_TxsRequest/example.go @@ -26,7 +26,7 @@ func main() { Before: before, } - res, err := explorerClient.GetTxs(ctx, req) + res, err := explorerClient.GetTxs(ctx, &req) if err != nil { fmt.Println(err) } diff --git a/examples/explorer/8_PeggyDeposits/example.go b/examples/explorer/8_PeggyDeposits/example.go index 9cd17c67..bd00e9e1 100644 --- a/examples/explorer/8_PeggyDeposits/example.go +++ b/examples/explorer/8_PeggyDeposits/example.go @@ -26,7 +26,7 @@ func main() { Receiver: receiver, } - res, err := explorerClient.GetPeggyDeposits(ctx, req) + res, err := explorerClient.GetPeggyDeposits(ctx, &req) if err != nil { fmt.Println(err) } diff --git a/examples/explorer/9_PeggyWithdrawals/example.go b/examples/explorer/9_PeggyWithdrawals/example.go index f7d221d4..d6284f5a 100644 --- a/examples/explorer/9_PeggyWithdrawals/example.go +++ b/examples/explorer/9_PeggyWithdrawals/example.go @@ -25,7 +25,7 @@ func main() { Sender: sender, } - res, err := explorerClient.GetPeggyWithdrawals(ctx, req) + res, err := explorerClient.GetPeggyWithdrawals(ctx, &req) if err != nil { fmt.Println(err) } diff --git a/go.mod b/go.mod index 6a8a21cd..3e0c72aa 100644 --- a/go.mod +++ b/go.mod @@ -16,14 +16,17 @@ require ( github.com/cosmos/gogoproto v1.4.10 github.com/cosmos/ibc-go/v7 v7.0.1 github.com/ethereum/go-ethereum v1.11.5 + github.com/golang/protobuf v1.5.3 github.com/google/uuid v1.4.0 github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 github.com/huandu/go-assert v1.1.5 github.com/olekukonko/tablewriter v0.0.5 github.com/pkg/errors v0.9.1 github.com/shopspring/decimal v1.2.0 + github.com/stretchr/testify v1.8.4 github.com/tyler-smith/go-bip39 v1.1.0 golang.org/x/crypto v0.11.0 + golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529 google.golang.org/grpc v1.56.2 google.golang.org/protobuf v1.31.0 @@ -86,7 +89,6 @@ require ( github.com/gofrs/uuid v4.3.0+incompatible // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/glog v1.1.0 // indirect - github.com/golang/protobuf v1.5.3 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/btree v1.1.2 // indirect github.com/google/go-cmp v0.5.9 // indirect @@ -139,7 +141,6 @@ require ( github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.16.0 // indirect - github.com/stretchr/testify v1.8.4 // indirect github.com/subosito/gotenv v1.4.2 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tendermint/go-amino v0.16.0 // indirect @@ -149,7 +150,6 @@ require ( github.com/zondax/hid v0.9.1 // indirect github.com/zondax/ledger-go v0.14.1 // indirect go.etcd.io/bbolt v1.3.7 // indirect - golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb // indirect golang.org/x/net v0.12.0 // indirect golang.org/x/sys v0.11.0 // indirect golang.org/x/term v0.10.0 // indirect