-
Notifications
You must be signed in to change notification settings - Fork 280
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: network abstraction and transaction builder #190
Changes from all commits
d030974
668d3d0
a698dee
dfbc394
6e1b1ee
8c5c484
66cf994
bc5f084
6e4e7d2
b809324
98b7c67
13e9a3b
f6b8e00
16b328e
b3db0fe
126a4b7
92cf293
5f195ba
9d3f6d3
b419d25
105fc61
c89e5a4
f3541d2
07d5aea
d88eba1
5dcd259
5d0a548
ac07332
264daa1
136cf84
043cef3
34b76ee
2404e88
288959f
201df2b
14d8329
5372ae0
abf6e4b
04158ea
4715b3e
b04e966
89c8c01
d5585ad
290beab
d897d2e
e228a61
ff555ab
dbf7f7f
dc18b0d
8afa99c
6f9b180
a7be381
17eb93a
bf86056
5210141
69bb2e1
9324861
2425bc9
95f22db
5a41fbb
6e03867
ceb865a
ad9c520
81c98a5
d2a349e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,10 +41,18 @@ alloy-transport-ipc = { version = "0.1.0", default-features = false, path = "cra | |
alloy-transport-ws = { version = "0.1.0", default-features = false, path = "crates/transport-ws" } | ||
|
||
alloy-core = { version = "0.6.4", default-features = false, features = ["std"] } | ||
alloy-dyn-abi = { version = "0.6.4", default-features = false, features = ["std"] } | ||
alloy-json-abi = { version = "0.6.4", default-features = false, features = ["std"] } | ||
alloy-primitives = { version = "0.6.4", default-features = false, features = ["std"] } | ||
alloy-sol-types = { version = "0.6.4", default-features = false, features = ["std"] } | ||
alloy-dyn-abi = { version = "0.6.4", default-features = false, features = [ | ||
"std", | ||
] } | ||
alloy-json-abi = { version = "0.6.4", default-features = false, features = [ | ||
"std", | ||
] } | ||
alloy-primitives = { version = "0.6.4", default-features = false, features = [ | ||
"std", | ||
] } | ||
alloy-sol-types = { version = "0.6.4", default-features = false, features = [ | ||
"std", | ||
] } | ||
|
||
alloy-rlp = "0.3" | ||
|
||
|
@@ -53,8 +61,13 @@ ethereum_ssz_derive = "0.5" | |
ethereum_ssz = "0.5" | ||
|
||
# crypto | ||
elliptic-curve = { version = "0.13", default-features = false, features = ["std"] } | ||
k256 = { version = "0.13", default-features = false, features = ["ecdsa", "std"] } | ||
elliptic-curve = { version = "0.13", default-features = false, features = [ | ||
"std", | ||
] } | ||
k256 = { version = "0.13", default-features = false, features = [ | ||
"ecdsa", | ||
"std", | ||
] } | ||
sha2 = { version = "0.10", default-features = false, features = ["std"] } | ||
spki = { version = "0.7", default-features = false, features = ["std"] } | ||
|
||
|
@@ -102,5 +115,5 @@ tempfile = "3.10" | |
|
||
# TODO: Keep around until alloy-contract is stable. | ||
# This should only be used in `alloy-contract` tests. | ||
# [patch.crates-io] | ||
# alloy-sol-macro = { git = "https://github.com/alloy-rs/core", rev = "18b0509950c90d9ec38f25913b692ae4cdd6f227" } | ||
[patch.crates-io] | ||
alloy-sol-macro = { git = "https://github.com/alloy-rs/core", rev = "ab0cab1047a088be6cffa4e7a2fcde7cf77aa460" } | ||
Comment on lines
+118
to
+119
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is now on main so can remove I think? Or still needed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will keep it until release |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use crate::Transaction; | ||
use crate::transaction::SignableTransaction; | ||
use alloy_primitives::{Signature, B256}; | ||
use alloy_rlp::BufMut; | ||
|
||
|
@@ -35,9 +35,9 @@ impl<T, Sig> Signed<T, Sig> { | |
} | ||
} | ||
|
||
impl<T: Transaction> Signed<T> { | ||
impl<T: SignableTransaction<Sig>, Sig> Signed<T, Sig> { | ||
/// Instantiate from a transaction and signature. Does not verify the signature. | ||
pub const fn new_unchecked(tx: T, signature: Signature, hash: B256) -> Self { | ||
pub const fn new_unchecked(tx: T, signature: Sig, hash: B256) -> Self { | ||
Self { tx, signature, hash } | ||
} | ||
|
||
|
@@ -59,22 +59,22 @@ impl<T: Transaction> Signed<T> { | |
} | ||
} | ||
|
||
impl<T: Transaction> alloy_rlp::Encodable for Signed<T> { | ||
impl<T: SignableTransaction<Sig>, Sig> alloy_rlp::Encodable for Signed<T, Sig> { | ||
fn encode(&self, out: &mut dyn BufMut) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i forget why we did Sig as a generic instead of associated type, maybe a follow-up breaking change to the trait could remove the double mention of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because transactions can be signed with multiple types of signatures on some networks |
||
self.tx.encode_signed(&self.signature, out) | ||
} | ||
|
||
// TODO: impl length | ||
} | ||
|
||
impl<T: Transaction> alloy_rlp::Decodable for Signed<T> { | ||
impl<T: SignableTransaction<Sig>, Sig> alloy_rlp::Decodable for Signed<T, Sig> { | ||
fn decode(buf: &mut &[u8]) -> alloy_rlp::Result<Self> { | ||
T::decode_signed(buf) | ||
<T as SignableTransaction<Sig>>::decode_signed(buf) | ||
} | ||
} | ||
|
||
#[cfg(feature = "k256")] | ||
impl<T: Transaction> Signed<T, Signature> { | ||
impl<T: SignableTransaction<Signature>> Signed<T, Signature> { | ||
/// Recover the signer of the transaction | ||
pub fn recover_signer( | ||
&self, | ||
|
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.
excluded because we now depend on
alloy-signer
which depends onrand
which is not wasm-compatible. the reasonalloy-signer
depends onrand
is for mnemonics, so a better long term solution would be to splitWallet
etc. into their own crate. will leave this for a follow upThere 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.
Yup -- let's make alloy-signer wasm compatilbe in follow up, should be easy
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.
#262