Skip to content

Commit

Permalink
Merge pull request #364 from NashMiao/master
Browse files Browse the repository at this point in the history
support Account type
  • Loading branch information
NashMiao authored Jun 21, 2019
2 parents 24a68da + f47284c commit 41dee39
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions ontology/contract/neo/abi/build_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'))

Expand Down
6 changes: 4 additions & 2 deletions ontology/vm/params_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
along with The ontology. If not, see <http://www.gnu.org/licenses/>.
"""

from typing import Union

from ontology.io.memory_stream import MemoryStream
from ontology.exception.error_code import ErrorCode
from ontology.exception.exception import SDKException
Expand Down Expand Up @@ -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]))
Expand All @@ -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)

Expand Down

0 comments on commit 41dee39

Please sign in to comment.