@t402/evm 2.0.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.
- package/README.md +183 -0
- package/dist/cjs/exact/client/index.d.ts +53 -0
- package/dist/cjs/exact/client/index.js +270 -0
- package/dist/cjs/exact/client/index.js.map +1 -0
- package/dist/cjs/exact/facilitator/index.d.ts +118 -0
- package/dist/cjs/exact/facilitator/index.js +735 -0
- package/dist/cjs/exact/facilitator/index.js.map +1 -0
- package/dist/cjs/exact/server/index.d.ts +36 -0
- package/dist/cjs/exact/server/index.js +438 -0
- package/dist/cjs/exact/server/index.js.map +1 -0
- package/dist/cjs/exact/v1/client/index.d.ts +37 -0
- package/dist/cjs/exact/v1/client/index.js +147 -0
- package/dist/cjs/exact/v1/client/index.js.map +1 -0
- package/dist/cjs/exact/v1/facilitator/index.d.ts +62 -0
- package/dist/cjs/exact/v1/facilitator/index.js +401 -0
- package/dist/cjs/exact/v1/facilitator/index.js.map +1 -0
- package/dist/cjs/index.d.ts +1537 -0
- package/dist/cjs/index.js +2368 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/scheme-C6uD7PdY.d.ts +130 -0
- package/dist/cjs/scheme-OojTBKAz.d.ts +35 -0
- package/dist/cjs/scheme-yqGaK9rK.d.ts +130 -0
- package/dist/cjs/signer-BkcAzwYi.d.ts +79 -0
- package/dist/cjs/v1/index.d.ts +7 -0
- package/dist/cjs/v1/index.js +171 -0
- package/dist/cjs/v1/index.js.map +1 -0
- package/dist/esm/chunk-ACDQ5QNT.mjs +305 -0
- package/dist/esm/chunk-ACDQ5QNT.mjs.map +1 -0
- package/dist/esm/chunk-JBWWBRYY.mjs +92 -0
- package/dist/esm/chunk-JBWWBRYY.mjs.map +1 -0
- package/dist/esm/chunk-LGSG73NJ.mjs +88 -0
- package/dist/esm/chunk-LGSG73NJ.mjs.map +1 -0
- package/dist/esm/chunk-OEXW2OK2.mjs +251 -0
- package/dist/esm/chunk-OEXW2OK2.mjs.map +1 -0
- package/dist/esm/chunk-QLXM7BIB.mjs +23 -0
- package/dist/esm/chunk-QLXM7BIB.mjs.map +1 -0
- package/dist/esm/chunk-XYKAO6KJ.mjs +141 -0
- package/dist/esm/chunk-XYKAO6KJ.mjs.map +1 -0
- package/dist/esm/exact/client/index.d.mts +53 -0
- package/dist/esm/exact/client/index.mjs +36 -0
- package/dist/esm/exact/client/index.mjs.map +1 -0
- package/dist/esm/exact/facilitator/index.d.mts +118 -0
- package/dist/esm/exact/facilitator/index.mjs +324 -0
- package/dist/esm/exact/facilitator/index.mjs.map +1 -0
- package/dist/esm/exact/server/index.d.mts +36 -0
- package/dist/esm/exact/server/index.mjs +218 -0
- package/dist/esm/exact/server/index.mjs.map +1 -0
- package/dist/esm/exact/v1/client/index.d.mts +37 -0
- package/dist/esm/exact/v1/client/index.mjs +8 -0
- package/dist/esm/exact/v1/client/index.mjs.map +1 -0
- package/dist/esm/exact/v1/facilitator/index.d.mts +62 -0
- package/dist/esm/exact/v1/facilitator/index.mjs +8 -0
- package/dist/esm/exact/v1/facilitator/index.mjs.map +1 -0
- package/dist/esm/index.d.mts +1537 -0
- package/dist/esm/index.mjs +1875 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/scheme-D4mOqq9l.d.mts +35 -0
- package/dist/esm/scheme-yqGaK9rK.d.mts +130 -0
- package/dist/esm/signer-BkcAzwYi.d.mts +79 -0
- package/dist/esm/v1/index.d.mts +7 -0
- package/dist/esm/v1/index.mjs +13 -0
- package/dist/esm/v1/index.mjs.map +1 -0
- package/package.json +127 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/exact/facilitator/index.ts","../../../../src/exact/facilitator/scheme.ts","../../../../src/constants.ts","../../../../src/exact/v1/facilitator/scheme.ts","../../../../src/utils.ts","../../../../src/exact/v1/client/scheme.ts","../../../../src/v1/index.ts","../../../../src/exact/facilitator/register.ts"],"sourcesContent":["export { ExactEvmScheme } from \"./scheme\";\nexport type { ExactEvmSchemeConfig } from \"./scheme\";\nexport { registerExactEvmScheme } from \"./register\";\nexport type { EvmFacilitatorConfig } from \"./register\";\n","import {\n PaymentPayload,\n PaymentRequirements,\n SchemeNetworkFacilitator,\n SettleResponse,\n VerifyResponse,\n} from \"@t402/core/types\";\nimport { getAddress, Hex, isAddressEqual, parseErc6492Signature, parseSignature } from \"viem\";\nimport { authorizationTypes, eip3009ABI } from \"../../constants\";\nimport { FacilitatorEvmSigner } from \"../../signer\";\nimport { ExactEvmPayloadV2 } from \"../../types\";\n\nexport interface ExactEvmSchemeConfig {\n /**\n * If enabled, the facilitator will deploy ERC-4337 smart wallets\n * via EIP-6492 when encountering undeployed contract signatures.\n *\n * @default false\n */\n deployERC4337WithEIP6492?: boolean;\n}\n\n/**\n * EVM facilitator implementation for the Exact payment scheme.\n */\nexport class ExactEvmScheme implements SchemeNetworkFacilitator {\n readonly scheme = \"exact\";\n readonly caipFamily = \"eip155:*\";\n private readonly config: Required<ExactEvmSchemeConfig>;\n\n /**\n * Creates a new ExactEvmFacilitator 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?: ExactEvmSchemeConfig,\n ) {\n this.config = {\n deployERC4337WithEIP6492: config?.deployERC4337WithEIP6492 ?? 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.\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 const exactEvmPayload = payload.payload as ExactEvmPayloadV2;\n\n // Verify scheme matches\n if (payload.accepted.scheme !== \"exact\" || requirements.scheme !== \"exact\") {\n return {\n isValid: false,\n invalidReason: \"unsupported_scheme\",\n payer: exactEvmPayload.authorization.from,\n };\n }\n\n // Get chain configuration\n if (!requirements.extra?.name || !requirements.extra?.version) {\n return {\n isValid: false,\n invalidReason: \"missing_eip712_domain\",\n payer: exactEvmPayload.authorization.from,\n };\n }\n\n const { name, version } = requirements.extra;\n const erc20Address = getAddress(requirements.asset);\n\n // Verify network matches\n if (payload.accepted.network !== requirements.network) {\n return {\n isValid: false,\n invalidReason: \"network_mismatch\",\n payer: exactEvmPayload.authorization.from,\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: parseInt(requirements.network.split(\":\")[1]),\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 // Verify signature\n try {\n const recoveredAddress = await this.signer.verifyTypedData({\n address: exactEvmPayload.authorization.from,\n ...permitTypedData,\n signature: exactEvmPayload.signature!,\n });\n\n if (!recoveredAddress) {\n return {\n isValid: false,\n invalidReason: \"invalid_exact_evm_payload_signature\",\n payer: exactEvmPayload.authorization.from,\n };\n }\n } catch {\n // Signature verification failed - could be an undeployed smart wallet\n // Check if smart wallet is deployed\n const signature = exactEvmPayload.signature!;\n const signatureLength = signature.startsWith(\"0x\") ? signature.length - 2 : signature.length;\n const isSmartWallet = signatureLength > 130; // 65 bytes = 130 hex chars for EOA\n\n if (isSmartWallet) {\n const payerAddress = exactEvmPayload.authorization.from;\n const bytecode = await this.signer.getCode({ address: payerAddress });\n\n if (!bytecode || bytecode === \"0x\") {\n // Wallet is not deployed. Check if it's EIP-6492 with deployment info.\n // EIP-6492 signatures contain factory address and calldata needed for deployment.\n // Non-EIP-6492 undeployed wallets cannot succeed (no way to deploy them).\n const erc6492Data = parseErc6492Signature(signature);\n const hasDeploymentInfo =\n erc6492Data.address &&\n erc6492Data.data &&\n !isAddressEqual(erc6492Data.address, \"0x0000000000000000000000000000000000000000\");\n\n if (!hasDeploymentInfo) {\n // Non-EIP-6492 undeployed smart wallet - will always fail at settlement\n // since EIP-3009 requires on-chain EIP-1271 validation\n return {\n isValid: false,\n invalidReason: \"invalid_exact_evm_payload_undeployed_smart_wallet\",\n payer: payerAddress,\n };\n }\n // EIP-6492 signature with deployment info - allow through\n // Facilitators with sponsored deployment support can handle this in settle()\n } else {\n // Wallet is deployed but signature still failed - invalid signature\n return {\n isValid: false,\n invalidReason: \"invalid_exact_evm_payload_signature\",\n payer: exactEvmPayload.authorization.from,\n };\n }\n } else {\n // EOA signature failed\n return {\n isValid: false,\n invalidReason: \"invalid_exact_evm_payload_signature\",\n payer: exactEvmPayload.authorization.from,\n };\n }\n }\n\n // Verify payment recipient matches\n if (getAddress(exactEvmPayload.authorization.to) !== getAddress(requirements.payTo)) {\n return {\n isValid: false,\n invalidReason: \"invalid_exact_evm_payload_recipient_mismatch\",\n payer: exactEvmPayload.authorization.from,\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: \"invalid_exact_evm_payload_authorization_valid_before\",\n payer: exactEvmPayload.authorization.from,\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: \"invalid_exact_evm_payload_authorization_valid_after\",\n payer: exactEvmPayload.authorization.from,\n };\n }\n\n // Check balance\n try {\n const balance = (await this.signer.readContract({\n address: erc20Address,\n abi: eip3009ABI,\n functionName: \"balanceOf\",\n args: [exactEvmPayload.authorization.from],\n })) as bigint;\n\n if (BigInt(balance) < BigInt(requirements.amount)) {\n return {\n isValid: false,\n invalidReason: \"insufficient_funds\",\n payer: exactEvmPayload.authorization.from,\n };\n }\n } catch {\n // If we can't check balance, continue with other validations\n }\n\n // Verify amount is sufficient\n if (BigInt(exactEvmPayload.authorization.value) < BigInt(requirements.amount)) {\n return {\n isValid: false,\n invalidReason: \"invalid_exact_evm_payload_authorization_value\",\n payer: exactEvmPayload.authorization.from,\n };\n }\n\n return {\n isValid: true,\n invalidReason: undefined,\n payer: exactEvmPayload.authorization.from,\n };\n }\n\n /**\n * Settles a payment by executing the transfer.\n *\n * @param payload - The payment payload to settle\n * @param requirements - The payment requirements\n * @returns Promise resolving to settlement response\n */\n async settle(\n payload: PaymentPayload,\n requirements: PaymentRequirements,\n ): Promise<SettleResponse> {\n const exactEvmPayload = payload.payload as ExactEvmPayloadV2;\n\n // Re-verify before settling\n const valid = await this.verify(payload, requirements);\n if (!valid.isValid) {\n return {\n success: false,\n network: payload.accepted.network,\n transaction: \"\",\n errorReason: valid.invalidReason ?? \"invalid_scheme\",\n payer: exactEvmPayload.authorization.from,\n };\n }\n\n try {\n // Parse ERC-6492 signature if applicable\n const parseResult = parseErc6492Signature(exactEvmPayload.signature!);\n const { signature, address: factoryAddress, data: factoryCalldata } = parseResult;\n\n // Deploy ERC-4337 smart wallet via EIP-6492 if configured and needed\n if (\n this.config.deployERC4337WithEIP6492 &&\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 // Wallet not deployed - attempt deployment\n try {\n console.log(`Deploying ERC-4337 smart wallet for ${payerAddress} via EIP-6492`);\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 transaction\n await this.signer.waitForTransactionReceipt({ hash: deployTx });\n console.log(`Successfully deployed smart wallet for ${payerAddress}`);\n } catch (deployError) {\n console.error(\"Smart wallet deployment failed:\", deployError);\n // Deployment failed - cannot proceed\n throw deployError;\n }\n } else {\n console.log(`Smart wallet for ${payerAddress} already deployed, skipping deployment`);\n }\n }\n\n // Determine if this is an ECDSA signature (EOA) or smart wallet signature\n // ECDSA signatures are exactly 65 bytes (130 hex chars without 0x)\n const signatureLength = signature.startsWith(\"0x\") ? signature.length - 2 : signature.length;\n const isECDSA = signatureLength === 130;\n\n let tx: Hex;\n if (isECDSA) {\n // For EOA wallets, parse signature into v, r, s and use that overload\n const parsedSig = parseSignature(signature);\n\n tx = await this.signer.writeContract({\n address: getAddress(requirements.asset),\n abi: eip3009ABI,\n functionName: \"transferWithAuthorization\",\n args: [\n getAddress(exactEvmPayload.authorization.from),\n getAddress(exactEvmPayload.authorization.to),\n BigInt(exactEvmPayload.authorization.value),\n BigInt(exactEvmPayload.authorization.validAfter),\n BigInt(exactEvmPayload.authorization.validBefore),\n exactEvmPayload.authorization.nonce,\n (parsedSig.v as number | undefined) || parsedSig.yParity,\n parsedSig.r,\n parsedSig.s,\n ],\n });\n } else {\n // For smart wallets, use the bytes signature overload\n // The signature contains WebAuthn/P256 or other ERC-1271 compatible signature data\n tx = await this.signer.writeContract({\n address: getAddress(requirements.asset),\n abi: eip3009ABI,\n functionName: \"transferWithAuthorization\",\n args: [\n getAddress(exactEvmPayload.authorization.from),\n getAddress(exactEvmPayload.authorization.to),\n BigInt(exactEvmPayload.authorization.value),\n BigInt(exactEvmPayload.authorization.validAfter),\n BigInt(exactEvmPayload.authorization.validBefore),\n exactEvmPayload.authorization.nonce,\n signature,\n ],\n });\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: \"invalid_transaction_state\",\n transaction: tx,\n network: payload.accepted.network,\n payer: exactEvmPayload.authorization.from,\n };\n }\n\n return {\n success: true,\n transaction: tx,\n network: payload.accepted.network,\n payer: exactEvmPayload.authorization.from,\n };\n } catch (error) {\n console.error(\"Failed to settle transaction:\", error);\n return {\n success: false,\n errorReason: \"transaction_failed\",\n transaction: \"\",\n network: payload.accepted.network,\n payer: exactEvmPayload.authorization.from,\n };\n }\n }\n}\n","// EIP-3009 TransferWithAuthorization types for EIP-712 signing\nexport const authorizationTypes = {\n TransferWithAuthorization: [\n { name: \"from\", type: \"address\" },\n { name: \"to\", type: \"address\" },\n { name: \"value\", type: \"uint256\" },\n { name: \"validAfter\", type: \"uint256\" },\n { name: \"validBefore\", type: \"uint256\" },\n { name: \"nonce\", type: \"bytes32\" },\n ],\n} as const;\n\n// Legacy transfer authorization types for EIP-712 signing\n// Used for tokens without EIP-3009 support (approve + transferFrom pattern)\nexport const legacyAuthorizationTypes = {\n LegacyTransferAuthorization: [\n { name: \"from\", type: \"address\" },\n { name: \"to\", type: \"address\" },\n { name: \"value\", type: \"uint256\" },\n { name: \"validAfter\", type: \"uint256\" },\n { name: \"validBefore\", type: \"uint256\" },\n { name: \"nonce\", type: \"bytes32\" },\n { name: \"spender\", type: \"address\" },\n ],\n} as const;\n\n// EIP3009 ABI for transferWithAuthorization function\nexport const eip3009ABI = [\n {\n inputs: [\n { name: \"from\", type: \"address\" },\n { name: \"to\", type: \"address\" },\n { name: \"value\", type: \"uint256\" },\n { name: \"validAfter\", type: \"uint256\" },\n { name: \"validBefore\", type: \"uint256\" },\n { name: \"nonce\", type: \"bytes32\" },\n { name: \"v\", type: \"uint8\" },\n { name: \"r\", type: \"bytes32\" },\n { name: \"s\", type: \"bytes32\" },\n ],\n name: \"transferWithAuthorization\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"from\", type: \"address\" },\n { name: \"to\", type: \"address\" },\n { name: \"value\", type: \"uint256\" },\n { name: \"validAfter\", type: \"uint256\" },\n { name: \"validBefore\", type: \"uint256\" },\n { name: \"nonce\", type: \"bytes32\" },\n { name: \"signature\", type: \"bytes\" },\n ],\n name: \"transferWithAuthorization\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [{ name: \"account\", type: \"address\" }],\n name: \"balanceOf\",\n outputs: [{ name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"version\",\n outputs: [{ name: \"\", type: \"string\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const;\n\n// Standard ERC20 ABI for legacy token operations (approve + transferFrom pattern)\nexport const erc20LegacyABI = [\n {\n inputs: [{ name: \"account\", type: \"address\" }],\n name: \"balanceOf\",\n outputs: [{ name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"owner\", type: \"address\" },\n { name: \"spender\", type: \"address\" },\n ],\n name: \"allowance\",\n outputs: [{ name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"spender\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n name: \"approve\",\n outputs: [{ name: \"\", type: \"bool\" }],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"from\", type: \"address\" },\n { name: \"to\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n name: \"transferFrom\",\n outputs: [{ name: \"\", type: \"bool\" }],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n] as const;\n","import {\n PaymentPayload,\n PaymentPayloadV1,\n PaymentRequirements,\n SchemeNetworkFacilitator,\n SettleResponse,\n VerifyResponse,\n} from \"@t402/core/types\";\nimport { PaymentRequirementsV1 } from \"@t402/core/types/v1\";\nimport { getAddress, Hex, isAddressEqual, parseErc6492Signature, parseSignature } from \"viem\";\nimport { authorizationTypes, eip3009ABI } from \"../../../constants\";\nimport { FacilitatorEvmSigner } from \"../../../signer\";\nimport { ExactEvmPayloadV1 } from \"../../../types\";\nimport { getEvmChainId } from \"../../../utils\";\n\nexport interface ExactEvmSchemeV1Config {\n /**\n * If enabled, the facilitator will deploy ERC-4337 smart wallets\n * via EIP-6492 when encountering undeployed contract signatures.\n *\n * @default false\n */\n deployERC4337WithEIP6492?: 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 deployERC4337WithEIP6492: config?.deployERC4337WithEIP6492 ?? 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 const requirementsV1 = requirements as unknown as PaymentRequirementsV1;\n const payloadV1 = payload as unknown as PaymentPayloadV1;\n const exactEvmPayload = payload.payload as ExactEvmPayloadV1;\n\n // Verify scheme matches\n if (payloadV1.scheme !== \"exact\" || requirements.scheme !== \"exact\") {\n return {\n isValid: false,\n invalidReason: \"unsupported_scheme\",\n payer: exactEvmPayload.authorization.from,\n };\n }\n\n // Get chain configuration\n const chainId = getEvmChainId(payloadV1.network);\n\n if (!requirements.extra?.name || !requirements.extra?.version) {\n return {\n isValid: false,\n invalidReason: \"missing_eip712_domain\",\n payer: exactEvmPayload.authorization.from,\n };\n }\n\n const { name, version } = requirements.extra;\n const erc20Address = getAddress(requirements.asset);\n\n // Verify network matches\n if (payloadV1.network !== requirements.network) {\n return {\n isValid: false,\n invalidReason: \"network_mismatch\",\n payer: exactEvmPayload.authorization.from,\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 // Verify signature\n try {\n const recoveredAddress = await this.signer.verifyTypedData({\n address: exactEvmPayload.authorization.from,\n ...permitTypedData,\n signature: exactEvmPayload.signature!,\n });\n\n if (!recoveredAddress) {\n return {\n isValid: false,\n invalidReason: \"invalid_exact_evm_payload_signature\",\n payer: exactEvmPayload.authorization.from,\n };\n }\n } catch {\n // Signature verification failed - could be an undeployed smart wallet\n // Check if smart wallet is deployed\n const signature = exactEvmPayload.signature!;\n const signatureLength = signature.startsWith(\"0x\") ? signature.length - 2 : signature.length;\n const isSmartWallet = signatureLength > 130; // 65 bytes = 130 hex chars for EOA\n\n if (isSmartWallet) {\n const payerAddress = exactEvmPayload.authorization.from;\n const bytecode = await this.signer.getCode({ address: payerAddress });\n\n if (!bytecode || bytecode === \"0x\") {\n // Wallet is not deployed. Check if it's EIP-6492 with deployment info.\n // EIP-6492 signatures contain factory address and calldata needed for deployment.\n // Non-EIP-6492 undeployed wallets cannot succeed (no way to deploy them).\n const erc6492Data = parseErc6492Signature(signature);\n const hasDeploymentInfo =\n erc6492Data.address &&\n erc6492Data.data &&\n !isAddressEqual(erc6492Data.address, \"0x0000000000000000000000000000000000000000\");\n\n if (!hasDeploymentInfo) {\n // Non-EIP-6492 undeployed smart wallet - will always fail at settlement\n // since EIP-3009 requires on-chain EIP-1271 validation\n return {\n isValid: false,\n invalidReason: \"invalid_exact_evm_payload_undeployed_smart_wallet\",\n payer: payerAddress,\n };\n }\n // EIP-6492 signature with deployment info - allow through\n // Facilitators with sponsored deployment support can handle this in settle()\n } else {\n // Wallet is deployed but signature still failed - invalid signature\n return {\n isValid: false,\n invalidReason: \"invalid_exact_evm_payload_signature\",\n payer: exactEvmPayload.authorization.from,\n };\n }\n } else {\n // EOA signature failed\n return {\n isValid: false,\n invalidReason: \"invalid_exact_evm_payload_signature\",\n payer: exactEvmPayload.authorization.from,\n };\n }\n }\n\n // Verify payment recipient matches\n if (getAddress(exactEvmPayload.authorization.to) !== getAddress(requirements.payTo)) {\n return {\n isValid: false,\n invalidReason: \"invalid_exact_evm_payload_recipient_mismatch\",\n payer: exactEvmPayload.authorization.from,\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: \"invalid_exact_evm_payload_authorization_valid_before\",\n payer: exactEvmPayload.authorization.from,\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: \"invalid_exact_evm_payload_authorization_valid_after\",\n payer: exactEvmPayload.authorization.from,\n };\n }\n\n // Check balance\n try {\n const balance = (await this.signer.readContract({\n address: erc20Address,\n abi: eip3009ABI,\n functionName: \"balanceOf\",\n args: [exactEvmPayload.authorization.from],\n })) as bigint;\n\n if (BigInt(balance) < BigInt(requirementsV1.maxAmountRequired)) {\n return {\n isValid: false,\n invalidReason: \"insufficient_funds\",\n payer: exactEvmPayload.authorization.from,\n };\n }\n } catch {\n // If we can't check balance, continue with other validations\n }\n\n // Verify amount is sufficient\n if (BigInt(exactEvmPayload.authorization.value) < BigInt(requirementsV1.maxAmountRequired)) {\n return {\n isValid: false,\n invalidReason: \"invalid_exact_evm_payload_authorization_value\",\n payer: exactEvmPayload.authorization.from,\n };\n }\n\n return {\n isValid: true,\n invalidReason: undefined,\n payer: exactEvmPayload.authorization.from,\n };\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 * @returns Promise resolving to settlement response\n */\n async settle(\n payload: PaymentPayload,\n requirements: PaymentRequirements,\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 if (!valid.isValid) {\n return {\n success: false,\n network: payloadV1.network,\n transaction: \"\",\n errorReason: valid.invalidReason ?? \"invalid_scheme\",\n payer: exactEvmPayload.authorization.from,\n };\n }\n\n try {\n // Parse ERC-6492 signature if applicable\n const parseResult = parseErc6492Signature(exactEvmPayload.signature!);\n const { signature, address: factoryAddress, data: factoryCalldata } = parseResult;\n\n // Deploy ERC-4337 smart wallet via EIP-6492 if configured and needed\n if (\n this.config.deployERC4337WithEIP6492 &&\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 // Wallet not deployed - attempt deployment\n try {\n console.log(`Deploying ERC-4337 smart wallet for ${payerAddress} via EIP-6492`);\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 transaction\n await this.signer.waitForTransactionReceipt({ hash: deployTx });\n console.log(`Successfully deployed smart wallet for ${payerAddress}`);\n } catch (deployError) {\n console.error(\"Smart wallet deployment failed:\", deployError);\n // Deployment failed - cannot proceed\n throw deployError;\n }\n } else {\n console.log(`Smart wallet for ${payerAddress} already deployed, skipping deployment`);\n }\n }\n\n // Determine if this is an ECDSA signature (EOA) or smart wallet signature\n // ECDSA signatures are exactly 65 bytes (130 hex chars without 0x)\n const signatureLength = signature.startsWith(\"0x\") ? signature.length - 2 : signature.length;\n const isECDSA = signatureLength === 130;\n\n let tx: Hex;\n if (isECDSA) {\n // For EOA wallets, parse signature into v, r, s and use that overload\n const parsedSig = parseSignature(signature);\n\n tx = await this.signer.writeContract({\n address: getAddress(requirements.asset),\n abi: eip3009ABI,\n functionName: \"transferWithAuthorization\",\n args: [\n getAddress(exactEvmPayload.authorization.from),\n getAddress(exactEvmPayload.authorization.to),\n BigInt(exactEvmPayload.authorization.value),\n BigInt(exactEvmPayload.authorization.validAfter),\n BigInt(exactEvmPayload.authorization.validBefore),\n exactEvmPayload.authorization.nonce,\n (parsedSig.v as number | undefined) || parsedSig.yParity,\n parsedSig.r,\n parsedSig.s,\n ],\n });\n } else {\n // For smart wallets, use the bytes signature overload\n // The signature contains WebAuthn/P256 or other ERC-1271 compatible signature data\n tx = await this.signer.writeContract({\n address: getAddress(requirements.asset),\n abi: eip3009ABI,\n functionName: \"transferWithAuthorization\",\n args: [\n getAddress(exactEvmPayload.authorization.from),\n getAddress(exactEvmPayload.authorization.to),\n BigInt(exactEvmPayload.authorization.value),\n BigInt(exactEvmPayload.authorization.validAfter),\n BigInt(exactEvmPayload.authorization.validBefore),\n exactEvmPayload.authorization.nonce,\n signature,\n ],\n });\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: \"invalid_transaction_state\",\n transaction: tx,\n network: payloadV1.network,\n payer: exactEvmPayload.authorization.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 console.error(\"Failed to settle transaction:\", error);\n return {\n success: false,\n errorReason: \"transaction_failed\",\n transaction: \"\",\n network: payloadV1.network,\n payer: exactEvmPayload.authorization.from,\n };\n }\n }\n}\n","import { toHex } from \"viem\";\nimport { Network } from \"@t402/core/types\";\n\n/**\n * Extract chain ID from network string (e.g., \"base-sepolia\" -> 84532)\n * Used by v1 implementations\n *\n * @param network - The network identifier\n * @returns The numeric chain ID\n */\nexport function getEvmChainId(network: Network): number {\n const networkMap: Record<string, number> = {\n base: 8453,\n \"base-sepolia\": 84532,\n ethereum: 1,\n sepolia: 11155111,\n polygon: 137,\n \"polygon-amoy\": 80002,\n };\n return networkMap[network] || 1;\n}\n\n/**\n * Create a random 32-byte nonce for authorization\n *\n * @returns A hex-encoded 32-byte nonce\n */\nexport function createNonce(): `0x${string}` {\n // Use dynamic import to avoid require() in ESM context\n const cryptoObj =\n typeof globalThis.crypto !== \"undefined\"\n ? globalThis.crypto\n : (globalThis as { crypto?: Crypto }).crypto;\n\n if (!cryptoObj) {\n throw new Error(\"Crypto API not available\");\n }\n\n return toHex(cryptoObj.getRandomValues(new Uint8Array(32)));\n}\n","import {\n Network,\n PaymentPayload,\n PaymentRequirements,\n SchemeNetworkClient,\n} from \"@t402/core/types\";\nimport { PaymentRequirementsV1 } from \"@t402/core/types/v1\";\nimport { getAddress } from \"viem\";\nimport { authorizationTypes } from \"../../../constants\";\nimport { ClientEvmSigner } from \"../../../signer\";\nimport { ExactEvmPayloadV1 } from \"../../../types\";\nimport { createNonce, getEvmChainId } from \"../../../utils\";\n\n/**\n * EVM client implementation for the Exact payment scheme (V1).\n */\nexport class ExactEvmSchemeV1 implements SchemeNetworkClient {\n readonly scheme = \"exact\";\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 t402Version - The t402 protocol version\n * @param paymentRequirements - The payment requirements\n * @returns Promise resolving to a payment payload\n */\n async createPaymentPayload(\n t402Version: number,\n paymentRequirements: PaymentRequirements,\n ): Promise<\n Pick<PaymentPayload, \"t402Version\" | \"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: (now - 600).toString(), // 10 minutes before\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 t402Version,\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 = getEvmChainId(requirements.network);\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","export { ExactEvmSchemeV1 } from \"../exact/v1\";\n\nexport const NETWORKS: string[] = [\n \"abstract\",\n \"abstract-testnet\",\n \"base-sepolia\",\n \"base\",\n \"avalanche-fuji\",\n \"avalanche\",\n \"iotex\",\n \"sei\",\n \"sei-testnet\",\n \"polygon\",\n \"polygon-amoy\",\n \"peaq\",\n \"story\",\n \"educhain\",\n \"skale-base-sepolia\",\n];\n","import { t402Facilitator } from \"@t402/core/facilitator\";\nimport { Network } from \"@t402/core/types\";\nimport { FacilitatorEvmSigner } from \"../../signer\";\nimport { ExactEvmScheme } from \"./scheme\";\nimport { ExactEvmSchemeV1 } from \"../v1/facilitator/scheme\";\nimport { NETWORKS } from \"../../v1\";\n\n/**\n * Configuration options for registering EVM schemes to an t402Facilitator\n */\nexport interface EvmFacilitatorConfig {\n /**\n * The EVM signer for facilitator operations (verify and settle)\n */\n signer: FacilitatorEvmSigner;\n\n /**\n * Networks to register (single network or array of networks)\n * Examples: \"eip155:84532\", [\"eip155:84532\", \"eip155:1\"]\n */\n networks: Network | Network[];\n\n /**\n * If enabled, the facilitator will deploy ERC-4337 smart wallets\n * via EIP-6492 when encountering undeployed contract signatures.\n *\n * @default false\n */\n deployERC4337WithEIP6492?: boolean;\n}\n\n/**\n * Registers EVM exact payment schemes to an t402Facilitator instance.\n *\n * This function registers:\n * - V2: Specified networks with ExactEvmScheme\n * - V1: All supported EVM networks with ExactEvmSchemeV1\n *\n * @param facilitator - The t402Facilitator instance to register schemes to\n * @param config - Configuration for EVM facilitator registration\n * @returns The facilitator instance for chaining\n *\n * @example\n * ```typescript\n * import { registerExactEvmScheme } from \"@t402/evm/exact/facilitator/register\";\n * import { t402Facilitator } from \"@t402/core/facilitator\";\n * import { createPublicClient, createWalletClient } from \"viem\";\n *\n * const facilitator = new t402Facilitator();\n *\n * // Single network\n * registerExactEvmScheme(facilitator, {\n * signer: combinedClient,\n * networks: \"eip155:84532\" // Base Sepolia\n * });\n *\n * // Multiple networks (will auto-derive eip155:* pattern)\n * registerExactEvmScheme(facilitator, {\n * signer: combinedClient,\n * networks: [\"eip155:84532\", \"eip155:1\"] // Base Sepolia and Mainnet\n * });\n * ```\n */\nexport function registerExactEvmScheme(\n facilitator: t402Facilitator,\n config: EvmFacilitatorConfig,\n): t402Facilitator {\n // Register V2 scheme with specified networks\n facilitator.register(\n config.networks,\n new ExactEvmScheme(config.signer, {\n deployERC4337WithEIP6492: config.deployERC4337WithEIP6492,\n }),\n );\n\n // Register all V1 networks\n facilitator.registerV1(\n NETWORKS as Network[],\n new ExactEvmSchemeV1(config.signer, {\n deployERC4337WithEIP6492: config.deployERC4337WithEIP6492,\n }),\n );\n\n return facilitator;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOA,kBAAuF;;;ACNhF,IAAM,qBAAqB;AAAA,EAChC,2BAA2B;AAAA,IACzB,EAAE,MAAM,QAAQ,MAAM,UAAU;AAAA,IAChC,EAAE,MAAM,MAAM,MAAM,UAAU;AAAA,IAC9B,EAAE,MAAM,SAAS,MAAM,UAAU;AAAA,IACjC,EAAE,MAAM,cAAc,MAAM,UAAU;AAAA,IACtC,EAAE,MAAM,eAAe,MAAM,UAAU;AAAA,IACvC,EAAE,MAAM,SAAS,MAAM,UAAU;AAAA,EACnC;AACF;AAiBO,IAAM,aAAa;AAAA,EACxB;AAAA,IACE,QAAQ;AAAA,MACN,EAAE,MAAM,QAAQ,MAAM,UAAU;AAAA,MAChC,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0B,OAAO;AAAA,IACnC,CAAC;AAAA,EACH;AAGA,cAAY;AAAA,IACV;AAAA,IACA,IAAI,iBAAiB,OAAO,QAAQ;AAAA,MAClC,0BAA0B,OAAO;AAAA,IACnC,CAAC;AAAA,EACH;AAEA,SAAO;AACT;","names":["import_viem","import_viem","import_viem"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export { E as ExactEvmScheme } from '../../scheme-yqGaK9rK.js';
|
|
2
|
+
import { t402ResourceServer } from '@t402/core/server';
|
|
3
|
+
import { Network } from '@t402/core/types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Configuration options for registering EVM schemes to an t402ResourceServer
|
|
7
|
+
*/
|
|
8
|
+
interface EvmResourceServerConfig {
|
|
9
|
+
/**
|
|
10
|
+
* Optional specific networks to register
|
|
11
|
+
* If not provided, registers wildcard support (eip155:*)
|
|
12
|
+
*/
|
|
13
|
+
networks?: Network[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Registers EVM exact payment schemes to an t402ResourceServer instance.
|
|
17
|
+
*
|
|
18
|
+
* This function registers:
|
|
19
|
+
* - V2: eip155:* wildcard scheme with ExactEvmScheme (or specific networks if provided)
|
|
20
|
+
*
|
|
21
|
+
* @param server - The t402ResourceServer instance to register schemes to
|
|
22
|
+
* @param config - Configuration for EVM resource server registration
|
|
23
|
+
* @returns The server instance for chaining
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { registerExactEvmScheme } from "@t402/evm/exact/server/register";
|
|
28
|
+
* import { t402ResourceServer } from "@t402/core/server";
|
|
29
|
+
*
|
|
30
|
+
* const server = new t402ResourceServer(facilitatorClient);
|
|
31
|
+
* registerExactEvmScheme(server, {});
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
declare function registerExactEvmScheme(server: t402ResourceServer, config?: EvmResourceServerConfig): t402ResourceServer;
|
|
35
|
+
|
|
36
|
+
export { type EvmResourceServerConfig, registerExactEvmScheme };
|
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/exact/server/index.ts
|
|
21
|
+
var server_exports = {};
|
|
22
|
+
__export(server_exports, {
|
|
23
|
+
ExactEvmScheme: () => ExactEvmScheme,
|
|
24
|
+
registerExactEvmScheme: () => registerExactEvmScheme
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(server_exports);
|
|
27
|
+
|
|
28
|
+
// src/tokens.ts
|
|
29
|
+
var USDT0_ADDRESSES = {
|
|
30
|
+
// Ethereum Mainnet - OFT Adapter (bridge endpoint)
|
|
31
|
+
"eip155:1": "0x6C96dE32CEa08842dcc4058c14d3aaAD7Fa41dee",
|
|
32
|
+
// Arbitrum One - Native USDT0
|
|
33
|
+
"eip155:42161": "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
|
|
34
|
+
// Ink Mainnet
|
|
35
|
+
"eip155:57073": "0x0200C29006150606B650577BBE7B6248F58470c1",
|
|
36
|
+
// Berachain Mainnet
|
|
37
|
+
"eip155:80094": "0x779Ded0c9e1022225f8E0630b35a9b54bE713736",
|
|
38
|
+
// Unichain Mainnet
|
|
39
|
+
"eip155:130": "0x588ce4F028D8e7B53B687865d6A67b3A54C75518"
|
|
40
|
+
};
|
|
41
|
+
var USDC_ADDRESSES = {
|
|
42
|
+
// Ethereum Mainnet
|
|
43
|
+
"eip155:1": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
44
|
+
// Base Mainnet
|
|
45
|
+
"eip155:8453": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
46
|
+
// Base Sepolia (testnet)
|
|
47
|
+
"eip155:84532": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
|
|
48
|
+
// Sepolia (testnet)
|
|
49
|
+
"eip155:11155111": "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
|
|
50
|
+
// Arbitrum One
|
|
51
|
+
"eip155:42161": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
52
|
+
// Polygon Mainnet
|
|
53
|
+
"eip155:137": "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359"
|
|
54
|
+
};
|
|
55
|
+
var USDT_LEGACY_ADDRESSES = {
|
|
56
|
+
// Ethereum Mainnet
|
|
57
|
+
"eip155:1": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
|
58
|
+
// Polygon Mainnet
|
|
59
|
+
"eip155:137": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F"
|
|
60
|
+
};
|
|
61
|
+
var TOKEN_REGISTRY = {
|
|
62
|
+
// Ethereum Mainnet
|
|
63
|
+
"eip155:1": {
|
|
64
|
+
USDT0: {
|
|
65
|
+
address: USDT0_ADDRESSES["eip155:1"],
|
|
66
|
+
symbol: "USDT0",
|
|
67
|
+
name: "TetherToken",
|
|
68
|
+
version: "1",
|
|
69
|
+
decimals: 6,
|
|
70
|
+
tokenType: "eip3009",
|
|
71
|
+
priority: 1
|
|
72
|
+
},
|
|
73
|
+
USDC: {
|
|
74
|
+
address: USDC_ADDRESSES["eip155:1"],
|
|
75
|
+
symbol: "USDC",
|
|
76
|
+
name: "USD Coin",
|
|
77
|
+
version: "2",
|
|
78
|
+
decimals: 6,
|
|
79
|
+
tokenType: "eip3009",
|
|
80
|
+
priority: 2
|
|
81
|
+
},
|
|
82
|
+
USDT: {
|
|
83
|
+
address: USDT_LEGACY_ADDRESSES["eip155:1"],
|
|
84
|
+
symbol: "USDT",
|
|
85
|
+
name: "TetherUSD",
|
|
86
|
+
version: "1",
|
|
87
|
+
decimals: 6,
|
|
88
|
+
tokenType: "legacy",
|
|
89
|
+
priority: 10
|
|
90
|
+
// Lower priority due to legacy flow
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
// Arbitrum One
|
|
94
|
+
"eip155:42161": {
|
|
95
|
+
USDT0: {
|
|
96
|
+
address: USDT0_ADDRESSES["eip155:42161"],
|
|
97
|
+
symbol: "USDT0",
|
|
98
|
+
name: "TetherToken",
|
|
99
|
+
version: "1",
|
|
100
|
+
decimals: 6,
|
|
101
|
+
tokenType: "eip3009",
|
|
102
|
+
priority: 1
|
|
103
|
+
},
|
|
104
|
+
USDC: {
|
|
105
|
+
address: USDC_ADDRESSES["eip155:42161"],
|
|
106
|
+
symbol: "USDC",
|
|
107
|
+
name: "USD Coin",
|
|
108
|
+
version: "2",
|
|
109
|
+
decimals: 6,
|
|
110
|
+
tokenType: "eip3009",
|
|
111
|
+
priority: 2
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
// Ink Mainnet
|
|
115
|
+
"eip155:57073": {
|
|
116
|
+
USDT0: {
|
|
117
|
+
address: USDT0_ADDRESSES["eip155:57073"],
|
|
118
|
+
symbol: "USDT0",
|
|
119
|
+
name: "TetherToken",
|
|
120
|
+
version: "1",
|
|
121
|
+
decimals: 6,
|
|
122
|
+
tokenType: "eip3009",
|
|
123
|
+
priority: 1
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
// Berachain Mainnet
|
|
127
|
+
"eip155:80094": {
|
|
128
|
+
USDT0: {
|
|
129
|
+
address: USDT0_ADDRESSES["eip155:80094"],
|
|
130
|
+
symbol: "USDT0",
|
|
131
|
+
name: "TetherToken",
|
|
132
|
+
version: "1",
|
|
133
|
+
decimals: 6,
|
|
134
|
+
tokenType: "eip3009",
|
|
135
|
+
priority: 1
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
// Unichain Mainnet
|
|
139
|
+
"eip155:130": {
|
|
140
|
+
USDT0: {
|
|
141
|
+
address: USDT0_ADDRESSES["eip155:130"],
|
|
142
|
+
symbol: "USDT0",
|
|
143
|
+
name: "TetherToken",
|
|
144
|
+
version: "1",
|
|
145
|
+
decimals: 6,
|
|
146
|
+
tokenType: "eip3009",
|
|
147
|
+
priority: 1
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
// Base Mainnet
|
|
151
|
+
"eip155:8453": {
|
|
152
|
+
USDC: {
|
|
153
|
+
address: USDC_ADDRESSES["eip155:8453"],
|
|
154
|
+
symbol: "USDC",
|
|
155
|
+
name: "USD Coin",
|
|
156
|
+
version: "2",
|
|
157
|
+
decimals: 6,
|
|
158
|
+
tokenType: "eip3009",
|
|
159
|
+
priority: 2
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
// Base Sepolia (testnet)
|
|
163
|
+
"eip155:84532": {
|
|
164
|
+
USDC: {
|
|
165
|
+
address: USDC_ADDRESSES["eip155:84532"],
|
|
166
|
+
symbol: "USDC",
|
|
167
|
+
name: "USDC",
|
|
168
|
+
version: "2",
|
|
169
|
+
decimals: 6,
|
|
170
|
+
tokenType: "eip3009",
|
|
171
|
+
priority: 2
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
// Sepolia (testnet)
|
|
175
|
+
"eip155:11155111": {
|
|
176
|
+
USDC: {
|
|
177
|
+
address: USDC_ADDRESSES["eip155:11155111"],
|
|
178
|
+
symbol: "USDC",
|
|
179
|
+
name: "USDC",
|
|
180
|
+
version: "2",
|
|
181
|
+
decimals: 6,
|
|
182
|
+
tokenType: "eip3009",
|
|
183
|
+
priority: 2
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
// Polygon Mainnet
|
|
187
|
+
"eip155:137": {
|
|
188
|
+
USDC: {
|
|
189
|
+
address: USDC_ADDRESSES["eip155:137"],
|
|
190
|
+
symbol: "USDC",
|
|
191
|
+
name: "USD Coin",
|
|
192
|
+
version: "2",
|
|
193
|
+
decimals: 6,
|
|
194
|
+
tokenType: "eip3009",
|
|
195
|
+
priority: 2
|
|
196
|
+
},
|
|
197
|
+
USDT: {
|
|
198
|
+
address: USDT_LEGACY_ADDRESSES["eip155:137"],
|
|
199
|
+
symbol: "USDT",
|
|
200
|
+
name: "TetherUSD",
|
|
201
|
+
version: "1",
|
|
202
|
+
decimals: 6,
|
|
203
|
+
tokenType: "legacy",
|
|
204
|
+
priority: 10
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
function getTokenConfig(network, symbol) {
|
|
209
|
+
return TOKEN_REGISTRY[network]?.[symbol.toUpperCase()];
|
|
210
|
+
}
|
|
211
|
+
function getNetworkTokens(network) {
|
|
212
|
+
const tokens = TOKEN_REGISTRY[network];
|
|
213
|
+
if (!tokens) return [];
|
|
214
|
+
return Object.values(tokens).sort((a, b) => a.priority - b.priority);
|
|
215
|
+
}
|
|
216
|
+
function getDefaultToken(network) {
|
|
217
|
+
const tokens = getNetworkTokens(network);
|
|
218
|
+
return tokens[0];
|
|
219
|
+
}
|
|
220
|
+
function getTokenByAddress(network, address) {
|
|
221
|
+
const tokens = TOKEN_REGISTRY[network];
|
|
222
|
+
if (!tokens) return void 0;
|
|
223
|
+
const lowerAddress = address.toLowerCase();
|
|
224
|
+
return Object.values(tokens).find((t) => t.address.toLowerCase() === lowerAddress);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// src/exact/server/scheme.ts
|
|
228
|
+
var ExactEvmScheme = class {
|
|
229
|
+
constructor(config = {}) {
|
|
230
|
+
this.scheme = "exact";
|
|
231
|
+
this.moneyParsers = [];
|
|
232
|
+
this.config = config;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Register a custom money parser in the parser chain.
|
|
236
|
+
* Multiple parsers can be registered - they will be tried in registration order.
|
|
237
|
+
* Each parser receives a decimal amount (e.g., 1.50 for $1.50).
|
|
238
|
+
* If a parser returns null, the next parser in the chain will be tried.
|
|
239
|
+
* The default parser is always the final fallback.
|
|
240
|
+
*
|
|
241
|
+
* @param parser - Custom function to convert amount to AssetAmount (or null to skip)
|
|
242
|
+
* @returns The server instance for chaining
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* evmServer.registerMoneyParser(async (amount, network) => {
|
|
246
|
+
* // Custom conversion logic
|
|
247
|
+
* if (amount > 100) {
|
|
248
|
+
* // Use different token for large amounts
|
|
249
|
+
* return { amount: (amount * 1e18).toString(), asset: "0xCustomToken" };
|
|
250
|
+
* }
|
|
251
|
+
* return null; // Use next parser
|
|
252
|
+
* });
|
|
253
|
+
*/
|
|
254
|
+
registerMoneyParser(parser) {
|
|
255
|
+
this.moneyParsers.push(parser);
|
|
256
|
+
return this;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Parses a price into an asset amount.
|
|
260
|
+
* If price is already an AssetAmount, returns it directly.
|
|
261
|
+
* If price is Money (string | number), parses to decimal and tries custom parsers.
|
|
262
|
+
* Falls back to default conversion if all custom parsers return null.
|
|
263
|
+
*
|
|
264
|
+
* @param price - The price to parse
|
|
265
|
+
* @param network - The network to use
|
|
266
|
+
* @returns Promise that resolves to the parsed asset amount
|
|
267
|
+
*/
|
|
268
|
+
async parsePrice(price, network) {
|
|
269
|
+
if (typeof price === "object" && price !== null && "amount" in price) {
|
|
270
|
+
if (!price.asset) {
|
|
271
|
+
throw new Error(`Asset address must be specified for AssetAmount on network ${network}`);
|
|
272
|
+
}
|
|
273
|
+
return {
|
|
274
|
+
amount: price.amount,
|
|
275
|
+
asset: price.asset,
|
|
276
|
+
extra: price.extra || {}
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
const amount = this.parseMoneyToDecimal(price);
|
|
280
|
+
for (const parser of this.moneyParsers) {
|
|
281
|
+
const result = await parser(amount, network);
|
|
282
|
+
if (result !== null) {
|
|
283
|
+
return result;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return this.defaultMoneyConversion(amount, network);
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Build payment requirements for this scheme/network combination
|
|
290
|
+
*
|
|
291
|
+
* @param paymentRequirements - The base payment requirements
|
|
292
|
+
* @param supportedKind - The supported kind from facilitator (unused)
|
|
293
|
+
* @param supportedKind.t402Version - The t402 version
|
|
294
|
+
* @param supportedKind.scheme - The logical payment scheme
|
|
295
|
+
* @param supportedKind.network - The network identifier in CAIP-2 format
|
|
296
|
+
* @param supportedKind.extra - Optional extra metadata regarding scheme/network implementation details
|
|
297
|
+
* @param extensionKeys - Extension keys supported by the facilitator (unused)
|
|
298
|
+
* @returns Payment requirements ready to be sent to clients
|
|
299
|
+
*/
|
|
300
|
+
enhancePaymentRequirements(paymentRequirements, supportedKind, extensionKeys) {
|
|
301
|
+
void supportedKind;
|
|
302
|
+
void extensionKeys;
|
|
303
|
+
return Promise.resolve(paymentRequirements);
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Parse Money (string | number) to a decimal number.
|
|
307
|
+
* Handles formats like "$1.50", "1.50", 1.50, etc.
|
|
308
|
+
*
|
|
309
|
+
* @param money - The money value to parse
|
|
310
|
+
* @returns Decimal number
|
|
311
|
+
*/
|
|
312
|
+
parseMoneyToDecimal(money) {
|
|
313
|
+
if (typeof money === "number") {
|
|
314
|
+
return money;
|
|
315
|
+
}
|
|
316
|
+
const cleanMoney = money.replace(/^\$/, "").trim();
|
|
317
|
+
const amount = parseFloat(cleanMoney);
|
|
318
|
+
if (isNaN(amount)) {
|
|
319
|
+
throw new Error(`Invalid money format: ${money}`);
|
|
320
|
+
}
|
|
321
|
+
return amount;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Default money conversion implementation.
|
|
325
|
+
* Converts decimal amount to the preferred token on the specified network.
|
|
326
|
+
* Priority: USDT0 > USDC > other configured tokens
|
|
327
|
+
*
|
|
328
|
+
* @param amount - The decimal amount (e.g., 1.50)
|
|
329
|
+
* @param network - The network to use
|
|
330
|
+
* @returns The parsed asset amount
|
|
331
|
+
*/
|
|
332
|
+
defaultMoneyConversion(amount, network) {
|
|
333
|
+
const token = this.getDefaultAsset(network);
|
|
334
|
+
const tokenAmount = this.convertToTokenAmount(amount.toString(), network, token.decimals);
|
|
335
|
+
return {
|
|
336
|
+
amount: tokenAmount,
|
|
337
|
+
asset: token.address,
|
|
338
|
+
extra: {
|
|
339
|
+
name: token.name,
|
|
340
|
+
version: token.version,
|
|
341
|
+
symbol: token.symbol,
|
|
342
|
+
tokenType: token.tokenType
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Convert decimal amount to token units (e.g., 0.10 -> 100000 for 6-decimal tokens)
|
|
348
|
+
*
|
|
349
|
+
* @param decimalAmount - The decimal amount to convert
|
|
350
|
+
* @param network - The network to use
|
|
351
|
+
* @param decimals - Optional number of decimals (defaults to network asset decimals)
|
|
352
|
+
* @returns The token amount as a string
|
|
353
|
+
*/
|
|
354
|
+
convertToTokenAmount(decimalAmount, network, decimals) {
|
|
355
|
+
const tokenDecimals = decimals ?? this.getAssetDecimals(network);
|
|
356
|
+
const amount = parseFloat(decimalAmount);
|
|
357
|
+
if (isNaN(amount)) {
|
|
358
|
+
throw new Error(`Invalid amount: ${decimalAmount}`);
|
|
359
|
+
}
|
|
360
|
+
const tokenAmount = Math.floor(amount * Math.pow(10, tokenDecimals));
|
|
361
|
+
return tokenAmount.toString();
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Get the default asset info for a network.
|
|
365
|
+
* Priority: configured preferredToken > USDT0 > USDC > first available
|
|
366
|
+
*
|
|
367
|
+
* @param network - The network to get asset info for
|
|
368
|
+
* @returns The asset information including address, name, version, and decimals
|
|
369
|
+
*/
|
|
370
|
+
getDefaultAsset(network) {
|
|
371
|
+
if (this.config.preferredToken) {
|
|
372
|
+
const preferred = getTokenConfig(network, this.config.preferredToken);
|
|
373
|
+
if (preferred) return preferred;
|
|
374
|
+
}
|
|
375
|
+
const defaultToken = getDefaultToken(network);
|
|
376
|
+
if (defaultToken) return defaultToken;
|
|
377
|
+
throw new Error(`No tokens configured for network ${network}`);
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Get asset info for a given symbol on a network
|
|
381
|
+
*
|
|
382
|
+
* @param symbol - The asset symbol (e.g., "USDT0", "USDC", "USDT")
|
|
383
|
+
* @param network - The network to use
|
|
384
|
+
* @returns The token configuration
|
|
385
|
+
*/
|
|
386
|
+
getAssetInfo(symbol, network) {
|
|
387
|
+
const token = getTokenConfig(network, symbol);
|
|
388
|
+
if (token) return token;
|
|
389
|
+
if (symbol.toUpperCase() === "USD") {
|
|
390
|
+
return this.getDefaultAsset(network);
|
|
391
|
+
}
|
|
392
|
+
throw new Error(`Unsupported asset: ${symbol} on network ${network}`);
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Get the number of decimals for the asset on a network
|
|
396
|
+
*
|
|
397
|
+
* @param network - The network to use
|
|
398
|
+
* @param tokenAddress - Optional token address to look up
|
|
399
|
+
* @returns The number of decimals for the asset
|
|
400
|
+
*/
|
|
401
|
+
getAssetDecimals(network, tokenAddress) {
|
|
402
|
+
if (tokenAddress) {
|
|
403
|
+
const token = getTokenByAddress(network, tokenAddress);
|
|
404
|
+
if (token) return token.decimals;
|
|
405
|
+
}
|
|
406
|
+
return 6;
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Get all supported networks
|
|
410
|
+
*/
|
|
411
|
+
static getSupportedNetworks() {
|
|
412
|
+
return Object.keys(TOKEN_REGISTRY);
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Check if a network is supported
|
|
416
|
+
*/
|
|
417
|
+
static isNetworkSupported(network) {
|
|
418
|
+
return network in TOKEN_REGISTRY;
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
// src/exact/server/register.ts
|
|
423
|
+
function registerExactEvmScheme(server, config = {}) {
|
|
424
|
+
if (config.networks && config.networks.length > 0) {
|
|
425
|
+
config.networks.forEach((network) => {
|
|
426
|
+
server.register(network, new ExactEvmScheme());
|
|
427
|
+
});
|
|
428
|
+
} else {
|
|
429
|
+
server.register("eip155:*", new ExactEvmScheme());
|
|
430
|
+
}
|
|
431
|
+
return server;
|
|
432
|
+
}
|
|
433
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
434
|
+
0 && (module.exports = {
|
|
435
|
+
ExactEvmScheme,
|
|
436
|
+
registerExactEvmScheme
|
|
437
|
+
});
|
|
438
|
+
//# sourceMappingURL=index.js.map
|