Skip to content
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.

Commit

Permalink
added SC calls like GetExecutingScriptHash
Browse files Browse the repository at this point in the history
  • Loading branch information
localhuman committed Sep 28, 2017
1 parent cc2d127 commit 280f345
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 5 deletions.
15 changes: 11 additions & 4 deletions boa/blockchain/vm/System/ExecutionEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ class ExecutionEngine():
pass


#def GetScriptContainer():
# pass
def GetScriptContainer():
pass


def GetExecutingScriptHash():
pass


def GetCallingScriptHash():
pass

#def GetExecutingScriptHash():
# pass

def GetEntryScriptHash():
pass
34 changes: 34 additions & 0 deletions boa/code/builtins.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@





class list(list):

def __init__(self, length=0):
Expand Down Expand Up @@ -86,6 +90,36 @@ def __setitem__(self, *args, **kwargs): # real signature unknown
pass


# @TODO this currently reverses the order of str1 and str2
def concat(str1, str2):
"""
range(str1, str2) -> str object
Return a string that is the concatenation of the two arguments
"""
pass


# @TODO this currently does not work
#def substr(source,start_index, count):
# """
# substr(source, start_index, count) -> list object
#
# Return a subset of a string `source`, starting at `start_index` and
# of length `count`
# """
# pass


# @TODO this currently does not work
#def take(source, count):
# """
# take(source, count) -> list object
#
# Return a subset of a string or list `source`, starting
# at index 0 and of length `count`
# """
# pass


def range(start, stop):
Expand Down
8 changes: 7 additions & 1 deletion boa/code/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ def convert_method_call(self, pytoken):

def is_op_call(self, op):

if op in ['len','abs','min','max',]:
if op in ['len','abs','min','max','concat','substr','take']:
return True
return False

Expand All @@ -816,6 +816,12 @@ def convert_op_call(self, op, pytoken=None):
return self.convert1(VMOp.MIN,pytoken)
elif op == 'max':
return self.convert1(VMOp.MAX,pytoken)
elif op == 'concat':
return self.convert1(VMOp.CAT,pytoken)
elif op == 'substr':
return self.convert1(VMOp.SUBSTR,pytoken)
elif op == 'take':
return self.convert1(VMOp.LEFT,pytoken)
return None

def is_notify_call(self, op):
Expand Down
13 changes: 13 additions & 0 deletions boa/tests/src/ConcatTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from boa.code.builtins import concat

def Main():

str1 = 'hello'
str2 = 'world'

str3 = concat(str1,str2)

#this ends up being 'worldhello'
#need to reverse the parameters...

return str3

0 comments on commit 280f345

Please sign in to comment.