Skip to content

Commit fb88a90

Browse files
committed
fixed toJSON fn
1 parent 1297ac4 commit fb88a90

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/sdk/common/OperationUtils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import { resolveProperties } from './utils';
22
import { BaseAccountUserOperationStruct } from '../types/user-operation-types';
33
import { toHex } from 'viem';
4+
import { BigNumber } from '../types/bignumber';
45

56
export function toJSON(op: Partial<BaseAccountUserOperationStruct>): Promise<any> {
67
return resolveProperties(op).then((userOp) =>
78
Object.keys(userOp)
89
.map((key) => {
910
let val = (userOp as any)[key];
10-
if (typeof val !== 'string' || !val.startsWith('0x')) {
11+
if (typeof val === 'object' && BigNumber.isBigNumber(val)) {
12+
val = val.toHexString()
13+
}
14+
else if (typeof val !== 'string' || !val.startsWith('0x')) {
1115
val = toHex(val);
1216
}
1317
return [key, val];

0 commit comments

Comments
 (0)