@metamask/smart-accounts-kit 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +76 -64
  2. package/dist/actions/index.cjs +4 -4
  3. package/dist/actions/index.d.cts +3 -3
  4. package/dist/actions/index.d.ts +3 -3
  5. package/dist/actions/index.mjs +3 -3
  6. package/dist/{caveats-gqMBZKkI.d.cts → caveats-BEKgygS8.d.cts} +1 -1
  7. package/dist/{caveats-B2OssjV4.d.ts → caveats-DPuxVdYU.d.ts} +1 -1
  8. package/dist/{chunk-JKVSTPEC.cjs → chunk-32RDDE5N.cjs} +13 -13
  9. package/dist/{chunk-JKVSTPEC.cjs.map → chunk-32RDDE5N.cjs.map} +1 -1
  10. package/dist/{chunk-TNGQTVSY.mjs → chunk-3KWKQ7PV.mjs} +2 -2
  11. package/dist/{chunk-TNGQTVSY.mjs.map → chunk-3KWKQ7PV.mjs.map} +1 -1
  12. package/dist/{chunk-EPU4O7FY.cjs → chunk-4GOGI2TA.cjs} +106 -106
  13. package/dist/{chunk-EPU4O7FY.cjs.map → chunk-4GOGI2TA.cjs.map} +1 -1
  14. package/dist/{chunk-2ZOWIAP3.cjs → chunk-6TSLFRJC.cjs} +62 -62
  15. package/dist/{chunk-2ZOWIAP3.cjs.map → chunk-6TSLFRJC.cjs.map} +1 -1
  16. package/dist/{chunk-YVU66KSH.mjs → chunk-EMPAUTIV.mjs} +2 -2
  17. package/dist/{chunk-W6HPAK4M.cjs → chunk-GHGCGV3C.cjs} +2 -2
  18. package/dist/{chunk-W6HPAK4M.cjs.map → chunk-GHGCGV3C.cjs.map} +1 -1
  19. package/dist/{chunk-L3EZCIY6.mjs → chunk-IERUQUKJ.mjs} +4 -4
  20. package/dist/{chunk-DCI2AN4N.cjs → chunk-KIXYMA7J.cjs} +15 -15
  21. package/dist/{chunk-DCI2AN4N.cjs.map → chunk-KIXYMA7J.cjs.map} +1 -1
  22. package/dist/{chunk-UJQ3JN3U.mjs → chunk-T6SWQZRX.mjs} +3 -3
  23. package/dist/{chunk-AZYTTGON.mjs → chunk-XUBMIW33.mjs} +3 -3
  24. package/dist/{chunk-K7GTZGKJ.mjs → chunk-YCNLPEPH.mjs} +2 -2
  25. package/dist/{chunk-PQPAEHJZ.cjs → chunk-YPUEM6YV.cjs} +12 -12
  26. package/dist/{chunk-PQPAEHJZ.cjs.map → chunk-YPUEM6YV.cjs.map} +1 -1
  27. package/dist/contracts/index.cjs +5 -5
  28. package/dist/contracts/index.d.cts +4 -4
  29. package/dist/contracts/index.d.ts +4 -4
  30. package/dist/contracts/index.mjs +4 -4
  31. package/dist/{decodeRevertReason-CmmCpmZ_.d.cts → decodeRevertReason-CSOClzsa.d.cts} +3 -3
  32. package/dist/{decodeRevertReason-dOTpJx2h.d.ts → decodeRevertReason-WjHVQ_Sz.d.ts} +3 -3
  33. package/dist/experimental/index.cjs +66 -38
  34. package/dist/experimental/index.cjs.map +1 -1
  35. package/dist/experimental/index.d.cts +4 -2
  36. package/dist/experimental/index.d.ts +4 -2
  37. package/dist/experimental/index.mjs +50 -22
  38. package/dist/experimental/index.mjs.map +1 -1
  39. package/dist/{index-B1Cmezvh.d.cts → index-BHm75OFP.d.cts} +1 -1
  40. package/dist/{index-BkgdU4LI.d.ts → index-BNHYZ9iU.d.ts} +2 -2
  41. package/dist/{index-DUJmm8Wz.d.ts → index-CgGKjHSr.d.ts} +2 -2
  42. package/dist/{index-Dv4jPzhe.d.cts → index-CsjbdUp_.d.cts} +2 -2
  43. package/dist/{index-LqiEgBjV.d.ts → index-DWvEgBtg.d.ts} +1 -1
  44. package/dist/{index-X7Qn3JTg.d.cts → index-DYJjOeTn.d.cts} +2 -2
  45. package/dist/index.cjs +19 -19
  46. package/dist/index.d.cts +8 -8
  47. package/dist/index.d.ts +8 -8
  48. package/dist/index.mjs +6 -6
  49. package/dist/{resolveCaveats-A9xC29l8.d.ts → resolveCaveats-aQPEogPk.d.cts} +2 -2
  50. package/dist/{resolveCaveats-A9xC29l8.d.cts → resolveCaveats-aQPEogPk.d.ts} +2 -2
  51. package/dist/utils/index.cjs +4 -4
  52. package/dist/utils/index.d.cts +5 -5
  53. package/dist/utils/index.d.ts +5 -5
  54. package/dist/utils/index.mjs +3 -3
  55. package/package.json +8 -8
  56. /package/dist/{chunk-YVU66KSH.mjs.map → chunk-EMPAUTIV.mjs.map} +0 -0
  57. /package/dist/{chunk-L3EZCIY6.mjs.map → chunk-IERUQUKJ.mjs.map} +0 -0
  58. /package/dist/{chunk-UJQ3JN3U.mjs.map → chunk-T6SWQZRX.mjs.map} +0 -0
  59. /package/dist/{chunk-AZYTTGON.mjs.map → chunk-XUBMIW33.mjs.map} +0 -0
  60. /package/dist/{chunk-K7GTZGKJ.mjs.map → chunk-YCNLPEPH.mjs.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/experimental/delegationStorage.ts","../../src/experimental/x402DelegationProviderUtils.ts","../../src/experimental/x402DelegationProvider.ts"],"sourcesContent":["import { type Hex, toHex } from 'viem';\n\nimport { trackSmartAccountsKitFunctionCall } from '../analytics';\nimport { hashDelegation } from '../delegation';\nimport type { Delegation } from '../types';\n\ntype ErrorResponse = {\n error: string;\n data?: any;\n};\n\nexport type APIStoreDelegationResponse = {\n delegationHash: Hex;\n};\n\n/**\n * Represents the allowed filters when querying the data store for delegations.\n */\nexport enum DelegationStoreFilter {\n Given = 'GIVEN',\n Received = 'RECEIVED',\n All = 'ALL',\n}\n\n/**\n * Public Delegation Storage Service environments. To be used in the\n * DeleGationStorageService config.\n */\nexport const DelegationStorageEnvironment: {\n [K in 'dev' | 'prod']: Environment;\n} = {\n dev: { apiUrl: 'https://passkeys.dev-api.cx.metamask.io' },\n prod: { apiUrl: 'https://passkeys.api.cx.metamask.io' },\n};\n\n/**\n * Returns the DelegationStorageEnvironment ('dev' or 'prod') for a given apiUrl,\n * or 'custom' if the apiUrl does not match a known environment.\n *\n * @param apiUrl - The API URL to check.\n * @returns The environment key ('dev' or 'prod'), or 'custom'.\n */\nfunction getDelegationStorageEnvironment(\n apiUrl: string,\n): 'dev' | 'prod' | 'custom' {\n const matchingEnvironment = Object.entries(DelegationStorageEnvironment).find(\n ([_, env]) => env.apiUrl === apiUrl,\n ) as [keyof typeof DelegationStorageEnvironment, Environment] | undefined;\n\n return matchingEnvironment ? matchingEnvironment[0] : 'custom';\n}\n\nexport type Environment = {\n apiUrl: string;\n};\n\nexport type DelegationStorageConfig = {\n apiKey: string;\n apiKeyId: string;\n environment: Environment;\n fetcher?: typeof fetch;\n};\n\nexport class DelegationStorageClient {\n readonly #apiVersionPrefix = 'api/v0';\n\n readonly #config: DelegationStorageConfig;\n\n readonly #fetcher: typeof fetch;\n\n readonly #apiUrl: string;\n\n constructor(config: DelegationStorageConfig) {\n const { apiUrl } = config.environment;\n\n trackSmartAccountsKitFunctionCall(\n 'experimental.DelegationStorageClient.constructor',\n {\n environment: getDelegationStorageEnvironment(apiUrl),\n },\n );\n\n if (apiUrl.endsWith(this.#apiVersionPrefix)) {\n this.#apiUrl = apiUrl;\n } else {\n const separator = apiUrl.endsWith('/') ? '' : '/';\n this.#apiUrl = `${apiUrl}${separator}${this.#apiVersionPrefix}`;\n }\n this.#fetcher = this.#initializeFetcher(config);\n this.#config = config;\n }\n\n /**\n * Initializes the fetch function for HTTP requests.\n *\n * - Uses `config.fetcher` if provided.\n * - Falls back to global `fetch` if available.\n * - Throws an error if no fetch function is available.\n *\n * @param config - Configuration object that may include a custom fetch function.\n * @returns The fetch function to be used for HTTP requests.\n * @throws Error if no fetch function is available in the environment.\n */\n #initializeFetcher(config: DelegationStorageConfig): typeof fetch {\n if (config.fetcher) {\n return config.fetcher;\n } else if (typeof globalThis?.fetch === 'function') {\n return globalThis.fetch.bind(globalThis);\n }\n throw new Error(\n 'Fetch API is not available in this environment. Please provide a fetch function in the config.',\n );\n }\n\n /**\n * Fetches the delegation chain from the Delegation Storage Service, ending with\n * the specified leaf delegation.\n *\n * @param leafDelegationOrDelegationHash - The leaf delegation, or the hash\n * of the leaf delegation.\n * @returns A promise that resolves to the delegation chain - empty array if the delegation\n * is not found.\n */\n async getDelegationChain(\n leafDelegationOrDelegationHash: Hex | Delegation,\n ): Promise<Delegation[]> {\n trackSmartAccountsKitFunctionCall(\n 'experimental.DelegationStorageClient.getDelegationChain',\n {\n inputKind:\n typeof leafDelegationOrDelegationHash === 'string'\n ? 'hash'\n : 'delegation',\n },\n );\n const leafDelegationHash =\n typeof leafDelegationOrDelegationHash === 'string'\n ? leafDelegationOrDelegationHash\n : hashDelegation(leafDelegationOrDelegationHash);\n\n const response = await this.#fetcher(\n `${this.#apiUrl}/delegation/chain/${leafDelegationHash}`,\n {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n },\n },\n );\n\n const responseData: Delegation[] | ErrorResponse = await response.json();\n\n if ('error' in responseData) {\n throw new Error(\n `Failed to fetch delegation chain: ${responseData.error}`,\n );\n }\n\n return responseData;\n }\n\n /**\n * Fetches the delegations from the Delegation Storage Service, either `Received`\n * by, or `Given` by, (or both: `All`) the specified deleGatorAddress. Defaults\n * to `Received`.\n *\n * @param deleGatorAddress - The deleGatorAddress to retrieve the delegations for.\n * @param filterMode - The DelegationStoreFilter mode - defaults to Received.\n * @returns A promise that resolves to the list of delegations received by the deleGatorAddress,\n * empty array if the delegations are not found.\n */\n async fetchDelegations(\n deleGatorAddress: Hex,\n filterMode = DelegationStoreFilter.Received,\n ): Promise<Delegation[]> {\n trackSmartAccountsKitFunctionCall(\n 'experimental.DelegationStorageClient.fetchDelegations',\n { filterMode },\n );\n const response = await this.#fetcher(\n `${this.#apiUrl}/delegation/accounts/${deleGatorAddress}?filter=${filterMode}`,\n {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n },\n },\n );\n\n const responseData: Delegation[] | ErrorResponse = await response.json();\n\n if ('error' in responseData) {\n throw new Error(`Failed to fetch delegations: ${responseData.error}`);\n }\n\n return responseData;\n }\n\n /**\n * Stores the specified delegation in the Delegation Storage Service.\n *\n * @param delegation - The delegation to store.\n * @returns A promise that resolves to the delegation hash indicating successful storage.\n */\n async storeDelegation(delegation: Delegation): Promise<Hex> {\n trackSmartAccountsKitFunctionCall(\n 'experimental.DelegationStorageClient.storeDelegation',\n { caveatCount: delegation.caveats.length },\n );\n if (!delegation.signature || delegation.signature === '0x') {\n throw new Error('Delegation must be signed to be stored');\n }\n\n const delegationHash = hashDelegation(delegation);\n\n const body = JSON.stringify(\n {\n ...delegation,\n metadata: [],\n },\n (_, value: any) =>\n typeof value === 'bigint' || typeof value === 'number'\n ? toHex(value)\n : value,\n 2,\n );\n\n const response = await this.#fetcher(`${this.#apiUrl}/delegation/store`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n 'Content-Type': 'application/json',\n },\n body,\n });\n\n const responseData: APIStoreDelegationResponse | ErrorResponse =\n await response.json();\n\n if ('error' in responseData) {\n throw new Error(responseData.error);\n }\n\n if (responseData.delegationHash !== delegationHash) {\n throw new Error(\n 'Failed to store the Delegation, the hash returned from the MM delegation storage API does not match the hash of the delegation',\n );\n }\n\n return responseData.delegationHash;\n }\n}\n","import {\n createAllowedCalldataTerms,\n createRedeemerTerms,\n createTimestampTerms,\n decodeRedeemerTerms,\n decodeTimestampTerms,\n} from '@metamask/delegation-core';\nimport { parseCaipChainId } from '@metamask/utils';\nimport { pad, type Account, type Address, type Hex } from 'viem';\n\nimport type { Caveats } from '../caveatBuilder';\nimport { resolveCaveats } from '../caveatBuilder';\nimport { ScopeType } from '../constants';\nimport type { createOpenDelegation } from '../delegation';\nimport { decodeDelegations } from '../delegation';\nimport { getSmartAccountsEnvironment } from '../smartAccountsEnvironment';\nimport type {\n Caveat,\n Delegation,\n PermissionContext,\n SmartAccountsEnvironment,\n} from '../types';\nimport type {\n MaybeDeferred,\n PaymentRequirements,\n x402DelegationProviderConfig,\n} from './x402DelegationProviderTypes';\nimport { generateSalt } from '../utils/';\n\n/**\n * Inputs for redeemer constraint enforcement.\n */\ntype EnsureRedeemerSufficientlyConstrainedParams = {\n redeemerEnforcer: Hex;\n caveats: Caveat[];\n existingDelegations: Delegation[];\n redeemerAddresses: Hex[];\n requireRedeemers: boolean;\n};\n\n/**\n * Inputs for payee constraint enforcement.\n */\ntype EnsurePayeeSufficientlyConstrainedParams = {\n allowedCalldataEnforcer: Hex;\n caveats: Caveat[];\n existingDelegations: Delegation[];\n payee: Hex;\n};\n\n/**\n * Inputs for expiry constraint enforcement.\n */\ntype EnsureExpirySufficientlyConstrainedParams = {\n timestampEnforcer: Hex;\n caveats: Caveat[];\n existingDelegations: Delegation[];\n expirySeconds: number;\n};\n\n/**\n * Resolved context required to build and sign an x402 delegation.\n */\nexport type DelegationCreationContext = {\n account: Account;\n createDelegationConfig: Parameters<typeof createOpenDelegation>[0];\n delegationManager: Address;\n existingDelegations: Delegation[];\n rootDelegator: Address;\n};\n\n/**\n * Inputs for resolving delegation caveats with x402-specific constraints.\n */\nexport type Resolvex402DelegationCaveatsParams = {\n environment: SmartAccountsEnvironment;\n caveatsConfig: Caveats | undefined;\n existingDelegations: Delegation[];\n facilitatorAddresses: Hex[] | undefined;\n payee: Hex;\n expirySeconds?: number;\n requireRedeemers: boolean;\n redeemerAddresses: Address[] | undefined;\n};\n\n/**\n * Resolves eager or deferred values against payment requirements.\n *\n * @param maybeDeferred - Value or async resolver function.\n * @param requirements - Payment requirements passed to deferred resolvers.\n * @returns The resolved value, or undefined when no value is provided.\n */\nasync function resolveMaybeDeferred<TResult>(\n maybeDeferred: MaybeDeferred<TResult>,\n requirements: PaymentRequirements,\n): Promise<TResult> {\n if (typeof maybeDeferred === 'function') {\n const deferred = maybeDeferred as (\n deferredRequirements: PaymentRequirements,\n ) => Promise<TResult> | TResult;\n\n return await deferred(requirements);\n }\n\n return maybeDeferred;\n}\n\n/**\n * Parses an EIP-155 CAIP network identifier into a numeric chain ID.\n *\n * @param network - CAIP network identifier (for example, `eip155:1`).\n * @returns Parsed numeric chain ID.\n * @throws If the CAIP namespace is not `eip155`.\n */\nexport function parseEip155ChainId(\n network: PaymentRequirements['network'],\n): number {\n const { namespace, reference } = parseCaipChainId(\n network as `${string}:${string}`,\n );\n\n if (namespace !== 'eip155') {\n throw new Error('Unsupported chain namespace');\n }\n\n const parsedChainId = Number(reference);\n\n if (isNaN(parsedChainId)) {\n throw new Error('Invalid chain id');\n }\n\n return parsedChainId;\n}\n\n/**\n * ERC-20 `transfer(address to, uint256 value)` calldata index for `to`.\n */\nconst TRANSFER_PAYEE_INDEX = 4;\n\n/**\n * Normalizes an address-like hex string for case-insensitive comparisons.\n *\n * @param address - Address value to normalize.\n * @returns Lowercased hex string.\n */\nconst normalizeAddress = (address: Address): Address =>\n address.toLowerCase() as Address;\n\n/**\n * Returns whether any caveat in local or inherited delegations matches a predicate.\n *\n * @param caveats - Current caveat list.\n * @param delegations - Existing delegations whose caveats should also be searched.\n * @param match - Predicate used to match caveats.\n * @returns True when at least one caveat satisfies `match`.\n */\nconst hasMatchingCaveats = (\n caveats: Caveat[],\n delegations: Delegation[],\n match: (caveat: Caveat) => boolean,\n): boolean => {\n for (const caveat of caveats) {\n if (match(caveat)) {\n return true;\n }\n }\n\n for (const delegation of delegations) {\n for (const caveat of delegation.caveats) {\n if (match(caveat)) {\n return true;\n }\n }\n }\n\n return false;\n};\n\n/**\n * Ensures caveats include an expiry timestamp constraint when requested.\n *\n * If an existing timestamp caveat already enforces a tighter (earlier) or equal\n * `validBefore` threshold than requested, caveats are returned unchanged.\n * Otherwise a new timestamp caveat is appended with `afterThreshold = 0`.\n *\n * @param options0 - Expiry constraint evaluation inputs.\n * @param options0.timestampEnforcer - Address of the TimestampEnforcer caveat contract.\n * @param options0.caveats - Currently resolved caveats for the delegation being created.\n * @param options0.existingDelegations - Existing parent-chain delegations to inspect for inherited constraints.\n * @param options0.expirySeconds - Relative expiry from \"now\" in seconds.\n * @returns The original caveats when sufficiently constrained, otherwise caveats with a timestamp caveat appended.\n */\nexport const ensureExpirySufficientlyConstrained = ({\n timestampEnforcer,\n caveats,\n existingDelegations,\n expirySeconds,\n}: EnsureExpirySufficientlyConstrainedParams): Caveat[] => {\n if (expirySeconds < 0) {\n throw new Error('Expiry seconds must be a positive number');\n }\n const beforeThreshold = Math.floor(Date.now() / 1000) + expirySeconds;\n const timestampEnforcerNormalized = normalizeAddress(timestampEnforcer);\n\n const hasSupersedingTimestampConstraint = hasMatchingCaveats(\n caveats,\n existingDelegations,\n (caveat) => {\n if (normalizeAddress(caveat.enforcer) !== timestampEnforcerNormalized) {\n return false;\n }\n\n const { beforeThreshold: existingBeforeThreshold } = decodeTimestampTerms(\n caveat.terms,\n );\n return (\n existingBeforeThreshold !== 0 &&\n existingBeforeThreshold <= beforeThreshold\n );\n },\n );\n\n if (hasSupersedingTimestampConstraint) {\n return caveats;\n }\n\n const timestampCaveat: Caveat = {\n enforcer: timestampEnforcer,\n terms: createTimestampTerms({\n afterThreshold: 0,\n beforeThreshold,\n }),\n args: '0x',\n };\n\n return [...caveats, timestampCaveat];\n};\n\n/**\n * Ensures caveats include a sufficiently strict redeemer constraint.\n *\n * Returns the caveat list unchanged when an existing redeemer caveat is already\n * strict enough, or appends a new redeemer caveat scoped to facilitator addresses.\n *\n * @param options0 - Redeemer constraint evaluation inputs.\n * @param options0.redeemerEnforcer - Address of the redeemer enforcer caveat contract.\n * @param options0.caveats - Currently resolved caveats for the delegation being created.\n * @param options0.existingDelegations - Existing parent-chain delegations to inspect for inherited constraints.\n * @param options0.redeemerAddresses - Optional addresses to which redemption should be constrained.\n * @param options0.requireRedeemers - Whether at least one redeemer constraint must exist when no redeemer addresses are supplied.\n * @returns The original caveats when sufficiently constrained, otherwise caveats with a redeemer caveat appended.\n * @throws If no facilitator addresses are provided and no redeemer constraint exists.\n */\nexport const ensureRedeemerSufficientlyConstrained = ({\n redeemerEnforcer,\n caveats,\n existingDelegations,\n redeemerAddresses,\n requireRedeemers,\n}: EnsureRedeemerSufficientlyConstrainedParams): Caveat[] => {\n const redeemerAddressNormalized = normalizeAddress(redeemerEnforcer);\n\n if (redeemerAddresses.length === 0) {\n if (!requireRedeemers) {\n return caveats;\n }\n\n const hasExistingRedeemerCaveat = hasMatchingCaveats(\n caveats,\n existingDelegations,\n ({ enforcer }) =>\n normalizeAddress(enforcer) === redeemerAddressNormalized,\n );\n\n if (!hasExistingRedeemerCaveat) {\n throw new Error(\n 'Redeemer must be constrained, either in the specified `caveats`, `parentPermissionContext`, or the `PaymentRequirements` as `extra.facilitatorAddresses`.',\n );\n }\n\n return caveats;\n }\n\n const redeemerAddressesNormalized = redeemerAddresses.map(normalizeAddress);\n const redeemerAddressesSet = new Set(redeemerAddressesNormalized);\n\n const hasSupersedingRedeemerCaveat = hasMatchingCaveats(\n caveats,\n existingDelegations,\n (caveat) => {\n if (normalizeAddress(caveat.enforcer) !== redeemerAddressNormalized) {\n return false;\n }\n\n const allowedRedeemerAddresses = decodeRedeemerTerms(\n caveat.terms,\n ).redeemers.map(normalizeAddress);\n\n // If this redeemer caveat only allows facilitator addresses, it is sufficiently constrained.\n return allowedRedeemerAddresses.every((item) =>\n redeemerAddressesSet.has(item),\n );\n },\n );\n\n if (hasSupersedingRedeemerCaveat) {\n return caveats;\n }\n\n const redeemerCaveat: Caveat = {\n enforcer: redeemerEnforcer,\n terms: createRedeemerTerms({ redeemers: redeemerAddresses }),\n args: '0x',\n };\n\n return [...caveats, redeemerCaveat];\n};\n\n/**\n * Ensures caveats include an allowed-calldata constraint for the payment payee.\n *\n * Scans both the in-progress caveat list and parent delegation caveats for an\n * `AllowedCalldataEnforcer` caveat whose terms match the encoded payee calldata\n * constraint. If found, returns caveats unchanged; otherwise appends a payee caveat.\n *\n * @param options0 - Payee constraint evaluation inputs.\n * @param options0.allowedCalldataEnforcer - Address of the AllowedCalldataEnforcer caveat contract.\n * @param options0.caveats - Currently resolved caveats for the delegation being created.\n * @param options0.existingDelegations - Existing parent-chain delegations to inspect for inherited constraints.\n * @param options0.payee - Expected ERC-20 transfer recipient to enforce in calldata.\n * @returns The original caveats when an equivalent payee constraint exists, otherwise caveats with a payee caveat appended.\n */\nexport const ensurePayeeSufficientlyConstrained = ({\n allowedCalldataEnforcer,\n caveats,\n existingDelegations,\n payee,\n}: EnsurePayeeSufficientlyConstrainedParams): Caveat[] => {\n const allowedCalldataTerms = createAllowedCalldataTerms({\n startIndex: TRANSFER_PAYEE_INDEX,\n value: pad(payee, { size: 32 }),\n });\n\n const allowedCalldataEnforcerNormalized = normalizeAddress(\n allowedCalldataEnforcer,\n );\n\n const lowercaseCalldataTerms = allowedCalldataTerms.toLowerCase();\n\n const hasSupersedingAllowedCalldataConstraint = hasMatchingCaveats(\n caveats,\n existingDelegations,\n ({ enforcer, terms }) =>\n normalizeAddress(enforcer) === allowedCalldataEnforcerNormalized &&\n terms.toLowerCase() === lowercaseCalldataTerms,\n );\n\n if (hasSupersedingAllowedCalldataConstraint) {\n return caveats;\n }\n\n const payeeCaveat: Caveat = {\n enforcer: allowedCalldataEnforcer,\n terms: allowedCalldataTerms,\n args: '0x',\n };\n\n return [...caveats, payeeCaveat];\n};\n\n/**\n * Resolves caveats and applies x402-specific redeemer and payee constraints.\n *\n * @param options0 - Caveat resolution inputs.\n * @param options0.environment - Environment containing caveat enforcer addresses.\n * @param options0.caveatsConfig - Optional caveat builder config.\n * @param options0.existingDelegations - Existing parent-chain delegations.\n * @param options0.facilitatorAddresses - Optional facilitator addresses used for redeemer constraints.\n * @param options0.payee - Payee address used for allowed calldata constraints.\n * @param options0.expirySeconds - Optional relative expiry in seconds for adding timestamp constraints.\n * @param options0.requireRedeemers - Whether redeemer constraints are mandatory when no facilitator or configured redeemer addresses are present.\n * @param options0.redeemerAddresses - Optional redeemer addresses from provider config to merge with facilitator addresses.\n * @returns Caveats after redeemer and payee constraints are enforced.\n */\nexport const resolvex402DelegationCaveats = ({\n environment,\n caveatsConfig,\n existingDelegations,\n facilitatorAddresses,\n payee,\n expirySeconds,\n requireRedeemers,\n redeemerAddresses,\n}: Resolvex402DelegationCaveatsParams): Caveat[] => {\n const {\n caveatEnforcers: {\n RedeemerEnforcer: redeemerEnforcer,\n AllowedCalldataEnforcer: allowedCalldataEnforcer,\n TimestampEnforcer: timestampEnforcer,\n },\n } = environment;\n\n if (!redeemerEnforcer) {\n throw new Error('RedeemerEnforcer not found in environment');\n }\n\n if (!allowedCalldataEnforcer) {\n throw new Error('AllowedCalldataEnforcer not found in environment');\n }\n\n if (!timestampEnforcer) {\n throw new Error('TimestampEnforcer not found in environment');\n }\n\n const initialCaveats = resolveCaveats({\n environment,\n caveats: caveatsConfig,\n // Resolve caveats first so downstream constraint checks can append as needed.\n // Scope is still attached later during delegation creation.\n isScopeOptional: true,\n });\n\n const allRedeemerAddresses = new Set(\n [...(facilitatorAddresses ?? []), ...(redeemerAddresses ?? [])].map(\n normalizeAddress,\n ),\n );\n\n const caveatsWithRedeemer = ensureRedeemerSufficientlyConstrained({\n redeemerEnforcer,\n caveats: initialCaveats,\n existingDelegations,\n redeemerAddresses: Array.from(allRedeemerAddresses),\n requireRedeemers,\n });\n\n const caveatsWithPayee = ensurePayeeSufficientlyConstrained({\n allowedCalldataEnforcer,\n caveats: caveatsWithRedeemer,\n existingDelegations,\n payee,\n });\n\n if (expirySeconds === undefined) {\n return caveatsWithPayee;\n }\n\n return ensureExpirySufficientlyConstrained({\n timestampEnforcer,\n caveats: caveatsWithPayee,\n existingDelegations,\n expirySeconds,\n });\n};\n\n/**\n * Builds the delegation creation context from provider config and requirements.\n *\n * @param config - Delegation provider config for context construction.\n * @param requirements - Payment requirements used to scope caveats.\n * @returns The resolved context used to create and sign a delegation.\n */\nexport const resolveDelegationCreationContext = async (\n config: x402DelegationProviderConfig,\n requirements: PaymentRequirements,\n): Promise<DelegationCreationContext> => {\n const account = await resolveMaybeDeferred(config.account, requirements);\n const redeemersConfig = await resolveMaybeDeferred(\n config.redeemers,\n requirements,\n );\n\n const requireRedeemers = redeemersConfig?.requireRedeemers ?? false;\n const redeemerAddresses = await resolveMaybeDeferred(\n redeemersConfig?.addresses,\n requirements,\n );\n\n const specifiedEnvironment = await resolveMaybeDeferred(\n config.environment,\n requirements,\n );\n const environment =\n specifiedEnvironment ??\n getSmartAccountsEnvironment(parseEip155ChainId(requirements.network));\n\n const caveatsConfig: Caveats | undefined = await resolveMaybeDeferred(\n config.caveats,\n requirements,\n );\n const parentPermissionContext: PermissionContext | undefined =\n await resolveMaybeDeferred(config.parentPermissionContext, requirements);\n const expirySeconds = await resolveMaybeDeferred(\n config.expirySeconds,\n requirements,\n );\n\n const from =\n (await resolveMaybeDeferred(config.from, requirements)) ?? account.address;\n const salt =\n (await resolveMaybeDeferred(config.salt, requirements)) ?? generateSalt();\n\n const scope = {\n type: ScopeType.Erc20TransferAmount,\n tokenAddress: requirements.asset as Hex,\n maxAmount: BigInt(requirements.amount),\n } as const;\n\n const facilitatorAddresses = requirements.extra?.facilitatorAddresses as\n | Hex[]\n | undefined;\n\n const existingDelegations = parentPermissionContext\n ? decodeDelegations(parentPermissionContext)\n : [];\n\n const { DelegationManager: delegationManager } = environment;\n const caveats = resolvex402DelegationCaveats({\n environment,\n caveatsConfig,\n existingDelegations,\n facilitatorAddresses,\n payee: requirements.payTo as Hex,\n expirySeconds,\n requireRedeemers,\n redeemerAddresses,\n });\n\n let createDelegationConfig: Parameters<typeof createOpenDelegation>[0];\n\n if (parentPermissionContext) {\n const parentDelegation = existingDelegations[0];\n\n if (!parentDelegation) {\n throw new Error('Parent permission context is not a valid delegation');\n }\n\n createDelegationConfig = {\n environment,\n from,\n caveats,\n salt,\n scope,\n parentDelegation,\n };\n } else {\n createDelegationConfig = {\n environment,\n from,\n caveats,\n salt,\n scope,\n };\n }\n\n const rootDelegator =\n existingDelegations[existingDelegations.length - 1]?.delegator ?? from;\n\n return {\n account,\n createDelegationConfig,\n delegationManager,\n existingDelegations,\n rootDelegator,\n };\n};\n","import {\n createOpenDelegation,\n encodeDelegations,\n prepareSignDelegationTypedData,\n} from '../delegation';\nimport type {\n PaymentRequirements,\n x402DelegationProvider,\n x402DelegationProviderConfig,\n x402DelegationProviderPaymentPayload,\n} from './x402DelegationProviderTypes';\nimport {\n parseEip155ChainId,\n resolveDelegationCreationContext,\n} from './x402DelegationProviderUtils';\n\nexport type {\n MaybeDeferred,\n PaymentRequirements,\n x402DelegationProvider,\n x402DelegationProviderConfig,\n x402DelegationProviderPaymentPayload,\n} from './x402DelegationProviderTypes';\n\nexport { parseEip155ChainId } from './x402DelegationProviderUtils';\n\n/**\n * Creates a delegation provider function for x402 payment requirements.\n *\n * The returned provider resolves deferred config values using incoming payment\n * requirements, creates an open delegation, signs it, and returns an encoded\n * permission context payload.\n *\n * @param config - Delegation creation and signing configuration.\n * @returns A provider that maps payment requirements to a signed delegation payload.\n */\nexport function createx402DelegationProvider(\n config: x402DelegationProviderConfig,\n): x402DelegationProvider {\n return async (\n requirements: PaymentRequirements,\n ): Promise<x402DelegationProviderPaymentPayload> => {\n const {\n account,\n createDelegationConfig,\n delegationManager,\n existingDelegations,\n rootDelegator,\n } = await resolveDelegationCreationContext(config, requirements);\n\n const delegation = createOpenDelegation(createDelegationConfig);\n\n const chainId = parseEip155ChainId(requirements.network);\n\n const typedData = prepareSignDelegationTypedData({\n delegationManager,\n chainId,\n delegation,\n });\n\n if (!account.signTypedData) {\n throw new Error('Account does not support signTypedData');\n }\n\n const signature = await account.signTypedData(typedData);\n\n const signedDelegation = {\n ...delegation,\n signature,\n };\n\n const permissionContext = encodeDelegations([\n signedDelegation,\n ...existingDelegations,\n ]);\n\n return {\n delegationManager,\n permissionContext,\n delegator: rootDelegator,\n };\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,SAAmB,aAAa;AA4BzB,IAAM,+BAET;AAAA,EACF,KAAK,EAAE,QAAQ,0CAA0C;AAAA,EACzD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AAI,CAAC,kBAAkB;AACrB,YAAM,IAAI,MAAM,qDAAqD;AAAA,IACvE;AAEA,6BAAyB;AAAA,MACvB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF,OAAO;AACL,6BAAyB;AAAA,MACvB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,QAAM,gBACJ,oBAAoB,oBAAoB,SAAS,CAAC,GAAG,aAAa;AAEpE,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;;;ACjhBO,SAAS,6BACd,QACwB;AACxB,SAAO,OACL,iBACkD;AAClD,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,IAAI,MAAM,iCAAiC,QAAQ,YAAY;AAE/D,UAAM,aAAa,qBAAqB,sBAAsB;AAE9D,UAAM,UAAU,mBAAmB,aAAa,OAAO;AAEvD,UAAM,YAAY,+BAA+B;AAAA,MAC/C;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,QAAI,CAAC,QAAQ,eAAe;AAC1B,YAAM,IAAI,MAAM,wCAAwC;AAAA,IAC1D;AAEA,UAAM,YAAY,MAAM,QAAQ,cAAc,SAAS;AAEvD,UAAM,mBAAmB;AAAA,MACvB,GAAG;AAAA,MACH;AAAA,IACF;AAEA,UAAM,oBAAoB,kBAAkB;AAAA,MAC1C;AAAA,MACA,GAAG;AAAA,IACL,CAAC;AAED,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA,WAAW;AAAA,IACb;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/experimental/delegationStorage.ts","../../src/experimental/x402DelegationProviderUtils.ts","../../src/experimental/x402DelegationProvider.ts"],"sourcesContent":["import { type Hex, toHex } from 'viem';\n\nimport { trackSmartAccountsKitFunctionCall } from '../analytics';\nimport { hashDelegation } from '../delegation';\nimport type { Delegation } from '../types';\n\ntype ErrorResponse = {\n error: string;\n data?: any;\n};\n\nexport type APIStoreDelegationResponse = {\n delegationHash: Hex;\n};\n\n/**\n * Represents the allowed filters when querying the data store for delegations.\n */\nexport enum DelegationStoreFilter {\n Given = 'GIVEN',\n Received = 'RECEIVED',\n All = 'ALL',\n}\n\n/**\n * Public Delegation Storage Service environments. To be used in the\n * DeleGationStorageService config.\n */\nexport const DelegationStorageEnvironment: {\n [K in 'dev' | 'prod']: Environment;\n} = {\n dev: { apiUrl: 'https://passkeys.dev-api.cx.metamask.io' },\n prod: { apiUrl: 'https://passkeys.api.cx.metamask.io' },\n};\n\n/**\n * Returns the DelegationStorageEnvironment ('dev' or 'prod') for a given apiUrl,\n * or 'custom' if the apiUrl does not match a known environment.\n *\n * @param apiUrl - The API URL to check.\n * @returns The environment key ('dev' or 'prod'), or 'custom'.\n */\nfunction getDelegationStorageEnvironment(\n apiUrl: string,\n): 'dev' | 'prod' | 'custom' {\n const matchingEnvironment = Object.entries(DelegationStorageEnvironment).find(\n ([_, env]) => env.apiUrl === apiUrl,\n ) as [keyof typeof DelegationStorageEnvironment, Environment] | undefined;\n\n return matchingEnvironment ? matchingEnvironment[0] : 'custom';\n}\n\nexport type Environment = {\n apiUrl: string;\n};\n\nexport type DelegationStorageConfig = {\n apiKey: string;\n apiKeyId: string;\n environment: Environment;\n fetcher?: typeof fetch;\n};\n\nexport class DelegationStorageClient {\n readonly #apiVersionPrefix = 'api/v0';\n\n readonly #config: DelegationStorageConfig;\n\n readonly #fetcher: typeof fetch;\n\n readonly #apiUrl: string;\n\n constructor(config: DelegationStorageConfig) {\n const { apiUrl } = config.environment;\n\n trackSmartAccountsKitFunctionCall(\n 'experimental.DelegationStorageClient.constructor',\n {\n environment: getDelegationStorageEnvironment(apiUrl),\n },\n );\n\n if (apiUrl.endsWith(this.#apiVersionPrefix)) {\n this.#apiUrl = apiUrl;\n } else {\n const separator = apiUrl.endsWith('/') ? '' : '/';\n this.#apiUrl = `${apiUrl}${separator}${this.#apiVersionPrefix}`;\n }\n this.#fetcher = this.#initializeFetcher(config);\n this.#config = config;\n }\n\n /**\n * Initializes the fetch function for HTTP requests.\n *\n * - Uses `config.fetcher` if provided.\n * - Falls back to global `fetch` if available.\n * - Throws an error if no fetch function is available.\n *\n * @param config - Configuration object that may include a custom fetch function.\n * @returns The fetch function to be used for HTTP requests.\n * @throws Error if no fetch function is available in the environment.\n */\n #initializeFetcher(config: DelegationStorageConfig): typeof fetch {\n if (config.fetcher) {\n return config.fetcher;\n } else if (typeof globalThis?.fetch === 'function') {\n return globalThis.fetch.bind(globalThis);\n }\n throw new Error(\n 'Fetch API is not available in this environment. Please provide a fetch function in the config.',\n );\n }\n\n /**\n * Fetches the delegation chain from the Delegation Storage Service, ending with\n * the specified leaf delegation.\n *\n * @param leafDelegationOrDelegationHash - The leaf delegation, or the hash\n * of the leaf delegation.\n * @returns A promise that resolves to the delegation chain - empty array if the delegation\n * is not found.\n */\n async getDelegationChain(\n leafDelegationOrDelegationHash: Hex | Delegation,\n ): Promise<Delegation[]> {\n trackSmartAccountsKitFunctionCall(\n 'experimental.DelegationStorageClient.getDelegationChain',\n {\n inputKind:\n typeof leafDelegationOrDelegationHash === 'string'\n ? 'hash'\n : 'delegation',\n },\n );\n const leafDelegationHash =\n typeof leafDelegationOrDelegationHash === 'string'\n ? leafDelegationOrDelegationHash\n : hashDelegation(leafDelegationOrDelegationHash);\n\n const response = await this.#fetcher(\n `${this.#apiUrl}/delegation/chain/${leafDelegationHash}`,\n {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n },\n },\n );\n\n const responseData: Delegation[] | ErrorResponse = await response.json();\n\n if ('error' in responseData) {\n throw new Error(\n `Failed to fetch delegation chain: ${responseData.error}`,\n );\n }\n\n return responseData;\n }\n\n /**\n * Fetches the delegations from the Delegation Storage Service, either `Received`\n * by, or `Given` by, (or both: `All`) the specified deleGatorAddress. Defaults\n * to `Received`.\n *\n * @param deleGatorAddress - The deleGatorAddress to retrieve the delegations for.\n * @param filterMode - The DelegationStoreFilter mode - defaults to Received.\n * @returns A promise that resolves to the list of delegations received by the deleGatorAddress,\n * empty array if the delegations are not found.\n */\n async fetchDelegations(\n deleGatorAddress: Hex,\n filterMode = DelegationStoreFilter.Received,\n ): Promise<Delegation[]> {\n trackSmartAccountsKitFunctionCall(\n 'experimental.DelegationStorageClient.fetchDelegations',\n { filterMode },\n );\n const response = await this.#fetcher(\n `${this.#apiUrl}/delegation/accounts/${deleGatorAddress}?filter=${filterMode}`,\n {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n },\n },\n );\n\n const responseData: Delegation[] | ErrorResponse = await response.json();\n\n if ('error' in responseData) {\n throw new Error(`Failed to fetch delegations: ${responseData.error}`);\n }\n\n return responseData;\n }\n\n /**\n * Stores the specified delegation in the Delegation Storage Service.\n *\n * @param delegation - The delegation to store.\n * @returns A promise that resolves to the delegation hash indicating successful storage.\n */\n async storeDelegation(delegation: Delegation): Promise<Hex> {\n trackSmartAccountsKitFunctionCall(\n 'experimental.DelegationStorageClient.storeDelegation',\n { caveatCount: delegation.caveats.length },\n );\n if (!delegation.signature || delegation.signature === '0x') {\n throw new Error('Delegation must be signed to be stored');\n }\n\n const delegationHash = hashDelegation(delegation);\n\n const body = JSON.stringify(\n {\n ...delegation,\n metadata: [],\n },\n (_, value: any) =>\n typeof value === 'bigint' || typeof value === 'number'\n ? toHex(value)\n : value,\n 2,\n );\n\n const response = await this.#fetcher(`${this.#apiUrl}/delegation/store`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n 'Content-Type': 'application/json',\n },\n body,\n });\n\n const responseData: APIStoreDelegationResponse | ErrorResponse =\n await response.json();\n\n if ('error' in responseData) {\n throw new Error(responseData.error);\n }\n\n if (responseData.delegationHash !== delegationHash) {\n throw new Error(\n 'Failed to store the Delegation, the hash returned from the MM delegation storage API does not match the hash of the delegation',\n );\n }\n\n return responseData.delegationHash;\n }\n}\n","import {\n createAllowedCalldataTerms,\n createRedeemerTerms,\n createTimestampTerms,\n decodeRedeemerTerms,\n decodeTimestampTerms,\n} from '@metamask/delegation-core';\nimport { parseCaipChainId } from '@metamask/utils';\nimport { pad, type Account, type Address, type Hex } from 'viem';\n\nimport type { Caveats } from '../caveatBuilder';\nimport { resolveCaveats } from '../caveatBuilder';\nimport { ScopeType } from '../constants';\nimport type { createOpenDelegation } from '../delegation';\nimport { decodeDelegations } from '../delegation';\nimport { getSmartAccountsEnvironment } from '../smartAccountsEnvironment';\nimport type {\n Caveat,\n Delegation,\n PermissionContext,\n SmartAccountsEnvironment,\n} from '../types';\nimport type {\n MaybeDeferred,\n PaymentRequirements,\n x402DelegationProviderConfig,\n} from './x402DelegationProviderTypes';\nimport { generateSalt } from '../utils/';\n\n/**\n * Inputs for redeemer constraint enforcement.\n */\ntype EnsureRedeemerSufficientlyConstrainedParams = {\n redeemerEnforcer: Hex;\n caveats: Caveat[];\n existingDelegations: Delegation[];\n facilitatorAddresses: Address[] | undefined;\n redeemerAddresses: Address[] | undefined;\n requireRedeemers: boolean;\n};\n\n/**\n * Inputs for payee constraint enforcement.\n */\ntype EnsurePayeeSufficientlyConstrainedParams = {\n allowedCalldataEnforcer: Hex;\n caveats: Caveat[];\n existingDelegations: Delegation[];\n payee: Hex;\n};\n\n/**\n * Inputs for expiry constraint enforcement.\n */\ntype EnsureExpirySufficientlyConstrainedParams = {\n timestampEnforcer: Hex;\n caveats: Caveat[];\n existingDelegations: Delegation[];\n expirySeconds: number;\n};\n\n/**\n * Inputs for resolving allowed redeemer addresses.\n */\ntype ResolveRedeemerAddressesParams = Pick<\n EnsureRedeemerSufficientlyConstrainedParams,\n 'facilitatorAddresses' | 'redeemerAddresses'\n>;\n\n/**\n * Resolved context required to build and sign an x402 delegation.\n */\nexport type DelegationCreationContext = {\n account: Account;\n createDelegationConfig: Parameters<typeof createOpenDelegation>[0];\n delegationManager: Address;\n existingDelegations: Delegation[];\n rootDelegator: Address;\n};\n\n/**\n * Inputs for resolving delegation caveats with x402-specific constraints.\n */\nexport type Resolvex402DelegationCaveatsParams = {\n environment: SmartAccountsEnvironment;\n caveatsConfig: Caveats | undefined;\n existingDelegations: Delegation[];\n facilitatorAddresses: Hex[] | undefined;\n payee: Hex;\n expirySeconds?: number;\n requireRedeemers: boolean;\n redeemerAddresses: Address[] | undefined;\n};\n\n/**\n * Resolves eager or deferred values against payment requirements.\n *\n * @param maybeDeferred - Value or async resolver function.\n * @param requirements - Payment requirements passed to deferred resolvers.\n * @returns The resolved value, or undefined when no value is provided.\n */\nasync function resolveMaybeDeferred<TResult>(\n maybeDeferred: MaybeDeferred<TResult>,\n requirements: PaymentRequirements,\n): Promise<TResult> {\n if (typeof maybeDeferred === 'function') {\n const deferred = maybeDeferred as (\n deferredRequirements: PaymentRequirements,\n ) => Promise<TResult> | TResult;\n\n return await deferred(requirements);\n }\n\n return maybeDeferred;\n}\n\n/**\n * Parses an EIP-155 CAIP network identifier into a numeric chain ID.\n *\n * @param network - CAIP network identifier (for example, `eip155:1`).\n * @returns Parsed numeric chain ID.\n * @throws If the CAIP namespace is not `eip155`.\n */\nexport function parseEip155ChainId(\n network: PaymentRequirements['network'],\n): number {\n const { namespace, reference } = parseCaipChainId(\n network as `${string}:${string}`,\n );\n\n if (namespace !== 'eip155') {\n throw new Error('Unsupported chain namespace');\n }\n\n const parsedChainId = Number(reference);\n\n if (isNaN(parsedChainId)) {\n throw new Error('Invalid chain id');\n }\n\n return parsedChainId;\n}\n\n/**\n * ERC-20 `transfer(address to, uint256 value)` calldata index for `to`.\n */\nconst TRANSFER_PAYEE_INDEX = 4;\n\n/**\n * Normalizes an address-like hex string for case-insensitive comparisons.\n *\n * @param address - Address value to normalize.\n * @returns Lowercased hex string.\n */\nconst normalizeAddress = (address: Address): Address =>\n address.toLowerCase() as Address;\n\n/**\n * Returns whether any caveat in local or inherited delegations matches a predicate.\n *\n * @param caveats - Current caveat list.\n * @param delegations - Existing delegations whose caveats should also be searched.\n * @param match - Predicate used to match caveats.\n * @returns True when at least one caveat satisfies `match`.\n */\nconst hasMatchingCaveats = (\n caveats: Caveat[],\n delegations: Delegation[],\n match: (caveat: Caveat) => boolean,\n): boolean => {\n for (const caveat of caveats) {\n if (match(caveat)) {\n return true;\n }\n }\n\n for (const delegation of delegations) {\n for (const caveat of delegation.caveats) {\n if (match(caveat)) {\n return true;\n }\n }\n }\n\n return false;\n};\n\n/**\n * Ensures caveats include an expiry timestamp constraint when requested.\n *\n * If an existing timestamp caveat already enforces a tighter (earlier) or equal\n * `validBefore` threshold than requested, caveats are returned unchanged.\n * Otherwise a new timestamp caveat is appended with `afterThreshold = 0`.\n *\n * @param options0 - Expiry constraint evaluation inputs.\n * @param options0.timestampEnforcer - Address of the TimestampEnforcer caveat contract.\n * @param options0.caveats - Currently resolved caveats for the delegation being created.\n * @param options0.existingDelegations - Existing parent-chain delegations to inspect for inherited constraints.\n * @param options0.expirySeconds - Relative expiry from \"now\" in seconds.\n * @returns The original caveats when sufficiently constrained, otherwise caveats with a timestamp caveat appended.\n */\nexport const ensureExpirySufficientlyConstrained = ({\n timestampEnforcer,\n caveats,\n existingDelegations,\n expirySeconds,\n}: EnsureExpirySufficientlyConstrainedParams): Caveat[] => {\n if (expirySeconds < 0) {\n throw new Error('Expiry seconds must be a positive number');\n }\n const beforeThreshold = Math.floor(Date.now() / 1000) + expirySeconds;\n const timestampEnforcerNormalized = normalizeAddress(timestampEnforcer);\n\n const hasSupersedingTimestampConstraint = hasMatchingCaveats(\n caveats,\n existingDelegations,\n (caveat) => {\n if (normalizeAddress(caveat.enforcer) !== timestampEnforcerNormalized) {\n return false;\n }\n\n const { beforeThreshold: existingBeforeThreshold } = decodeTimestampTerms(\n caveat.terms,\n );\n return (\n existingBeforeThreshold !== 0 &&\n existingBeforeThreshold <= beforeThreshold\n );\n },\n );\n\n if (hasSupersedingTimestampConstraint) {\n return caveats;\n }\n\n const timestampCaveat: Caveat = {\n enforcer: timestampEnforcer,\n terms: createTimestampTerms({\n afterThreshold: 0,\n beforeThreshold,\n }),\n args: '0x',\n };\n\n return [...caveats, timestampCaveat];\n};\n\n/**\n * Resolves allowed redeemer addresses from facilitator and configured redeemer inputs.\n *\n * If both inputs are provided, returns their intersection.\n * If only one input is provided, returns that input.\n * If neither input is provided, returns undefined.\n *\n * @param options - Redeemer address inputs.\n * @param options.facilitatorAddresses - Optional facilitator addresses from the PaymentRequirements.\n * @param options.redeemerAddresses - Optional redeemer addresses from the RedeemersConfig.\n * @returns Resolved allowed redeemer addresses, or undefined when no input is provided.\n */\nconst resolveRedeemerAddresses = ({\n facilitatorAddresses,\n redeemerAddresses,\n}: ResolveRedeemerAddressesParams): Address[] | undefined => {\n if (!facilitatorAddresses) {\n if (!redeemerAddresses) {\n return undefined;\n }\n return redeemerAddresses;\n }\n\n if (!redeemerAddresses) {\n return facilitatorAddresses;\n }\n\n const normalizedFacilitatorAddresses =\n facilitatorAddresses.map(normalizeAddress);\n\n const normalizedRedeemerAddressSet = new Set(\n redeemerAddresses.map(normalizeAddress),\n );\n\n const redeemerAddressesIntersection = normalizedFacilitatorAddresses.filter(\n (address) => normalizedRedeemerAddressSet.has(address),\n );\n\n return redeemerAddressesIntersection;\n};\n\n/**\n * Ensures caveats include a sufficiently strict redeemer constraint.\n *\n * Returns the caveat list unchanged when an existing redeemer caveat is already\n * strict enough, or appends a new redeemer caveat scoped to facilitator addresses.\n *\n * @param config - Redeemer constraint evaluation inputs.\n * @param config.redeemerEnforcer - Address of the redeemer enforcer caveat contract.\n * @param config.caveats - Currently resolved caveats for the delegation being created.\n * @param config.existingDelegations - Existing parent-chain delegations to inspect for inherited constraints.\n * @param config.redeemerAddresses - Optional addresses to which redemption should be constrained.\n * @param config.requireRedeemers - Whether at least one redeemer constraint must exist.\n * @returns The original caveats when sufficiently constrained, otherwise caveats with a redeemer caveat appended.\n * @throws If either facilitatorAddresses and/or redeemerAddresses are provided, but the intersection is empty.\n * @throws If requireRedeemers is true, but no valid redeemer addresses are provided, and no existing redeemer caveat is found in the existingDelegations.\n */\nexport const ensureRedeemerSufficientlyConstrained = (\n config: EnsureRedeemerSufficientlyConstrainedParams,\n): Caveat[] => {\n // `redeemerAddresses` is the intersection of `facilitatorAddresses` and `redeemerAddresses`.\n // If either is undefined, it implies no constraint is specified by that value, and the other is returned.\n // If both are undefined, it implies that no constraint is specified overall.\n const redeemerAddresses = resolveRedeemerAddresses(config);\n\n // If the result is defined, but zero-length, it implies no redeemers are allowed, which is a non-satisfiable constraint, so an error is thrown.\n if (redeemerAddresses?.length === 0) {\n throw new Error(\n 'No valid redeemer addresses were resolved. If both `redeemers.addresses` and `extra.facilitatorAddresses` are provided, they must overlap. If only one is provided, it must include at least one address.',\n );\n }\n\n const { caveats, existingDelegations, redeemerEnforcer } = config;\n\n const redeemerEnforcerNormalized = normalizeAddress(redeemerEnforcer);\n\n if (!redeemerAddresses) {\n if (!config.requireRedeemers) {\n return caveats;\n }\n\n const hasExistingRedeemerCaveat = hasMatchingCaveats(\n caveats,\n existingDelegations,\n ({ enforcer }) =>\n normalizeAddress(enforcer) === redeemerEnforcerNormalized,\n );\n\n if (!hasExistingRedeemerCaveat) {\n throw new Error(\n 'Redeemer must be constrained, either in the specified `caveats`, `parentPermissionContext`, or the `PaymentRequirements` as `extra.facilitatorAddresses`.',\n );\n }\n\n return caveats;\n }\n\n const redeemerAddressesSet = new Set(redeemerAddresses.map(normalizeAddress));\n\n const hasSupersedingRedeemerCaveat = hasMatchingCaveats(\n caveats,\n existingDelegations,\n (caveat) => {\n if (normalizeAddress(caveat.enforcer) !== redeemerEnforcerNormalized) {\n return false;\n }\n\n const allowedRedeemerAddresses = decodeRedeemerTerms(\n caveat.terms,\n ).redeemers.map(normalizeAddress);\n\n // If this redeemer caveat only allows redeemer addresses, it is sufficiently constrained.\n return allowedRedeemerAddresses.every((item) =>\n redeemerAddressesSet.has(item),\n );\n },\n );\n\n if (hasSupersedingRedeemerCaveat) {\n return caveats;\n }\n\n const redeemerCaveat: Caveat = {\n enforcer: redeemerEnforcer,\n terms: createRedeemerTerms({ redeemers: redeemerAddresses }),\n args: '0x',\n };\n\n return [...caveats, redeemerCaveat];\n};\n\n/**\n * Ensures caveats include an allowed-calldata constraint for the payment payee.\n *\n * Scans both the in-progress caveat list and parent delegation caveats for an\n * `AllowedCalldataEnforcer` caveat whose terms match the encoded payee calldata\n * constraint. If found, returns caveats unchanged; otherwise appends a payee caveat.\n *\n * @param options0 - Payee constraint evaluation inputs.\n * @param options0.allowedCalldataEnforcer - Address of the AllowedCalldataEnforcer caveat contract.\n * @param options0.caveats - Currently resolved caveats for the delegation being created.\n * @param options0.existingDelegations - Existing parent-chain delegations to inspect for inherited constraints.\n * @param options0.payee - Expected ERC-20 transfer recipient to enforce in calldata.\n * @returns The original caveats when an equivalent payee constraint exists, otherwise caveats with a payee caveat appended.\n */\nexport const ensurePayeeSufficientlyConstrained = ({\n allowedCalldataEnforcer,\n caveats,\n existingDelegations,\n payee,\n}: EnsurePayeeSufficientlyConstrainedParams): Caveat[] => {\n const allowedCalldataTerms = createAllowedCalldataTerms({\n startIndex: TRANSFER_PAYEE_INDEX,\n value: pad(payee, { size: 32 }),\n });\n\n const allowedCalldataEnforcerNormalized = normalizeAddress(\n allowedCalldataEnforcer,\n );\n\n const lowercaseCalldataTerms = allowedCalldataTerms.toLowerCase();\n\n const hasSupersedingAllowedCalldataConstraint = hasMatchingCaveats(\n caveats,\n existingDelegations,\n ({ enforcer, terms }) =>\n normalizeAddress(enforcer) === allowedCalldataEnforcerNormalized &&\n terms.toLowerCase() === lowercaseCalldataTerms,\n );\n\n if (hasSupersedingAllowedCalldataConstraint) {\n return caveats;\n }\n\n const payeeCaveat: Caveat = {\n enforcer: allowedCalldataEnforcer,\n terms: allowedCalldataTerms,\n args: '0x',\n };\n\n return [...caveats, payeeCaveat];\n};\n\n/**\n * Resolves caveats and applies x402-specific redeemer and payee constraints.\n *\n * @param options0 - Caveat resolution inputs.\n * @param options0.environment - Environment containing caveat enforcer addresses.\n * @param options0.caveatsConfig - Optional caveat builder config.\n * @param options0.existingDelegations - Existing parent-chain delegations.\n * @param options0.facilitatorAddresses - Optional facilitator addresses used for redeemer constraints.\n * @param options0.payee - Payee address used for allowed calldata constraints.\n * @param options0.expirySeconds - Optional relative expiry in seconds for adding timestamp constraints.\n * @param options0.requireRedeemers - Whether redeemer constraints are mandatory when no facilitator or configured redeemer addresses are present.\n * @param options0.redeemerAddresses - Optional redeemer addresses from provider config to merge with facilitator addresses.\n * @returns Caveats after redeemer and payee constraints are enforced.\n */\nexport const resolvex402DelegationCaveats = ({\n environment,\n caveatsConfig,\n existingDelegations,\n facilitatorAddresses,\n payee,\n expirySeconds,\n requireRedeemers,\n redeemerAddresses,\n}: Resolvex402DelegationCaveatsParams): Caveat[] => {\n const {\n caveatEnforcers: {\n RedeemerEnforcer: redeemerEnforcer,\n AllowedCalldataEnforcer: allowedCalldataEnforcer,\n TimestampEnforcer: timestampEnforcer,\n },\n } = environment;\n\n if (!redeemerEnforcer) {\n throw new Error('RedeemerEnforcer not found in environment');\n }\n\n if (!allowedCalldataEnforcer) {\n throw new Error('AllowedCalldataEnforcer not found in environment');\n }\n\n if (!timestampEnforcer) {\n throw new Error('TimestampEnforcer not found in environment');\n }\n\n const initialCaveats = resolveCaveats({\n environment,\n caveats: caveatsConfig,\n // Resolve caveats first so downstream constraint checks can append as needed.\n // Scope is still attached later during delegation creation.\n isScopeOptional: true,\n });\n\n const caveatsWithRedeemer = ensureRedeemerSufficientlyConstrained({\n redeemerEnforcer,\n facilitatorAddresses,\n redeemerAddresses,\n caveats: initialCaveats,\n existingDelegations,\n requireRedeemers,\n });\n\n const caveatsWithPayee = ensurePayeeSufficientlyConstrained({\n allowedCalldataEnforcer,\n caveats: caveatsWithRedeemer,\n existingDelegations,\n payee,\n });\n\n if (expirySeconds === undefined) {\n return caveatsWithPayee;\n }\n\n return ensureExpirySufficientlyConstrained({\n timestampEnforcer,\n caveats: caveatsWithPayee,\n existingDelegations,\n expirySeconds,\n });\n};\n\n/**\n * Builds the delegation creation context from provider config and requirements.\n *\n * @param config - Delegation provider config for context construction.\n * @param requirements - Payment requirements used to scope caveats.\n * @returns The resolved context used to create and sign a delegation.\n */\nexport const resolveDelegationCreationContext = async (\n config: x402DelegationProviderConfig,\n requirements: PaymentRequirements,\n): Promise<DelegationCreationContext> => {\n const account = await resolveMaybeDeferred(config.account, requirements);\n const redeemersConfig = await resolveMaybeDeferred(\n config.redeemers,\n requirements,\n );\n\n const requireRedeemers = redeemersConfig?.requireRedeemers ?? false;\n const redeemerAddresses = await resolveMaybeDeferred(\n redeemersConfig?.addresses,\n requirements,\n );\n\n const specifiedEnvironment = await resolveMaybeDeferred(\n config.environment,\n requirements,\n );\n const environment =\n specifiedEnvironment ??\n getSmartAccountsEnvironment(parseEip155ChainId(requirements.network));\n\n const caveatsConfig: Caveats | undefined = await resolveMaybeDeferred(\n config.caveats,\n requirements,\n );\n const parentPermissionContext: PermissionContext | undefined =\n await resolveMaybeDeferred(config.parentPermissionContext, requirements);\n const expirySeconds = await resolveMaybeDeferred(\n config.expirySeconds,\n requirements,\n );\n\n const from =\n (await resolveMaybeDeferred(config.from, requirements)) ?? account.address;\n const salt =\n (await resolveMaybeDeferred(config.salt, requirements)) ?? generateSalt();\n\n const scope = {\n type: ScopeType.Erc20TransferAmount,\n tokenAddress: requirements.asset as Hex,\n maxAmount: BigInt(requirements.amount),\n } as const;\n\n const facilitatorAddresses = requirements.extra?.facilitatorAddresses as\n | Hex[]\n | undefined;\n\n const existingDelegations = parentPermissionContext\n ? decodeDelegations(parentPermissionContext)\n : [];\n\n const { DelegationManager: delegationManager } = environment;\n const caveats = resolvex402DelegationCaveats({\n environment,\n caveatsConfig,\n existingDelegations,\n facilitatorAddresses,\n payee: requirements.payTo as Hex,\n expirySeconds,\n requireRedeemers,\n redeemerAddresses,\n });\n\n let createDelegationConfig: Parameters<typeof createOpenDelegation>[0];\n\n if (parentPermissionContext) {\n const parentDelegation = existingDelegations[0];\n\n if (!parentDelegation) {\n throw new Error('Parent permission context is not a valid delegation');\n }\n\n createDelegationConfig = {\n environment,\n from,\n caveats,\n salt,\n scope,\n parentDelegation,\n };\n } else {\n createDelegationConfig = {\n environment,\n from,\n caveats,\n salt,\n scope,\n };\n }\n\n const rootDelegator =\n existingDelegations[existingDelegations.length - 1]?.delegator ?? from;\n\n return {\n account,\n createDelegationConfig,\n delegationManager,\n existingDelegations,\n rootDelegator,\n };\n};\n","import type { Address } from 'viem';\n\nimport {\n createOpenDelegation,\n encodeDelegations,\n prepareSignDelegationTypedData,\n} from '../delegation';\nimport type {\n PaymentRequirements,\n x402DelegationProvider,\n x402DelegationProviderConfig,\n x402DelegationProviderPaymentPayload,\n} from './x402DelegationProviderTypes';\nimport {\n parseEip155ChainId,\n resolveDelegationCreationContext,\n} from './x402DelegationProviderUtils';\n\nexport type {\n MaybeDeferred,\n PaymentRequirements,\n x402DelegationProvider,\n x402DelegationProviderConfig,\n x402DelegationProviderPaymentPayload,\n} from './x402DelegationProviderTypes';\n\nexport { parseEip155ChainId } from './x402DelegationProviderUtils';\n\nexport const METAMASK_FACILITATOR_ADDRESSES: readonly Address[] = [\n '0xB01caEa8c6C47bbf4F4b4c5080Ca642043359C2E',\n '0xC066ac5D385419B1A8c43A0E146fA439837a8B8c',\n '0xB42F812A44c22cc6b861478900401ee759EbEAD6',\n];\nexport const METAMASK_FACILITATOR_ADDRESSES_DEV: readonly Address[] = [\n '0xb4827A2a066CD2Ef88560EFdf063dD05C6c41cC7',\n];\n\n/**\n * Creates a delegation provider function for x402 payment requirements.\n *\n * The returned provider resolves deferred config values using incoming payment\n * requirements, creates an open delegation, signs it, and returns an encoded\n * permission context payload.\n *\n * @param config - Delegation creation and signing configuration.\n * @returns A provider that maps payment requirements to a signed delegation payload.\n */\nexport function createx402DelegationProvider(\n config: x402DelegationProviderConfig,\n): x402DelegationProvider {\n return async (\n requirements: PaymentRequirements,\n ): Promise<x402DelegationProviderPaymentPayload> => {\n const {\n account,\n createDelegationConfig,\n delegationManager,\n existingDelegations,\n rootDelegator,\n } = await resolveDelegationCreationContext(config, requirements);\n\n const delegation = createOpenDelegation(createDelegationConfig);\n\n const chainId = parseEip155ChainId(requirements.network);\n\n const typedData = prepareSignDelegationTypedData({\n delegationManager,\n chainId,\n delegation,\n });\n\n if (!account.signTypedData) {\n throw new Error('Account does not support signTypedData');\n }\n\n const signature = await account.signTypedData(typedData);\n\n const signedDelegation = {\n ...delegation,\n signature,\n };\n\n const permissionContext = encodeDelegations([\n signedDelegation,\n ...existingDelegations,\n ]);\n\n return {\n delegationManager,\n permissionContext,\n delegator: rootDelegator,\n };\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,SAAmB,aAAa;AA4BzB,IAAM,+BAET;AAAA,EACF,KAAK,EAAE,QAAQ,0CAA0C;AAAA,EACzD,MAAM,EAAE,QAAQ,sCAAsC;AACxD;AASA,SAAS,gCACP,QAC2B;AAC3B,QAAM,sBAAsB,OAAO,QAAQ,4BAA4B,EAAE;AAAA,IACvE,CAAC,CAAC,GAAG,GAAG,MAAM,IAAI,WAAW;AAAA,EAC/B;AAEA,SAAO,sBAAsB,oBAAoB,CAAC,IAAI;AACxD;AAaO,IAAM,0BAAN,MAA8B;AAAA,EAC1B,oBAAoB;AAAA,EAEpB;AAAA,EAEA;AAAA,EAEA;AAAA,EAET,YAAY,QAAiC;AAC3C,UAAM,EAAE,OAAO,IAAI,OAAO;AAE1B;AAAA,MACE;AAAA,MACA;AAAA,QACE,aAAa,gCAAgC,MAAM;AAAA,MACrD;AAAA,IACF;AAEA,QAAI,OAAO,SAAS,KAAK,iBAAiB,GAAG;AAC3C,WAAK,UAAU;AAAA,IACjB,OAAO;AACL,YAAM,YAAY,OAAO,SAAS,GAAG,IA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AA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,QAAM,gBACJ,oBAAoB,oBAAoB,SAAS,CAAC,GAAG,aAAa;AAEpE,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;;;AChlBO,IAAM,iCAAqD;AAAA,EAChE;AAAA,EACA;AAAA,EACA;AACF;AACO,IAAM,qCAAyD;AAAA,EACpE;AACF;AAYO,SAAS,6BACd,QACwB;AACxB,SAAO,OACL,iBACkD;AAClD,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,IAAI,MAAM,iCAAiC,QAAQ,YAAY;AAE/D,UAAM,aAAa,qBAAqB,sBAAsB;AAE9D,UAAM,UAAU,mBAAmB,aAAa,OAAO;AAEvD,UAAM,YAAY,+BAA+B;AAAA,MAC/C;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,QAAI,CAAC,QAAQ,eAAe;AAC1B,YAAM,IAAI,MAAM,wCAAwC;AAAA,IAC1D;AAEA,UAAM,YAAY,MAAM,QAAQ,cAAc,SAAS;AAEvD,UAAM,mBAAmB;AAAA,MACvB,GAAG;AAAA,MACH;AAAA,IACF;AAEA,UAAM,oBAAoB,kBAAkB;AAAA,MAC1C;AAAA,MACA,GAAG;AAAA,IACL,CAAC;AAED,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA,WAAW;AAAA,IACb;AAAA,EACF;AACF;","names":[]}
@@ -1,4 +1,4 @@
1
- import { j as ScopeType, B as Erc20PeriodTransferBuilderConfig, F as Erc20StreamingBuilderConfig, G as Erc20TransferAmountBuilderConfig, J as Erc721TransferBuilderConfig, K as AllowedCalldataBuilderConfig, L as ExactCalldataBuilderConfig, V as ValueLteBuilderConfig, N as AllowedTargetsBuilderConfig, O as AllowedMethodsBuilderConfig, Q as NativeTokenPeriodTransferBuilderConfig, R as NativeTokenStreamingBuilderConfig, U as NativeTokenTransferAmountBuilderConfig, X as OwnershipTransferBuilderConfig } from './resolveCaveats-A9xC29l8.cjs';
1
+ import { j as ScopeType, B as Erc20PeriodTransferBuilderConfig, F as Erc20StreamingBuilderConfig, G as Erc20TransferAmountBuilderConfig, J as Erc721TransferBuilderConfig, K as AllowedCalldataBuilderConfig, L as ExactCalldataBuilderConfig, V as ValueLteBuilderConfig, N as AllowedTargetsBuilderConfig, O as AllowedMethodsBuilderConfig, Q as NativeTokenPeriodTransferBuilderConfig, R as NativeTokenStreamingBuilderConfig, U as NativeTokenTransferAmountBuilderConfig, X as OwnershipTransferBuilderConfig } from './resolveCaveats-aQPEogPk.cjs';
2
2
 
3
3
  type Erc20PeriodicScopeConfig = {
4
4
  type: ScopeType.Erc20PeriodTransfer;
@@ -1,8 +1,8 @@
1
1
  import { ANY_BENEFICIARY, ROOT_AUTHORITY } from '@metamask/delegation-core';
2
2
  import * as viem from 'viem';
3
3
  import { Client, Transport, Chain, Account, Address, Hex } from 'viem';
4
- import { f as DecodedRevertReason, g as DelegationStruct } from './decodeRevertReason-dOTpJx2h.js';
5
- import { P as PermissionContext, E as ExecutionMode, e as ExecutionStruct, D as Delegation } from './resolveCaveats-A9xC29l8.js';
4
+ import { D as DecodedRevertReason, d as DelegationStruct } from './decodeRevertReason-WjHVQ_Sz.js';
5
+ import { P as PermissionContext, E as ExecutionMode, e as ExecutionStruct, D as Delegation } from './resolveCaveats-aQPEogPk.js';
6
6
 
7
7
  declare const NAME$1 = "DelegationManager";
8
8
  declare const VERSION$1 = "1.3.0";
@@ -1,6 +1,6 @@
1
1
  import { Account, Address, Hex, Chain, Client, Transport, WalletClient, RpcSchema, OneOf, SendTransactionRequest, SendTransactionParameters, PublicClient } from 'viem';
2
- import { S as SmartAccountsEnvironment, P as PermissionContext, c as Caveats, D as Delegation, p as Call } from './resolveCaveats-A9xC29l8.js';
3
- import { S as ScopeConfig } from './index-LqiEgBjV.js';
2
+ import { S as SmartAccountsEnvironment, P as PermissionContext, C as Caveats, D as Delegation, p as Call } from './resolveCaveats-aQPEogPk.js';
3
+ import { S as ScopeConfig } from './index-DWvEgBtg.js';
4
4
  import { Rule, PermissionRequest as PermissionRequest$1, PermissionTypes as PermissionTypes$1, PermissionResponse as PermissionResponse$1 } from '@metamask/7715-permission-types';
5
5
  import { ApprovalRevocationTerms } from '@metamask/delegation-core';
6
6
  import { SmartAccount, SendUserOperationParameters } from 'viem/account-abstraction';
@@ -1,8 +1,8 @@
1
1
  import { ANY_BENEFICIARY, ROOT_AUTHORITY } from '@metamask/delegation-core';
2
2
  import * as viem from 'viem';
3
3
  import { Client, Transport, Chain, Account, Address, Hex } from 'viem';
4
- import { f as DecodedRevertReason, g as DelegationStruct } from './decodeRevertReason-CmmCpmZ_.cjs';
5
- import { P as PermissionContext, E as ExecutionMode, e as ExecutionStruct, D as Delegation } from './resolveCaveats-A9xC29l8.cjs';
4
+ import { D as DecodedRevertReason, d as DelegationStruct } from './decodeRevertReason-CSOClzsa.cjs';
5
+ import { P as PermissionContext, E as ExecutionMode, e as ExecutionStruct, D as Delegation } from './resolveCaveats-aQPEogPk.cjs';
6
6
 
7
7
  declare const NAME$1 = "DelegationManager";
8
8
  declare const VERSION$1 = "1.3.0";
@@ -1,4 +1,4 @@
1
- import { j as ScopeType, B as Erc20PeriodTransferBuilderConfig, F as Erc20StreamingBuilderConfig, G as Erc20TransferAmountBuilderConfig, J as Erc721TransferBuilderConfig, K as AllowedCalldataBuilderConfig, L as ExactCalldataBuilderConfig, V as ValueLteBuilderConfig, N as AllowedTargetsBuilderConfig, O as AllowedMethodsBuilderConfig, Q as NativeTokenPeriodTransferBuilderConfig, R as NativeTokenStreamingBuilderConfig, U as NativeTokenTransferAmountBuilderConfig, X as OwnershipTransferBuilderConfig } from './resolveCaveats-A9xC29l8.js';
1
+ import { j as ScopeType, B as Erc20PeriodTransferBuilderConfig, F as Erc20StreamingBuilderConfig, G as Erc20TransferAmountBuilderConfig, J as Erc721TransferBuilderConfig, K as AllowedCalldataBuilderConfig, L as ExactCalldataBuilderConfig, V as ValueLteBuilderConfig, N as AllowedTargetsBuilderConfig, O as AllowedMethodsBuilderConfig, Q as NativeTokenPeriodTransferBuilderConfig, R as NativeTokenStreamingBuilderConfig, U as NativeTokenTransferAmountBuilderConfig, X as OwnershipTransferBuilderConfig } from './resolveCaveats-aQPEogPk.js';
2
2
 
3
3
  type Erc20PeriodicScopeConfig = {
4
4
  type: ScopeType.Erc20PeriodTransfer;
@@ -1,6 +1,6 @@
1
1
  import { Account, Address, Hex, Chain, Client, Transport, WalletClient, RpcSchema, OneOf, SendTransactionRequest, SendTransactionParameters, PublicClient } from 'viem';
2
- import { S as SmartAccountsEnvironment, P as PermissionContext, c as Caveats, D as Delegation, p as Call } from './resolveCaveats-A9xC29l8.cjs';
3
- import { S as ScopeConfig } from './index-B1Cmezvh.cjs';
2
+ import { S as SmartAccountsEnvironment, P as PermissionContext, C as Caveats, D as Delegation, p as Call } from './resolveCaveats-aQPEogPk.cjs';
3
+ import { S as ScopeConfig } from './index-BHm75OFP.cjs';
4
4
  import { Rule, PermissionRequest as PermissionRequest$1, PermissionTypes as PermissionTypes$1, PermissionResponse as PermissionResponse$1 } from '@metamask/7715-permission-types';
5
5
  import { ApprovalRevocationTerms } from '@metamask/delegation-core';
6
6
  import { SmartAccount, SendUserOperationParameters } from 'viem/account-abstraction';
package/dist/index.cjs CHANGED
@@ -2,24 +2,24 @@
2
2
 
3
3
 
4
4
 
5
- var _chunk2ZOWIAP3cjs = require('./chunk-2ZOWIAP3.cjs');
5
+ var _chunk6TSLFRJCcjs = require('./chunk-6TSLFRJC.cjs');
6
6
 
7
7
 
8
- var _chunkEPU4O7FYcjs = require('./chunk-EPU4O7FY.cjs');
9
- require('./chunk-PQPAEHJZ.cjs');
8
+ var _chunk4GOGI2TAcjs = require('./chunk-4GOGI2TA.cjs');
9
+ require('./chunk-YPUEM6YV.cjs');
10
10
 
11
11
 
12
12
 
13
13
 
14
14
 
15
- var _chunkDCI2AN4Ncjs = require('./chunk-DCI2AN4N.cjs');
15
+ var _chunkKIXYMA7Jcjs = require('./chunk-KIXYMA7J.cjs');
16
16
 
17
17
 
18
18
 
19
19
 
20
20
 
21
21
  var _chunk2OS36DVVcjs = require('./chunk-2OS36DVV.cjs');
22
- require('./chunk-JKVSTPEC.cjs');
22
+ require('./chunk-32RDDE5N.cjs');
23
23
 
24
24
 
25
25
 
@@ -36,7 +36,7 @@ require('./chunk-JKVSTPEC.cjs');
36
36
 
37
37
 
38
38
 
39
- var _chunkW6HPAK4Mcjs = require('./chunk-W6HPAK4M.cjs');
39
+ var _chunkGHGCGV3Ccjs = require('./chunk-GHGCGV3C.cjs');
40
40
 
41
41
  // src/toMetaMaskSmartAccount.ts
42
42
 
@@ -59,7 +59,7 @@ var signatureTypes = ["ECDSA"];
59
59
  var aggregateSignature = ({
60
60
  signatures
61
61
  }) => {
62
- _chunkW6HPAK4Mcjs.trackSmartAccountsKitFunctionCall.call(void 0, "aggregateSignature", {
62
+ _chunkGHGCGV3Ccjs.trackSmartAccountsKitFunctionCall.call(void 0, "aggregateSignature", {
63
63
  signatureCount: signatures.length
64
64
  });
65
65
  if (signatures.length === 0) {
@@ -115,7 +115,7 @@ var resolveHybridSigner = (config) => {
115
115
  if (webAuthnAccount.type !== "webAuthn") {
116
116
  throw new Error("Account is not a webAuthn account");
117
117
  }
118
- const encodeSignature = (result) => _chunkDCI2AN4Ncjs.encodeDeleGatorSignature.call(void 0,
118
+ const encodeSignature = (result) => _chunkKIXYMA7Jcjs.encodeDeleGatorSignature.call(void 0,
119
119
  keyId,
120
120
  result.signature,
121
121
  result.webauthn.clientDataJSON,
@@ -123,7 +123,7 @@ var resolveHybridSigner = (config) => {
123
123
  );
124
124
  const signMessage = async (args) => webAuthnAccount.signMessage(args).then(encodeSignature);
125
125
  const signTypedData = async (typedDataDefinition) => webAuthnAccount.signTypedData(typedDataDefinition).then(encodeSignature);
126
- const getStubSignature = async () => _chunkDCI2AN4Ncjs.createDummyWebAuthnSignature.call(void 0, keyId);
126
+ const getStubSignature = async () => _chunkKIXYMA7Jcjs.createDummyWebAuthnSignature.call(void 0, keyId);
127
127
  return {
128
128
  signMessage,
129
129
  signTypedData,
@@ -234,7 +234,7 @@ async function toMetaMaskSmartAccount(params) {
234
234
  implementation,
235
235
  nonceKeyManager
236
236
  } = params;
237
- _chunkW6HPAK4Mcjs.trackSmartAccountsKitFunctionCall.call(void 0, "toMetaMaskSmartAccount", {
237
+ _chunkGHGCGV3Ccjs.trackSmartAccountsKitFunctionCall.call(void 0, "toMetaMaskSmartAccount", {
238
238
  implementation,
239
239
  hasAddress: params.address !== void 0,
240
240
  hasEnvironment: params.environment !== void 0,
@@ -256,7 +256,7 @@ async function toMetaMaskSmartAccount(params) {
256
256
  if (implementation === "Stateless7702" /* Stateless7702 */) {
257
257
  throw new Error("Stateless7702 does not support counterfactual accounts");
258
258
  }
259
- const accountData = await _chunkDCI2AN4Ncjs.getCounterfactualAccountData.call(void 0, {
259
+ const accountData = await _chunkKIXYMA7Jcjs.getCounterfactualAccountData.call(void 0, {
260
260
  factory: environment.SimpleFactory,
261
261
  implementations: environment.implementations,
262
262
  implementation,
@@ -303,7 +303,7 @@ async function toMetaMaskSmartAccount(params) {
303
303
  );
304
304
  }
305
305
  const { delegation, chainId } = delegationParams;
306
- const delegationStruct = _chunkW6HPAK4Mcjs.toDelegationStruct.call(void 0, {
306
+ const delegationStruct = _chunkGHGCGV3Ccjs.toDelegationStruct.call(void 0, {
307
307
  ...delegation,
308
308
  signature: "0x"
309
309
  });
@@ -314,7 +314,7 @@ async function toMetaMaskSmartAccount(params) {
314
314
  version: "1",
315
315
  verifyingContract: environment.DelegationManager
316
316
  },
317
- types: _chunkW6HPAK4Mcjs.SIGNABLE_DELEGATION_TYPED_DATA,
317
+ types: _chunkGHGCGV3Ccjs.SIGNABLE_DELEGATION_TYPED_DATA,
318
318
  primaryType: "Delegation",
319
319
  message: delegationStruct
320
320
  });
@@ -346,7 +346,7 @@ async function toMetaMaskSmartAccount(params) {
346
346
  return signature;
347
347
  };
348
348
  const getAddress = async () => address;
349
- const encodeCalls = async (calls) => _chunkDCI2AN4Ncjs.encodeCallsForCaller.call(void 0, address, calls);
349
+ const encodeCalls = async (calls) => _chunkKIXYMA7Jcjs.encodeCallsForCaller.call(void 0, address, calls);
350
350
  const signerMethods = _nullishCoalesce(signer, () => ( {
351
351
  signMessage: async () => {
352
352
  throw new Error(
@@ -380,7 +380,7 @@ async function toMetaMaskSmartAccount(params) {
380
380
  if (implementation === "Stateless7702" /* Stateless7702 */) {
381
381
  return {
382
382
  ...smartAccount,
383
- isDeployed: async () => _chunk2ZOWIAP3cjs.isValid7702Implementation.call(void 0, {
383
+ isDeployed: async () => _chunk6TSLFRJCcjs.isValid7702Implementation.call(void 0, {
384
384
  client,
385
385
  accountAddress: address,
386
386
  environment
@@ -398,10 +398,10 @@ function createCaveatEnforcerClient({
398
398
  client,
399
399
  environment
400
400
  }) {
401
- _chunkW6HPAK4Mcjs.trackSmartAccountsKitFunctionCall.call(void 0, "createCaveatEnforcerClient", {
401
+ _chunkGHGCGV3Ccjs.trackSmartAccountsKitFunctionCall.call(void 0, "createCaveatEnforcerClient", {
402
402
  chainId: _nullishCoalesce(_optionalChain([client, 'access', _2 => _2.chain, 'optionalAccess', _3 => _3.id]), () => ( null))
403
403
  });
404
- return client.extend(_chunk2ZOWIAP3cjs.caveatEnforcerActions.call(void 0, { environment }));
404
+ return client.extend(_chunk6TSLFRJCcjs.caveatEnforcerActions.call(void 0, { environment }));
405
405
  }
406
406
 
407
407
  // src/actions/infuraBundlerClient.ts
@@ -429,7 +429,7 @@ var infuraBundlerActions = () => (client) => ({
429
429
  }
430
430
  });
431
431
  function createInfuraBundlerClient(config) {
432
- _chunkW6HPAK4Mcjs.trackSmartAccountsKitFunctionCall.call(void 0, "createInfuraBundlerClient", {
432
+ _chunkGHGCGV3Ccjs.trackSmartAccountsKitFunctionCall.call(void 0, "createInfuraBundlerClient", {
433
433
  chainId: _nullishCoalesce(_optionalChain([config, 'access', _4 => _4.chain, 'optionalAccess', _5 => _5.id]), () => ( null))
434
434
  });
435
435
  const baseBundlerClient = _accountabstraction.createBundlerClient.call(void 0, config);
@@ -460,5 +460,5 @@ function createInfuraBundlerClient(config) {
460
460
 
461
461
 
462
462
 
463
- exports.ANY_BENEFICIARY = _chunkW6HPAK4Mcjs.ANY_BENEFICIARY; exports.BalanceChangeType = _delegationcore.BalanceChangeType; exports.CaveatType = _chunkW6HPAK4Mcjs.CaveatType; exports.ExecutionMode = _chunkW6HPAK4Mcjs.ExecutionMode; exports.Implementation = _chunkW6HPAK4Mcjs.Implementation; exports.PREFERRED_VERSION = _chunk2OS36DVVcjs.PREFERRED_VERSION; exports.ROOT_AUTHORITY = _chunkW6HPAK4Mcjs.ROOT_AUTHORITY; exports.ScopeType = _chunkW6HPAK4Mcjs.ScopeType; exports.TransferWindow = _chunkW6HPAK4Mcjs.TransferWindow; exports.actions = _chunk2ZOWIAP3cjs.actions_exports; exports.aggregateSignature = aggregateSignature; exports.contracts = _chunkEPU4O7FYcjs.contracts_exports; exports.createCaveat = _chunkW6HPAK4Mcjs.createCaveat; exports.createCaveatEnforcerClient = createCaveatEnforcerClient; exports.createDelegation = _chunkW6HPAK4Mcjs.createDelegation; exports.createExecution = _chunkW6HPAK4Mcjs.createExecution; exports.createInfuraBundlerClient = createInfuraBundlerClient; exports.createOpenDelegation = _chunkW6HPAK4Mcjs.createOpenDelegation; exports.getSmartAccountsEnvironment = _chunk2OS36DVVcjs.getSmartAccountsEnvironment; exports.signDelegation = _chunkW6HPAK4Mcjs.signDelegation; exports.signUserOperation = _chunk2OS36DVVcjs.signUserOperation; exports.toMetaMaskSmartAccount = toMetaMaskSmartAccount;
463
+ exports.ANY_BENEFICIARY = _chunkGHGCGV3Ccjs.ANY_BENEFICIARY; exports.BalanceChangeType = _delegationcore.BalanceChangeType; exports.CaveatType = _chunkGHGCGV3Ccjs.CaveatType; exports.ExecutionMode = _chunkGHGCGV3Ccjs.ExecutionMode; exports.Implementation = _chunkGHGCGV3Ccjs.Implementation; exports.PREFERRED_VERSION = _chunk2OS36DVVcjs.PREFERRED_VERSION; exports.ROOT_AUTHORITY = _chunkGHGCGV3Ccjs.ROOT_AUTHORITY; exports.ScopeType = _chunkGHGCGV3Ccjs.ScopeType; exports.TransferWindow = _chunkGHGCGV3Ccjs.TransferWindow; exports.actions = _chunk6TSLFRJCcjs.actions_exports; exports.aggregateSignature = aggregateSignature; exports.contracts = _chunk4GOGI2TAcjs.contracts_exports; exports.createCaveat = _chunkGHGCGV3Ccjs.createCaveat; exports.createCaveatEnforcerClient = createCaveatEnforcerClient; exports.createDelegation = _chunkGHGCGV3Ccjs.createDelegation; exports.createExecution = _chunkGHGCGV3Ccjs.createExecution; exports.createInfuraBundlerClient = createInfuraBundlerClient; exports.createOpenDelegation = _chunkGHGCGV3Ccjs.createOpenDelegation; exports.getSmartAccountsEnvironment = _chunk2OS36DVVcjs.getSmartAccountsEnvironment; exports.signDelegation = _chunkGHGCGV3Ccjs.signDelegation; exports.signUserOperation = _chunk2OS36DVVcjs.signUserOperation; exports.toMetaMaskSmartAccount = toMetaMaskSmartAccount;
464
464
  //# sourceMappingURL=index.cjs.map
package/dist/index.d.cts CHANGED
@@ -1,17 +1,17 @@
1
- import { I as Implementation, T as ToMetaMaskSmartAccountParameters, a as ToMetaMaskSmartAccountReturnType, S as SmartAccountsEnvironment } from './resolveCaveats-A9xC29l8.cjs';
2
- export { A as AccountSignerConfig, C as Caveat, b as CaveatType, c as Caveats, d as CreateExecutionArgs, D as Delegation, E as ExecutionMode, e as ExecutionStruct, H as HybridDeleGatorDeployParams, f as HybridSignerConfig, M as MetaMaskSmartAccount, g as MetaMaskSmartAccountImplementation, h as MultiSigDeleGatorDeployParams, i as MultiSigSignerConfig, P as PermissionContext, j as ScopeType, k as SignDelegationParams, l as SignUserOperationParams, m as TransferWindow, W as WalletSignerConfig, n as WebAuthnSignerConfig, o as createExecution } from './resolveCaveats-A9xC29l8.cjs';
3
- export { C as CreateDelegationOptions, a as CreateOpenDelegationOptions, c as createDelegation, b as createOpenDelegation, s as signDelegation } from './decodeRevertReason-CmmCpmZ_.cjs';
4
- export { P as PREFERRED_VERSION, c as createCaveat, g as getSmartAccountsEnvironment } from './caveats-gqMBZKkI.cjs';
1
+ import { I as Implementation, T as ToMetaMaskSmartAccountParameters, a as ToMetaMaskSmartAccountReturnType, S as SmartAccountsEnvironment } from './resolveCaveats-aQPEogPk.cjs';
2
+ export { A as AccountSignerConfig, b as Caveat, c as CaveatType, C as Caveats, d as CreateExecutionArgs, D as Delegation, E as ExecutionMode, e as ExecutionStruct, H as HybridDeleGatorDeployParams, f as HybridSignerConfig, M as MetaMaskSmartAccount, g as MetaMaskSmartAccountImplementation, h as MultiSigDeleGatorDeployParams, i as MultiSigSignerConfig, P as PermissionContext, j as ScopeType, k as SignDelegationParams, l as SignUserOperationParams, m as TransferWindow, W as WalletSignerConfig, n as WebAuthnSignerConfig, o as createExecution } from './resolveCaveats-aQPEogPk.cjs';
3
+ export { C as CreateDelegationOptions, a as CreateOpenDelegationOptions, c as createDelegation, b as createOpenDelegation, s as signDelegation } from './decodeRevertReason-CSOClzsa.cjs';
4
+ export { P as PREFERRED_VERSION, c as createCaveat, g as getSmartAccountsEnvironment } from './caveats-BEKgygS8.cjs';
5
5
  export { ANY_BENEFICIARY, BalanceChangeType, ROOT_AUTHORITY } from '@metamask/delegation-core';
6
6
  import { Address, Hex, Transport, Chain, Account, Client } from 'viem';
7
7
  export { s as signUserOperation } from './userOp-DKgjzz7B.cjs';
8
- export { i as contracts } from './index-Dv4jPzhe.cjs';
9
- import { c as caveatEnforcerActions } from './index-X7Qn3JTg.cjs';
10
- export { i as actions } from './index-X7Qn3JTg.cjs';
8
+ export { i as contracts } from './index-CsjbdUp_.cjs';
9
+ import { c as caveatEnforcerActions } from './index-DYJjOeTn.cjs';
10
+ export { i as actions } from './index-DYJjOeTn.cjs';
11
11
  import { SmartAccount, BundlerClient, BundlerClientConfig } from 'viem/account-abstraction';
12
12
  import '@metamask/delegation-abis';
13
13
  import 'viem/chains';
14
- import './index-B1Cmezvh.cjs';
14
+ import './index-BHm75OFP.cjs';
15
15
  import '@metamask/7715-permission-types';
16
16
 
17
17
  declare function toMetaMaskSmartAccount<TImplementation extends Implementation>(params: ToMetaMaskSmartAccountParameters<TImplementation>): Promise<ToMetaMaskSmartAccountReturnType<TImplementation>>;
package/dist/index.d.ts CHANGED
@@ -1,17 +1,17 @@
1
- import { I as Implementation, T as ToMetaMaskSmartAccountParameters, a as ToMetaMaskSmartAccountReturnType, S as SmartAccountsEnvironment } from './resolveCaveats-A9xC29l8.js';
2
- export { A as AccountSignerConfig, C as Caveat, b as CaveatType, c as Caveats, d as CreateExecutionArgs, D as Delegation, E as ExecutionMode, e as ExecutionStruct, H as HybridDeleGatorDeployParams, f as HybridSignerConfig, M as MetaMaskSmartAccount, g as MetaMaskSmartAccountImplementation, h as MultiSigDeleGatorDeployParams, i as MultiSigSignerConfig, P as PermissionContext, j as ScopeType, k as SignDelegationParams, l as SignUserOperationParams, m as TransferWindow, W as WalletSignerConfig, n as WebAuthnSignerConfig, o as createExecution } from './resolveCaveats-A9xC29l8.js';
3
- export { C as CreateDelegationOptions, a as CreateOpenDelegationOptions, c as createDelegation, b as createOpenDelegation, s as signDelegation } from './decodeRevertReason-dOTpJx2h.js';
4
- export { P as PREFERRED_VERSION, c as createCaveat, g as getSmartAccountsEnvironment } from './caveats-B2OssjV4.js';
1
+ import { I as Implementation, T as ToMetaMaskSmartAccountParameters, a as ToMetaMaskSmartAccountReturnType, S as SmartAccountsEnvironment } from './resolveCaveats-aQPEogPk.js';
2
+ export { A as AccountSignerConfig, b as Caveat, c as CaveatType, C as Caveats, d as CreateExecutionArgs, D as Delegation, E as ExecutionMode, e as ExecutionStruct, H as HybridDeleGatorDeployParams, f as HybridSignerConfig, M as MetaMaskSmartAccount, g as MetaMaskSmartAccountImplementation, h as MultiSigDeleGatorDeployParams, i as MultiSigSignerConfig, P as PermissionContext, j as ScopeType, k as SignDelegationParams, l as SignUserOperationParams, m as TransferWindow, W as WalletSignerConfig, n as WebAuthnSignerConfig, o as createExecution } from './resolveCaveats-aQPEogPk.js';
3
+ export { C as CreateDelegationOptions, a as CreateOpenDelegationOptions, c as createDelegation, b as createOpenDelegation, s as signDelegation } from './decodeRevertReason-WjHVQ_Sz.js';
4
+ export { P as PREFERRED_VERSION, c as createCaveat, g as getSmartAccountsEnvironment } from './caveats-DPuxVdYU.js';
5
5
  export { ANY_BENEFICIARY, BalanceChangeType, ROOT_AUTHORITY } from '@metamask/delegation-core';
6
6
  import { Address, Hex, Transport, Chain, Account, Client } from 'viem';
7
7
  export { s as signUserOperation } from './userOp-DKgjzz7B.js';
8
- export { i as contracts } from './index-BkgdU4LI.js';
9
- import { c as caveatEnforcerActions } from './index-DUJmm8Wz.js';
10
- export { i as actions } from './index-DUJmm8Wz.js';
8
+ export { i as contracts } from './index-BNHYZ9iU.js';
9
+ import { c as caveatEnforcerActions } from './index-CgGKjHSr.js';
10
+ export { i as actions } from './index-CgGKjHSr.js';
11
11
  import { SmartAccount, BundlerClient, BundlerClientConfig } from 'viem/account-abstraction';
12
12
  import '@metamask/delegation-abis';
13
13
  import 'viem/chains';
14
- import './index-LqiEgBjV.js';
14
+ import './index-DWvEgBtg.js';
15
15
  import '@metamask/7715-permission-types';
16
16
 
17
17
  declare function toMetaMaskSmartAccount<TImplementation extends Implementation>(params: ToMetaMaskSmartAccountParameters<TImplementation>): Promise<ToMetaMaskSmartAccountReturnType<TImplementation>>;
package/dist/index.mjs CHANGED
@@ -2,24 +2,24 @@ import {
2
2
  actions_exports,
3
3
  caveatEnforcerActions,
4
4
  isValid7702Implementation
5
- } from "./chunk-AZYTTGON.mjs";
5
+ } from "./chunk-XUBMIW33.mjs";
6
6
  import {
7
7
  contracts_exports
8
- } from "./chunk-L3EZCIY6.mjs";
9
- import "./chunk-K7GTZGKJ.mjs";
8
+ } from "./chunk-IERUQUKJ.mjs";
9
+ import "./chunk-YCNLPEPH.mjs";
10
10
  import {
11
11
  createDummyWebAuthnSignature,
12
12
  encodeCallsForCaller,
13
13
  encodeDeleGatorSignature,
14
14
  getCounterfactualAccountData
15
- } from "./chunk-UJQ3JN3U.mjs";
15
+ } from "./chunk-T6SWQZRX.mjs";
16
16
  import {
17
17
  PREFERRED_VERSION,
18
18
  SIGNABLE_USER_OP_TYPED_DATA,
19
19
  getSmartAccountsEnvironment,
20
20
  signUserOperation
21
21
  } from "./chunk-GMGJRC3D.mjs";
22
- import "./chunk-YVU66KSH.mjs";
22
+ import "./chunk-EMPAUTIV.mjs";
23
23
  import {
24
24
  ANY_BENEFICIARY,
25
25
  CaveatType,
@@ -36,7 +36,7 @@ import {
36
36
  signDelegation,
37
37
  toDelegationStruct,
38
38
  trackSmartAccountsKitFunctionCall
39
- } from "./chunk-TNGQTVSY.mjs";
39
+ } from "./chunk-3KWKQ7PV.mjs";
40
40
 
41
41
  // src/toMetaMaskSmartAccount.ts
42
42
  import {
@@ -1,5 +1,5 @@
1
1
  import { HybridDeleGator, MultiSigDeleGator, EIP7702StatelessDeleGator } from '@metamask/delegation-abis';
2
- import { Account, Hex, WalletClient, Transport, Chain, PublicClient, NonceManager, OneOf, Address, AbiFunction } from 'viem';
2
+ import { Hex, Account, WalletClient, Transport, Chain, PublicClient, NonceManager, OneOf, Address, AbiFunction } from 'viem';
3
3
  import { WebAuthnAccount, SmartAccount, SmartAccountImplementation, entryPoint07Abi } from 'viem/account-abstraction';
4
4
  import { Prettify } from 'viem/chains';
5
5
  import { ApprovalRevocationTerms, BalanceChangeType } from '@metamask/delegation-core';
@@ -444,4 +444,4 @@ declare const createCaveatBuilder: (environment: SmartAccountsEnvironment, confi
444
444
 
445
445
  type Caveats = CaveatBuilder | (Caveat | CoreCaveatConfiguration)[];
446
446
 
447
- export { type AccountSignerConfig as A, type Erc20PeriodTransferBuilderConfig as B, type Caveat as C, type Delegation as D, ExecutionMode as E, type Erc20StreamingBuilderConfig as F, type Erc20TransferAmountBuilderConfig as G, type HybridDeleGatorDeployParams as H, Implementation as I, type Erc721TransferBuilderConfig as J, type AllowedCalldataBuilderConfig as K, type ExactCalldataBuilderConfig as L, type MetaMaskSmartAccount as M, type AllowedTargetsBuilderConfig as N, type AllowedMethodsBuilderConfig as O, type PermissionContext as P, type NativeTokenPeriodTransferBuilderConfig as Q, type NativeTokenStreamingBuilderConfig as R, type SmartAccountsEnvironment as S, type ToMetaMaskSmartAccountParameters as T, type NativeTokenTransferAmountBuilderConfig as U, type ValueLteBuilderConfig as V, type WalletSignerConfig as W, type OwnershipTransferBuilderConfig as X, type ToMetaMaskSmartAccountReturnType as a, CaveatType as b, type Caveats as c, type CreateExecutionArgs as d, type ExecutionStruct as e, type HybridSignerConfig as f, type MetaMaskSmartAccountImplementation as g, type MultiSigDeleGatorDeployParams as h, type MultiSigSignerConfig as i, ScopeType as j, type SignDelegationParams as k, type SignUserOperationParams as l, TransferWindow as m, type WebAuthnSignerConfig as n, createExecution as o, type Call as p, type DeployParams as q, CaveatBuilder as r, type CaveatBuilderConfig as s, type CoreCaveatBuilder as t, createCaveatBuilder as u, encodeBatchExecution as v, encodeExecutionCalldata as w, encodeExecutionCalldatas as x, encodeSingleExecution as y, type CoreCaveatConfiguration as z };
447
+ export { type AccountSignerConfig as A, type Erc20PeriodTransferBuilderConfig as B, type Caveats as C, type Delegation as D, ExecutionMode as E, type Erc20StreamingBuilderConfig as F, type Erc20TransferAmountBuilderConfig as G, type HybridDeleGatorDeployParams as H, Implementation as I, type Erc721TransferBuilderConfig as J, type AllowedCalldataBuilderConfig as K, type ExactCalldataBuilderConfig as L, type MetaMaskSmartAccount as M, type AllowedTargetsBuilderConfig as N, type AllowedMethodsBuilderConfig as O, type PermissionContext as P, type NativeTokenPeriodTransferBuilderConfig as Q, type NativeTokenStreamingBuilderConfig as R, type SmartAccountsEnvironment as S, type ToMetaMaskSmartAccountParameters as T, type NativeTokenTransferAmountBuilderConfig as U, type ValueLteBuilderConfig as V, type WalletSignerConfig as W, type OwnershipTransferBuilderConfig as X, type ToMetaMaskSmartAccountReturnType as a, type Caveat as b, CaveatType as c, type CreateExecutionArgs as d, type ExecutionStruct as e, type HybridSignerConfig as f, type MetaMaskSmartAccountImplementation as g, type MultiSigDeleGatorDeployParams as h, type MultiSigSignerConfig as i, ScopeType as j, type SignDelegationParams as k, type SignUserOperationParams as l, TransferWindow as m, type WebAuthnSignerConfig as n, createExecution as o, type Call as p, type DeployParams as q, CaveatBuilder as r, type CaveatBuilderConfig as s, type CoreCaveatBuilder as t, createCaveatBuilder as u, encodeBatchExecution as v, encodeExecutionCalldata as w, encodeExecutionCalldatas as x, encodeSingleExecution as y, type CoreCaveatConfiguration as z };
@@ -1,5 +1,5 @@
1
1
  import { HybridDeleGator, MultiSigDeleGator, EIP7702StatelessDeleGator } from '@metamask/delegation-abis';
2
- import { Account, Hex, WalletClient, Transport, Chain, PublicClient, NonceManager, OneOf, Address, AbiFunction } from 'viem';
2
+ import { Hex, Account, WalletClient, Transport, Chain, PublicClient, NonceManager, OneOf, Address, AbiFunction } from 'viem';
3
3
  import { WebAuthnAccount, SmartAccount, SmartAccountImplementation, entryPoint07Abi } from 'viem/account-abstraction';
4
4
  import { Prettify } from 'viem/chains';
5
5
  import { ApprovalRevocationTerms, BalanceChangeType } from '@metamask/delegation-core';
@@ -444,4 +444,4 @@ declare const createCaveatBuilder: (environment: SmartAccountsEnvironment, confi
444
444
 
445
445
  type Caveats = CaveatBuilder | (Caveat | CoreCaveatConfiguration)[];
446
446
 
447
- export { type AccountSignerConfig as A, type Erc20PeriodTransferBuilderConfig as B, type Caveat as C, type Delegation as D, ExecutionMode as E, type Erc20StreamingBuilderConfig as F, type Erc20TransferAmountBuilderConfig as G, type HybridDeleGatorDeployParams as H, Implementation as I, type Erc721TransferBuilderConfig as J, type AllowedCalldataBuilderConfig as K, type ExactCalldataBuilderConfig as L, type MetaMaskSmartAccount as M, type AllowedTargetsBuilderConfig as N, type AllowedMethodsBuilderConfig as O, type PermissionContext as P, type NativeTokenPeriodTransferBuilderConfig as Q, type NativeTokenStreamingBuilderConfig as R, type SmartAccountsEnvironment as S, type ToMetaMaskSmartAccountParameters as T, type NativeTokenTransferAmountBuilderConfig as U, type ValueLteBuilderConfig as V, type WalletSignerConfig as W, type OwnershipTransferBuilderConfig as X, type ToMetaMaskSmartAccountReturnType as a, CaveatType as b, type Caveats as c, type CreateExecutionArgs as d, type ExecutionStruct as e, type HybridSignerConfig as f, type MetaMaskSmartAccountImplementation as g, type MultiSigDeleGatorDeployParams as h, type MultiSigSignerConfig as i, ScopeType as j, type SignDelegationParams as k, type SignUserOperationParams as l, TransferWindow as m, type WebAuthnSignerConfig as n, createExecution as o, type Call as p, type DeployParams as q, CaveatBuilder as r, type CaveatBuilderConfig as s, type CoreCaveatBuilder as t, createCaveatBuilder as u, encodeBatchExecution as v, encodeExecutionCalldata as w, encodeExecutionCalldatas as x, encodeSingleExecution as y, type CoreCaveatConfiguration as z };
447
+ export { type AccountSignerConfig as A, type Erc20PeriodTransferBuilderConfig as B, type Caveats as C, type Delegation as D, ExecutionMode as E, type Erc20StreamingBuilderConfig as F, type Erc20TransferAmountBuilderConfig as G, type HybridDeleGatorDeployParams as H, Implementation as I, type Erc721TransferBuilderConfig as J, type AllowedCalldataBuilderConfig as K, type ExactCalldataBuilderConfig as L, type MetaMaskSmartAccount as M, type AllowedTargetsBuilderConfig as N, type AllowedMethodsBuilderConfig as O, type PermissionContext as P, type NativeTokenPeriodTransferBuilderConfig as Q, type NativeTokenStreamingBuilderConfig as R, type SmartAccountsEnvironment as S, type ToMetaMaskSmartAccountParameters as T, type NativeTokenTransferAmountBuilderConfig as U, type ValueLteBuilderConfig as V, type WalletSignerConfig as W, type OwnershipTransferBuilderConfig as X, type ToMetaMaskSmartAccountReturnType as a, type Caveat as b, CaveatType as c, type CreateExecutionArgs as d, type ExecutionStruct as e, type HybridSignerConfig as f, type MetaMaskSmartAccountImplementation as g, type MultiSigDeleGatorDeployParams as h, type MultiSigSignerConfig as i, ScopeType as j, type SignDelegationParams as k, type SignUserOperationParams as l, TransferWindow as m, type WebAuthnSignerConfig as n, createExecution as o, type Call as p, type DeployParams as q, CaveatBuilder as r, type CaveatBuilderConfig as s, type CoreCaveatBuilder as t, createCaveatBuilder as u, encodeBatchExecution as v, encodeExecutionCalldata as w, encodeExecutionCalldatas as x, encodeSingleExecution as y, type CoreCaveatConfiguration as z };
@@ -6,7 +6,7 @@ var _chunkIQT6XFDTcjs = require('../chunk-IQT6XFDT.cjs');
6
6
 
7
7
 
8
8
 
9
- var _chunkDCI2AN4Ncjs = require('../chunk-DCI2AN4N.cjs');
9
+ var _chunkKIXYMA7Jcjs = require('../chunk-KIXYMA7J.cjs');
10
10
 
11
11
 
12
12
 
@@ -15,7 +15,7 @@ var _chunk2OS36DVVcjs = require('../chunk-2OS36DVV.cjs');
15
15
 
16
16
 
17
17
 
18
- var _chunkJKVSTPECcjs = require('../chunk-JKVSTPEC.cjs');
18
+ var _chunk32RDDE5Ncjs = require('../chunk-32RDDE5N.cjs');
19
19
 
20
20
 
21
21
 
@@ -36,7 +36,7 @@ var _chunkJKVSTPECcjs = require('../chunk-JKVSTPEC.cjs');
36
36
 
37
37
 
38
38
 
39
- var _chunkW6HPAK4Mcjs = require('../chunk-W6HPAK4M.cjs');
39
+ var _chunkGHGCGV3Ccjs = require('../chunk-GHGCGV3C.cjs');
40
40
 
41
41
 
42
42
 
@@ -67,5 +67,5 @@ var _chunkW6HPAK4Mcjs = require('../chunk-W6HPAK4M.cjs');
67
67
 
68
68
 
69
69
 
70
- exports.CaveatBuilder = _chunkW6HPAK4Mcjs.CaveatBuilder; exports.DELEGATION_ABI_TYPE = _chunkW6HPAK4Mcjs.DELEGATION_ABI_TYPE; exports.DELEGATION_ABI_TYPE_COMPONENTS = _chunkW6HPAK4Mcjs.DELEGATION_ABI_TYPE_COMPONENTS; exports.DELEGATION_ARRAY_ABI_TYPE = _chunkW6HPAK4Mcjs.DELEGATION_ARRAY_ABI_TYPE; exports.DELEGATION_TYPEHASH = _chunkW6HPAK4Mcjs.DELEGATION_TYPEHASH; exports.SIGNABLE_DELEGATION_TYPED_DATA = _chunkW6HPAK4Mcjs.SIGNABLE_DELEGATION_TYPED_DATA; exports.SIGNABLE_USER_OP_TYPED_DATA = _chunk2OS36DVVcjs.SIGNABLE_USER_OP_TYPED_DATA; exports.SIGNATURE_ABI_PARAMS = _chunkDCI2AN4Ncjs.SIGNATURE_ABI_PARAMS; exports.createCaveatBuilder = _chunkW6HPAK4Mcjs.createCaveatBuilder; exports.decodeCaveat = _chunkW6HPAK4Mcjs.decodeCaveat; exports.decodeDelegation = _chunkW6HPAK4Mcjs.decodeDelegation; exports.decodeDelegations = _chunkW6HPAK4Mcjs.decodeDelegations; exports.decodeRevertData = _chunkJKVSTPECcjs.decodeRevertData; exports.decodeRevertReason = _chunkJKVSTPECcjs.decodeRevertReason; exports.deploySmartAccountsEnvironment = _chunk2OS36DVVcjs.deploySmartAccountsEnvironment; exports.encodeBatchExecution = _chunkW6HPAK4Mcjs.encodeBatchExecution; exports.encodeCalls = _chunkDCI2AN4Ncjs.encodeCalls; exports.encodeCallsForCaller = _chunkDCI2AN4Ncjs.encodeCallsForCaller; exports.encodeDelegation = _chunkW6HPAK4Mcjs.encodeDelegation; exports.encodeDelegations = _chunkW6HPAK4Mcjs.encodeDelegations; exports.encodeExecutionCalldata = _chunkW6HPAK4Mcjs.encodeExecutionCalldata; exports.encodeExecutionCalldatas = _chunkW6HPAK4Mcjs.encodeExecutionCalldatas; exports.encodeSingleExecution = _chunkW6HPAK4Mcjs.encodeSingleExecution; exports.generateSalt = _chunkIQT6XFDTcjs.generateSalt; exports.getCounterfactualAccountData = _chunkDCI2AN4Ncjs.getCounterfactualAccountData; exports.hashDelegation = _chunkW6HPAK4Mcjs.hashDelegation; exports.overrideDeployedEnvironment = _chunk2OS36DVVcjs.overrideDeployedEnvironment; exports.toDelegation = _chunkW6HPAK4Mcjs.toDelegation; exports.toDelegationStruct = _chunkW6HPAK4Mcjs.toDelegationStruct;
70
+ exports.CaveatBuilder = _chunkGHGCGV3Ccjs.CaveatBuilder; exports.DELEGATION_ABI_TYPE = _chunkGHGCGV3Ccjs.DELEGATION_ABI_TYPE; exports.DELEGATION_ABI_TYPE_COMPONENTS = _chunkGHGCGV3Ccjs.DELEGATION_ABI_TYPE_COMPONENTS; exports.DELEGATION_ARRAY_ABI_TYPE = _chunkGHGCGV3Ccjs.DELEGATION_ARRAY_ABI_TYPE; exports.DELEGATION_TYPEHASH = _chunkGHGCGV3Ccjs.DELEGATION_TYPEHASH; exports.SIGNABLE_DELEGATION_TYPED_DATA = _chunkGHGCGV3Ccjs.SIGNABLE_DELEGATION_TYPED_DATA; exports.SIGNABLE_USER_OP_TYPED_DATA = _chunk2OS36DVVcjs.SIGNABLE_USER_OP_TYPED_DATA; exports.SIGNATURE_ABI_PARAMS = _chunkKIXYMA7Jcjs.SIGNATURE_ABI_PARAMS; exports.createCaveatBuilder = _chunkGHGCGV3Ccjs.createCaveatBuilder; exports.decodeCaveat = _chunkGHGCGV3Ccjs.decodeCaveat; exports.decodeDelegation = _chunkGHGCGV3Ccjs.decodeDelegation; exports.decodeDelegations = _chunkGHGCGV3Ccjs.decodeDelegations; exports.decodeRevertData = _chunk32RDDE5Ncjs.decodeRevertData; exports.decodeRevertReason = _chunk32RDDE5Ncjs.decodeRevertReason; exports.deploySmartAccountsEnvironment = _chunk2OS36DVVcjs.deploySmartAccountsEnvironment; exports.encodeBatchExecution = _chunkGHGCGV3Ccjs.encodeBatchExecution; exports.encodeCalls = _chunkKIXYMA7Jcjs.encodeCalls; exports.encodeCallsForCaller = _chunkKIXYMA7Jcjs.encodeCallsForCaller; exports.encodeDelegation = _chunkGHGCGV3Ccjs.encodeDelegation; exports.encodeDelegations = _chunkGHGCGV3Ccjs.encodeDelegations; exports.encodeExecutionCalldata = _chunkGHGCGV3Ccjs.encodeExecutionCalldata; exports.encodeExecutionCalldatas = _chunkGHGCGV3Ccjs.encodeExecutionCalldatas; exports.encodeSingleExecution = _chunkGHGCGV3Ccjs.encodeSingleExecution; exports.generateSalt = _chunkIQT6XFDTcjs.generateSalt; exports.getCounterfactualAccountData = _chunkKIXYMA7Jcjs.getCounterfactualAccountData; exports.hashDelegation = _chunkGHGCGV3Ccjs.hashDelegation; exports.overrideDeployedEnvironment = _chunk2OS36DVVcjs.overrideDeployedEnvironment; exports.toDelegation = _chunkGHGCGV3Ccjs.toDelegation; exports.toDelegationStruct = _chunkGHGCGV3Ccjs.toDelegationStruct;
71
71
  //# sourceMappingURL=index.cjs.map
@@ -1,11 +1,11 @@
1
- export { d as decodeCaveat, a as deploySmartAccountsEnvironment, o as overrideDeployedEnvironment } from '../caveats-gqMBZKkI.cjs';
2
- export { D as DELEGATION_ABI_TYPE, d as DELEGATION_ABI_TYPE_COMPONENTS, e as DELEGATION_ARRAY_ABI_TYPE, f as DecodedRevertReason, g as DelegationStruct, S as SIGNABLE_DELEGATION_TYPED_DATA, h as decodeDelegation, i as decodeDelegations, j as decodeRevertData, k as decodeRevertReason, l as encodeDelegation, m as encodeDelegations, n as hashDelegation, t as toDelegation, o as toDelegationStruct } from '../decodeRevertReason-CmmCpmZ_.cjs';
3
- import { p as Call, I as Implementation, S as SmartAccountsEnvironment, q as DeployParams } from '../resolveCaveats-A9xC29l8.cjs';
4
- export { r as CaveatBuilder, s as CaveatBuilderConfig, t as CoreCaveatBuilder, e as ExecutionStruct, u as createCaveatBuilder, v as encodeBatchExecution, w as encodeExecutionCalldata, x as encodeExecutionCalldatas, y as encodeSingleExecution } from '../resolveCaveats-A9xC29l8.cjs';
1
+ export { d as decodeCaveat, a as deploySmartAccountsEnvironment, o as overrideDeployedEnvironment } from '../caveats-BEKgygS8.cjs';
2
+ export { e as DELEGATION_ABI_TYPE, f as DELEGATION_ABI_TYPE_COMPONENTS, g as DELEGATION_ARRAY_ABI_TYPE, D as DecodedRevertReason, d as DelegationStruct, S as SIGNABLE_DELEGATION_TYPED_DATA, h as decodeDelegation, i as decodeDelegations, j as decodeRevertData, k as decodeRevertReason, l as encodeDelegation, m as encodeDelegations, n as hashDelegation, t as toDelegation, o as toDelegationStruct } from '../decodeRevertReason-CSOClzsa.cjs';
3
+ import { p as Call, I as Implementation, S as SmartAccountsEnvironment, q as DeployParams } from '../resolveCaveats-aQPEogPk.cjs';
4
+ export { r as CaveatBuilder, s as CaveatBuilderConfig, t as CoreCaveatBuilder, e as ExecutionStruct, u as createCaveatBuilder, v as encodeBatchExecution, w as encodeExecutionCalldata, x as encodeExecutionCalldatas, y as encodeSingleExecution } from '../resolveCaveats-aQPEogPk.cjs';
5
5
  export { S as SIGNABLE_USER_OP_TYPED_DATA } from '../userOp-DKgjzz7B.cjs';
6
6
  import { Address, Hex } from 'viem';
7
7
  export { DELEGATION_TYPEHASH } from '@metamask/delegation-core';
8
- import '../index-B1Cmezvh.cjs';
8
+ import '../index-BHm75OFP.cjs';
9
9
  import '@metamask/delegation-abis';
10
10
  import 'viem/account-abstraction';
11
11
  import 'viem/chains';