@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.
@@ -5293,6 +5293,57 @@ declare class CryptoUtils {
5293
5293
  * @returns The UserOperation hash as a hex string.
5294
5294
  */
5295
5295
  static computeUserOpHash(userOp: PackedUserOperation, entryPoint: Hex, chainId: bigint): Hex;
5296
+ /**
5297
+ * Derives the ERC-4337 nonce key that binds a bid UserOperation to its
5298
+ * order and session key: the lower 192 bits of
5299
+ * `keccak256(commitment ‖ sessionKey)`. `SolverAccount` rejects bid
5300
+ * operations whose nonce key differs — this is what lets the solver sign
5301
+ * the plain userOpHash while staying committed to the order and to the
5302
+ * session key it bid against.
5303
+ *
5304
+ * @param commitment - The order commitment (`order.id`).
5305
+ * @param sessionKey - The order's session key address (`order.session`).
5306
+ * @returns The 192-bit nonce key as a bigint (pass to `EntryPoint.getNonce`).
5307
+ */
5308
+ static bidNonceKey(commitment: HexString, sessionKey: HexString): bigint;
5309
+ /**
5310
+ * Builds the EIP-712 typed-data payload whose digest is the EntryPoint v0.8
5311
+ * `userOpHash` (i.e. `hashTypedData(packedUserOpTypedData(...)) ===
5312
+ * computeUserOpHash(...)`). Signing this typed data is bit-identical to
5313
+ * signing the raw userOpHash, but keeps the full operation visible to
5314
+ * signing infrastructure (hardware wallets, MPC/TEE policy engines) instead
5315
+ * of an opaque 32-byte digest.
5316
+ *
5317
+ * @param userOp - The packed UserOperation to sign (signature field ignored).
5318
+ * @param entryPoint - Address of the EntryPoint v0.8 contract.
5319
+ * @param chainId - Chain ID of the network on which the operation will execute.
5320
+ * @returns A viem `TypedDataDefinition` for the operation.
5321
+ */
5322
+ static packedUserOpTypedData(userOp: PackedUserOperation, entryPoint: Hex, chainId: bigint): {
5323
+ domain: {
5324
+ name: string;
5325
+ version: string;
5326
+ chainId: bigint;
5327
+ verifyingContract: `0x${string}`;
5328
+ };
5329
+ types: {
5330
+ PackedUserOperation: {
5331
+ name: string;
5332
+ type: string;
5333
+ }[];
5334
+ };
5335
+ primaryType: "PackedUserOperation";
5336
+ message: {
5337
+ sender: `0x${string}`;
5338
+ nonce: bigint;
5339
+ initCode: `0x${string}`;
5340
+ callData: `0x${string}`;
5341
+ accountGasLimits: `0x${string}`;
5342
+ preVerificationGas: bigint;
5343
+ gasFees: `0x${string}`;
5344
+ paymasterAndData: `0x${string}`;
5345
+ };
5346
+ };
5296
5347
  /**
5297
5348
  * Computes the EIP-712 struct hash of a `PackedUserOperation`.
5298
5349
  *
@@ -2635,7 +2635,7 @@ var chainConfigs = {
2635
2635
  UniswapV3Quoter: "0x0000000000000000000000000000000000000000",
2636
2636
  UniswapV4Quoter: "0x0000000000000000000000000000000000000000",
2637
2637
  EntryPointV08: "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108",
2638
- SolverAccount: "0x07FeC66d967800998060194EaECDd7C66dA4a1B1"
2638
+ SolverAccount: "0x110C7E1814c923127469Ca8939a12dAa70B96a17"
2639
2639
  },
2640
2640
  rpcEnvKey: "BSC_CHAPEL",
2641
2641
  defaultRpcUrl: "https://bnb-testnet.api.onfinality.io/public",
@@ -2743,7 +2743,7 @@ var chainConfigs = {
2743
2743
  },
2744
2744
  addresses: {
2745
2745
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
2746
- SolverAccount: "0x975e80B476cB1d4Cd06c292ce36898f2bE4159ea",
2746
+ SolverAccount: "0x3bdB532d91F165BeFad5542700205f5BB5152a82",
2747
2747
  TokenGateway: "0xFd413e3AFe560182C4471F4d143A96d3e259B6dE",
2748
2748
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
2749
2749
  UniswapRouter02: "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D",
@@ -2798,7 +2798,7 @@ var chainConfigs = {
2798
2798
  },
2799
2799
  addresses: {
2800
2800
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
2801
- SolverAccount: "0x975e80B476cB1d4Cd06c292ce36898f2bE4159ea",
2801
+ SolverAccount: "0x3bdB532d91F165BeFad5542700205f5BB5152a82",
2802
2802
  TokenGateway: "0xFd413e3AFe560182C4471F4d143A96d3e259B6dE",
2803
2803
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
2804
2804
  UniswapRouter02: "0x10ED43C718714eb63d5aA57B78B54704E256024E",
@@ -2854,7 +2854,7 @@ var chainConfigs = {
2854
2854
  },
2855
2855
  addresses: {
2856
2856
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
2857
- SolverAccount: "0x975e80B476cB1d4Cd06c292ce36898f2bE4159ea",
2857
+ SolverAccount: "0x3bdB532d91F165BeFad5542700205f5BB5152a82",
2858
2858
  TokenGateway: "0xFd413e3AFe560182C4471F4d143A96d3e259B6dE",
2859
2859
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
2860
2860
  UniswapRouter02: "0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24",
@@ -2911,7 +2911,7 @@ var chainConfigs = {
2911
2911
  },
2912
2912
  addresses: {
2913
2913
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
2914
- SolverAccount: "0x975e80B476cB1d4Cd06c292ce36898f2bE4159ea",
2914
+ SolverAccount: "0x3bdB532d91F165BeFad5542700205f5BB5152a82",
2915
2915
  TokenGateway: "0xFd413e3AFe560182C4471F4d143A96d3e259B6dE",
2916
2916
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
2917
2917
  UniswapRouter02: "0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24",
@@ -2970,7 +2970,7 @@ var chainConfigs = {
2970
2970
  },
2971
2971
  addresses: {
2972
2972
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
2973
- SolverAccount: "0x975e80B476cB1d4Cd06c292ce36898f2bE4159ea",
2973
+ SolverAccount: "0x3bdB532d91F165BeFad5542700205f5BB5152a82",
2974
2974
  TokenGateway: "0x8b536105b6Fae2aE9199f5146D3C57Dfe53b614E",
2975
2975
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
2976
2976
  UniswapRouter02: "0xd2f9496824951D5237cC71245D659E48d0d5f9E8",
@@ -3057,7 +3057,7 @@ var chainConfigs = {
3057
3057
  Calldispatcher: "0x876F1891982E260026630c233A4897160A281Fb8",
3058
3058
  Permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
3059
3059
  EntryPointV08: "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108",
3060
- SolverAccount: "0x07FeC66d967800998060194EaECDd7C66dA4a1B1"
3060
+ SolverAccount: "0x110C7E1814c923127469Ca8939a12dAa70B96a17"
3061
3061
  },
3062
3062
  rpcEnvKey: "POLYGON_AMOY",
3063
3063
  defaultRpcUrl: "https://rpc-amoy.polygon.technology",
@@ -3081,7 +3081,7 @@ var chainConfigs = {
3081
3081
  },
3082
3082
  addresses: {
3083
3083
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
3084
- SolverAccount: "0x975e80B476cB1d4Cd06c292ce36898f2bE4159ea",
3084
+ SolverAccount: "0x3bdB532d91F165BeFad5542700205f5BB5152a82",
3085
3085
  TokenGateway: "0xFd413e3AFe560182C4471F4d143A96d3e259B6dE",
3086
3086
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
3087
3087
  UniswapRouter02: "0x4A7b5Da61326A6379179b40d00F57E5bbDC962c2",
@@ -3116,7 +3116,7 @@ var chainConfigs = {
3116
3116
  },
3117
3117
  addresses: {
3118
3118
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
3119
- SolverAccount: "0x975e80B476cB1d4Cd06c292ce36898f2bE4159ea",
3119
+ SolverAccount: "0x3bdB532d91F165BeFad5542700205f5BB5152a82",
3120
3120
  TokenGateway: "0xFd413e3AFe560182C4471F4d143A96d3e259B6dE",
3121
3121
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
3122
3122
  UniswapRouter02: "0xB2e26652e4BAd1e56055A051f922E06760cA0BFE",
@@ -3271,7 +3271,7 @@ var chainConfigs = {
3271
3271
  },
3272
3272
  addresses: {
3273
3273
  IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
3274
- SolverAccount: "0x975e80B476cB1d4Cd06c292ce36898f2bE4159ea",
3274
+ SolverAccount: "0x3bdB532d91F165BeFad5542700205f5BB5152a82",
3275
3275
  Host: "0x620128E2B19193d6Bd244a3AC8D3bBa0541B19c3",
3276
3276
  Calldispatcher: "0xE2C7e576E26E0bE7aC97c6fE925bcDAbD87c4bEd"
3277
3277
  },
@@ -14823,6 +14823,67 @@ var CryptoUtils = class _CryptoUtils {
14823
14823
  encodePacked(["bytes1", "bytes1", "bytes32", "bytes32"], ["0x19", "0x01", domainSeparator, structHash])
14824
14824
  );
14825
14825
  }
14826
+ /**
14827
+ * Derives the ERC-4337 nonce key that binds a bid UserOperation to its
14828
+ * order and session key: the lower 192 bits of
14829
+ * `keccak256(commitment ‖ sessionKey)`. `SolverAccount` rejects bid
14830
+ * operations whose nonce key differs — this is what lets the solver sign
14831
+ * the plain userOpHash while staying committed to the order and to the
14832
+ * session key it bid against.
14833
+ *
14834
+ * @param commitment - The order commitment (`order.id`).
14835
+ * @param sessionKey - The order's session key address (`order.session`).
14836
+ * @returns The 192-bit nonce key as a bigint (pass to `EntryPoint.getNonce`).
14837
+ */
14838
+ static bidNonceKey(commitment, sessionKey) {
14839
+ return BigInt(keccak256(encodePacked(["bytes32", "address"], [commitment, sessionKey]))) & (1n << 192n) - 1n;
14840
+ }
14841
+ /**
14842
+ * Builds the EIP-712 typed-data payload whose digest is the EntryPoint v0.8
14843
+ * `userOpHash` (i.e. `hashTypedData(packedUserOpTypedData(...)) ===
14844
+ * computeUserOpHash(...)`). Signing this typed data is bit-identical to
14845
+ * signing the raw userOpHash, but keeps the full operation visible to
14846
+ * signing infrastructure (hardware wallets, MPC/TEE policy engines) instead
14847
+ * of an opaque 32-byte digest.
14848
+ *
14849
+ * @param userOp - The packed UserOperation to sign (signature field ignored).
14850
+ * @param entryPoint - Address of the EntryPoint v0.8 contract.
14851
+ * @param chainId - Chain ID of the network on which the operation will execute.
14852
+ * @returns A viem `TypedDataDefinition` for the operation.
14853
+ */
14854
+ static packedUserOpTypedData(userOp, entryPoint, chainId) {
14855
+ return {
14856
+ domain: {
14857
+ name: "ERC4337",
14858
+ version: "1",
14859
+ chainId,
14860
+ verifyingContract: entryPoint
14861
+ },
14862
+ types: {
14863
+ PackedUserOperation: [
14864
+ { name: "sender", type: "address" },
14865
+ { name: "nonce", type: "uint256" },
14866
+ { name: "initCode", type: "bytes" },
14867
+ { name: "callData", type: "bytes" },
14868
+ { name: "accountGasLimits", type: "bytes32" },
14869
+ { name: "preVerificationGas", type: "uint256" },
14870
+ { name: "gasFees", type: "bytes32" },
14871
+ { name: "paymasterAndData", type: "bytes" }
14872
+ ]
14873
+ },
14874
+ primaryType: "PackedUserOperation",
14875
+ message: {
14876
+ sender: userOp.sender,
14877
+ nonce: userOp.nonce,
14878
+ initCode: userOp.initCode,
14879
+ callData: userOp.callData,
14880
+ accountGasLimits: userOp.accountGasLimits,
14881
+ preVerificationGas: userOp.preVerificationGas,
14882
+ gasFees: userOp.gasFees,
14883
+ paymasterAndData: userOp.paymasterAndData
14884
+ }
14885
+ };
14886
+ }
14826
14887
  /**
14827
14888
  * Computes the EIP-712 struct hash of a `PackedUserOperation`.
14828
14889
  *
@@ -16331,9 +16392,12 @@ var BidManager = class {
16331
16392
  * Constructs a signed `PackedUserOperation` that a solver can submit to the
16332
16393
  * Hyperbridge coprocessor as a bid to fill an order.
16333
16394
  *
16334
- * The solver's signature covers a hash that binds the UserOperation to the
16335
- * order commitment and the session key address, so the IntentGatewayV2
16336
- * contract can verify the solver's intent on-chain.
16395
+ * The solver signs the operation as EntryPoint v0.8 EIP-712 typed data,
16396
+ * whose digest is the plain userOpHash. The binding to the order lives in
16397
+ * the operation itself: the 4337 nonce key must be the lower 192 bits of
16398
+ * the order commitment (`SolverAccount` enforces this during validation),
16399
+ * and the callData carries the order. This keeps the signed payload fully
16400
+ * transparent to signing infrastructure instead of an opaque digest.
16337
16401
  *
16338
16402
  * @param options - Parameters describing the solver account, gas limits, fee
16339
16403
  * market values, and pre-built `callData` for the fill operation.
@@ -16371,10 +16435,17 @@ var BidManager = class {
16371
16435
  paymasterAndData,
16372
16436
  signature: "0x"
16373
16437
  };
16374
- const userOpHash = CryptoUtils.computeUserOpHash(userOp, entryPointAddress, chainId);
16375
- const sessionKey = order.session;
16376
- const messageHash = keccak256(concat([userOpHash, order.id, sessionKey]));
16377
- const solverSignature = await solverSigner.signMessage(messageHash, Number(chainId));
16438
+ const nonceKey = BigInt(nonce) >> 64n;
16439
+ const expectedKey = CryptoUtils.bidNonceKey(order.id, order.session);
16440
+ if (nonceKey !== expectedKey) {
16441
+ console.warn(
16442
+ `[BidManager] bid nonce key does not bind the order commitment and session key; on-chain validation will fail (order=${order.id})`
16443
+ );
16444
+ }
16445
+ const solverSignature = await solverSigner.signTypedData(
16446
+ CryptoUtils.packedUserOpTypedData(userOp, entryPointAddress, chainId),
16447
+ Number(chainId)
16448
+ );
16378
16449
  const signature = concat([order.id, solverSignature]);
16379
16450
  return { ...userOp, signature };
16380
16451
  }