Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions auth_vote/authz_vote.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
package main

import (
"context"
"encoding/json"
"fmt"
"os"
"time"

chainclient "github.com/InjectiveLabs/sdk-go/client/chain"
"github.com/InjectiveLabs/sdk-go/client/common"
rpchttp "github.com/cometbft/cometbft/rpc/client/http"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
authztypes "github.com/cosmos/cosmos-sdk/x/authz"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"

chainclient "github.com/InjectiveLabs/sdk-go/client/chain"
"github.com/InjectiveLabs/sdk-go/client/common"
)

//revive:disable:function-length // this is an example script
Expand Down Expand Up @@ -59,7 +62,10 @@ func main() {
panic(err)
}

gasPrice := chainClient.CurrentChainGasPrice()
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

gasPrice := chainClient.CurrentChainGasPrice(ctx)
// adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted
gasPrice = int64(float64(gasPrice) * 1.1)
chainClient.SetGasPrice(gasPrice)
Expand Down Expand Up @@ -93,7 +99,7 @@ func main() {
}

// AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg
response, err := chainClient.AsyncBroadcastMsg(msgs...)
response, err := chainClient.AsyncBroadcastMsg(ctx, msgs...)

if err != nil {
panic(err)
Expand All @@ -102,7 +108,7 @@ func main() {
str, _ := json.MarshalIndent(response, "", "\t")
fmt.Print(string(str))

gasPrice = chainClient.CurrentChainGasPrice()
gasPrice = chainClient.CurrentChainGasPrice(ctx)
// adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted
gasPrice = int64(float64(gasPrice) * 1.1)
chainClient.SetGasPrice(gasPrice)
Expand Down
2 changes: 1 addition & 1 deletion chain/exchange/types/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ func OrdersByMarketDirectionPriceOrderHashPrefix(marketID, orderHash common.Hash
return append(ordersByMarketDirectionPricePrefix(marketID, price, isLong), orderHash.Bytes()...)
}

// orderIndexByMarketDirectionSubaccountPrefix allows to obtain prefix of exchange against a particular marketID, direction and price
// ordersByMarketDirectionPricePrefix allows to obtain prefix of exchange against a particular marketID, direction and price
func ordersByMarketDirectionPricePrefix(marketID common.Hash, price *big.Int, isLong bool) []byte {
return append(MarketDirectionPrefix(marketID, isLong), common.LeftPadBytes(price.Bytes(), 32)...)
}
Expand Down
Loading