@introspectivelabs/x402-evm 0.1.0-beta.11 → 0.1.0-beta.12
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/server/index.d.ts +1 -0
- package/dist/cjs/exact/server/index.js +102 -0
- package/dist/cjs/exact/server/index.js.map +1 -1
- package/dist/cjs/index.js +151 -134
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/{chunk-CGTTWYDC.mjs → chunk-JIQ3WKXV.mjs} +1 -1
- package/dist/esm/{chunk-E3XDJP7M.mjs → chunk-NZIZ7SXW.mjs} +20 -1
- package/dist/esm/chunk-NZIZ7SXW.mjs.map +1 -0
- package/dist/esm/{chunk-ZTFX2VPI.mjs → chunk-OEV5E7TH.mjs} +2 -2
- package/dist/esm/chunk-RN5WLEGU.mjs +1 -0
- package/dist/esm/chunk-RN5WLEGU.mjs.map +1 -0
- package/dist/esm/exact/client/index.mjs +3 -2
- package/dist/esm/exact/server/index.d.mts +1 -0
- package/dist/esm/exact/server/index.mjs +2 -1
- package/dist/esm/index.mjs +4 -3
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/networks/index.mjs +2 -1
- package/package.json +1 -1
- package/dist/esm/chunk-E3XDJP7M.mjs.map +0 -1
- /package/dist/esm/{chunk-CGTTWYDC.mjs.map → chunk-JIQ3WKXV.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZTFX2VPI.mjs.map → chunk-OEV5E7TH.mjs.map} +0 -0
|
@@ -27,6 +27,93 @@ module.exports = __toCommonJS(server_exports);
|
|
|
27
27
|
// src/exact/server/scheme.ts
|
|
28
28
|
var import_server = require("@x402/evm/exact/server");
|
|
29
29
|
|
|
30
|
+
// src/networks/registry.ts
|
|
31
|
+
var SUPPORTED_CHAINS = {
|
|
32
|
+
8453: {
|
|
33
|
+
chainId: 8453,
|
|
34
|
+
name: "Base",
|
|
35
|
+
v1Name: "base",
|
|
36
|
+
caip2: "eip155:8453",
|
|
37
|
+
rpcUrl: "https://mainnet.base.org",
|
|
38
|
+
blockExplorerUrl: "https://basescan.org",
|
|
39
|
+
usdcAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
40
|
+
safeTransactionServiceUrl: "https://safe-transaction-base.safe.global",
|
|
41
|
+
testnet: false
|
|
42
|
+
},
|
|
43
|
+
84532: {
|
|
44
|
+
chainId: 84532,
|
|
45
|
+
name: "Base Sepolia",
|
|
46
|
+
v1Name: "base-sepolia",
|
|
47
|
+
caip2: "eip155:84532",
|
|
48
|
+
rpcUrl: "https://sepolia.base.org",
|
|
49
|
+
blockExplorerUrl: "https://sepolia.basescan.org",
|
|
50
|
+
usdcAddress: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
|
|
51
|
+
safeTransactionServiceUrl: "https://safe-transaction-base-sepolia.safe.global",
|
|
52
|
+
testnet: true
|
|
53
|
+
},
|
|
54
|
+
10: {
|
|
55
|
+
chainId: 10,
|
|
56
|
+
name: "Optimism",
|
|
57
|
+
v1Name: "optimism",
|
|
58
|
+
caip2: "eip155:10",
|
|
59
|
+
rpcUrl: "https://mainnet.optimism.io",
|
|
60
|
+
blockExplorerUrl: "https://optimistic.etherscan.io",
|
|
61
|
+
usdcAddress: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
|
|
62
|
+
safeTransactionServiceUrl: "https://safe-transaction-optimism.safe.global",
|
|
63
|
+
testnet: false
|
|
64
|
+
},
|
|
65
|
+
11155420: {
|
|
66
|
+
chainId: 11155420,
|
|
67
|
+
name: "Optimism Sepolia",
|
|
68
|
+
v1Name: "optimism-sepolia",
|
|
69
|
+
caip2: "eip155:11155420",
|
|
70
|
+
rpcUrl: "https://sepolia.optimism.io",
|
|
71
|
+
blockExplorerUrl: "https://sepolia-optimistic.etherscan.io",
|
|
72
|
+
usdcAddress: "0x5fd84259d66Cd46123540766Be93DFE6D43130D7",
|
|
73
|
+
safeTransactionServiceUrl: "https://safe-transaction-optimism-sepolia.safe.global",
|
|
74
|
+
testnet: true
|
|
75
|
+
},
|
|
76
|
+
42161: {
|
|
77
|
+
chainId: 42161,
|
|
78
|
+
name: "Arbitrum One",
|
|
79
|
+
v1Name: "arbitrum",
|
|
80
|
+
caip2: "eip155:42161",
|
|
81
|
+
rpcUrl: "https://arb1.arbitrum.io/rpc",
|
|
82
|
+
blockExplorerUrl: "https://arbiscan.io",
|
|
83
|
+
usdcAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
84
|
+
safeTransactionServiceUrl: "https://safe-transaction-arbitrum.safe.global",
|
|
85
|
+
testnet: false
|
|
86
|
+
},
|
|
87
|
+
421614: {
|
|
88
|
+
chainId: 421614,
|
|
89
|
+
name: "Arbitrum Sepolia",
|
|
90
|
+
v1Name: "arbitrum-sepolia",
|
|
91
|
+
caip2: "eip155:421614",
|
|
92
|
+
rpcUrl: "https://sepolia-rollup.arbitrum.io/rpc",
|
|
93
|
+
blockExplorerUrl: "https://sepolia.arbiscan.io",
|
|
94
|
+
usdcAddress: "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
|
|
95
|
+
safeTransactionServiceUrl: "https://safe-transaction-arbitrum-sepolia.safe.global",
|
|
96
|
+
testnet: true
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
var V1_NAME_INDEX = new Map(
|
|
100
|
+
Object.values(SUPPORTED_CHAINS).map((chain) => [chain.v1Name, chain])
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
// src/networks/helpers.ts
|
|
104
|
+
function parseCAIP2(caip2) {
|
|
105
|
+
const match = caip2.match(/^eip155:(\d+)$/);
|
|
106
|
+
if (!match) {
|
|
107
|
+
throw new Error(
|
|
108
|
+
`Invalid CAIP-2 identifier: ${caip2}. Expected format: eip155:{chainId}`
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
return parseInt(match[1], 10);
|
|
112
|
+
}
|
|
113
|
+
function getChainById(chainId) {
|
|
114
|
+
return SUPPORTED_CHAINS[chainId];
|
|
115
|
+
}
|
|
116
|
+
|
|
30
117
|
// src/exact/utils.ts
|
|
31
118
|
function extractUserOperationCapability(requirements) {
|
|
32
119
|
const userOpExtra = requirements.extra?.userOperation;
|
|
@@ -38,6 +125,21 @@ function extractUserOperationCapability(requirements) {
|
|
|
38
125
|
|
|
39
126
|
// src/exact/server/scheme.ts
|
|
40
127
|
var ExactEvmSchemeERC4337 = class extends import_server.ExactEvmScheme {
|
|
128
|
+
constructor() {
|
|
129
|
+
super();
|
|
130
|
+
this.getDefaultAsset = (network) => {
|
|
131
|
+
const chainId = parseCAIP2(network);
|
|
132
|
+
const chain = getChainById(chainId);
|
|
133
|
+
if (chain) {
|
|
134
|
+
return {
|
|
135
|
+
address: chain.usdcAddress,
|
|
136
|
+
name: "USDC",
|
|
137
|
+
version: "2"
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
throw new Error(`No default asset configured for network ${network}`);
|
|
141
|
+
};
|
|
142
|
+
}
|
|
41
143
|
/**
|
|
42
144
|
* Enhance payment requirements while preserving UserOperation capability.
|
|
43
145
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/exact/server/index.ts","../../../../src/exact/server/scheme.ts","../../../../src/exact/utils.ts"],"sourcesContent":["export { ExactEvmSchemeERC4337 } from \"./scheme\";\n","import type { PaymentRequirements, Network } from \"@x402/core/types\";\nimport { ExactEvmScheme } from \"@x402/evm/exact/server\";\nimport { extractUserOperationCapability } from \"../utils\";\n\n/**\n * Enhanced ExactEvmScheme that preserves UserOperation capability in payment requirements.\n *\n * This class extends ExactEvmScheme and enhances the `enhancePaymentRequirements` method\n * to preserve `userOperation` from `paymentRequirements.extra`. This ensures that when routes\n * are transformed using `transformRoutesForUserOperation`, the userOperation data flows through\n * the entire payment requirements pipeline.\n *\n * @example\n * ```typescript\n * import { ExactEvmSchemeERC4337 } from '@introspectivelabs/x402-evm/exact/server';\n * import { x402ResourceServer } from '@x402/core/server';\n *\n * const schemeServer = new ExactEvmSchemeERC4337();\n * const server = new x402ResourceServer(facilitatorClient);\n * server.register('eip155:84532', schemeServer);\n * ```\n */\nexport class ExactEvmSchemeERC4337 extends ExactEvmScheme {\n /**\n * Enhance payment requirements while preserving UserOperation capability.\n *\n * This method calls the parent's enhancePaymentRequirements and then ensures\n * that any userOperation from the original paymentRequirements.extra is preserved\n * in the returned requirements.\n *\n * @param paymentRequirements - The base payment requirements\n * @param supportedKind - The supported kind from facilitator\n * @param supportedKind.x402Version - The x402 version supported by the facilitator\n * @param supportedKind.scheme - The scheme supported by the facilitator\n * @param supportedKind.network - The network supported by the facilitator\n * @param supportedKind.extra - The extra supported by the facilitator\n * @param extensionKeys - Extension keys supported by the facilitator\n * @returns Enhanced payment requirements with userOperation preserved\n */\n async 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 // Extract userOperation from the original requirements before enhancement\n const userOperation = extractUserOperationCapability(paymentRequirements);\n\n // Call parent's enhancePaymentRequirements\n const enhanced = await super.enhancePaymentRequirements(\n paymentRequirements,\n supportedKind,\n extensionKeys,\n );\n\n // If userOperation was present in the original requirements, preserve it\n if (userOperation) {\n return {\n ...enhanced,\n extra: {\n ...enhanced.extra,\n userOperation,\n },\n };\n }\n\n // No userOperation to preserve, but ensure extra exists\n if (!enhanced.extra) {\n return {\n ...enhanced,\n extra: {},\n };\n }\n\n // Return enhanced requirements as-is\n return enhanced;\n }\n}\n","import { PaymentRequirements } from \"@x402/core/types\";\nimport { UserOperationCapability } from \"./types\";\n\n/**\n * Extracts the user operation capability from the payment requirements.\n *\n * @param requirements - The payment requirements\n * @returns The user operation capability\n */\nexport function extractUserOperationCapability(\n requirements: PaymentRequirements,\n): UserOperationCapability | undefined {\n const userOpExtra = requirements.extra?.userOperation;\n if (\n userOpExtra &&\n typeof userOpExtra === \"object\" &&\n \"supported\" in userOpExtra &&\n userOpExtra.supported === true\n ) {\n return userOpExtra as UserOperationCapability;\n }\n return undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,oBAA+B;;;ACQxB,SAAS,+BACd,cACqC;AACrC,QAAM,cAAc,aAAa,OAAO;AACxC,MACE,eACA,OAAO,gBAAgB,YACvB,eAAe,eACf,YAAY,cAAc,MAC1B;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT;;;ADAO,IAAM,wBAAN,cAAoC,6BAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBxD,MAAM,2BACJ,qBACA,eAMA,eAC8B;AAE9B,UAAM,gBAAgB,+BAA+B,mBAAmB;AAGxE,UAAM,WAAW,MAAM,MAAM;AAAA,MAC3B;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAGA,QAAI,eAAe;AACjB,aAAO;AAAA,QACL,GAAG;AAAA,QACH,OAAO;AAAA,UACL,GAAG,SAAS;AAAA,UACZ;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAGA,QAAI,CAAC,SAAS,OAAO;AACnB,aAAO;AAAA,QACL,GAAG;AAAA,QACH,OAAO,CAAC;AAAA,MACV;AAAA,IACF;AAGA,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/exact/server/index.ts","../../../../src/exact/server/scheme.ts","../../../../src/networks/registry.ts","../../../../src/networks/helpers.ts","../../../../src/exact/utils.ts"],"sourcesContent":["export { ExactEvmSchemeERC4337 } from \"./scheme\";\n","import type { PaymentRequirements, Network } from \"@x402/core/types\";\nimport { ExactEvmScheme } from \"@x402/evm/exact/server\";\nimport { getChainById, parseCAIP2 } from \"../../networks/helpers\";\nimport { extractUserOperationCapability } from \"../utils\";\n\n/**\n * Enhanced ExactEvmScheme that preserves UserOperation capability in payment requirements.\n *\n * This class extends ExactEvmScheme and enhances the `enhancePaymentRequirements` method\n * to preserve `userOperation` from `paymentRequirements.extra`. This ensures that when routes\n * are transformed using `transformRoutesForUserOperation`, the userOperation data flows through\n * the entire payment requirements pipeline.\n *\n * @example\n * ```typescript\n * import { ExactEvmSchemeERC4337 } from '@introspectivelabs/x402-evm/exact/server';\n * import { x402ResourceServer } from '@x402/core/server';\n *\n * const schemeServer = new ExactEvmSchemeERC4337();\n * const server = new x402ResourceServer(facilitatorClient);\n * server.register('eip155:84532', schemeServer);\n * ```\n */\nexport class ExactEvmSchemeERC4337 extends ExactEvmScheme {\n constructor() {\n super();\n // Patch getDefaultAsset to support all networks in our registry.\n // The upstream ExactEvmScheme only has USDC addresses for Base and Base Sepolia.\n // We override at the instance level since upstream marks the method as private.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (this as any).getDefaultAsset = (network: string) => {\n const chainId = parseCAIP2(network);\n const chain = getChainById(chainId);\n if (chain) {\n return {\n address: chain.usdcAddress,\n name: \"USDC\",\n version: \"2\",\n };\n }\n throw new Error(`No default asset configured for network ${network}`);\n };\n }\n\n /**\n * Enhance payment requirements while preserving UserOperation capability.\n *\n * This method calls the parent's enhancePaymentRequirements and then ensures\n * that any userOperation from the original paymentRequirements.extra is preserved\n * in the returned requirements.\n *\n * @param paymentRequirements - The base payment requirements\n * @param supportedKind - The supported kind from facilitator\n * @param supportedKind.x402Version - The x402 version supported by the facilitator\n * @param supportedKind.scheme - The scheme supported by the facilitator\n * @param supportedKind.network - The network supported by the facilitator\n * @param supportedKind.extra - The extra supported by the facilitator\n * @param extensionKeys - Extension keys supported by the facilitator\n * @returns Enhanced payment requirements with userOperation preserved\n */\n async 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 // Extract userOperation from the original requirements before enhancement\n const userOperation = extractUserOperationCapability(paymentRequirements);\n\n // Call parent's enhancePaymentRequirements\n const enhanced = await super.enhancePaymentRequirements(\n paymentRequirements,\n supportedKind,\n extensionKeys,\n );\n\n // If userOperation was present in the original requirements, preserve it\n if (userOperation) {\n return {\n ...enhanced,\n extra: {\n ...enhanced.extra,\n userOperation,\n },\n };\n }\n\n // No userOperation to preserve, but ensure extra exists\n if (!enhanced.extra) {\n return {\n ...enhanced,\n extra: {},\n };\n }\n\n // Return enhanced requirements as-is\n return enhanced;\n }\n}\n","import type { ChainInfo } from \"./types\";\n\nexport const SUPPORTED_CHAINS: Record<number, ChainInfo> = {\n 8453: {\n chainId: 8453,\n name: \"Base\",\n v1Name: \"base\",\n caip2: \"eip155:8453\",\n rpcUrl: \"https://mainnet.base.org\",\n blockExplorerUrl: \"https://basescan.org\",\n usdcAddress: \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\",\n safeTransactionServiceUrl: \"https://safe-transaction-base.safe.global\",\n testnet: false,\n },\n 84532: {\n chainId: 84532,\n name: \"Base Sepolia\",\n v1Name: \"base-sepolia\",\n caip2: \"eip155:84532\",\n rpcUrl: \"https://sepolia.base.org\",\n blockExplorerUrl: \"https://sepolia.basescan.org\",\n usdcAddress: \"0x036CbD53842c5426634e7929541eC2318f3dCF7e\",\n safeTransactionServiceUrl:\n \"https://safe-transaction-base-sepolia.safe.global\",\n testnet: true,\n },\n 10: {\n chainId: 10,\n name: \"Optimism\",\n v1Name: \"optimism\",\n caip2: \"eip155:10\",\n rpcUrl: \"https://mainnet.optimism.io\",\n blockExplorerUrl: \"https://optimistic.etherscan.io\",\n usdcAddress: \"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85\",\n safeTransactionServiceUrl:\n \"https://safe-transaction-optimism.safe.global\",\n testnet: false,\n },\n 11155420: {\n chainId: 11155420,\n name: \"Optimism Sepolia\",\n v1Name: \"optimism-sepolia\",\n caip2: \"eip155:11155420\",\n rpcUrl: \"https://sepolia.optimism.io\",\n blockExplorerUrl: \"https://sepolia-optimistic.etherscan.io\",\n usdcAddress: \"0x5fd84259d66Cd46123540766Be93DFE6D43130D7\",\n safeTransactionServiceUrl:\n \"https://safe-transaction-optimism-sepolia.safe.global\",\n testnet: true,\n },\n 42161: {\n chainId: 42161,\n name: \"Arbitrum One\",\n v1Name: \"arbitrum\",\n caip2: \"eip155:42161\",\n rpcUrl: \"https://arb1.arbitrum.io/rpc\",\n blockExplorerUrl: \"https://arbiscan.io\",\n usdcAddress: \"0xaf88d065e77c8cC2239327C5EDb3A432268e5831\",\n safeTransactionServiceUrl:\n \"https://safe-transaction-arbitrum.safe.global\",\n testnet: false,\n },\n 421614: {\n chainId: 421614,\n name: \"Arbitrum Sepolia\",\n v1Name: \"arbitrum-sepolia\",\n caip2: \"eip155:421614\",\n rpcUrl: \"https://sepolia-rollup.arbitrum.io/rpc\",\n blockExplorerUrl: \"https://sepolia.arbiscan.io\",\n usdcAddress: \"0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d\",\n safeTransactionServiceUrl:\n \"https://safe-transaction-arbitrum-sepolia.safe.global\",\n testnet: true,\n },\n};\n\nexport const V1_NAME_INDEX: Map<string, ChainInfo> = new Map(\n Object.values(SUPPORTED_CHAINS).map((chain) => [chain.v1Name, chain]),\n);\n","import type { CAIP2Identifier, ChainInfo, NetworkInput } from \"./types\";\nimport { SUPPORTED_CHAINS, V1_NAME_INDEX } from \"./registry\";\n\nexport function parseCAIP2(caip2: string): number {\n const match = caip2.match(/^eip155:(\\d+)$/);\n if (!match) {\n throw new Error(\n `Invalid CAIP-2 identifier: ${caip2}. Expected format: eip155:{chainId}`,\n );\n }\n return parseInt(match[1], 10);\n}\n\nexport function toCAIP2(chainId: number): CAIP2Identifier {\n return `eip155:${chainId}` as CAIP2Identifier;\n}\n\nexport function resolveChainId(network: NetworkInput): number {\n if (typeof network === \"number\") {\n return network;\n }\n if (network.startsWith(\"eip155:\")) {\n return parseCAIP2(network);\n }\n const chain = V1_NAME_INDEX.get(network);\n if (!chain) {\n throw new Error(\n `Unknown network: ${network}. Expected CAIP-2 (eip155:chainId), a known v1 name, or a numeric chain ID.`,\n );\n }\n return chain.chainId;\n}\n\nexport function getV1Name(chainId: number): string | undefined {\n return SUPPORTED_CHAINS[chainId]?.v1Name;\n}\n\nexport function getV1Names(chainId: number): string[] {\n const name = getV1Name(chainId);\n return name ? [name] : [];\n}\n\nexport function isSupported(chainId: number): boolean {\n return chainId in SUPPORTED_CHAINS;\n}\n\nexport function getChainById(chainId: number): ChainInfo | undefined {\n return SUPPORTED_CHAINS[chainId];\n}\n\nexport function getChain(network: NetworkInput): ChainInfo {\n const chainId = resolveChainId(network);\n const chain = SUPPORTED_CHAINS[chainId];\n if (!chain) {\n throw new Error(\n `Chain ${chainId} is not in the supported chains registry.`,\n );\n }\n return chain;\n}\n\nexport function getSupportedChains(): ChainInfo[] {\n return Object.values(SUPPORTED_CHAINS);\n}\n\nexport function getMainnets(): ChainInfo[] {\n return Object.values(SUPPORTED_CHAINS).filter((c) => !c.testnet);\n}\n\nexport function getTestnets(): ChainInfo[] {\n return Object.values(SUPPORTED_CHAINS).filter((c) => c.testnet);\n}\n","import { PaymentRequirements } from \"@x402/core/types\";\nimport { UserOperationCapability } from \"./types\";\n\n/**\n * Extracts the user operation capability from the payment requirements.\n *\n * @param requirements - The payment requirements\n * @returns The user operation capability\n */\nexport function extractUserOperationCapability(\n requirements: PaymentRequirements,\n): UserOperationCapability | undefined {\n const userOpExtra = requirements.extra?.userOperation;\n if (\n userOpExtra &&\n typeof userOpExtra === \"object\" &&\n \"supported\" in userOpExtra &&\n userOpExtra.supported === true\n ) {\n return userOpExtra as UserOperationCapability;\n }\n return undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,oBAA+B;;;ACCxB,IAAM,mBAA8C;AAAA,EACzD,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,MAAM;AAAA,IACN,QAAQ;AAAA,IAC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package/dist/cjs/index.js
CHANGED
|
@@ -171,7 +171,158 @@ async function injectUserOperationIntoPrice(price, network, userOperation, schem
|
|
|
171
171
|
|
|
172
172
|
// src/exact/server/scheme.ts
|
|
173
173
|
var import_server = require("@x402/evm/exact/server");
|
|
174
|
+
|
|
175
|
+
// src/networks/registry.ts
|
|
176
|
+
var SUPPORTED_CHAINS = {
|
|
177
|
+
8453: {
|
|
178
|
+
chainId: 8453,
|
|
179
|
+
name: "Base",
|
|
180
|
+
v1Name: "base",
|
|
181
|
+
caip2: "eip155:8453",
|
|
182
|
+
rpcUrl: "https://mainnet.base.org",
|
|
183
|
+
blockExplorerUrl: "https://basescan.org",
|
|
184
|
+
usdcAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
185
|
+
safeTransactionServiceUrl: "https://safe-transaction-base.safe.global",
|
|
186
|
+
testnet: false
|
|
187
|
+
},
|
|
188
|
+
84532: {
|
|
189
|
+
chainId: 84532,
|
|
190
|
+
name: "Base Sepolia",
|
|
191
|
+
v1Name: "base-sepolia",
|
|
192
|
+
caip2: "eip155:84532",
|
|
193
|
+
rpcUrl: "https://sepolia.base.org",
|
|
194
|
+
blockExplorerUrl: "https://sepolia.basescan.org",
|
|
195
|
+
usdcAddress: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
|
|
196
|
+
safeTransactionServiceUrl: "https://safe-transaction-base-sepolia.safe.global",
|
|
197
|
+
testnet: true
|
|
198
|
+
},
|
|
199
|
+
10: {
|
|
200
|
+
chainId: 10,
|
|
201
|
+
name: "Optimism",
|
|
202
|
+
v1Name: "optimism",
|
|
203
|
+
caip2: "eip155:10",
|
|
204
|
+
rpcUrl: "https://mainnet.optimism.io",
|
|
205
|
+
blockExplorerUrl: "https://optimistic.etherscan.io",
|
|
206
|
+
usdcAddress: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
|
|
207
|
+
safeTransactionServiceUrl: "https://safe-transaction-optimism.safe.global",
|
|
208
|
+
testnet: false
|
|
209
|
+
},
|
|
210
|
+
11155420: {
|
|
211
|
+
chainId: 11155420,
|
|
212
|
+
name: "Optimism Sepolia",
|
|
213
|
+
v1Name: "optimism-sepolia",
|
|
214
|
+
caip2: "eip155:11155420",
|
|
215
|
+
rpcUrl: "https://sepolia.optimism.io",
|
|
216
|
+
blockExplorerUrl: "https://sepolia-optimistic.etherscan.io",
|
|
217
|
+
usdcAddress: "0x5fd84259d66Cd46123540766Be93DFE6D43130D7",
|
|
218
|
+
safeTransactionServiceUrl: "https://safe-transaction-optimism-sepolia.safe.global",
|
|
219
|
+
testnet: true
|
|
220
|
+
},
|
|
221
|
+
42161: {
|
|
222
|
+
chainId: 42161,
|
|
223
|
+
name: "Arbitrum One",
|
|
224
|
+
v1Name: "arbitrum",
|
|
225
|
+
caip2: "eip155:42161",
|
|
226
|
+
rpcUrl: "https://arb1.arbitrum.io/rpc",
|
|
227
|
+
blockExplorerUrl: "https://arbiscan.io",
|
|
228
|
+
usdcAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
229
|
+
safeTransactionServiceUrl: "https://safe-transaction-arbitrum.safe.global",
|
|
230
|
+
testnet: false
|
|
231
|
+
},
|
|
232
|
+
421614: {
|
|
233
|
+
chainId: 421614,
|
|
234
|
+
name: "Arbitrum Sepolia",
|
|
235
|
+
v1Name: "arbitrum-sepolia",
|
|
236
|
+
caip2: "eip155:421614",
|
|
237
|
+
rpcUrl: "https://sepolia-rollup.arbitrum.io/rpc",
|
|
238
|
+
blockExplorerUrl: "https://sepolia.arbiscan.io",
|
|
239
|
+
usdcAddress: "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
|
|
240
|
+
safeTransactionServiceUrl: "https://safe-transaction-arbitrum-sepolia.safe.global",
|
|
241
|
+
testnet: true
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
var V1_NAME_INDEX = new Map(
|
|
245
|
+
Object.values(SUPPORTED_CHAINS).map((chain) => [chain.v1Name, chain])
|
|
246
|
+
);
|
|
247
|
+
|
|
248
|
+
// src/networks/helpers.ts
|
|
249
|
+
function parseCAIP2(caip2) {
|
|
250
|
+
const match = caip2.match(/^eip155:(\d+)$/);
|
|
251
|
+
if (!match) {
|
|
252
|
+
throw new Error(
|
|
253
|
+
`Invalid CAIP-2 identifier: ${caip2}. Expected format: eip155:{chainId}`
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
return parseInt(match[1], 10);
|
|
257
|
+
}
|
|
258
|
+
function toCAIP2(chainId) {
|
|
259
|
+
return `eip155:${chainId}`;
|
|
260
|
+
}
|
|
261
|
+
function resolveChainId(network) {
|
|
262
|
+
if (typeof network === "number") {
|
|
263
|
+
return network;
|
|
264
|
+
}
|
|
265
|
+
if (network.startsWith("eip155:")) {
|
|
266
|
+
return parseCAIP2(network);
|
|
267
|
+
}
|
|
268
|
+
const chain = V1_NAME_INDEX.get(network);
|
|
269
|
+
if (!chain) {
|
|
270
|
+
throw new Error(
|
|
271
|
+
`Unknown network: ${network}. Expected CAIP-2 (eip155:chainId), a known v1 name, or a numeric chain ID.`
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
return chain.chainId;
|
|
275
|
+
}
|
|
276
|
+
function getV1Name(chainId) {
|
|
277
|
+
return SUPPORTED_CHAINS[chainId]?.v1Name;
|
|
278
|
+
}
|
|
279
|
+
function getV1Names(chainId) {
|
|
280
|
+
const name = getV1Name(chainId);
|
|
281
|
+
return name ? [name] : [];
|
|
282
|
+
}
|
|
283
|
+
function isSupported(chainId) {
|
|
284
|
+
return chainId in SUPPORTED_CHAINS;
|
|
285
|
+
}
|
|
286
|
+
function getChainById(chainId) {
|
|
287
|
+
return SUPPORTED_CHAINS[chainId];
|
|
288
|
+
}
|
|
289
|
+
function getChain(network) {
|
|
290
|
+
const chainId = resolveChainId(network);
|
|
291
|
+
const chain = SUPPORTED_CHAINS[chainId];
|
|
292
|
+
if (!chain) {
|
|
293
|
+
throw new Error(
|
|
294
|
+
`Chain ${chainId} is not in the supported chains registry.`
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
return chain;
|
|
298
|
+
}
|
|
299
|
+
function getSupportedChains() {
|
|
300
|
+
return Object.values(SUPPORTED_CHAINS);
|
|
301
|
+
}
|
|
302
|
+
function getMainnets() {
|
|
303
|
+
return Object.values(SUPPORTED_CHAINS).filter((c) => !c.testnet);
|
|
304
|
+
}
|
|
305
|
+
function getTestnets() {
|
|
306
|
+
return Object.values(SUPPORTED_CHAINS).filter((c) => c.testnet);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// src/exact/server/scheme.ts
|
|
174
310
|
var ExactEvmSchemeERC4337 = class extends import_server.ExactEvmScheme {
|
|
311
|
+
constructor() {
|
|
312
|
+
super();
|
|
313
|
+
this.getDefaultAsset = (network) => {
|
|
314
|
+
const chainId = parseCAIP2(network);
|
|
315
|
+
const chain = getChainById(chainId);
|
|
316
|
+
if (chain) {
|
|
317
|
+
return {
|
|
318
|
+
address: chain.usdcAddress,
|
|
319
|
+
name: "USDC",
|
|
320
|
+
version: "2"
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
throw new Error(`No default asset configured for network ${network}`);
|
|
324
|
+
};
|
|
325
|
+
}
|
|
175
326
|
/**
|
|
176
327
|
* Enhance payment requirements while preserving UserOperation capability.
|
|
177
328
|
*
|
|
@@ -808,140 +959,6 @@ var PaymentCreationError = class extends Error {
|
|
|
808
959
|
}
|
|
809
960
|
};
|
|
810
961
|
|
|
811
|
-
// src/networks/registry.ts
|
|
812
|
-
var SUPPORTED_CHAINS = {
|
|
813
|
-
8453: {
|
|
814
|
-
chainId: 8453,
|
|
815
|
-
name: "Base",
|
|
816
|
-
v1Name: "base",
|
|
817
|
-
caip2: "eip155:8453",
|
|
818
|
-
rpcUrl: "https://mainnet.base.org",
|
|
819
|
-
blockExplorerUrl: "https://basescan.org",
|
|
820
|
-
usdcAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
821
|
-
safeTransactionServiceUrl: "https://safe-transaction-base.safe.global",
|
|
822
|
-
testnet: false
|
|
823
|
-
},
|
|
824
|
-
84532: {
|
|
825
|
-
chainId: 84532,
|
|
826
|
-
name: "Base Sepolia",
|
|
827
|
-
v1Name: "base-sepolia",
|
|
828
|
-
caip2: "eip155:84532",
|
|
829
|
-
rpcUrl: "https://sepolia.base.org",
|
|
830
|
-
blockExplorerUrl: "https://sepolia.basescan.org",
|
|
831
|
-
usdcAddress: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
|
|
832
|
-
safeTransactionServiceUrl: "https://safe-transaction-base-sepolia.safe.global",
|
|
833
|
-
testnet: true
|
|
834
|
-
},
|
|
835
|
-
10: {
|
|
836
|
-
chainId: 10,
|
|
837
|
-
name: "Optimism",
|
|
838
|
-
v1Name: "optimism",
|
|
839
|
-
caip2: "eip155:10",
|
|
840
|
-
rpcUrl: "https://mainnet.optimism.io",
|
|
841
|
-
blockExplorerUrl: "https://optimistic.etherscan.io",
|
|
842
|
-
usdcAddress: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
|
|
843
|
-
safeTransactionServiceUrl: "https://safe-transaction-optimism.safe.global",
|
|
844
|
-
testnet: false
|
|
845
|
-
},
|
|
846
|
-
11155420: {
|
|
847
|
-
chainId: 11155420,
|
|
848
|
-
name: "Optimism Sepolia",
|
|
849
|
-
v1Name: "optimism-sepolia",
|
|
850
|
-
caip2: "eip155:11155420",
|
|
851
|
-
rpcUrl: "https://sepolia.optimism.io",
|
|
852
|
-
blockExplorerUrl: "https://sepolia-optimistic.etherscan.io",
|
|
853
|
-
usdcAddress: "0x5fd84259d66Cd46123540766Be93DFE6D43130D7",
|
|
854
|
-
safeTransactionServiceUrl: "https://safe-transaction-optimism-sepolia.safe.global",
|
|
855
|
-
testnet: true
|
|
856
|
-
},
|
|
857
|
-
42161: {
|
|
858
|
-
chainId: 42161,
|
|
859
|
-
name: "Arbitrum One",
|
|
860
|
-
v1Name: "arbitrum",
|
|
861
|
-
caip2: "eip155:42161",
|
|
862
|
-
rpcUrl: "https://arb1.arbitrum.io/rpc",
|
|
863
|
-
blockExplorerUrl: "https://arbiscan.io",
|
|
864
|
-
usdcAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
865
|
-
safeTransactionServiceUrl: "https://safe-transaction-arbitrum.safe.global",
|
|
866
|
-
testnet: false
|
|
867
|
-
},
|
|
868
|
-
421614: {
|
|
869
|
-
chainId: 421614,
|
|
870
|
-
name: "Arbitrum Sepolia",
|
|
871
|
-
v1Name: "arbitrum-sepolia",
|
|
872
|
-
caip2: "eip155:421614",
|
|
873
|
-
rpcUrl: "https://sepolia-rollup.arbitrum.io/rpc",
|
|
874
|
-
blockExplorerUrl: "https://sepolia.arbiscan.io",
|
|
875
|
-
usdcAddress: "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
|
|
876
|
-
safeTransactionServiceUrl: "https://safe-transaction-arbitrum-sepolia.safe.global",
|
|
877
|
-
testnet: true
|
|
878
|
-
}
|
|
879
|
-
};
|
|
880
|
-
var V1_NAME_INDEX = new Map(
|
|
881
|
-
Object.values(SUPPORTED_CHAINS).map((chain) => [chain.v1Name, chain])
|
|
882
|
-
);
|
|
883
|
-
|
|
884
|
-
// src/networks/helpers.ts
|
|
885
|
-
function parseCAIP2(caip2) {
|
|
886
|
-
const match = caip2.match(/^eip155:(\d+)$/);
|
|
887
|
-
if (!match) {
|
|
888
|
-
throw new Error(
|
|
889
|
-
`Invalid CAIP-2 identifier: ${caip2}. Expected format: eip155:{chainId}`
|
|
890
|
-
);
|
|
891
|
-
}
|
|
892
|
-
return parseInt(match[1], 10);
|
|
893
|
-
}
|
|
894
|
-
function toCAIP2(chainId) {
|
|
895
|
-
return `eip155:${chainId}`;
|
|
896
|
-
}
|
|
897
|
-
function resolveChainId(network) {
|
|
898
|
-
if (typeof network === "number") {
|
|
899
|
-
return network;
|
|
900
|
-
}
|
|
901
|
-
if (network.startsWith("eip155:")) {
|
|
902
|
-
return parseCAIP2(network);
|
|
903
|
-
}
|
|
904
|
-
const chain = V1_NAME_INDEX.get(network);
|
|
905
|
-
if (!chain) {
|
|
906
|
-
throw new Error(
|
|
907
|
-
`Unknown network: ${network}. Expected CAIP-2 (eip155:chainId), a known v1 name, or a numeric chain ID.`
|
|
908
|
-
);
|
|
909
|
-
}
|
|
910
|
-
return chain.chainId;
|
|
911
|
-
}
|
|
912
|
-
function getV1Name(chainId) {
|
|
913
|
-
return SUPPORTED_CHAINS[chainId]?.v1Name;
|
|
914
|
-
}
|
|
915
|
-
function getV1Names(chainId) {
|
|
916
|
-
const name = getV1Name(chainId);
|
|
917
|
-
return name ? [name] : [];
|
|
918
|
-
}
|
|
919
|
-
function isSupported(chainId) {
|
|
920
|
-
return chainId in SUPPORTED_CHAINS;
|
|
921
|
-
}
|
|
922
|
-
function getChainById(chainId) {
|
|
923
|
-
return SUPPORTED_CHAINS[chainId];
|
|
924
|
-
}
|
|
925
|
-
function getChain(network) {
|
|
926
|
-
const chainId = resolveChainId(network);
|
|
927
|
-
const chain = SUPPORTED_CHAINS[chainId];
|
|
928
|
-
if (!chain) {
|
|
929
|
-
throw new Error(
|
|
930
|
-
`Chain ${chainId} is not in the supported chains registry.`
|
|
931
|
-
);
|
|
932
|
-
}
|
|
933
|
-
return chain;
|
|
934
|
-
}
|
|
935
|
-
function getSupportedChains() {
|
|
936
|
-
return Object.values(SUPPORTED_CHAINS);
|
|
937
|
-
}
|
|
938
|
-
function getMainnets() {
|
|
939
|
-
return Object.values(SUPPORTED_CHAINS).filter((c) => !c.testnet);
|
|
940
|
-
}
|
|
941
|
-
function getTestnets() {
|
|
942
|
-
return Object.values(SUPPORTED_CHAINS).filter((c) => c.testnet);
|
|
943
|
-
}
|
|
944
|
-
|
|
945
962
|
// src/exact/client/schemes/erc4337.ts
|
|
946
963
|
function resolveChain(network) {
|
|
947
964
|
const chainId = resolveChainId(network);
|