-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: temporary provider trait #20
Conversation
342e2d9
to
9a060cd
Compare
6b8901b
to
b32a3d8
Compare
f597612
to
0702253
Compare
* fix: serialize block num w/o leading zeros * fix: use `u64` for block numbers
* workaround * fix: actual fix * fix: actual fix part 2
* workaround * fix: actual fix * fix: actual fix part 2 * fix access list keys --------- Co-authored-by: Enrique Ortiz <[email protected]>
* chore: start removing cows * chore: uncow tempProvider * Apply suggestions from code review Co-authored-by: DaniPopes <[email protected]> * switch to single element tuple --------- Co-authored-by: DaniPopes <[email protected]>
* feat(): raw_request * chore: remove unneeded async block
0ccb869
to
bc87178
Compare
bc87178
to
1d825ec
Compare
crates/providers/src/provider.rs
Outdated
Self: Sync; | ||
|
||
#[cfg(feature = "anvil")] | ||
async fn set_code(&self, address: Address, code: &'static str) -> TransportResult<()> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AnvilProvider extension trait? instead of cfg in this trait
where | ||
Self: Sync; | ||
|
||
async fn raw_request<P, R>(&self, method: &'static str, params: P) -> TransportResult<R> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this in the trait? Because it breaks object safety unless Self:Sized
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need it for the RPC cheatcode—maybe we could add an extension trait for this too?
@@ -36,6 +113,131 @@ pub struct LegacyTransactionRequest { | |||
pub chain_id: Option<u64>, | |||
} | |||
|
|||
impl Encodable for LegacyTransactionRequest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this even implement rlp traits? This is the same as encode_fields
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO we should remove these RLP impls—we originally did this to migrate cast but decided against it later. RLP-able types should go on the alloy-consensus-types
crate
len += self.gas_limit.length(); | ||
len += self.kind.length(); | ||
len += self.value.length(); | ||
len += self.input.0.length(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be in the derive macro and the method in encodable trait
/// | ||
/// See [Self::encode_for_signing] for more information on the encoding format. | ||
pub fn signature_hash(&self) -> B256 { | ||
let mut buf = bytes::BytesMut::with_capacity(self.payload_len_for_signature()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should just be Vec
@@ -49,6 +251,175 @@ pub struct EIP2930TransactionRequest { | |||
pub access_list: AccessList, | |||
} | |||
|
|||
impl Encodable for EIP2930TransactionRequest { | |||
fn encode(&self, out: &mut dyn BufMut) { | |||
self.chain_id.encode(out); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
@@ -63,6 +434,183 @@ pub struct EIP1559TransactionRequest { | |||
pub access_list: AccessList, | |||
} | |||
|
|||
impl Encodable for EIP1559TransactionRequest { | |||
fn encode(&self, out: &mut dyn BufMut) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
* chore: remove self: sync from defs * chore: remove most generics * chore: default for BlockId * chore: remove unnecesary reassignment * chore: auto impl on mut/rc * chore: unnecesary assignment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright let's send it. @Evalir you wanna take any follow-ups to this that we didn't address yet?
Motivation
I am currently migrating Foundry to use Alloy's providers instead of Ether's middleware. To make migration easier later on when we have the final API down I am introducing a temporary trait for the current
Provider
struct.Additionally, some RPC methods were either incomplete or missing.
Solution
Todo
PR Checklist
Depends on #28