|
|
@ -117,6 +117,17 @@ func (vm *VM) Call(caller, callee *Account, code, input []byte, value int64, gas |
|
|
|
} |
|
|
|
}() |
|
|
|
|
|
|
|
// if code is empty, callee may be snative contract
|
|
|
|
if vm.snative && len(code) == 0 { |
|
|
|
if snativeContract := vm.SNativeContract(callee.Address); snativeContract != nil { |
|
|
|
output, err = snativeContract(caller, input) |
|
|
|
if err != nil { |
|
|
|
*exception = err.Error() |
|
|
|
} |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if err = transfer(caller, callee, value); err != nil { |
|
|
|
*exception = err.Error() |
|
|
|
return |
|
|
@ -746,9 +757,6 @@ func (vm *VM) call(caller, callee *Account, code, input []byte, value int64, gas |
|
|
|
if nativeContract := nativeContracts[addr]; nativeContract != nil { |
|
|
|
// Native contract
|
|
|
|
ret, err = nativeContract(args, &gasLimit) |
|
|
|
} else if snativeContract := vm.SNativeContract(addr); vm.snative && snativeContract != nil { |
|
|
|
// Secure native contract (with access to chain state)
|
|
|
|
ret, err = snativeContract(callee, args) |
|
|
|
} else { |
|
|
|
// EVM contract
|
|
|
|
if ok = useGas(gas, GasGetAccount); !ok { |
|
|
@ -766,13 +774,15 @@ func (vm *VM) call(caller, callee *Account, code, input []byte, value int64, gas |
|
|
|
ret, err = vm.Call(callee, callee, acc.Code, args, value, gas) |
|
|
|
} else { |
|
|
|
if acc == nil { |
|
|
|
// if we have not seen the account before, create it
|
|
|
|
// so we can send funds
|
|
|
|
if vm.perms && !vm.HasPermission(caller, ptypes.CreateAccount) { |
|
|
|
return nil, ErrPermission{"create_account"} |
|
|
|
} |
|
|
|
acc = &Account{ |
|
|
|
Address: addr, |
|
|
|
if _, ok := RegisteredSNativeContracts[addr]; vm.snative && ok { |
|
|
|
acc = &Account{Address: addr} |
|
|
|
} else { |
|
|
|
// if we have not seen the account before, create it
|
|
|
|
// so we can send funds
|
|
|
|
if vm.perms && !vm.HasPermission(caller, ptypes.CreateAccount) { |
|
|
|
return nil, ErrPermission{"create_account"} |
|
|
|
} |
|
|
|
acc = &Account{Address: addr} |
|
|
|
} |
|
|
|
vm.appState.UpdateAccount(acc) |
|
|
|
} |
|
|
|