@hyperbridge/sdk 2.3.3 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2335,6 +2335,57 @@ declare class CryptoUtils {
2335
2335
  * @returns The UserOperation hash as a hex string.
2336
2336
  */
2337
2337
  static computeUserOpHash(userOp: PackedUserOperation, entryPoint: Hex, chainId: bigint): Hex;
2338
+ /**
2339
+ * Derives the ERC-4337 nonce key that binds a bid UserOperation to its
2340
+ * order and session key: the lower 192 bits of
2341
+ * `keccak256(commitment ‖ sessionKey)`. `SolverAccount` rejects bid
2342
+ * operations whose nonce key differs — this is what lets the solver sign
2343
+ * the plain userOpHash while staying committed to the order and to the
2344
+ * session key it bid against.
2345
+ *
2346
+ * @param commitment - The order commitment (`order.id`).
2347
+ * @param sessionKey - The order's session key address (`order.session`).
2348
+ * @returns The 192-bit nonce key as a bigint (pass to `EntryPoint.getNonce`).
2349
+ */
2350
+ static bidNonceKey(commitment: HexString, sessionKey: HexString): bigint;
2351
+ /**
2352
+ * Builds the EIP-712 typed-data payload whose digest is the EntryPoint v0.8
2353
+ * `userOpHash` (i.e. `hashTypedData(packedUserOpTypedData(...)) ===
2354
+ * computeUserOpHash(...)`). Signing this typed data is bit-identical to
2355
+ * signing the raw userOpHash, but keeps the full operation visible to
2356
+ * signing infrastructure (hardware wallets, MPC/TEE policy engines) instead
2357
+ * of an opaque 32-byte digest.
2358
+ *
2359
+ * @param userOp - The packed UserOperation to sign (signature field ignored).
2360
+ * @param entryPoint - Address of the EntryPoint v0.8 contract.
2361
+ * @param chainId - Chain ID of the network on which the operation will execute.
2362
+ * @returns A viem `TypedDataDefinition` for the operation.
2363
+ */
2364
+ static packedUserOpTypedData(userOp: PackedUserOperation, entryPoint: Hex, chainId: bigint): {
2365
+ domain: {
2366
+ name: string;
2367
+ version: string;
2368
+ chainId: bigint;
2369
+ verifyingContract: `0x${string}`;
2370
+ };
2371
+ types: {
2372
+ PackedUserOperation: {
2373
+ name: string;
2374
+ type: string;
2375
+ }[];
2376
+ };
2377
+ primaryType: "PackedUserOperation";
2378
+ message: {
2379
+ sender: `0x${string}`;
2380
+ nonce: bigint;
2381
+ initCode: `0x${string}`;
2382
+ callData: `0x${string}`;
2383
+ accountGasLimits: `0x${string}`;
2384
+ preVerificationGas: bigint;
2385
+ gasFees: `0x${string}`;
2386
+ paymasterAndData: `0x${string}`;
2387
+ };
2388
+ };
2338
2389
  /**
2339
2390
  * Computes the EIP-712 struct hash of a `PackedUserOperation`.
2340
2391
  *
@@ -2335,6 +2335,57 @@ declare class CryptoUtils {
2335
2335
  * @returns The UserOperation hash as a hex string.
2336
2336
  */
2337
2337
  static computeUserOpHash(userOp: PackedUserOperation, entryPoint: Hex, chainId: bigint): Hex;
2338
+ /**
2339
+ * Derives the ERC-4337 nonce key that binds a bid UserOperation to its
2340
+ * order and session key: the lower 192 bits of
2341
+ * `keccak256(commitment ‖ sessionKey)`. `SolverAccount` rejects bid
2342
+ * operations whose nonce key differs — this is what lets the solver sign
2343
+ * the plain userOpHash while staying committed to the order and to the
2344
+ * session key it bid against.
2345
+ *
2346
+ * @param commitment - The order commitment (`order.id`).
2347
+ * @param sessionKey - The order's session key address (`order.session`).
2348
+ * @returns The 192-bit nonce key as a bigint (pass to `EntryPoint.getNonce`).
2349
+ */
2350
+ static bidNonceKey(commitment: HexString, sessionKey: HexString): bigint;
2351
+ /**
2352
+ * Builds the EIP-712 typed-data payload whose digest is the EntryPoint v0.8
2353
+ * `userOpHash` (i.e. `hashTypedData(packedUserOpTypedData(...)) ===
2354
+ * computeUserOpHash(...)`). Signing this typed data is bit-identical to
2355
+ * signing the raw userOpHash, but keeps the full operation visible to
2356
+ * signing infrastructure (hardware wallets, MPC/TEE policy engines) instead
2357
+ * of an opaque 32-byte digest.
2358
+ *
2359
+ * @param userOp - The packed UserOperation to sign (signature field ignored).
2360
+ * @param entryPoint - Address of the EntryPoint v0.8 contract.
2361
+ * @param chainId - Chain ID of the network on which the operation will execute.
2362
+ * @returns A viem `TypedDataDefinition` for the operation.
2363
+ */
2364
+ static packedUserOpTypedData(userOp: PackedUserOperation, entryPoint: Hex, chainId: bigint): {
2365
+ domain: {
2366
+ name: string;
2367
+ version: string;
2368
+ chainId: bigint;
2369
+ verifyingContract: `0x${string}`;
2370
+ };
2371
+ types: {
2372
+ PackedUserOperation: {
2373
+ name: string;
2374
+ type: string;
2375
+ }[];
2376
+ };
2377
+ primaryType: "PackedUserOperation";
2378
+ message: {
2379
+ sender: `0x${string}`;
2380
+ nonce: bigint;
2381
+ initCode: `0x${string}`;
2382
+ callData: `0x${string}`;
2383
+ accountGasLimits: `0x${string}`;
2384
+ preVerificationGas: bigint;
2385
+ gasFees: `0x${string}`;
2386
+ paymasterAndData: `0x${string}`;
2387
+ };
2388
+ };
2338
2389
  /**
2339
2390
  * Computes the EIP-712 struct hash of a `PackedUserOperation`.
2340
2391
  *
@@ -2585,7 +2585,7 @@ var chainConfigs = {
2585
2585
  UniswapV3Quoter: "0x0000000000000000000000000000000000000000",
2586
2586
  UniswapV4Quoter: "0x0000000000000000000000000000000000000000",
2587
2587
  EntryPointV08: "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108",
2588
- SolverAccount: "0x07FeC66d967800998060194EaECDd7C66dA4a1B1"
2588
+ SolverAccount: "0x110C7E1814c923127469Ca8939a12dAa70B96a17"
2589
2589
  },
2590
2590
  rpcEnvKey: "BSC_CHAPEL",
2591
2591
  defaultRpcUrl: "https://bnb-testnet.api.onfinality.io/public",
@@ -2693,7 +2693,7 @@ var chainConfigs = {
2693
2693
  },
2694
2694
  addresses: {
2695
2695
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
2696
- SolverAccount: "0x975e80B476cB1d4Cd06c292ce36898f2bE4159ea",
2696
+ SolverAccount: "0x3bdB532d91F165BeFad5542700205f5BB5152a82",
2697
2697
  TokenGateway: "0xFd413e3AFe560182C4471F4d143A96d3e259B6dE",
2698
2698
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
2699
2699
  UniswapRouter02: "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D",
@@ -2748,7 +2748,7 @@ var chainConfigs = {
2748
2748
  },
2749
2749
  addresses: {
2750
2750
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
2751
- SolverAccount: "0x975e80B476cB1d4Cd06c292ce36898f2bE4159ea",
2751
+ SolverAccount: "0x3bdB532d91F165BeFad5542700205f5BB5152a82",
2752
2752
  TokenGateway: "0xFd413e3AFe560182C4471F4d143A96d3e259B6dE",
2753
2753
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
2754
2754
  UniswapRouter02: "0x10ED43C718714eb63d5aA57B78B54704E256024E",
@@ -2804,7 +2804,7 @@ var chainConfigs = {
2804
2804
  },
2805
2805
  addresses: {
2806
2806
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
2807
- SolverAccount: "0x975e80B476cB1d4Cd06c292ce36898f2bE4159ea",
2807
+ SolverAccount: "0x3bdB532d91F165BeFad5542700205f5BB5152a82",
2808
2808
  TokenGateway: "0xFd413e3AFe560182C4471F4d143A96d3e259B6dE",
2809
2809
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
2810
2810
  UniswapRouter02: "0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24",
@@ -2861,7 +2861,7 @@ var chainConfigs = {
2861
2861
  },
2862
2862
  addresses: {
2863
2863
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
2864
- SolverAccount: "0x975e80B476cB1d4Cd06c292ce36898f2bE4159ea",
2864
+ SolverAccount: "0x3bdB532d91F165BeFad5542700205f5BB5152a82",
2865
2865
  TokenGateway: "0xFd413e3AFe560182C4471F4d143A96d3e259B6dE",
2866
2866
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
2867
2867
  UniswapRouter02: "0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24",
@@ -2920,7 +2920,7 @@ var chainConfigs = {
2920
2920
  },
2921
2921
  addresses: {
2922
2922
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
2923
- SolverAccount: "0x975e80B476cB1d4Cd06c292ce36898f2bE4159ea",
2923
+ SolverAccount: "0x3bdB532d91F165BeFad5542700205f5BB5152a82",
2924
2924
  TokenGateway: "0x8b536105b6Fae2aE9199f5146D3C57Dfe53b614E",
2925
2925
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
2926
2926
  UniswapRouter02: "0xd2f9496824951D5237cC71245D659E48d0d5f9E8",
@@ -3007,7 +3007,7 @@ var chainConfigs = {
3007
3007
  Calldispatcher: "0x876F1891982E260026630c233A4897160A281Fb8",
3008
3008
  Permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
3009
3009
  EntryPointV08: "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108",
3010
- SolverAccount: "0x07FeC66d967800998060194EaECDd7C66dA4a1B1"
3010
+ SolverAccount: "0x110C7E1814c923127469Ca8939a12dAa70B96a17"
3011
3011
  },
3012
3012
  rpcEnvKey: "POLYGON_AMOY",
3013
3013
  defaultRpcUrl: "https://rpc-amoy.polygon.technology",
@@ -3031,7 +3031,7 @@ var chainConfigs = {
3031
3031
  },
3032
3032
  addresses: {
3033
3033
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
3034
- SolverAccount: "0x975e80B476cB1d4Cd06c292ce36898f2bE4159ea",
3034
+ SolverAccount: "0x3bdB532d91F165BeFad5542700205f5BB5152a82",
3035
3035
  TokenGateway: "0xFd413e3AFe560182C4471F4d143A96d3e259B6dE",
3036
3036
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
3037
3037
  UniswapRouter02: "0x4A7b5Da61326A6379179b40d00F57E5bbDC962c2",
@@ -3066,7 +3066,7 @@ var chainConfigs = {
3066
3066
  },
3067
3067
  addresses: {
3068
3068
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
3069
- SolverAccount: "0x975e80B476cB1d4Cd06c292ce36898f2bE4159ea",
3069
+ SolverAccount: "0x3bdB532d91F165BeFad5542700205f5BB5152a82",
3070
3070
  TokenGateway: "0xFd413e3AFe560182C4471F4d143A96d3e259B6dE",
3071
3071
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
3072
3072
  UniswapRouter02: "0xB2e26652e4BAd1e56055A051f922E06760cA0BFE",
@@ -3221,7 +3221,7 @@ var chainConfigs = {
3221
3221
  },
3222
3222
  addresses: {
3223
3223
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
3224
- SolverAccount: "0x975e80B476cB1d4Cd06c292ce36898f2bE4159ea",
3224
+ SolverAccount: "0x3bdB532d91F165BeFad5542700205f5BB5152a82",
3225
3225
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
3226
3226
  Calldispatcher: "0xE2C7e576E26E0bE7aC97c6fE925bcDAbD87c4bEd"
3227
3227
  },
@@ -14763,6 +14763,67 @@ var CryptoUtils = class _CryptoUtils {
14763
14763
  encodePacked(["bytes1", "bytes1", "bytes32", "bytes32"], ["0x19", "0x01", domainSeparator, structHash])
14764
14764
  );
14765
14765
  }
14766
+ /**
14767
+ * Derives the ERC-4337 nonce key that binds a bid UserOperation to its
14768
+ * order and session key: the lower 192 bits of
14769
+ * `keccak256(commitment ‖ sessionKey)`. `SolverAccount` rejects bid
14770
+ * operations whose nonce key differs — this is what lets the solver sign
14771
+ * the plain userOpHash while staying committed to the order and to the
14772
+ * session key it bid against.
14773
+ *
14774
+ * @param commitment - The order commitment (`order.id`).
14775
+ * @param sessionKey - The order's session key address (`order.session`).
14776
+ * @returns The 192-bit nonce key as a bigint (pass to `EntryPoint.getNonce`).
14777
+ */
14778
+ static bidNonceKey(commitment, sessionKey) {
14779
+ return BigInt(keccak256(encodePacked(["bytes32", "address"], [commitment, sessionKey]))) & (1n << 192n) - 1n;
14780
+ }
14781
+ /**
14782
+ * Builds the EIP-712 typed-data payload whose digest is the EntryPoint v0.8
14783
+ * `userOpHash` (i.e. `hashTypedData(packedUserOpTypedData(...)) ===
14784
+ * computeUserOpHash(...)`). Signing this typed data is bit-identical to
14785
+ * signing the raw userOpHash, but keeps the full operation visible to
14786
+ * signing infrastructure (hardware wallets, MPC/TEE policy engines) instead
14787
+ * of an opaque 32-byte digest.
14788
+ *
14789
+ * @param userOp - The packed UserOperation to sign (signature field ignored).
14790
+ * @param entryPoint - Address of the EntryPoint v0.8 contract.
14791
+ * @param chainId - Chain ID of the network on which the operation will execute.
14792
+ * @returns A viem `TypedDataDefinition` for the operation.
14793
+ */
14794
+ static packedUserOpTypedData(userOp, entryPoint, chainId) {
14795
+ return {
14796
+ domain: {
14797
+ name: "ERC4337",
14798
+ version: "1",
14799
+ chainId,
14800
+ verifyingContract: entryPoint
14801
+ },
14802
+ types: {
14803
+ PackedUserOperation: [
14804
+ { name: "sender", type: "address" },
14805
+ { name: "nonce", type: "uint256" },
14806
+ { name: "initCode", type: "bytes" },
14807
+ { name: "callData", type: "bytes" },
14808
+ { name: "accountGasLimits", type: "bytes32" },
14809
+ { name: "preVerificationGas", type: "uint256" },
14810
+ { name: "gasFees", type: "bytes32" },
14811
+ { name: "paymasterAndData", type: "bytes" }
14812
+ ]
14813
+ },
14814
+ primaryType: "PackedUserOperation",
14815
+ message: {
14816
+ sender: userOp.sender,
14817
+ nonce: userOp.nonce,
14818
+ initCode: userOp.initCode,
14819
+ callData: userOp.callData,
14820
+ accountGasLimits: userOp.accountGasLimits,
14821
+ preVerificationGas: userOp.preVerificationGas,
14822
+ gasFees: userOp.gasFees,
14823
+ paymasterAndData: userOp.paymasterAndData
14824
+ }
14825
+ };
14826
+ }
14766
14827
  /**
14767
14828
  * Computes the EIP-712 struct hash of a `PackedUserOperation`.
14768
14829
  *
@@ -16271,9 +16332,12 @@ var BidManager = class {
16271
16332
  * Constructs a signed `PackedUserOperation` that a solver can submit to the
16272
16333
  * Hyperbridge coprocessor as a bid to fill an order.
16273
16334
  *
16274
- * The solver's signature covers a hash that binds the UserOperation to the
16275
- * order commitment and the session key address, so the IntentGatewayV2
16276
- * contract can verify the solver's intent on-chain.
16335
+ * The solver signs the operation as EntryPoint v0.8 EIP-712 typed data,
16336
+ * whose digest is the plain userOpHash. The binding to the order lives in
16337
+ * the operation itself: the 4337 nonce key must be the lower 192 bits of
16338
+ * the order commitment (`SolverAccount` enforces this during validation),
16339
+ * and the callData carries the order. This keeps the signed payload fully
16340
+ * transparent to signing infrastructure instead of an opaque digest.
16277
16341
  *
16278
16342
  * @param options - Parameters describing the solver account, gas limits, fee
16279
16343
  * market values, and pre-built `callData` for the fill operation.
@@ -16311,10 +16375,17 @@ var BidManager = class {
16311
16375
  paymasterAndData,
16312
16376
  signature: "0x"
16313
16377
  };
16314
- const userOpHash = CryptoUtils.computeUserOpHash(userOp, entryPointAddress, chainId);
16315
- const sessionKey = order.session;
16316
- const messageHash = keccak256(concat([userOpHash, order.id, sessionKey]));
16317
- const solverSignature = await solverSigner.signMessage(messageHash, Number(chainId));
16378
+ const nonceKey = BigInt(nonce) >> 64n;
16379
+ const expectedKey = CryptoUtils.bidNonceKey(order.id, order.session);
16380
+ if (nonceKey !== expectedKey) {
16381
+ console.warn(
16382
+ `[BidManager] bid nonce key does not bind the order commitment and session key; on-chain validation will fail (order=${order.id})`
16383
+ );
16384
+ }
16385
+ const solverSignature = await solverSigner.signTypedData(
16386
+ CryptoUtils.packedUserOpTypedData(userOp, entryPointAddress, chainId),
16387
+ Number(chainId)
16388
+ );
16318
16389
  const signature = concat([order.id, solverSignature]);
16319
16390
  return { ...userOp, signature };
16320
16391
  }