* remove error when signing with a different chain
- a chain_id mismatch between the signer and the transaction is valid
since the behavior is the same between two signers with different
chain ids
- a specified chain_id should be signed regardless of the chain_id of
the signer
- refactor `sign_hash` to no longer take an `eip155` flag - it now
_just_ signs hashes. EIP155 is specific to transactions, so we
now normalize the `v` value in `sign_transaction_sync`
* use signer chain_id for tx in trezor signer
- use the trezor signer's chain_id if the transaction's chain_id
doesn't exist
- sets the chain_id in both `sign_tx` and the Signer implementation's
`sign_transaction`
* use signer chain_id for tx in ledger signer
- use the ledger signer's chain_id if the transaction's chain_id
doesn't exist
- sets the chain_id in both `sign_tx` and the Signer implementation's
`sign_transaction`
* prefer transaction chain_id in aws signer
- uses the signer chain_id if the transaction chain_id doesn't exist
- refactor `sign_digest_with_eip155` to take an input chain_id, so the
signer chain_id is not used every time. If we want to enforce
transaction and signer chain ids to be consistent, this should be
undone
* add private key signing test for an empty chain_id
* Apply suggestions from code review
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
* Update ethers-signers/src/ledger/mod.rs
Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
* added trezor signer
* linting
* TrezorHDPath instead of HDPath
* update trezor_client rev. added compatible hidapi backend
* remove unused variables
* keep track of the client session_id
* add to Other derivation paths to trezor
* remove commented macro
* remove unnecessary drops
* no ens
* added TrezorTransaction that loads from TypedTransaction
* enforce minimum firmware version
* add big data test to trezor app
* clippy
* replace trezor-client git with published crate
* change one char string to char
* bump trezor-client, with ethereum feature only
* fix: eip712 signing with ledger hw
This commit fixes the way a EIP712 derived struct is sent to the
Ledger HW to obtain the signature.
It also checks if the Ledger ETH app is at least 1.6.0 since this
is a requirement.
* fix: apply cargo fmt
* fix: revert ledger eip712 test
* refactor: remove unused code
* test: add ledger eip712 test
* fix: cargo fmt
* fix: move the logic to app.rs
* feat: make sign_typed_data take a reference
* chore: ensure abigen is enabled in ledger tests
we need this to compile ethers-contract as a standalone package
* test: ensure that the ledger sig verifies
* test: pass foo_bar by ref
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>