-
Notifications
You must be signed in to change notification settings - Fork 470
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
EIP712 #169
Comments
@wysenynja We don't have that method exposed yet (PRs welcome!). You can freely extend rust-web3 though, you will just need to define all the input and output types and their deserialization. |
There is a separate crate which may fit the bill here: eip-712 |
Doesn't that conflict with this library's MIT license? |
@gakonst Correct, the crate mentioned here can't really be included in |
Dismayed by the licensing, I went ahead to build a replacement for the GPL licensed https://github.com/graphprotocol/eip-712-derive Example usage: struct Mail {
from: Person,
to: Person,
contents: String,
}
// This is all that is necessary to implement any EIP-712 signable struct
impl StructType for Mail {
const TYPE_NAME: &'static str = "Mail";
fn visit_members<T: MemberVisitor>(&self, visitor: &mut T) {
visitor.visit("from", &self.from);
visitor.visit("to", &self.to);
visitor.visit("contents", &self.contents);
}
}
/* Elided Person struct, etc */
fn test() -> (Signature, RecoveryId) {
let domain = DomainStruct {
name: "Ether Mail".to_owned(),
version: "1".to_owned(),
chain_id: chain_id::MAIN_NET,
verifying_contract: Address(
(&(hex::decode("CcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC").unwrap())[..])
.try_into()
.unwrap(),
),
};
let domain_separator = DomainSeparator::new(&domain);
let message = Mail {
from: Person { /* elided */ },
to: Person { /* elided */ },
contents: "Hello, Bob!".to_owned(),
};
sign_typed(&domain_separator, &message, &pk)
} |
I'm wanting to hash 0x orders and they use EIP712. I'm trying to write this in rust and not javascript. Is this currently possible with rust-web3?
The text was updated successfully, but these errors were encountered: