@@ -2,41 +2,31 @@ use core::hash::{Hash, HashStateExTrait, HashStateTrait};
22use core :: poseidon :: PoseidonTrait ;
33use openzeppelin :: utils :: snip12 :: StructHash ;
44use starknet :: ContractAddress ;
5- use starkware_utils :: signature :: stark :: { HashType , PublicKey } ;
5+ use starkware_utils :: signature :: stark :: HashType ;
66use starkware_utils :: time :: time :: Timestamp ;
77
88#[derive(Drop , Serde , Copy )]
99pub struct Order {
1010 pub salt : felt252 ,
1111 pub expiry : Timestamp ,
12- pub owner : ContractAddress ,
13- pub public_key : PublicKey ,
12+ pub user : ContractAddress ,
1413 pub sell_token : ContractAddress ,
1514 pub buy_token : ContractAddress ,
1615 pub sell_amount : u128 ,
1716 pub buy_amount : u128 ,
18- // Addresses the user is willing to trade with. Empty means any address
17+ // Addresses the user is willing to trade with. Empty span means any address.
1918 pub allowed_addresses : Span <ContractAddress >,
2019}
2120
2221pub impl HashOrderImpl <S , + HashStateTrait <S >, + Drop <S >> of Hash <Order , S > {
2322 fn update_state (mut state : S , value : Order ) -> S {
2423 let Order {
25- salt ,
26- expiry ,
27- owner ,
28- public_key ,
29- sell_token ,
30- buy_token ,
31- sell_amount ,
32- buy_amount ,
33- allowed_addresses ,
24+ salt , expiry , user , sell_token , buy_token , sell_amount , buy_amount , allowed_addresses ,
3425 } = value ;
3526 state = state
3627 . update_with (salt )
3728 . update_with (expiry )
38- . update_with (owner )
39- . update_with (public_key )
29+ . update_with (user )
4030 . update_with (sell_token )
4131 . update_with (buy_token )
4232 . update_with (sell_amount )
@@ -55,8 +45,7 @@ pub impl HashOrderImpl<S, +HashStateTrait<S>, +Drop<S>> of Hash<Order, S> {
5545/// "\"Order\"(
5646/// \"salt\":\"felt\",
5747/// \"expiry\":\"Timestamp\",
58- /// \"owner\":\"ContractAddress\",
59- /// \"public_key\":\"PublicKey\",
48+ /// \"user\":\"ContractAddress\",
6049/// \"sell_token\":\"ContractAddress\",
6150/// \"buy_token\":\"ContractAddress\",
6251/// \"sell_amount\":\"u128\",
@@ -68,7 +57,7 @@ pub impl HashOrderImpl<S, +HashStateTrait<S>, +Drop<S>> of Hash<Order, S> {
6857/// )
6958/// );
7059
71- const ORDER_TYPE_HASH : HashType = 0x110a09f78c9cd3ca416d13d90e38007ba8bde2f44ae77b5fd037cb9bfb68117 ;
60+ const ORDER_TYPE_HASH : HashType = 0x2d9dc4d67a6cc048d96cd39c037575fa17fc4f4ba67fa9307cd08d3aac3943b ;
7261
7362impl StructHashImpl of StructHash <Order > {
7463 fn hash_struct (self : @ Order ) -> HashType {
@@ -85,7 +74,7 @@ mod tests {
8574 #[test]
8675 fn test_order_type_hash () {
8776 let expected = selector! (
88- " \ " Order\ " (\ " salt\ " :\ " felt\ " ,\ " expiry\ " :\ " Timestamp\ " ,\ "owner \ " :\ " ContractAddress\ " , \ " public_key \ " : \ " PublicKey \ " ,\ " sell_token\ " :\ " ContractAddress\ " ,\ " buy_token\ " :\ " ContractAddress\ " ,\ " sell_amount\ " :\ " u128\ " ,\ " buy_amount\ " :\ " u128\ " ,\ " allowed_addresses\ " :\ " Span<ContractAddress>\ " )\ " Timestamp\ " (\ " seconds\ " :\ " u64\ " )" ,
77+ " \ " Order\ " (\ " salt\ " :\ " felt\ " ,\ " expiry\ " :\ " Timestamp\ " ,\ "user \ " :\ " ContractAddress\ " ,\ " sell_token\ " :\ " ContractAddress\ " ,\ " buy_token\ " :\ " ContractAddress\ " ,\ " sell_amount\ " :\ " u128\ " ,\ " buy_amount\ " :\ " u128\ " ,\ " allowed_addresses\ " :\ " Span<ContractAddress>\ " )\ " Timestamp\ " (\ " seconds\ " :\ " u64\ " )" ,
8978 );
9079 assert_eq! (ORDER_TYPE_HASH . into_base_16_string (), expected . into_base_16_string ());
9180 }
0 commit comments