@@ -28,6 +28,7 @@ import {
2828 isAddressEqual ,
2929 pad ,
3030 toEventSelector ,
31+ trim ,
3132 zeroAddress ,
3233 zeroHash ,
3334} from 'viem' ;
@@ -1407,6 +1408,21 @@ export function detectSignatureType(signature: Hex): SignatureType {
14071408 throw new Error ( 'Invalid signature format' ) ;
14081409}
14091410
1411+ /**
1412+ * Normalizes a hex value to ensure proper byte padding.
1413+ * This prevents viem's automatic padding which can change the value.
1414+ * For example:
1415+ * - "0x1" -> "0x01"
1416+ * - "0xabc" -> "0x0abc"
1417+ * - "0xabcd" -> "0xabcd"
1418+ *
1419+ * @param {Hex } value - The hex value to normalize
1420+ * @returns {Hex } The normalized hex string
1421+ */
1422+ function normalizeUintValue ( value : Hex ) : Hex {
1423+ return trim ( pad ( value ) ) ;
1424+ }
1425+
14101426/**
14111427 * Function to properly encode an event action payload.
14121428 *
@@ -1546,6 +1562,15 @@ export function prepareEventActionPayload({
15461562 detectSignatureType ( actionStepOne . signature ) ,
15471563 signature : pad ( actionStepOne . signature ) ,
15481564 actionType : actionStepOne . actionType || 0 ,
1565+ actionParameter :
1566+ actionStepOne . actionParameter . fieldType === PrimitiveType . UINT
1567+ ? {
1568+ ...actionStepOne . actionParameter ,
1569+ filterData : normalizeUintValue (
1570+ actionStepOne . actionParameter . filterData ,
1571+ ) ,
1572+ }
1573+ : actionStepOne . actionParameter ,
15491574 } ,
15501575 actionStepTwo : {
15511576 ..._toRawActionStep ( actionStepTwo ) ,
@@ -1554,6 +1579,15 @@ export function prepareEventActionPayload({
15541579 detectSignatureType ( actionStepTwo . signature ) ,
15551580 signature : pad ( actionStepTwo . signature ) ,
15561581 actionType : actionStepTwo . actionType || 0 ,
1582+ actionParameter :
1583+ actionStepTwo . actionParameter . fieldType === PrimitiveType . UINT
1584+ ? {
1585+ ...actionStepTwo . actionParameter ,
1586+ filterData : normalizeUintValue (
1587+ actionStepTwo . actionParameter . filterData ,
1588+ ) ,
1589+ }
1590+ : actionStepTwo . actionParameter ,
15571591 } ,
15581592 actionStepThree : {
15591593 ..._toRawActionStep ( actionStepThree ) ,
@@ -1562,6 +1596,15 @@ export function prepareEventActionPayload({
15621596 detectSignatureType ( actionStepThree . signature ) ,
15631597 signature : pad ( actionStepThree . signature ) ,
15641598 actionType : actionStepThree . actionType || 0 ,
1599+ actionParameter :
1600+ actionStepThree . actionParameter . fieldType === PrimitiveType . UINT
1601+ ? {
1602+ ...actionStepThree . actionParameter ,
1603+ filterData : normalizeUintValue (
1604+ actionStepThree . actionParameter . filterData ,
1605+ ) ,
1606+ }
1607+ : actionStepThree . actionParameter ,
15651608 } ,
15661609 actionStepFour : {
15671610 ..._toRawActionStep ( actionStepFour ) ,
@@ -1570,6 +1613,15 @@ export function prepareEventActionPayload({
15701613 detectSignatureType ( actionStepFour . signature ) ,
15711614 signature : pad ( actionStepFour . signature ) ,
15721615 actionType : actionStepFour . actionType || 0 ,
1616+ actionParameter :
1617+ actionStepFour . actionParameter . fieldType === PrimitiveType . UINT
1618+ ? {
1619+ ...actionStepFour . actionParameter ,
1620+ filterData : normalizeUintValue (
1621+ actionStepFour . actionParameter . filterData ,
1622+ ) ,
1623+ }
1624+ : actionStepFour . actionParameter ,
15731625 } ,
15741626 } ,
15751627 ] ,
0 commit comments