Esempio n. 1
0
        // Gas measured: ?? TODO
        function TheTestContract(int32 newInt) 
        {
            aPublicInt = newInt;
            _ownerAddr = msg.sender;
        }
        
        function SetTheInt(int32 newInt)
        {
            aPublicInt = newInt; 
        }
    }
        
    '''

contract_path = fs.write_temp_contract("test.sol", contract_src)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# Test of async calls
#


class async_tester(TransactionDelegate):
    
    # potential states
    STATE_INIT = 0 # Initialize and create the contract...
    STATE_CONTRACT_CREATED = 1 # just poll until it's installed    
    STATE_CONTRACT_INSTALLED = 2 # send a TX to the contract
    STATE_TX_SENT = 3 # poll until it's there
    STATE_TX_DONE = 4 # use a contract call() to read the result
    STATE_DONE = 7
Esempio n. 2
0
        }        
        
        function testNullWithSha() constant returns(int8)
        {
            int8 ret = 0;
            if (sha3(_stringsByAddr[msg.sender])==sha3(""))
                ret = 1;
            return ret;         
        
        }
        
    }
        
    '''

contract_path = fs.write_temp_contract("test.sol", contract_src)

print("\nContract Creation")   
byte_code = SolcCaller.compile_solidity(contract_path)
utx = eth.prepare_contract_creation_tx(byte_data=byte_code, 
                                    ctor_sig='TheTestContract()', 
                                    ctor_params=[],
                                    from_address=account,
                                    nonce=nonce,
                                    gas=1500000
                                    )    
(stx, errcode, errmsg) = keystore.sign_transaction(account, utx)
if errcode < 0:
    print("Signing error. Code: {0}, Msg: {1}".format(errcode, errmsg))   
txhash = eth.eth_sendRawTransaction(stx)
print("tx_hash: {0}".format(txhash))
Esempio n. 3
0
    '''
    libscpe is <source_path>:<LibraryName>
    ie" ./base/contract/bob.sol:BobContract"
    '''
    print("\n\n{0}".format(bytecode))
    pat = '__({0})__+'.format(libspec)
    newcode = re.sub(pat, address, bytecode, 0)
    print("\n\n{0}".format(newcode))
    return newcode


# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

fs = FuncSetups()

lib_path = fs.write_temp_contract("test-lib.sol", lib_src)
lib2_path = fs.write_temp_contract("test-lib2.sol", lib2_src)
lib_folder = os.path.dirname(lib_path)

os.chdir(lib_folder)
lib_path = "./test-lib.sol"
lib2_path = "./test-lib2.sol"

# insert actual library source path,
# needs to happen because files are written to temp
caller_src = str.replace(caller_src, '{{libpath}}', lib_path)
caller_src = str.replace(caller_src, '{{lib2path}}', lib2_path)
caller_path = fs.write_temp_contract("test_caller.sol", caller_src)

#eth = fs.create_proxy()
eth = fs.create_proxy('https://infuranet.infura.io:443')
Esempio n. 4
0
def insert_library_address(bytecode, libspec, address):
    '''
    libscpe is <source_path>:<LibraryName>
    ie" ./base/contract/bob.sol:BobContract"
    '''    
    print("\n\n{0}".format(bytecode))
    pat = '__({0})__+'.format(libspec)
    newcode = re.sub(pat,address,bytecode,0)
    print("\n\n{0}".format(newcode))
    return newcode
    
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

fs = FuncSetups()

lib_path = fs.write_temp_contract("test-lib.sol", lib_src)   
lib2_path = fs.write_temp_contract("test-lib2.sol", lib2_src)   
lib_folder = os.path.dirname(lib_path)


os.chdir(lib_folder)
lib_path = "./test-lib.sol"
lib2_path = "./test-lib2.sol"

# insert actual library source path,
# needs to happen because files are written to temp
caller_src = str.replace(caller_src, '{{libpath}}', lib_path)
caller_src = str.replace(caller_src, '{{lib2path}}', lib2_path)
caller_path = fs.write_temp_contract("test_caller.sol", caller_src)

#eth = fs.create_proxy()