Skip to content

Instantly share code, notes, and snippets.

@tinybike
Last active June 20, 2016 02:12
Show Gist options
  • Select an option

  • Save tinybike/eac71f091eac484ccff499c7b2887b27 to your computer and use it in GitHub Desktop.

Select an option

Save tinybike/eac71f091eac484ccff499c7b2887b27 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# @author Chris Calderon (calderon.christian760@gmail.com)
from ethereum import tester as t
code1 = '''data muhState[]
data muhLen[]
def get(i):
return(load(self.muhState[i], items=self.muhLen[i]):arr)
def set(i, junk:arr):
self.muhLen[i] = len(junk)
save(self.muhState[i], junk, items=len(junk))
return(self.muhLen[i])
'''
code2 = '''extern code1:[get:i:a, set:ia:i]
code1 = {}
def doJunk(x):
junk = array(x)
i = 0
while i < x:
junk[i] = i*x
i += 1
code1.set(x, junk)
return(code1.get(x, outsz=x):arr)
'''
code3 = '''extern code2:[doJunk:i:a]
code2 = {}
def foo(i):
return(code2.doJunk(i*2, outsz=i*2):arr)
'''
s = t.state()
c1 = s.abi_contract(code1)
c2 = s.abi_contract(code2.format('0x' + c1.address.encode('hex')))
c3 = s.abi_contract(code3.format('0x' + c2.address.encode('hex')))
print c3.foo(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment