예제 #1
0
def init_wallet():
    global psw
    if not os.path.exists('data-dir/mywallet.wallet'):
        psw = wallet.create('mywallet')
        print('wallet password:'******'data-dir/data.pkl', 'wb') as f:
            print('test wallet password save to data-dir/data.pkl')
            pickle.dump(psw, f)

    wallet.open('mywallet')
    if not psw:
        with open('data-dir/data.pkl', 'rb') as f:
            psw = pickle.load(f)
    wallet.unlock('mywallet', psw)
    wallet.set_timeout(60 * 60 * 24)

    priv_keys = [
        '5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3',
        '5JEcwbckBCdmji5j8ZoMHLEUS8TqQiqBG1DRx1X9DN124GUok9s',
        '5JbDP55GXN7MLcNYKCnJtfKi9aD2HvHAdY7g8m67zFTAFkY1uBB',
        '5K463ynhZoCDDa4RDcr63cUwWLTnKqmdcoTKTHBjqoKfv4u5V7p'
    ]

    keys = wallet.list_keys('mywallet', psw)
    exist_priv_keys = keys.values()
    for priv_key in priv_keys:
        if not priv_key in exist_priv_keys:
            print('import key:', priv_key)
            wallet.import_key('mywallet', priv_key)
예제 #2
0
파일: test.py 프로젝트: 51weekend/pyeos
def init():
    psw = 'PW5Kd5tv4var9XCzvQWHZVyBMPjHEXwMjH1V19X67kixwxRpPNM4J'
    wallet.open('mywallet')
    wallet.unlock('mywallet', psw)

    key1 = 'EOS61MgZLN7Frbc2J7giU7JdYjy2TqnfWFjZuLXvpHJoKzWAj7Nst'
    key2 = 'EOS5JuNfuZPATy8oPz9KMZV2asKf9m8fb2bSzftvhW55FKQFakzFL'
    if not eosapi.get_account('currency'):
        with producer:
            r = eosapi.create_account('inita', 'currency', key1, key2)
            assert r

    if not eosapi.get_account('exchange'):
        with producer:
            r = eosapi.create_account('inita', 'exchange', key1, key2)
            assert r

    with producer:
        r = eosapi.set_contract(
            'currency', '../../programs/pyeos/contracts/currency/currency.py',
            '../../contracts/currency/currency.abi', 1)
        assert r
        r = eosapi.set_contract(
            'exchange', '../../programs/pyeos/contracts/exchange/exchange.py',
            '../../contracts/exchange/exchange.abi', 1)
        assert r
예제 #3
0
파일: test.py 프로젝트: anklee/pyeos
def init():
    psw = 'PW5Kd5tv4var9XCzvQWHZVyBMPjHEXwMjH1V19X67kixwxRpPNM4J'
    wallet.open('mywallet')
    wallet.unlock('mywallet', psw)
    
    key1 = 'EOS61MgZLN7Frbc2J7giU7JdYjy2TqnfWFjZuLXvpHJoKzWAj7Nst'
    key2 = 'EOS5JuNfuZPATy8oPz9KMZV2asKf9m8fb2bSzftvhW55FKQFakzFL'
    
    with producer:
        if not eosapi.get_account('currency'):
            r = eosapi.create_account('inita', 'currency', key1, key2)

        if not eosapi.get_account('test'):
            r = eosapi.create_account('inita', 'test', key1, key2)
            assert r

    with producer:
        r = eosapi.set_contract('currency', '../../programs/pyeos/contracts/currency/currency.py', '../../contracts/currency/currency.abi', eosapi.py_vm_type)
        assert r
        r = eosapi.set_contract('test','../../programs/pyeos/contracts/test/code.py','../../programs/pyeos/contracts/test/test.abi', eosapi.py_vm_type)
        assert r

    #transfer some "money" to test account for test
    with producer:
        r = eosapi.push_message('currency','transfer','{"from":"currency","to":"test","quantity":1000}',['currency','test'],{'currency':'active'})
        assert r

    #transfer some "money" to test account for test
    with producer:
        r = eosapi.push_message('eos','transfer',{"from":"inita","to":"test","amount":1000,"memo":"hello"},['inita','test'],{'inita':'active'})
        assert r
예제 #4
0
def init():

    psw = 'PW5Kk1h8RqDwf8CB8mKcz7WZ8r6MF9of9CYvrC96XdBL5Z1SwBVx9'

    if not os.path.exists('data-dir/mywallet.wallet'):
        psw = wallet.create('mywallet')
        print(psw)

    wallet.open('mywallet')
    wallet.unlock('mywallet', psw)

    priv_keys = [
        '5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3',
        '5JEcwbckBCdmji5j8ZoMHLEUS8TqQiqBG1DRx1X9DN124GUok9s',
        '5JbDP55GXN7MLcNYKCnJtfKi9aD2HvHAdY7g8m67zFTAFkY1uBB'
    ]

    keys = wallet.list_keys()
    exist_priv_keys = keys.values()
    for priv_key in priv_keys:
        if not priv_key in exist_priv_keys:
            wallet.import_key('mywallet', priv_key)

    src_dir = os.path.dirname(os.path.abspath(__file__))
    sys.path.append(os.path.join(src_dir, '/contracts/cryptokitties'))
    contracts_path = os.path.join(src_dir, '../../build', 'contracts')
    for account in ['eosio.bios', 'eosio.msig', 'eosio.system', 'eosio.token']:
        if not eosapi.get_account(account).permissions:
            r = eosapi.create_account('eosio', account, key1, key2)
            assert r
        if not eosapi.get_code(account):
            wast = os.path.join(contracts_path, account, account + '.wast')
            abi = os.path.join(contracts_path, account, account + '.abi')
            r = eosapi.set_contract(account, wast, abi, 0)
        eosapi.produce_block()
예제 #5
0
파일: test.py 프로젝트: anklee/pyeos
def init():
    psw = 'PW5JUPL2mFQTtRaxCYcuEKSiWpYuiECh6PKqKdUY17bYZNuZ3zA5Y'
    wallet.open('mywallet')
    wallet.unlock('mywallet', psw)
예제 #6
0
def init():

    psw = 'PW5K87AKbRvFFMJJm4dU7Zco4fi6pQtygEU4iyajwyTvmELUDnFBK'

    if not os.path.exists('data-dir/mywallet.wallet'):
        psw = wallet.create('mywallet')
        print('wallet password:'******'mywallet')
    wallet.unlock('mywallet', psw)

    priv_keys = [
        '5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3',
        '5JEcwbckBCdmji5j8ZoMHLEUS8TqQiqBG1DRx1X9DN124GUok9s',
        '5JbDP55GXN7MLcNYKCnJtfKi9aD2HvHAdY7g8m67zFTAFkY1uBB'
    ]

    keys = wallet.list_keys()
    exist_priv_keys = keys.values()
    for priv_key in priv_keys:
        if not priv_key in exist_priv_keys:
            wallet.import_key('mywallet', priv_key)

    if eosapi.is_replay():
        return

    src_dir = os.path.dirname(os.path.abspath(__file__))
    '''
    r = eosapi.push_message('eosio.token', 'create', {"to":"eosio", "quantity":"10000.0000 EOS", "memo":""},{'eosio':'active'})
    r = eosapi.push_message('eosio.token','issue',{"to":"hello","quantity":"1000.0000 EOS","memo":""},{'hello':'active'})
    assert r
    msg = {"from":"eosio", "to":"hello", "quantity":"25.0000 EOS", "memo":"m"}
    r = eosapi.push_message('eosio.token', 'transfer', msg, {'eosio':'active'})
    assert r
    '''

    contracts_path = os.path.join(src_dir, '../../build', 'contracts')
    sys.path.append(os.getcwd())
    for account in ['eosio.bios', 'eosio.msig', 'eosio.system', 'eosio.token']:
        print('account', account)
        if not eosapi.get_account(account).permissions:
            r = eosapi.create_account('eosio', account, key1, key2)
            assert r
            eosapi.produce_block()

        old_code = eosapi.get_code(account)[0]
        need_update = not old_code
        if False:  #old_code:
            print('+++++++++old_code[:4]', old_code[:4])
            if old_code[:4] != b'\x00asm':
                old_code = eosapi.wast2wasm(old_code)

            wast = os.path.join(contracts_path, account, account + '.wast')
            code = open(wast, 'rb').read()
            code = eosapi.wast2wasm(code)

            print(len(code), len(old_code), old_code[:20])
            if code == old_code:
                need_update = False
        if need_update:
            wast = os.path.join(contracts_path, account, account + '.wast')
            abi = os.path.join(contracts_path, account, account + '.abi')
            r = eosapi.set_contract(account, wast, abi, 0)
            eosapi.produce_block()

            if False:  #account == 'eosio.token':
                msg = {
                    "issuer": "eosio",
                    "maximum_supply": "1000000000.0000 EOS",
                    "can_freeze": 0,
                    "can_recall": 0,
                    "can_whitelist": 0
                }
                r = eosapi.push_message('eosio.token', 'create', msg,
                                        {'eosio.token': 'active'})
                assert r
                r = eosapi.push_message('eosio.token', 'issue', {
                    "to": "eosio",
                    "quantity": "1000.0000 EOS",
                    "memo": ""
                }, {'eosio': 'active'})
                assert r
                eosapi.produce_block()

    from backyard import t
    t.deploy_mpy()
    #load common libraries
    #    t.load_all()

    console = PyEosConsole(locals=globals())
    console.interact(banner='Welcome to PyEos')
예제 #7
0
파일: initeos.py 프로젝트: eos21/pyeos
key1 = 'EOS61MgZLN7Frbc2J7giU7JdYjy2TqnfWFjZuLXvpHJoKzWAj7Nst'
key2 = 'EOS5JuNfuZPATy8oPz9KMZV2asKf9m8fb2bSzftvhW55FKQFakzFL'

import wallet
wallet.open('mywallet')
wallet.unlock('mywallet',
              'PW5Kd5tv4var9XCzvQWHZVyBMPjHEXwMjH1V19X67kixwxRpPNM4J')
예제 #8
0
def init():
    psw = 'PW5KTHfg4QA7wD1dZjbkpA97hEktDtQaip6hNNswWkmYo5pDK3CL1'
    wallet.open('mywallet')
    wallet.unlock('mywallet', psw)
예제 #9
0
파일: initeos.py 프로젝트: anklee/pyeos
key1 = 'EOS61MgZLN7Frbc2J7giU7JdYjy2TqnfWFjZuLXvpHJoKzWAj7Nst'
key2 = 'EOS5JuNfuZPATy8oPz9KMZV2asKf9m8fb2bSzftvhW55FKQFakzFL'


import wallet
wallet.open('mywallet')
wallet.unlock('mywallet','PW5JUPL2mFQTtRaxCYcuEKSiWpYuiECh6PKqKdUY17bYZNuZ3zA5Y')