From 9a3740bf103ee202538b6346698e7667d6daf711 Mon Sep 17 00:00:00 2001 From: Abel Armoa <30988000+aarmoa@users.noreply.github.com> Date: Tue, 4 Jun 2024 10:56:26 -0300 Subject: [PATCH] (feat) Added golangci configuration to include more validations in the pre-commit run --- .golangci.yml | 53 ++++++ .pre-commit-config.yaml | 2 +- auth_vote/authz_vote.go | 4 +- chain/exchange/types/derivative_orders.go | 2 +- chain/exchange/types/spot_orders.go | 6 +- chain/peggy/types/params.go | 2 +- chain/permissions/types/tx.go | 8 +- chain/wasmx/types/params.go | 2 +- chain/wasmx/types/util.go | 3 +- client/chain/chain.go | 121 +++++++------ client/chain/chain_test_support.go | 76 ++++----- client/chain/keys.go | 4 +- client/chain/markets_assistant.go | 161 +++++++++--------- client/common/api_request_assistant.go | 8 +- client/common/network.go | 48 +++--- client/common/options.go | 2 +- client/common/util.go | 3 +- client/core/market.go | 2 +- client/core/market_test.go | 2 +- client/exchange/exchange.go | 12 +- client/exchange/exchange_test_support.go | 8 +- client/explorer/explorer.go | 4 +- client/metadata/fetch_metadata.go | 6 +- client/tm/tmclient.go | 15 +- eip712_cosmos.go | 8 +- ethereum/util/amounts.go | 12 +- ethereum/util/contract.go | 6 +- examples/chain/1_LocalOrderHash/example.go | 2 +- .../example.go | 2 +- .../example.go | 2 +- examples/chain/6_MsgRegisterAsDMM/example.go | 2 +- examples/chain/auction/1_MsgBid/example.go | 2 +- examples/chain/authz/1_MsgGrant/example.go | 8 +- examples/chain/authz/2_MsgExec/example.go | 2 +- examples/chain/authz/3_MsgRevoke/example.go | 2 +- examples/chain/bank/1_MsgSend/example.go | 2 +- examples/chain/bank/2_MsgMultiSend/example.go | 2 +- .../1_SetWithdrawAddress/example.go | 2 +- .../2_MsgWithdrawDelegatorReward/example.go | 2 +- .../3_WithdrawValidatorCommission/example.go | 2 +- .../4_FundCommunityPool/example.go | 2 +- .../example.go | 2 +- .../example.go | 2 +- .../12_MsgCancelDerivativeOrder/example.go | 2 +- .../example.go | 2 +- .../14_MsgSubaccountTransfer/example.go | 2 +- .../15_MsgExternalTransfer/example.go | 2 +- .../16_MsgLiquidatePosition/example.go | 2 +- .../17_MsgIncreasePositionMargin/example.go | 2 +- .../chain/exchange/1_MsgDeposit/example.go | 2 +- .../exchange/21_MsgRewardsOptOut/example.go | 2 +- .../chain/exchange/2_MsgWithdraw/example.go | 2 +- .../3_MsgInstantSpotMarketLaunch/example.go | 2 +- .../example.go | 2 +- .../example.go | 2 +- .../6_MsgCreateSpotLimitOrder/example.go | 2 +- .../7_MsgCreateSpotMarketOrder/example.go | 2 +- .../exchange/8_MsgCancelSpotOrder/example.go | 2 +- .../9_MsgBatchUpdateOrders/example.go | 2 +- .../ibc/transfer/1_MsgTransfer/example.go | 2 +- .../1_MsgRelayPriceFeedPrice/example.go | 2 +- .../chain/peggy/1_MsgSendToEth/example.go | 2 +- .../chain/staking/1_MsgDelegate/example.go | 2 +- .../tokenfactory/1_CreateDenom/example.go | 2 +- .../chain/tokenfactory/2_MsgMint/example.go | 2 +- .../chain/tokenfactory/3_MsgBurn/example.go | 2 +- .../4_MsgSetDenomMetadata/example.go | 2 +- .../tokenfactory/5_MsgChangeAdmin/example.go | 2 +- .../1_MsgExecuteContractCompat/example.go | 2 +- .../1_StreamSubaccountBalance/example.go | 2 +- .../derivatives/13_StreamTrades/example.go | 2 +- .../14_SubaccountOrdersList/example.go | 2 +- .../15_SubaccountTradesList/example.go | 2 +- .../derivatives/16_FundingPayments/example.go | 2 +- .../derivatives/17_FundingRates/example.go | 2 +- .../exchange/derivatives/1_Market/example.go | 2 +- .../exchange/derivatives/2_Markets/example.go | 2 +- .../derivatives/3_StreamMarket/example.go | 2 +- .../derivatives/4_Orderbook/example.go | 2 +- .../derivatives/5_Orderbooks/example.go | 2 +- .../derivatives/8_Positions/example.go | 2 +- .../exchange/derivatives/9_Orders/example.go | 2 +- .../insurance/1_InsuranceFunds/example.go | 2 +- .../insurance/2_Redemptions/example.go | 2 +- examples/exchange/meta/1_Ping/example.go | 2 +- examples/exchange/meta/2_Version/example.go | 2 +- examples/exchange/meta/3_Info/example.go | 2 +- .../meta/4_StreamKeepAlive/example.go | 2 +- .../exchange/spot/10_StreamTrades/example.go | 2 +- .../spot/11_SubaccountOrdersList/example.go | 2 +- .../spot/12_SubaccountTradesList/example.go | 2 +- .../exchange/spot/13_Orderbooks/example.go | 2 +- examples/exchange/spot/1_Market/example.go | 2 +- examples/exchange/spot/2_Markets/example.go | 2 +- .../exchange/spot/3_StreamMarket/example.go | 2 +- examples/exchange/spot/4_Orderbook/example.go | 2 +- examples/exchange/spot/5_Orders/example.go | 2 +- .../exchange/spot/9_StreamOrders/example.go | 2 +- go.mod | 6 +- go.sum | 12 +- typeddata/typed_data.go | 2 +- 101 files changed, 398 insertions(+), 350 deletions(-) create mode 100644 .golangci.yml diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 00000000..0073fe19 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,53 @@ +{ + "run": { + "tests": false, + }, + "linters": { + "fast": false, + "enable": [ + "errcheck", + "errorlint", + "gas", + "gocritic", + "gosimple", + "govet", + "ineffassign", + "megacheck", + "misspell", + "nakedret", + "prealloc", + "revive", + "staticcheck", + "unconvert", + "unparam", + ], + "disable": [ + "unused", + ] + }, + "linters-settings": { + "revive": { + "enableAllRules": true, + "rules": [ + { + "name": "var-naming", + "arguments": [ + ["ID"] + ] + } + ] + }, + "gocritic": { + "enabled-tags": [ + "diagnostic", + "experimental", + "opinionated", + "performance", + "style", + ], + "disabled-checks": [ + "hugeParam", + ] + } + }, +} \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a70840d1..6641de94 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/dnephin/pre-commit-golang - rev: v0.5.0 + rev: master hooks: - id: go-fmt - id: go-imports diff --git a/auth_vote/authz_vote.go b/auth_vote/authz_vote.go index 508a7c70..77613712 100644 --- a/auth_vote/authz_vote.go +++ b/auth_vote/authz_vote.go @@ -69,7 +69,7 @@ func main() { validators := []string{"inj156t3yxd4udv0h9gwagfcmwnmm3quy0npqc7pks", "inj16nd8yqxe9p6ggnrz58qr7dxn5y2834yendward"} grantee := senderAddress.String() proposalId := uint64(375) - var msgs []sdk.Msg + var msgs = make([]sdk.Msg, 0) for _, validator := range validators { msgVote := v1beta1.MsgVote{ @@ -92,7 +92,7 @@ func main() { msgs = append(msgs, sdkMsg) } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg response, err := chainClient.AsyncBroadcastMsg(msgs...) if err != nil { diff --git a/chain/exchange/types/derivative_orders.go b/chain/exchange/types/derivative_orders.go index 630b470a..422fd108 100644 --- a/chain/exchange/types/derivative_orders.go +++ b/chain/exchange/types/derivative_orders.go @@ -219,7 +219,7 @@ func (o *DerivativeLimitOrder) GetCancelRefundAmount(feeRate math.LegacyDec) mat if o.IsVanilla() { // negative fees are only accounted for upon matching positiveFeePart := math.LegacyMaxDec(math.LegacyZeroDec(), feeRate) - //nolint:all + // nolint:all // Refund = (FillableQuantity / Quantity) * (Margin + Price * Quantity * feeRate) notional := o.OrderInfo.Price.Mul(o.OrderInfo.Quantity) marginHoldRefund = o.Fillable.Mul(o.Margin.Add(notional.Mul(positiveFeePart))).Quo(o.OrderInfo.Quantity) diff --git a/chain/exchange/types/spot_orders.go b/chain/exchange/types/spot_orders.go index 3253e5b5..7225a00c 100644 --- a/chain/exchange/types/spot_orders.go +++ b/chain/exchange/types/spot_orders.go @@ -143,9 +143,7 @@ func (m *SpotLimitOrder) GetUnfilledFeeAmount(fee math.LegacyDec) math.LegacyDec return m.GetUnfilledNotional().Mul(fee) } -func (m *SpotOrder) GetBalanceHoldAndMarginDenom(market *SpotMarket) (math.LegacyDec, string) { - var denom string - var balanceHold math.LegacyDec +func (m *SpotOrder) GetBalanceHoldAndMarginDenom(market *SpotMarket) (balanceHold math.LegacyDec, denom string) { if m.IsBuy() { denom = market.QuoteDenom if m.OrderType.IsPostOnly() { @@ -167,7 +165,7 @@ func (m *SpotOrder) GetBalanceHoldAndMarginDenom(market *SpotMarket) (math.Legac return balanceHold, denom } -func (m *SpotLimitOrder) GetUnfilledMarginHoldAndMarginDenom(market *SpotMarket, isTransient bool) (math.LegacyDec, string) { +func (m *SpotLimitOrder) GetUnfilledMarginHoldAndMarginDenom(market *SpotMarket, isTransient bool) (marginHold math.LegacyDec, marginDenom string) { var denom string var balanceHold math.LegacyDec if m.IsBuy() { diff --git a/chain/peggy/types/params.go b/chain/peggy/types/params.go index 656ada2b..b4363219 100644 --- a/chain/peggy/types/params.go +++ b/chain/peggy/types/params.go @@ -290,6 +290,6 @@ func validateSlashFractionBadEthSignature(i interface{}) error { return nil } -func validateValsetReward(i interface{}) error { +func validateValsetReward(_ interface{}) error { return nil } diff --git a/chain/permissions/types/tx.go b/chain/permissions/types/tx.go index dbbd6e91..776372a5 100644 --- a/chain/permissions/types/tx.go +++ b/chain/permissions/types/tx.go @@ -33,7 +33,7 @@ func (m MsgCreateNamespace) Route() string { return routerKey } func (m MsgCreateNamespace) Type() string { return "create_namespace" } -func (msg MsgCreateNamespace) ValidateBasic() error { return nil } +func (m MsgCreateNamespace) ValidateBasic() error { return nil } func (m *MsgCreateNamespace) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshal(m)) @@ -84,7 +84,7 @@ func (m MsgUpdateNamespaceRoles) Route() string { return routerKey } func (m MsgUpdateNamespaceRoles) Type() string { return "update_namespace_roles" } -func (msg MsgUpdateNamespaceRoles) ValidateBasic() error { return nil } +func (m MsgUpdateNamespaceRoles) ValidateBasic() error { return nil } func (m *MsgUpdateNamespaceRoles) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshal(m)) @@ -101,7 +101,7 @@ func (m MsgRevokeNamespaceRoles) Route() string { return routerKey } func (m MsgRevokeNamespaceRoles) Type() string { return "revoke_namespace_roles" } -func (msg MsgRevokeNamespaceRoles) ValidateBasic() error { return nil } +func (m MsgRevokeNamespaceRoles) ValidateBasic() error { return nil } func (m *MsgRevokeNamespaceRoles) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshal(m)) @@ -118,7 +118,7 @@ func (m MsgClaimVoucher) Route() string { return routerKey } func (m MsgClaimVoucher) Type() string { return "claim_voucher" } -func (msg MsgClaimVoucher) ValidateBasic() error { return nil } +func (m MsgClaimVoucher) ValidateBasic() error { return nil } func (m *MsgClaimVoucher) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshal(m)) diff --git a/chain/wasmx/types/params.go b/chain/wasmx/types/params.go index 53bd56d5..8e1e5351 100644 --- a/chain/wasmx/types/params.go +++ b/chain/wasmx/types/params.go @@ -19,7 +19,7 @@ const ( var ( DefaultIsExecutionEnabled = false DefaultMaxBeginBlockTotalGas uint64 = 42_000_000 // 42M - DefaultMaxContractGasLimit uint64 = DefaultMaxBeginBlockTotalGas / 12 // 3.5M + DefaultMaxContractGasLimit = DefaultMaxBeginBlockTotalGas / 12 // 3.5M DefaultMinGasPrice uint64 = 1_000_000_000 // 1B ) diff --git a/chain/wasmx/types/util.go b/chain/wasmx/types/util.go index c7eb5ae2..bde09b7a 100644 --- a/chain/wasmx/types/util.go +++ b/chain/wasmx/types/util.go @@ -6,8 +6,7 @@ import ( ) func IsAllowed(accessConfig types.AccessConfig, actor types2.AccAddress) bool { - switch accessConfig.Permission { - case types.AccessTypeAnyOfAddresses: + if accessConfig.Permission == types.AccessTypeAnyOfAddresses { for _, v := range accessConfig.Addresses { if v == actor.String() { return true diff --git a/client/chain/chain.go b/client/chain/chain.go index a37c0b3a..c8d25ddc 100644 --- a/client/chain/chain.go +++ b/client/chain/chain.go @@ -43,7 +43,6 @@ import ( ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" ibcchanneltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" - eth "github.com/ethereum/go-ethereum/common" "github.com/pkg/errors" "github.com/shopspring/decimal" "google.golang.org/grpc" @@ -114,21 +113,21 @@ type ChainClient interface { expireIn time.Time, ) *authztypes.MsgGrant - DefaultSubaccount(acc sdk.AccAddress) eth.Hash - Subaccount(account sdk.AccAddress, index int) eth.Hash + DefaultSubaccount(acc sdk.AccAddress) ethcommon.Hash + Subaccount(account sdk.AccAddress, index int) ethcommon.Hash - GetSubAccountNonce(ctx context.Context, subaccountId eth.Hash) (*exchangetypes.QuerySubaccountTradeNonceResponse, error) + GetSubAccountNonce(ctx context.Context, subaccountId ethcommon.Hash) (*exchangetypes.QuerySubaccountTradeNonceResponse, error) GetFeeDiscountInfo(ctx context.Context, account string) (*exchangetypes.QueryFeeDiscountAccountInfoResponse, error) UpdateSubaccountNonceFromChain() error - SynchronizeSubaccountNonce(subaccountId eth.Hash) error - ComputeOrderHashes(spotOrders []exchangetypes.SpotOrder, derivativeOrders []exchangetypes.DerivativeOrder, subaccountId eth.Hash) (OrderHashes, error) + SynchronizeSubaccountNonce(subaccountId ethcommon.Hash) error + ComputeOrderHashes(spotOrders []exchangetypes.SpotOrder, derivativeOrders []exchangetypes.DerivativeOrder, subaccountId ethcommon.Hash) (OrderHashes, error) - SpotOrder(defaultSubaccountID eth.Hash, network common.Network, d *SpotOrderData) *exchangetypes.SpotOrder - CreateSpotOrder(defaultSubaccountID eth.Hash, d *SpotOrderData, marketsAssistant MarketsAssistant) *exchangetypes.SpotOrder - DerivativeOrder(defaultSubaccountID eth.Hash, network common.Network, d *DerivativeOrderData) *exchangetypes.DerivativeOrder - CreateDerivativeOrder(defaultSubaccountID eth.Hash, d *DerivativeOrderData, marketAssistant MarketsAssistant) *exchangetypes.DerivativeOrder - OrderCancel(defaultSubaccountID eth.Hash, d *OrderCancelData) *exchangetypes.OrderData + SpotOrder(defaultSubaccountID ethcommon.Hash, network common.Network, d *SpotOrderData) *exchangetypes.SpotOrder + CreateSpotOrder(defaultSubaccountID ethcommon.Hash, d *SpotOrderData, marketsAssistant MarketsAssistant) *exchangetypes.SpotOrder + DerivativeOrder(defaultSubaccountID ethcommon.Hash, network common.Network, d *DerivativeOrderData) *exchangetypes.DerivativeOrder + CreateDerivativeOrder(defaultSubaccountID ethcommon.Hash, d *DerivativeOrderData, marketAssistant MarketsAssistant) *exchangetypes.DerivativeOrder + OrderCancel(defaultSubaccountID ethcommon.Hash, d *OrderCancelData) *exchangetypes.OrderData GetGasFee() (string, error) @@ -340,8 +339,8 @@ func NewChainClient( // process options opts := common.DefaultClientOptions() - if network.ChainTlsCert != nil { - options = append(options, common.OptionTLSCert(network.ChainTlsCert)) + if network.ChainTLSCert != nil { + options = append(options, common.OptionTLSCert(network.ChainTLSCert)) } for _, opt := range options { if err := opt(opts); err != nil { @@ -517,7 +516,7 @@ func (c *chainClient) getAccSeq() uint64 { return c.accSeq } -func (c *chainClient) GetAccNonce() (accNum uint64, accSeq uint64) { +func (c *chainClient) GetAccNonce() (accNum, accSeq uint64) { return c.accNum, c.accSeq } @@ -561,7 +560,7 @@ func (c *chainClient) Close() { } } -//Bank Module +// Bank Module func (c *chainClient) GetBankBalances(ctx context.Context, address string) (*banktypes.QueryAllBalancesResponse, error) { req := &banktypes.QueryAllBalancesRequest{ @@ -572,7 +571,7 @@ func (c *chainClient) GetBankBalances(ctx context.Context, address string) (*ban return res, err } -func (c *chainClient) GetBankBalance(ctx context.Context, address string, denom string) (*banktypes.QueryBalanceResponse, error) { +func (c *chainClient) GetBankBalance(ctx context.Context, address, denom string) (*banktypes.QueryBalanceResponse, error) { req := &banktypes.QueryBalanceRequest{ Address: address, Denom: denom, @@ -592,7 +591,7 @@ func (c *chainClient) GetBankSpendableBalances(ctx context.Context, address stri return res, err } -func (c *chainClient) GetBankSpendableBalancesByDenom(ctx context.Context, address string, denom string) (*banktypes.QuerySpendableBalanceByDenomResponse, error) { +func (c *chainClient) GetBankSpendableBalancesByDenom(ctx context.Context, address, denom string) (*banktypes.QuerySpendableBalanceByDenomResponse, error) { req := &banktypes.QuerySpendableBalanceByDenomRequest{ Address: address, Denom: denom, @@ -1034,19 +1033,19 @@ func (c *chainClient) GetGasFee() (string, error) { return c.gasFee, err } -func (c *chainClient) DefaultSubaccount(acc sdk.AccAddress) eth.Hash { +func (c *chainClient) DefaultSubaccount(acc sdk.AccAddress) ethcommon.Hash { return c.Subaccount(acc, 0) } -func (c *chainClient) Subaccount(account sdk.AccAddress, index int) eth.Hash { - ethAddress := eth.BytesToAddress(account.Bytes()) +func (c *chainClient) Subaccount(account sdk.AccAddress, index int) ethcommon.Hash { + ethAddress := ethcommon.BytesToAddress(account.Bytes()) ethLowerAddress := strings.ToLower(ethAddress.String()) subaccountId := fmt.Sprintf("%s%024x", ethLowerAddress, index) - return eth.HexToHash(subaccountId) + return ethcommon.HexToHash(subaccountId) } -func (c *chainClient) GetSubAccountNonce(ctx context.Context, subaccountId eth.Hash) (*exchangetypes.QuerySubaccountTradeNonceResponse, error) { +func (c *chainClient) GetSubAccountNonce(ctx context.Context, subaccountId ethcommon.Hash) (*exchangetypes.QuerySubaccountTradeNonceResponse, error) { req := &exchangetypes.QuerySubaccountTradeNonceRequest{SubaccountId: subaccountId.String()} res, err := common.ExecuteCall(ctx, c.network.ChainCookieAssistant, c.exchangeQueryClient.SubaccountTradeNonce, req) @@ -1054,7 +1053,7 @@ func (c *chainClient) GetSubAccountNonce(ctx context.Context, subaccountId eth.H } // Deprecated: Use CreateSpotOrder instead -func (c *chainClient) SpotOrder(defaultSubaccountID eth.Hash, network common.Network, d *SpotOrderData) *exchangetypes.SpotOrder { +func (c *chainClient) SpotOrder(defaultSubaccountID ethcommon.Hash, network common.Network, d *SpotOrderData) *exchangetypes.SpotOrder { assistant, err := NewMarketsAssistant(network.Name) if err != nil { panic(err) @@ -1063,7 +1062,7 @@ func (c *chainClient) SpotOrder(defaultSubaccountID eth.Hash, network common.Net return c.CreateSpotOrder(defaultSubaccountID, d, assistant) } -func (c *chainClient) CreateSpotOrder(defaultSubaccountID eth.Hash, d *SpotOrderData, marketsAssistant MarketsAssistant) *exchangetypes.SpotOrder { +func (c *chainClient) CreateSpotOrder(defaultSubaccountID ethcommon.Hash, d *SpotOrderData, marketsAssistant MarketsAssistant) *exchangetypes.SpotOrder { market, isPresent := marketsAssistant.AllSpotMarkets()[d.MarketId] if !isPresent { @@ -1087,7 +1086,7 @@ func (c *chainClient) CreateSpotOrder(defaultSubaccountID eth.Hash, d *SpotOrder } // Deprecated: Use CreateDerivativeOrder instead -func (c *chainClient) DerivativeOrder(defaultSubaccountID eth.Hash, network common.Network, d *DerivativeOrderData) *exchangetypes.DerivativeOrder { +func (c *chainClient) DerivativeOrder(defaultSubaccountID ethcommon.Hash, network common.Network, d *DerivativeOrderData) *exchangetypes.DerivativeOrder { assistant, err := NewMarketsAssistant(network.Name) if err != nil { @@ -1097,7 +1096,7 @@ func (c *chainClient) DerivativeOrder(defaultSubaccountID eth.Hash, network comm return c.CreateDerivativeOrder(defaultSubaccountID, d, assistant) } -func (c *chainClient) CreateDerivativeOrder(defaultSubaccountID eth.Hash, d *DerivativeOrderData, marketAssistant MarketsAssistant) *exchangetypes.DerivativeOrder { +func (c *chainClient) CreateDerivativeOrder(defaultSubaccountID ethcommon.Hash, d *DerivativeOrderData, marketAssistant MarketsAssistant) *exchangetypes.DerivativeOrder { market, isPresent := marketAssistant.AllDerivativeMarkets()[d.MarketId] if !isPresent { panic(errors.Errorf("Invalid derivative market id for %s network (%s)", c.network.Name, d.MarketId)) @@ -1125,7 +1124,7 @@ func (c *chainClient) CreateDerivativeOrder(defaultSubaccountID eth.Hash, d *Der } } -func (c *chainClient) OrderCancel(defaultSubaccountID eth.Hash, d *OrderCancelData) *exchangetypes.OrderData { +func (c *chainClient) OrderCancel(defaultSubaccountID ethcommon.Hash, d *OrderCancelData) *exchangetypes.OrderData { return &exchangetypes.OrderData{ MarketId: d.MarketId, OrderHash: d.OrderHash, @@ -1140,7 +1139,7 @@ func (c *chainClient) GetAuthzGrants(ctx context.Context, req authztypes.QueryGr return res, err } -func (c *chainClient) BuildGenericAuthz(granter string, grantee string, msgtype string, expireIn time.Time) *authztypes.MsgGrant { +func (c *chainClient) BuildGenericAuthz(granter, grantee, msgtype string, expireIn time.Time) *authztypes.MsgGrant { authz := authztypes.NewGenericAuthorization(msgtype) authzAny := codectypes.UnsafePackAny(authz) return &authztypes.MsgGrant{ @@ -1171,7 +1170,7 @@ var ( BatchUpdateOrdersAuthz = ExchangeAuthz("/" + proto.MessageName(&exchangetypes.BatchUpdateOrdersAuthz{})) ) -func (c *chainClient) BuildExchangeAuthz(granter string, grantee string, authzType ExchangeAuthz, subaccountId string, markets []string, expireIn time.Time) *authztypes.MsgGrant { +func (c *chainClient) BuildExchangeAuthz(granter, grantee string, authzType ExchangeAuthz, subaccountId string, markets []string, expireIn time.Time) *authztypes.MsgGrant { var typedAuthzAny codectypes.Any var typedAuthzBytes []byte switch authzType { @@ -1550,7 +1549,7 @@ func (c *chainClient) FetchContractsByCreator(ctx context.Context, creator strin // Tokenfactory module -func (c *chainClient) FetchDenomAuthorityMetadata(ctx context.Context, creator string, subDenom string) (*tokenfactorytypes.QueryDenomAuthorityMetadataResponse, error) { +func (c *chainClient) FetchDenomAuthorityMetadata(ctx context.Context, creator, subDenom string) (*tokenfactorytypes.QueryDenomAuthorityMetadataResponse, error) { req := &tokenfactorytypes.QueryDenomAuthorityMetadataRequest{ Creator: creator, } @@ -1636,7 +1635,7 @@ func (c *chainClient) FetchValidatorCommission(ctx context.Context, validatorAdd return res, err } -func (c *chainClient) FetchValidatorSlashes(ctx context.Context, validatorAddress string, startingHeight uint64, endingHeight uint64, pagination *query.PageRequest) (*distributiontypes.QueryValidatorSlashesResponse, error) { +func (c *chainClient) FetchValidatorSlashes(ctx context.Context, validatorAddress string, startingHeight, endingHeight uint64, pagination *query.PageRequest) (*distributiontypes.QueryValidatorSlashesResponse, error) { req := &distributiontypes.QueryValidatorSlashesRequest{ ValidatorAddress: validatorAddress, StartingHeight: startingHeight, @@ -1648,7 +1647,7 @@ func (c *chainClient) FetchValidatorSlashes(ctx context.Context, validatorAddres return res, err } -func (c *chainClient) FetchDelegationRewards(ctx context.Context, delegatorAddress string, validatorAddress string) (*distributiontypes.QueryDelegationRewardsResponse, error) { +func (c *chainClient) FetchDelegationRewards(ctx context.Context, delegatorAddress, validatorAddress string) (*distributiontypes.QueryDelegationRewardsResponse, error) { req := &distributiontypes.QueryDelegationRewardsRequest{ DelegatorAddress: delegatorAddress, ValidatorAddress: validatorAddress, @@ -1702,7 +1701,7 @@ func (c *chainClient) FetchSubaccountDeposits(ctx context.Context, subaccountId return res, err } -func (c *chainClient) FetchSubaccountDeposit(ctx context.Context, subaccountId string, denom string) (*exchangetypes.QuerySubaccountDepositResponse, error) { +func (c *chainClient) FetchSubaccountDeposit(ctx context.Context, subaccountId, denom string) (*exchangetypes.QuerySubaccountDepositResponse, error) { req := &exchangetypes.QuerySubaccountDepositRequest{ SubaccountId: subaccountId, Denom: denom, @@ -1728,7 +1727,7 @@ func (c *chainClient) FetchAggregateVolume(ctx context.Context, account string) return res, err } -func (c *chainClient) FetchAggregateVolumes(ctx context.Context, accounts []string, marketIds []string) (*exchangetypes.QueryAggregateVolumesResponse, error) { +func (c *chainClient) FetchAggregateVolumes(ctx context.Context, accounts, marketIds []string) (*exchangetypes.QueryAggregateVolumesResponse, error) { req := &exchangetypes.QueryAggregateVolumesRequest{ Accounts: accounts, MarketIds: marketIds, @@ -1818,7 +1817,7 @@ func (c *chainClient) FetchChainFullSpotMarket(ctx context.Context, marketId str return res, err } -func (c *chainClient) FetchChainSpotOrderbook(ctx context.Context, marketId string, limit uint64, orderSide exchangetypes.OrderSide, limitCumulativeNotional sdkmath.LegacyDec, limitCumulativeQuantity sdkmath.LegacyDec) (*exchangetypes.QuerySpotOrderbookResponse, error) { +func (c *chainClient) FetchChainSpotOrderbook(ctx context.Context, marketId string, limit uint64, orderSide exchangetypes.OrderSide, limitCumulativeNotional, limitCumulativeQuantity sdkmath.LegacyDec) (*exchangetypes.QuerySpotOrderbookResponse, error) { req := &exchangetypes.QuerySpotOrderbookRequest{ MarketId: marketId, Limit: limit, @@ -1831,7 +1830,7 @@ func (c *chainClient) FetchChainSpotOrderbook(ctx context.Context, marketId stri return res, err } -func (c *chainClient) FetchChainTraderSpotOrders(ctx context.Context, marketId string, subaccountId string) (*exchangetypes.QueryTraderSpotOrdersResponse, error) { +func (c *chainClient) FetchChainTraderSpotOrders(ctx context.Context, marketId, subaccountId string) (*exchangetypes.QueryTraderSpotOrdersResponse, error) { req := &exchangetypes.QueryTraderSpotOrdersRequest{ MarketId: marketId, SubaccountId: subaccountId, @@ -1841,7 +1840,7 @@ func (c *chainClient) FetchChainTraderSpotOrders(ctx context.Context, marketId s return res, err } -func (c *chainClient) FetchChainAccountAddressSpotOrders(ctx context.Context, marketId string, address string) (*exchangetypes.QueryAccountAddressSpotOrdersResponse, error) { +func (c *chainClient) FetchChainAccountAddressSpotOrders(ctx context.Context, marketId, address string) (*exchangetypes.QueryAccountAddressSpotOrdersResponse, error) { req := &exchangetypes.QueryAccountAddressSpotOrdersRequest{ MarketId: marketId, AccountAddress: address, @@ -1851,7 +1850,7 @@ func (c *chainClient) FetchChainAccountAddressSpotOrders(ctx context.Context, ma return res, err } -func (c *chainClient) FetchChainSpotOrdersByHashes(ctx context.Context, marketId string, subaccountId string, orderHashes []string) (*exchangetypes.QuerySpotOrdersByHashesResponse, error) { +func (c *chainClient) FetchChainSpotOrdersByHashes(ctx context.Context, marketId, subaccountId string, orderHashes []string) (*exchangetypes.QuerySpotOrdersByHashesResponse, error) { req := &exchangetypes.QuerySpotOrdersByHashesRequest{ MarketId: marketId, SubaccountId: subaccountId, @@ -1862,7 +1861,7 @@ func (c *chainClient) FetchChainSpotOrdersByHashes(ctx context.Context, marketId return res, err } -func (c *chainClient) FetchChainSubaccountOrders(ctx context.Context, subaccountId string, marketId string) (*exchangetypes.QuerySubaccountOrdersResponse, error) { +func (c *chainClient) FetchChainSubaccountOrders(ctx context.Context, subaccountId, marketId string) (*exchangetypes.QuerySubaccountOrdersResponse, error) { req := &exchangetypes.QuerySubaccountOrdersRequest{ SubaccountId: subaccountId, MarketId: marketId, @@ -1872,7 +1871,7 @@ func (c *chainClient) FetchChainSubaccountOrders(ctx context.Context, subaccount return res, err } -func (c *chainClient) FetchChainTraderSpotTransientOrders(ctx context.Context, marketId string, subaccountId string) (*exchangetypes.QueryTraderSpotOrdersResponse, error) { +func (c *chainClient) FetchChainTraderSpotTransientOrders(ctx context.Context, marketId, subaccountId string) (*exchangetypes.QueryTraderSpotOrdersResponse, error) { req := &exchangetypes.QueryTraderSpotOrdersRequest{ MarketId: marketId, SubaccountId: subaccountId, @@ -1911,7 +1910,7 @@ func (c *chainClient) FetchChainDerivativeOrderbook(ctx context.Context, marketI return res, err } -func (c *chainClient) FetchChainTraderDerivativeOrders(ctx context.Context, marketId string, subaccountId string) (*exchangetypes.QueryTraderDerivativeOrdersResponse, error) { +func (c *chainClient) FetchChainTraderDerivativeOrders(ctx context.Context, marketId, subaccountId string) (*exchangetypes.QueryTraderDerivativeOrdersResponse, error) { req := &exchangetypes.QueryTraderDerivativeOrdersRequest{ MarketId: marketId, SubaccountId: subaccountId, @@ -1921,7 +1920,7 @@ func (c *chainClient) FetchChainTraderDerivativeOrders(ctx context.Context, mark return res, err } -func (c *chainClient) FetchChainAccountAddressDerivativeOrders(ctx context.Context, marketId string, address string) (*exchangetypes.QueryAccountAddressDerivativeOrdersResponse, error) { +func (c *chainClient) FetchChainAccountAddressDerivativeOrders(ctx context.Context, marketId, address string) (*exchangetypes.QueryAccountAddressDerivativeOrdersResponse, error) { req := &exchangetypes.QueryAccountAddressDerivativeOrdersRequest{ MarketId: marketId, AccountAddress: address, @@ -1931,7 +1930,7 @@ func (c *chainClient) FetchChainAccountAddressDerivativeOrders(ctx context.Conte return res, err } -func (c *chainClient) FetchChainDerivativeOrdersByHashes(ctx context.Context, marketId string, subaccountId string, orderHashes []string) (*exchangetypes.QueryDerivativeOrdersByHashesResponse, error) { +func (c *chainClient) FetchChainDerivativeOrdersByHashes(ctx context.Context, marketId, subaccountId string, orderHashes []string) (*exchangetypes.QueryDerivativeOrdersByHashesResponse, error) { req := &exchangetypes.QueryDerivativeOrdersByHashesRequest{ MarketId: marketId, SubaccountId: subaccountId, @@ -1942,7 +1941,7 @@ func (c *chainClient) FetchChainDerivativeOrdersByHashes(ctx context.Context, ma return res, err } -func (c *chainClient) FetchChainTraderDerivativeTransientOrders(ctx context.Context, marketId string, subaccountId string) (*exchangetypes.QueryTraderDerivativeOrdersResponse, error) { +func (c *chainClient) FetchChainTraderDerivativeTransientOrders(ctx context.Context, marketId, subaccountId string) (*exchangetypes.QueryTraderDerivativeOrdersResponse, error) { req := &exchangetypes.QueryTraderDerivativeOrdersRequest{ MarketId: marketId, SubaccountId: subaccountId, @@ -2008,7 +2007,7 @@ func (c *chainClient) FetchChainSubaccountPositions(ctx context.Context, subacco return res, err } -func (c *chainClient) FetchChainSubaccountPositionInMarket(ctx context.Context, subaccountId string, marketId string) (*exchangetypes.QuerySubaccountPositionInMarketResponse, error) { +func (c *chainClient) FetchChainSubaccountPositionInMarket(ctx context.Context, subaccountId, marketId string) (*exchangetypes.QuerySubaccountPositionInMarketResponse, error) { req := &exchangetypes.QuerySubaccountPositionInMarketRequest{ SubaccountId: subaccountId, MarketId: marketId, @@ -2018,7 +2017,7 @@ func (c *chainClient) FetchChainSubaccountPositionInMarket(ctx context.Context, return res, err } -func (c *chainClient) FetchChainSubaccountEffectivePositionInMarket(ctx context.Context, subaccountId string, marketId string) (*exchangetypes.QuerySubaccountEffectivePositionInMarketResponse, error) { +func (c *chainClient) FetchChainSubaccountEffectivePositionInMarket(ctx context.Context, subaccountId, marketId string) (*exchangetypes.QuerySubaccountEffectivePositionInMarketResponse, error) { req := &exchangetypes.QuerySubaccountEffectivePositionInMarketRequest{ SubaccountId: subaccountId, MarketId: marketId, @@ -2189,7 +2188,7 @@ func (c *chainClient) FetchChainBinaryOptionsMarkets(ctx context.Context, status return res, err } -func (c *chainClient) FetchTraderDerivativeConditionalOrders(ctx context.Context, subaccountId string, marketId string) (*exchangetypes.QueryTraderDerivativeConditionalOrdersResponse, error) { +func (c *chainClient) FetchTraderDerivativeConditionalOrders(ctx context.Context, subaccountId, marketId string) (*exchangetypes.QueryTraderDerivativeConditionalOrdersResponse, error) { req := &exchangetypes.QueryTraderDerivativeConditionalOrdersRequest{ SubaccountId: subaccountId, MarketId: marketId, @@ -2297,7 +2296,7 @@ func (c *chainClient) FetchDenomHash(ctx context.Context, trace string) (*ibctra return res, err } -func (c *chainClient) FetchEscrowAddress(ctx context.Context, portId string, channelId string) (*ibctransfertypes.QueryEscrowAddressResponse, error) { +func (c *chainClient) FetchEscrowAddress(ctx context.Context, portId, channelId string) (*ibctransfertypes.QueryEscrowAddressResponse, error) { req := &ibctransfertypes.QueryEscrowAddressRequest{ PortId: portId, ChannelId: channelId, @@ -2317,7 +2316,7 @@ func (c *chainClient) FetchTotalEscrowForDenom(ctx context.Context, denom string } // IBC Core Channel module -func (c *chainClient) FetchIBCChannel(ctx context.Context, portId string, channelId string) (*ibcchanneltypes.QueryChannelResponse, error) { +func (c *chainClient) FetchIBCChannel(ctx context.Context, portId, channelId string) (*ibcchanneltypes.QueryChannelResponse, error) { req := &ibcchanneltypes.QueryChannelRequest{ PortId: portId, ChannelId: channelId, @@ -2346,7 +2345,7 @@ func (c *chainClient) FetchIBCConnectionChannels(ctx context.Context, connection return res, err } -func (c *chainClient) FetchIBCChannelClientState(ctx context.Context, portId string, channelId string) (*ibcchanneltypes.QueryChannelClientStateResponse, error) { +func (c *chainClient) FetchIBCChannelClientState(ctx context.Context, portId, channelId string) (*ibcchanneltypes.QueryChannelClientStateResponse, error) { req := &ibcchanneltypes.QueryChannelClientStateRequest{ PortId: portId, ChannelId: channelId, @@ -2356,7 +2355,7 @@ func (c *chainClient) FetchIBCChannelClientState(ctx context.Context, portId str return res, err } -func (c *chainClient) FetchIBCChannelConsensusState(ctx context.Context, portId string, channelId string, revisionNumber uint64, revisionHeight uint64) (*ibcchanneltypes.QueryChannelConsensusStateResponse, error) { +func (c *chainClient) FetchIBCChannelConsensusState(ctx context.Context, portId, channelId string, revisionNumber, revisionHeight uint64) (*ibcchanneltypes.QueryChannelConsensusStateResponse, error) { req := &ibcchanneltypes.QueryChannelConsensusStateRequest{ PortId: portId, ChannelId: channelId, @@ -2368,7 +2367,7 @@ func (c *chainClient) FetchIBCChannelConsensusState(ctx context.Context, portId return res, err } -func (c *chainClient) FetchIBCPacketCommitment(ctx context.Context, portId string, channelId string, sequence uint64) (*ibcchanneltypes.QueryPacketCommitmentResponse, error) { +func (c *chainClient) FetchIBCPacketCommitment(ctx context.Context, portId, channelId string, sequence uint64) (*ibcchanneltypes.QueryPacketCommitmentResponse, error) { req := &ibcchanneltypes.QueryPacketCommitmentRequest{ PortId: portId, ChannelId: channelId, @@ -2379,7 +2378,7 @@ func (c *chainClient) FetchIBCPacketCommitment(ctx context.Context, portId strin return res, err } -func (c *chainClient) FetchIBCPacketCommitments(ctx context.Context, portId string, channelId string, pagination *query.PageRequest) (*ibcchanneltypes.QueryPacketCommitmentsResponse, error) { +func (c *chainClient) FetchIBCPacketCommitments(ctx context.Context, portId, channelId string, pagination *query.PageRequest) (*ibcchanneltypes.QueryPacketCommitmentsResponse, error) { req := &ibcchanneltypes.QueryPacketCommitmentsRequest{ PortId: portId, ChannelId: channelId, @@ -2390,7 +2389,7 @@ func (c *chainClient) FetchIBCPacketCommitments(ctx context.Context, portId stri return res, err } -func (c *chainClient) FetchIBCPacketReceipt(ctx context.Context, portId string, channelId string, sequence uint64) (*ibcchanneltypes.QueryPacketReceiptResponse, error) { +func (c *chainClient) FetchIBCPacketReceipt(ctx context.Context, portId, channelId string, sequence uint64) (*ibcchanneltypes.QueryPacketReceiptResponse, error) { req := &ibcchanneltypes.QueryPacketReceiptRequest{ PortId: portId, ChannelId: channelId, @@ -2401,7 +2400,7 @@ func (c *chainClient) FetchIBCPacketReceipt(ctx context.Context, portId string, return res, err } -func (c *chainClient) FetchIBCPacketAcknowledgement(ctx context.Context, portId string, channelId string, sequence uint64) (*ibcchanneltypes.QueryPacketAcknowledgementResponse, error) { +func (c *chainClient) FetchIBCPacketAcknowledgement(ctx context.Context, portId, channelId string, sequence uint64) (*ibcchanneltypes.QueryPacketAcknowledgementResponse, error) { req := &ibcchanneltypes.QueryPacketAcknowledgementRequest{ PortId: portId, ChannelId: channelId, @@ -2412,7 +2411,7 @@ func (c *chainClient) FetchIBCPacketAcknowledgement(ctx context.Context, portId return res, err } -func (c *chainClient) FetchIBCPacketAcknowledgements(ctx context.Context, portId string, channelId string, packetCommitmentSequences []uint64, pagination *query.PageRequest) (*ibcchanneltypes.QueryPacketAcknowledgementsResponse, error) { +func (c *chainClient) FetchIBCPacketAcknowledgements(ctx context.Context, portId, channelId string, packetCommitmentSequences []uint64, pagination *query.PageRequest) (*ibcchanneltypes.QueryPacketAcknowledgementsResponse, error) { req := &ibcchanneltypes.QueryPacketAcknowledgementsRequest{ PortId: portId, ChannelId: channelId, @@ -2424,7 +2423,7 @@ func (c *chainClient) FetchIBCPacketAcknowledgements(ctx context.Context, portId return res, err } -func (c *chainClient) FetchIBCUnreceivedPackets(ctx context.Context, portId string, channelId string, packetCommitmentSequences []uint64) (*ibcchanneltypes.QueryUnreceivedPacketsResponse, error) { +func (c *chainClient) FetchIBCUnreceivedPackets(ctx context.Context, portId, channelId string, packetCommitmentSequences []uint64) (*ibcchanneltypes.QueryUnreceivedPacketsResponse, error) { req := &ibcchanneltypes.QueryUnreceivedPacketsRequest{ PortId: portId, ChannelId: channelId, @@ -2435,7 +2434,7 @@ func (c *chainClient) FetchIBCUnreceivedPackets(ctx context.Context, portId stri return res, err } -func (c *chainClient) FetchIBCUnreceivedAcks(ctx context.Context, portId string, channelId string, packetAckSequences []uint64) (*ibcchanneltypes.QueryUnreceivedAcksResponse, error) { +func (c *chainClient) FetchIBCUnreceivedAcks(ctx context.Context, portId, channelId string, packetAckSequences []uint64) (*ibcchanneltypes.QueryUnreceivedAcksResponse, error) { req := &ibcchanneltypes.QueryUnreceivedAcksRequest{ PortId: portId, ChannelId: channelId, @@ -2446,7 +2445,7 @@ func (c *chainClient) FetchIBCUnreceivedAcks(ctx context.Context, portId string, return res, err } -func (c *chainClient) FetchIBCNextSequenceReceive(ctx context.Context, portId string, channelId string) (*ibcchanneltypes.QueryNextSequenceReceiveResponse, error) { +func (c *chainClient) FetchIBCNextSequenceReceive(ctx context.Context, portId, channelId string) (*ibcchanneltypes.QueryNextSequenceReceiveResponse, error) { req := &ibcchanneltypes.QueryNextSequenceReceiveRequest{ PortId: portId, ChannelId: channelId, @@ -2475,7 +2474,7 @@ func (c *chainClient) FetchIBCClientStates(ctx context.Context, pagination *quer return res, err } -func (c *chainClient) FetchIBCConsensusState(ctx context.Context, clientId string, revisionNumber uint64, revisionHeight uint64, latestHeight bool) (*ibcclienttypes.QueryConsensusStateResponse, error) { +func (c *chainClient) FetchIBCConsensusState(ctx context.Context, clientId string, revisionNumber, revisionHeight uint64, latestHeight bool) (*ibcclienttypes.QueryConsensusStateResponse, error) { req := &ibcclienttypes.QueryConsensusStateRequest{ ClientId: clientId, RevisionNumber: revisionNumber, @@ -2574,7 +2573,7 @@ func (c *chainClient) FetchIBCConnectionClientState(ctx context.Context, connect return res, err } -func (c *chainClient) FetchIBCConnectionConsensusState(ctx context.Context, connectionId string, revisionNumber uint64, revisionHeight uint64) (*ibcconnectiontypes.QueryConnectionConsensusStateResponse, error) { +func (c *chainClient) FetchIBCConnectionConsensusState(ctx context.Context, connectionId string, revisionNumber, revisionHeight uint64) (*ibcconnectiontypes.QueryConnectionConsensusStateResponse, error) { req := &ibcconnectiontypes.QueryConnectionConsensusStateRequest{ ConnectionId: connectionId, RevisionNumber: revisionNumber, diff --git a/client/chain/chain_test_support.go b/client/chain/chain_test_support.go index de867442..2d8af3ab 100644 --- a/client/chain/chain_test_support.go +++ b/client/chain/chain_test_support.go @@ -51,7 +51,7 @@ func (c *MockChainClient) ClientContext() client.Context { return client.Context{} } -func (c *MockChainClient) GetAccNonce() (accNum uint64, accSeq uint64) { +func (c *MockChainClient) GetAccNonce() (accNum, accSeq uint64) { return 1, 2 } @@ -68,7 +68,7 @@ func (c *MockChainClient) SyncBroadcastMsg(msgs ...sdk.Msg) (*txtypes.BroadcastT } func (c *MockChainClient) BuildSignedTx(clientCtx client.Context, accNum, accSeq, initialGas uint64, msg ...sdk.Msg) ([]byte, error) { - return *new([]byte), nil + return []byte(nil), nil } func (c *MockChainClient) SyncBroadcastSignedTx(tyBytes []byte) (*txtypes.BroadcastTxResponse, error) { @@ -87,7 +87,7 @@ func (c *MockChainClient) GetBankBalances(ctx context.Context, address string) ( return &banktypes.QueryAllBalancesResponse{}, nil } -func (c *MockChainClient) GetBankBalance(ctx context.Context, address string, denom string) (*banktypes.QueryBalanceResponse, error) { +func (c *MockChainClient) GetBankBalance(ctx context.Context, address, denom string) (*banktypes.QueryBalanceResponse, error) { return &banktypes.QueryBalanceResponse{}, nil } @@ -95,7 +95,7 @@ func (c *MockChainClient) GetBankSpendableBalances(ctx context.Context, address return &banktypes.QuerySpendableBalancesResponse{}, nil } -func (c *MockChainClient) GetBankSpendableBalancesByDenom(ctx context.Context, address string, denom string) (*banktypes.QuerySpendableBalanceByDenomResponse, error) { +func (c *MockChainClient) GetBankSpendableBalancesByDenom(ctx context.Context, address, denom string) (*banktypes.QuerySpendableBalanceByDenomResponse, error) { return &banktypes.QuerySpendableBalanceByDenomResponse{}, nil } @@ -142,11 +142,11 @@ func (c *MockChainClient) GetAccount(ctx context.Context, address string) (*auth return &authtypes.QueryAccountResponse{}, nil } -func (c *MockChainClient) BuildGenericAuthz(granter string, grantee string, msgtype string, expireIn time.Time) *authztypes.MsgGrant { +func (c *MockChainClient) BuildGenericAuthz(granter, grantee, msgtype string, expireIn time.Time) *authztypes.MsgGrant { return &authztypes.MsgGrant{} } -func (c *MockChainClient) BuildExchangeAuthz(granter string, grantee string, authzType ExchangeAuthz, subaccountId string, markets []string, expireIn time.Time) *authztypes.MsgGrant { +func (c *MockChainClient) BuildExchangeAuthz(granter, grantee string, authzType ExchangeAuthz, subaccountId string, markets []string, expireIn time.Time) *authztypes.MsgGrant { return &authztypes.MsgGrant{} } @@ -282,7 +282,7 @@ func (c *MockChainClient) FetchContractsByCreator(ctx context.Context, creator s return &wasmtypes.QueryContractsByCreatorResponse{}, nil } -func (c *MockChainClient) FetchDenomAuthorityMetadata(ctx context.Context, creator string, subDenom string) (*tokenfactorytypes.QueryDenomAuthorityMetadataResponse, error) { +func (c *MockChainClient) FetchDenomAuthorityMetadata(ctx context.Context, creator, subDenom string) (*tokenfactorytypes.QueryDenomAuthorityMetadataResponse, error) { return &tokenfactorytypes.QueryDenomAuthorityMetadataResponse{}, nil } @@ -307,11 +307,11 @@ func (c *MockChainClient) FetchValidatorCommission(ctx context.Context, validato return &distributiontypes.QueryValidatorCommissionResponse{}, nil } -func (c *MockChainClient) FetchValidatorSlashes(ctx context.Context, validatorAddress string, startingHeight uint64, endingHeight uint64, pagination *query.PageRequest) (*distributiontypes.QueryValidatorSlashesResponse, error) { +func (c *MockChainClient) FetchValidatorSlashes(ctx context.Context, validatorAddress string, startingHeight, endingHeight uint64, pagination *query.PageRequest) (*distributiontypes.QueryValidatorSlashesResponse, error) { return &distributiontypes.QueryValidatorSlashesResponse{}, nil } -func (c *MockChainClient) FetchDelegationRewards(ctx context.Context, delegatorAddress string, validatorAddress string) (*distributiontypes.QueryDelegationRewardsResponse, error) { +func (c *MockChainClient) FetchDelegationRewards(ctx context.Context, delegatorAddress, validatorAddress string) (*distributiontypes.QueryDelegationRewardsResponse, error) { return &distributiontypes.QueryDelegationRewardsResponse{}, nil } @@ -336,7 +336,7 @@ func (c *MockChainClient) FetchSubaccountDeposits(ctx context.Context, subaccoun return &exchangetypes.QuerySubaccountDepositsResponse{}, nil } -func (c *MockChainClient) FetchSubaccountDeposit(ctx context.Context, subaccountId string, denom string) (*exchangetypes.QuerySubaccountDepositResponse, error) { +func (c *MockChainClient) FetchSubaccountDeposit(ctx context.Context, subaccountId, denom string) (*exchangetypes.QuerySubaccountDepositResponse, error) { return &exchangetypes.QuerySubaccountDepositResponse{}, nil } @@ -348,7 +348,7 @@ func (c *MockChainClient) FetchAggregateVolume(ctx context.Context, account stri return &exchangetypes.QueryAggregateVolumeResponse{}, nil } -func (c *MockChainClient) FetchAggregateVolumes(ctx context.Context, accounts []string, marketIds []string) (*exchangetypes.QueryAggregateVolumesResponse, error) { +func (c *MockChainClient) FetchAggregateVolumes(ctx context.Context, accounts, marketIds []string) (*exchangetypes.QueryAggregateVolumesResponse, error) { return &exchangetypes.QueryAggregateVolumesResponse{}, nil } @@ -384,27 +384,27 @@ func (c *MockChainClient) FetchChainFullSpotMarket(ctx context.Context, marketId return &exchangetypes.QueryFullSpotMarketResponse{}, nil } -func (c *MockChainClient) FetchChainSpotOrderbook(ctx context.Context, marketId string, limit uint64, orderSide exchangetypes.OrderSide, limitCumulativeNotional sdkmath.LegacyDec, limitCumulativeQuantity sdkmath.LegacyDec) (*exchangetypes.QuerySpotOrderbookResponse, error) { +func (c *MockChainClient) FetchChainSpotOrderbook(ctx context.Context, marketId string, limit uint64, orderSide exchangetypes.OrderSide, limitCumulativeNotional, limitCumulativeQuantity sdkmath.LegacyDec) (*exchangetypes.QuerySpotOrderbookResponse, error) { return &exchangetypes.QuerySpotOrderbookResponse{}, nil } -func (c *MockChainClient) FetchChainTraderSpotOrders(ctx context.Context, marketId string, subaccountId string) (*exchangetypes.QueryTraderSpotOrdersResponse, error) { +func (c *MockChainClient) FetchChainTraderSpotOrders(ctx context.Context, marketId, subaccountId string) (*exchangetypes.QueryTraderSpotOrdersResponse, error) { return &exchangetypes.QueryTraderSpotOrdersResponse{}, nil } -func (c *MockChainClient) FetchChainAccountAddressSpotOrders(ctx context.Context, marketId string, address string) (*exchangetypes.QueryAccountAddressSpotOrdersResponse, error) { +func (c *MockChainClient) FetchChainAccountAddressSpotOrders(ctx context.Context, marketId, address string) (*exchangetypes.QueryAccountAddressSpotOrdersResponse, error) { return &exchangetypes.QueryAccountAddressSpotOrdersResponse{}, nil } -func (c *MockChainClient) FetchChainSpotOrdersByHashes(ctx context.Context, marketId string, subaccountId string, orderHashes []string) (*exchangetypes.QuerySpotOrdersByHashesResponse, error) { +func (c *MockChainClient) FetchChainSpotOrdersByHashes(ctx context.Context, marketId, subaccountId string, orderHashes []string) (*exchangetypes.QuerySpotOrdersByHashesResponse, error) { return &exchangetypes.QuerySpotOrdersByHashesResponse{}, nil } -func (c *MockChainClient) FetchChainSubaccountOrders(ctx context.Context, subaccountId string, marketId string) (*exchangetypes.QuerySubaccountOrdersResponse, error) { +func (c *MockChainClient) FetchChainSubaccountOrders(ctx context.Context, subaccountId, marketId string) (*exchangetypes.QuerySubaccountOrdersResponse, error) { return &exchangetypes.QuerySubaccountOrdersResponse{}, nil } -func (c *MockChainClient) FetchChainTraderSpotTransientOrders(ctx context.Context, marketId string, subaccountId string) (*exchangetypes.QueryTraderSpotOrdersResponse, error) { +func (c *MockChainClient) FetchChainTraderSpotTransientOrders(ctx context.Context, marketId, subaccountId string) (*exchangetypes.QueryTraderSpotOrdersResponse, error) { return &exchangetypes.QueryTraderSpotOrdersResponse{}, nil } @@ -420,19 +420,19 @@ func (c *MockChainClient) FetchChainDerivativeOrderbook(ctx context.Context, mar return &exchangetypes.QueryDerivativeOrderbookResponse{}, nil } -func (c *MockChainClient) FetchChainTraderDerivativeOrders(ctx context.Context, marketId string, subaccountId string) (*exchangetypes.QueryTraderDerivativeOrdersResponse, error) { +func (c *MockChainClient) FetchChainTraderDerivativeOrders(ctx context.Context, marketId, subaccountId string) (*exchangetypes.QueryTraderDerivativeOrdersResponse, error) { return &exchangetypes.QueryTraderDerivativeOrdersResponse{}, nil } -func (c *MockChainClient) FetchChainAccountAddressDerivativeOrders(ctx context.Context, marketId string, address string) (*exchangetypes.QueryAccountAddressDerivativeOrdersResponse, error) { +func (c *MockChainClient) FetchChainAccountAddressDerivativeOrders(ctx context.Context, marketId, address string) (*exchangetypes.QueryAccountAddressDerivativeOrdersResponse, error) { return &exchangetypes.QueryAccountAddressDerivativeOrdersResponse{}, nil } -func (c *MockChainClient) FetchChainDerivativeOrdersByHashes(ctx context.Context, marketId string, subaccountId string, orderHashes []string) (*exchangetypes.QueryDerivativeOrdersByHashesResponse, error) { +func (c *MockChainClient) FetchChainDerivativeOrdersByHashes(ctx context.Context, marketId, subaccountId string, orderHashes []string) (*exchangetypes.QueryDerivativeOrdersByHashesResponse, error) { return &exchangetypes.QueryDerivativeOrdersByHashesResponse{}, nil } -func (c *MockChainClient) FetchChainTraderDerivativeTransientOrders(ctx context.Context, marketId string, subaccountId string) (*exchangetypes.QueryTraderDerivativeOrdersResponse, error) { +func (c *MockChainClient) FetchChainTraderDerivativeTransientOrders(ctx context.Context, marketId, subaccountId string) (*exchangetypes.QueryTraderDerivativeOrdersResponse, error) { return &exchangetypes.QueryTraderDerivativeOrdersResponse{}, nil } @@ -460,11 +460,11 @@ func (c *MockChainClient) FetchChainSubaccountPositions(ctx context.Context, sub return &exchangetypes.QuerySubaccountPositionsResponse{}, nil } -func (c *MockChainClient) FetchChainSubaccountPositionInMarket(ctx context.Context, subaccountId string, marketId string) (*exchangetypes.QuerySubaccountPositionInMarketResponse, error) { +func (c *MockChainClient) FetchChainSubaccountPositionInMarket(ctx context.Context, subaccountId, marketId string) (*exchangetypes.QuerySubaccountPositionInMarketResponse, error) { return &exchangetypes.QuerySubaccountPositionInMarketResponse{}, nil } -func (c *MockChainClient) FetchChainSubaccountEffectivePositionInMarket(ctx context.Context, subaccountId string, marketId string) (*exchangetypes.QuerySubaccountEffectivePositionInMarketResponse, error) { +func (c *MockChainClient) FetchChainSubaccountEffectivePositionInMarket(ctx context.Context, subaccountId, marketId string) (*exchangetypes.QuerySubaccountEffectivePositionInMarketResponse, error) { return &exchangetypes.QuerySubaccountEffectivePositionInMarketResponse{}, nil } @@ -544,7 +544,7 @@ func (c *MockChainClient) FetchChainBinaryOptionsMarkets(ctx context.Context, st return &exchangetypes.QueryBinaryMarketsResponse{}, nil } -func (c *MockChainClient) FetchTraderDerivativeConditionalOrders(ctx context.Context, subaccountId string, marketId string) (*exchangetypes.QueryTraderDerivativeConditionalOrdersResponse, error) { +func (c *MockChainClient) FetchTraderDerivativeConditionalOrders(ctx context.Context, subaccountId, marketId string) (*exchangetypes.QueryTraderDerivativeConditionalOrdersResponse, error) { return &exchangetypes.QueryTraderDerivativeConditionalOrdersResponse{}, nil } @@ -595,7 +595,7 @@ func (c *MockChainClient) FetchDenomHash(ctx context.Context, trace string) (*ib return &ibctransfertypes.QueryDenomHashResponse{}, nil } -func (c *MockChainClient) FetchEscrowAddress(ctx context.Context, portId string, channelId string) (*ibctransfertypes.QueryEscrowAddressResponse, error) { +func (c *MockChainClient) FetchEscrowAddress(ctx context.Context, portId, channelId string) (*ibctransfertypes.QueryEscrowAddressResponse, error) { return &ibctransfertypes.QueryEscrowAddressResponse{}, nil } @@ -604,7 +604,7 @@ func (c *MockChainClient) FetchTotalEscrowForDenom(ctx context.Context, denom st } // IBC Core Channel module -func (c *MockChainClient) FetchIBCChannel(ctx context.Context, portId string, channelId string) (*ibcchanneltypes.QueryChannelResponse, error) { +func (c *MockChainClient) FetchIBCChannel(ctx context.Context, portId, channelId string) (*ibcchanneltypes.QueryChannelResponse, error) { return &ibcchanneltypes.QueryChannelResponse{}, nil } @@ -616,43 +616,43 @@ func (c *MockChainClient) FetchIBCConnectionChannels(ctx context.Context, connec return &ibcchanneltypes.QueryConnectionChannelsResponse{}, nil } -func (c *MockChainClient) FetchIBCChannelClientState(ctx context.Context, portId string, channelId string) (*ibcchanneltypes.QueryChannelClientStateResponse, error) { +func (c *MockChainClient) FetchIBCChannelClientState(ctx context.Context, portId, channelId string) (*ibcchanneltypes.QueryChannelClientStateResponse, error) { return &ibcchanneltypes.QueryChannelClientStateResponse{}, nil } -func (c *MockChainClient) FetchIBCChannelConsensusState(ctx context.Context, portId string, channelId string, revisionNumber uint64, revisionHeight uint64) (*ibcchanneltypes.QueryChannelConsensusStateResponse, error) { +func (c *MockChainClient) FetchIBCChannelConsensusState(ctx context.Context, portId, channelId string, revisionNumber, revisionHeight uint64) (*ibcchanneltypes.QueryChannelConsensusStateResponse, error) { return &ibcchanneltypes.QueryChannelConsensusStateResponse{}, nil } -func (c *MockChainClient) FetchIBCPacketCommitment(ctx context.Context, portId string, channelId string, sequence uint64) (*ibcchanneltypes.QueryPacketCommitmentResponse, error) { +func (c *MockChainClient) FetchIBCPacketCommitment(ctx context.Context, portId, channelId string, sequence uint64) (*ibcchanneltypes.QueryPacketCommitmentResponse, error) { return &ibcchanneltypes.QueryPacketCommitmentResponse{}, nil } -func (c *MockChainClient) FetchIBCPacketCommitments(ctx context.Context, portId string, channelId string, pagination *query.PageRequest) (*ibcchanneltypes.QueryPacketCommitmentsResponse, error) { +func (c *MockChainClient) FetchIBCPacketCommitments(ctx context.Context, portId, channelId string, pagination *query.PageRequest) (*ibcchanneltypes.QueryPacketCommitmentsResponse, error) { return &ibcchanneltypes.QueryPacketCommitmentsResponse{}, nil } -func (c *MockChainClient) FetchIBCPacketReceipt(ctx context.Context, portId string, channelId string, sequence uint64) (*ibcchanneltypes.QueryPacketReceiptResponse, error) { +func (c *MockChainClient) FetchIBCPacketReceipt(ctx context.Context, portId, channelId string, sequence uint64) (*ibcchanneltypes.QueryPacketReceiptResponse, error) { return &ibcchanneltypes.QueryPacketReceiptResponse{}, nil } -func (c *MockChainClient) FetchIBCPacketAcknowledgement(ctx context.Context, portId string, channelId string, sequence uint64) (*ibcchanneltypes.QueryPacketAcknowledgementResponse, error) { +func (c *MockChainClient) FetchIBCPacketAcknowledgement(ctx context.Context, portId, channelId string, sequence uint64) (*ibcchanneltypes.QueryPacketAcknowledgementResponse, error) { return &ibcchanneltypes.QueryPacketAcknowledgementResponse{}, nil } -func (c *MockChainClient) FetchIBCPacketAcknowledgements(ctx context.Context, portId string, channelId string, packetCommitmentSequences []uint64, pagination *query.PageRequest) (*ibcchanneltypes.QueryPacketAcknowledgementsResponse, error) { +func (c *MockChainClient) FetchIBCPacketAcknowledgements(ctx context.Context, portId, channelId string, packetCommitmentSequences []uint64, pagination *query.PageRequest) (*ibcchanneltypes.QueryPacketAcknowledgementsResponse, error) { return &ibcchanneltypes.QueryPacketAcknowledgementsResponse{}, nil } -func (c *MockChainClient) FetchIBCUnreceivedPackets(ctx context.Context, portId string, channelId string, packetCommitmentSequences []uint64) (*ibcchanneltypes.QueryUnreceivedPacketsResponse, error) { +func (c *MockChainClient) FetchIBCUnreceivedPackets(ctx context.Context, portId, channelId string, packetCommitmentSequences []uint64) (*ibcchanneltypes.QueryUnreceivedPacketsResponse, error) { return &ibcchanneltypes.QueryUnreceivedPacketsResponse{}, nil } -func (c *MockChainClient) FetchIBCUnreceivedAcks(ctx context.Context, portId string, channelId string, packetAckSequences []uint64) (*ibcchanneltypes.QueryUnreceivedAcksResponse, error) { +func (c *MockChainClient) FetchIBCUnreceivedAcks(ctx context.Context, portId, channelId string, packetAckSequences []uint64) (*ibcchanneltypes.QueryUnreceivedAcksResponse, error) { return &ibcchanneltypes.QueryUnreceivedAcksResponse{}, nil } -func (c *MockChainClient) FetchIBCNextSequenceReceive(ctx context.Context, portId string, channelId string) (*ibcchanneltypes.QueryNextSequenceReceiveResponse, error) { +func (c *MockChainClient) FetchIBCNextSequenceReceive(ctx context.Context, portId, channelId string) (*ibcchanneltypes.QueryNextSequenceReceiveResponse, error) { return &ibcchanneltypes.QueryNextSequenceReceiveResponse{}, nil } @@ -665,7 +665,7 @@ func (c *MockChainClient) FetchIBCClientStates(ctx context.Context, pagination * return &ibcclienttypes.QueryClientStatesResponse{}, nil } -func (c *MockChainClient) FetchIBCConsensusState(ctx context.Context, clientId string, revisionNumber uint64, revisionHeight uint64, latestHeight bool) (*ibcclienttypes.QueryConsensusStateResponse, error) { +func (c *MockChainClient) FetchIBCConsensusState(ctx context.Context, clientId string, revisionNumber, revisionHeight uint64, latestHeight bool) (*ibcclienttypes.QueryConsensusStateResponse, error) { return &ibcclienttypes.QueryConsensusStateResponse{}, nil } @@ -710,7 +710,7 @@ func (c *MockChainClient) FetchIBCConnectionClientState(ctx context.Context, con return &ibcconnectiontypes.QueryConnectionClientStateResponse{}, nil } -func (c *MockChainClient) FetchIBCConnectionConsensusState(ctx context.Context, connectionId string, revisionNumber uint64, revisionHeight uint64) (*ibcconnectiontypes.QueryConnectionConsensusStateResponse, error) { +func (c *MockChainClient) FetchIBCConnectionConsensusState(ctx context.Context, connectionId string, revisionNumber, revisionHeight uint64) (*ibcconnectiontypes.QueryConnectionConsensusStateResponse, error) { return &ibcconnectiontypes.QueryConnectionConsensusStateResponse{}, nil } diff --git a/client/chain/keys.go b/client/chain/keys.go index f23a380b..f9a97aa2 100644 --- a/client/chain/keys.go +++ b/client/chain/keys.go @@ -48,7 +48,7 @@ func InitCosmosKeyring( return emptyCosmosAddress, nil, err } - // Specfic to Injective chain with Ethermint keys + // Specific to Injective chain with Ethermint keys // Should be secp256k1.PrivKey for generic Cosmos chain cosmosAccPk := ðsecp256k1.PrivKey{ Key: pkBytes, @@ -72,7 +72,7 @@ func InitCosmosKeyring( } } - if len(keyName) == 0 { + if keyName == "" { keyName = defaultKeyringKeyName } diff --git a/client/chain/markets_assistant.go b/client/chain/markets_assistant.go index 10b2b188..6b970d4d 100644 --- a/client/chain/markets_assistant.go +++ b/client/chain/markets_assistant.go @@ -112,22 +112,20 @@ func NewMarketsAssistant(networkName string) (MarketsAssistant, error) { assistant.derivativeMarkets[market.Id] = market } - } else { - if sectionName != "DEFAULT" { - tokenDecimals, _ := section.Key("decimals").Int() - newToken := core.Token{ - Name: sectionName, - Symbol: sectionName, - Denom: section.Key("peggy_denom").String(), - Address: "", - Decimals: int32(tokenDecimals), - Logo: "", - Updated: -1, - } - - assistant.tokensByDenom[newToken.Denom] = newToken - assistant.tokensBySymbol[newToken.Symbol] = newToken + } else if sectionName != "DEFAULT" { + tokenDecimals, _ := section.Key("decimals").Int() + newToken := core.Token{ + Name: sectionName, + Symbol: sectionName, + Denom: section.Key("peggy_denom").String(), + Address: "", + Decimals: int32(tokenDecimals), + Logo: "", + Updated: -1, } + + assistant.tokensByDenom[newToken.Denom] = newToken + assistant.tokensBySymbol[newToken.Symbol] = newToken } } } @@ -150,40 +148,42 @@ func NewMarketsAssistantInitializedFromChain(ctx context.Context, exchangeClient } for _, marketInfo := range spotMarkets.GetMarkets() { - if len(marketInfo.GetBaseTokenMeta().GetSymbol()) > 0 && len(marketInfo.GetQuoteTokenMeta().GetSymbol()) > 0 { - var baseTokenSymbol, quoteTokenSymbol string - if strings.Contains(marketInfo.GetTicker(), "/") { - baseAndQuote := strings.Split(marketInfo.GetTicker(), "/") - baseTokenSymbol, quoteTokenSymbol = baseAndQuote[0], baseAndQuote[1] - } else { - baseTokenSymbol = marketInfo.GetBaseTokenMeta().GetSymbol() - quoteTokenSymbol = marketInfo.GetQuoteTokenMeta().GetSymbol() - } + if marketInfo.GetBaseTokenMeta().GetSymbol() == "" || marketInfo.GetQuoteTokenMeta().GetSymbol() == "" { + continue + } - baseToken := spotTokenRepresentation(baseTokenSymbol, marketInfo.GetBaseTokenMeta(), marketInfo.GetBaseDenom(), &assistant) - quoteToken := spotTokenRepresentation(quoteTokenSymbol, marketInfo.GetQuoteTokenMeta(), marketInfo.GetQuoteDenom(), &assistant) - - makerFeeRate := decimal.RequireFromString(marketInfo.GetMakerFeeRate()) - takerFeeRate := decimal.RequireFromString(marketInfo.GetTakerFeeRate()) - serviceProviderFee := decimal.RequireFromString(marketInfo.GetServiceProviderFee()) - minPriceTickSize := decimal.RequireFromString(marketInfo.GetMinPriceTickSize()) - minQuantityTickSize := decimal.RequireFromString(marketInfo.GetMinQuantityTickSize()) - - market := core.SpotMarket{ - Id: marketInfo.GetMarketId(), - Status: marketInfo.GetMarketStatus(), - Ticker: marketInfo.GetTicker(), - BaseToken: baseToken, - QuoteToken: quoteToken, - MakerFeeRate: makerFeeRate, - TakerFeeRate: takerFeeRate, - ServiceProviderFee: serviceProviderFee, - MinPriceTickSize: minPriceTickSize, - MinQuantityTickSize: minQuantityTickSize, - } + var baseTokenSymbol, quoteTokenSymbol string + if strings.Contains(marketInfo.GetTicker(), "/") { + baseAndQuote := strings.Split(marketInfo.GetTicker(), "/") + baseTokenSymbol, quoteTokenSymbol = baseAndQuote[0], baseAndQuote[1] + } else { + baseTokenSymbol = marketInfo.GetBaseTokenMeta().GetSymbol() + quoteTokenSymbol = marketInfo.GetQuoteTokenMeta().GetSymbol() + } - assistant.spotMarkets[market.Id] = market + baseToken := spotTokenRepresentation(baseTokenSymbol, marketInfo.GetBaseTokenMeta(), marketInfo.GetBaseDenom(), &assistant) + quoteToken := spotTokenRepresentation(quoteTokenSymbol, marketInfo.GetQuoteTokenMeta(), marketInfo.GetQuoteDenom(), &assistant) + + makerFeeRate := decimal.RequireFromString(marketInfo.GetMakerFeeRate()) + takerFeeRate := decimal.RequireFromString(marketInfo.GetTakerFeeRate()) + serviceProviderFee := decimal.RequireFromString(marketInfo.GetServiceProviderFee()) + minPriceTickSize := decimal.RequireFromString(marketInfo.GetMinPriceTickSize()) + minQuantityTickSize := decimal.RequireFromString(marketInfo.GetMinQuantityTickSize()) + + market := core.SpotMarket{ + Id: marketInfo.GetMarketId(), + Status: marketInfo.GetMarketStatus(), + Ticker: marketInfo.GetTicker(), + BaseToken: baseToken, + QuoteToken: quoteToken, + MakerFeeRate: makerFeeRate, + TakerFeeRate: takerFeeRate, + ServiceProviderFee: serviceProviderFee, + MinPriceTickSize: minPriceTickSize, + MinQuantityTickSize: minQuantityTickSize, } + + assistant.spotMarkets[market.Id] = market } derivativeMarketsRequest := derivativeExchangePB.MarketsRequest{ @@ -196,39 +196,41 @@ func NewMarketsAssistantInitializedFromChain(ctx context.Context, exchangeClient } for _, marketInfo := range derivativeMarkets.GetMarkets() { - if len(marketInfo.GetQuoteTokenMeta().GetSymbol()) > 0 { - quoteTokenSymbol := marketInfo.GetQuoteTokenMeta().GetSymbol() - - quoteToken := derivativeTokenRepresentation(quoteTokenSymbol, marketInfo.GetQuoteTokenMeta(), marketInfo.GetQuoteDenom(), &assistant) - - initialMarginRatio := decimal.RequireFromString(marketInfo.GetInitialMarginRatio()) - maintenanceMarginRatio := decimal.RequireFromString(marketInfo.GetMaintenanceMarginRatio()) - makerFeeRate := decimal.RequireFromString(marketInfo.GetMakerFeeRate()) - takerFeeRate := decimal.RequireFromString(marketInfo.GetTakerFeeRate()) - serviceProviderFee := decimal.RequireFromString(marketInfo.GetServiceProviderFee()) - minPriceTickSize := decimal.RequireFromString(marketInfo.GetMinPriceTickSize()) - minQuantityTickSize := decimal.RequireFromString(marketInfo.GetMinQuantityTickSize()) - - market := core.DerivativeMarket{ - Id: marketInfo.GetMarketId(), - Status: marketInfo.GetMarketStatus(), - Ticker: marketInfo.GetTicker(), - OracleBase: marketInfo.GetOracleBase(), - OracleQuote: marketInfo.GetOracleQuote(), - OracleType: marketInfo.GetOracleType(), - OracleScaleFactor: marketInfo.GetOracleScaleFactor(), - InitialMarginRatio: initialMarginRatio, - MaintenanceMarginRatio: maintenanceMarginRatio, - QuoteToken: quoteToken, - MakerFeeRate: makerFeeRate, - TakerFeeRate: takerFeeRate, - ServiceProviderFee: serviceProviderFee, - MinPriceTickSize: minPriceTickSize, - MinQuantityTickSize: minQuantityTickSize, - } + if marketInfo.GetQuoteTokenMeta().GetSymbol() == "" { + continue + } - assistant.derivativeMarkets[market.Id] = market + quoteTokenSymbol := marketInfo.GetQuoteTokenMeta().GetSymbol() + + quoteToken := derivativeTokenRepresentation(quoteTokenSymbol, marketInfo.GetQuoteTokenMeta(), marketInfo.GetQuoteDenom(), &assistant) + + initialMarginRatio := decimal.RequireFromString(marketInfo.GetInitialMarginRatio()) + maintenanceMarginRatio := decimal.RequireFromString(marketInfo.GetMaintenanceMarginRatio()) + makerFeeRate := decimal.RequireFromString(marketInfo.GetMakerFeeRate()) + takerFeeRate := decimal.RequireFromString(marketInfo.GetTakerFeeRate()) + serviceProviderFee := decimal.RequireFromString(marketInfo.GetServiceProviderFee()) + minPriceTickSize := decimal.RequireFromString(marketInfo.GetMinPriceTickSize()) + minQuantityTickSize := decimal.RequireFromString(marketInfo.GetMinQuantityTickSize()) + + market := core.DerivativeMarket{ + Id: marketInfo.GetMarketId(), + Status: marketInfo.GetMarketStatus(), + Ticker: marketInfo.GetTicker(), + OracleBase: marketInfo.GetOracleBase(), + OracleQuote: marketInfo.GetOracleQuote(), + OracleType: marketInfo.GetOracleType(), + OracleScaleFactor: marketInfo.GetOracleScaleFactor(), + InitialMarginRatio: initialMarginRatio, + MaintenanceMarginRatio: maintenanceMarginRatio, + QuoteToken: quoteToken, + MakerFeeRate: makerFeeRate, + TakerFeeRate: takerFeeRate, + ServiceProviderFee: serviceProviderFee, + MinPriceTickSize: minPriceTickSize, + MinQuantityTickSize: minQuantityTickSize, } + + assistant.derivativeMarkets[market.Id] = market } return assistant, nil @@ -245,7 +247,7 @@ func NewMarketsAssistantWithAllTokens(ctx context.Context, exchangeClient exchan return assistant, nil } -func uniqueSymbol(symbol string, denom string, tokenMetaSymbol string, tokenMetaName string, assistant MarketsAssistant) string { +func uniqueSymbol(symbol, denom, tokenMetaSymbol, tokenMetaName string, assistant MarketsAssistant) string { uniqueSymbol := denom _, isSymbolPresent := assistant.tokensBySymbol[symbol] if isSymbolPresent { @@ -343,7 +345,8 @@ func (assistant MarketsAssistant) initializeTokensFromChainDenoms(ctx context.Co denomsMetadata = append(denomsMetadata, result.GetMetadatas()...) } - for _, denomMetadata := range denomsMetadata { + for i := range denomsMetadata { + denomMetadata := denomsMetadata[i] symbol := denomMetadata.GetSymbol() denom := denomMetadata.GetBase() diff --git a/client/common/api_request_assistant.go b/client/common/api_request_assistant.go index eaafb110..1dd4acee 100644 --- a/client/common/api_request_assistant.go +++ b/client/common/api_request_assistant.go @@ -7,10 +7,10 @@ import ( "google.golang.org/grpc/metadata" ) -type ApiCall[Q any, R any] func(ctx context.Context, in *Q, opts ...grpc.CallOption) (*R, error) -type ApiStreamCall[Q any, S grpc.ClientStream] func(ctx context.Context, in *Q, opts ...grpc.CallOption) (S, error) +type APICall[Q any, R any] func(ctx context.Context, in *Q, opts ...grpc.CallOption) (*R, error) +type APIStreamCall[Q any, S grpc.ClientStream] func(ctx context.Context, in *Q, opts ...grpc.CallOption) (S, error) -func ExecuteCall[Q any, R any](ctx context.Context, cookieAssistant CookieAssistant, call ApiCall[Q, R], in *Q) (*R, error) { +func ExecuteCall[Q any, R any](ctx context.Context, cookieAssistant CookieAssistant, call APICall[Q, R], in *Q) (*R, error) { var header metadata.MD localCtx := metadata.NewOutgoingContext(ctx, cookieAssistant.RealMetadata()) @@ -21,7 +21,7 @@ func ExecuteCall[Q any, R any](ctx context.Context, cookieAssistant CookieAssist return response, err } -func ExecuteStreamCall[Q any, S grpc.ClientStream](ctx context.Context, cookieAssistant CookieAssistant, call ApiStreamCall[Q, S], in *Q) (S, error) { +func ExecuteStreamCall[Q any, S grpc.ClientStream](ctx context.Context, cookieAssistant CookieAssistant, call APIStreamCall[Q, S], in *Q) (S, error) { localCtx := metadata.NewOutgoingContext(ctx, cookieAssistant.RealMetadata()) stream, callError := call(localCtx, in) diff --git a/client/common/network.go b/client/common/network.go index d2a5184a..c5786ce1 100644 --- a/client/common/network.go +++ b/client/common/network.go @@ -64,7 +64,7 @@ func (assistant *ExpiringCookieAssistant) initializeCookie(provider MetadataProv } func (assistant *ExpiringCookieAssistant) checkCookieExpiration() { - //borrow http request to parse cookie + // borrow http request to parse cookie header := http.Header{} header.Add("Cookie", assistant.cookie) request := http.Request{Header: header} @@ -188,11 +188,11 @@ type Network struct { TmEndpoint string ChainGrpcEndpoint string ChainStreamGrpcEndpoint string - ChainTlsCert credentials.TransportCredentials + ChainTLSCert credentials.TransportCredentials ExchangeGrpcEndpoint string ExplorerGrpcEndpoint string - ExchangeTlsCert credentials.TransportCredentials - ExplorerTlsCert credentials.TransportCredentials + ExchangeTLSCert credentials.TransportCredentials + ExplorerTLSCert credentials.TransportCredentials ChainId string FeeDenom string Name string @@ -201,7 +201,7 @@ type Network struct { ExplorerCookieAssistant CookieAssistant } -func LoadNetwork(name string, node string) Network { +func LoadNetwork(name, node string) Network { switch name { case "local": @@ -257,7 +257,7 @@ func LoadNetwork(name string, node string) Network { } var lcdEndpoint, tmEndpoint, chainGrpcEndpoint, chainStreamGrpcEndpoint, exchangeGrpcEndpoint, explorerGrpcEndpoint string - var chainTlsCert, exchangeTlsCert, explorerTlsCert credentials.TransportCredentials + var chainTLSCert, exchangeTLSCert, explorerTLSCert credentials.TransportCredentials var chainCookieAssistant, exchangeCookieAssistant, explorerCookieAssistant CookieAssistant if node == "lb" { lcdEndpoint = "https://testnet.sentry.lcd.injective.network:443" @@ -266,9 +266,9 @@ func LoadNetwork(name string, node string) Network { chainStreamGrpcEndpoint = "testnet.sentry.chain.stream.injective.network:443" exchangeGrpcEndpoint = "testnet.sentry.exchange.grpc.injective.network:443" explorerGrpcEndpoint = "testnet.sentry.explorer.grpc.injective.network:443" - chainTlsCert = credentials.NewServerTLSFromCert(&tls.Certificate{}) - exchangeTlsCert = credentials.NewServerTLSFromCert(&tls.Certificate{}) - explorerTlsCert = credentials.NewServerTLSFromCert(&tls.Certificate{}) + chainTLSCert = credentials.NewServerTLSFromCert(&tls.Certificate{}) + exchangeTLSCert = credentials.NewServerTLSFromCert(&tls.Certificate{}) + explorerTLSCert = credentials.NewServerTLSFromCert(&tls.Certificate{}) chainCookieAssistant = &BareMetalLoadBalancedCookieAssistant{} exchangeCookieAssistant = &BareMetalLoadBalancedCookieAssistant{} explorerCookieAssistant = &BareMetalLoadBalancedCookieAssistant{} @@ -279,9 +279,9 @@ func LoadNetwork(name string, node string) Network { chainStreamGrpcEndpoint = "testnet.chain.stream.injective.network:443" exchangeGrpcEndpoint = "testnet.exchange.grpc.injective.network:443" explorerGrpcEndpoint = "testnet.explorer.grpc.injective.network:443" - chainTlsCert = credentials.NewServerTLSFromCert(&tls.Certificate{}) - exchangeTlsCert = credentials.NewServerTLSFromCert(&tls.Certificate{}) - explorerTlsCert = credentials.NewServerTLSFromCert(&tls.Certificate{}) + chainTLSCert = credentials.NewServerTLSFromCert(&tls.Certificate{}) + exchangeTLSCert = credentials.NewServerTLSFromCert(&tls.Certificate{}) + explorerTLSCert = credentials.NewServerTLSFromCert(&tls.Certificate{}) chainCookieAssistant = &DisabledCookieAssistant{} exchangeCookieAssistant = &DisabledCookieAssistant{} explorerCookieAssistant = &DisabledCookieAssistant{} @@ -292,11 +292,11 @@ func LoadNetwork(name string, node string) Network { TmEndpoint: tmEndpoint, ChainGrpcEndpoint: chainGrpcEndpoint, ChainStreamGrpcEndpoint: chainStreamGrpcEndpoint, - ChainTlsCert: chainTlsCert, + ChainTLSCert: chainTLSCert, ExchangeGrpcEndpoint: exchangeGrpcEndpoint, - ExchangeTlsCert: exchangeTlsCert, + ExchangeTLSCert: exchangeTLSCert, ExplorerGrpcEndpoint: explorerGrpcEndpoint, - ExplorerTlsCert: explorerTlsCert, + ExplorerTLSCert: explorerTLSCert, ChainId: "injective-888", FeeDenom: "inj", Name: "testnet", @@ -310,7 +310,7 @@ func LoadNetwork(name string, node string) Network { panic(fmt.Sprintf("invalid node %s for %s", node, name)) } var lcdEndpoint, tmEndpoint, chainGrpcEndpoint, chainStreamGrpcEndpoint, exchangeGrpcEndpoint, explorerGrpcEndpoint string - var chainTlsCert, exchangeTlsCert, explorerTlsCert credentials.TransportCredentials + var chainTLSCert, exchangeTLSCert, explorerTLSCert credentials.TransportCredentials var chainCookieAssistant, exchangeCookieAssistant, explorerCookieAssistant CookieAssistant lcdEndpoint = "https://sentry.lcd.injective.network" @@ -319,9 +319,9 @@ func LoadNetwork(name string, node string) Network { chainStreamGrpcEndpoint = "sentry.chain.stream.injective.network:443" exchangeGrpcEndpoint = "sentry.exchange.grpc.injective.network:443" explorerGrpcEndpoint = "sentry.explorer.grpc.injective.network:443" - chainTlsCert = credentials.NewServerTLSFromCert(&tls.Certificate{}) - exchangeTlsCert = credentials.NewServerTLSFromCert(&tls.Certificate{}) - explorerTlsCert = credentials.NewServerTLSFromCert(&tls.Certificate{}) + chainTLSCert = credentials.NewServerTLSFromCert(&tls.Certificate{}) + exchangeTLSCert = credentials.NewServerTLSFromCert(&tls.Certificate{}) + explorerTLSCert = credentials.NewServerTLSFromCert(&tls.Certificate{}) chainCookieAssistant = &BareMetalLoadBalancedCookieAssistant{} exchangeCookieAssistant = &BareMetalLoadBalancedCookieAssistant{} explorerCookieAssistant = &BareMetalLoadBalancedCookieAssistant{} @@ -331,11 +331,11 @@ func LoadNetwork(name string, node string) Network { TmEndpoint: tmEndpoint, ChainGrpcEndpoint: chainGrpcEndpoint, ChainStreamGrpcEndpoint: chainStreamGrpcEndpoint, - ChainTlsCert: chainTlsCert, + ChainTLSCert: chainTLSCert, ExchangeGrpcEndpoint: exchangeGrpcEndpoint, - ExchangeTlsCert: exchangeTlsCert, + ExchangeTLSCert: exchangeTLSCert, ExplorerGrpcEndpoint: explorerGrpcEndpoint, - ExplorerTlsCert: explorerTlsCert, + ExplorerTLSCert: explorerTLSCert, ChainId: "injective-1", FeeDenom: "inj", Name: "mainnet", @@ -382,8 +382,8 @@ func Connect(protoAddr string) (net.Conn, error) { // ProtocolAndAddress splits an address into the protocol and address components. // For instance, "tcp://127.0.0.1:8080" will be split into "tcp" and "127.0.0.1:8080". // If the address has no protocol prefix, the default is "tcp". -func ProtocolAndAddress(listenAddr string) (string, string) { - protocol, address := "tcp", listenAddr +func ProtocolAndAddress(listenAddr string) (protocol, address string) { + protocol, address = "tcp", listenAddr parts := strings.SplitN(address, "://", 2) if len(parts) == 2 { protocol, address = parts[0], parts[1] diff --git a/client/common/options.go b/client/common/options.go index a4050947..17526a59 100644 --- a/client/common/options.go +++ b/client/common/options.go @@ -51,7 +51,7 @@ func OptionTLSCert(tlsCert credentials.TransportCredentials) ClientOption { if tlsCert == nil { log.Infoln("client does not use grpc secure transport") } else { - log.Infoln("succesfully load server TLS cert") + log.Infoln("successfully load server TLS cert") } opts.TLSCert = tlsCert return nil diff --git a/client/common/util.go b/client/common/util.go index 7254ea51..80416fcb 100644 --- a/client/common/util.go +++ b/client/common/util.go @@ -25,7 +25,7 @@ func HexToBytes(str string) ([]byte, error) { return data, nil } -func LoadTlsCert(path string, serverName string) credentials.TransportCredentials { +func LoadTLSCert(path, serverName string) credentials.TransportCredentials { if path == "" { return nil } @@ -43,6 +43,7 @@ func LoadTlsCert(path string, serverName string) credentials.TransportCredential } // get domain from tcp://domain:port domain := strings.Split(serverName, ":")[1][2:] + // nolint:gosec // we ignore the MinVersion validation because it's not a security issue config := &tls.Config{ RootCAs: certPool, ServerName: domain, diff --git a/client/core/market.go b/client/core/market.go index df2151c6..3e6c273b 100644 --- a/client/core/market.go +++ b/client/core/market.go @@ -99,7 +99,7 @@ func (derivativeMarket DerivativeMarket) MarginToChainFormat(humanReadableValue return valueInChainFormat } -func (derivativeMarket DerivativeMarket) CalculateMarginInChainFormat(humanReadableQuantity decimal.Decimal, humanReadablePrice decimal.Decimal, leverage decimal.Decimal) sdkmath.LegacyDec { +func (derivativeMarket DerivativeMarket) CalculateMarginInChainFormat(humanReadableQuantity, humanReadablePrice, leverage decimal.Decimal) sdkmath.LegacyDec { chainFormattedQuantity := humanReadableQuantity chainFormattedPrice := humanReadablePrice.Mul(decimal.New(1, derivativeMarket.QuoteToken.Decimals)) diff --git a/client/core/market_test.go b/client/core/market_test.go index 64a58679..733b8be8 100644 --- a/client/core/market_test.go +++ b/client/core/market_test.go @@ -134,7 +134,7 @@ func TestConvertPriceFromExtendedChainFormatForSpotMarket(t *testing.T) { assert.Assert(t, expectedPrice.Equal(humanReadablePrice)) } -//Derivative markets tests +// Derivative markets tests func TestConvertQuantityToChainFormatForDerivativeMarket(t *testing.T) { derivativeMarket := createBTCUSDTPerpMarket() diff --git a/client/exchange/exchange.go b/client/exchange/exchange.go index f0ec7892..847b1cd1 100644 --- a/client/exchange/exchange.go +++ b/client/exchange/exchange.go @@ -96,8 +96,8 @@ type ExchangeClient interface { func NewExchangeClient(network common.Network, options ...common.ClientOption) (ExchangeClient, error) { // process options opts := common.DefaultClientOptions() - if network.ChainTlsCert != nil { - options = append(options, common.OptionTLSCert(network.ExchangeTlsCert)) + if network.ChainTLSCert != nil { + options = append(options, common.OptionTLSCert(network.ExchangeTLSCert)) } for _, opt := range options { if err := opt(opts); err != nil { @@ -432,7 +432,7 @@ func (c *exchangeClient) GetDerivativeFundingRates(ctx context.Context, req *der // 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, quoteSymbol, oracleType string, oracleScaleFactor uint32) (*oraclePB.PriceResponse, error) { req := oraclePB.PriceRequest{ BaseSymbol: baseSymbol, QuoteSymbol: quoteSymbol, @@ -462,7 +462,7 @@ func (c *exchangeClient) GetOracleList(ctx context.Context) (*oraclePB.OracleLis return res, nil } -func (c *exchangeClient) StreamPrices(ctx context.Context, baseSymbol string, quoteSymbol string, oracleType string) (oraclePB.InjectiveOracleRPC_StreamPricesClient, error) { +func (c *exchangeClient) StreamPrices(ctx context.Context, baseSymbol, quoteSymbol, oracleType string) (oraclePB.InjectiveOracleRPC_StreamPricesClient, error) { req := oraclePB.StreamPricesRequest{ BaseSymbol: baseSymbol, QuoteSymbol: quoteSymbol, @@ -537,7 +537,7 @@ func (c *exchangeClient) GetSubaccountsList(ctx context.Context, accountAddress 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, denom string) (*accountPB.SubaccountBalanceEndpointResponse, error) { req := accountPB.SubaccountBalanceEndpointRequest{ SubaccountId: subaccountId, Denom: denom, @@ -945,7 +945,7 @@ func (c *exchangeClient) GetAccountPortfolioBalances(ctx context.Context, accoun return res, nil } -func (c *exchangeClient) StreamAccountPortfolio(ctx context.Context, accountAddress string, subaccountId, balanceType string) (portfolioExchangePB.InjectivePortfolioRPC_StreamAccountPortfolioClient, error) { +func (c *exchangeClient) StreamAccountPortfolio(ctx context.Context, accountAddress, subaccountId, balanceType string) (portfolioExchangePB.InjectivePortfolioRPC_StreamAccountPortfolioClient, error) { req := &portfolioExchangePB.StreamAccountPortfolioRequest{ AccountAddress: accountAddress, SubaccountId: subaccountId, diff --git a/client/exchange/exchange_test_support.go b/client/exchange/exchange_test_support.go index 2b37623a..68af97d4 100644 --- a/client/exchange/exchange_test_support.go +++ b/client/exchange/exchange_test_support.go @@ -128,7 +128,7 @@ func (e *MockExchangeClient) GetDerivativeFundingRates(ctx context.Context, req return &derivativeExchangePB.FundingRatesResponse{}, nil } -func (e *MockExchangeClient) GetPrice(ctx context.Context, baseSymbol string, quoteSymbol string, oracleType string, oracleScaleFactor uint32) (*oraclePB.PriceResponse, error) { +func (e *MockExchangeClient) GetPrice(ctx context.Context, baseSymbol, quoteSymbol, oracleType string, oracleScaleFactor uint32) (*oraclePB.PriceResponse, error) { return &oraclePB.PriceResponse{}, nil } @@ -136,7 +136,7 @@ func (e *MockExchangeClient) GetOracleList(ctx context.Context) (*oraclePB.Oracl return &oraclePB.OracleListResponse{}, nil } -func (e *MockExchangeClient) StreamPrices(ctx context.Context, baseSymbol string, quoteSymbol string, oracleType string) (oraclePB.InjectiveOracleRPC_StreamPricesClient, error) { +func (e *MockExchangeClient) StreamPrices(ctx context.Context, baseSymbol, quoteSymbol, oracleType string) (oraclePB.InjectiveOracleRPC_StreamPricesClient, error) { return nil, nil } @@ -156,7 +156,7 @@ func (e *MockExchangeClient) GetSubaccountsList(ctx context.Context, accountAddr return &accountPB.SubaccountsListResponse{}, nil } -func (e *MockExchangeClient) GetSubaccountBalance(ctx context.Context, subaccountId string, denom string) (*accountPB.SubaccountBalanceEndpointResponse, error) { +func (e *MockExchangeClient) GetSubaccountBalance(ctx context.Context, subaccountId, denom string) (*accountPB.SubaccountBalanceEndpointResponse, error) { return &accountPB.SubaccountBalanceEndpointResponse{}, nil } @@ -283,7 +283,7 @@ func (e *MockExchangeClient) GetAccountPortfolioBalances(ctx context.Context, ac return &portfolioExchangePB.AccountPortfolioBalancesResponse{}, nil } -func (e *MockExchangeClient) StreamAccountPortfolio(ctx context.Context, accountAddress string, subaccountId, balanceType string) (portfolioExchangePB.InjectivePortfolioRPC_StreamAccountPortfolioClient, error) { +func (e *MockExchangeClient) StreamAccountPortfolio(ctx context.Context, accountAddress, subaccountId, balanceType string) (portfolioExchangePB.InjectivePortfolioRPC_StreamAccountPortfolioClient, error) { return nil, nil } diff --git a/client/explorer/explorer.go b/client/explorer/explorer.go index 02b2290a..2dbe8ce8 100644 --- a/client/explorer/explorer.go +++ b/client/explorer/explorer.go @@ -36,8 +36,8 @@ type ExplorerClient interface { func NewExplorerClient(network common.Network, options ...common.ClientOption) (ExplorerClient, error) { // process options opts := common.DefaultClientOptions() - if network.ChainTlsCert != nil { - options = append(options, common.OptionTLSCert(network.ExchangeTlsCert)) + if network.ChainTLSCert != nil { + options = append(options, common.OptionTLSCert(network.ExchangeTLSCert)) } for _, opt := range options { if err := opt(opts); err != nil { diff --git a/client/metadata/fetch_metadata.go b/client/metadata/fetch_metadata.go index cb4f08b0..5bfa0da2 100644 --- a/client/metadata/fetch_metadata.go +++ b/client/metadata/fetch_metadata.go @@ -9,7 +9,7 @@ import ( exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" derivativeExchangePB "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" - //derivativeExchangePB "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" + // derivativeExchangePB "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" "math" "strconv" @@ -81,7 +81,7 @@ func FetchDenom(network common.Network) { metadataOutput += config } - //fetch derivative markets + // fetch derivative markets derivativeMarketsReq := derivativeExchangePB.MarketsRequest{MarketStatus: "active"} derivativeRes, err := exchangeClient.GetDerivativeMarkets(ctx, &derivativeMarketsReq) if err != nil { @@ -128,7 +128,7 @@ func FetchDenom(network common.Network) { } fileName := fmt.Sprintf("client/metadata/assets/%s.ini", network.Name) - err = os.WriteFile(fileName, []byte(metadataOutput), 0644) + err = os.WriteFile(fileName, []byte(metadataOutput), 0600) // nolint:gocritic // 0600 is the correct permission if err != nil { panic(err) } diff --git a/client/tm/tmclient.go b/client/tm/tmclient.go index 420567f6..6b5908c8 100644 --- a/client/tm/tmclient.go +++ b/client/tm/tmclient.go @@ -9,15 +9,14 @@ import ( rpcclient "github.com/cometbft/cometbft/rpc/client" rpchttp "github.com/cometbft/cometbft/rpc/client/http" ctypes "github.com/cometbft/cometbft/rpc/core/types" - tmctypes "github.com/cometbft/cometbft/rpc/core/types" ) type TendermintClient interface { - GetBlock(ctx context.Context, height int64) (*tmctypes.ResultBlock, error) + GetBlock(ctx context.Context, height int64) (*ctypes.ResultBlock, error) GetLatestBlockHeight(ctx context.Context) (int64, error) - GetTxs(ctx context.Context, block *tmctypes.ResultBlock) ([]*ctypes.ResultTx, error) + GetTxs(ctx context.Context, block *ctypes.ResultBlock) ([]*ctypes.ResultTx, error) GetBlockResults(ctx context.Context, height int64) (*ctypes.ResultBlockResults, error) - GetValidatorSet(ctx context.Context, height int64) (*tmctypes.ResultValidators, error) + GetValidatorSet(ctx context.Context, height int64) (*ctypes.ResultValidators, error) GetABCIInfo(ctx context.Context) (*ctypes.ResultABCIInfo, error) } @@ -37,7 +36,7 @@ func NewRPCClient(rpcNodeAddr string) TendermintClient { } // GetBlock queries for a block by height. An error is returned if the query fails. -func (c *tmClient) GetBlock(ctx context.Context, height int64) (*tmctypes.ResultBlock, error) { +func (c *tmClient) GetBlock(ctx context.Context, height int64) (*ctypes.ResultBlock, error) { return c.rpcClient.Block(ctx, &height) } @@ -60,7 +59,7 @@ func (c *tmClient) GetLatestBlockHeight(ctx context.Context) (int64, error) { // GetTxs queries for all the transactions in a block height. // It uses `Tx` RPC method to query for the transaction. -func (c *tmClient) GetTxs(ctx context.Context, block *tmctypes.ResultBlock) ([]*ctypes.ResultTx, error) { +func (c *tmClient) GetTxs(ctx context.Context, block *ctypes.ResultBlock) ([]*ctypes.ResultTx, error) { txs := make([]*ctypes.ResultTx, 0, len(block.Block.Txs)) for _, tmTx := range block.Block.Txs { @@ -82,11 +81,11 @@ func (c *tmClient) GetTxs(ctx context.Context, block *tmctypes.ResultBlock) ([]* // GetValidatorSet returns all the known Tendermint validators for a given block // height. An error is returned if the query fails. -func (c *tmClient) GetValidatorSet(ctx context.Context, height int64) (*tmctypes.ResultValidators, error) { +func (c *tmClient) GetValidatorSet(ctx context.Context, height int64) (*ctypes.ResultValidators, error) { return c.rpcClient.Validators(ctx, &height, nil, nil) } // GetABCIInfo returns the node abci version -func (c *tmClient) GetABCIInfo(ctx context.Context) (*tmctypes.ResultABCIInfo, error) { +func (c *tmClient) GetABCIInfo(ctx context.Context) (*ctypes.ResultABCIInfo, error) { return c.rpcClient.ABCIInfo(ctx) } diff --git a/eip712_cosmos.go b/eip712_cosmos.go index 3f3ad3d5..cc0e645b 100644 --- a/eip712_cosmos.go +++ b/eip712_cosmos.go @@ -194,12 +194,12 @@ func traverseFields( if prefix == typeDefPrefix { if len(typeMap[rootType]) == n { - return + return nil } } else { typeDef := sanitizeTypedef(prefix) if len(typeMap[typeDef]) == n { - return + return nil } } @@ -232,7 +232,7 @@ func traverseFields( err = cdc.UnpackAny(any, &anyWrapper.Value) if err != nil { err = errors.Wrap(err, "failed to unpack Any in msg struct") - return + return err } fieldType = reflect.TypeOf(anyWrapper) @@ -337,7 +337,7 @@ func traverseFields( err = traverseFields(cdc, typeMap, rootType, fieldPrefix, fieldType, field) if err != nil { - return + return err } continue diff --git a/ethereum/util/amounts.go b/ethereum/util/amounts.go index 1435beaa..9535c8cf 100644 --- a/ethereum/util/amounts.go +++ b/ethereum/util/amounts.go @@ -10,16 +10,16 @@ import ( type Wei decimal.Decimal func (w Wei) String() string { - return (decimal.Decimal)(w).String() + return decimal.Decimal(w).String() } func (w Wei) StringGwei() string { - d := (decimal.Decimal)(w).Div(decimal.NewFromFloat(1e9)) + d := decimal.Decimal(w).Div(decimal.NewFromFloat(1e9)) return d.String() } func (w Wei) Bytes() []byte { - return []byte((decimal.Decimal)(w).String()) + return []byte(decimal.Decimal(w).String()) } func (w *Wei) Scan(v interface{}) error { @@ -37,10 +37,10 @@ func (w *Wei) Scan(v interface{}) error { } d, err := decimal.NewFromString(source) if err != nil { - err := fmt.Errorf("failed to parse decimal.Decimal from %s, error: %v", source, err) + err := fmt.Errorf("failed to parse decimal.Decimal from %s, error: %w", source, err) return err } else { - *w = (Wei)(d) + *w = Wei(d) } return nil } @@ -128,7 +128,7 @@ func (w *Wei) Add(amount *Wei) *Wei { return (*Wei)(&result) } -// Sub substracts two amounts and returns a new amount. +// Sub subtracts two amounts and returns a new amount. func (w *Wei) Sub(amount *Wei) *Wei { d1 := (*decimal.Decimal)(w) d2 := (*decimal.Decimal)(amount) diff --git a/ethereum/util/contract.go b/ethereum/util/contract.go index c3c66568..7f83113c 100644 --- a/ethereum/util/contract.go +++ b/ethereum/util/contract.go @@ -41,7 +41,7 @@ func BindContract(client *ethclient.Client, contract *Contract) (*BoundContract, } parsedABI, err := abi.JSON(bytes.NewReader(contract.ABI)) if err != nil { - err = fmt.Errorf("failed to parse contract ABI: %v", err) + err = fmt.Errorf("failed to parse contract ABI: %w", err) return nil, err } bound := &BoundContract{ @@ -87,10 +87,6 @@ func (contract *BoundContract) ABI() abi.ABI { return contract.abi } -func (c *BoundContract) DeployContract(opts *bind.TransactOpts, params ...interface{}) (common.Address, *types.Transaction, error) { - panic("not implemented") -} - func (c *BoundContract) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { if c.transactFn == nil { return c.BoundContract.Transact(opts, method, params...) diff --git a/examples/chain/1_LocalOrderHash/example.go b/examples/chain/1_LocalOrderHash/example.go index b271aaab..a3ba477d 100644 --- a/examples/chain/1_LocalOrderHash/example.go +++ b/examples/chain/1_LocalOrderHash/example.go @@ -119,7 +119,7 @@ func main() { fmt.Println("computed spot order hashes: ", orderHashes.Spot) fmt.Println("computed derivative order hashes: ", orderHashes.Derivative) - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg, msg1) if err != nil { diff --git a/examples/chain/4_MsgBatchCreateSpotLimitOrders/example.go b/examples/chain/4_MsgBatchCreateSpotLimitOrders/example.go index 617617dd..e8911b0c 100644 --- a/examples/chain/4_MsgBatchCreateSpotLimitOrders/example.go +++ b/examples/chain/4_MsgBatchCreateSpotLimitOrders/example.go @@ -112,7 +112,7 @@ func main() { fmt.Println("simulated order hashes", msgBatchCreateSpotLimitOrdersResponse.OrderHashes) - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/5_MsgBatchCreateDerivativeLimitOrders/example.go b/examples/chain/5_MsgBatchCreateDerivativeLimitOrders/example.go index 24830abc..cbd1812c 100644 --- a/examples/chain/5_MsgBatchCreateDerivativeLimitOrders/example.go +++ b/examples/chain/5_MsgBatchCreateDerivativeLimitOrders/example.go @@ -117,7 +117,7 @@ func main() { fmt.Println("simulated order hashes", msgBatchCreateDerivativeLimitOrdersResponse.OrderHashes) - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/6_MsgRegisterAsDMM/example.go b/examples/chain/6_MsgRegisterAsDMM/example.go index ca877e9e..a21f352b 100644 --- a/examples/chain/6_MsgRegisterAsDMM/example.go +++ b/examples/chain/6_MsgRegisterAsDMM/example.go @@ -60,7 +60,7 @@ func main() { Sender: senderAddress.String(), } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/auction/1_MsgBid/example.go b/examples/chain/auction/1_MsgBid/example.go index 0012157c..705b626a 100644 --- a/examples/chain/auction/1_MsgBid/example.go +++ b/examples/chain/auction/1_MsgBid/example.go @@ -68,7 +68,7 @@ func main() { BidAmount: bidAmount, } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/authz/1_MsgGrant/example.go b/examples/chain/authz/1_MsgGrant/example.go index 02f5116e..96fad70a 100644 --- a/examples/chain/authz/1_MsgGrant/example.go +++ b/examples/chain/authz/1_MsgGrant/example.go @@ -60,9 +60,9 @@ func main() { grantee := "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r" expireIn := time.Now().AddDate(1, 0, 0) // years months days - //GENERIC AUTHZ - //msgtype := "/injective.exchange.v1beta1.MsgCreateSpotLimitOrder" - //msg := chainClient.BuildGenericAuthz(granter, grantee, msgtype, expireIn) + // GENERIC AUTHZ + // msgtype := "/injective.exchange.v1beta1.MsgCreateSpotLimitOrder" + // msg := chainClient.BuildGenericAuthz(granter, grantee, msgtype, expireIn) // TYPED AUTHZ msg := chainClient.BuildExchangeAuthz( @@ -74,7 +74,7 @@ func main() { expireIn, ) - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/authz/2_MsgExec/example.go b/examples/chain/authz/2_MsgExec/example.go index 4fd3f7aa..840b4bc9 100644 --- a/examples/chain/authz/2_MsgExec/example.go +++ b/examples/chain/authz/2_MsgExec/example.go @@ -126,7 +126,7 @@ func main() { Msgs: []*codectypes.Any{msg0Any}, } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/authz/3_MsgRevoke/example.go b/examples/chain/authz/3_MsgRevoke/example.go index 46bb2f3a..dfdfa8b5 100644 --- a/examples/chain/authz/3_MsgRevoke/example.go +++ b/examples/chain/authz/3_MsgRevoke/example.go @@ -65,7 +65,7 @@ func main() { MsgTypeUrl: msgType, } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/bank/1_MsgSend/example.go b/examples/chain/bank/1_MsgSend/example.go index d49591a3..a7a2e737 100644 --- a/examples/chain/bank/1_MsgSend/example.go +++ b/examples/chain/bank/1_MsgSend/example.go @@ -66,7 +66,7 @@ func main() { }, } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/bank/2_MsgMultiSend/example.go b/examples/chain/bank/2_MsgMultiSend/example.go index 5bf49241..77c8e0b5 100644 --- a/examples/chain/bank/2_MsgMultiSend/example.go +++ b/examples/chain/bank/2_MsgMultiSend/example.go @@ -92,7 +92,7 @@ func main() { }, } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/distribution/1_SetWithdrawAddress/example.go b/examples/chain/distribution/1_SetWithdrawAddress/example.go index 7e0d371c..71ef6fe0 100644 --- a/examples/chain/distribution/1_SetWithdrawAddress/example.go +++ b/examples/chain/distribution/1_SetWithdrawAddress/example.go @@ -63,7 +63,7 @@ func main() { WithdrawAddress: withdrawAddress, } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg response, err := chainClient.AsyncBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/distribution/2_MsgWithdrawDelegatorReward/example.go b/examples/chain/distribution/2_MsgWithdrawDelegatorReward/example.go index 46eed8cb..e2c7a359 100644 --- a/examples/chain/distribution/2_MsgWithdrawDelegatorReward/example.go +++ b/examples/chain/distribution/2_MsgWithdrawDelegatorReward/example.go @@ -60,7 +60,7 @@ func main() { msg.DelegatorAddress = senderAddress.String() msg.ValidatorAddress = "injvaloper14gy4acwjm96wd20awm9ar6j54lev5p7espy9ug" - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/distribution/3_WithdrawValidatorCommission/example.go b/examples/chain/distribution/3_WithdrawValidatorCommission/example.go index 85efe852..2e90b143 100644 --- a/examples/chain/distribution/3_WithdrawValidatorCommission/example.go +++ b/examples/chain/distribution/3_WithdrawValidatorCommission/example.go @@ -62,7 +62,7 @@ func main() { ValidatorAddress: validatorAddress, } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg response, err := chainClient.AsyncBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/distribution/4_FundCommunityPool/example.go b/examples/chain/distribution/4_FundCommunityPool/example.go index 9c2c9aeb..9da1b1d7 100644 --- a/examples/chain/distribution/4_FundCommunityPool/example.go +++ b/examples/chain/distribution/4_FundCommunityPool/example.go @@ -64,7 +64,7 @@ func main() { Depositor: senderAddress.String(), } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg response, err := chainClient.AsyncBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/exchange/10_MsgCreateDerivativeLimitOrder/example.go b/examples/chain/exchange/10_MsgCreateDerivativeLimitOrder/example.go index 13d00928..d8881b1c 100644 --- a/examples/chain/exchange/10_MsgCreateDerivativeLimitOrder/example.go +++ b/examples/chain/exchange/10_MsgCreateDerivativeLimitOrder/example.go @@ -113,7 +113,7 @@ func main() { fmt.Println("simulated order hash", msgCreateDerivativeLimitOrderResponse.OrderHash) - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/exchange/11_MsgCreateDerivativeMarketOrder/example.go b/examples/chain/exchange/11_MsgCreateDerivativeMarketOrder/example.go index 26806c33..9e1a8d78 100644 --- a/examples/chain/exchange/11_MsgCreateDerivativeMarketOrder/example.go +++ b/examples/chain/exchange/11_MsgCreateDerivativeMarketOrder/example.go @@ -114,7 +114,7 @@ func main() { fmt.Println("simulated order hash", msgCreateDerivativeMarketOrderResponse.OrderHash) - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/exchange/12_MsgCancelDerivativeOrder/example.go b/examples/chain/exchange/12_MsgCancelDerivativeOrder/example.go index dd5972d2..2fb04e91 100644 --- a/examples/chain/exchange/12_MsgCancelDerivativeOrder/example.go +++ b/examples/chain/exchange/12_MsgCancelDerivativeOrder/example.go @@ -64,7 +64,7 @@ func main() { OrderHash: "0x8cf97e586c0d84cd7864ccc8916b886557120d84fc97a21ae193b67882835ec5", } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/exchange/13_MsgInstantBinaryOptionsMarketLaunch/example.go b/examples/chain/exchange/13_MsgInstantBinaryOptionsMarketLaunch/example.go index be7b7ddc..475aed44 100644 --- a/examples/chain/exchange/13_MsgInstantBinaryOptionsMarketLaunch/example.go +++ b/examples/chain/exchange/13_MsgInstantBinaryOptionsMarketLaunch/example.go @@ -95,7 +95,7 @@ func main() { MinQuantityTickSize: chainMinQuantityTickSize, } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg response, err := chainClient.AsyncBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/exchange/14_MsgSubaccountTransfer/example.go b/examples/chain/exchange/14_MsgSubaccountTransfer/example.go index d7580995..2bae28c4 100644 --- a/examples/chain/exchange/14_MsgSubaccountTransfer/example.go +++ b/examples/chain/exchange/14_MsgSubaccountTransfer/example.go @@ -66,7 +66,7 @@ func main() { }, } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/exchange/15_MsgExternalTransfer/example.go b/examples/chain/exchange/15_MsgExternalTransfer/example.go index 4a25192f..3481f248 100644 --- a/examples/chain/exchange/15_MsgExternalTransfer/example.go +++ b/examples/chain/exchange/15_MsgExternalTransfer/example.go @@ -66,7 +66,7 @@ func main() { }, } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/exchange/16_MsgLiquidatePosition/example.go b/examples/chain/exchange/16_MsgLiquidatePosition/example.go index 8a328d94..4a00f6a8 100644 --- a/examples/chain/exchange/16_MsgLiquidatePosition/example.go +++ b/examples/chain/exchange/16_MsgLiquidatePosition/example.go @@ -100,7 +100,7 @@ func main() { Order: order, } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg response, err := chainClient.AsyncBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/exchange/17_MsgIncreasePositionMargin/example.go b/examples/chain/exchange/17_MsgIncreasePositionMargin/example.go index 578d9243..f27c5904 100644 --- a/examples/chain/exchange/17_MsgIncreasePositionMargin/example.go +++ b/examples/chain/exchange/17_MsgIncreasePositionMargin/example.go @@ -66,7 +66,7 @@ func main() { Amount: cosmtypes.MustNewDecFromStr("100000000"), //100 USDT } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/exchange/1_MsgDeposit/example.go b/examples/chain/exchange/1_MsgDeposit/example.go index abf339a4..33c274ce 100644 --- a/examples/chain/exchange/1_MsgDeposit/example.go +++ b/examples/chain/exchange/1_MsgDeposit/example.go @@ -65,7 +65,7 @@ func main() { }, } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/exchange/21_MsgRewardsOptOut/example.go b/examples/chain/exchange/21_MsgRewardsOptOut/example.go index ca877e9e..a21f352b 100644 --- a/examples/chain/exchange/21_MsgRewardsOptOut/example.go +++ b/examples/chain/exchange/21_MsgRewardsOptOut/example.go @@ -60,7 +60,7 @@ func main() { Sender: senderAddress.String(), } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/exchange/2_MsgWithdraw/example.go b/examples/chain/exchange/2_MsgWithdraw/example.go index 8c49c6e5..522fbacf 100644 --- a/examples/chain/exchange/2_MsgWithdraw/example.go +++ b/examples/chain/exchange/2_MsgWithdraw/example.go @@ -65,7 +65,7 @@ func main() { }, } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/exchange/3_MsgInstantSpotMarketLaunch/example.go b/examples/chain/exchange/3_MsgInstantSpotMarketLaunch/example.go index 2bd6e62a..1b34f23f 100644 --- a/examples/chain/exchange/3_MsgInstantSpotMarketLaunch/example.go +++ b/examples/chain/exchange/3_MsgInstantSpotMarketLaunch/example.go @@ -89,7 +89,7 @@ func main() { MinQuantityTickSize: chainMinQuantityTickSize, } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg response, err := chainClient.AsyncBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/exchange/4_MsgInstantPerpetualMarketLaunch/example.go b/examples/chain/exchange/4_MsgInstantPerpetualMarketLaunch/example.go index 0792a6d2..890c2286 100644 --- a/examples/chain/exchange/4_MsgInstantPerpetualMarketLaunch/example.go +++ b/examples/chain/exchange/4_MsgInstantPerpetualMarketLaunch/example.go @@ -94,7 +94,7 @@ func main() { MinQuantityTickSize: chainMinQuantityTickSize, } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg response, err := chainClient.AsyncBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/exchange/5_MsgInstantExpiryFuturesMarketLaunch/example.go b/examples/chain/exchange/5_MsgInstantExpiryFuturesMarketLaunch/example.go index dac6f76f..e1cba9c9 100644 --- a/examples/chain/exchange/5_MsgInstantExpiryFuturesMarketLaunch/example.go +++ b/examples/chain/exchange/5_MsgInstantExpiryFuturesMarketLaunch/example.go @@ -95,7 +95,7 @@ func main() { MinQuantityTickSize: chainMinQuantityTickSize, } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg response, err := chainClient.AsyncBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/exchange/6_MsgCreateSpotLimitOrder/example.go b/examples/chain/exchange/6_MsgCreateSpotLimitOrder/example.go index 976f8881..3707d502 100644 --- a/examples/chain/exchange/6_MsgCreateSpotLimitOrder/example.go +++ b/examples/chain/exchange/6_MsgCreateSpotLimitOrder/example.go @@ -112,7 +112,7 @@ func main() { fmt.Println("simulated order hash: ", msgCreateSpotLimitOrderResponse.OrderHash) - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/exchange/7_MsgCreateSpotMarketOrder/example.go b/examples/chain/exchange/7_MsgCreateSpotMarketOrder/example.go index 6fd3595f..392fbd08 100644 --- a/examples/chain/exchange/7_MsgCreateSpotMarketOrder/example.go +++ b/examples/chain/exchange/7_MsgCreateSpotMarketOrder/example.go @@ -111,7 +111,7 @@ func main() { fmt.Println("simulated order hash", msgCreateSpotMarketOrderResponse.OrderHash) - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/exchange/8_MsgCancelSpotOrder/example.go b/examples/chain/exchange/8_MsgCancelSpotOrder/example.go index f42ec5cc..adc9d9a8 100644 --- a/examples/chain/exchange/8_MsgCancelSpotOrder/example.go +++ b/examples/chain/exchange/8_MsgCancelSpotOrder/example.go @@ -64,7 +64,7 @@ func main() { OrderHash: "0xc1dd07efb7cf3a90c3d09da958fa22d96a5787eba3dbec56b63902c482accbd4", } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/exchange/9_MsgBatchUpdateOrders/example.go b/examples/chain/exchange/9_MsgBatchUpdateOrders/example.go index a1aff89d..a292074d 100644 --- a/examples/chain/exchange/9_MsgBatchUpdateOrders/example.go +++ b/examples/chain/exchange/9_MsgBatchUpdateOrders/example.go @@ -137,7 +137,7 @@ func main() { fmt.Println("simulated derivative order hashes", MsgBatchUpdateOrdersResponse.DerivativeOrderHashes) - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/ibc/transfer/1_MsgTransfer/example.go b/examples/chain/ibc/transfer/1_MsgTransfer/example.go index c08689e4..587b0c91 100644 --- a/examples/chain/ibc/transfer/1_MsgTransfer/example.go +++ b/examples/chain/ibc/transfer/1_MsgTransfer/example.go @@ -75,7 +75,7 @@ func main() { TimeoutHeight: timeoutHeight, } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg response, err := chainClient.AsyncBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/oracle/1_MsgRelayPriceFeedPrice/example.go b/examples/chain/oracle/1_MsgRelayPriceFeedPrice/example.go index 9718d252..f7988a87 100644 --- a/examples/chain/oracle/1_MsgRelayPriceFeedPrice/example.go +++ b/examples/chain/oracle/1_MsgRelayPriceFeedPrice/example.go @@ -68,7 +68,7 @@ func main() { Quote: quote, } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/peggy/1_MsgSendToEth/example.go b/examples/chain/peggy/1_MsgSendToEth/example.go index 89623c6b..bee6838b 100644 --- a/examples/chain/peggy/1_MsgSendToEth/example.go +++ b/examples/chain/peggy/1_MsgSendToEth/example.go @@ -73,7 +73,7 @@ func main() { BridgeFee: bridgeFee, } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/staking/1_MsgDelegate/example.go b/examples/chain/staking/1_MsgDelegate/example.go index 756a26dd..0ba43c66 100644 --- a/examples/chain/staking/1_MsgDelegate/example.go +++ b/examples/chain/staking/1_MsgDelegate/example.go @@ -64,7 +64,7 @@ func main() { Denom: "inj", Amount: sdktypes.NewInt(1000000000000000000), // 1 INJ } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { diff --git a/examples/chain/tokenfactory/1_CreateDenom/example.go b/examples/chain/tokenfactory/1_CreateDenom/example.go index 0ced42bf..6839dca9 100644 --- a/examples/chain/tokenfactory/1_CreateDenom/example.go +++ b/examples/chain/tokenfactory/1_CreateDenom/example.go @@ -60,7 +60,7 @@ func main() { message.Name = "Injective Test Token" message.Symbol = "INJTEST" - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg response, err := chainClient.AsyncBroadcastMsg(message) if err != nil { diff --git a/examples/chain/tokenfactory/2_MsgMint/example.go b/examples/chain/tokenfactory/2_MsgMint/example.go index 26a43830..c651e18f 100644 --- a/examples/chain/tokenfactory/2_MsgMint/example.go +++ b/examples/chain/tokenfactory/2_MsgMint/example.go @@ -62,7 +62,7 @@ func main() { Amount: sdktypes.NewInt(1000000000), } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg response, err := chainClient.AsyncBroadcastMsg(message) if err != nil { diff --git a/examples/chain/tokenfactory/3_MsgBurn/example.go b/examples/chain/tokenfactory/3_MsgBurn/example.go index 35c6cc64..a342a851 100644 --- a/examples/chain/tokenfactory/3_MsgBurn/example.go +++ b/examples/chain/tokenfactory/3_MsgBurn/example.go @@ -62,7 +62,7 @@ func main() { Amount: sdktypes.NewInt(100), } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg response, err := chainClient.AsyncBroadcastMsg(message) if err != nil { diff --git a/examples/chain/tokenfactory/4_MsgSetDenomMetadata/example.go b/examples/chain/tokenfactory/4_MsgSetDenomMetadata/example.go index d5787500..2957f952 100644 --- a/examples/chain/tokenfactory/4_MsgSetDenomMetadata/example.go +++ b/examples/chain/tokenfactory/4_MsgSetDenomMetadata/example.go @@ -85,7 +85,7 @@ func main() { message.Sender = senderAddress.String() message.Metadata = metadata - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg response, err := chainClient.AsyncBroadcastMsg(message) if err != nil { diff --git a/examples/chain/tokenfactory/5_MsgChangeAdmin/example.go b/examples/chain/tokenfactory/5_MsgChangeAdmin/example.go index a9371ebb..09f4c57b 100644 --- a/examples/chain/tokenfactory/5_MsgChangeAdmin/example.go +++ b/examples/chain/tokenfactory/5_MsgChangeAdmin/example.go @@ -60,7 +60,7 @@ func main() { // This is the zero address to remove admin permissions message.NewAdmin = "inj1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqe2hm49" - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg response, err := chainClient.AsyncBroadcastMsg(message) if err != nil { diff --git a/examples/chain/wasmx/1_MsgExecuteContractCompat/example.go b/examples/chain/wasmx/1_MsgExecuteContractCompat/example.go index dc405028..bea54441 100644 --- a/examples/chain/wasmx/1_MsgExecuteContractCompat/example.go +++ b/examples/chain/wasmx/1_MsgExecuteContractCompat/example.go @@ -77,7 +77,7 @@ func main() { Funds: funds, } - //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg response, err := chainClient.AsyncBroadcastMsg(&message) if err != nil { diff --git a/examples/exchange/accounts/1_StreamSubaccountBalance/example.go b/examples/exchange/accounts/1_StreamSubaccountBalance/example.go index 49f3222d..c14b5022 100644 --- a/examples/exchange/accounts/1_StreamSubaccountBalance/example.go +++ b/examples/exchange/accounts/1_StreamSubaccountBalance/example.go @@ -10,7 +10,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/examples/exchange/derivatives/13_StreamTrades/example.go b/examples/exchange/derivatives/13_StreamTrades/example.go index 02239ad5..139a6872 100644 --- a/examples/exchange/derivatives/13_StreamTrades/example.go +++ b/examples/exchange/derivatives/13_StreamTrades/example.go @@ -11,7 +11,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/examples/exchange/derivatives/14_SubaccountOrdersList/example.go b/examples/exchange/derivatives/14_SubaccountOrdersList/example.go index 0177193e..f7fefbda 100644 --- a/examples/exchange/derivatives/14_SubaccountOrdersList/example.go +++ b/examples/exchange/derivatives/14_SubaccountOrdersList/example.go @@ -11,7 +11,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/examples/exchange/derivatives/15_SubaccountTradesList/example.go b/examples/exchange/derivatives/15_SubaccountTradesList/example.go index 2bf30a1e..4117ce62 100644 --- a/examples/exchange/derivatives/15_SubaccountTradesList/example.go +++ b/examples/exchange/derivatives/15_SubaccountTradesList/example.go @@ -11,7 +11,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/examples/exchange/derivatives/16_FundingPayments/example.go b/examples/exchange/derivatives/16_FundingPayments/example.go index 8aa286c9..87dcaf2c 100644 --- a/examples/exchange/derivatives/16_FundingPayments/example.go +++ b/examples/exchange/derivatives/16_FundingPayments/example.go @@ -11,7 +11,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/examples/exchange/derivatives/17_FundingRates/example.go b/examples/exchange/derivatives/17_FundingRates/example.go index 0512f91a..5271b7bf 100644 --- a/examples/exchange/derivatives/17_FundingRates/example.go +++ b/examples/exchange/derivatives/17_FundingRates/example.go @@ -11,7 +11,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/examples/exchange/derivatives/1_Market/example.go b/examples/exchange/derivatives/1_Market/example.go index 8576e113..61a1c7f6 100644 --- a/examples/exchange/derivatives/1_Market/example.go +++ b/examples/exchange/derivatives/1_Market/example.go @@ -10,7 +10,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/examples/exchange/derivatives/2_Markets/example.go b/examples/exchange/derivatives/2_Markets/example.go index 97618d7a..cf18c133 100644 --- a/examples/exchange/derivatives/2_Markets/example.go +++ b/examples/exchange/derivatives/2_Markets/example.go @@ -11,7 +11,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("mainnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/examples/exchange/derivatives/3_StreamMarket/example.go b/examples/exchange/derivatives/3_StreamMarket/example.go index 2de5f205..ac5bd943 100644 --- a/examples/exchange/derivatives/3_StreamMarket/example.go +++ b/examples/exchange/derivatives/3_StreamMarket/example.go @@ -10,7 +10,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/examples/exchange/derivatives/4_Orderbook/example.go b/examples/exchange/derivatives/4_Orderbook/example.go index 87ffff36..d14c0501 100644 --- a/examples/exchange/derivatives/4_Orderbook/example.go +++ b/examples/exchange/derivatives/4_Orderbook/example.go @@ -10,7 +10,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/examples/exchange/derivatives/5_Orderbooks/example.go b/examples/exchange/derivatives/5_Orderbooks/example.go index 29681c50..fdca6060 100644 --- a/examples/exchange/derivatives/5_Orderbooks/example.go +++ b/examples/exchange/derivatives/5_Orderbooks/example.go @@ -10,7 +10,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/examples/exchange/derivatives/8_Positions/example.go b/examples/exchange/derivatives/8_Positions/example.go index 3b11e289..d081759e 100644 --- a/examples/exchange/derivatives/8_Positions/example.go +++ b/examples/exchange/derivatives/8_Positions/example.go @@ -11,7 +11,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/examples/exchange/derivatives/9_Orders/example.go b/examples/exchange/derivatives/9_Orders/example.go index 824ebd28..5aa8b22c 100644 --- a/examples/exchange/derivatives/9_Orders/example.go +++ b/examples/exchange/derivatives/9_Orders/example.go @@ -11,7 +11,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/examples/exchange/insurance/1_InsuranceFunds/example.go b/examples/exchange/insurance/1_InsuranceFunds/example.go index 63abd806..8cb4adaf 100644 --- a/examples/exchange/insurance/1_InsuranceFunds/example.go +++ b/examples/exchange/insurance/1_InsuranceFunds/example.go @@ -11,7 +11,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/examples/exchange/insurance/2_Redemptions/example.go b/examples/exchange/insurance/2_Redemptions/example.go index e109cc7d..17166b4b 100644 --- a/examples/exchange/insurance/2_Redemptions/example.go +++ b/examples/exchange/insurance/2_Redemptions/example.go @@ -11,7 +11,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/examples/exchange/meta/1_Ping/example.go b/examples/exchange/meta/1_Ping/example.go index 15172af0..f814e871 100644 --- a/examples/exchange/meta/1_Ping/example.go +++ b/examples/exchange/meta/1_Ping/example.go @@ -11,7 +11,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/examples/exchange/meta/2_Version/example.go b/examples/exchange/meta/2_Version/example.go index f9f9ef15..3428627d 100644 --- a/examples/exchange/meta/2_Version/example.go +++ b/examples/exchange/meta/2_Version/example.go @@ -11,7 +11,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/examples/exchange/meta/3_Info/example.go b/examples/exchange/meta/3_Info/example.go index 571c3b6c..6d1bceae 100644 --- a/examples/exchange/meta/3_Info/example.go +++ b/examples/exchange/meta/3_Info/example.go @@ -11,7 +11,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/examples/exchange/meta/4_StreamKeepAlive/example.go b/examples/exchange/meta/4_StreamKeepAlive/example.go index c76a8605..bd007577 100644 --- a/examples/exchange/meta/4_StreamKeepAlive/example.go +++ b/examples/exchange/meta/4_StreamKeepAlive/example.go @@ -10,7 +10,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/examples/exchange/spot/10_StreamTrades/example.go b/examples/exchange/spot/10_StreamTrades/example.go index 48d160c1..6406cc99 100644 --- a/examples/exchange/spot/10_StreamTrades/example.go +++ b/examples/exchange/spot/10_StreamTrades/example.go @@ -11,7 +11,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/examples/exchange/spot/11_SubaccountOrdersList/example.go b/examples/exchange/spot/11_SubaccountOrdersList/example.go index 6bb6d48b..e2321f8d 100644 --- a/examples/exchange/spot/11_SubaccountOrdersList/example.go +++ b/examples/exchange/spot/11_SubaccountOrdersList/example.go @@ -11,7 +11,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/examples/exchange/spot/12_SubaccountTradesList/example.go b/examples/exchange/spot/12_SubaccountTradesList/example.go index 401e981d..1830dc20 100644 --- a/examples/exchange/spot/12_SubaccountTradesList/example.go +++ b/examples/exchange/spot/12_SubaccountTradesList/example.go @@ -11,7 +11,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/examples/exchange/spot/13_Orderbooks/example.go b/examples/exchange/spot/13_Orderbooks/example.go index ebab285a..f6a865ed 100644 --- a/examples/exchange/spot/13_Orderbooks/example.go +++ b/examples/exchange/spot/13_Orderbooks/example.go @@ -10,7 +10,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/examples/exchange/spot/1_Market/example.go b/examples/exchange/spot/1_Market/example.go index 813c75c8..4c980328 100644 --- a/examples/exchange/spot/1_Market/example.go +++ b/examples/exchange/spot/1_Market/example.go @@ -10,7 +10,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/examples/exchange/spot/2_Markets/example.go b/examples/exchange/spot/2_Markets/example.go index e11b3b6d..4c5488c1 100644 --- a/examples/exchange/spot/2_Markets/example.go +++ b/examples/exchange/spot/2_Markets/example.go @@ -11,7 +11,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/examples/exchange/spot/3_StreamMarket/example.go b/examples/exchange/spot/3_StreamMarket/example.go index e7af4810..d1beea22 100644 --- a/examples/exchange/spot/3_StreamMarket/example.go +++ b/examples/exchange/spot/3_StreamMarket/example.go @@ -10,7 +10,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/examples/exchange/spot/4_Orderbook/example.go b/examples/exchange/spot/4_Orderbook/example.go index 2c158cbc..9e964ca4 100644 --- a/examples/exchange/spot/4_Orderbook/example.go +++ b/examples/exchange/spot/4_Orderbook/example.go @@ -10,7 +10,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/examples/exchange/spot/5_Orders/example.go b/examples/exchange/spot/5_Orders/example.go index 4fe513c8..850525ed 100644 --- a/examples/exchange/spot/5_Orders/example.go +++ b/examples/exchange/spot/5_Orders/example.go @@ -11,7 +11,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("mainnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/examples/exchange/spot/9_StreamOrders/example.go b/examples/exchange/spot/9_StreamOrders/example.go index cb4cfffb..98c22487 100644 --- a/examples/exchange/spot/9_StreamOrders/example.go +++ b/examples/exchange/spot/9_StreamOrders/example.go @@ -11,7 +11,7 @@ import ( ) func main() { - //network := common.LoadNetwork("mainnet", "k8s") + // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "lb") exchangeClient, err := exchangeclient.NewExchangeClient(network) if err != nil { diff --git a/go.mod b/go.mod index d5171206..bff702f3 100644 --- a/go.mod +++ b/go.mod @@ -184,9 +184,9 @@ require ( golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 // indirect golang.org/x/net v0.24.0 // indirect golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.19.0 // indirect - golang.org/x/term v0.19.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/sys v0.20.0 // indirect + golang.org/x/term v0.20.0 // indirect + golang.org/x/text v0.15.0 // indirect google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect diff --git a/go.sum b/go.sum index 7b202ed5..40c5e343 100644 --- a/go.sum +++ b/go.sum @@ -1062,13 +1062,13 @@ golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= -golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= +golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= -golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= +golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw= +golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -1076,8 +1076,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= +golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= diff --git a/typeddata/typed_data.go b/typeddata/typed_data.go index e23efe82..f52cefd1 100644 --- a/typeddata/typed_data.go +++ b/typeddata/typed_data.go @@ -105,7 +105,7 @@ var typedDataReferenceTypeRegexp = regexp.MustCompile(`^[A-Z](\w*)(\[\])?$`) // SignTextWithValidator signs the given message which can be further recovered // with the given validator. // hash = keccak256("\x19\x00"${address}${data}). -func SignTextValidator(validatorData ValidatorData) (hexutil.Bytes, string) { +func SignTextValidator(validatorData ValidatorData) (signature hexutil.Bytes, message string) { msg := fmt.Sprintf("\x19\x00%s%s", string(validatorData.Address.Bytes()), string(validatorData.Message)) return crypto.Keccak256([]byte(msg)), msg }