Add nil checks
This commit is contained in:
@@ -323,6 +323,10 @@ func (k Keeper) instantiate(
|
||||
if err != nil {
|
||||
return nil, nil, errorsmod.Wrap(types.ErrVMError, err.Error())
|
||||
}
|
||||
if res == nil {
|
||||
// If this gets executed, that's a bug in wasmvm
|
||||
return nil, nil, errorsmod.Wrap(types.ErrVMError, "internal wasmvm error")
|
||||
}
|
||||
if res.Err != "" {
|
||||
return nil, nil, types.MarkErrorDeterministic(errorsmod.Wrap(types.ErrInstantiateFailed, res.Err))
|
||||
}
|
||||
@@ -407,6 +411,10 @@ func (k Keeper) execute(ctx context.Context, contractAddress, caller sdk.AccAddr
|
||||
if execErr != nil {
|
||||
return nil, errorsmod.Wrap(types.ErrVMError, execErr.Error())
|
||||
}
|
||||
if res == nil {
|
||||
// If this gets executed, that's a bug in wasmvm
|
||||
return nil, errorsmod.Wrap(types.ErrVMError, "internal wasmvm error")
|
||||
}
|
||||
if res.Err != "" {
|
||||
return nil, types.MarkErrorDeterministic(errorsmod.Wrap(types.ErrExecuteFailed, res.Err))
|
||||
}
|
||||
@@ -484,6 +492,10 @@ func (k Keeper) migrate(
|
||||
if err != nil {
|
||||
return nil, errorsmod.Wrap(types.ErrVMError, err.Error())
|
||||
}
|
||||
if res == nil {
|
||||
// If this gets executed, that's a bug in wasmvm
|
||||
return nil, errorsmod.Wrap(types.ErrVMError, "internal wasmvm error")
|
||||
}
|
||||
if res.Err != "" {
|
||||
return nil, types.MarkErrorDeterministic(errorsmod.Wrap(types.ErrMigrationFailed, res.Err))
|
||||
}
|
||||
@@ -549,6 +561,10 @@ func (k Keeper) Sudo(ctx context.Context, contractAddress sdk.AccAddress, msg []
|
||||
if execErr != nil {
|
||||
return nil, errorsmod.Wrap(types.ErrVMError, execErr.Error())
|
||||
}
|
||||
if res == nil {
|
||||
// If this gets executed, that's a bug in wasmvm
|
||||
return nil, errorsmod.Wrap(types.ErrVMError, "internal wasmvm error")
|
||||
}
|
||||
if res.Err != "" {
|
||||
return nil, types.MarkErrorDeterministic(errorsmod.Wrap(types.ErrExecuteFailed, res.Err))
|
||||
}
|
||||
@@ -589,6 +605,10 @@ func (k Keeper) reply(ctx sdk.Context, contractAddress sdk.AccAddress, reply was
|
||||
if execErr != nil {
|
||||
return nil, errorsmod.Wrap(types.ErrVMError, execErr.Error())
|
||||
}
|
||||
if res == nil {
|
||||
// If this gets executed, that's a bug in wasmvm
|
||||
return nil, errorsmod.Wrap(types.ErrVMError, "internal wasmvm error")
|
||||
}
|
||||
if res.Err != "" {
|
||||
return nil, types.MarkErrorDeterministic(errorsmod.Wrap(types.ErrExecuteFailed, res.Err))
|
||||
}
|
||||
|
||||
@@ -75,6 +75,10 @@ func (k Keeper) OnConnectChannel(
|
||||
if execErr != nil {
|
||||
return errorsmod.Wrap(types.ErrExecuteFailed, execErr.Error())
|
||||
}
|
||||
if res == nil {
|
||||
// If this gets executed, that's a bug in wasmvm
|
||||
return errorsmod.Wrap(types.ErrVMError, "internal wasmvm error")
|
||||
}
|
||||
if res.Err != "" {
|
||||
return types.MarkErrorDeterministic(errorsmod.Wrap(types.ErrExecuteFailed, res.Err))
|
||||
}
|
||||
@@ -109,6 +113,10 @@ func (k Keeper) OnCloseChannel(
|
||||
if execErr != nil {
|
||||
return errorsmod.Wrap(types.ErrExecuteFailed, execErr.Error())
|
||||
}
|
||||
if res == nil {
|
||||
// If this gets executed, that's a bug in wasmvm
|
||||
return errorsmod.Wrap(types.ErrVMError, "internal wasmvm error")
|
||||
}
|
||||
if res.Err != "" {
|
||||
return types.MarkErrorDeterministic(errorsmod.Wrap(types.ErrExecuteFailed, res.Err))
|
||||
}
|
||||
@@ -145,6 +153,10 @@ func (k Keeper) OnRecvPacket(
|
||||
// all state downstream and not persist any data in ibc-go.
|
||||
// This can be triggered by throwing a panic in the contract
|
||||
}
|
||||
if res == nil {
|
||||
// If this gets executed, that's a bug in wasmvm
|
||||
return nil, errorsmod.Wrap(types.ErrVMError, "internal wasmvm error")
|
||||
}
|
||||
if res.Err != "" {
|
||||
// return error ACK with non-redacted contract message, state will be reverted
|
||||
return channeltypes.Acknowledgement{
|
||||
@@ -200,6 +212,10 @@ func (k Keeper) OnAckPacket(
|
||||
if execErr != nil {
|
||||
return errorsmod.Wrap(types.ErrExecuteFailed, execErr.Error())
|
||||
}
|
||||
if res == nil {
|
||||
// If this gets executed, that's a bug in wasmvm
|
||||
return errorsmod.Wrap(types.ErrVMError, "internal wasmvm error")
|
||||
}
|
||||
if res.Err != "" {
|
||||
return types.MarkErrorDeterministic(errorsmod.Wrap(types.ErrExecuteFailed, res.Err))
|
||||
}
|
||||
@@ -231,6 +247,10 @@ func (k Keeper) OnTimeoutPacket(
|
||||
if execErr != nil {
|
||||
return errorsmod.Wrap(types.ErrExecuteFailed, execErr.Error())
|
||||
}
|
||||
if res == nil {
|
||||
// If this gets executed, that's a bug in wasmvm
|
||||
return errorsmod.Wrap(types.ErrVMError, "internal wasmvm error")
|
||||
}
|
||||
if res.Err != "" {
|
||||
return types.MarkErrorDeterministic(errorsmod.Wrap(types.ErrExecuteFailed, res.Err))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user