Skip to content

Commit

Permalink
Merge pull request #686 from enigmampc/v1.0.4
Browse files Browse the repository at this point in the history
Fix ordering of contract initialization vs message dispatching
  • Loading branch information
assafmo authored Dec 16, 2020
2 parents 3aa3d1f + 789295f commit 786d3c4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions x/compute/internal/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,6 @@ func (k Keeper) Instantiate(ctx sdk.Context, codeID uint64, creator /* , admin *
events := types.ParseEvents(res.Log, contractAddress)
ctx.EventManager().EmitEvents(events)

err = k.dispatchMessages(ctx, contractAddress, res.Messages)
if err != nil {
return nil, err
}

// persist instance
createdAt := types.NewAbsoluteTxPosition(ctx)
instance := types.NewContractInfo(codeID, creator /* admin, */, label, createdAt)
Expand All @@ -358,6 +353,11 @@ func (k Keeper) Instantiate(ctx sdk.Context, codeID uint64, creator /* , admin *

store.Set(types.GetContractLabelPrefix(label), contractAddress)

err = k.dispatchMessages(ctx, contractAddress, res.Messages)
if err != nil {
return nil, err
}

// k.appendToContractHistory(ctx, contractAddress, instance.InitialHistory(initMsg))
return contractAddress, nil
}
Expand Down

0 comments on commit 786d3c4

Please sign in to comment.