Skip to content
Snippets Groups Projects
Unverified Commit 9ce5b1b3 authored by Silas Davis's avatar Silas Davis
Browse files

change hasBase to bool return as intended and add check for native contracts...

change hasBase to bool return as intended and add check for native contracts to simulated call (for query-contract)
parent 7454c0a3
No related branches found
No related tags found
No related merge requests found
...@@ -24,8 +24,8 @@ import ( ...@@ -24,8 +24,8 @@ import (
var registeredNativeContracts = make(map[Word256]NativeContract) var registeredNativeContracts = make(map[Word256]NativeContract)
func RegisteredNativeContract(addr Word256) bool { func RegisteredNativeContract(address Word256) bool {
_, ok := registeredNativeContracts[addr] _, ok := registeredNativeContracts[address]
return ok return ok
} }
......
...@@ -165,7 +165,7 @@ func SNativeContracts() map[string]*SNativeContractDescription { ...@@ -165,7 +165,7 @@ func SNativeContracts() map[string]*SNativeContractDescription {
[]abi.Arg{ []abi.Arg{
arg("_account", abi.AddressTypeName), arg("_account", abi.AddressTypeName),
arg("_permission", permFlagTypeName)}, arg("_permission", permFlagTypeName)},
ret("result", permFlagTypeName), ret("result", abi.BoolTypeName),
ptypes.HasBase, ptypes.HasBase,
hasBase}, hasBase},
......
...@@ -409,6 +409,11 @@ func (pipe *burrowMintPipe) DumpStorage(address []byte) (*rpc_tm_types.ResultDum ...@@ -409,6 +409,11 @@ func (pipe *burrowMintPipe) DumpStorage(address []byte) (*rpc_tm_types.ResultDum
// TODO: [ben] resolve incompatibilities in byte representation for 0.12.0 release // TODO: [ben] resolve incompatibilities in byte representation for 0.12.0 release
func (pipe *burrowMintPipe) Call(fromAddress, toAddress, data []byte) (*rpc_tm_types.ResultCall, func (pipe *burrowMintPipe) Call(fromAddress, toAddress, data []byte) (*rpc_tm_types.ResultCall,
error) { error) {
if vm.RegisteredNativeContract(word256.LeftPadWord256(toAddress)) {
return nil, fmt.Errorf("Attempt to call native contract at address "+
"%X, but native contracts can not be called directly. Use a deployed "+
"contract that calls the native function instead.", toAddress)
}
st := pipe.burrowMint.GetState() st := pipe.burrowMint.GetState()
cache := state.NewBlockCache(st) cache := state.NewBlockCache(st)
outAcc := cache.GetAccount(toAddress) outAcc := cache.GetAccount(toAddress)
......
...@@ -431,7 +431,10 @@ func ExecTx(blockCache *BlockCache, tx txs.Tx, runCall bool, evc events.Fireable ...@@ -431,7 +431,10 @@ func ExecTx(blockCache *BlockCache, tx txs.Tx, runCall bool, evc events.Fireable
} }
// check if its a native contract // check if its a native contract
if vm.RegisteredNativeContract(LeftPadWord256(tx.Address)) { if vm.RegisteredNativeContract(LeftPadWord256(tx.Address)) {
return fmt.Errorf("NativeContracts can not be called using CallTx. Use a contract or the appropriate tx type (eg. PermissionsTx, NameTx)") return fmt.Errorf("Attempt to call a native contract at %X, "+
"but native contracts cannot be called using CallTx. Use a "+
"contract that calls the native contract or the appropriate tx "+
"type (eg. PermissionsTx, NameTx).", tx.Address)
} }
// Output account may be nil if we are still in mempool and contract was created in same block as this tx // Output account may be nil if we are still in mempool and contract was created in same block as this tx
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment