Skip to content

Commit

Permalink
Merge pull request #181 from Pylons-tech/cel_type_conversion_unit_tes…
Browse files Browse the repository at this point in the history
…t_and_doc

fix execute recipe coinoutput result wrong data
  • Loading branch information
antstalepresh authored Mar 6, 2020
2 parents fbabcd7 + d87ebfa commit 384c6f8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions x/pylons/handlers/execute_recipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func AddExecutedResult(ctx sdk.Context, keeper keep.Keeper, output types.Weighte
switch output.(type) {
case types.CoinOutput:
coinOutput, _ := output.(types.CoinOutput)
var ocl sdk.Coins
var coinAmount int64
if len(coinOutput.Program) > 0 {
refVal, refErr := types.CheckAndExecuteProgram(env, variables, funcs, coinOutput.Program)
if refErr != nil {
Expand All @@ -99,18 +99,19 @@ func AddExecutedResult(ctx sdk.Context, keeper keep.Keeper, output types.Weighte
if !ok {
return ers, sdk.ErrInternal("returned result from program is not convertable to int")
}
ocl = append(ocl, sdk.NewCoin(coinOutput.Coin, sdk.NewInt(val64)))
coinAmount = val64
} else {
ocl = append(ocl, sdk.NewCoin(coinOutput.Coin, sdk.NewInt(coinOutput.Count)))
coinAmount = coinOutput.Count
}
ocl := sdk.Coins{sdk.NewCoin(coinOutput.Coin, sdk.NewInt(coinAmount))}

_, _, err := keeper.CoinKeeper.AddCoins(ctx, sender, ocl)
if err != nil {
return ers, err
}
ers.Type = "COIN"
ers.Coin = coinOutput.Coin
ers.Amount = coinOutput.Count
ers.Amount = coinAmount
return ers, nil
case types.ItemOutput:
itemOutput, _ := output.(types.ItemOutput)
Expand Down

0 comments on commit 384c6f8

Please sign in to comment.