alloy-rs / core Goto Github PK
View Code? Open in Web Editor NEWHigh-performance, well-tested & documented core libraries for Ethereum, in Rust
Home Page: https://alloy.rs
License: Apache License 2.0
High-performance, well-tested & documented core libraries for Ethereum, in Rust
Home Page: https://alloy.rs
License: Apache License 2.0
Custom types are Solidity paths, and currently we panic if it's longer than 1 ident.
No response
have sol!
generate SolCall
structs for auto-generated getters for storage vars and mappings
No response
sol-type, sol! macro
core/crates/sol-macro/src/expand/type.rs
Lines 71 to 72 in f6f3a4f
No response
Support ABI, and parsing it from JSON. Like ethabi::Contract
.
cc @prestwich
I'll refactor this file after this is merged, it's also getting pretty big
Originally posted by @DaniPopes in #83 (comment)
type_data_size
multiples array length by inner_size, which will incorrectly calculate lengths and incorrectly inner_size
expressions.
https://github.com/alloy-rs/core/blob/main/crates/sol-macro/src/expand/type.rs#L159-L179
blocker for #85
current behavior:
struct Foo {
address[] baz;
}
/// Nested struct.
struct Nested {
Foo[2] a;
}
produces code like this:
0usize
+ 2usize * (0usize + 32usize + 64usize + self.a.baz.len() * (32usize))
correct behavior:
0usize
+ self.a.iter().map( |element| /* inner size expression for element */ ).sum::<usize>()
2 incorrect things:
Foo.a
are the same sizeboth of these would be resolved using an iter in the expansion
sol! macro
v0.2.0
Linux
I think the problem is related to deposit
taking in no arguments.
use alloy_sol_types::{sol, SolCall};
sol! {
interface WETH {
function deposit() external payable;
}
}
fn main() {
WETH::depositCall::decode(&WETH::depositCall::SELECTOR, true).expect("it should work");
}
Like iterators from ethabi::*
Use cargo workspace deps
syn-solidity
Listed in the description of #119
No response
Rename SolError::Tuple
to SolError::Parameters
, SolCall::Tuple
to SolCall::Arguments
Should #[repr(u8)]
, add convert functions and impl SolType
(new SolEnum
trait?)
There is nothing done at run-time, so it should be a compile-time constant
should we rename to `canonical_type` to match solidity spec?
Originally posted by @prestwich in #104 (comment)
No response
Exported macro_rules!
that wrap hex_literal::hex!
with $crate::<type>
constructors. Also re-export hex!
itself
No response
No response
No response
None
No response
json-abi
Add a borrowed version of all json-abi
types, which implement ToOwned
. Ideally methods are implemented only once, with the owned version implementing Deref
towards the borrowed type, but this might not be fully doable.
This might also allow declaring the entire ABI as a const
/static
by setting the lifetime to 'static
.
Refs: #136
Blockers
pre-pub actions
pub
Post pub
ruint
ruint
(blocks primitives publishing)currently the type
field is unparsed, while ethabi
users expect a parsed ParamKind
enum. This would also remove the intermediate enum between the {Simple,Complex}
structs
compilation requires the feature to be selected, whether via dep or dev-dep. All consuming libraries using wasm must set this feature in deps or dev-deps
SolError
and SolFunctionCall
would be awesome
Needs #72.
File
#[sol(...)]
attributes, maybe #![sol(include = "path/to/abi.json")]
TokenStream
, and call sol
I think this can be done in another PR, since we don't handle any type of function (constructor, fallback...) other than literally `function`
Originally posted by @DaniPopes in #153 (comment)
Similar to the way error & panic are included in the base lib, we should consider including fallback and receive as hard-coded types. This requires special handling, as they have no selector
> But we're cloning the data to get the inner tuple, so this is not ideal
I'm gonna think about this a bit more. what do you think of this:
trait SolType {
type BorrowAbstraction: From<Self::RustType>;
fn encode<T: Into<Self::BorrowAbstraction>>(t: T)
}
pub enum TupleBorrowAbstraction<'t, 'u, T, U> {
Owned((T,U)),
Borrowed(&'t (T, U)),
MembersBorrowed((&'t T, &'u U))
}
// From impls here
Originally posted by @prestwich in #83 (comment)
dyn-abi is poorly tested. We should port the tests
the tests that need to be ported are in `sol-type`
Originally posted by @prestwich in #75 (comment)
sol-type, sol! macro
Currently we generate a ContractErrors
enum, which is fine for custom errors but cannot be used to also decode Solidity panics and reverts.
We should provide some way to easily decode all of the above in one method
No response
Input
, minus lone Type
s and other contracts. Needs also adjusting logic for resolving stuff recursively inside of it toosol-types/tests/doc_contracts.rs
and UI testsCan users use .into()
the way they'd expect
Port serde_helpers from old ethers, as a new crate ethers-serde
sol-type
No response
macOS (Apple Silicon)
(de)Tokenization logic does not properly handle ints whose length is different from the rust type's length. causes panic in the copy_from_slice in the macro
#[test]
fn tokenizing_int_sizes() {
Uint::<24>::tokenize(&1u32);
let word: [u8; 32] = (0..32).collect::<Vec<u8>>().try_into().unwrap();
let word: WordToken = word.into();
assert_eq!(Uint::<24>::detokenize(word), 126495);
}```
SolEvent
traitsol!
support, similar implementation to error.rs
Benchmark from #57, as of commit 64bf519:
ethabi/encode/single time: [82.202 ns 82.358 ns 82.525 ns]
ethabi/encode/struct time: [164.10 ns 165.43 ns 166.85 ns]
ethabi/decode/word time: [34.678 ns 34.765 ns 34.861 ns]
ethabi/decode/dynamic time: [78.638 ns 78.759 ns 78.910 ns]
dyn-abi/encode/single time: [68.373 ns 68.550 ns 68.741 ns]
dyn-abi/encode/struct time: [683.96 ns 684.70 ns 685.52 ns]
dyn-abi/decode/word time: [54.141 ns 54.203 ns 54.266 ns]
dyn-abi/decode/dynamic time: [80.822 ns 80.932 ns 81.053 ns]
sol-types/encode/single time: [42.843 ns 43.007 ns 43.207 ns]
sol-types/encode/struct time: [49.110 ns 49.171 ns 49.235 ns]
sol-types/decode/word time: [1.3375 ns 1.3389 ns 1.3405 ns]
sol-types/decode/dynamic
time: [39.279 ns 39.478 ns 39.721 ns]
Maybe we can skip tokenizing by encoding directly the DynSolValue
? Looking at the "struct"
bench, ethabi is much more concise because of ethabi::encode(tokens: &[ethabi::Token])
, while dyn-abi has to declare all the types, and then also clone the input on each call.
Originally posted by @DaniPopes in #57 (comment)
port from ethers-rs
To consider: should we error if there are too many topics in the iterator?
Originally posted by @prestwich in #83 (comment)
Wrap the visitor macro impl with paste::paste! {}
and wrap function names: [<visit_... $(_ $mut)?>]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.