Skip to content

Commit

Permalink
https://github.com/neo-project/neo/pull/2240
Browse files Browse the repository at this point in the history
  • Loading branch information
ixje committed Feb 15, 2021
1 parent 4693228 commit 023b986
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
12 changes: 4 additions & 8 deletions neo3/contracts/native/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,24 +170,20 @@ def contract_create_with_data(self,
)

nef = contracts.NEF.deserialize_from_bytes(nef_file)
parsed_manifest = contracts.ContractManifest.from_json(json.loads(manifest.decode()))
sb = vm.ScriptBuilder()
sb.emit(vm.OpCode.ABORT)
sb.emit_push(engine.script_container.sender.to_array())
sb.emit_push(nef.script)
sb.emit_push(nef.checksum)
sb.emit_push(parsed_manifest.name)
hash_ = to_script_hash(sb.to_array())

key = self.create_key(self._PREFIX_CONTRACT + hash_.to_array())
contract = engine.snapshot.storages.try_get(key)
if contract is not None:
raise ValueError("Contract already exists")

contract = storage.ContractState(
self.get_next_available_id(engine.snapshot),
nef,
contracts.ContractManifest.from_json(json.loads(manifest.decode())),
0,
hash_
)
contract = storage.ContractState(self.get_next_available_id(engine.snapshot), nef, parsed_manifest, 0, hash_)

if not contract.manifest.is_valid(hash_):
raise ValueError("Error: invalid manifest")
Expand Down
3 changes: 2 additions & 1 deletion neo3/contracts/native/nativecontract.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ def init(self):
sb = vm.ScriptBuilder()
sb.emit(vm.OpCode.ABORT)
sb.emit_push(sender.to_array())
sb.emit_push(self._script)
sb.emit_push(self.nef.checksum)
sb.emit_push(self.service_name())
self._hash: types.UInt160 = to_script_hash(sb.to_array())
self._manifest: contracts.ContractManifest = contracts.ContractManifest()
self._manifest.name = self.service_name()
Expand Down

0 comments on commit 023b986

Please sign in to comment.