示例#1
0
def init():
    if eosapi.is_replay():
        return

    src_dir = os.path.dirname(os.path.abspath(__file__))
    create_system_accounts()
    publish_system_contracts({'eosio.token': 'eosio.token'})
    publish_system_contracts({'eosio.msig': 'eosio.msig'})
    publish_system_contracts({'eosio': 'eosio.system'})
    '''
示例#2
0
def init():
    if eosapi.is_replay():
        return

    src_dir = os.path.dirname(os.path.abspath(__file__))

    publish_system_contract()

    from backyard import t
    t.deploy_mpy()
    net.connect('127.0.0.1:9101')
示例#3
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')