From 4f25576d8558fda3bd331868a221087ca3f332b1 Mon Sep 17 00:00:00 2001 From: dingxin Date: Fri, 21 Jun 2019 11:43:14 +0800 Subject: [PATCH] support Account type --- ontology/contract/neo/abi/build_params.py | 3 +++ ontology/vm/params_builder.py | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ontology/contract/neo/abi/build_params.py b/ontology/contract/neo/abi/build_params.py index 6d91bb0..c2f3339 100644 --- a/ontology/contract/neo/abi/build_params.py +++ b/ontology/contract/neo/abi/build_params.py @@ -20,6 +20,7 @@ from ontology.utils import utils from ontology.common.address import Address +from ontology.account.account import Account from ontology.exception.error_code import ErrorCode from ontology.vm.params_builder import ParamsBuilder from ontology.exception.exception import SDKException @@ -108,6 +109,8 @@ def push_param(param, builder: ParamsBuilder): BuildParams.push_struct(param, builder) elif isinstance(param, Address): builder.emit_push_bytearray(param.to_bytes()) + elif isinstance(param, Account): + builder.emit_push_bytearray(param.get_address().to_bytes()) else: raise SDKException(ErrorCode.other_error('parameter type is error')) diff --git a/ontology/vm/params_builder.py b/ontology/vm/params_builder.py index c4696d1..82dce11 100644 --- a/ontology/vm/params_builder.py +++ b/ontology/vm/params_builder.py @@ -16,6 +16,8 @@ along with The ontology. If not, see . """ +from typing import Union + from ontology.io.memory_stream import MemoryStream from ontology.exception.error_code import ErrorCode from ontology.exception.exception import SDKException @@ -49,7 +51,7 @@ def emit_push_int(self, num: int): bs = self.big_int_to_neo_bytearray(num) return self.emit_push_bytearray(bs) - def emit_push_bytearray(self, data): + def emit_push_bytearray(self, data: Union[bytes, bytearray]): data_len = len(data) if data_len < int.from_bytes(PUSHBYTES75, 'little'): self.write_bytes(bytearray([data_len])) @@ -64,7 +66,7 @@ def emit_push_bytearray(self, data): self.write_bytes(len(data).to_bytes(4, "little")) self.write_bytes(data) - def emit_push_call(self, address): + def emit_push_call(self, address: bytes): self.emit(APPCALL) self.write_bytes(address)