Exemple #1
0
def apply_state_dict(state: StateAPI, state_dict: AccountState) -> None:
    for account, account_data in state_dict.items():
        state.set_balance(account, account_data["balance"])
        state.set_nonce(account, account_data["nonce"])
        state.set_code(account, account_data["code"])

        for slot, value in account_data["storage"].items():
            state.set_storage(account, slot, value)
Exemple #2
0
def setup_state(desired_state: AccountState, state: StateAPI) -> None:
    for account, account_data in desired_state.items():
        for slot, value in account_data['storage'].items():
            state.set_storage(account, slot, value)

        nonce = account_data['nonce']
        code = account_data['code']
        balance = account_data['balance']

        state.set_nonce(account, nonce)
        state.set_code(account, code)
        state.set_balance(account, balance)
    state.persist()