Skip to content

Commit

Permalink
Merge pull request #228 from InjectiveLabs/fix-PrepareFactory-public
Browse files Browse the repository at this point in the history
fix: make PrepareFactory public so chilliass can re-use it
  • Loading branch information
kakysha authored Jul 15, 2024
2 parents d7aa99d + 50dedaa commit 58aee14
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
8 changes: 2 additions & 6 deletions chain/exchange/types/spot_orders.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -167,9 +165,7 @@ func (m *SpotOrder) GetBalanceHoldAndMarginDenom(market *SpotMarket) (math.Legac
return balanceHold, denom
}

func (m *SpotLimitOrder) GetUnfilledMarginHoldAndMarginDenom(market *SpotMarket, isTransient bool) (math.LegacyDec, string) {
var denom string
var balanceHold math.LegacyDec
func (m *SpotLimitOrder) GetUnfilledMarginHoldAndMarginDenom(market *SpotMarket, isTransient bool) (balanceHold math.LegacyDec, denom string) {
if m.IsBuy() {
var tradeFeeRate math.LegacyDec

Expand Down
3 changes: 2 additions & 1 deletion chain/wasmx/types/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func IsAllowed(accessConfig types.AccessConfig, actor types2.AccAddress) bool {
}
}
return false
default:
return false
}
return false
}
8 changes: 4 additions & 4 deletions client/chain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,11 +481,11 @@ func (c *chainClient) syncTimeoutHeight() {
}
}

// prepareFactory ensures the account defined by ctx.GetFromAddress() exists and
// PrepareFactory ensures the account defined by ctx.GetFromAddress() exists and
// if the account number and/or the account sequence number are zero (not set),
// they will be queried for and set on the provided Factory. A new Factory with
// the updated fields will be returned.
func (c *chainClient) prepareFactory(clientCtx client.Context, txf tx.Factory) (tx.Factory, error) {
func PrepareFactory(clientCtx client.Context, txf tx.Factory) (tx.Factory, error) {
from := clientCtx.GetFromAddress()

if err := txf.AccountRetriever().EnsureExists(clientCtx, from); err != nil {
Expand Down Expand Up @@ -703,7 +703,7 @@ func (c *chainClient) GetFeeDiscountInfo(ctx context.Context, account string) (*
func (c *chainClient) SimulateMsg(clientCtx client.Context, msgs ...sdk.Msg) (*txtypes.SimulateResponse, error) {
c.txFactory = c.txFactory.WithSequence(c.accSeq)
c.txFactory = c.txFactory.WithAccountNumber(c.accNum)
txf, err := c.prepareFactory(clientCtx, c.txFactory)
txf, err := PrepareFactory(clientCtx, c.txFactory)
if err != nil {
err = errors.Wrap(err, "failed to prepareFactory")
return nil, err
Expand Down Expand Up @@ -785,7 +785,7 @@ func (c *chainClient) buildSignedTx(clientCtx client.Context, txf tx.Factory, ms
c.gasWanted = adjustedGas
}

txf, err := c.prepareFactory(clientCtx, txf)
txf, err := PrepareFactory(clientCtx, txf)
if err != nil {
return nil, errors.Wrap(err, "failed to prepareFactory")
}
Expand Down

0 comments on commit 58aee14

Please sign in to comment.