Commit Graph

40 Commits

Author SHA1 Message Date
Georgios Konstantopoulos 73c7f6cacc
fix: ethers-contract circular dep on ethers-signers (#2291)
* fix: remove dep of contract on signers

* refactor: move ethers/live up a dir

* test: move over eip712 test from ethers-contract

* chore: rm unused vars

* ethers: enable ethers-solc by default

* ci: remove --live from ci tests

* chore: make ethers-solc always part of ethers

* test: ensure rustls is enabled for https

* chore: ignore clippy fp
2023-03-21 11:44:12 -07:00
James Prestwich 0c16eb971d
Prestwich/event no lifetime (#2105)
* refactor(breaking): remove lifetime from Event

* fix: example updated to use new event
2023-02-13 17:14:38 -08:00
James Prestwich 2607c67ca0
Refactor factories to use `Borrow<M>` (#2103)
* refactor: abstract factories over Borrow

* chore: changelog

* fix: docs for factory and type aliases
2023-02-07 10:51:34 -08:00
James Prestwich 0236de8d2a
refactor: make contract abstract over Borrow (#2082)
* refactor: contract abstract over Borrow

* refactor: preserve old connect usage

* nit: remove commented out modules

* chore: changelog

* test: add compile check to tests

* docs: add usage note to doc and make sure contractcall is visible

* fix: test compilation

* refactor: ContractCallInternal -> FunctionCall, ContractInternal -> ContractInstance

* fix: Send IntoFuture

* nit: must-use on connect

* docs: remove deprecation warning in docstrings for type aliases

* Update ethers-contract/src/call.rs

Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>

---------

Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
2023-02-06 13:27:01 -08:00
DaniPopes 015eeabea8
feat(contract): return multicall pending transaction (#2044)
* feat(contract): return multicall pending transaction

* fix: tests

* docs: update CHANGELOG.md
2023-01-11 19:30:56 -08:00
DaniPopes 24b9ae2404
fix(contract): doctests (#2007) 2023-01-04 13:29:10 +02:00
Matthias Seitz 84f896f47b
chore(clippy): make clippy happy (#1888) 2022-11-23 07:35:38 -08:00
Andrea Simeoni 845aa4920f
feat: Instantiate an event builder without a contract instance (#1882)
* Build an `Event` without requiring a contract instance

* Contract unit test

* Function to set Event address

* Example

* Typo to improve readability

* CHANGELOG

* cargo +nightly fmt

* FIX conflict

* review: applied Address alias

Co-authored-by: Andrea Simeoni <>
Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
2022-11-22 13:15:36 -08:00
DaniPopes fb88215a87
fix: rustdoc errors (#1808)
* fix: rustdoc warnings

* fix: partially re-run abigen for multicall_contract

* fix

* fix test

* fix: rustdoc nightly warnings
2022-11-07 15:43:23 -08:00
DaniPopes 4ed46089d8
contract: return `Arc<M>` instead of `&M` (#1731)
* return Arc<M> instead of &M

* docs
2022-09-24 12:40:08 -07:00
DaniPopes 733c5d3dfd
fix(contract): relax Middleware trait bound for getters (#1728)
* wip

* fix(contract): relax Middleware trait bound for getters

* chore: clippy

* move

* fix: multicall
2022-09-23 17:32:24 -07:00
DaniPopes db75e3628e
feat(core): add utility methods to NameOrAddress (#1720)
* feat: NameOrAddress impls

* feat: add to_addr to TypedTransaction

* fix: use NameOrAddress for ens

* chore: clippy

* dont clone
2022-09-19 10:51:04 -07:00
oblique 6faceb20d7
feat: Relax `Clone` requirements when `Arc<M>` is used (#1183)
`#[derive(Clone)]` was implementing `Clone` only if `M` was `Clone`,
however because of `Arc<M>` this can be relaxed.
2022-04-27 15:33:22 +03:00
Matthias Seitz 969d4e01c0
feat: accept different middlewares for contract connect (#1159) 2022-04-21 17:05:23 +02:00
Matthias Seitz e24117a1e1
chore(clippy): make clippy happy (#705) 2021-12-19 06:28:38 +02:00
Georgios Konstantopoulos f0dea75219
feat: use ethers_solc::Solc instead of ethers_core::utils::Solc (#546)
* 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
2021-10-31 13:34:51 +02:00
Matthias Seitz dcf20022c6
chore: add rustfmt.toml (#537)
* chore: add rustfmt.toml

* rustfmt

* chore: Update readme with fmt info

* ci: update ci

* chore: rustfmt

* rustfmt

* rustfmt

* ci: install libudev

* chore(clippy): make clippy happy

* chore(clippy): make clippy happy

* revert ci

* ci: install libudev
2021-10-29 14:29:35 +02:00
Georgios Konstantopoulos 38c7f5030f
chore: remove cyclical dependencies (#410)
* chore(core): remove ethers dep

* chore(providers): remove ethers dep

tests using higher-rank crates are temporarily disabled

* chore(middleware): remove ethers dep and move tests over from providers

* chore(signers): remove ethers dep

* fix(contracts): correctly determine ethers sub-crates & remove ethers

* fix: re-enable tests for all members

* fix: make contract compile without middleware dep

move over the test using middleware to ethers-middleware

* chore: cargo fmt

* chore(contract): add missing import

* WIP

* WIP

* fix(middleware): use rustls as dev dep

* chore: cargo fmt

* fix: use different key for nonce manager to avoid nonce conflicts

* chore: fix celo test ported over to middlewares

the test had the same private key with an existing middleware test,
causing potential nonce reuses

it now also uses a different storage contract, so we had to change
it to use u256 instead of string

* fix(middleware): enable contracts/celo feature

* chore: ignore non-eip2718 txs to rinkeby
2021-08-29 00:06:29 +03:00
Georgios Konstantopoulos 60ff4660df
feat: multiple addresses on Filter (#375)
* feat: support multiple addresses in filters

To support filtering of 1..n addresses we had to add the ValueOrArray
enum to the log types and refactor some ethers-contract code

Fixes: #240

Signed-off-by: Sebastian Martinez <sebastinez@me.com>

* chore: fmt

* fix: use legacy tx in unit test due to Ganache

Co-authored-by: Sebastian Martinez <sebastinez@me.com>
2021-08-12 19:19:24 +03:00
Georgios Konstantopoulos 25c2e0e199
feat(ethers-contract): typed txs (part 4) (#362)
* feat(contract): use eip-1559 txs by default

This may break any tests which use Ganache, since it only supports legacy transactions.
We should replace Ganache with hardhat where possible

* fix(providers): always try setting default_sender

* chore: make all test transactions legacy

* feat(multicall): allow submitting legacy txs

* chore: default to legacy txs via feature flag

This is useful for chains like Celo that do not support the Typed Envelope

* fix: use legacy txs in ds proxy deployment / tests

* chore: fix review comments
2021-08-09 03:50:38 +03:00
Matthias Seitz 816c5fc071
feat(abigen): extend ethevent trait methods and decoding (#239)
* feat: extend EthEvent with decode_log method and support indexed proc
macro attributes

* test: check that ethevent proc macro attributes compile

* docs: document EthEvent proc macro attributes and add example

* refactor: change decode_log to take a reference

* refactor: use ethers as fully qualified path

* feat: add events enum generation

* feat: introduce EthLogDecode trait

* feat: generate EthLogDecode implementations

* refactor: use fully qualified syntax during abigen

* fix: switch to new Event builder

* fix: make test compile again

* test: update failing tests

* refactor: rename event function

* chore(clippy): make clippy happy

* fix: rename the event correctly

* fix: add missing indexed attribute

* Revert "fix: rename the event correctly"

This reverts commit 03eabc3ead.

* fix: make indexed names optional

* fix: dsproxy name

* fix: rename ethers top level module imports
2021-03-19 17:44:59 +02:00
Rohit Narurkar 3105431007
feat: Transformer middleware with DsProxy impl (#165)
* feat: basic structure of proxy wallet middleware with DsProxy

* feat: build DsProxy contract, minor fixes, naming convention changes

* fix: add provider error in contract error

* fix: left pad storage value

* fix: delete gnosis safe for now

* feat(ds_proxy): execute code or target

* test(ds_proxy): transformer middleware tests

* fix: clippy should be happy

* fix(tests): ds proxy execute code

* chore: add documentation

* chore: formatting
2021-01-22 11:25:22 +02:00
Georgios Konstantopoulos 29a3a16085
chore: upgrade to latest ethtypes (#137)
* chore: upgrade to latest ethtypes

* chore: fix doctests
2021-01-10 14:03:37 +02:00
Georgios Konstantopoulos 5f292670fc
docs: add more docs (#130) 2020-12-31 21:08:12 +02:00
Georgios Konstantopoulos 5c1f8f532a
Upgrade to Tokio 1.0 and remove async-std (#120)
* feat(providers): tokio 1.0

BREAKING: This removes async-std as a compatibility option

* feat: tokio 1.0 in rest of crates

* fix: patch Cargo.toml until deps are released

* fix(contract): load ws deps

* feat: bytes 1.0 (#121)

* feat(core): move to bytes::Bytes

* feat: adjust rest of crates to Bytes

* chore: bump deps

CI fails due to:
https://github.com/snapview/tokio-tungstenite/pull/142#discussion_r550445144

* chore: use latest tokio-tungstenite

* ci: split tests into jobs (#129)

* Switch to `hex` (#128)

* fix(core): replace rustc_hex with hex

* fix(providers): replace rustc_hex with hex

* chore: replace rustc-hex with hex

* chore: cargo fmt

* fix(ledger): copy address from string correctly

* chore: fix flaky tests

Fixes #105
2020-12-31 19:19:14 +02:00
Georgios Konstantopoulos 3a2fd3e814
Returning a `PendingTransaction` after sending a tx (#107)
* feat(providers): return a PendingTransaction from send_tx calls

* feat(providers): expose the internal provider to all middlewares

* fix(middleware): use the returned PendingTx instead of using a hash

* fix(contract): use the pending tx returned value

Note1: To support that, we need to clone the tx when sending in order to make lifetimes work out
Note2: Multicall does not support that feature

* fix(ethers): adjust examples

* chore: fix provider test

* chore: fix celo test

BREAKING CHANGE
2020-12-17 13:26:01 +02:00
Georgios Konstantopoulos eb26915081
feat: allow encoding/decoding function data (#90)
* feat: allow encoding/decoding function data

* feat: allow decoding event data

* feat: human readable abi

inspired from https://blog.ricmoo.com/human-readable-contract-abis-in-ethers-js-141902f4d917

* test: add event / fn decoding tests

* chore: fix clippy

* feat(abigen): allow providing args in human readable format
2020-10-29 09:48:24 +02:00
Pawan Dhananjay 35e24ed412
refactor: extract minimal features of Contract into BaseContract (#88)
* refactor: extract minimal features of Contract into BaseContract

* refactor: move BaseContract to own file

* chore: ensure celo test passes

* chore: fix clippy

Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
2020-10-27 12:57:01 +02:00
Georgios Konstantopoulos 2d51c523ba
feature: Middleware Architecture (#65)
* feat: convert Provider to Middleware trait

* feat: move gas oracle to middleware crate

* feat: move signer to middleware crate

* feat: add nonce manager middleware and test stacking

* refactor: convert generic middleware jsonrpc type to associated type

* feat: move ethers-contract to middleware arch

* test(provider): make tests pass

* test(middleware): move middleware tests from signer

* test: fix ethers examples

* fix(contract): make tests compile

* chore: fix clippy

* feat: deduplicate trait delegation

* refactor(signer): deduplicate tx signing logic across signers

* fix doctests

* fix: examples, celo tests and ci
2020-09-25 00:33:09 +03:00
Georgios Konstantopoulos 95fcbe5240
feat: ledger support (#66)
* feat: ledger support

Adds support for Ledger Nano S Eth app (v1.3.7)

- sign message
- sign transaction
- get addresses
- get app version

* fix: fix eth docstring

* fix: take into account EIP155

* feat: convert Signer to async

* feat: implement Signer for Ledger

* ci: run celo-only tests explicitly

This is done to avoid using --all-features

* fix: remove async from with_signer

* chore: fix doctests

* fix: add Send/Sync to SignerError

* ci: update etherscan key

* test: disable etherscan abigen tests temporarily
2020-09-20 18:17:02 +03:00
Georgios Konstantopoulos 3d2d40699f
Fix buggy non-nested tuples (#48)
* test(tokens): ensure nested tuples tokenize properly

* test(contract): add failing test with 2 args

This happens because the args are serialized as Token::Tuple, while instead they should be just a vector

* fix(tokens): add token flattening method to fix non-nested tuples

* fix: do not export the flatten function
2020-07-03 17:37:38 +03:00
Georgios Konstantopoulos 1cfbc7b3c3
Replace contract client references with Arc (#35)
* feat(provider): allow specifying a default polling interval param

This parameter is going to be used for all subsequent client calls by default. It can still be overriden with the internal
`interval` calls

* feat(contract): replace reference to Client with Arc

* feat(abigen): adjusts codegen to use Arcs

* fix(ethers): adjust examples to new apis

* fix(provider): return TxHash instead of PendingTransaction on tx submission

Returning a PendingTransaction allowed us to have nice ethers.js-like syntax where you submit
a transaction and then can immediately await it. Unfortunately, now that we use Arcs and not lifetimes
this meant that we would need to bind the function call in a variable, and then await on it, which is pretty
bad UX.

To fix this, we revert back to returning a TxHash and introduce a convenience method on the provider and the
contract which takes a tx_hash and returns a PendingTransaction object. The syntax ends up being slightly
more verbose (although more explicit), but the issue is fixed.
2020-06-22 11:44:08 +03:00
Georgios Konstantopoulos 0cfeadadf4
Websockets + TLS for Async-Std / Tokio (#30)
* fix: relax trait bounds on JsonRpcClient

* refactor(provider): move http client to separate dir

* feat(provider): add initial Websocket support over Stream/Sink + Tungstenite

* test(provider): add websocket test

* feat(provider): add convenience method using tokio/async-std behind a feature flag

* test(provider): add websocket ssl test

* feat(provider): add TLS websockets for tokio/async-std

* docs(provider): add websocket docs / examples

* fix(provider): make tokio an optional dep
2020-06-21 10:17:11 +03:00
Georgios Konstantopoulos 4ff466a593
fix intradoc links and add missing cargo metadata (#29) 2020-06-20 16:55:07 +03:00
Georgios Konstantopoulos d90b03da06
Add streamed logs to the provider (#9)
* feat(provider): implement Streamed logs

This utilizes eth_getFilterChanges. The stream struct must be instantiated with a factory that yields logs/hashes.
Consumers are expected to use the `FilterStream` trait in order to simplify their type definitions

* feat(provider): expose streaming methods

* test(provider): add new blocks/pending txs test

* feat(contract): allow events to be streamed

* test(contract): add integration test for streaming event logs

* perf(contract-factory): take abi and bytecode by value instead of reference

The abi, bytecode and the factory's deploy method now consume the structs instead of being passed by reference. While this means that
consumers might need to clone before using them, this gives us some more flexiblity around factories inside helper functions

* refactor(contract): use test helpers to reduce code dup

* chore: make clippy happy
2020-06-15 11:46:07 +03:00
Georgios Konstantopoulos 030fc671fe
docs(contract): expand contract docs 2020-06-10 21:20:47 +03:00
Georgios Konstantopoulos c18e52f918
contract: simplify lifetimes 2020-06-02 14:39:01 +03:00
Georgios Konstantopoulos e051cffe47
contract: allow connecting to many clients/addresses 2020-06-02 13:36:29 +03:00
Georgios Konstantopoulos 6bd3c41bd0
contract: simplify errors and generics 2020-06-02 02:15:33 +03:00
Georgios Konstantopoulos cd4914d37f
refactor: pull crates to root dir 2020-06-01 21:24:22 +03:00