@payai/x402-evm 2.3.0 → 2.3.2
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/dist/cjs/exact/client/index.d.ts +2 -2
- package/dist/cjs/exact/server/index.js +19 -4
- package/dist/cjs/exact/server/index.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/permit2-DHAq6FTe.d.ts +517 -0
- package/dist/esm/exact/client/index.d.mts +2 -2
- package/dist/esm/exact/server/index.mjs +19 -4
- package/dist/esm/exact/server/index.mjs.map +1 -1
- package/dist/esm/index.d.mts +1 -1
- package/dist/esm/{permit2-CGOcN7Et.d.mts → permit2-BuAhWvNC.d.mts} +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { E as ExactEvmScheme,
|
|
2
|
-
import { SelectPaymentRequirements, PaymentPolicy
|
|
1
|
+
export { E as ExactEvmScheme, P as Permit2AllowanceParams, c as createPermit2ApprovalTx, e as erc20AllowanceAbi, g as getPermit2AllowanceReadParams } from '../../permit2-DHAq6FTe.js';
|
|
2
|
+
import { x402Client, SelectPaymentRequirements, PaymentPolicy } from '@x402/core/client';
|
|
3
3
|
import { Network } from '@x402/core/types';
|
|
4
4
|
import { C as ClientEvmSigner } from '../../signer-DC81R8wQ.js';
|
|
5
5
|
|
|
@@ -131,12 +131,18 @@ var ExactEvmScheme = class {
|
|
|
131
131
|
defaultMoneyConversion(amount, network) {
|
|
132
132
|
const assetInfo = this.getDefaultAsset(network);
|
|
133
133
|
const tokenAmount = this.convertToTokenAmount(amount.toString(), assetInfo.decimals);
|
|
134
|
+
const includeEip712Domain = !assetInfo.assetTransferMethod || assetInfo.supportsEip2612;
|
|
134
135
|
return {
|
|
135
136
|
amount: tokenAmount,
|
|
136
137
|
asset: assetInfo.address,
|
|
137
138
|
extra: {
|
|
138
|
-
|
|
139
|
-
|
|
139
|
+
...includeEip712Domain && {
|
|
140
|
+
name: assetInfo.name,
|
|
141
|
+
version: assetInfo.version
|
|
142
|
+
},
|
|
143
|
+
...assetInfo.assetTransferMethod && {
|
|
144
|
+
assetTransferMethod: assetInfo.assetTransferMethod
|
|
145
|
+
}
|
|
140
146
|
}
|
|
141
147
|
};
|
|
142
148
|
}
|
|
@@ -183,9 +189,18 @@ var ExactEvmScheme = class {
|
|
|
183
189
|
address: "0xFAfDdbb3FC7688494971a79cc65DCa3EF82079E7",
|
|
184
190
|
name: "MegaUSD",
|
|
185
191
|
version: "1",
|
|
186
|
-
decimals: 18
|
|
192
|
+
decimals: 18,
|
|
193
|
+
assetTransferMethod: "permit2",
|
|
194
|
+
supportsEip2612: true
|
|
195
|
+
},
|
|
196
|
+
// MegaETH mainnet MegaUSD (no EIP-3009, supports EIP-2612)
|
|
197
|
+
"eip155:143": {
|
|
198
|
+
address: "0x754704Bc059F8C67012fEd69BC8A327a5aafb603",
|
|
199
|
+
name: "USD Coin",
|
|
200
|
+
version: "2",
|
|
201
|
+
decimals: 6
|
|
187
202
|
}
|
|
188
|
-
//
|
|
203
|
+
// Monad mainnet USDC
|
|
189
204
|
};
|
|
190
205
|
const assetInfo = stablecoins[network];
|
|
191
206
|
if (!assetInfo) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/exact/server/index.ts","../../../../src/exact/server/scheme.ts","../../../../src/exact/server/register.ts"],"sourcesContent":["export { ExactEvmScheme } from \"./scheme\";\nexport { registerExactEvmScheme } from \"./register\";\nexport type { EvmResourceServerConfig } from \"./register\";\n","import {\n AssetAmount,\n Network,\n PaymentRequirements,\n Price,\n SchemeNetworkServer,\n MoneyParser,\n} from \"@x402/core/types\";\n\n/**\n * EVM server implementation for the Exact payment scheme.\n */\nexport class ExactEvmScheme implements SchemeNetworkServer {\n readonly scheme = \"exact\";\n private moneyParsers: MoneyParser[] = [];\n\n /**\n * Register a custom money parser in the parser chain.\n * Multiple parsers can be registered - they will be tried in registration order.\n * Each parser receives a decimal amount (e.g., 1.50 for $1.50).\n * If a parser returns null, the next parser in the chain will be tried.\n * The default parser is always the final fallback.\n *\n * @param parser - Custom function to convert amount to AssetAmount (or null to skip)\n * @returns The server instance for chaining\n *\n * @example\n * evmServer.registerMoneyParser(async (amount, network) => {\n * // Custom conversion logic\n * if (amount > 100) {\n * // Use different token for large amounts\n * return { amount: (amount * 1e18).toString(), asset: \"0xCustomToken\" };\n * }\n * return null; // Use next parser\n * });\n */\n registerMoneyParser(parser: MoneyParser): ExactEvmScheme {\n this.moneyParsers.push(parser);\n return this;\n }\n\n /**\n * Parses a price into an asset amount.\n * If price is already an AssetAmount, returns it directly.\n * If price is Money (string | number), parses to decimal and tries custom parsers.\n * Falls back to default conversion if all custom parsers return null.\n *\n * @param price - The price to parse\n * @param network - The network to use\n * @returns Promise that resolves to the parsed asset amount\n */\n async parsePrice(price: Price, network: Network): Promise<AssetAmount> {\n // If already an AssetAmount, return it directly\n if (typeof price === \"object\" && price !== null && \"amount\" in price) {\n if (!price.asset) {\n throw new Error(`Asset address must be specified for AssetAmount on network ${network}`);\n }\n return {\n amount: price.amount,\n asset: price.asset,\n extra: price.extra || {},\n };\n }\n\n // Parse Money to decimal number\n const amount = this.parseMoneyToDecimal(price);\n\n // Try each custom money parser in order\n for (const parser of this.moneyParsers) {\n const result = await parser(amount, network);\n if (result !== null) {\n return result;\n }\n }\n\n // All custom parsers returned null, use default conversion\n return this.defaultMoneyConversion(amount, network);\n }\n\n /**\n * Build payment requirements for this scheme/network combination\n *\n * @param paymentRequirements - The base payment requirements\n * @param supportedKind - The supported kind from facilitator (unused)\n * @param supportedKind.x402Version - The x402 version\n * @param supportedKind.scheme - The logical payment scheme\n * @param supportedKind.network - The network identifier in CAIP-2 format\n * @param supportedKind.extra - Optional extra metadata regarding scheme/network implementation details\n * @param extensionKeys - Extension keys supported by the facilitator (unused)\n * @returns Payment requirements ready to be sent to clients\n */\n enhancePaymentRequirements(\n paymentRequirements: PaymentRequirements,\n supportedKind: {\n x402Version: number;\n scheme: string;\n network: Network;\n extra?: Record<string, unknown>;\n },\n extensionKeys: string[],\n ): Promise<PaymentRequirements> {\n // Mark unused parameters to satisfy linter\n void supportedKind;\n void extensionKeys;\n return Promise.resolve(paymentRequirements);\n }\n\n /**\n * Parse Money (string | number) to a decimal number.\n * Handles formats like \"$1.50\", \"1.50\", 1.50, etc.\n *\n * @param money - The money value to parse\n * @returns Decimal number\n */\n private parseMoneyToDecimal(money: string | number): number {\n if (typeof money === \"number\") {\n return money;\n }\n\n // Remove $ sign and whitespace, then parse\n const cleanMoney = money.replace(/^\\$/, \"\").trim();\n const amount = parseFloat(cleanMoney);\n\n if (isNaN(amount)) {\n throw new Error(`Invalid money format: ${money}`);\n }\n\n return amount;\n }\n\n /**\n * Default money conversion implementation.\n * Converts decimal amount to the default stablecoin on the specified network.\n *\n * @param amount - The decimal amount (e.g., 1.50)\n * @param network - The network to use\n * @returns The parsed asset amount in the default stablecoin\n */\n private defaultMoneyConversion(amount: number, network: Network): AssetAmount {\n const assetInfo = this.getDefaultAsset(network);\n const tokenAmount = this.convertToTokenAmount(amount.toString(), assetInfo.decimals);\n\n return {\n amount: tokenAmount,\n asset: assetInfo.address,\n extra: {\n name: assetInfo.name,\n version: assetInfo.version,\n },\n };\n }\n\n /**\n * Convert decimal amount to token units (e.g., 0.10 -> 100000 for 6-decimal tokens)\n *\n * @param decimalAmount - The decimal amount to convert\n * @param decimals - The number of decimals for the token\n * @returns The token amount as a string\n */\n private convertToTokenAmount(decimalAmount: string, decimals: number): string {\n const amount = parseFloat(decimalAmount);\n if (isNaN(amount)) {\n throw new Error(`Invalid amount: ${decimalAmount}`);\n }\n // Convert to smallest unit (e.g., for USDC with 6 decimals: 0.10 * 10^6 = 100000)\n const [intPart, decPart = \"\"] = String(amount).split(\".\");\n const paddedDec = decPart.padEnd(decimals, \"0\").slice(0, decimals);\n const tokenAmount = (intPart + paddedDec).replace(/^0+/, \"\") || \"0\";\n return tokenAmount;\n }\n\n /**\n * Get the default asset info for a network (typically USDC)\n *\n * @param network - The network to get asset info for\n * @returns The asset information including address, name, version, and decimals\n */\n private getDefaultAsset(network: Network): {\n address: string;\n name: string;\n version: string;\n decimals: number;\n } {\n // Map of network to USDC info including EIP-712 domain parameters\n // Each network has the right to determine its own default stablecoin that can be expressed as a USD string by calling servers\n // NOTE: Currently only EIP-3009 supporting stablecoins can be used with this scheme\n // Generic ERC20 support via EIP-2612/permit2 is planned, but not yet implemented.\n const stablecoins: Record<\n string,\n { address: string; name: string; version: string; decimals: number }\n > = {\n \"eip155:8453\": {\n address: \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\",\n name: \"USD Coin\",\n version: \"2\",\n decimals: 6,\n }, // Base mainnet USDC\n \"eip155:84532\": {\n address: \"0x036CbD53842c5426634e7929541eC2318f3dCF7e\",\n name: \"USDC\",\n version: \"2\",\n decimals: 6,\n }, // Base Sepolia USDC\n \"eip155:4326\": {\n address: \"0xFAfDdbb3FC7688494971a79cc65DCa3EF82079E7\",\n name: \"MegaUSD\",\n version: \"1\",\n decimals: 18,\n }, // MegaETH mainnet USDM\n };\n\n const assetInfo = stablecoins[network];\n if (!assetInfo) {\n throw new Error(`No default asset configured for network ${network}`);\n }\n\n return assetInfo;\n }\n}\n","import { x402ResourceServer } from \"@x402/core/server\";\nimport { Network } from \"@x402/core/types\";\nimport { ExactEvmScheme } from \"./scheme\";\n\n/**\n * Configuration options for registering EVM schemes to an x402ResourceServer\n */\nexport interface EvmResourceServerConfig {\n /**\n * Optional specific networks to register\n * If not provided, registers wildcard support (eip155:*)\n */\n networks?: Network[];\n}\n\n/**\n * Registers EVM exact payment schemes to an x402ResourceServer instance.\n *\n * This function registers:\n * - V2: eip155:* wildcard scheme with ExactEvmScheme (or specific networks if provided)\n *\n * @param server - The x402ResourceServer instance to register schemes to\n * @param config - Configuration for EVM resource server registration\n * @returns The server instance for chaining\n *\n * @example\n * ```typescript\n * import { registerExactEvmScheme } from \"@x402/evm/exact/server/register\";\n * import { x402ResourceServer } from \"@x402/core/server\";\n *\n * const server = new x402ResourceServer(facilitatorClient);\n * registerExactEvmScheme(server, {});\n * ```\n */\nexport function registerExactEvmScheme(\n server: x402ResourceServer,\n config: EvmResourceServerConfig = {},\n): x402ResourceServer {\n // Register V2 scheme\n if (config.networks && config.networks.length > 0) {\n // Register specific networks\n config.networks.forEach(network => {\n server.register(network, new ExactEvmScheme());\n });\n } else {\n // Register wildcard for all EVM chains\n server.register(\"eip155:*\", new ExactEvmScheme());\n }\n\n return server;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACYO,IAAM,iBAAN,MAAoD;AAAA,EAApD;AACL,SAAS,SAAS;AAClB,SAAQ,eAA8B,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsBvC,oBAAoB,QAAqC;AACvD,SAAK,aAAa,KAAK,MAAM;AAC7B,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,MAAM,WAAW,OAAc,SAAwC;AAErE,QAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,YAAY,OAAO;AACpE,UAAI,CAAC,MAAM,OAAO;AAChB,cAAM,IAAI,MAAM,8DAA8D,OAAO,EAAE;AAAA,MACzF;AACA,aAAO;AAAA,QACL,QAAQ,MAAM;AAAA,QACd,OAAO,MAAM;AAAA,QACb,OAAO,MAAM,SAAS,CAAC;AAAA,MACzB;AAAA,IACF;AAGA,UAAM,SAAS,KAAK,oBAAoB,KAAK;AAG7C,eAAW,UAAU,KAAK,cAAc;AACtC,YAAM,SAAS,MAAM,OAAO,QAAQ,OAAO;AAC3C,UAAI,WAAW,MAAM;AACnB,eAAO;AAAA,MACT;AAAA,IACF;AAGA,WAAO,KAAK,uBAAuB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AW,QAAQ,OAAO,EAAE,KAAK;AAChE,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQQ,gBAAgB,SAKtB;AAKA,UAAM,cAGF;AAAA,MACF,eAAe;AAAA,QACb,SAAS;AAAA,QACT,MAAM;AAAA,QACN,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA;AAAA,MACA,gBAAgB;AAAA,QACd,SAAS;AAAA,QACT,MAAM;AAAA,QACN,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA;AAAA,MACA,eAAe;AAAA,QACb,SAAS;AAAA,QACT,MAAM;AAAA,QACN,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA;AAAA,IACF;AAEA,UAAM,YAAY,YAAY,OAAO;AACrC,QAAI,CAAC,WAAW;AACd,YAAM,IAAI,MAAM,2CAA2C,OAAO,EAAE;AAAA,IACtE;AAEA,WAAO;AAAA,EACT;AACF;;;ACxLO,SAAS,uBACd,QACA,SAAkC,CAAC,GACf;AAEpB,MAAI,OAAO,YAAY,OAAO,SAAS,SAAS,GAAG;AAEjD,WAAO,SAAS,QAAQ,aAAW;AACjC,aAAO,SAAS,SAAS,IAAI,eAAe,CAAC;AAAA,IAC/C,CAAC;AAAA,EACH,OAAO;AAEL,WAAO,SAAS,YAAY,IAAI,eAAe,CAAC;AAAA,EAClD;AAEA,SAAO;AACT;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/exact/server/index.ts","../../../../src/exact/server/scheme.ts","../../../../src/exact/server/register.ts"],"sourcesContent":["export { ExactEvmScheme } from \"./scheme\";\nexport { registerExactEvmScheme } from \"./register\";\nexport type { EvmResourceServerConfig } from \"./register\";\n","import {\n AssetAmount,\n Network,\n PaymentRequirements,\n Price,\n SchemeNetworkServer,\n MoneyParser,\n} from \"@x402/core/types\";\n\n/**\n * EVM server implementation for the Exact payment scheme.\n */\nexport class ExactEvmScheme implements SchemeNetworkServer {\n readonly scheme = \"exact\";\n private moneyParsers: MoneyParser[] = [];\n\n /**\n * Register a custom money parser in the parser chain.\n * Multiple parsers can be registered - they will be tried in registration order.\n * Each parser receives a decimal amount (e.g., 1.50 for $1.50).\n * If a parser returns null, the next parser in the chain will be tried.\n * The default parser is always the final fallback.\n *\n * @param parser - Custom function to convert amount to AssetAmount (or null to skip)\n * @returns The server instance for chaining\n *\n * @example\n * evmServer.registerMoneyParser(async (amount, network) => {\n * // Custom conversion logic\n * if (amount > 100) {\n * // Use different token for large amounts\n * return { amount: (amount * 1e18).toString(), asset: \"0xCustomToken\" };\n * }\n * return null; // Use next parser\n * });\n */\n registerMoneyParser(parser: MoneyParser): ExactEvmScheme {\n this.moneyParsers.push(parser);\n return this;\n }\n\n /**\n * Parses a price into an asset amount.\n * If price is already an AssetAmount, returns it directly.\n * If price is Money (string | number), parses to decimal and tries custom parsers.\n * Falls back to default conversion if all custom parsers return null.\n *\n * @param price - The price to parse\n * @param network - The network to use\n * @returns Promise that resolves to the parsed asset amount\n */\n async parsePrice(price: Price, network: Network): Promise<AssetAmount> {\n // If already an AssetAmount, return it directly\n if (typeof price === \"object\" && price !== null && \"amount\" in price) {\n if (!price.asset) {\n throw new Error(`Asset address must be specified for AssetAmount on network ${network}`);\n }\n return {\n amount: price.amount,\n asset: price.asset,\n extra: price.extra || {},\n };\n }\n\n // Parse Money to decimal number\n const amount = this.parseMoneyToDecimal(price);\n\n // Try each custom money parser in order\n for (const parser of this.moneyParsers) {\n const result = await parser(amount, network);\n if (result !== null) {\n return result;\n }\n }\n\n // All custom parsers returned null, use default conversion\n return this.defaultMoneyConversion(amount, network);\n }\n\n /**\n * Build payment requirements for this scheme/network combination\n *\n * @param paymentRequirements - The base payment requirements\n * @param supportedKind - The supported kind from facilitator (unused)\n * @param supportedKind.x402Version - The x402 version\n * @param supportedKind.scheme - The logical payment scheme\n * @param supportedKind.network - The network identifier in CAIP-2 format\n * @param supportedKind.extra - Optional extra metadata regarding scheme/network implementation details\n * @param extensionKeys - Extension keys supported by the facilitator (unused)\n * @returns Payment requirements ready to be sent to clients\n */\n enhancePaymentRequirements(\n paymentRequirements: PaymentRequirements,\n supportedKind: {\n x402Version: number;\n scheme: string;\n network: Network;\n extra?: Record<string, unknown>;\n },\n extensionKeys: string[],\n ): Promise<PaymentRequirements> {\n // Mark unused parameters to satisfy linter\n void supportedKind;\n void extensionKeys;\n return Promise.resolve(paymentRequirements);\n }\n\n /**\n * Parse Money (string | number) to a decimal number.\n * Handles formats like \"$1.50\", \"1.50\", 1.50, etc.\n *\n * @param money - The money value to parse\n * @returns Decimal number\n */\n private parseMoneyToDecimal(money: string | number): number {\n if (typeof money === \"number\") {\n return money;\n }\n\n // Remove $ sign and whitespace, then parse\n const cleanMoney = money.replace(/^\\$/, \"\").trim();\n const amount = parseFloat(cleanMoney);\n\n if (isNaN(amount)) {\n throw new Error(`Invalid money format: ${money}`);\n }\n\n return amount;\n }\n\n /**\n * Default money conversion implementation.\n * Converts decimal amount to the default stablecoin on the specified network.\n *\n * @param amount - The decimal amount (e.g., 1.50)\n * @param network - The network to use\n * @returns The parsed asset amount in the default stablecoin\n */\n private defaultMoneyConversion(amount: number, network: Network): AssetAmount {\n const assetInfo = this.getDefaultAsset(network);\n const tokenAmount = this.convertToTokenAmount(amount.toString(), assetInfo.decimals);\n\n // EIP-3009 tokens always need name/version for their transferWithAuthorization domain.\n // Permit2 tokens only need them if the token supports EIP-2612 (for gasless permit signing).\n // Omitting name/version for permit2 tokens signals the client to skip EIP-2612 and use\n // ERC-20 approval gas sponsoring instead.\n const includeEip712Domain = !assetInfo.assetTransferMethod || assetInfo.supportsEip2612;\n\n return {\n amount: tokenAmount,\n asset: assetInfo.address,\n extra: {\n ...(includeEip712Domain && {\n name: assetInfo.name,\n version: assetInfo.version,\n }),\n ...(assetInfo.assetTransferMethod && {\n assetTransferMethod: assetInfo.assetTransferMethod,\n }),\n },\n };\n }\n\n /**\n * Convert decimal amount to token units (e.g., 0.10 -> 100000 for 6-decimal tokens)\n *\n * @param decimalAmount - The decimal amount to convert\n * @param decimals - The number of decimals for the token\n * @returns The token amount as a string\n */\n private convertToTokenAmount(decimalAmount: string, decimals: number): string {\n const amount = parseFloat(decimalAmount);\n if (isNaN(amount)) {\n throw new Error(`Invalid amount: ${decimalAmount}`);\n }\n // Convert to smallest unit (e.g., for USDC with 6 decimals: 0.10 * 10^6 = 100000)\n const [intPart, decPart = \"\"] = String(amount).split(\".\");\n const paddedDec = decPart.padEnd(decimals, \"0\").slice(0, decimals);\n const tokenAmount = (intPart + paddedDec).replace(/^0+/, \"\") || \"0\";\n return tokenAmount;\n }\n\n /**\n * Get the default asset info for a network (typically USDC)\n *\n * @param network - The network to get asset info for\n * @returns The asset information including address, name, version, and decimals\n */\n private getDefaultAsset(network: Network): {\n address: string;\n name: string;\n version: string;\n decimals: number;\n assetTransferMethod?: string;\n supportsEip2612?: boolean;\n } {\n // Map of network to stablecoin info including EIP-712 domain parameters.\n // Each network has the right to determine its own default stablecoin that can be expressed as a USD string by calling servers.\n // Tokens that don't support EIP-3009 should set assetTransferMethod: \"permit2\".\n // For permit2 tokens, set supportsEip2612: true if the token implements EIP-2612 permit().\n // When supportsEip2612 is false/absent on a permit2 token, name/version are omitted from\n // extra so the client skips the EIP-2612 path and falls back to ERC-20 approval gas sponsoring.\n const stablecoins: Record<\n string,\n {\n address: string;\n name: string;\n version: string;\n decimals: number;\n assetTransferMethod?: string;\n supportsEip2612?: boolean;\n }\n > = {\n \"eip155:8453\": {\n address: \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\",\n name: \"USD Coin\",\n version: \"2\",\n decimals: 6,\n }, // Base mainnet USDC\n \"eip155:84532\": {\n address: \"0x036CbD53842c5426634e7929541eC2318f3dCF7e\",\n name: \"USDC\",\n version: \"2\",\n decimals: 6,\n }, // Base Sepolia USDC\n \"eip155:4326\": {\n address: \"0xFAfDdbb3FC7688494971a79cc65DCa3EF82079E7\",\n name: \"MegaUSD\",\n version: \"1\",\n decimals: 18,\n assetTransferMethod: \"permit2\",\n supportsEip2612: true,\n }, // MegaETH mainnet MegaUSD (no EIP-3009, supports EIP-2612)\n \"eip155:143\": {\n address: \"0x754704Bc059F8C67012fEd69BC8A327a5aafb603\",\n name: \"USD Coin\",\n version: \"2\",\n decimals: 6,\n }, // Monad mainnet USDC\n };\n\n const assetInfo = stablecoins[network];\n if (!assetInfo) {\n throw new Error(`No default asset configured for network ${network}`);\n }\n\n return assetInfo;\n }\n}\n","import { x402ResourceServer } from \"@x402/core/server\";\nimport { Network } from \"@x402/core/types\";\nimport { ExactEvmScheme } from \"./scheme\";\n\n/**\n * Configuration options for registering EVM schemes to an x402ResourceServer\n */\nexport interface EvmResourceServerConfig {\n /**\n * Optional specific networks to register\n * If not provided, registers wildcard support (eip155:*)\n */\n networks?: Network[];\n}\n\n/**\n * Registers EVM exact payment schemes to an x402ResourceServer instance.\n *\n * This function registers:\n * - V2: eip155:* wildcard scheme with ExactEvmScheme (or specific networks if provided)\n *\n * @param server - The x402ResourceServer instance to register schemes to\n * @param config - Configuration for EVM resource server registration\n * @returns The server instance for chaining\n *\n * @example\n * ```typescript\n * import { registerExactEvmScheme } from \"@x402/evm/exact/server/register\";\n * import { x402ResourceServer } from \"@x402/core/server\";\n *\n * const server = new x402ResourceServer(facilitatorClient);\n * registerExactEvmScheme(server, {});\n * ```\n */\nexport function registerExactEvmScheme(\n server: x402ResourceServer,\n config: EvmResourceServerConfig = {},\n): x402ResourceServer {\n // Register V2 scheme\n if (config.networks && config.networks.length > 0) {\n // Register specific networks\n config.networks.forEach(network => {\n server.register(network, new ExactEvmScheme());\n });\n } else {\n // Register wildcard for all EVM chains\n server.register(\"eip155:*\", new ExactEvmScheme());\n }\n\n return server;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACYO,IAAM,iBAAN,MAAoD;AAAA,EAApD;AACL,SAAS,SAAS;AAClB,SAAQ,eAA8B,CAAC;AAAA;AAAA;AAAA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Z;AAAA;AAAA,MACA,eAAe;AAAA,QACb,SAAS;AAAA,QACT,MAAM;AAAA,QACN,SAAS;AAAA,QACT,UAAU;AAAA,QACV,qBAAqB;AAAA,QACrB,iBAAiB;AAAA,MACnB;AAAA;AAAA,MACA,cAAc;AAAA,QACZ,SAAS;AAAA,QACT,MAAM;AAAA,QACN,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA;AAAA,IACF;AAEA,UAAM,YAAY,YAAY,OAAO;AACrC,QAAI,CAAC,WAAW;AACd,YAAM,IAAI,MAAM,2CAA2C,OAAO,EAAE;AAAA,IACtE;AAEA,WAAO;AAAA,EACT;AACF;;;ACtNO,SAAS,uBACd,QACA,SAAkC,CAAC,GACf;AAEpB,MAAI,OAAO,YAAY,OAAO,SAAS,SAAS,GAAG;AAEjD,WAAO,SAAS,QAAQ,aAAW;AACjC,aAAO,SAAS,SAAS,IAAI,eAAe,CAAC;AAAA,IAC/C,CAAC;AAAA,EACH,OAAO;AAEL,WAAO,SAAS,YAAY,IAAI,eAAe,CAAC;AAAA,EAClD;AAEA,SAAO;AACT;","names":[]}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { E as ExactEvmScheme,
|
|
1
|
+
export { E as ExactEvmScheme, a as PERMIT2_ADDRESS, P as Permit2AllowanceParams, d as authorizationTypes, c as createPermit2ApprovalTx, f as eip3009ABI, e as erc20AllowanceAbi, g as getPermit2AllowanceReadParams, p as permit2WitnessTypes, h as x402ExactPermit2ProxyABI, x as x402ExactPermit2ProxyAddress, b as x402UptoPermit2ProxyAddress } from './permit2-DHAq6FTe.js';
|
|
2
2
|
export { C as ClientEvmSigner, F as FacilitatorEvmSigner, t as toClientEvmSigner, a as toFacilitatorEvmSigner } from './signer-DC81R8wQ.js';
|
|
3
3
|
import '@x402/core/types';
|
|
4
4
|
|
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
import { SchemeNetworkClient, PaymentRequirements, PaymentPayloadContext, PaymentPayloadResult } from '@x402/core/types';
|
|
2
|
+
import { C as ClientEvmSigner } from './signer-DC81R8wQ.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* EVM client implementation for the Exact payment scheme.
|
|
6
|
+
* Supports both EIP-3009 (transferWithAuthorization) and Permit2 flows.
|
|
7
|
+
*
|
|
8
|
+
* Routes to the appropriate authorization method based on
|
|
9
|
+
* `requirements.extra.assetTransferMethod`. Defaults to EIP-3009
|
|
10
|
+
* for backward compatibility with older facilitators.
|
|
11
|
+
*
|
|
12
|
+
* When the server advertises `eip2612GasSponsoring` and the asset transfer
|
|
13
|
+
* method is `permit2`, the scheme automatically signs an EIP-2612 permit
|
|
14
|
+
* if the user lacks Permit2 approval. This requires `readContract` on the signer.
|
|
15
|
+
*/
|
|
16
|
+
declare class ExactEvmScheme implements SchemeNetworkClient {
|
|
17
|
+
private readonly signer;
|
|
18
|
+
readonly scheme = "exact";
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new ExactEvmClient instance.
|
|
21
|
+
*
|
|
22
|
+
* @param signer - The EVM signer for client operations.
|
|
23
|
+
* Must support `readContract` for EIP-2612 gas sponsoring.
|
|
24
|
+
* Use `createWalletClient(...).extend(publicActions)` or `toClientEvmSigner(account, publicClient)`.
|
|
25
|
+
*/
|
|
26
|
+
constructor(signer: ClientEvmSigner);
|
|
27
|
+
/**
|
|
28
|
+
* Creates a payment payload for the Exact scheme.
|
|
29
|
+
* Routes to EIP-3009 or Permit2 based on requirements.extra.assetTransferMethod.
|
|
30
|
+
*
|
|
31
|
+
* For Permit2 flows, if the server advertises `eip2612GasSponsoring` and the
|
|
32
|
+
* signer supports `readContract`, automatically signs an EIP-2612 permit
|
|
33
|
+
* when Permit2 allowance is insufficient.
|
|
34
|
+
*
|
|
35
|
+
* @param x402Version - The x402 protocol version
|
|
36
|
+
* @param paymentRequirements - The payment requirements
|
|
37
|
+
* @param context - Optional context with server-declared extensions
|
|
38
|
+
* @returns Promise resolving to a payment payload result (with optional extensions)
|
|
39
|
+
*/
|
|
40
|
+
createPaymentPayload(x402Version: number, paymentRequirements: PaymentRequirements, context?: PaymentPayloadContext): Promise<PaymentPayloadResult>;
|
|
41
|
+
/**
|
|
42
|
+
* Attempts to sign an EIP-2612 permit for gasless Permit2 approval.
|
|
43
|
+
*
|
|
44
|
+
* Returns extension data if:
|
|
45
|
+
* 1. Server advertises eip2612GasSponsoring
|
|
46
|
+
* 2. Signer has readContract capability
|
|
47
|
+
* 3. Current Permit2 allowance is insufficient
|
|
48
|
+
*
|
|
49
|
+
* Returns undefined if the extension should not be used.
|
|
50
|
+
*
|
|
51
|
+
* @param requirements - The payment requirements from the server
|
|
52
|
+
* @param result - The payment payload result from the scheme
|
|
53
|
+
* @param context - Optional context containing server extensions and metadata
|
|
54
|
+
* @returns Extension data for EIP-2612 gas sponsoring, or undefined if not applicable
|
|
55
|
+
*/
|
|
56
|
+
private trySignEip2612Permit;
|
|
57
|
+
/**
|
|
58
|
+
* Attempts to sign an ERC-20 approval transaction for gasless Permit2 approval.
|
|
59
|
+
*
|
|
60
|
+
* This is the fallback path when the token does not support EIP-2612. The client
|
|
61
|
+
* signs (but does not broadcast) a raw `approve(Permit2, MaxUint256)` transaction.
|
|
62
|
+
* The facilitator broadcasts it atomically before settling.
|
|
63
|
+
*
|
|
64
|
+
* Returns extension data if:
|
|
65
|
+
* 1. Server advertises erc20ApprovalGasSponsoring
|
|
66
|
+
* 2. Signer has signTransaction + getTransactionCount capabilities
|
|
67
|
+
* 3. Current Permit2 allowance is insufficient
|
|
68
|
+
*
|
|
69
|
+
* Returns undefined if the extension should not be used.
|
|
70
|
+
*
|
|
71
|
+
* @param requirements - The payment requirements from the server
|
|
72
|
+
* @param _result - The payment payload result from the scheme (unused)
|
|
73
|
+
* @param context - Optional context containing server extensions and metadata
|
|
74
|
+
* @returns Extension data for ERC-20 approval gas sponsoring, or undefined if not applicable
|
|
75
|
+
*/
|
|
76
|
+
private trySignErc20Approval;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
declare const authorizationTypes: {
|
|
80
|
+
readonly TransferWithAuthorization: readonly [{
|
|
81
|
+
readonly name: "from";
|
|
82
|
+
readonly type: "address";
|
|
83
|
+
}, {
|
|
84
|
+
readonly name: "to";
|
|
85
|
+
readonly type: "address";
|
|
86
|
+
}, {
|
|
87
|
+
readonly name: "value";
|
|
88
|
+
readonly type: "uint256";
|
|
89
|
+
}, {
|
|
90
|
+
readonly name: "validAfter";
|
|
91
|
+
readonly type: "uint256";
|
|
92
|
+
}, {
|
|
93
|
+
readonly name: "validBefore";
|
|
94
|
+
readonly type: "uint256";
|
|
95
|
+
}, {
|
|
96
|
+
readonly name: "nonce";
|
|
97
|
+
readonly type: "bytes32";
|
|
98
|
+
}];
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Permit2 EIP-712 types for signing PermitWitnessTransferFrom.
|
|
102
|
+
* Must match the exact format expected by the Permit2 contract.
|
|
103
|
+
* Note: Types must be in ALPHABETICAL order after the primary type (TokenPermissions < Witness).
|
|
104
|
+
*/
|
|
105
|
+
declare const permit2WitnessTypes: {
|
|
106
|
+
readonly PermitWitnessTransferFrom: readonly [{
|
|
107
|
+
readonly name: "permitted";
|
|
108
|
+
readonly type: "TokenPermissions";
|
|
109
|
+
}, {
|
|
110
|
+
readonly name: "spender";
|
|
111
|
+
readonly type: "address";
|
|
112
|
+
}, {
|
|
113
|
+
readonly name: "nonce";
|
|
114
|
+
readonly type: "uint256";
|
|
115
|
+
}, {
|
|
116
|
+
readonly name: "deadline";
|
|
117
|
+
readonly type: "uint256";
|
|
118
|
+
}, {
|
|
119
|
+
readonly name: "witness";
|
|
120
|
+
readonly type: "Witness";
|
|
121
|
+
}];
|
|
122
|
+
readonly TokenPermissions: readonly [{
|
|
123
|
+
readonly name: "token";
|
|
124
|
+
readonly type: "address";
|
|
125
|
+
}, {
|
|
126
|
+
readonly name: "amount";
|
|
127
|
+
readonly type: "uint256";
|
|
128
|
+
}];
|
|
129
|
+
readonly Witness: readonly [{
|
|
130
|
+
readonly name: "to";
|
|
131
|
+
readonly type: "address";
|
|
132
|
+
}, {
|
|
133
|
+
readonly name: "validAfter";
|
|
134
|
+
readonly type: "uint256";
|
|
135
|
+
}];
|
|
136
|
+
};
|
|
137
|
+
declare const eip3009ABI: readonly [{
|
|
138
|
+
readonly inputs: readonly [{
|
|
139
|
+
readonly name: "from";
|
|
140
|
+
readonly type: "address";
|
|
141
|
+
}, {
|
|
142
|
+
readonly name: "to";
|
|
143
|
+
readonly type: "address";
|
|
144
|
+
}, {
|
|
145
|
+
readonly name: "value";
|
|
146
|
+
readonly type: "uint256";
|
|
147
|
+
}, {
|
|
148
|
+
readonly name: "validAfter";
|
|
149
|
+
readonly type: "uint256";
|
|
150
|
+
}, {
|
|
151
|
+
readonly name: "validBefore";
|
|
152
|
+
readonly type: "uint256";
|
|
153
|
+
}, {
|
|
154
|
+
readonly name: "nonce";
|
|
155
|
+
readonly type: "bytes32";
|
|
156
|
+
}, {
|
|
157
|
+
readonly name: "v";
|
|
158
|
+
readonly type: "uint8";
|
|
159
|
+
}, {
|
|
160
|
+
readonly name: "r";
|
|
161
|
+
readonly type: "bytes32";
|
|
162
|
+
}, {
|
|
163
|
+
readonly name: "s";
|
|
164
|
+
readonly type: "bytes32";
|
|
165
|
+
}];
|
|
166
|
+
readonly name: "transferWithAuthorization";
|
|
167
|
+
readonly outputs: readonly [];
|
|
168
|
+
readonly stateMutability: "nonpayable";
|
|
169
|
+
readonly type: "function";
|
|
170
|
+
}, {
|
|
171
|
+
readonly inputs: readonly [{
|
|
172
|
+
readonly name: "from";
|
|
173
|
+
readonly type: "address";
|
|
174
|
+
}, {
|
|
175
|
+
readonly name: "to";
|
|
176
|
+
readonly type: "address";
|
|
177
|
+
}, {
|
|
178
|
+
readonly name: "value";
|
|
179
|
+
readonly type: "uint256";
|
|
180
|
+
}, {
|
|
181
|
+
readonly name: "validAfter";
|
|
182
|
+
readonly type: "uint256";
|
|
183
|
+
}, {
|
|
184
|
+
readonly name: "validBefore";
|
|
185
|
+
readonly type: "uint256";
|
|
186
|
+
}, {
|
|
187
|
+
readonly name: "nonce";
|
|
188
|
+
readonly type: "bytes32";
|
|
189
|
+
}, {
|
|
190
|
+
readonly name: "signature";
|
|
191
|
+
readonly type: "bytes";
|
|
192
|
+
}];
|
|
193
|
+
readonly name: "transferWithAuthorization";
|
|
194
|
+
readonly outputs: readonly [];
|
|
195
|
+
readonly stateMutability: "nonpayable";
|
|
196
|
+
readonly type: "function";
|
|
197
|
+
}, {
|
|
198
|
+
readonly inputs: readonly [{
|
|
199
|
+
readonly name: "account";
|
|
200
|
+
readonly type: "address";
|
|
201
|
+
}];
|
|
202
|
+
readonly name: "balanceOf";
|
|
203
|
+
readonly outputs: readonly [{
|
|
204
|
+
readonly name: "";
|
|
205
|
+
readonly type: "uint256";
|
|
206
|
+
}];
|
|
207
|
+
readonly stateMutability: "view";
|
|
208
|
+
readonly type: "function";
|
|
209
|
+
}, {
|
|
210
|
+
readonly inputs: readonly [];
|
|
211
|
+
readonly name: "version";
|
|
212
|
+
readonly outputs: readonly [{
|
|
213
|
+
readonly name: "";
|
|
214
|
+
readonly type: "string";
|
|
215
|
+
}];
|
|
216
|
+
readonly stateMutability: "view";
|
|
217
|
+
readonly type: "function";
|
|
218
|
+
}];
|
|
219
|
+
/** ERC-20 allowance(address,address) ABI for checking spender approval. */
|
|
220
|
+
declare const erc20AllowanceAbi: readonly [{
|
|
221
|
+
readonly type: "function";
|
|
222
|
+
readonly name: "allowance";
|
|
223
|
+
readonly inputs: readonly [{
|
|
224
|
+
readonly name: "owner";
|
|
225
|
+
readonly type: "address";
|
|
226
|
+
}, {
|
|
227
|
+
readonly name: "spender";
|
|
228
|
+
readonly type: "address";
|
|
229
|
+
}];
|
|
230
|
+
readonly outputs: readonly [{
|
|
231
|
+
readonly type: "uint256";
|
|
232
|
+
}];
|
|
233
|
+
readonly stateMutability: "view";
|
|
234
|
+
}];
|
|
235
|
+
/**
|
|
236
|
+
* Canonical Permit2 contract address.
|
|
237
|
+
* Same address on all EVM chains via CREATE2 deployment.
|
|
238
|
+
*
|
|
239
|
+
* @see https://github.com/Uniswap/permit2
|
|
240
|
+
*/
|
|
241
|
+
declare const PERMIT2_ADDRESS: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
242
|
+
/**
|
|
243
|
+
* x402ExactPermit2Proxy contract address.
|
|
244
|
+
* Vanity address: 0x4020...0001 for easy recognition.
|
|
245
|
+
* This address is deterministic based on:
|
|
246
|
+
* - Arachnid's deterministic deployer (0x4e59b44847b379578588920cA78FbF26c0B4956C)
|
|
247
|
+
* - Vanity-mined salt for prefix 0x4020 and suffix 0001
|
|
248
|
+
* - Contract bytecode + constructor args (PERMIT2_ADDRESS)
|
|
249
|
+
*/
|
|
250
|
+
declare const x402ExactPermit2ProxyAddress: "0x402085c248EeA27D92E8b30b2C58ed07f9E20001";
|
|
251
|
+
/**
|
|
252
|
+
* x402UptoPermit2Proxy contract address.
|
|
253
|
+
* Vanity address: 0x4020...0002 for easy recognition.
|
|
254
|
+
* This address is deterministic based on:
|
|
255
|
+
* - Arachnid's deterministic deployer (0x4e59b44847b379578588920cA78FbF26c0B4956C)
|
|
256
|
+
* - Vanity-mined salt for prefix 0x4020 and suffix 0002
|
|
257
|
+
* - Contract bytecode + constructor args (PERMIT2_ADDRESS)
|
|
258
|
+
*/
|
|
259
|
+
declare const x402UptoPermit2ProxyAddress: "0x402039b3d6E6BEC5A02c2C9fd937ac17A6940002";
|
|
260
|
+
/**
|
|
261
|
+
* x402ExactPermit2Proxy ABI - settle function for exact payment scheme.
|
|
262
|
+
*/
|
|
263
|
+
declare const x402ExactPermit2ProxyABI: readonly [{
|
|
264
|
+
readonly type: "function";
|
|
265
|
+
readonly name: "PERMIT2";
|
|
266
|
+
readonly inputs: readonly [];
|
|
267
|
+
readonly outputs: readonly [{
|
|
268
|
+
readonly name: "";
|
|
269
|
+
readonly type: "address";
|
|
270
|
+
readonly internalType: "contract ISignatureTransfer";
|
|
271
|
+
}];
|
|
272
|
+
readonly stateMutability: "view";
|
|
273
|
+
}, {
|
|
274
|
+
readonly type: "function";
|
|
275
|
+
readonly name: "WITNESS_TYPEHASH";
|
|
276
|
+
readonly inputs: readonly [];
|
|
277
|
+
readonly outputs: readonly [{
|
|
278
|
+
readonly name: "";
|
|
279
|
+
readonly type: "bytes32";
|
|
280
|
+
readonly internalType: "bytes32";
|
|
281
|
+
}];
|
|
282
|
+
readonly stateMutability: "view";
|
|
283
|
+
}, {
|
|
284
|
+
readonly type: "function";
|
|
285
|
+
readonly name: "WITNESS_TYPE_STRING";
|
|
286
|
+
readonly inputs: readonly [];
|
|
287
|
+
readonly outputs: readonly [{
|
|
288
|
+
readonly name: "";
|
|
289
|
+
readonly type: "string";
|
|
290
|
+
readonly internalType: "string";
|
|
291
|
+
}];
|
|
292
|
+
readonly stateMutability: "view";
|
|
293
|
+
}, {
|
|
294
|
+
readonly type: "function";
|
|
295
|
+
readonly name: "settle";
|
|
296
|
+
readonly inputs: readonly [{
|
|
297
|
+
readonly name: "permit";
|
|
298
|
+
readonly type: "tuple";
|
|
299
|
+
readonly internalType: "struct ISignatureTransfer.PermitTransferFrom";
|
|
300
|
+
readonly components: readonly [{
|
|
301
|
+
readonly name: "permitted";
|
|
302
|
+
readonly type: "tuple";
|
|
303
|
+
readonly internalType: "struct ISignatureTransfer.TokenPermissions";
|
|
304
|
+
readonly components: readonly [{
|
|
305
|
+
readonly name: "token";
|
|
306
|
+
readonly type: "address";
|
|
307
|
+
readonly internalType: "address";
|
|
308
|
+
}, {
|
|
309
|
+
readonly name: "amount";
|
|
310
|
+
readonly type: "uint256";
|
|
311
|
+
readonly internalType: "uint256";
|
|
312
|
+
}];
|
|
313
|
+
}, {
|
|
314
|
+
readonly name: "nonce";
|
|
315
|
+
readonly type: "uint256";
|
|
316
|
+
readonly internalType: "uint256";
|
|
317
|
+
}, {
|
|
318
|
+
readonly name: "deadline";
|
|
319
|
+
readonly type: "uint256";
|
|
320
|
+
readonly internalType: "uint256";
|
|
321
|
+
}];
|
|
322
|
+
}, {
|
|
323
|
+
readonly name: "owner";
|
|
324
|
+
readonly type: "address";
|
|
325
|
+
readonly internalType: "address";
|
|
326
|
+
}, {
|
|
327
|
+
readonly name: "witness";
|
|
328
|
+
readonly type: "tuple";
|
|
329
|
+
readonly internalType: "struct x402ExactPermit2Proxy.Witness";
|
|
330
|
+
readonly components: readonly [{
|
|
331
|
+
readonly name: "to";
|
|
332
|
+
readonly type: "address";
|
|
333
|
+
readonly internalType: "address";
|
|
334
|
+
}, {
|
|
335
|
+
readonly name: "validAfter";
|
|
336
|
+
readonly type: "uint256";
|
|
337
|
+
readonly internalType: "uint256";
|
|
338
|
+
}];
|
|
339
|
+
}, {
|
|
340
|
+
readonly name: "signature";
|
|
341
|
+
readonly type: "bytes";
|
|
342
|
+
readonly internalType: "bytes";
|
|
343
|
+
}];
|
|
344
|
+
readonly outputs: readonly [];
|
|
345
|
+
readonly stateMutability: "nonpayable";
|
|
346
|
+
}, {
|
|
347
|
+
readonly type: "function";
|
|
348
|
+
readonly name: "settleWithPermit";
|
|
349
|
+
readonly inputs: readonly [{
|
|
350
|
+
readonly name: "permit2612";
|
|
351
|
+
readonly type: "tuple";
|
|
352
|
+
readonly internalType: "struct x402ExactPermit2Proxy.EIP2612Permit";
|
|
353
|
+
readonly components: readonly [{
|
|
354
|
+
readonly name: "value";
|
|
355
|
+
readonly type: "uint256";
|
|
356
|
+
readonly internalType: "uint256";
|
|
357
|
+
}, {
|
|
358
|
+
readonly name: "deadline";
|
|
359
|
+
readonly type: "uint256";
|
|
360
|
+
readonly internalType: "uint256";
|
|
361
|
+
}, {
|
|
362
|
+
readonly name: "r";
|
|
363
|
+
readonly type: "bytes32";
|
|
364
|
+
readonly internalType: "bytes32";
|
|
365
|
+
}, {
|
|
366
|
+
readonly name: "s";
|
|
367
|
+
readonly type: "bytes32";
|
|
368
|
+
readonly internalType: "bytes32";
|
|
369
|
+
}, {
|
|
370
|
+
readonly name: "v";
|
|
371
|
+
readonly type: "uint8";
|
|
372
|
+
readonly internalType: "uint8";
|
|
373
|
+
}];
|
|
374
|
+
}, {
|
|
375
|
+
readonly name: "permit";
|
|
376
|
+
readonly type: "tuple";
|
|
377
|
+
readonly internalType: "struct ISignatureTransfer.PermitTransferFrom";
|
|
378
|
+
readonly components: readonly [{
|
|
379
|
+
readonly name: "permitted";
|
|
380
|
+
readonly type: "tuple";
|
|
381
|
+
readonly internalType: "struct ISignatureTransfer.TokenPermissions";
|
|
382
|
+
readonly components: readonly [{
|
|
383
|
+
readonly name: "token";
|
|
384
|
+
readonly type: "address";
|
|
385
|
+
readonly internalType: "address";
|
|
386
|
+
}, {
|
|
387
|
+
readonly name: "amount";
|
|
388
|
+
readonly type: "uint256";
|
|
389
|
+
readonly internalType: "uint256";
|
|
390
|
+
}];
|
|
391
|
+
}, {
|
|
392
|
+
readonly name: "nonce";
|
|
393
|
+
readonly type: "uint256";
|
|
394
|
+
readonly internalType: "uint256";
|
|
395
|
+
}, {
|
|
396
|
+
readonly name: "deadline";
|
|
397
|
+
readonly type: "uint256";
|
|
398
|
+
readonly internalType: "uint256";
|
|
399
|
+
}];
|
|
400
|
+
}, {
|
|
401
|
+
readonly name: "owner";
|
|
402
|
+
readonly type: "address";
|
|
403
|
+
readonly internalType: "address";
|
|
404
|
+
}, {
|
|
405
|
+
readonly name: "witness";
|
|
406
|
+
readonly type: "tuple";
|
|
407
|
+
readonly internalType: "struct x402ExactPermit2Proxy.Witness";
|
|
408
|
+
readonly components: readonly [{
|
|
409
|
+
readonly name: "to";
|
|
410
|
+
readonly type: "address";
|
|
411
|
+
readonly internalType: "address";
|
|
412
|
+
}, {
|
|
413
|
+
readonly name: "validAfter";
|
|
414
|
+
readonly type: "uint256";
|
|
415
|
+
readonly internalType: "uint256";
|
|
416
|
+
}];
|
|
417
|
+
}, {
|
|
418
|
+
readonly name: "signature";
|
|
419
|
+
readonly type: "bytes";
|
|
420
|
+
readonly internalType: "bytes";
|
|
421
|
+
}];
|
|
422
|
+
readonly outputs: readonly [];
|
|
423
|
+
readonly stateMutability: "nonpayable";
|
|
424
|
+
}, {
|
|
425
|
+
readonly type: "event";
|
|
426
|
+
readonly name: "Settled";
|
|
427
|
+
readonly inputs: readonly [];
|
|
428
|
+
readonly anonymous: false;
|
|
429
|
+
}, {
|
|
430
|
+
readonly type: "event";
|
|
431
|
+
readonly name: "SettledWithPermit";
|
|
432
|
+
readonly inputs: readonly [];
|
|
433
|
+
readonly anonymous: false;
|
|
434
|
+
}, {
|
|
435
|
+
readonly type: "error";
|
|
436
|
+
readonly name: "InvalidAmount";
|
|
437
|
+
readonly inputs: readonly [];
|
|
438
|
+
}, {
|
|
439
|
+
readonly type: "error";
|
|
440
|
+
readonly name: "InvalidDestination";
|
|
441
|
+
readonly inputs: readonly [];
|
|
442
|
+
}, {
|
|
443
|
+
readonly type: "error";
|
|
444
|
+
readonly name: "InvalidOwner";
|
|
445
|
+
readonly inputs: readonly [];
|
|
446
|
+
}, {
|
|
447
|
+
readonly type: "error";
|
|
448
|
+
readonly name: "InvalidPermit2Address";
|
|
449
|
+
readonly inputs: readonly [];
|
|
450
|
+
}, {
|
|
451
|
+
readonly type: "error";
|
|
452
|
+
readonly name: "PaymentTooEarly";
|
|
453
|
+
readonly inputs: readonly [];
|
|
454
|
+
}, {
|
|
455
|
+
readonly type: "error";
|
|
456
|
+
readonly name: "Permit2612AmountMismatch";
|
|
457
|
+
readonly inputs: readonly [];
|
|
458
|
+
}, {
|
|
459
|
+
readonly type: "error";
|
|
460
|
+
readonly name: "ReentrancyGuardReentrantCall";
|
|
461
|
+
readonly inputs: readonly [];
|
|
462
|
+
}];
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Creates transaction data to approve Permit2 to spend tokens.
|
|
466
|
+
* The user sends this transaction (paying gas) before using Permit2 flow.
|
|
467
|
+
*
|
|
468
|
+
* @param tokenAddress - The ERC20 token contract address
|
|
469
|
+
* @returns Transaction data to send for approval
|
|
470
|
+
*
|
|
471
|
+
* @example
|
|
472
|
+
* ```typescript
|
|
473
|
+
* const tx = createPermit2ApprovalTx("0x...");
|
|
474
|
+
* await walletClient.sendTransaction({
|
|
475
|
+
* to: tx.to,
|
|
476
|
+
* data: tx.data,
|
|
477
|
+
* });
|
|
478
|
+
* ```
|
|
479
|
+
*/
|
|
480
|
+
declare function createPermit2ApprovalTx(tokenAddress: `0x${string}`): {
|
|
481
|
+
to: `0x${string}`;
|
|
482
|
+
data: `0x${string}`;
|
|
483
|
+
};
|
|
484
|
+
/**
|
|
485
|
+
* Parameters for checking Permit2 allowance.
|
|
486
|
+
* Application provides these to check if approval is needed.
|
|
487
|
+
*/
|
|
488
|
+
interface Permit2AllowanceParams {
|
|
489
|
+
tokenAddress: `0x${string}`;
|
|
490
|
+
ownerAddress: `0x${string}`;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Returns contract read parameters for checking Permit2 allowance.
|
|
494
|
+
* Use with a public client to check if the user has approved Permit2.
|
|
495
|
+
*
|
|
496
|
+
* @param params - The allowance check parameters
|
|
497
|
+
* @returns Contract read parameters for checking allowance
|
|
498
|
+
*
|
|
499
|
+
* @example
|
|
500
|
+
* ```typescript
|
|
501
|
+
* const readParams = getPermit2AllowanceReadParams({
|
|
502
|
+
* tokenAddress: "0x...",
|
|
503
|
+
* ownerAddress: "0x...",
|
|
504
|
+
* });
|
|
505
|
+
*
|
|
506
|
+
* const allowance = await publicClient.readContract(readParams);
|
|
507
|
+
* const needsApproval = allowance < requiredAmount;
|
|
508
|
+
* ```
|
|
509
|
+
*/
|
|
510
|
+
declare function getPermit2AllowanceReadParams(params: Permit2AllowanceParams): {
|
|
511
|
+
address: `0x${string}`;
|
|
512
|
+
abi: typeof erc20AllowanceAbi;
|
|
513
|
+
functionName: "allowance";
|
|
514
|
+
args: [`0x${string}`, `0x${string}`];
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
export { ExactEvmScheme as E, type Permit2AllowanceParams as P, PERMIT2_ADDRESS as a, x402UptoPermit2ProxyAddress as b, createPermit2ApprovalTx as c, authorizationTypes as d, erc20AllowanceAbi as e, eip3009ABI as f, getPermit2AllowanceReadParams as g, x402ExactPermit2ProxyABI as h, permit2WitnessTypes as p, x402ExactPermit2ProxyAddress as x };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { E as ExactEvmScheme,
|
|
2
|
-
import { SelectPaymentRequirements, PaymentPolicy
|
|
1
|
+
export { E as ExactEvmScheme, P as Permit2AllowanceParams, c as createPermit2ApprovalTx, e as erc20AllowanceAbi, g as getPermit2AllowanceReadParams } from '../../permit2-BuAhWvNC.mjs';
|
|
2
|
+
import { x402Client, SelectPaymentRequirements, PaymentPolicy } from '@x402/core/client';
|
|
3
3
|
import { Network } from '@x402/core/types';
|
|
4
4
|
import { C as ClientEvmSigner } from '../../signer-DC81R8wQ.mjs';
|
|
5
5
|
|
|
@@ -104,12 +104,18 @@ var ExactEvmScheme = class {
|
|
|
104
104
|
defaultMoneyConversion(amount, network) {
|
|
105
105
|
const assetInfo = this.getDefaultAsset(network);
|
|
106
106
|
const tokenAmount = this.convertToTokenAmount(amount.toString(), assetInfo.decimals);
|
|
107
|
+
const includeEip712Domain = !assetInfo.assetTransferMethod || assetInfo.supportsEip2612;
|
|
107
108
|
return {
|
|
108
109
|
amount: tokenAmount,
|
|
109
110
|
asset: assetInfo.address,
|
|
110
111
|
extra: {
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
...includeEip712Domain && {
|
|
113
|
+
name: assetInfo.name,
|
|
114
|
+
version: assetInfo.version
|
|
115
|
+
},
|
|
116
|
+
...assetInfo.assetTransferMethod && {
|
|
117
|
+
assetTransferMethod: assetInfo.assetTransferMethod
|
|
118
|
+
}
|
|
113
119
|
}
|
|
114
120
|
};
|
|
115
121
|
}
|
|
@@ -156,9 +162,18 @@ var ExactEvmScheme = class {
|
|
|
156
162
|
address: "0xFAfDdbb3FC7688494971a79cc65DCa3EF82079E7",
|
|
157
163
|
name: "MegaUSD",
|
|
158
164
|
version: "1",
|
|
159
|
-
decimals: 18
|
|
165
|
+
decimals: 18,
|
|
166
|
+
assetTransferMethod: "permit2",
|
|
167
|
+
supportsEip2612: true
|
|
168
|
+
},
|
|
169
|
+
// MegaETH mainnet MegaUSD (no EIP-3009, supports EIP-2612)
|
|
170
|
+
"eip155:143": {
|
|
171
|
+
address: "0x754704Bc059F8C67012fEd69BC8A327a5aafb603",
|
|
172
|
+
name: "USD Coin",
|
|
173
|
+
version: "2",
|
|
174
|
+
decimals: 6
|
|
160
175
|
}
|
|
161
|
-
//
|
|
176
|
+
// Monad mainnet USDC
|
|
162
177
|
};
|
|
163
178
|
const assetInfo = stablecoins[network];
|
|
164
179
|
if (!assetInfo) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/exact/server/scheme.ts","../../../../src/exact/server/register.ts"],"sourcesContent":["import {\n AssetAmount,\n Network,\n PaymentRequirements,\n Price,\n SchemeNetworkServer,\n MoneyParser,\n} from \"@x402/core/types\";\n\n/**\n * EVM server implementation for the Exact payment scheme.\n */\nexport class ExactEvmScheme implements SchemeNetworkServer {\n readonly scheme = \"exact\";\n private moneyParsers: MoneyParser[] = [];\n\n /**\n * Register a custom money parser in the parser chain.\n * Multiple parsers can be registered - they will be tried in registration order.\n * Each parser receives a decimal amount (e.g., 1.50 for $1.50).\n * If a parser returns null, the next parser in the chain will be tried.\n * The default parser is always the final fallback.\n *\n * @param parser - Custom function to convert amount to AssetAmount (or null to skip)\n * @returns The server instance for chaining\n *\n * @example\n * evmServer.registerMoneyParser(async (amount, network) => {\n * // Custom conversion logic\n * if (amount > 100) {\n * // Use different token for large amounts\n * return { amount: (amount * 1e18).toString(), asset: \"0xCustomToken\" };\n * }\n * return null; // Use next parser\n * });\n */\n registerMoneyParser(parser: MoneyParser): ExactEvmScheme {\n this.moneyParsers.push(parser);\n return this;\n }\n\n /**\n * Parses a price into an asset amount.\n * If price is already an AssetAmount, returns it directly.\n * If price is Money (string | number), parses to decimal and tries custom parsers.\n * Falls back to default conversion if all custom parsers return null.\n *\n * @param price - The price to parse\n * @param network - The network to use\n * @returns Promise that resolves to the parsed asset amount\n */\n async parsePrice(price: Price, network: Network): Promise<AssetAmount> {\n // If already an AssetAmount, return it directly\n if (typeof price === \"object\" && price !== null && \"amount\" in price) {\n if (!price.asset) {\n throw new Error(`Asset address must be specified for AssetAmount on network ${network}`);\n }\n return {\n amount: price.amount,\n asset: price.asset,\n extra: price.extra || {},\n };\n }\n\n // Parse Money to decimal number\n const amount = this.parseMoneyToDecimal(price);\n\n // Try each custom money parser in order\n for (const parser of this.moneyParsers) {\n const result = await parser(amount, network);\n if (result !== null) {\n return result;\n }\n }\n\n // All custom parsers returned null, use default conversion\n return this.defaultMoneyConversion(amount, network);\n }\n\n /**\n * Build payment requirements for this scheme/network combination\n *\n * @param paymentRequirements - The base payment requirements\n * @param supportedKind - The supported kind from facilitator (unused)\n * @param supportedKind.x402Version - The x402 version\n * @param supportedKind.scheme - The logical payment scheme\n * @param supportedKind.network - The network identifier in CAIP-2 format\n * @param supportedKind.extra - Optional extra metadata regarding scheme/network implementation details\n * @param extensionKeys - Extension keys supported by the facilitator (unused)\n * @returns Payment requirements ready to be sent to clients\n */\n enhancePaymentRequirements(\n paymentRequirements: PaymentRequirements,\n supportedKind: {\n x402Version: number;\n scheme: string;\n network: Network;\n extra?: Record<string, unknown>;\n },\n extensionKeys: string[],\n ): Promise<PaymentRequirements> {\n // Mark unused parameters to satisfy linter\n void supportedKind;\n void extensionKeys;\n return Promise.resolve(paymentRequirements);\n }\n\n /**\n * Parse Money (string | number) to a decimal number.\n * Handles formats like \"$1.50\", \"1.50\", 1.50, etc.\n *\n * @param money - The money value to parse\n * @returns Decimal number\n */\n private parseMoneyToDecimal(money: string | number): number {\n if (typeof money === \"number\") {\n return money;\n }\n\n // Remove $ sign and whitespace, then parse\n const cleanMoney = money.replace(/^\\$/, \"\").trim();\n const amount = parseFloat(cleanMoney);\n\n if (isNaN(amount)) {\n throw new Error(`Invalid money format: ${money}`);\n }\n\n return amount;\n }\n\n /**\n * Default money conversion implementation.\n * Converts decimal amount to the default stablecoin on the specified network.\n *\n * @param amount - The decimal amount (e.g., 1.50)\n * @param network - The network to use\n * @returns The parsed asset amount in the default stablecoin\n */\n private defaultMoneyConversion(amount: number, network: Network): AssetAmount {\n const assetInfo = this.getDefaultAsset(network);\n const tokenAmount = this.convertToTokenAmount(amount.toString(), assetInfo.decimals);\n\n return {\n amount: tokenAmount,\n asset: assetInfo.address,\n extra: {\n name: assetInfo.name,\n version: assetInfo.version,\n },\n };\n }\n\n /**\n * Convert decimal amount to token units (e.g., 0.10 -> 100000 for 6-decimal tokens)\n *\n * @param decimalAmount - The decimal amount to convert\n * @param decimals - The number of decimals for the token\n * @returns The token amount as a string\n */\n private convertToTokenAmount(decimalAmount: string, decimals: number): string {\n const amount = parseFloat(decimalAmount);\n if (isNaN(amount)) {\n throw new Error(`Invalid amount: ${decimalAmount}`);\n }\n // Convert to smallest unit (e.g., for USDC with 6 decimals: 0.10 * 10^6 = 100000)\n const [intPart, decPart = \"\"] = String(amount).split(\".\");\n const paddedDec = decPart.padEnd(decimals, \"0\").slice(0, decimals);\n const tokenAmount = (intPart + paddedDec).replace(/^0+/, \"\") || \"0\";\n return tokenAmount;\n }\n\n /**\n * Get the default asset info for a network (typically USDC)\n *\n * @param network - The network to get asset info for\n * @returns The asset information including address, name, version, and decimals\n */\n private getDefaultAsset(network: Network): {\n address: string;\n name: string;\n version: string;\n decimals: number;\n } {\n // Map of network to USDC info including EIP-712 domain parameters\n // Each network has the right to determine its own default stablecoin that can be expressed as a USD string by calling servers\n // NOTE: Currently only EIP-3009 supporting stablecoins can be used with this scheme\n // Generic ERC20 support via EIP-2612/permit2 is planned, but not yet implemented.\n const stablecoins: Record<\n string,\n { address: string; name: string; version: string; decimals: number }\n > = {\n \"eip155:8453\": {\n address: \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\",\n name: \"USD Coin\",\n version: \"2\",\n decimals: 6,\n }, // Base mainnet USDC\n \"eip155:84532\": {\n address: \"0x036CbD53842c5426634e7929541eC2318f3dCF7e\",\n name: \"USDC\",\n version: \"2\",\n decimals: 6,\n }, // Base Sepolia USDC\n \"eip155:4326\": {\n address: \"0xFAfDdbb3FC7688494971a79cc65DCa3EF82079E7\",\n name: \"MegaUSD\",\n version: \"1\",\n decimals: 18,\n }, // MegaETH mainnet USDM\n };\n\n const assetInfo = stablecoins[network];\n if (!assetInfo) {\n throw new Error(`No default asset configured for network ${network}`);\n }\n\n return assetInfo;\n }\n}\n","import { x402ResourceServer } from \"@x402/core/server\";\nimport { Network } from \"@x402/core/types\";\nimport { ExactEvmScheme } from \"./scheme\";\n\n/**\n * Configuration options for registering EVM schemes to an x402ResourceServer\n */\nexport interface EvmResourceServerConfig {\n /**\n * Optional specific networks to register\n * If not provided, registers wildcard support (eip155:*)\n */\n networks?: Network[];\n}\n\n/**\n * Registers EVM exact payment schemes to an x402ResourceServer instance.\n *\n * This function registers:\n * - V2: eip155:* wildcard scheme with ExactEvmScheme (or specific networks if provided)\n *\n * @param server - The x402ResourceServer instance to register schemes to\n * @param config - Configuration for EVM resource server registration\n * @returns The server instance for chaining\n *\n * @example\n * ```typescript\n * import { registerExactEvmScheme } from \"@x402/evm/exact/server/register\";\n * import { x402ResourceServer } from \"@x402/core/server\";\n *\n * const server = new x402ResourceServer(facilitatorClient);\n * registerExactEvmScheme(server, {});\n * ```\n */\nexport function registerExactEvmScheme(\n server: x402ResourceServer,\n config: EvmResourceServerConfig = {},\n): x402ResourceServer {\n // Register V2 scheme\n if (config.networks && config.networks.length > 0) {\n // Register specific networks\n config.networks.forEach(network => {\n server.register(network, new ExactEvmScheme());\n });\n } else {\n // Register wildcard for all EVM chains\n server.register(\"eip155:*\", new ExactEvmScheme());\n }\n\n return server;\n}\n"],"mappings":";AAYO,IAAM,iBAAN,MAAoD;AA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ACT,UAAU;AAAA,MACZ;AAAA;AAAA,IACF;AAEA,UAAM,YAAY,YAAY,OAAO;AACrC,QAAI,CAAC,WAAW;AACd,YAAM,IAAI,MAAM,2CAA2C,OAAO,EAAE;AAAA,IACtE;AAEA,WAAO;AAAA,EACT;AACF;;;ACxLO,SAAS,uBACd,QACA,SAAkC,CAAC,GACf;AAEpB,MAAI,OAAO,YAAY,OAAO,SAAS,SAAS,GAAG;AAEjD,WAAO,SAAS,QAAQ,aAAW;AACjC,aAAO,SAAS,SAAS,IAAI,eAAe,CAAC;AAAA,IAC/C,CAAC;AAAA,EACH,OAAO;AAEL,WAAO,SAAS,YAAY,IAAI,eAAe,CAAC;AAAA,EAClD;AAEA,SAAO;AACT;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/exact/server/scheme.ts","../../../../src/exact/server/register.ts"],"sourcesContent":["import {\n AssetAmount,\n Network,\n PaymentRequirements,\n Price,\n SchemeNetworkServer,\n MoneyParser,\n} from \"@x402/core/types\";\n\n/**\n * EVM server implementation for the Exact payment scheme.\n */\nexport class ExactEvmScheme implements SchemeNetworkServer {\n readonly scheme = \"exact\";\n private moneyParsers: MoneyParser[] = [];\n\n /**\n * Register a custom money parser in the parser chain.\n * Multiple parsers can be registered - they will be tried in registration order.\n * Each parser receives a decimal amount (e.g., 1.50 for $1.50).\n * If a parser returns null, the next parser in the chain will be tried.\n * The default parser is always the final fallback.\n *\n * @param parser - Custom function to convert amount to AssetAmount (or null to skip)\n * @returns The server instance for chaining\n *\n * @example\n * evmServer.registerMoneyParser(async (amount, network) => {\n * // Custom conversion logic\n * if (amount > 100) {\n * // Use different token for large amounts\n * return { amount: (amount * 1e18).toString(), asset: \"0xCustomToken\" };\n * }\n * return null; // Use next parser\n * });\n */\n registerMoneyParser(parser: MoneyParser): ExactEvmScheme {\n this.moneyParsers.push(parser);\n return this;\n }\n\n /**\n * Parses a price into an asset amount.\n * If price is already an AssetAmount, returns it directly.\n * If price is Money (string | number), parses to decimal and tries custom parsers.\n * Falls back to default conversion if all custom parsers return null.\n *\n * @param price - The price to parse\n * @param network - The network to use\n * @returns Promise that resolves to the parsed asset amount\n */\n async parsePrice(price: Price, network: Network): Promise<AssetAmount> {\n // If already an AssetAmount, return it directly\n if (typeof price === \"object\" && price !== null && \"amount\" in price) {\n if (!price.asset) {\n throw new Error(`Asset address must be specified for AssetAmount on network ${network}`);\n }\n return {\n amount: price.amount,\n asset: price.asset,\n extra: price.extra || {},\n };\n }\n\n // Parse Money to decimal number\n const amount = this.parseMoneyToDecimal(price);\n\n // Try each custom money parser in order\n for (const parser of this.moneyParsers) {\n const result = await parser(amount, network);\n if (result !== null) {\n return result;\n }\n }\n\n // All custom parsers returned null, use default conversion\n return this.defaultMoneyConversion(amount, network);\n }\n\n /**\n * Build payment requirements for this scheme/network combination\n *\n * @param paymentRequirements - The base payment requirements\n * @param supportedKind - The supported kind from facilitator (unused)\n * @param supportedKind.x402Version - The x402 version\n * @param supportedKind.scheme - The logical payment scheme\n * @param supportedKind.network - The network identifier in CAIP-2 format\n * @param supportedKind.extra - Optional extra metadata regarding scheme/network implementation details\n * @param extensionKeys - Extension keys supported by the facilitator (unused)\n * @returns Payment requirements ready to be sent to clients\n */\n enhancePaymentRequirements(\n paymentRequirements: PaymentRequirements,\n supportedKind: {\n x402Version: number;\n scheme: string;\n network: Network;\n extra?: Record<string, unknown>;\n },\n extensionKeys: string[],\n ): Promise<PaymentRequirements> {\n // Mark unused parameters to satisfy linter\n void supportedKind;\n void extensionKeys;\n return Promise.resolve(paymentRequirements);\n }\n\n /**\n * Parse Money (string | number) to a decimal number.\n * Handles formats like \"$1.50\", \"1.50\", 1.50, etc.\n *\n * @param money - The money value to parse\n * @returns Decimal number\n */\n private parseMoneyToDecimal(money: string | number): number {\n if (typeof money === \"number\") {\n return money;\n }\n\n // Remove $ sign and whitespace, then parse\n const cleanMoney = money.replace(/^\\$/, \"\").trim();\n const amount = parseFloat(cleanMoney);\n\n if (isNaN(amount)) {\n throw new Error(`Invalid money format: ${money}`);\n }\n\n return amount;\n }\n\n /**\n * Default money conversion implementation.\n * Converts decimal amount to the default stablecoin on the specified network.\n *\n * @param amount - The decimal amount (e.g., 1.50)\n * @param network - The network to use\n * @returns The parsed asset amount in the default stablecoin\n */\n private defaultMoneyConversion(amount: number, network: Network): AssetAmount {\n const assetInfo = this.getDefaultAsset(network);\n const tokenAmount = this.convertToTokenAmount(amount.toString(), assetInfo.decimals);\n\n // EIP-3009 tokens always need name/version for their transferWithAuthorization domain.\n // Permit2 tokens only need them if the token supports EIP-2612 (for gasless permit signing).\n // Omitting name/version for permit2 tokens signals the client to skip EIP-2612 and use\n // ERC-20 approval gas sponsoring instead.\n const includeEip712Domain = !assetInfo.assetTransferMethod || assetInfo.supportsEip2612;\n\n return {\n amount: tokenAmount,\n asset: assetInfo.address,\n extra: {\n ...(includeEip712Domain && {\n name: assetInfo.name,\n version: assetInfo.version,\n }),\n ...(assetInfo.assetTransferMethod && {\n assetTransferMethod: assetInfo.assetTransferMethod,\n }),\n },\n };\n }\n\n /**\n * Convert decimal amount to token units (e.g., 0.10 -> 100000 for 6-decimal tokens)\n *\n * @param decimalAmount - The decimal amount to convert\n * @param decimals - The number of decimals for the token\n * @returns The token amount as a string\n */\n private convertToTokenAmount(decimalAmount: string, decimals: number): string {\n const amount = parseFloat(decimalAmount);\n if (isNaN(amount)) {\n throw new Error(`Invalid amount: ${decimalAmount}`);\n }\n // Convert to smallest unit (e.g., for USDC with 6 decimals: 0.10 * 10^6 = 100000)\n const [intPart, decPart = \"\"] = String(amount).split(\".\");\n const paddedDec = decPart.padEnd(decimals, \"0\").slice(0, decimals);\n const tokenAmount = (intPart + paddedDec).replace(/^0+/, \"\") || \"0\";\n return tokenAmount;\n }\n\n /**\n * Get the default asset info for a network (typically USDC)\n *\n * @param network - The network to get asset info for\n * @returns The asset information including address, name, version, and decimals\n */\n private getDefaultAsset(network: Network): {\n address: string;\n name: string;\n version: string;\n decimals: number;\n assetTransferMethod?: string;\n supportsEip2612?: boolean;\n } {\n // Map of network to stablecoin info including EIP-712 domain parameters.\n // Each network has the right to determine its own default stablecoin that can be expressed as a USD string by calling servers.\n // Tokens that don't support EIP-3009 should set assetTransferMethod: \"permit2\".\n // For permit2 tokens, set supportsEip2612: true if the token implements EIP-2612 permit().\n // When supportsEip2612 is false/absent on a permit2 token, name/version are omitted from\n // extra so the client skips the EIP-2612 path and falls back to ERC-20 approval gas sponsoring.\n const stablecoins: Record<\n string,\n {\n address: string;\n name: string;\n version: string;\n decimals: number;\n assetTransferMethod?: string;\n supportsEip2612?: boolean;\n }\n > = {\n \"eip155:8453\": {\n address: \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\",\n name: \"USD Coin\",\n version: \"2\",\n decimals: 6,\n }, // Base mainnet USDC\n \"eip155:84532\": {\n address: \"0x036CbD53842c5426634e7929541eC2318f3dCF7e\",\n name: \"USDC\",\n version: \"2\",\n decimals: 6,\n }, // Base Sepolia USDC\n \"eip155:4326\": {\n address: \"0xFAfDdbb3FC7688494971a79cc65DCa3EF82079E7\",\n name: \"MegaUSD\",\n version: \"1\",\n decimals: 18,\n assetTransferMethod: \"permit2\",\n supportsEip2612: true,\n }, // MegaETH mainnet MegaUSD (no EIP-3009, supports EIP-2612)\n \"eip155:143\": {\n address: \"0x754704Bc059F8C67012fEd69BC8A327a5aafb603\",\n name: \"USD Coin\",\n version: \"2\",\n decimals: 6,\n }, // Monad mainnet USDC\n };\n\n const assetInfo = stablecoins[network];\n if (!assetInfo) {\n throw new Error(`No default asset configured for network ${network}`);\n }\n\n return assetInfo;\n }\n}\n","import { x402ResourceServer } from \"@x402/core/server\";\nimport { Network } from \"@x402/core/types\";\nimport { ExactEvmScheme } from \"./scheme\";\n\n/**\n * Configuration options for registering EVM schemes to an x402ResourceServer\n */\nexport interface EvmResourceServerConfig {\n /**\n * Optional specific networks to register\n * If not provided, registers wildcard support (eip155:*)\n */\n networks?: Network[];\n}\n\n/**\n * Registers EVM exact payment schemes to an x402ResourceServer instance.\n *\n * This function registers:\n * - V2: eip155:* wildcard scheme with ExactEvmScheme (or specific networks if provided)\n *\n * @param server - The x402ResourceServer instance to register schemes to\n * @param config - Configuration for EVM resource server registration\n * @returns The server instance for chaining\n *\n * @example\n * ```typescript\n * import { registerExactEvmScheme } from \"@x402/evm/exact/server/register\";\n * import { x402ResourceServer } from \"@x402/core/server\";\n *\n * const server = new x402ResourceServer(facilitatorClient);\n * registerExactEvmScheme(server, {});\n * ```\n */\nexport function registerExactEvmScheme(\n server: x402ResourceServer,\n config: EvmResourceServerConfig = {},\n): x402ResourceServer {\n // Register V2 scheme\n if (config.networks && config.networks.length > 0) {\n // Register specific networks\n config.networks.forEach(network => {\n server.register(network, new ExactEvmScheme());\n });\n } else {\n // Register wildcard for all EVM chains\n server.register(\"eip155:*\", new ExactEvmScheme());\n }\n\n return server;\n}\n"],"mappings":";AAYO,IAAM,iBAAN,MAAoD;AAAA,EAApD;AACL,SAAS,SAAS;AAClB,SAAQ,eAA8B,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsBvC,oBAAoB,QAAqC;AACvD,SAAK,aAAa,KAAK,MAAM;AAC7B,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,MAAM,WAAW,OAAc,SAAwC;AAErE,QAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,YAAY,OAAO;AACpE,UAAI,CAAC,MAAM,OAAO;AAChB,cAAM,IAAI,MAAM,8DAA8D,OAAO,EAAE;AAAA,MACzF;AACA,aAAO;AAAA,QACL,QAAQ,MAAM;AAAA,QACd,OAAO,MAAM;AAAA,QACb,OAAO,MAAM,SAAS,CAAC;AAAA,MACzB;AAAA,IACF;AAGA,UAAM,SAAS,KAAK,oBAAoB,KA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,CAAC;AAAA,EACH,OAAO;AAEL,WAAO,SAAS,YAAY,IAAI,eAAe,CAAC;AAAA,EAClD;AAEA,SAAO;AACT;","names":[]}
|
package/dist/esm/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { E as ExactEvmScheme,
|
|
1
|
+
export { E as ExactEvmScheme, a as PERMIT2_ADDRESS, P as Permit2AllowanceParams, d as authorizationTypes, c as createPermit2ApprovalTx, f as eip3009ABI, e as erc20AllowanceAbi, g as getPermit2AllowanceReadParams, p as permit2WitnessTypes, h as x402ExactPermit2ProxyABI, x as x402ExactPermit2ProxyAddress, b as x402UptoPermit2ProxyAddress } from './permit2-BuAhWvNC.mjs';
|
|
2
2
|
export { C as ClientEvmSigner, F as FacilitatorEvmSigner, t as toClientEvmSigner, a as toFacilitatorEvmSigner } from './signer-DC81R8wQ.mjs';
|
|
3
3
|
import '@x402/core/types';
|
|
4
4
|
|
|
@@ -514,4 +514,4 @@ declare function getPermit2AllowanceReadParams(params: Permit2AllowanceParams):
|
|
|
514
514
|
args: [`0x${string}`, `0x${string}`];
|
|
515
515
|
};
|
|
516
516
|
|
|
517
|
-
export { ExactEvmScheme as E,
|
|
517
|
+
export { ExactEvmScheme as E, type Permit2AllowanceParams as P, PERMIT2_ADDRESS as a, x402UptoPermit2ProxyAddress as b, createPermit2ApprovalTx as c, authorizationTypes as d, erc20AllowanceAbi as e, eip3009ABI as f, getPermit2AllowanceReadParams as g, x402ExactPermit2ProxyABI as h, permit2WitnessTypes as p, x402ExactPermit2ProxyAddress as x };
|