{"version":3,"sources":["../../src/exact/v1/client/scheme.ts","../../src/exact/v1/facilitator/scheme.ts"],"sourcesContent":["import {\n  Network,\n  PaymentPayload,\n  PaymentRequirements,\n  SchemeNetworkClient,\n} from \"@bankofai/x402-core/types\";\nimport { PaymentRequirementsV1 } from \"@bankofai/x402-core/types/v1\";\nimport { getAddress } from \"viem\";\nimport { authorizationTypes } from \"../../../constants\";\nimport { ClientEvmSigner } from \"../../../signer\";\nimport { ExactEvmPayloadV1 } from \"../../../types\";\nimport { createNonce } from \"../../../utils\";\nimport { findDefaultAsset } from \"../../../defaultAssets\";\nimport { EvmNetworkV1, getEvmChainIdV1 } from \"../../../v1\";\n\n/**\n * EVM client implementation for the Exact payment scheme (V1).\n */\nexport class ExactEvmSchemeV1 implements SchemeNetworkClient {\n  readonly scheme = \"exact\";\n  findDefaultAsset = findDefaultAsset;\n\n  /**\n   * Creates a new ExactEvmClientV1 instance.\n   *\n   * @param signer - The EVM signer for client operations\n   */\n  constructor(private readonly signer: ClientEvmSigner) {}\n\n  /**\n   * Creates a payment payload for the Exact scheme (V1).\n   *\n   * @param x402Version - The x402 protocol version\n   * @param paymentRequirements - The payment requirements\n   * @returns Promise resolving to a payment payload\n   */\n  async createPaymentPayload(\n    x402Version: number,\n    paymentRequirements: PaymentRequirements,\n  ): Promise<\n    Pick<PaymentPayload, \"x402Version\" | \"payload\"> & { scheme: string; network: Network }\n  > {\n    const selectedV1 = paymentRequirements as unknown as PaymentRequirementsV1;\n    const nonce = createNonce();\n    const now = Math.floor(Date.now() / 1000);\n\n    const authorization: ExactEvmPayloadV1[\"authorization\"] = {\n      from: this.signer.address,\n      to: getAddress(selectedV1.payTo),\n      value: selectedV1.maxAmountRequired,\n      validAfter: \"0\",\n      validBefore: (now + selectedV1.maxTimeoutSeconds).toString(),\n      nonce,\n    };\n\n    // Sign the authorization\n    const signature = await this.signAuthorization(authorization, selectedV1);\n\n    const payload: ExactEvmPayloadV1 = {\n      authorization,\n      signature,\n    };\n\n    return {\n      x402Version,\n      scheme: selectedV1.scheme,\n      network: selectedV1.network,\n      payload,\n    };\n  }\n\n  /**\n   * Sign the EIP-3009 authorization using EIP-712\n   *\n   * @param authorization - The authorization to sign\n   * @param requirements - The payment requirements\n   * @returns Promise resolving to the signature\n   */\n  private async signAuthorization(\n    authorization: ExactEvmPayloadV1[\"authorization\"],\n    requirements: PaymentRequirementsV1,\n  ): Promise<`0x${string}`> {\n    const chainId = getEvmChainIdV1(requirements.network as EvmNetworkV1);\n\n    if (!requirements.extra?.name || !requirements.extra?.version) {\n      throw new Error(\n        `EIP-712 domain parameters (name, version) are required in payment requirements for asset ${requirements.asset}`,\n      );\n    }\n\n    const { name, version } = requirements.extra;\n\n    const domain = {\n      name,\n      version,\n      chainId,\n      verifyingContract: getAddress(requirements.asset),\n    };\n\n    const message = {\n      from: getAddress(authorization.from),\n      to: getAddress(authorization.to),\n      value: BigInt(authorization.value),\n      validAfter: BigInt(authorization.validAfter),\n      validBefore: BigInt(authorization.validBefore),\n      nonce: authorization.nonce,\n    };\n\n    return await this.signer.signTypedData({\n      domain,\n      types: authorizationTypes,\n      primaryType: \"TransferWithAuthorization\",\n      message,\n    });\n  }\n}\n","import {\n  PaymentPayload,\n  PaymentPayloadV1,\n  PaymentRequirements,\n  SchemeNetworkFacilitator,\n  FacilitatorContext,\n  SettleResponse,\n  VerifyResponse,\n} from \"@bankofai/x402-core/types\";\nimport { resolveDataSuffix } from \"../../../shared/extensions\";\nimport { PaymentRequirementsV1 } from \"@bankofai/x402-core/types/v1\";\nimport { getAddress, Hex, isAddressEqual, parseErc6492Signature } from \"viem\";\nimport { authorizationTypes } from \"../../../constants\";\nimport { FacilitatorEvmSigner } from \"../../../signer\";\nimport { verifyTypedDataSignature, classifyErc6492Payer } from \"../../../shared/verifySignature\";\nimport { ExactEvmPayloadV1 } from \"../../../types\";\nimport { EvmNetworkV1, getEvmChainIdV1 } from \"../../../v1\";\nimport * as Errors from \"../../facilitator/errors\";\nimport {\n  diagnoseEip3009SimulationFailure,\n  executeTransferWithAuthorization,\n  simulateEip3009Transfer,\n  verifyEip3009TransferEvent,\n} from \"../../facilitator/eip3009-utils\";\n\nexport interface VerifyV1Options {\n  /** Run onchain simulation. Defaults to true. */\n  simulate?: boolean;\n}\n\nexport interface ExactEvmSchemeV1Config {\n  /**\n   * Allowlist of factory contract addresses (hex strings, case-insensitive) that the facilitator\n   * will call when deploying an undeployed smart wallet via ERC-6492.\n   *\n   * A non-empty list enables ERC-4337 smart wallet deployment via EIP-6492. Facilitators must\n   * explicitly list every factory they trust to prevent arbitrary transaction injection via\n   * attacker-controlled ERC-6492 signature wrappers. An empty or omitted list denies all factory\n   * deployment calls.\n   *\n   * @default []\n   */\n  eip6492AllowedFactories?: string[];\n  /**\n   * If enabled, simulates transaction before settling. Defaults to false, ie only simulate during verify.\n   *\n   * @default false\n   */\n  simulateInSettle?: boolean;\n}\n\n/**\n * EVM facilitator implementation for the Exact payment scheme (V1).\n */\nexport class ExactEvmSchemeV1 implements SchemeNetworkFacilitator {\n  readonly scheme = \"exact\";\n  readonly caipFamily = \"eip155:*\";\n  private readonly config: Required<ExactEvmSchemeV1Config>;\n\n  /**\n   * Creates a new ExactEvmFacilitatorV1 instance.\n   *\n   * @param signer - The EVM signer for facilitator operations\n   * @param config - Optional configuration for the facilitator\n   */\n  constructor(\n    private readonly signer: FacilitatorEvmSigner,\n    config?: ExactEvmSchemeV1Config,\n  ) {\n    this.config = {\n      eip6492AllowedFactories: config?.eip6492AllowedFactories ?? [],\n      simulateInSettle: config?.simulateInSettle ?? false,\n    };\n  }\n\n  /**\n   * Get mechanism-specific extra data for the supported kinds endpoint.\n   * For EVM, no extra data is needed.\n   *\n   * @param _ - The network identifier (unused for EVM)\n   * @returns undefined (EVM has no extra data)\n   */\n  getExtra(_: string): Record<string, unknown> | undefined {\n    return undefined;\n  }\n\n  /**\n   * Get signer addresses used by this facilitator.\n   * Returns all addresses this facilitator can use for signing/settling transactions.\n   *\n   * @param _ - The network identifier (unused for EVM, addresses are network-agnostic)\n   * @returns Array of facilitator wallet addresses\n   */\n  getSigners(_: string): string[] {\n    return [...this.signer.getAddresses()];\n  }\n\n  /**\n   * Verifies a payment payload (V1).\n   *\n   * @param payload - The payment payload to verify\n   * @param requirements - The payment requirements\n   * @returns Promise resolving to verification response\n   */\n  async verify(\n    payload: PaymentPayload,\n    requirements: PaymentRequirements,\n  ): Promise<VerifyResponse> {\n    return this._verify(payload, requirements);\n  }\n\n  /**\n   * Settles a payment by executing the transfer (V1).\n   *\n   * @param payload - The payment payload to settle\n   * @param requirements - The payment requirements\n   * @param context - Optional facilitator context for extension capabilities\n   * @returns Promise resolving to settlement response\n   */\n  async settle(\n    payload: PaymentPayload,\n    requirements: PaymentRequirements,\n    context?: FacilitatorContext,\n  ): Promise<SettleResponse> {\n    const payloadV1 = payload as unknown as PaymentPayloadV1;\n    const exactEvmPayload = payload.payload as ExactEvmPayloadV1;\n\n    // Re-verify before settling\n    const valid = await this._verify(payload, requirements, {\n      simulate: this.config.simulateInSettle ?? false,\n    });\n    if (!valid.isValid) {\n      return {\n        success: false,\n        network: payloadV1.network,\n        transaction: \"\",\n        errorReason: valid.invalidReason ?? Errors.ErrInvalidScheme,\n        payer: exactEvmPayload.authorization.from,\n      };\n    }\n\n    try {\n      // Parse ERC-6492 signature if applicable (for optional deployment)\n      const { address: factoryAddress, data: factoryCalldata } = parseErc6492Signature(\n        exactEvmPayload.signature!,\n      );\n\n      // Deploy ERC-4337 smart wallet via EIP-6492 if factory is in the allowlist\n      if (\n        factoryAddress &&\n        factoryCalldata &&\n        !isAddressEqual(factoryAddress, \"0x0000000000000000000000000000000000000000\")\n      ) {\n        // Check if smart wallet is already deployed\n        const payerAddress = exactEvmPayload.authorization.from;\n        const bytecode = await this.signer.getCode({ address: payerAddress });\n\n        if (!bytecode || bytecode === \"0x\") {\n          const normalizedFactory = factoryAddress.toLowerCase();\n          const isAllowed = (this.config.eip6492AllowedFactories ?? []).some(\n            allowed => allowed.toLowerCase() === normalizedFactory,\n          );\n          if (!isAllowed) {\n            return {\n              success: false,\n              errorReason: Errors.ErrFactoryNotAllowed,\n              transaction: \"\",\n              network: payloadV1.network,\n              payer: exactEvmPayload.authorization.from,\n            };\n          }\n\n          // Send the factory calldata directly as a transaction\n          // The factoryCalldata already contains the complete encoded function call\n          const deployTx = await this.signer.sendTransaction({\n            to: factoryAddress as Hex,\n            data: factoryCalldata as Hex,\n          });\n\n          // Wait for deployment and verify it actually succeeded.\n          const deployReceipt = await this.signer.waitForTransactionReceipt({ hash: deployTx });\n          if (deployReceipt.status !== \"success\") {\n            return {\n              success: false,\n              errorReason: Errors.ErrSmartWalletDeploymentFailed,\n              transaction: \"\",\n              network: payloadV1.network,\n              payer: exactEvmPayload.authorization.from,\n            };\n          }\n\n          // Do NOT re-simulate the transfer here. The authoritative pre-check is the atomic\n          // deploy+transfer simulation in verify; a second standalone eth_call after the real\n          // deploy tx races the deploy's state propagation across load-balanced RPC nodes and\n          // false-rejected valid wallets. The on-chain transferWithAuthorization below is the\n          // definitive signature check; a genuinely unsupported inner signature reverts there\n          // and is classified by parseEip3009TransferError.\n        }\n      }\n\n      // V1 payloads carry no extensions, so the builder-code suffix can only contain the\n      // facilitator's own wallet code (`w`); client app (`a`) and service (`s`) codes are\n      // always absent.\n      const dataSuffix = await resolveDataSuffix(context, {\n        paymentPayload: payload,\n        paymentRequirements: requirements,\n      });\n\n      const tx = await executeTransferWithAuthorization(\n        this.signer,\n        getAddress(requirements.asset),\n        exactEvmPayload,\n        dataSuffix,\n      );\n\n      // Wait for transaction confirmation\n      const receipt = await this.signer.waitForTransactionReceipt({ hash: tx });\n\n      if (receipt.status !== \"success\") {\n        return {\n          success: false,\n          errorReason: Errors.ErrTransactionFailed,\n          transaction: tx,\n          network: payloadV1.network,\n          payer: exactEvmPayload.authorization.from,\n        };\n      }\n\n      // Receipt status only proves the tx did not revert.\n      // When logs are present, require the expected ERC-20 Transfer event.\n      const auth = exactEvmPayload.authorization;\n      if (\n        receipt.logs != null &&\n        !verifyEip3009TransferEvent(receipt.logs, getAddress(requirements.asset), {\n          from: getAddress(auth.from),\n          to: getAddress(auth.to),\n          value: BigInt(auth.value),\n        })\n      ) {\n        return {\n          success: false,\n          errorReason: Errors.ErrTransferEventMismatch,\n          transaction: tx,\n          network: payloadV1.network,\n          payer: auth.from,\n        };\n      }\n\n      return {\n        success: true,\n        transaction: tx,\n        network: payloadV1.network,\n        payer: exactEvmPayload.authorization.from,\n      };\n    } catch (error) {\n      return {\n        success: false,\n        errorReason: error instanceof Error ? error.message : Errors.ErrTransactionFailed,\n        transaction: \"\",\n        network: payloadV1.network,\n        payer: exactEvmPayload.authorization.from,\n      };\n    }\n  }\n\n  /**\n   * Internal verify with optional simulation control.\n   *\n   * @param payload - The payment payload to verify\n   * @param requirements - The payment requirements\n   * @param options - Verification options (e.g. simulate)\n   * @returns Promise resolving to verification response\n   */\n  private async _verify(\n    payload: PaymentPayload,\n    requirements: PaymentRequirements,\n    options?: VerifyV1Options,\n  ): Promise<VerifyResponse> {\n    const requirementsV1 = requirements as unknown as PaymentRequirementsV1;\n    const payloadV1 = payload as unknown as PaymentPayloadV1;\n    const exactEvmPayload = payload.payload as ExactEvmPayloadV1;\n    const payer = exactEvmPayload.authorization.from;\n    let eip6492Deployment:\n      | { factoryAddress: `0x${string}`; factoryCalldata: `0x${string}` }\n      | undefined;\n\n    // Verify scheme matches\n    if (payloadV1.scheme !== \"exact\" || requirements.scheme !== \"exact\") {\n      return {\n        isValid: false,\n        invalidReason: Errors.ErrInvalidScheme,\n        payer,\n      };\n    }\n\n    // Get chain configuration\n    let chainId: number;\n    try {\n      chainId = getEvmChainIdV1(payloadV1.network as EvmNetworkV1);\n    } catch {\n      return {\n        isValid: false,\n        invalidReason: Errors.ErrNetworkMismatch,\n        payer,\n      };\n    }\n\n    if (!requirements.extra?.name || !requirements.extra?.version) {\n      return {\n        isValid: false,\n        invalidReason: Errors.ErrMissingEip712Domain,\n        payer,\n      };\n    }\n\n    const { name, version } = requirements.extra as { name: string; version: string };\n    const erc20Address = getAddress(requirements.asset);\n\n    // Verify network matches\n    if (payloadV1.network !== requirements.network) {\n      return {\n        isValid: false,\n        invalidReason: Errors.ErrNetworkMismatch,\n        payer,\n      };\n    }\n\n    // Build typed data for signature verification\n    const permitTypedData = {\n      types: authorizationTypes,\n      primaryType: \"TransferWithAuthorization\" as const,\n      domain: {\n        name,\n        version,\n        chainId,\n        verifyingContract: erc20Address,\n      },\n      message: {\n        from: exactEvmPayload.authorization.from,\n        to: exactEvmPayload.authorization.to,\n        value: BigInt(exactEvmPayload.authorization.value),\n        validAfter: BigInt(exactEvmPayload.authorization.validAfter),\n        validBefore: BigInt(exactEvmPayload.authorization.validBefore),\n        nonce: exactEvmPayload.authorization.nonce,\n      },\n    };\n\n    const signature = exactEvmPayload.signature!;\n\n    // Classify the payer (counterfactual vs deployed) and extract inner sig in one shot.\n    const {\n      isCounterfactual,\n      innerSignature,\n      eip6492Deployment: classification6492,\n    } = await classifyErc6492Payer(this.signer, signature, payer);\n\n    if (classification6492) {\n      eip6492Deployment = classification6492;\n    }\n\n    if (isCounterfactual) {\n      // Mirror settle's allowlist gate so verify predicts settle: a counterfactual payment whose\n      // factory is not allowlisted is rejected at settle, so reject it here too.\n      const factory = classification6492?.factoryAddress;\n      const factoryAllowed =\n        !!factory &&\n        this.config.eip6492AllowedFactories.some(\n          a => a.trim().toLowerCase() === factory.toLowerCase(),\n        );\n      if (!factoryAllowed) {\n        return {\n          isValid: false,\n          invalidReason: Errors.ErrFactoryNotAllowed,\n          payer,\n        };\n      }\n    }\n\n    if (!isCounterfactual) {\n      // Non-counterfactual path: verify using the strict primitive that mirrors\n      // on-chain SignatureChecker semantics (ecrecover for EOAs, strict EIP-1271\n      // for any address with code). No ECDSA fallback for code addresses.\n      const isValid = await verifyTypedDataSignature(this.signer, {\n        address: payer,\n        ...permitTypedData,\n        signature: innerSignature,\n      });\n      if (!isValid) {\n        return {\n          isValid: false,\n          invalidReason: Errors.ErrInvalidSignature,\n          payer,\n        };\n      }\n    }\n    // Counterfactual path: defer to on-chain simulation which deploys + verifies atomically.\n\n    // Verify payment recipient matches\n    if (getAddress(exactEvmPayload.authorization.to) !== getAddress(requirements.payTo)) {\n      return {\n        isValid: false,\n        invalidReason: Errors.ErrRecipientMismatch,\n        payer,\n      };\n    }\n\n    // Verify validBefore is in the future (with 6 second buffer for block time)\n    const now = Math.floor(Date.now() / 1000);\n    if (BigInt(exactEvmPayload.authorization.validBefore) < BigInt(now + 6)) {\n      return {\n        isValid: false,\n        invalidReason: Errors.ErrValidBeforeExpired,\n        payer,\n      };\n    }\n\n    // Verify validAfter is not in the future\n    if (BigInt(exactEvmPayload.authorization.validAfter) > BigInt(now)) {\n      return {\n        isValid: false,\n        invalidReason: Errors.ErrValidAfterInFuture,\n        payer,\n      };\n    }\n\n    // Verify amount exactly matches requirements\n    if (BigInt(exactEvmPayload.authorization.value) !== BigInt(requirementsV1.maxAmountRequired)) {\n      return {\n        isValid: false,\n        invalidReason: Errors.ErrInvalidAuthorizationValue,\n        payer,\n      };\n    }\n\n    // Transaction simulation\n    if (options?.simulate !== false) {\n      const simulationSucceeded = await simulateEip3009Transfer(\n        this.signer,\n        erc20Address,\n        exactEvmPayload,\n        eip6492Deployment,\n      );\n      if (!simulationSucceeded) {\n        return diagnoseEip3009SimulationFailure(\n          this.signer,\n          erc20Address,\n          exactEvmPayload,\n          requirements,\n          requirementsV1.maxAmountRequired,\n        );\n      }\n    }\n\n    return {\n      isValid: true,\n      invalidReason: undefined,\n      payer,\n    };\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,SAAS,kBAAkB;AAWpB,IAAM,mBAAN,MAAsD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS3D,YAA6B,QAAyB;AAAzB;AAR7B,SAAS,SAAS;AAClB,4BAAmB;AAAA,EAOoC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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