|
| 1 | +# Migrating from Wake 4.x |
| 2 | + |
| 3 | +In version 5.0.0, a new testing EVM execution engine based on [revm](https://github.com/bluealloy/revm) was introduced. This brings several breaking changes as well as new features. |
| 4 | + |
| 5 | +## Breaking changes |
| 6 | + |
| 7 | +### Renamed symbols |
| 8 | + |
| 9 | +- The `default_chain` alias no longer exists, use `chain` instead |
| 10 | +- `TransactionRevertedError` was renamed to `RevertError` |
| 11 | +- `UnknownTransactionRevertedError` was renamed to `UnknownRevertError` |
| 12 | + |
| 13 | +### Dropped development chain support |
| 14 | + |
| 15 | +[Ganache](https://archive.trufflesuite.com/ganache/) is no longer supported. Hardhat's development chain support is considered deprecated. |
| 16 | + |
| 17 | +### `bytearray` replaced with `bytes` |
| 18 | + |
| 19 | +All pytypes functions and dataclass attributes that represent Solidity `bytes` are now represented by Python `bytes` instead of `bytearray`. This affects: |
| 20 | + |
| 21 | +- Low-level `Account.call` function |
| 22 | +- Return value of `Account.transact` |
| 23 | +- `random_bytes` function |
| 24 | +- Other similar API functions |
| 25 | + |
| 26 | +### Configured accounts must be re-imported |
| 27 | + |
| 28 | +All accounts configured through `wake accounts` CLI commands must be manually deleted and imported again: |
| 29 | + |
| 30 | +1. Remove existing accounts: `wake accounts remove <alias>` |
| 31 | +2. Import accounts again: `wake accounts import <alias>` |
| 32 | + |
| 33 | +### Removed `type` kwarg from functions interacting with contracts |
| 34 | + |
| 35 | +Transaction type can no longer be specified through the `type` keyword argument. Instead, the transaction type is derived automatically from the passed arguments. |
| 36 | + |
| 37 | +## New features |
| 38 | + |
| 39 | +### [revm](https://github.com/bluealloy/revm)-based execution backend |
| 40 | + |
| 41 | +The new execution backend with amazing performance can be used by setting the following in wake.toml: |
| 42 | + |
| 43 | +```toml |
| 44 | +[testing] |
| 45 | +cmd = "revm" |
| 46 | +``` |
| 47 | + |
| 48 | +**Note:** There is no JSON-RPC available for this testing backend. |
| 49 | + |
| 50 | +### Support for [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) transactions |
| 51 | + |
| 52 | +A new function was implemented to sign [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) authorizations: |
| 53 | + |
| 54 | +```python |
| 55 | +Account.sign_authorization( |
| 56 | + address: Account | Address | int | str, |
| 57 | + chain_id: int | None = None, |
| 58 | + nonce: int | None = None |
| 59 | +) -> SignedAuthorization |
| 60 | +``` |
| 61 | + |
| 62 | +All contract interaction functions now support an `authorization_list: Optional[List[SignedAuthorization]]` keyword argument accepting an optional list of such signed authorizations. |
| 63 | + |
| 64 | +### `ExternalEvent` and `ExternalError` API |
| 65 | + |
| 66 | +Events and errors originating in forked contracts are now resolved into specialized class instances when possible (i.e., when ABI is available either on Sourcify or Etherscan with an API key set). |
| 67 | + |
| 68 | +This feature is currently only supported with `revm` testing chain. |
| 69 | + |
| 70 | +**`ExternalEvent` class:** |
| 71 | + |
| 72 | +- Provides `_event_full_name` attribute with the canonical name of the event |
| 73 | +- Other attributes named according to the event parameters in ABI |
| 74 | + |
| 75 | +**`ExternalError` class:** |
| 76 | + |
| 77 | +- Provides `_error_full_name` attribute with the canonical name of the error |
| 78 | +- Other attributes named according to the error parameters in ABI |
| 79 | + |
| 80 | +### Support for Trezor hardware wallets |
| 81 | + |
| 82 | +An `Account` instance may be created using a new function: |
| 83 | + |
| 84 | +```python |
| 85 | +Account.from_trezor( |
| 86 | + path: str = "m/44'/60'/0'/0/0", |
| 87 | + chain: Optional[Chain] = None |
| 88 | +) -> Account |
| 89 | +``` |
| 90 | + |
| 91 | +### Request access list for reverting transactions |
| 92 | + |
| 93 | +API calls requesting [EIP-2930](https://eips.ethereum.org/EIPS/eip-2930) access lists now support: |
| 94 | + |
| 95 | +- New `revert_on_failure` keyword argument (set to `True` by default) |
| 96 | +- Setting it to `False` allows requesting an access list even for failing transactions |
| 97 | + |
| 98 | +### Support for Linux ARM |
| 99 | + |
| 100 | +ARM Linux is now supported through 3rd party [nikitastupin/solc](https://github.com/nikitastupin/solc) repository containing solc binaries for this platform. |
| 101 | + |
| 102 | +### `pytypes_resolver` for enforcing event and error resolution |
| 103 | + |
| 104 | +It is possible to override the resolution of events and errors for any Account using `pytypes_resolver`. |
| 105 | + |
| 106 | +```python |
| 107 | +usdt = Account("0xdAC17F958D2ee523a2206206994597C13D831ec7") |
| 108 | +usdt.pytypes_resolver = IUSDT |
| 109 | +``` |
| 110 | + |
| 111 | +where `IUSDT` is a Solidity interface generated into pytypes. |
| 112 | + |
| 113 | +This feature can be used to enforce user-friendly resolution of "external contracts" (e.g. forked contracts, low-level deployed contracts with init code) and in cases when implicit resolution doesn't work correctly. |
| 114 | + |
| 115 | +`pytypes_resolver` must always be assigned to the Account that performs the event emit (LOGn instruction) or performs the revert. In a proxy-implementation setup, `pytypes_resolver` must be set on the implementation contract to correctly resolve events and errors originating from the code of the implementation contract. It may be set for the proxy as well if it defines its own events or errors. |
| 116 | + |
| 117 | +This feature is currently only supported with `revm` testing chain. |
| 118 | + |
| 119 | +### [EIP-712](https://eips.ethereum.org/EIPS/eip-712) encoded data for all structs |
| 120 | + |
| 121 | +All instances of structs generated in pytypes now offer two helper functions for easier debugging of signatures provided by `Account.sign_structured`: |
| 122 | + |
| 123 | +- `.encode_eip712_type()` returning the [EIP-712](https://eips.ethereum.org/EIPS/eip-712) encoded type of the struct as a string |
| 124 | +- `.encode_eip712_data()` returning the [EIP-712](https://eips.ethereum.org/EIPS/eip-712) encoded data of the struct as bytes |
0 commit comments