hyperliquid_rust_sdk_toaster 0.6.1

Rust SDK for Hyperliquid - toaster fork
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use alloy::{
    dyn_abi::Eip712Domain,
    primitives::{keccak256, B256},
};

pub trait Eip712 {
    fn domain(&self) -> Eip712Domain;
    fn struct_hash(&self) -> B256;

    fn eip712_signing_hash(&self) -> B256 {
        let mut digest_input = [0u8; 2 + 32 + 32];
        digest_input[0] = 0x19;
        digest_input[1] = 0x01;
        digest_input[2..34].copy_from_slice(&self.domain().hash_struct()[..]);
        digest_input[34..66].copy_from_slice(&self.struct_hash()[..]);
        keccak256(digest_input)
    }
}