fixes: https://github.com/foundry-rs/foundry/issues/1866, because
previously we'd read chain id 31337, parse it as Dev, and then when
convert it to the wrong number (1337) which would make the transaction's
chain id not match the signer's
* ci: install anvil
* test: use anvil instead of ganache
* ci: fix anvil ver
* ci: re-enable example tests
* test: remove unnecessary assertions
* test: enable anvil launch test
* docs: typo
* test: fix anvil chain id
* ci: install ganache
Ganache is needed for the Ganache tests
* chore: remove legacy feature from some examples
* ci: correctly build examples
* test: use correct account balance for anvil
* chore: remove sub_id == 1 check
this was only possible in ganache because it gives serial
sub ids, but in every other reasonable client the ids are generated
randomly, so we cannot test for its value
* test: ensure txs are different
There is a bug in Ganache's mempool which accepts duplicate transactions (here with the same nonce), whereas here we pre-set all the nonces so that they end up having a different transaction hash.
* test: ignore ganache tests
* fix: terzor api changes
* ci(examples): install Anvil, remove geth/ganache
* test(provider): Anvil instead of Geth
some tests start to fail now
* fix: revert usage of Anvil in ipc tests
Anvil does not support IPC yet
* fix: update examples script
* ci: use anvil for wasm example
* replace last ganache usage
Co-authored-by: Oliver Nordbjerg <hi@notbjerg.me>
Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
* fix: correctly serialize TxPoolInspectSummary
previously we'd use the default serde derive, now we serialize
it like geth does
* chore: add back removed Eq derive
* add different helpers for type transactions
* remove as_() on TypedTransaction
* specify into_eip2930 when it matches a legacy tx
* remove unused error type
* specify into_legacy when it matches an eip2930 tx
* Adds From<H160> trait to ValueOrArray<H160>
The trait From<H160> for ValueOrArray<H160> was not implemented which
prevented compilation when using
pub fn address<T: Into<ValueOrArray<Address>>>(self, address: T)
for ethers_core::types::Filter.
Fixes: #1199
* update CHANGELOG.md
* Adds From<Vec<H160>> trait to ValueOrArray<H160> and documentation
The trait From<Vec<H160>> for ValueOrArray<H160> was not implemented which
prevented compilation when passing a Vec<H160> into
pub fn address<T: Into<ValueOrArray<Address>>>(self, address: T)
for ethers_core::types::Filter.
This commit also includes documentation on how to use fn address for
ethers_core::types::Filter.
Fixes: #1199
* fix(core): add eip1559 prefix for sighash
- add a test which properly tests the `from` address decoding, which
was incorrect due to the tx type not being hashed before recovery
* fix(core): decode from for EIP2930 transactions
- add test which checks signed decoding for an EIP2930 transaction
* ignore decoding tests for celo
* remove type constant and use typed sighash
* update CHANGELOG
The optional access list on `Transaction` was being incorrectly encoded
as an empty string (0x80) when omitted, when it should be encoded as an
empty list (0xc0).
Fixes#1134.
* doc(core/Signature): methods are all using normalized v, dont need to be 0 or 1 only
* feat(core/Transaction): make from optional, add method to recover from
* fix recovery
* add recover_from_mut
* update changelog
* feat(ethers-core/block): add gas_target and next_block_base_fee fns according to EIP-1559
* fix: feature flag gas_target, and next_block_base_fee to !celo, address review comments
* fix: in decreasing base fee case max(delta, 1) is not used
Refer 599ea45b9e/EIPS/eip-1559.md?plain=1#L193
* Parsing U256 from base10_parse::<u64>() instead of directly to U256
This fixes a bug for chain_ids that are > 10, base10_parse::<U256>() was
somehow parsing into hex.
When using the derive macro, chain_id = 10 was parsed as chain_id = 0x10 = 16,
causing an issue for some chains like Polygon.
* chore: fmt
Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
The U256 priority fees were being coerced into u32, which was not big
enough for actual values. The overflow was happening but not checked.
This led to a possible divide-by-zero panic in this code as well.
This change does the math as I256 -- overkill, but it works.
* feat(chain): map Chain enum to values
* feat(chain): support TryFrom<u64>
* chore: use parsechain error for the try_from impl
Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
* feat: macro and token (simplest form)
* fix: better structure to fetch token by string symbol
* chore: add tokenlist to prelude
* fix: from current dir
* fix: dir refactoring
* fix: clippy
* chore: refactor tokenlist to addressbook
* fix: do not panic on invalid units conversion
This is done by switching the From implementations to TryFrom and
making the conversion functions return a thiserror Error instead of
the previous Boxed error object
* chore: update changelog
* feat(etherscan, middleware): implement gas-related endpoints and use them in gas oracle
* cleanup deps
* better comment
* revertme: add debug print
* Revert "revertme: add debug print"
This reverts commit 63993642c4.
* make etherscan tests serial
* run each etherscan test at least 200ms
* 200ms -> 250ms
* Revert "200ms -> 250ms"
This reverts commit 29c7f6ed9a.
* add separate etherscan key for celo tests
* 200ms -> 250ms
* add Chain::Sepolia to match
* fix: unit8 encoding
* feat: use ethers::types::Bytes for solidity bytes type
* feat: add const generic from impls
* fix: failing tests
* fix: make compatible with bytes
* update changelog
* make compatible with encoding changes
* chore rm write to file
* feat(ethers-solc): deserialize bytecode as bytes
* feat(ethers-solc): add method to fetch compact contract
* feat(ethers-solc): use Abi type instead of Vec<serde_json::Value>
* test(contract): use new Solc bindings
* test(middleware): use new Solc bindings
* chore: remove solc from ethers-core
* chore: remove concurrent setup code from ethers-core
* feat(ethers-solc): add ArtifactOutput::Nothing as a no-op artifact logger
* feat: add ethers-solc to top level crate
* examples: use new solc building pattern
* chore(solc): re-use opt str impl for error code decoding
* fix abigen example
* chore: fix doctests
* chore: remove setup feature
* fix: decode string to bytes correctly
* chore: clippy lints
* feat: use const generics for array tokenize
* feat: add abi encode decode impls
* test: add some tests
* chore: move abi codec to core
* update changelog
* fix: ensure gas estimation includes the access list in 1559/2930 txs
* feat: add gas_price to typed tx
* feat: add access list to typed tx
* chore(providers): cleanup fill_transaction
* chore: fmt
* chore: enable 712 on ethers-contract at top level crate
* fix: do not error if eth_createAccessList is not available
* feat: only use access list if needed
* fix: do not sort event variants
* style: use deref over clone
* style: refactor some stuff
* feat: add ethcall trait
* feat: include in abigen
* feat: add bare bones eth call derive
* feat: impl EthCall derive
* feat: support enums
* feat: use abigen enum derive
* fix: concrete abi and map errors
* test: first call test
* rustfmt
* chore: use correct trait name on error
* feat: derive display for call structs
* feat: add from conversion
* test: add convert test
* chore: docs and test
* chore: update changelog
* cargo fix
* feat: add unit type derive support and more test
* chore: patch ethabi
* chore: rm ethabi patch
* feat: add encode/decode trait impls
* style: use AsRef<[u8]>
* Update ethers-contract/ethers-contract-abigen/src/contract/methods.rs
Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
* style: reindent macro body
* test: add tuple event test
Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
* derive-eip712: initial implementation of eip712 derive macro
This commit provides an initial implementation for a derive macro
to encode typed data according to EIP-712, https://eips.ethereum.org/EIPS/eip-712
Additionally, this commit introduces a new signer trait method:
async fn sign_typed_data<T: Eip712 + Send + Sync>(
&self,
payload: &T,
) -> Result<Signature, Self::Error>;
And implements the new method for each of the signers (wallet, ledger,
aws).
Additionally, these changes include using `WalletError` for the Wallet
signer error type
At the moment, derive does not recurse the primary type to find nested
Eip712 structs. This is something that is noted in the source and
currently responds with an error regarding custom types.
A subsequent PR should be opened once this issue becomes needed. For the
moment, the current implementation should satisfy non-nested, basic struct types.
* rename to ethers-derive-eip712; move to ethers-core
* refactor of derive-eip712 macro; use ParamType and EthAbiToken
* macro updates; add byte array checker for paramtype; use literal constant for domain type hash
* replace std::convert::Infallible with WalletError as Wallet signer error type
* update workspace members and dev dependencies for examples folder
* add example for eip712 and test against contract
* remove extraneous backward slash in '\x19\x01' prefix; example tests pass
* update unreleased change log
* remove print statements
* use parse_macro_input macro; remove dead code; handle nest struct not implemented error
* move eip712 example to solidity-contract tests folder; update cargo workspace dependencies
* allow optional EIP712Domain parameter when encoding eip712 struct and signing typed data
* add documentation for eip712 feature
* Update ethers-signers/src/ledger/mod.rs
Co-authored-by: Sebastian Martinez <me@sebastinez.dev>
* add error enum for Eip712Error; use sign_payload for ledger signer
* add EIP712WithDomain type for providing a wrapper around custom setting of the domain
* make LedgerWallet sign_payload public
* use optional feature gated dependencies for eip712; add default method for encode_eip712
* add default domain_separator method, pre-compute separator hash
* move derive-eip712 deps to dev deps
* remove invalid sign payload parameter, add await on async method
* remove deprecated comment
* debugging 'bad key handle' error for ledger signer
try using 'sign_message'
* await sign digest for aws signer
* remove extra space, fix fmt warning
* fix test, fmt errors
* use gt 0.6.0 pragma compiler version
* enable ABIEncoderV2 for solidity test contract
* chore: make test constructor public
Co-authored-by: Sebastian Martinez <me@sebastinez.dev>
Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
* feat: keep track of custom types in abi parser
* feat: use internal structs for abi parsers
* test: add human readable struct input test
* chore: update changelog
* fix conflicts
* fix: remove eprintln
* make clippy happy
* make clippy happy
* rustfmt
* make clippy happy
* feat(core, abi): support shorthand functions
* simplify a bit but not much lol
* refactor a bit, beautify a lot
* fail on absent output parens for shorthand
* chore: fix clippy lints
* fix: parse shorthand functions in multiline parsing
Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
* fix(solc): normalize EVM version across solc versions
* fix: return semver::Version from solc::version instead of String
* fix off-by-1 error in solc version parsing
* Add getProof to provider
* Format updates
* Add docs
* Remove fill_tx method, not sure how it got there
* Fix removed Trace type
* Remove test, eth_getProof not supported by ganache
* chore: use ethabi with bumped ethereum-types
* fix: do not use internal type in human readable abi
* fix: do not use internal type in abigen
* feat(solc): save the runtime bytecode
* feat: implement serde for CompiledContract
* feat: allow overriding solc binary path
* feat: expose providing raw file paths
* feat: do not set evm versions on old solc
* chore: use upstream ethabi
* Correctly encode non-legacy mempool transactions
If a non-legacy transaction was fetched from the mempool and
then RLP-encoded for inclusion in e.g. a flashbots bundle,
then the bundle would fail because the encoding only worked
for legacy transactions.
* Add tests and fix encoding