-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiff.txt
More file actions
78 lines (74 loc) · 2.8 KB
/
diff.txt
File metadata and controls
78 lines (74 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
diff --git a/frontend/src/app/api/order/resolver.ts b/frontend/src/app/api/order/resolver.ts
index 3499b03..1121b79 100644
--- a/frontend/src/app/api/order/resolver.ts
+++ b/frontend/src/app/api/order/resolver.ts
@@ -25,21 +25,38 @@ export const deploySrcCallData = (
) => {
// Removed client-side logging to reduce noise
- const { r, yParityAndS: vs } = Signature.from(signature);
+ const sig = Signature.from(signature);
+ const rHex = sig.r;
+ const sHex = sig.s;
+ const vValue = sig.v;
- // Ensure r and vs are proper 32-byte hex strings (bytes32)
- const rHex =
- typeof r === "string" ? r : (r as { toString(): string }).toString();
- const vsHex =
- typeof vs === "string" ? vs : (vs as { toString(): string }).toString();
+ // Ensure r and s are proper 32-byte hex strings (bytes32)
+ const rHexString = typeof rHex === "string" ? rHex : String(rHex);
+ const sHexString = typeof sHex === "string" ? sHex : String(sHex);
+
+ // Calculate vs: s with recovery ID (v) encoded in the high bit
+ // vs = s + (v << 255) where v is 0 or 1
+ const sBigInt = BigInt(sHexString);
+ const vsBigInt = sBigInt + (BigInt(vValue) << BigInt(255));
+ const vsHex = "0x" + vsBigInt.toString(16).padStart(64, "0");
// Validate that r and vs are proper 32-byte hex strings
- if (!rHex.startsWith("0x") || rHex.length !== 66) {
- throw new Error(`Invalid r value: ${rHex} (expected 32-byte hex string)`);
+ if (!rHexString.startsWith("0x") || rHexString.length !== 66) {
+ throw new Error(
+ `Invalid r value: ${rHexString} (expected 32-byte hex string)`
+ );
}
if (!vsHex.startsWith("0x") || vsHex.length !== 66) {
throw new Error(`Invalid vs value: ${vsHex} (expected 32-byte hex string)`);
}
+
+ console.log("[DEBUG] Signature components:", {
+ r: rHexString,
+ s: sHexString,
+ v: vValue,
+ vs: vsHex,
+ originalSignature: signature,
+ });
const { trait } = takerTraits as { args: unknown; trait: unknown };
// Helper function to convert address string to uint256 BigInt
@@ -100,7 +117,7 @@ export const deploySrcCallData = (
typeof value === "bigint" ? value.toString() : value
)
);
- console.log("DEBUG: rHex:", rHex);
+ console.log("DEBUG: rHex:", rHexString);
console.log("DEBUG: vsHex:", vsHex);
console.log("DEBUG: amount:", amount);
console.log("DEBUG: trait:", trait);
@@ -110,7 +127,7 @@ export const deploySrcCallData = (
[
immutablesTuple,
orderTuple,
- rHex,
+ rHexString,
vsHex,
BigInt(amount),
BigInt(trait as string | number),
@@ -127,7 +144,7 @@ export const deploySrcCallData = (
// Include tuple data for contract interface fallback
immutablesTuple,
orderTuple,
- rHex,
+ rHex: rHexString,
vsHex,
};
} catch (error) {