Skip to content

Commit

Permalink
fix(bidengine): decode script result directly into decint
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <troian.ap@gmail.com>
  • Loading branch information
troian committed Aug 14, 2023
1 parent 285a363 commit 2a9035a
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions bidengine/shellscript.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,11 @@ func (ssp shellScriptPricing) CalculatePrice(ctx context.Context, req Request) (
decoder := json.NewDecoder(outputBuf)
decoder.UseNumber()

var priceNumber json.Number
err = decoder.Decode(&priceNumber)
if err != nil {
return sdk.DecCoin{}, fmt.Errorf("%w: script failure %s", err, stderrBuf.String())
}
valueStr := strings.TrimSpace(outputBuf.String())

price, err := sdk.NewDecFromStr(priceNumber.String())
price, err := sdk.NewDecFromStr(valueStr)
if err != nil {
return sdk.DecCoin{}, ErrBidQuantityInvalid
return sdk.DecCoin{}, fmt.Errorf("%w: unable to decode price from %s", err, valueStr)
}

if price.IsZero() {
Expand Down

0 comments on commit 2a9035a

Please sign in to comment.