@@ -72,14 +72,16 @@ pub struct PswapNoteStorage {
7272 /// executed transaction's output).
7373 #[ builder( default = NoteType :: Private ) ]
7474 payback_note_type : NoteType ,
75+ /// Minimum fill amount. If None, no minimum is enforced.
76+ min_fill_amount : Option < u64 > ,
7577}
7678
7779impl PswapNoteStorage {
7880 // CONSTANTS
7981 // --------------------------------------------------------------------------------------------
8082
8183 /// Expected number of storage items for the PSWAP note.
82- pub const NUM_STORAGE_ITEMS : usize = 6 ;
84+ pub const NUM_STORAGE_ITEMS : usize = 8 ;
8385
8486 /// Consumes the storage and returns a PSWAP [`NoteRecipient`] with the provided serial number.
8587 pub fn into_recipient ( self , serial_num : Word ) -> NoteRecipient {
@@ -130,9 +132,11 @@ impl From<PswapNoteStorage> for NoteStorage {
130132 Felt :: from( storage. min_requested_asset. amount( ) ) ,
131133 // Payback note type [3]
132134 Felt :: from( storage. payback_note_type. as_u8( ) ) ,
133- // Creator ID [4-5]
134- storage. creator_account_id. prefix( ) . as_felt( ) ,
135+ // Creator ID [5-6] — FIXED: suffix first, then prefix
135136 storage. creator_account_id. suffix( ) ,
137+ storage. creator_account_id. prefix( ) . as_felt( ) ,
138+ // min_fill_amount [7]
139+ Felt :: new( storage. min_fill_amount. unwrap_or( 0 ) ) . expect( "min_fill_amount is valid" ) ,
136140 ] ;
137141 NoteStorage :: new ( storage_items)
138142 . expect ( "number of storage items should not exceed max storage items" )
@@ -167,14 +171,19 @@ impl TryFrom<&[Felt]> for PswapNoteStorage {
167171 )
168172 . map_err ( |e| NoteError :: other_with_source ( "failed to parse payback note type" , e) ) ?;
169173
170- // [4-5 ] = creator account ID (prefix, suffix)
171- let creator_account_id = AccountId :: try_from_elements ( note_storage[ 5 ] , note_storage[ 4 ] )
174+ // [5-6 ] = creator account ID (suffix, prefix) — FIXED
175+ let creator_account_id = AccountId :: try_from_elements ( note_storage[ 5 ] , note_storage[ 6 ] )
172176 . map_err ( |e| NoteError :: other_with_source ( "failed to parse creator account ID" , e) ) ?;
173177
178+ // [7] = min_fill_amount
179+ let min_fill_amount = note_storage[ 7 ] . as_canonical_u64 ( ) ;
180+ let min_fill_amount = if min_fill_amount == 0 { None } else { Some ( min_fill_amount) } ;
181+
174182 Ok ( Self {
175183 min_requested_asset,
176184 creator_account_id,
177185 payback_note_type,
186+ min_fill_amount,
178187 } )
179188 }
180189}
@@ -1035,8 +1044,9 @@ mod tests {
10351044 min_requested_asset. faucet_id( ) . prefix( ) . as_felt( ) ,
10361045 Felt :: from( min_requested_asset. amount( ) ) ,
10371046 Felt :: from( NoteType :: Private . as_u8( ) ) , // payback_note_type
1038- creator_id. prefix( ) . as_felt( ) ,
10391047 creator_id. suffix( ) ,
1048+ creator_id. prefix( ) . as_felt( ) ,
1049+ Felt :: ZERO , // min_fill_amount = None
10401050 ] ;
10411051
10421052 let parsed = PswapNoteStorage :: try_from ( storage_items. as_slice ( ) ) . unwrap ( ) ;
0 commit comments