{"version":3,"sources":["../src/permissions/caveats/erc20TokenAllowance.ts","../src/permissions/rules/expiry.ts","../src/permissions/utils.ts","../src/permissions/rules/payee.ts","../src/permissions/rules/redeemer.ts","../src/permissions/caveats/erc20TokenPeriodic.ts","../src/permissions/caveats/erc20TokenStream.ts","../src/permissions/caveats/nativeTokenAllowance.ts","../src/permissions/caveats/nativeTokenPeriodic.ts","../src/permissions/caveats/nativeTokenStream.ts","../src/permissions/caveats/tokenApprovalRevocation.ts","../src/permissions/schema/constants.ts","../src/permissions/schema/facilitatorAddresses.ts","../src/permissions/schema/utils.ts","../src/permissions/schema/sections.ts","../src/permissions/schema/erc20TokenAllowance.ts","../src/permissions/schema/erc20TokenPeriodic.ts","../src/permissions/schema/erc20TokenStream.ts","../src/permissions/schema/nativeTokenAllowance.ts","../src/permissions/schema/nativeTokenPeriodic.ts","../src/permissions/schema/nativeTokenStream.ts","../src/permissions/schema/tokenApprovalRevocation.ts","../src/permissions/schema/unknownPermissionType.ts","../src/permissions/schema/index.ts","../src/permissions/index.ts"],"sourcesContent":["import type { Caveat } from '@metamask/delegation-core';\nimport {\n  createERC20TokenPeriodTransferTerms,\n  createValueLteTerms,\n} from '@metamask/delegation-core';\nimport { hexToBigInt, hexToNumber } from '@metamask/utils';\n\nimport type { Erc20TokenAllowancePermission, Populated } from '../../types';\nimport { expiryRuleDecoder } from '../rules/expiry';\nimport { erc20PayeeRuleDecoder } from '../rules/payee';\nimport { redeemerRuleDecoder } from '../rules/redeemer';\nimport type {\n  ChecksumCaveat,\n  EnforcerAddressesByName,\n  DecodedPermissionData,\n  PermissionDecoderConfig,\n} from '../types';\nimport {\n  getByteLength,\n  getTermsByEnforcer,\n  splitHex,\n  UINT256_MAX,\n  ZERO_32_BYTES,\n} from '../utils';\n\n/**\n * Builds the configuration for the erc20-token-allowance permission decoder.\n *\n * @param contractAddresses - Checksummed enforcer addresses for the chain.\n * @returns The erc20-token-allowance permission decoder configuration.\n */\nexport function makeErc20TokenAllowanceDecoderConfig(\n  contractAddresses: EnforcerAddressesByName,\n): PermissionDecoderConfig {\n  const {\n    timestampEnforcer,\n    erc20PeriodTransferEnforcer,\n    valueLteEnforcer,\n    nonceEnforcer,\n    allowedCalldataEnforcer,\n    redeemerEnforcer,\n  } = contractAddresses;\n\n  return {\n    permissionType: 'erc20-token-allowance',\n    contractAddresses,\n    optionalEnforcers: [\n      timestampEnforcer, // expiry rule\n      redeemerEnforcer, // redeemer rule\n      allowedCalldataEnforcer, // payee rule\n    ],\n    requiredEnforcers: {\n      [erc20PeriodTransferEnforcer]: 1,\n      [valueLteEnforcer]: 1,\n      [nonceEnforcer]: 1,\n    },\n    rules: [expiryRuleDecoder, redeemerRuleDecoder, erc20PayeeRuleDecoder],\n    validateAndDecodeData,\n  };\n}\n\n/**\n * Decodes erc20-token-allowance permission data from caveats; throws on invalid.\n *\n * @param caveats - Caveats from the permission context (checksummed).\n * @param contractAddresses - Checksummed enforcer addresses for the chain.\n * @returns Decoded allowance terms.\n */\nfunction validateAndDecodeData(\n  caveats: ChecksumCaveat[],\n  contractAddresses: EnforcerAddressesByName,\n): DecodedPermissionData<Erc20TokenAllowancePermission> {\n  const { erc20PeriodTransferEnforcer, valueLteEnforcer } = contractAddresses;\n\n  const valueLteTerms = getTermsByEnforcer({\n    caveats,\n    enforcer: valueLteEnforcer,\n  });\n  if (valueLteTerms !== ZERO_32_BYTES) {\n    throw new Error(`Invalid value-lte terms: must be ${ZERO_32_BYTES}`);\n  }\n\n  const terms = getTermsByEnforcer({\n    caveats,\n    enforcer: erc20PeriodTransferEnforcer,\n  });\n\n  const EXPECTED_TERMS_BYTELENGTH = 116; // 20 + 32 + 32 + 32\n\n  if (getByteLength(terms) !== EXPECTED_TERMS_BYTELENGTH) {\n    throw new Error('Invalid erc20-token-allowance terms: expected 116 bytes');\n  }\n\n  const [tokenAddress, allowanceAmount, periodDurationRaw, startTimeRaw] =\n    splitHex(terms, [20, 32, 32, 32]);\n\n  if (periodDurationRaw.toLowerCase() !== UINT256_MAX) {\n    throw new Error(\n      'Invalid erc20-token-allowance terms: periodDuration must be UINT256_MAX',\n    );\n  }\n\n  const startTime = hexToNumber(startTimeRaw);\n\n  if (startTime === 0) {\n    throw new Error(\n      'Invalid erc20-token-allowance terms: startTime must be a positive number',\n    );\n  }\n\n  if (allowanceAmount === ZERO_32_BYTES) {\n    throw new Error(\n      'Invalid erc20-token-allowance terms: allowanceAmount must be a positive number',\n    );\n  }\n\n  return { tokenAddress, allowanceAmount, startTime };\n}\n\n/**\n * Enforcers required to build ERC-20 token allowance caveats.\n */\nexport type Erc20TokenAllowanceEnforcers = Pick<\n  EnforcerAddressesByName,\n  'erc20PeriodTransferEnforcer' | 'valueLteEnforcer'\n>;\n\n/**\n * Builds the erc20-token-allowance caveats required for this permission type.\n *\n * @param options0 - Caveat builder arguments.\n * @param options0.permission - Fully populated erc20-token-allowance permission data.\n * @param options0.contracts - Enforcer addresses used to construct caveats.\n * @returns The ERC-20 allowance and zero-value caveats.\n */\nexport function createErc20TokenAllowanceCaveats({\n  permission,\n  contracts,\n}: {\n  permission: Populated<Erc20TokenAllowancePermission>;\n  contracts: Erc20TokenAllowanceEnforcers;\n}): Caveat[] {\n  const { tokenAddress, allowanceAmount, startTime } = permission.data;\n  const allowanceAmountBigInt = hexToBigInt(allowanceAmount);\n\n  if (allowanceAmountBigInt === 0n) {\n    throw new Error(\n      'Invalid erc20-token-allowance permission: allowanceAmount must be a positive number.',\n    );\n  }\n\n  if (startTime <= 0) {\n    throw new Error(\n      'Invalid erc20-token-allowance permission: startTime must be a positive number.',\n    );\n  }\n\n  const erc20PeriodCaveat: Caveat = {\n    enforcer: contracts.erc20PeriodTransferEnforcer,\n    terms: createERC20TokenPeriodTransferTerms({\n      tokenAddress,\n      periodAmount: allowanceAmountBigInt,\n      // delegation-core accepts bigint for encoding although the type is `number`.\n      periodDuration: BigInt(UINT256_MAX) as unknown as number,\n      startDate: startTime,\n    }),\n    args: '0x',\n  };\n\n  const valueLteCaveat: Caveat = {\n    enforcer: contracts.valueLteEnforcer,\n    terms: createValueLteTerms({ maxValue: 0n }),\n    args: '0x',\n  };\n\n  return [erc20PeriodCaveat, valueLteCaveat];\n}\n","import { decodeTimestampTerms } from '@metamask/delegation-core';\n\nimport type { RuleDecoder } from '../types';\nimport { getTermsByEnforcer } from '../utils';\n\nexport const EXECUTION_PERMISSION_EXPIRY_RULE_TYPE = 'expiry' as const;\n\n/**\n * Execution permission rule derived from TimestampEnforcer caveats.\n */\nexport type ExpiryRule = {\n  type: 'expiry';\n  data: {\n    timestamp: number;\n  };\n};\n\n/**\n * Rule decoder that extracts the expiry timestamp from a TimestampEnforcer\n * caveat, when present.\n *\n * @param options0 - Rule decoder arguments.\n * @param options0.contractAddresses - Checksummed enforcer addresses for the chain.\n * @param options0.caveats - Checksummed caveats from the delegation.\n * @returns The decoded expiry rule when present, otherwise `null`.\n */\nexport const expiryRuleDecoder: RuleDecoder = ({\n  contractAddresses,\n  caveats,\n}) => {\n  const { timestampEnforcer } = contractAddresses;\n\n  const expiryTerms = getTermsByEnforcer({\n    caveats,\n    enforcer: timestampEnforcer,\n    throwIfNotFound: false,\n  });\n\n  if (!expiryTerms) {\n    return null;\n  }\n\n  if (expiryTerms.length !== 66) {\n    throw new Error('Invalid TimestampEnforcer terms length');\n  }\n\n  const decodedTerms = decodeTimestampTerms(expiryTerms);\n  const timestampBeforeThreshold = Number(decodedTerms.beforeThreshold);\n  const timestampAfterThreshold = Number(decodedTerms.afterThreshold);\n\n  if (timestampBeforeThreshold <= 0) {\n    throw new Error(\n      'Invalid expiry: timestampBeforeThreshold must be greater than 0',\n    );\n  }\n\n  if (timestampAfterThreshold !== 0) {\n    throw new Error('Invalid expiry: timestampAfterThreshold must be 0');\n  }\n\n  return {\n    type: EXECUTION_PERMISSION_EXPIRY_RULE_TYPE,\n    data: { timestamp: timestampBeforeThreshold },\n  };\n};\n","import { getChecksumAddress } from '@metamask/utils';\n\nimport type { ChecksumCaveat, EnforcerAddressesByName } from './types';\nimport type { Hex } from '../types';\n\n/**\n * 32 bytes of zero (0x + 64 hex chars).\n */\nexport const ZERO_32_BYTES =\n  '0x0000000000000000000000000000000000000000000000000000000000000000' as const;\n\n/**\n * Maximum unsigned 256-bit integer encoded as 32 bytes (0x + 64 hex chars).\n */\nexport const UINT256_MAX =\n  '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' as const;\n\n/** AllowedCalldataEnforcer terms for ERC20 approve selector. */\nexport const ERC20_APPROVE_SELECTOR_TERMS =\n  '0x0000000000000000000000000000000000000000000000000000000000000000095ea7b3' as const;\n\n/** AllowedCalldataEnforcer terms for ERC20 approve zero amount. */\nexport const ERC20_APPROVE_ZERO_AMOUNT_TERMS =\n  '0x00000000000000000000000000000000000000000000000000000000000000240000000000000000000000000000000000000000000000000000000000000000' as const;\n\n/** Maximum period duration in seconds. */\nexport const MAX_PERIOD_DURATION = 10 * 365 * 24 * 60 * 60;\n\n/**\n * Gets the terms for a given enforcer from a list of caveats.\n *\n * @param options0 - Terms lookup arguments.\n * @param options0.caveats - Caveats to search.\n * @param options0.enforcer - Enforcer address to match.\n * @param options0.throwIfNotFound - Whether to throw if no match is found.\n * @returns The matched terms, or `null` when disabled and no caveat is found.\n */\nexport function getTermsByEnforcer({\n  caveats,\n  enforcer,\n  throwIfNotFound,\n}: {\n  caveats: ChecksumCaveat[];\n  enforcer: Hex;\n  throwIfNotFound?: true;\n}): Hex;\nexport function getTermsByEnforcer({\n  caveats,\n  enforcer,\n  throwIfNotFound,\n}: {\n  caveats: ChecksumCaveat[];\n  enforcer: Hex;\n  throwIfNotFound: false;\n}): Hex | null;\n/**\n * Implementation signature for getTermsByEnforcer overloads.\n *\n * @param options0 - Terms lookup arguments.\n * @param options0.caveats - Caveats to search.\n * @param options0.enforcer - Enforcer address to match.\n * @param options0.throwIfNotFound - Whether to throw if no match is found.\n * @returns The matched terms, or `null` when disabled and no caveat is found.\n */\nexport function getTermsByEnforcer({\n  caveats,\n  enforcer,\n  throwIfNotFound = true,\n}: {\n  caveats: ChecksumCaveat[];\n  enforcer: Hex;\n  throwIfNotFound?: boolean;\n}): Hex | null {\n  let matchingCaveat: ChecksumCaveat | undefined;\n\n  for (const caveat of caveats) {\n    if (caveat.enforcer !== enforcer) {\n      continue;\n    }\n\n    if (matchingCaveat) {\n      throw new Error(\n        `Invalid caveats: multiple caveats found matching enforcer ${enforcer}`,\n      );\n    }\n\n    matchingCaveat = caveat;\n  }\n\n  if (!matchingCaveat) {\n    if (throwIfNotFound) {\n      throw new Error(\n        `Invalid caveats: no caveat found matching enforcer ${enforcer}`,\n      );\n    }\n\n    return null;\n  }\n\n  return matchingCaveat.terms;\n}\n\n/**\n * Get the byte length of a hex string.\n *\n * @param hexString - A 0x-prefixed hex string.\n * @returns The byte length of the provided hex string.\n */\nexport const getByteLength = (hexString: Hex): number => {\n  return (hexString.length - 2) / 2;\n};\n\n/**\n * A tuple of TElement, the same length as the specified type TInput\n */\ntype Tuple<TElement, TInput extends readonly unknown[]> = {\n  [K in keyof TInput]: TElement;\n};\n\n/**\n * Splits a 0x-prefixed hex string into parts according to the provided byte lengths.\n *\n * @param value - The hex value to split.\n * @param lengths - Segment lengths in bytes.\n * @returns The split hex segments, each with `0x` prefix.\n */\nexport function splitHex<const TLengths extends readonly number[]>(\n  value: Hex,\n  lengths: TLengths,\n): Tuple<Hex, TLengths> {\n  let start = 2;\n  const parts: Hex[] = [];\n  for (const partLength of lengths) {\n    const partCharLength = partLength * 2;\n    const part = value.slice(start, start + partCharLength);\n    start += partCharLength;\n    parts.push(`0x${part}` as const);\n  }\n  return parts as Tuple<Hex, TLengths>;\n}\n\n/**\n * Resolves and returns checksummed enforcer addresses from deployed contracts.\n *\n * @param contracts - Deployed contract-name-to-address map for a chain.\n * @returns Checksummed enforcer addresses keyed by known enforcer role.\n */\nexport const checksumEnforcerAddresses = (\n  contracts: EnforcerAddressesByName,\n): EnforcerAddressesByName => {\n  return {\n    erc20StreamingEnforcer: getChecksumAddress(\n      contracts.erc20StreamingEnforcer,\n    ),\n    erc20PeriodTransferEnforcer: getChecksumAddress(\n      contracts.erc20PeriodTransferEnforcer,\n    ),\n    nativeTokenStreamingEnforcer: getChecksumAddress(\n      contracts.nativeTokenStreamingEnforcer,\n    ),\n    nativeTokenPeriodTransferEnforcer: getChecksumAddress(\n      contracts.nativeTokenPeriodTransferEnforcer,\n    ),\n    approvalRevocationEnforcer: getChecksumAddress(\n      contracts.approvalRevocationEnforcer,\n    ),\n    exactCalldataEnforcer: getChecksumAddress(contracts.exactCalldataEnforcer),\n    valueLteEnforcer: getChecksumAddress(contracts.valueLteEnforcer),\n    timestampEnforcer: getChecksumAddress(contracts.timestampEnforcer),\n    nonceEnforcer: getChecksumAddress(contracts.nonceEnforcer),\n    allowedCalldataEnforcer: getChecksumAddress(\n      contracts.allowedCalldataEnforcer,\n    ),\n    allowedTargetsEnforcer: getChecksumAddress(\n      contracts.allowedTargetsEnforcer,\n    ),\n    redeemerEnforcer: getChecksumAddress(contracts.redeemerEnforcer),\n  };\n};\n","import {\n  decodeAllowedCalldataTerms,\n  decodeAllowedTargetsTerms,\n} from '@metamask/delegation-core';\nimport { getChecksumAddress } from '@metamask/utils';\n\nimport type { Hex } from '../../types';\nimport type { RuleDecoder } from '../types';\nimport { getByteLength, getTermsByEnforcer } from '../utils';\n\nexport const EXECUTION_PERMISSION_PAYEE_RULE_TYPE = 'payee' as const;\n\nconst ERC20_TRANSFER_PAYEE_START_INDEX = 4;\nconst ERC20_PAYEE_VALUE_BYTE_LENGTH = 32;\n\n/**\n * Execution permission rule restricting which addresses may receive payments\n * (on-chain AllowedCalldataEnforcer / AllowedTargetsEnforcer caveat).\n */\nexport type PayeeRule = {\n  type: 'payee';\n  data: {\n    addresses: Hex[];\n  };\n};\n\n/**\n * Rule decoder for ERC-20 style payees from AllowedCalldataEnforcer caveats.\n *\n * @param options0 - Rule decoder arguments.\n * @param options0.contractAddresses - Checksummed enforcer addresses for the chain.\n * @param options0.caveats - Checksummed caveats from the delegation.\n * @param options0.requiredEnforcers - Required enforcer counts for this decoder.\n * @returns The decoded payee rule when present, otherwise `null`.\n */\nexport const erc20PayeeRuleDecoder: RuleDecoder = ({\n  contractAddresses,\n  caveats,\n  requiredEnforcers,\n}) => {\n  const { allowedCalldataEnforcer } = contractAddresses;\n\n  if (requiredEnforcers.has(allowedCalldataEnforcer)) {\n    throw new Error(\n      'Invalid payee caveats: payee enforcer may not be a required caveat',\n    );\n  }\n\n  const terms = getTermsByEnforcer({\n    caveats,\n    enforcer: allowedCalldataEnforcer,\n    throwIfNotFound: false,\n  });\n\n  if (!terms) {\n    return null;\n  }\n\n  const decoded = decodeAllowedCalldataTerms(terms);\n\n  if (decoded.startIndex !== ERC20_TRANSFER_PAYEE_START_INDEX) {\n    throw new Error(\n      `Invalid payee caveat: AllowedCalldataEnforcer startIndex must be ${ERC20_TRANSFER_PAYEE_START_INDEX}`,\n    );\n  }\n\n  if (getByteLength(decoded.value) !== ERC20_PAYEE_VALUE_BYTE_LENGTH) {\n    throw new Error(\n      `Invalid payee caveat: AllowedCalldataEnforcer value must be ${ERC20_PAYEE_VALUE_BYTE_LENGTH} bytes long`,\n    );\n  }\n\n  const address: Hex = `0x${decoded.value.slice(-40)}`;\n\n  return {\n    type: EXECUTION_PERMISSION_PAYEE_RULE_TYPE,\n    data: { addresses: [getChecksumAddress(address)] },\n  };\n};\n\n/**\n * Rule decoder for native-token style payees from AllowedTargetsEnforcer caveats.\n *\n * @param options0 - Rule decoder arguments.\n * @param options0.contractAddresses - Checksummed enforcer addresses for the chain.\n * @param options0.caveats - Checksummed caveats from the delegation.\n * @param options0.requiredEnforcers - Required enforcer counts for this decoder.\n * @returns The decoded payee rule when present, otherwise `null`.\n */\nexport const nativePayeeRuleDecoder: RuleDecoder = ({\n  contractAddresses,\n  caveats,\n  requiredEnforcers,\n}) => {\n  const { allowedTargetsEnforcer } = contractAddresses;\n\n  if (requiredEnforcers.has(allowedTargetsEnforcer)) {\n    throw new Error(\n      'Invalid payee caveats: payee enforcer may not be a required caveat',\n    );\n  }\n\n  const terms = getTermsByEnforcer({\n    caveats,\n    enforcer: allowedTargetsEnforcer,\n    throwIfNotFound: false,\n  });\n\n  if (!terms) {\n    return null;\n  }\n\n  const decoded = decodeAllowedTargetsTerms(terms);\n\n  return {\n    type: EXECUTION_PERMISSION_PAYEE_RULE_TYPE,\n    data: { addresses: decoded.targets.map(getChecksumAddress) },\n  };\n};\n","import { decodeRedeemerTerms } from '@metamask/delegation-core';\nimport { getChecksumAddress } from '@metamask/utils';\n\nimport type { Hex } from '../../types';\nimport type { RuleDecoder } from '../types';\nimport { getTermsByEnforcer } from '../utils';\n\nexport const EXECUTION_PERMISSION_REDEEMER_RULE_TYPE = 'redeemer' as const;\n\n/**\n * Execution permission rule restricting which addresses may redeem the delegation\n * (on-chain RedeemerEnforcer caveat).\n */\nexport type RedeemerRule = {\n  type: 'redeemer';\n  data: {\n    addresses: Hex[];\n  };\n};\n\n/**\n * Rule decoder that extracts a redeemer allowlist from a RedeemerEnforcer caveat.\n *\n * @param options0 - Rule decoder arguments.\n * @param options0.contractAddresses - Checksummed enforcer addresses for the chain.\n * @param options0.caveats - Checksummed caveats from the delegation.\n * @returns The decoded redeemer rule when present, otherwise `null`.\n */\nexport const redeemerRuleDecoder: RuleDecoder = ({\n  contractAddresses,\n  caveats,\n}) => {\n  const { redeemerEnforcer } = contractAddresses;\n\n  const terms = getTermsByEnforcer({\n    caveats,\n    enforcer: redeemerEnforcer,\n    throwIfNotFound: false,\n  });\n\n  if (!terms) {\n    return null;\n  }\n\n  const { redeemers } = decodeRedeemerTerms(terms);\n\n  const addresses = redeemers.map(getChecksumAddress);\n\n  return {\n    type: EXECUTION_PERMISSION_REDEEMER_RULE_TYPE,\n    data: {\n      addresses,\n    },\n  };\n};\n","import type { Caveat } from '@metamask/delegation-core';\nimport {\n  createERC20TokenPeriodTransferTerms,\n  createValueLteTerms,\n  decodeERC20TokenPeriodTransferTerms,\n} from '@metamask/delegation-core';\nimport { bigIntToHex, hexToBigInt } from '@metamask/utils';\n\nimport type { Erc20TokenPeriodicPermission, Populated } from '../../types';\nimport { expiryRuleDecoder } from '../rules/expiry';\nimport { erc20PayeeRuleDecoder } from '../rules/payee';\nimport { redeemerRuleDecoder } from '../rules/redeemer';\nimport type {\n  ChecksumCaveat,\n  EnforcerAddressesByName,\n  DecodedPermissionData,\n  PermissionDecoderConfig,\n} from '../types';\nimport {\n  getTermsByEnforcer,\n  MAX_PERIOD_DURATION,\n  ZERO_32_BYTES,\n} from '../utils';\n\n/**\n * Builds the configuration for the erc20-token-periodic permission decoder.\n *\n * @param contractAddresses - Checksummed enforcer addresses for the chain.\n * @returns The erc20-token-periodic permission decoder configuration.\n */\nexport function makeErc20TokenPeriodicDecoderConfig(\n  contractAddresses: EnforcerAddressesByName,\n): PermissionDecoderConfig {\n  const {\n    timestampEnforcer,\n    erc20PeriodTransferEnforcer,\n    valueLteEnforcer,\n    nonceEnforcer,\n    allowedCalldataEnforcer,\n    redeemerEnforcer,\n  } = contractAddresses;\n\n  return {\n    permissionType: 'erc20-token-periodic',\n    contractAddresses,\n    optionalEnforcers: [\n      timestampEnforcer, // expiry rule\n      redeemerEnforcer, // redeemer rule\n      allowedCalldataEnforcer, // payee rule\n    ],\n    requiredEnforcers: {\n      [erc20PeriodTransferEnforcer]: 1,\n      [valueLteEnforcer]: 1,\n      [nonceEnforcer]: 1,\n    },\n    rules: [expiryRuleDecoder, redeemerRuleDecoder, erc20PayeeRuleDecoder],\n    validateAndDecodeData,\n  };\n}\n\n/**\n * Decodes erc20-token-periodic permission data from caveats; throws on invalid.\n *\n * @param caveats - Caveats from the permission context (checksummed).\n * @param contractAddresses - Checksummed enforcer addresses for the chain.\n * @returns Decoded periodic terms.\n */\nfunction validateAndDecodeData(\n  caveats: ChecksumCaveat[],\n  contractAddresses: EnforcerAddressesByName,\n): DecodedPermissionData<Erc20TokenPeriodicPermission> {\n  const { erc20PeriodTransferEnforcer, valueLteEnforcer } = contractAddresses;\n\n  const valueLteTerms = getTermsByEnforcer({\n    caveats,\n    enforcer: valueLteEnforcer,\n  });\n  if (valueLteTerms !== ZERO_32_BYTES) {\n    throw new Error(`Invalid value-lte terms: must be ${ZERO_32_BYTES}`);\n  }\n\n  const terms = getTermsByEnforcer({\n    caveats,\n    enforcer: erc20PeriodTransferEnforcer,\n  });\n\n  const {\n    tokenAddress,\n    periodAmount,\n    periodDuration,\n    startDate: startTime,\n  } = decodeERC20TokenPeriodTransferTerms(terms);\n\n  if (periodAmount === 0n) {\n    throw new Error(\n      'Invalid erc20-token-periodic terms: periodAmount must be a positive number',\n    );\n  }\n\n  if (periodDuration === 0) {\n    throw new Error(\n      'Invalid erc20-token-periodic terms: periodDuration must be a positive number',\n    );\n  }\n\n  if (periodDuration > MAX_PERIOD_DURATION) {\n    throw new Error(\n      'Invalid erc20-token-periodic terms: periodDuration must be less than or equal to MAX_PERIOD_DURATION',\n    );\n  }\n\n  if (startTime === 0) {\n    throw new Error(\n      'Invalid erc20-token-periodic terms: startTime must be a positive number',\n    );\n  }\n\n  return {\n    tokenAddress,\n    periodAmount: bigIntToHex(periodAmount),\n    periodDuration,\n    startTime,\n  };\n}\n\n/**\n * Enforcers required to build ERC-20 token periodic caveats.\n */\nexport type Erc20TokenPeriodicEnforcers = Pick<\n  EnforcerAddressesByName,\n  'erc20PeriodTransferEnforcer' | 'valueLteEnforcer'\n>;\n\n/**\n * Builds the erc20-token-periodic caveats required for this permission type.\n *\n * @param options0 - Caveat builder arguments.\n * @param options0.permission - Fully populated erc20-token-periodic permission data.\n * @param options0.contracts - Enforcer addresses used to construct caveats.\n * @returns The ERC-20 periodic and zero-value caveats.\n */\nexport function createErc20TokenPeriodicCaveats({\n  permission,\n  contracts,\n}: {\n  permission: Populated<Erc20TokenPeriodicPermission>;\n  contracts: Erc20TokenPeriodicEnforcers;\n}): Caveat[] {\n  const { tokenAddress, periodAmount, periodDuration, startTime } =\n    permission.data;\n  const periodAmountBigInt = hexToBigInt(periodAmount);\n\n  if (periodAmountBigInt === 0n) {\n    throw new Error(\n      'Invalid erc20-token-periodic permission: periodAmount must be a positive number.',\n    );\n  }\n\n  if (periodDuration <= 0) {\n    throw new Error(\n      'Invalid erc20-token-periodic permission: periodDuration must be a positive number.',\n    );\n  }\n\n  if (periodDuration > MAX_PERIOD_DURATION) {\n    throw new Error(\n      'Invalid erc20-token-periodic permission: periodDuration must be less than or equal to MAX_PERIOD_DURATION.',\n    );\n  }\n\n  if (startTime <= 0) {\n    throw new Error(\n      'Invalid erc20-token-periodic permission: startTime must be a positive number.',\n    );\n  }\n\n  const erc20PeriodCaveat: Caveat = {\n    enforcer: contracts.erc20PeriodTransferEnforcer,\n    terms: createERC20TokenPeriodTransferTerms({\n      tokenAddress,\n      periodAmount: periodAmountBigInt,\n      periodDuration,\n      startDate: startTime,\n    }),\n    args: '0x',\n  };\n\n  const valueLteCaveat: Caveat = {\n    enforcer: contracts.valueLteEnforcer,\n    terms: createValueLteTerms({ maxValue: 0n }),\n    args: '0x',\n  };\n\n  return [erc20PeriodCaveat, valueLteCaveat];\n}\n","import type { Caveat } from '@metamask/delegation-core';\nimport {\n  createERC20StreamingTerms,\n  createValueLteTerms,\n  decodeERC20StreamingTerms,\n} from '@metamask/delegation-core';\nimport { bigIntToHex, hexToBigInt } from '@metamask/utils';\n\nimport type { Erc20TokenStreamPermission, Populated } from '../../types';\nimport { expiryRuleDecoder } from '../rules/expiry';\nimport { erc20PayeeRuleDecoder } from '../rules/payee';\nimport { redeemerRuleDecoder } from '../rules/redeemer';\nimport type {\n  ChecksumCaveat,\n  DecodedPermissionData,\n  EnforcerAddressesByName,\n  PermissionDecoderConfig,\n} from '../types';\nimport { getTermsByEnforcer, ZERO_32_BYTES } from '../utils';\n\n/**\n * Builds the configuration for the erc20-token-stream permission decoder.\n *\n * @param contractAddresses - Checksummed enforcer addresses for the chain.\n * @returns The erc20-token-stream permission decoder configuration.\n */\nexport function makeErc20TokenStreamDecoderConfig(\n  contractAddresses: EnforcerAddressesByName,\n): PermissionDecoderConfig {\n  const {\n    timestampEnforcer,\n    erc20StreamingEnforcer,\n    valueLteEnforcer,\n    nonceEnforcer,\n    allowedCalldataEnforcer,\n    redeemerEnforcer,\n  } = contractAddresses;\n\n  return {\n    permissionType: 'erc20-token-stream',\n    contractAddresses,\n    optionalEnforcers: [\n      timestampEnforcer, // expiry rule\n      redeemerEnforcer, // redeemer rule\n      allowedCalldataEnforcer, // payee rule\n    ],\n    requiredEnforcers: {\n      [erc20StreamingEnforcer]: 1,\n      [valueLteEnforcer]: 1,\n      [nonceEnforcer]: 1,\n    },\n    rules: [expiryRuleDecoder, redeemerRuleDecoder, erc20PayeeRuleDecoder],\n    validateAndDecodeData,\n  };\n}\n\n/**\n * Decodes erc20-token-stream permission data from caveats; throws on invalid.\n *\n * @param caveats - Caveats from the permission context (checksummed).\n * @param contractAddresses - Checksummed enforcer addresses for the chain.\n * @returns Decoded stream terms.\n */\nfunction validateAndDecodeData(\n  caveats: ChecksumCaveat[],\n  contractAddresses: EnforcerAddressesByName,\n): DecodedPermissionData<Erc20TokenStreamPermission> {\n  const { erc20StreamingEnforcer, valueLteEnforcer } = contractAddresses;\n\n  const valueLteTerms = getTermsByEnforcer({\n    caveats,\n    enforcer: valueLteEnforcer,\n  });\n\n  if (valueLteTerms !== ZERO_32_BYTES) {\n    throw new Error(`Invalid value-lte terms: must be ${ZERO_32_BYTES}`);\n  }\n\n  const terms = getTermsByEnforcer({\n    caveats,\n    enforcer: erc20StreamingEnforcer,\n  });\n  const { tokenAddress, initialAmount, maxAmount, amountPerSecond, startTime } =\n    decodeERC20StreamingTerms(terms);\n\n  if (maxAmount <= initialAmount) {\n    throw new Error(\n      'Invalid erc20-token-stream terms: maxAmount must be greater than initialAmount',\n    );\n  }\n\n  if (amountPerSecond === 0n) {\n    throw new Error(\n      'Invalid erc20-token-stream terms: amountPerSecond must be a positive number',\n    );\n  }\n\n  if (startTime === 0) {\n    throw new Error(\n      'Invalid erc20-token-stream terms: startTime must be a positive number',\n    );\n  }\n\n  return {\n    tokenAddress,\n    initialAmount: bigIntToHex(initialAmount),\n    maxAmount: bigIntToHex(maxAmount),\n    amountPerSecond: bigIntToHex(amountPerSecond),\n    startTime,\n  };\n}\n\n/**\n * Enforcers required to build ERC-20 token stream caveats.\n */\nexport type Erc20TokenStreamEnforcers = Pick<\n  EnforcerAddressesByName,\n  'erc20StreamingEnforcer' | 'valueLteEnforcer'\n>;\n\n/**\n * Builds the ERC-20 stream caveats required for this permission type.\n *\n * @param options0 - Caveat builder arguments.\n * @param options0.permission - Fully populated ERC-20 stream permission data.\n * @param options0.contracts - Enforcer addresses used to construct caveats.\n * @returns The ERC20 streaming and zero-value caveats.\n */\nexport function createErc20TokenStreamCaveats({\n  permission,\n  contracts,\n}: {\n  permission: Populated<Erc20TokenStreamPermission>;\n  contracts: Erc20TokenStreamEnforcers;\n}): Caveat[] {\n  const { initialAmount, maxAmount, amountPerSecond, startTime } =\n    permission.data;\n  const initialAmountBigInt = hexToBigInt(initialAmount);\n  const maxAmountBigInt = hexToBigInt(maxAmount);\n  const amountPerSecondBigInt = hexToBigInt(amountPerSecond);\n\n  if (maxAmountBigInt <= initialAmountBigInt) {\n    throw new Error(\n      'Invalid erc20-token-stream permission: maxAmount must be greater than initialAmount.',\n    );\n  }\n\n  if (amountPerSecondBigInt === 0n) {\n    throw new Error(\n      'Invalid erc20-token-stream permission: amountPerSecond must be a positive number.',\n    );\n  }\n\n  if (startTime <= 0) {\n    throw new Error(\n      'Invalid erc20-token-stream permission: startTime must be a positive number.',\n    );\n  }\n\n  // ERC20StreamingEnforcer: enforce token address, initial/max amount, amount per second, and start time.\n  const erc20StreamingCaveat: Caveat = {\n    enforcer: contracts.erc20StreamingEnforcer,\n    terms: createERC20StreamingTerms({\n      tokenAddress: permission.data.tokenAddress,\n      initialAmount: initialAmountBigInt,\n      maxAmount: maxAmountBigInt,\n      amountPerSecond: amountPerSecondBigInt,\n      startTime,\n    }),\n    args: '0x',\n  };\n\n  // ValueLteEnforcer: allow no native value (e.g. msg.value must be 0).\n  const valueLteCaveat: Caveat = {\n    enforcer: contracts.valueLteEnforcer,\n    terms: createValueLteTerms({\n      maxValue: 0n,\n    }),\n    args: '0x',\n  };\n\n  return [erc20StreamingCaveat, valueLteCaveat];\n}\n","import type { Caveat } from '@metamask/delegation-core';\nimport {\n  createExactCalldataTerms,\n  createNativeTokenPeriodTransferTerms,\n} from '@metamask/delegation-core';\nimport { hexToBigInt, hexToNumber } from '@metamask/utils';\n\nimport type { NativeTokenAllowancePermission, Populated } from '../../types';\nimport { expiryRuleDecoder } from '../rules/expiry';\nimport { nativePayeeRuleDecoder } from '../rules/payee';\nimport { redeemerRuleDecoder } from '../rules/redeemer';\nimport type {\n  ChecksumCaveat,\n  EnforcerAddressesByName,\n  DecodedPermissionData,\n  PermissionDecoderConfig,\n} from '../types';\nimport {\n  getByteLength,\n  getTermsByEnforcer,\n  splitHex,\n  UINT256_MAX,\n  ZERO_32_BYTES,\n} from '../utils';\n\n/**\n * Builds the configuration for the native-token-allowance permission decoder.\n *\n * @param contractAddresses - Checksummed enforcer addresses for the chain.\n * @returns The native-token-allowance permission decoder configuration.\n */\nexport function makeNativeTokenAllowanceDecoderConfig(\n  contractAddresses: EnforcerAddressesByName,\n): PermissionDecoderConfig {\n  const {\n    timestampEnforcer,\n    nativeTokenPeriodTransferEnforcer,\n    exactCalldataEnforcer,\n    nonceEnforcer,\n    allowedTargetsEnforcer,\n    redeemerEnforcer,\n  } = contractAddresses;\n\n  return {\n    permissionType: 'native-token-allowance',\n    contractAddresses,\n    optionalEnforcers: [\n      timestampEnforcer, // expiry rule\n      redeemerEnforcer, // redeemer rule\n      allowedTargetsEnforcer, // payee rule\n    ],\n    requiredEnforcers: {\n      [nativeTokenPeriodTransferEnforcer]: 1,\n      [exactCalldataEnforcer]: 1,\n      [nonceEnforcer]: 1,\n    },\n    rules: [expiryRuleDecoder, redeemerRuleDecoder, nativePayeeRuleDecoder],\n    validateAndDecodeData,\n  };\n}\n\n/**\n * Decodes native-token-allowance permission data from caveats; throws on invalid.\n *\n * @param caveats - Caveats from the permission context (checksummed).\n * @param contractAddresses - Checksummed enforcer addresses for the chain.\n * @returns Decoded allowance terms.\n */\nfunction validateAndDecodeData(\n  caveats: ChecksumCaveat[],\n  contractAddresses: EnforcerAddressesByName,\n): DecodedPermissionData<NativeTokenAllowancePermission> {\n  const { nativeTokenPeriodTransferEnforcer, exactCalldataEnforcer } =\n    contractAddresses;\n\n  const exactCalldataTerms = getTermsByEnforcer({\n    caveats,\n    enforcer: exactCalldataEnforcer,\n  });\n\n  if (exactCalldataTerms !== '0x') {\n    throw new Error('Invalid exact-calldata terms: must be 0x');\n  }\n\n  const terms = getTermsByEnforcer({\n    caveats,\n    enforcer: nativeTokenPeriodTransferEnforcer,\n  });\n\n  const EXPECTED_TERMS_BYTELENGTH = 96; // 32 + 32 + 32\n\n  if (getByteLength(terms) !== EXPECTED_TERMS_BYTELENGTH) {\n    throw new Error('Invalid native-token-allowance terms: expected 96 bytes');\n  }\n\n  const [allowanceAmount, periodDurationRaw, startTimeRaw] = splitHex(\n    terms,\n    [32, 32, 32],\n  );\n\n  if (periodDurationRaw.toLowerCase() !== UINT256_MAX) {\n    throw new Error(\n      'Invalid native-token-allowance terms: periodDuration must be UINT256_MAX',\n    );\n  }\n\n  const startTime = hexToNumber(startTimeRaw);\n\n  if (startTime === 0) {\n    throw new Error(\n      'Invalid native-token-allowance terms: startTime must be a positive number',\n    );\n  }\n\n  if (allowanceAmount === ZERO_32_BYTES) {\n    throw new Error(\n      'Invalid native-token-allowance terms: allowanceAmount must be a positive number',\n    );\n  }\n\n  return { allowanceAmount, startTime };\n}\n\n/**\n * Enforcers required to build native token allowance caveats.\n */\nexport type NativeTokenAllowanceEnforcers = Pick<\n  EnforcerAddressesByName,\n  'nativeTokenPeriodTransferEnforcer' | 'exactCalldataEnforcer'\n>;\n\n/**\n * Builds the native-token-allowance caveats required for this permission type.\n *\n * @param options0 - Caveat builder arguments.\n * @param options0.permission - Fully populated native-token-allowance permission data.\n * @param options0.contracts - Enforcer addresses used to construct caveats.\n * @returns The native token allowance and exact-calldata caveats.\n */\nexport function createNativeTokenAllowanceCaveats({\n  permission,\n  contracts,\n}: {\n  permission: Populated<NativeTokenAllowancePermission>;\n  contracts: NativeTokenAllowanceEnforcers;\n}): Caveat[] {\n  const { allowanceAmount, startTime } = permission.data;\n  const allowanceAmountBigInt = hexToBigInt(allowanceAmount);\n\n  if (allowanceAmountBigInt === 0n) {\n    throw new Error(\n      'Invalid native-token-allowance permission: allowanceAmount must be a positive number.',\n    );\n  }\n\n  if (startTime <= 0) {\n    throw new Error(\n      'Invalid native-token-allowance permission: startTime must be a positive number.',\n    );\n  }\n\n  const nativeTokenPeriodTransferCaveat: Caveat = {\n    enforcer: contracts.nativeTokenPeriodTransferEnforcer,\n    terms: createNativeTokenPeriodTransferTerms({\n      periodAmount: allowanceAmountBigInt,\n      // delegation-core accepts bigint for encoding although the type is `number`.\n      periodDuration: BigInt(UINT256_MAX) as unknown as number,\n      startDate: startTime,\n    }),\n    args: '0x',\n  };\n\n  const exactCalldataCaveat: Caveat = {\n    enforcer: contracts.exactCalldataEnforcer,\n    terms: createExactCalldataTerms({ calldata: '0x' }),\n    args: '0x',\n  };\n\n  return [nativeTokenPeriodTransferCaveat, exactCalldataCaveat];\n}\n","import type { Caveat } from '@metamask/delegation-core';\nimport {\n  createExactCalldataTerms,\n  createNativeTokenPeriodTransferTerms,\n  decodeNativeTokenPeriodTransferTerms,\n} from '@metamask/delegation-core';\nimport { bigIntToHex, hexToBigInt } from '@metamask/utils';\n\nimport type { NativeTokenPeriodicPermission, Populated } from '../../types';\nimport { expiryRuleDecoder } from '../rules/expiry';\nimport { nativePayeeRuleDecoder } from '../rules/payee';\nimport { redeemerRuleDecoder } from '../rules/redeemer';\nimport type {\n  ChecksumCaveat,\n  EnforcerAddressesByName,\n  DecodedPermissionData,\n  PermissionDecoderConfig,\n} from '../types';\nimport { getTermsByEnforcer, MAX_PERIOD_DURATION } from '../utils';\n\n/**\n * Builds the configuration for the native-token-periodic permission decoder.\n *\n * @param contractAddresses - Checksummed enforcer addresses for the chain.\n * @returns The native-token-periodic permission decoder configuration.\n */\nexport function makeNativeTokenPeriodicDecoderConfig(\n  contractAddresses: EnforcerAddressesByName,\n): PermissionDecoderConfig {\n  const {\n    timestampEnforcer,\n    nativeTokenPeriodTransferEnforcer,\n    exactCalldataEnforcer,\n    nonceEnforcer,\n    allowedTargetsEnforcer,\n    redeemerEnforcer,\n  } = contractAddresses;\n\n  return {\n    permissionType: 'native-token-periodic',\n    contractAddresses,\n    optionalEnforcers: [\n      timestampEnforcer, // expiry rule\n      redeemerEnforcer, // redeemer rule\n      allowedTargetsEnforcer, // payee rule\n    ],\n    requiredEnforcers: {\n      [nativeTokenPeriodTransferEnforcer]: 1,\n      [exactCalldataEnforcer]: 1,\n      [nonceEnforcer]: 1,\n    },\n    rules: [expiryRuleDecoder, redeemerRuleDecoder, nativePayeeRuleDecoder],\n    validateAndDecodeData,\n  };\n}\n\n/**\n * Decodes native-token-periodic permission data from caveats; throws on invalid.\n *\n * @param caveats - Caveats from the permission context (checksummed).\n * @param contractAddresses - Checksummed enforcer addresses for the chain.\n * @returns Decoded periodic terms.\n */\nfunction validateAndDecodeData(\n  caveats: ChecksumCaveat[],\n  contractAddresses: EnforcerAddressesByName,\n): DecodedPermissionData<NativeTokenPeriodicPermission> {\n  const { nativeTokenPeriodTransferEnforcer, exactCalldataEnforcer } =\n    contractAddresses;\n\n  const exactCalldataTerms = getTermsByEnforcer({\n    caveats,\n    enforcer: exactCalldataEnforcer,\n  });\n\n  if (exactCalldataTerms !== '0x') {\n    throw new Error('Invalid exact-calldata terms: must be 0x');\n  }\n\n  const terms = getTermsByEnforcer({\n    caveats,\n    enforcer: nativeTokenPeriodTransferEnforcer,\n  });\n  const {\n    periodAmount,\n    periodDuration,\n    startDate: startTime,\n  } = decodeNativeTokenPeriodTransferTerms(terms);\n\n  if (periodAmount === 0n) {\n    throw new Error(\n      'Invalid native-token-periodic terms: periodAmount must be a positive number',\n    );\n  }\n\n  if (periodDuration === 0) {\n    throw new Error(\n      'Invalid native-token-periodic terms: periodDuration must be a positive number',\n    );\n  }\n\n  if (periodDuration > MAX_PERIOD_DURATION) {\n    throw new Error(\n      'Invalid native-token-periodic terms: periodDuration must be less than or equal to MAX_PERIOD_DURATION',\n    );\n  }\n\n  if (startTime === 0) {\n    throw new Error(\n      'Invalid native-token-periodic terms: startTime must be a positive number',\n    );\n  }\n\n  return {\n    periodAmount: bigIntToHex(periodAmount),\n    periodDuration,\n    startTime,\n  };\n}\n\n/**\n * Enforcers required to build native token periodic caveats.\n */\nexport type NativeTokenPeriodicEnforcers = Pick<\n  EnforcerAddressesByName,\n  'nativeTokenPeriodTransferEnforcer' | 'exactCalldataEnforcer'\n>;\n\n/**\n * Builds the native-token-periodic caveats required for this permission type.\n *\n * @param options0 - Caveat builder arguments.\n * @param options0.permission - Fully populated native-token-periodic permission data.\n * @param options0.contracts - Enforcer addresses used to construct caveats.\n * @returns The native token periodic and exact-calldata caveats.\n */\nexport function createNativeTokenPeriodicCaveats({\n  permission,\n  contracts,\n}: {\n  permission: Populated<NativeTokenPeriodicPermission>;\n  contracts: NativeTokenPeriodicEnforcers;\n}): Caveat[] {\n  const { periodAmount, periodDuration, startTime } = permission.data;\n  const periodAmountBigInt = hexToBigInt(periodAmount);\n\n  if (periodAmountBigInt === 0n) {\n    throw new Error(\n      'Invalid native-token-periodic permission: periodAmount must be a positive number.',\n    );\n  }\n\n  if (periodDuration <= 0) {\n    throw new Error(\n      'Invalid native-token-periodic permission: periodDuration must be a positive number.',\n    );\n  }\n\n  if (periodDuration > MAX_PERIOD_DURATION) {\n    throw new Error(\n      'Invalid native-token-periodic permission: periodDuration must be less than or equal to MAX_PERIOD_DURATION.',\n    );\n  }\n\n  if (startTime <= 0) {\n    throw new Error(\n      'Invalid native-token-periodic permission: startTime must be a positive number.',\n    );\n  }\n\n  const nativeTokenPeriodTransferCaveat: Caveat = {\n    enforcer: contracts.nativeTokenPeriodTransferEnforcer,\n    terms: createNativeTokenPeriodTransferTerms({\n      periodAmount: periodAmountBigInt,\n      periodDuration,\n      startDate: startTime,\n    }),\n    args: '0x',\n  };\n\n  const exactCalldataCaveat: Caveat = {\n    enforcer: contracts.exactCalldataEnforcer,\n    terms: createExactCalldataTerms({ calldata: '0x' }),\n    args: '0x',\n  };\n\n  return [nativeTokenPeriodTransferCaveat, exactCalldataCaveat];\n}\n","import type { Caveat } from '@metamask/delegation-core';\nimport {\n  createExactCalldataTerms,\n  createNativeTokenStreamingTerms,\n  decodeNativeTokenStreamingTerms,\n} from '@metamask/delegation-core';\nimport { bigIntToHex, hexToBigInt } from '@metamask/utils';\n\nimport type { NativeTokenStreamPermission, Populated } from '../../types';\nimport { expiryRuleDecoder } from '../rules/expiry';\nimport { nativePayeeRuleDecoder } from '../rules/payee';\nimport { redeemerRuleDecoder } from '../rules/redeemer';\nimport type {\n  ChecksumCaveat,\n  EnforcerAddressesByName,\n  DecodedPermissionData,\n  PermissionDecoderConfig,\n} from '../types';\nimport { getTermsByEnforcer } from '../utils';\n\n/**\n * Builds the configuration for the native-token-stream permission decoder.\n *\n * @param contractAddresses - Checksummed enforcer addresses for the chain.\n * @returns The native-token-stream permission decoder configuration.\n */\nexport function makeNativeTokenStreamDecoderConfig(\n  contractAddresses: EnforcerAddressesByName,\n): PermissionDecoderConfig {\n  const {\n    timestampEnforcer,\n    nativeTokenStreamingEnforcer,\n    exactCalldataEnforcer,\n    nonceEnforcer,\n    allowedTargetsEnforcer,\n    redeemerEnforcer,\n  } = contractAddresses;\n\n  return {\n    permissionType: 'native-token-stream',\n    contractAddresses,\n    optionalEnforcers: [\n      timestampEnforcer, // expiry rule\n      redeemerEnforcer, // redeemer rule\n      allowedTargetsEnforcer, // payee rule\n    ],\n    requiredEnforcers: {\n      [nativeTokenStreamingEnforcer]: 1,\n      [exactCalldataEnforcer]: 1,\n      [nonceEnforcer]: 1,\n    },\n    rules: [expiryRuleDecoder, redeemerRuleDecoder, nativePayeeRuleDecoder],\n    validateAndDecodeData,\n  };\n}\n\n/**\n * Decodes native-token-stream permission data from caveats; throws on invalid.\n *\n * @param caveats - Caveats from the permission context (checksummed).\n * @param contractAddresses - Checksummed enforcer addresses for the chain.\n * @returns Decoded stream terms.\n */\nfunction validateAndDecodeData(\n  caveats: ChecksumCaveat[],\n  contractAddresses: EnforcerAddressesByName,\n): DecodedPermissionData<NativeTokenStreamPermission> {\n  const { nativeTokenStreamingEnforcer, exactCalldataEnforcer } =\n    contractAddresses;\n\n  const exactCalldataTerms = getTermsByEnforcer({\n    caveats,\n    enforcer: exactCalldataEnforcer,\n  });\n\n  if (exactCalldataTerms !== '0x') {\n    throw new Error('Invalid exact-calldata terms: must be 0x');\n  }\n\n  const terms = getTermsByEnforcer({\n    caveats,\n    enforcer: nativeTokenStreamingEnforcer,\n  });\n  const { initialAmount, maxAmount, amountPerSecond, startTime } =\n    decodeNativeTokenStreamingTerms(terms);\n\n  if (maxAmount <= initialAmount) {\n    throw new Error(\n      'Invalid native-token-stream terms: maxAmount must be greater than initialAmount',\n    );\n  }\n\n  if (amountPerSecond === 0n) {\n    throw new Error(\n      'Invalid native-token-stream terms: amountPerSecond must be a positive number',\n    );\n  }\n\n  if (startTime === 0) {\n    throw new Error(\n      'Invalid native-token-stream terms: startTime must be a positive number',\n    );\n  }\n\n  return {\n    initialAmount: bigIntToHex(initialAmount),\n    maxAmount: bigIntToHex(maxAmount),\n    amountPerSecond: bigIntToHex(amountPerSecond),\n    startTime,\n  };\n}\n\n/**\n * Enforcers required to build native token stream caveats.\n */\nexport type NativeTokenStreamEnforcers = Pick<\n  EnforcerAddressesByName,\n  'nativeTokenStreamingEnforcer' | 'exactCalldataEnforcer'\n>;\n\n/**\n * Builds the native-token-stream caveats required for this permission type.\n *\n * @param options0 - Caveat builder arguments.\n * @param options0.permission - Fully populated native-token-stream permission data.\n * @param options0.contracts - Enforcer addresses used to construct caveats.\n * @returns The native token streaming and exact-calldata caveats.\n */\nexport function createNativeTokenStreamCaveats({\n  permission,\n  contracts,\n}: {\n  permission: Populated<NativeTokenStreamPermission>;\n  contracts: NativeTokenStreamEnforcers;\n}): Caveat[] {\n  const { initialAmount, maxAmount, amountPerSecond, startTime } =\n    permission.data;\n  const initialAmountBigInt = hexToBigInt(initialAmount);\n  const maxAmountBigInt = hexToBigInt(maxAmount);\n  const amountPerSecondBigInt = hexToBigInt(amountPerSecond);\n\n  if (maxAmountBigInt <= initialAmountBigInt) {\n    throw new Error(\n      'Invalid native-token-stream permission: maxAmount must be greater than initialAmount.',\n    );\n  }\n\n  if (amountPerSecondBigInt === 0n) {\n    throw new Error(\n      'Invalid native-token-stream permission: amountPerSecond must be a positive number.',\n    );\n  }\n\n  if (startTime <= 0) {\n    throw new Error(\n      'Invalid native-token-stream permission: startTime must be a positive number.',\n    );\n  }\n\n  const nativeTokenStreamingCaveat: Caveat = {\n    enforcer: contracts.nativeTokenStreamingEnforcer,\n    terms: createNativeTokenStreamingTerms({\n      initialAmount: initialAmountBigInt,\n      maxAmount: maxAmountBigInt,\n      amountPerSecond: amountPerSecondBigInt,\n      startTime,\n    }),\n    args: '0x',\n  };\n\n  const exactCalldataCaveat: Caveat = {\n    enforcer: contracts.exactCalldataEnforcer,\n    terms: createExactCalldataTerms({ calldata: '0x' }),\n    args: '0x',\n  };\n\n  return [nativeTokenStreamingCaveat, exactCalldataCaveat];\n}\n","import type { Caveat } from '@metamask/delegation-core';\nimport {\n  createApprovalRevocationTerms,\n  decodeApprovalRevocationTerms,\n} from '@metamask/delegation-core';\n\nimport type { TokenApprovalRevocationPermission, Populated } from '../../types';\nimport { expiryRuleDecoder } from '../rules/expiry';\nimport type {\n  ChecksumCaveat,\n  EnforcerAddressesByName,\n  DecodedPermissionData,\n  PermissionDecoderConfig,\n} from '../types';\nimport { getTermsByEnforcer } from '../utils';\n\n/**\n * Builds the configuration for the token-approval-revocation permission decoder.\n *\n * @param contractAddresses - Checksummed enforcer addresses for the chain.\n * @returns The token-approval-revocation permission decoder configuration.\n */\nexport function makeTokenApprovalRevocationDecoderConfig(\n  contractAddresses: EnforcerAddressesByName,\n): PermissionDecoderConfig {\n  const { timestampEnforcer, approvalRevocationEnforcer, nonceEnforcer } =\n    contractAddresses;\n\n  return {\n    permissionType: 'token-approval-revocation',\n    contractAddresses,\n    optionalEnforcers: [\n      timestampEnforcer, // expiry rule\n    ],\n    requiredEnforcers: {\n      [approvalRevocationEnforcer]: 1,\n      [nonceEnforcer]: 1,\n    },\n    rules: [expiryRuleDecoder],\n    validateAndDecodeData,\n  };\n}\n\n/**\n * Decodes token-approval-revocation permission data from caveats; throws on invalid.\n *\n * @param caveats - Caveats from the permission context (checksummed).\n * @param contractAddresses - Checksummed enforcer addresses for the chain.\n * @returns Decoded approval-revocation capability flags.\n */\nfunction validateAndDecodeData(\n  caveats: ChecksumCaveat[],\n  contractAddresses: EnforcerAddressesByName,\n): DecodedPermissionData<TokenApprovalRevocationPermission> {\n  const { approvalRevocationEnforcer } = contractAddresses;\n\n  const terms = getTermsByEnforcer({\n    caveats,\n    enforcer: approvalRevocationEnforcer,\n  });\n\n  const {\n    erc20Approve,\n    erc721Approve,\n    erc721SetApprovalForAll,\n    permit2Approve,\n    permit2Lockdown,\n    permit2InvalidateNonces,\n  } = decodeApprovalRevocationTerms(terms);\n\n  return {\n    erc20Approve,\n    erc721Approve,\n    erc721SetApprovalForAll,\n    permit2Approve,\n    permit2Lockdown,\n    permit2InvalidateNonces,\n  };\n}\n\n/**\n * Enforcers required to build token approval revocation caveats.\n */\nexport type TokenApprovalRevocationEnforcers = Pick<\n  EnforcerAddressesByName,\n  'approvalRevocationEnforcer'\n>;\n\n/**\n * Builds the token-approval-revocation caveat required for this permission type.\n *\n * @param options0 - Caveat builder arguments.\n * @param options0.permission - Fully populated token-approval-revocation permission data.\n * @param options0.contracts - Enforcer addresses used to construct caveats.\n * @returns A single approval-revocation caveat.\n */\nexport function createTokenApprovalRevocationCaveats({\n  permission,\n  contracts,\n}: {\n  permission: Populated<TokenApprovalRevocationPermission>;\n  contracts: TokenApprovalRevocationEnforcers;\n}): Caveat[] {\n  const approvalRevocationCaveat: Caveat = {\n    enforcer: contracts.approvalRevocationEnforcer,\n    terms: createApprovalRevocationTerms(permission.data),\n    args: '0x',\n  };\n\n  return [approvalRevocationCaveat];\n}\n","/** Milliseconds in common time periods. */\nexport const SECOND = 1000;\nexport const HOUR = 60 * 60 * SECOND;\nexport const DAY = 24 * HOUR;\nexport const WEEK = 7 * DAY;\nexport const FORTNIGHT = 2 * WEEK;\nexport const MONTH = 30 * DAY;\nexport const YEAR = 365 * DAY;\n\n/** Maximum uint256 value as lowercase hex. */\nexport const MAX_UINT256 =\n  '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff';\n","export const METAMASK_FACILITATOR_ADDRESSES = [\n  '0xB01caEa8c6C47bbf4F4b4c5080Ca642043359C2E',\n  '0xC066ac5D385419B1A8c43A0E146fA439837a8B8c',\n  '0xB42F812A44c22cc6b861478900401ee759EbEAD6',\n] as const;\n\nexport const METAMASK_FACILITATOR_ADDRESSES_DEV = [\n  '0xb4827A2a066CD2Ef88560EFdf063dD05C6c41cC7',\n] as const;\n\nexport const ALL_METAMASK_FACILITATOR_ADDRESSES = [\n  ...METAMASK_FACILITATOR_ADDRESSES,\n  ...METAMASK_FACILITATOR_ADDRESSES_DEV,\n] as const;\n\nconst METAMASK_FACILITATOR_ADDRESSES_LOWERCASE = new Set<string>(\n  ALL_METAMASK_FACILITATOR_ADDRESSES.map((address) => address.toLowerCase()),\n);\n\n/**\n * Checks whether an address is a known MetaMask facilitator address.\n *\n * @param address - Address to check.\n * @returns True if the address is a known MetaMask facilitator address.\n */\nexport function isMetaMaskFacilitatorAddress(address: string): boolean {\n  return METAMASK_FACILITATOR_ADDRESSES_LOWERCASE.has(address.toLowerCase());\n}\n\n/**\n * Checks whether every provided address is a known MetaMask facilitator address.\n *\n * @param addresses - Addresses to check.\n * @returns True when the list is non-empty and all entries are known facilitators.\n */\nexport function areOnlyMetaMaskFacilitatorAddresses(\n  addresses: string[] | null | undefined,\n): boolean {\n  if (!addresses?.length) {\n    return false;\n  }\n\n  return addresses.every(isMetaMaskFacilitatorAddress);\n}\n","import { bigIntToHex, hexToBigInt } from '@metamask/utils';\nimport type { Hex } from '@metamask/utils';\n\nimport { DAY, FORTNIGHT, HOUR, MONTH, SECOND, WEEK, YEAR } from './constants';\nimport type { I18nValue } from './types';\n\n/**\n * Parses a permission amount string as an unsigned EVM integer.\n *\n * Strings without a `0x` prefix are still interpreted as hexadecimal, not\n * decimal. That matches uint values from RPC / typed data.\n *\n * @param value - Hex string with or without `0x` / `0X` prefix.\n * @returns The parsed amount as a bigint.\n */\nexport function parseHexPermissionAmount(value: string): bigint {\n  const trimmed = value.trim();\n  if (trimmed.length === 0) {\n    throw new Error('Cannot parse empty permission amount');\n  }\n\n  return hexToBigInt(trimmed as Hex);\n}\n\n/**\n * Returns an i18n key for a period duration in seconds.\n *\n * @param periodDurationInSeconds - The period duration in seconds.\n * @returns The translation key for the frequency description.\n */\nexport function getPeriodFrequencyValueTranslationKey(\n  periodDurationInSeconds: number,\n): string {\n  const periodDurationMillisecond = periodDurationInSeconds * SECOND;\n  if (periodDurationMillisecond === DAY) {\n    return 'gatorPermissionDailyFrequency';\n  } else if (periodDurationMillisecond === WEEK) {\n    return 'gatorPermissionWeeklyFrequency';\n  } else if (periodDurationMillisecond === FORTNIGHT) {\n    return 'gatorPermissionFortnightlyFrequency';\n  } else if (periodDurationMillisecond === MONTH) {\n    return 'gatorPermissionMonthlyFrequency';\n  } else if (periodDurationMillisecond === YEAR) {\n    return 'gatorPermissionAnnualFrequency';\n  }\n  return 'gatorPermissionCustomFrequency';\n}\n\n/**\n * Returns an i18n key and optional args for a period duration in seconds.\n *\n * @param periodSeconds - The period duration in seconds.\n * @returns A translatable period duration value.\n */\nexport function formatPermissionPeriodDuration(\n  periodSeconds: number,\n): I18nValue {\n  if (periodSeconds === 0) {\n    throw new Error('Cannot format period duration of 0 seconds');\n  }\n\n  if (periodSeconds < 0) {\n    throw new Error('Cannot format negative period duration');\n  }\n\n  const periodMilliseconds = periodSeconds * SECOND;\n\n  switch (periodMilliseconds) {\n    case HOUR:\n      return { key: 'confirmFieldPeriodDurationHourly' };\n    case DAY:\n      return { key: 'confirmFieldPeriodDurationDaily' };\n    case WEEK:\n      return { key: 'confirmFieldPeriodDurationWeekly' };\n    case FORTNIGHT:\n      return { key: 'confirmFieldPeriodDurationBiWeekly' };\n    case MONTH:\n      return { key: 'confirmFieldPeriodDurationMonthly' };\n    case YEAR:\n      return { key: 'confirmFieldPeriodDurationYearly' };\n    default:\n      return {\n        key: 'confirmFieldPeriodDurationSeconds',\n        args: [periodSeconds],\n      };\n  }\n}\n\n/**\n * Converts milliseconds to seconds.\n *\n * @param milliseconds - The milliseconds to convert.\n * @returns The seconds.\n */\nexport function convertMillisecondsToSeconds(milliseconds: number): number {\n  return milliseconds / SECOND;\n}\n\n/**\n * Converts an amount per second to an amount per period.\n *\n * @param amountPerSecond - The amount per second in hexadecimal format.\n * @param period - The period to convert to.\n * @returns The amount per period.\n */\nexport function convertAmountPerSecondToAmountPerPeriod(\n  amountPerSecond: Hex,\n  period: 'weekly' | 'monthly' | 'fortnightly' | 'yearly',\n): Hex {\n  const amountBigInt = hexToBigInt(amountPerSecond);\n  switch (period) {\n    case 'weekly':\n      return bigIntToHex(\n        amountBigInt * BigInt(convertMillisecondsToSeconds(WEEK)),\n      );\n    case 'monthly':\n      return bigIntToHex(\n        amountBigInt * BigInt(convertMillisecondsToSeconds(MONTH)),\n      );\n    case 'fortnightly':\n      return bigIntToHex(\n        amountBigInt * BigInt(convertMillisecondsToSeconds(FORTNIGHT)),\n      );\n    case 'yearly':\n      return bigIntToHex(\n        amountBigInt * BigInt(convertMillisecondsToSeconds(YEAR)),\n      );\n    default:\n      throw new Error(`Invalid period: ${period as string}`);\n  }\n}\n","import type { Hex } from '@metamask/utils';\n\nimport { DAY, MAX_UINT256 } from './constants';\nimport { areOnlyMetaMaskFacilitatorAddresses } from './facilitatorAddresses';\nimport type {\n  I18nValue,\n  PermissionRenderContext,\n  SchemaSection,\n} from './types';\nimport {\n  convertAmountPerSecondToAmountPerPeriod,\n  formatPermissionPeriodDuration,\n  getPeriodFrequencyValueTranslationKey,\n  parseHexPermissionAmount,\n} from './utils';\n\nexport const getData = <TReturn = unknown>(\n  ctx: PermissionRenderContext,\n  key: string,\n): TReturn => ctx.permission.data[key] as TReturn;\n\n/**\n * Reads stream total exposure from the schema context.\n *\n * @param ctx - Permission render context.\n * @returns Total exposure, or null for unlimited exposure.\n */\nexport function getStreamTotalExposure(\n  ctx: PermissionRenderContext,\n): bigint | null {\n  if (ctx.streamTotalExposure === undefined) {\n    throw new Error(\n      'PermissionRenderContext.streamTotalExposure must be set when rendering stream permission fields',\n    );\n  }\n  return ctx.streamTotalExposure;\n}\n\nexport const requireStartTime = (permission: {\n  data: Record<string, unknown>;\n}): void => {\n  if (!permission.data.startTime) {\n    throw new Error('Start time is required');\n  }\n};\n\nexport const alwaysVisible = (): boolean => true;\n\nconst getJustificationValue = (\n  ctx: PermissionRenderContext,\n): string | I18nValue => {\n  if (ctx.permission.justification) {\n    return ctx.permission.justification;\n  }\n  return { key: 'gatorNoJustificationProvided' };\n};\n\nexport const justificationSection: SchemaSection = {\n  testId: 'confirmation_justification-section',\n  elements: [\n    {\n      type: 'justification',\n      labelKey: 'gatorPermissionsJustification',\n      testId: 'review-gator-permission-justification',\n      getValue: getJustificationValue,\n      isVisible: alwaysVisible,\n      includeInViews: ['confirmation', 'reviewDetail'],\n    },\n    {\n      type: 'account',\n      labelKey: 'account',\n      testId: 'review-gator-permission-account-name',\n      getValue: () => undefined,\n      isVisible: alwaysVisible,\n      includeInViews: ['confirmation'],\n    },\n  ],\n};\n\nexport const reviewSummaryAccountSection: SchemaSection = {\n  testId: 'review_summary-account-section',\n  elements: [\n    {\n      type: 'account',\n      labelKey: 'account',\n      testId: 'review-gator-permission-account-name',\n      getValue: () => undefined,\n      isVisible: alwaysVisible,\n      includeInViews: ['reviewSummary'],\n    },\n  ],\n};\n\nexport const permissionInfoSection: SchemaSection = {\n  testId: 'confirmation_permission-section',\n  elements: [\n    {\n      type: 'origin',\n      labelKey: 'requestFrom',\n      testId: 'confirmation-origin',\n      getValue: (ctx) => ctx.origin,\n      isVisible: alwaysVisible,\n      includeInViews: ['confirmation'],\n    },\n    {\n      type: 'address',\n      labelKey: 'recipient',\n      testId: 'confirmation-recipient',\n      getValue: (ctx) => ctx.to,\n      isVisible: (ctx) => Boolean(ctx.to),\n      includeInViews: ['confirmation'],\n    },\n    { type: 'network', includeInViews: ['confirmation', 'reviewDetail'] },\n    {\n      type: 'text',\n      labelKey: 'redeemers',\n      testId: 'confirmation-redeemer-metamask-facilitator',\n      getValue: () => ({ key: 'gatorPermissionsMetaMaskFacilitator' }),\n      isVisible: (ctx) =>\n        areOnlyMetaMaskFacilitatorAddresses(ctx.redeemerAddresses),\n      includeInViews: ['confirmation', 'reviewDetail'],\n    },\n    {\n      type: 'rule-address',\n      labelKey: 'redeemer',\n      testId: 'confirmation-redeemer',\n      getValue: (ctx) => ctx.redeemerAddresses ?? undefined,\n      isVisible: (ctx) =>\n        Boolean(ctx.redeemerAddresses?.length) &&\n        !areOnlyMetaMaskFacilitatorAddresses(ctx.redeemerAddresses),\n      includeInViews: ['confirmation', 'reviewDetail'],\n    },\n    {\n      type: 'rule-address',\n      labelKey: 'payee',\n      testId: 'confirmation-payee',\n      getValue: (ctx) => ctx.payeeAddresses ?? undefined,\n      isVisible: (ctx) => Boolean(ctx.payeeAddresses?.length),\n      includeInViews: ['confirmation', 'reviewDetail'],\n    },\n  ],\n};\n\nexport const periodicDetailsSection = (\n  testId: string,\n  tokenAddressKey?: string,\n): SchemaSection => ({\n  testId,\n  elements: [\n    {\n      type: 'amount',\n      labelKey: 'amount',\n      testId: 'review-gator-permission-amount-label',\n      getValue: (ctx) =>\n        parseHexPermissionAmount(getData<string>(ctx, 'periodAmount')),\n      isVisible: alwaysVisible,\n      includeInViews: ['reviewSummary'],\n    },\n    {\n      type: 'text',\n      labelKey: 'gatorPermissionTokenPeriodicFrequencyLabel',\n      testId: 'review-gator-permission-frequency-label',\n      getValue: (ctx) => ({\n        key: getPeriodFrequencyValueTranslationKey(\n          getData<number>(ctx, 'periodDuration'),\n        ),\n      }),\n      isVisible: alwaysVisible,\n      includeInViews: ['reviewSummary'],\n    },\n    {\n      type: 'amount',\n      labelKey: 'confirmFieldAllowance',\n      testId: 'confirmation-allowance',\n      getValue: (ctx) =>\n        parseHexPermissionAmount(getData<string>(ctx, 'periodAmount')),\n      getTokenAddress: tokenAddressKey\n        ? (ctx): Hex => getData<Hex>(ctx, tokenAddressKey)\n        : undefined,\n      isVisible: alwaysVisible,\n      includeInViews: ['confirmation'],\n    },\n    {\n      type: 'text',\n      labelKey: 'confirmFieldFrequency',\n      testId: 'confirmation-frequency',\n      getValue: (ctx) =>\n        formatPermissionPeriodDuration(getData<number>(ctx, 'periodDuration')),\n      isVisible: alwaysVisible,\n      includeInViews: ['confirmation'],\n    },\n    { type: 'divider', includeInViews: ['confirmation'] },\n    {\n      type: 'date',\n      labelKey: 'gatorPermissionsStartDate',\n      testId: 'review-gator-permission-start-date',\n      getValue: (ctx) => getData<number>(ctx, 'startTime'),\n      isVisible: alwaysVisible,\n      includeInViews: ['confirmation', 'reviewDetail'],\n    },\n    {\n      type: 'expiry',\n      labelKey: 'gatorPermissionsExpirationDate',\n      testId: 'review-gator-permission-expiration-date',\n      getValue: (ctx) => ctx.expiry,\n      isVisible: alwaysVisible,\n      includeInViews: ['confirmation', 'reviewDetail'],\n    },\n  ],\n});\n\nexport const streamDetailsSection = (\n  testId: string,\n  tokenAddressKey?: string,\n): SchemaSection => ({\n  testId,\n  elements: [\n    {\n      type: 'amount',\n      labelKey: 'gatorPermissionsStreamingAmountLabel',\n      testId: 'review-gator-permission-amount-label',\n      getValue: (ctx) =>\n        parseHexPermissionAmount(\n          convertAmountPerSecondToAmountPerPeriod(\n            getData<Hex>(ctx, 'amountPerSecond'),\n            'weekly',\n          ),\n        ),\n      isVisible: alwaysVisible,\n      includeInViews: ['reviewSummary'],\n    },\n    {\n      type: 'text',\n      labelKey: 'gatorPermissionTokenStreamFrequencyLabel',\n      testId: 'review-gator-permission-frequency-label',\n      getValue: () => ({ key: 'gatorPermissionWeeklyFrequency' }),\n      isVisible: alwaysVisible,\n      includeInViews: ['reviewSummary'],\n    },\n    {\n      type: 'amount',\n      labelKey: 'gatorPermissionsInitialAllowance',\n      testId: 'review-gator-permission-initial-allowance',\n      getValue: (ctx) =>\n        parseHexPermissionAmount(getData<string>(ctx, 'initialAmount')),\n      getTokenAddress: tokenAddressKey\n        ? (ctx): Hex => getData<Hex>(ctx, tokenAddressKey)\n        : undefined,\n      isVisible: (ctx): boolean => Boolean(getData(ctx, 'initialAmount')),\n      includeInViews: ['confirmation', 'reviewDetail'],\n    },\n    {\n      type: 'amount',\n      labelKey: 'gatorPermissionsMaxAllowance',\n      testId: 'review-gator-permission-max-allowance',\n      getValue: (ctx) =>\n        parseHexPermissionAmount(getData<string>(ctx, 'maxAmount')),\n      getTokenAddress: tokenAddressKey\n        ? (ctx): Hex => getData<Hex>(ctx, tokenAddressKey)\n        : undefined,\n      isVisible: (ctx): boolean => {\n        const max = getData<string | null | undefined>(ctx, 'maxAmount');\n        return (\n          max !== undefined && max !== null && max.toLowerCase() !== MAX_UINT256\n        );\n      },\n      includeInViews: ['confirmation', 'reviewDetail'],\n    },\n    {\n      type: 'text',\n      labelKey: 'gatorPermissionsMaxAllowance',\n      testId: 'review-gator-permission-max-allowance-unlimited',\n      getValue: () => ({ key: 'unlimited' }),\n      isVisible: (ctx): boolean => {\n        const max = getData<string | null | undefined>(ctx, 'maxAmount');\n        return Boolean(max?.toLowerCase() === MAX_UINT256);\n      },\n      includeInViews: ['confirmation', 'reviewDetail'],\n    },\n    { type: 'divider', includeInViews: ['confirmation'] },\n    {\n      type: 'date',\n      labelKey: 'gatorPermissionsStartDate',\n      testId: 'review-gator-permission-start-date',\n      getValue: (ctx) => getData<number>(ctx, 'startTime'),\n      isVisible: alwaysVisible,\n      includeInViews: ['confirmation', 'reviewDetail'],\n    },\n    {\n      type: 'expiry',\n      labelKey: 'gatorPermissionsExpirationDate',\n      testId: 'review-gator-permission-expiration-date',\n      getValue: (ctx) => ctx.expiry,\n      isVisible: alwaysVisible,\n      includeInViews: ['confirmation', 'reviewDetail'],\n    },\n  ],\n});\n\nexport const streamRateSection = (\n  testId: string,\n  tokenAddressKey?: string,\n): SchemaSection => ({\n  testId,\n  elements: [\n    {\n      type: 'amount',\n      labelKey: 'gatorPermissionsStreamRate',\n      testId: 'review-gator-permission-stream-rate',\n      getValue: (ctx) =>\n        parseHexPermissionAmount(getData<string>(ctx, 'amountPerSecond')),\n      getTokenAddress: tokenAddressKey\n        ? (ctx): Hex => getData<Hex>(ctx, tokenAddressKey)\n        : undefined,\n      isRatePerSecond: true,\n      isVisible: alwaysVisible,\n      includeInViews: ['confirmation', 'reviewDetail'],\n    },\n    {\n      type: 'amount',\n      labelKey: 'confirmFieldAvailablePerDay',\n      testId: 'confirmation-available-per-day',\n      getValue: (ctx) =>\n        parseHexPermissionAmount(getData<string>(ctx, 'amountPerSecond')) *\n        BigInt(DAY / 1000),\n      getTokenAddress: tokenAddressKey\n        ? (ctx): Hex => getData<Hex>(ctx, tokenAddressKey)\n        : undefined,\n      isVisible: alwaysVisible,\n      includeInViews: ['confirmation'],\n    },\n    {\n      type: 'amount',\n      labelKey: 'confirmFieldTotalExposure',\n      testId: 'confirmation-total-exposure',\n      getValue: (ctx) => getStreamTotalExposure(ctx) ?? 0n,\n      getTokenAddress: tokenAddressKey\n        ? (ctx): Hex => getData<Hex>(ctx, tokenAddressKey)\n        : undefined,\n      isVisible: (ctx): boolean => getStreamTotalExposure(ctx) !== null,\n      includeInViews: ['confirmation'],\n    },\n    {\n      type: 'text',\n      labelKey: 'confirmFieldTotalExposure',\n      testId: 'confirmation-total-exposure-unlimited',\n      getValue: () => ({ key: 'unlimited' }),\n      isVisible: (ctx): boolean => getStreamTotalExposure(ctx) === null,\n      includeInViews: ['confirmation'],\n    },\n  ],\n});\n\nexport const allowanceDetailsSection = (\n  testId: string,\n  tokenAddressKey?: string,\n): SchemaSection => ({\n  testId,\n  elements: [\n    {\n      type: 'amount',\n      labelKey: 'amount',\n      testId: 'review-gator-permission-amount-label',\n      getValue: (ctx) =>\n        parseHexPermissionAmount(getData<string>(ctx, 'allowanceAmount')),\n      getTokenAddress: tokenAddressKey\n        ? (ctx): Hex => getData<Hex>(ctx, tokenAddressKey)\n        : undefined,\n      isVisible: alwaysVisible,\n      includeInViews: ['confirmation', 'reviewSummary'],\n    },\n    {\n      type: 'date',\n      labelKey: 'gatorPermissionsStartDate',\n      testId: 'review-gator-permission-start-date',\n      getValue: (ctx) => getData<number>(ctx, 'startTime'),\n      isVisible: alwaysVisible,\n      includeInViews: ['confirmation', 'reviewDetail'],\n    },\n    {\n      type: 'expiry',\n      labelKey: 'gatorPermissionsExpirationDate',\n      testId: 'review-gator-permission-expiration-date',\n      getValue: (ctx) => ctx.expiry,\n      isVisible: alwaysVisible,\n      includeInViews: ['confirmation', 'reviewDetail'],\n    },\n  ],\n});\n","import {\n  allowanceDetailsSection,\n  justificationSection,\n  permissionInfoSection,\n  requireStartTime,\n  reviewSummaryAccountSection,\n} from './sections';\nimport type { PermissionSchemaEntry } from './types';\n\nexport const erc20TokenAllowanceSchema: PermissionSchemaEntry = {\n  tokenVariant: 'erc20',\n  tokenResolution: {\n    kind: 'erc20',\n    getTokenAddress: (permission) => permission.data.tokenAddress as string,\n  },\n  validate: requireStartTime,\n  sections: [\n    justificationSection,\n    permissionInfoSection,\n    allowanceDetailsSection(\n      'erc20-token-allowance-details-section',\n      'tokenAddress',\n    ),\n    reviewSummaryAccountSection,\n  ],\n};\n","import {\n  justificationSection,\n  periodicDetailsSection,\n  permissionInfoSection,\n  requireStartTime,\n  reviewSummaryAccountSection,\n} from './sections';\nimport type { PermissionSchemaEntry } from './types';\n\nexport const erc20TokenPeriodicSchema: PermissionSchemaEntry = {\n  tokenVariant: 'erc20',\n  tokenResolution: {\n    kind: 'erc20',\n    getTokenAddress: (permission) => permission.data.tokenAddress as string,\n  },\n  validate: requireStartTime,\n  sections: [\n    justificationSection,\n    permissionInfoSection,\n    periodicDetailsSection(\n      'erc20-token-periodic-details-section',\n      'tokenAddress',\n    ),\n    reviewSummaryAccountSection,\n  ],\n};\n","import {\n  justificationSection,\n  permissionInfoSection,\n  requireStartTime,\n  reviewSummaryAccountSection,\n  streamDetailsSection,\n  streamRateSection,\n} from './sections';\nimport type { PermissionSchemaEntry } from './types';\n\nexport const erc20TokenStreamSchema: PermissionSchemaEntry = {\n  tokenVariant: 'erc20',\n  tokenResolution: {\n    kind: 'erc20',\n    getTokenAddress: (permission) => permission.data.tokenAddress as string,\n  },\n  validate: requireStartTime,\n  sections: [\n    justificationSection,\n    permissionInfoSection,\n    streamDetailsSection('erc20-token-stream-details-section', 'tokenAddress'),\n    streamRateSection('erc20-token-stream-stream-rate-section', 'tokenAddress'),\n    reviewSummaryAccountSection,\n  ],\n};\n","import {\n  allowanceDetailsSection,\n  justificationSection,\n  permissionInfoSection,\n  requireStartTime,\n  reviewSummaryAccountSection,\n} from './sections';\nimport type { PermissionSchemaEntry } from './types';\n\nexport const nativeTokenAllowanceSchema: PermissionSchemaEntry = {\n  tokenVariant: 'native',\n  tokenResolution: { kind: 'native' },\n  validate: requireStartTime,\n  sections: [\n    justificationSection,\n    permissionInfoSection,\n    allowanceDetailsSection('native-token-allowance-details-section'),\n    reviewSummaryAccountSection,\n  ],\n};\n","import {\n  justificationSection,\n  periodicDetailsSection,\n  permissionInfoSection,\n  requireStartTime,\n  reviewSummaryAccountSection,\n} from './sections';\nimport type { PermissionSchemaEntry } from './types';\n\nexport const nativeTokenPeriodicSchema: PermissionSchemaEntry = {\n  tokenVariant: 'native',\n  tokenResolution: { kind: 'native' },\n  validate: requireStartTime,\n  sections: [\n    justificationSection,\n    permissionInfoSection,\n    periodicDetailsSection('native-token-periodic-details-section'),\n    reviewSummaryAccountSection,\n  ],\n};\n","import {\n  justificationSection,\n  permissionInfoSection,\n  requireStartTime,\n  reviewSummaryAccountSection,\n  streamDetailsSection,\n  streamRateSection,\n} from './sections';\nimport type { PermissionSchemaEntry } from './types';\n\nexport const nativeTokenStreamSchema: PermissionSchemaEntry = {\n  tokenVariant: 'native',\n  tokenResolution: { kind: 'native' },\n  validate: requireStartTime,\n  sections: [\n    justificationSection,\n    permissionInfoSection,\n    streamDetailsSection('native-token-stream-details-section'),\n    streamRateSection('native-token-stream-stream-rate-section'),\n    reviewSummaryAccountSection,\n  ],\n};\n","import {\n  alwaysVisible,\n  getData,\n  justificationSection,\n  permissionInfoSection,\n  reviewSummaryAccountSection,\n} from './sections';\nimport type { PermissionRenderContext, PermissionSchemaEntry } from './types';\n\nconst TOKEN_APPROVAL_REVOCATION_METHODS: {\n  key: string;\n  translationKey: string;\n}[] = [\n  {\n    key: 'erc20Approve',\n    translationKey: 'gatorPermissionsErc20ApproveRevocation',\n  },\n  {\n    key: 'erc721Approve',\n    translationKey: 'gatorPermissionsErc721ApproveRevocation',\n  },\n  {\n    key: 'erc721SetApprovalForAll',\n    translationKey: 'gatorPermissionsSetApprovalForAllRevocation',\n  },\n  {\n    key: 'permit2Approve',\n    translationKey: 'gatorPermissionsPermit2ApproveRevocation',\n  },\n  {\n    key: 'permit2Lockdown',\n    translationKey: 'gatorPermissionsPermit2Lockdown',\n  },\n  {\n    key: 'permit2InvalidateNonces',\n    translationKey: 'gatorPermissionsPermit2InvalidateNonces',\n  },\n];\n\nconst TOKEN_APPROVAL_REVOCATION_PRIMITIVE_KEYS =\n  TOKEN_APPROVAL_REVOCATION_METHODS.map(({ key }) => key);\n\n/**\n * Gets translation keys for enabled token approval revocation methods.\n *\n * @param ctx - Permission render context.\n * @returns Translation keys for enabled revocation methods.\n */\nfunction getEnabledTokenApprovalRevocationMethods(\n  ctx: PermissionRenderContext,\n): string[] {\n  return TOKEN_APPROVAL_REVOCATION_METHODS.filter(({ key }) =>\n    Boolean(getData<boolean | undefined>(ctx, key)),\n  ).map(({ translationKey }) => translationKey);\n}\n\n/**\n * Checks whether all token approval revocation primitives are enabled.\n *\n * @param ctx - Permission render context.\n * @returns True when every token approval revocation primitive is enabled.\n */\nfunction hasAllTokenApprovalRevocationPrimitivesEnabled(\n  ctx: PermissionRenderContext,\n): boolean {\n  return TOKEN_APPROVAL_REVOCATION_PRIMITIVE_KEYS.every((key) =>\n    Boolean(getData<boolean | undefined>(ctx, key)),\n  );\n}\n\nexport const tokenApprovalRevocationSchema: PermissionSchemaEntry = {\n  tokenVariant: 'none',\n  tokenResolution: { kind: 'none' },\n  sections: [\n    justificationSection,\n    permissionInfoSection,\n    {\n      testId: 'token-approval-revocation-details-section',\n      elements: [\n        {\n          type: 'text',\n          labelKey: 'revokeTokenApprovals',\n          testId: 'review-gator-permission-amount-label',\n          getValue: () => ({ key: 'allTokens' }),\n          isVisible: alwaysVisible,\n          includeInViews: ['reviewSummary'],\n        },\n        {\n          type: 'text',\n          labelKey: 'gatorPermissionsRevocationMethods',\n          testId:\n            'review-gator-permission-all-token-approval-revocation-primitives',\n          getValue: () => ({\n            key: 'gatorPermissionsAllTokenApprovalRevocationPrimitives',\n          }),\n          isVisible: (ctx) =>\n            hasAllTokenApprovalRevocationPrimitivesEnabled(ctx),\n          includeInViews: ['confirmation', 'reviewDetail'],\n        },\n        {\n          type: 'list',\n          labelKey: 'gatorPermissionsRevocationMethods',\n          testId: 'review-gator-permission-revocation-methods',\n          getValue: (ctx) => getEnabledTokenApprovalRevocationMethods(ctx),\n          isVisible: (ctx) =>\n            !hasAllTokenApprovalRevocationPrimitivesEnabled(ctx),\n          includeInViews: ['confirmation', 'reviewDetail'],\n        },\n        { type: 'divider', includeInViews: ['confirmation'] },\n        {\n          type: 'expiry',\n          labelKey: 'gatorPermissionsExpirationDate',\n          testId: 'review-gator-permission-expiration-date',\n          getValue: (ctx) => ctx.expiry,\n          isVisible: alwaysVisible,\n          includeInViews: ['confirmation', 'reviewDetail'],\n        },\n      ],\n    },\n    reviewSummaryAccountSection,\n  ],\n};\n","import {\n  alwaysVisible,\n  justificationSection,\n  permissionInfoSection,\n} from './sections';\nimport type { PermissionSchemaEntry } from './types';\n\nexport const unknownPermissionTypeSchema: PermissionSchemaEntry = {\n  tokenVariant: 'none',\n  tokenResolution: { kind: 'none' },\n  sections: [\n    justificationSection,\n    permissionInfoSection,\n    {\n      testId: 'unknown-permission-type-details-section',\n      elements: [\n        {\n          type: 'raw-text',\n          labelKey: 'unknownPermissionType',\n          testId: 'review-gator-permission-unknown-type',\n          getValue: (ctx) => ctx.permission.type,\n          isVisible: alwaysVisible,\n          includeInViews: ['reviewSummary'],\n        },\n      ],\n    },\n  ],\n};\n","import { erc20TokenAllowanceSchema } from './erc20TokenAllowance';\nimport { erc20TokenPeriodicSchema } from './erc20TokenPeriodic';\nimport { erc20TokenStreamSchema } from './erc20TokenStream';\nimport { nativeTokenAllowanceSchema } from './nativeTokenAllowance';\nimport { nativeTokenPeriodicSchema } from './nativeTokenPeriodic';\nimport { nativeTokenStreamSchema } from './nativeTokenStream';\nimport { tokenApprovalRevocationSchema } from './tokenApprovalRevocation';\nimport type { PermissionSchemaEntry, PermissionSchemaRegistry } from './types';\nimport { unknownPermissionTypeSchema } from './unknownPermissionType';\n\nexport {\n  DAY,\n  FORTNIGHT,\n  HOUR,\n  MAX_UINT256,\n  MONTH,\n  SECOND,\n  WEEK,\n  YEAR,\n} from './constants';\nexport {\n  ALL_METAMASK_FACILITATOR_ADDRESSES,\n  METAMASK_FACILITATOR_ADDRESSES,\n  METAMASK_FACILITATOR_ADDRESSES_DEV,\n  areOnlyMetaMaskFacilitatorAddresses,\n  isMetaMaskFacilitatorAddress,\n} from './facilitatorAddresses';\nexport type {\n  AccountField,\n  AddressField,\n  AmountField,\n  DateField,\n  DividerElement,\n  ExpiryField,\n  FieldView,\n  I18nFunction,\n  I18nValue,\n  JustificationField,\n  ListField,\n  NetworkField,\n  OriginField,\n  PermissionRenderContext,\n  PermissionSchemaEntry,\n  PermissionSchemaRegistry,\n  RawTextField,\n  ReviewFieldView,\n  RuleAddressField,\n  SchemaElement,\n  SchemaSection,\n  TextField,\n  TokenResolution,\n  TokenVariant,\n  TranslationKeys,\n} from './types';\nexport {\n  convertAmountPerSecondToAmountPerPeriod,\n  convertMillisecondsToSeconds,\n  formatPermissionPeriodDuration,\n  getPeriodFrequencyValueTranslationKey,\n  parseHexPermissionAmount,\n} from './utils';\n\nconst PERMISSION_SCHEMAS: PermissionSchemaRegistry = {\n  'native-token-periodic': nativeTokenPeriodicSchema,\n  'native-token-stream': nativeTokenStreamSchema,\n  'native-token-allowance': nativeTokenAllowanceSchema,\n  'erc20-token-periodic': erc20TokenPeriodicSchema,\n  'erc20-token-stream': erc20TokenStreamSchema,\n  'erc20-token-allowance': erc20TokenAllowanceSchema,\n  'token-approval-revocation': tokenApprovalRevocationSchema,\n};\n\n/**\n * Gets the schema entry for a permission type.\n *\n * @param permissionType - Permission type identifier.\n * @param throwIfUnknown - Whether to throw instead of returning the unknown schema.\n * @returns The matching schema, or the unknown permission schema fallback.\n */\nexport function getPermissionSchemaEntry(\n  permissionType: string,\n  throwIfUnknown: boolean = false,\n): PermissionSchemaEntry {\n  if (\n    Object.prototype.hasOwnProperty.call(PERMISSION_SCHEMAS, permissionType)\n  ) {\n    return (PERMISSION_SCHEMAS as Record<string, PermissionSchemaEntry>)[\n      permissionType\n    ] as PermissionSchemaEntry;\n  }\n  if (throwIfUnknown) {\n    throw new Error(`Unknown permission type: ${permissionType}`);\n  }\n\n  return unknownPermissionTypeSchema;\n}\n","import { makeErc20TokenAllowanceDecoderConfig } from './caveats/erc20TokenAllowance';\nimport { makeErc20TokenPeriodicDecoderConfig } from './caveats/erc20TokenPeriodic';\nimport { makeErc20TokenStreamDecoderConfig } from './caveats/erc20TokenStream';\nimport { makeNativeTokenAllowanceDecoderConfig } from './caveats/nativeTokenAllowance';\nimport { makeNativeTokenPeriodicDecoderConfig } from './caveats/nativeTokenPeriodic';\nimport { makeNativeTokenStreamDecoderConfig } from './caveats/nativeTokenStream';\nimport { makeTokenApprovalRevocationDecoderConfig } from './caveats/tokenApprovalRevocation';\nimport type { EnforcerAddressesByName, PermissionDecoderConfig } from './types';\nimport { checksumEnforcerAddresses } from './utils';\n\nexport {\n  createErc20TokenStreamCaveats,\n  type Erc20TokenStreamEnforcers,\n} from './caveats/erc20TokenStream';\nexport {\n  createErc20TokenPeriodicCaveats,\n  type Erc20TokenPeriodicEnforcers,\n} from './caveats/erc20TokenPeriodic';\nexport {\n  createErc20TokenAllowanceCaveats,\n  type Erc20TokenAllowanceEnforcers,\n} from './caveats/erc20TokenAllowance';\nexport {\n  createNativeTokenStreamCaveats,\n  type NativeTokenStreamEnforcers,\n} from './caveats/nativeTokenStream';\nexport {\n  createNativeTokenPeriodicCaveats,\n  type NativeTokenPeriodicEnforcers,\n} from './caveats/nativeTokenPeriodic';\nexport {\n  createNativeTokenAllowanceCaveats,\n  type NativeTokenAllowanceEnforcers,\n} from './caveats/nativeTokenAllowance';\nexport {\n  createTokenApprovalRevocationCaveats,\n  type TokenApprovalRevocationEnforcers,\n} from './caveats/tokenApprovalRevocation';\n\nexport type { ExpiryRule } from './rules/expiry';\nexport type { PayeeRule } from './rules/payee';\nexport type { RedeemerRule } from './rules/redeemer';\nexport type { EnforcerAddressesByName, PermissionDecoderConfig };\nexport {\n  DAY,\n  FORTNIGHT,\n  HOUR,\n  MAX_UINT256,\n  MONTH,\n  SECOND,\n  WEEK,\n  YEAR,\n  ALL_METAMASK_FACILITATOR_ADDRESSES,\n  METAMASK_FACILITATOR_ADDRESSES,\n  METAMASK_FACILITATOR_ADDRESSES_DEV,\n  areOnlyMetaMaskFacilitatorAddresses,\n  isMetaMaskFacilitatorAddress,\n  convertAmountPerSecondToAmountPerPeriod,\n  convertMillisecondsToSeconds,\n  formatPermissionPeriodDuration,\n  getPeriodFrequencyValueTranslationKey,\n  parseHexPermissionAmount,\n  getPermissionSchemaEntry,\n} from './schema';\nexport type {\n  AccountField,\n  AddressField,\n  AmountField,\n  DateField,\n  DividerElement,\n  ExpiryField,\n  FieldView,\n  I18nFunction,\n  JustificationField,\n  ListField,\n  NetworkField,\n  OriginField,\n  PermissionRenderContext,\n  PermissionSchemaEntry,\n  PermissionSchemaRegistry,\n  RawTextField,\n  ReviewFieldView,\n  RuleAddressField,\n  SchemaElement,\n  SchemaSection,\n  TextField,\n  TokenResolution,\n  TokenVariant,\n} from './schema';\n\n/**\n * Builds the canonical set of permission decoders for a chain.\n *\n * @param contracts - Deployed delegation framework contracts for one chain.\n * @returns The full set of permission decoders for the chain.\n */\nexport const makePermissionDecoderConfigs = (\n  contracts: EnforcerAddressesByName,\n): PermissionDecoderConfig[] => {\n  const enforcerAddresses = checksumEnforcerAddresses(contracts);\n\n  return [\n    makeNativeTokenStreamDecoderConfig(enforcerAddresses),\n    makeNativeTokenPeriodicDecoderConfig(enforcerAddresses),\n    makeNativeTokenAllowanceDecoderConfig(enforcerAddresses),\n    makeErc20TokenStreamDecoderConfig(enforcerAddresses),\n    makeErc20TokenPeriodicDecoderConfig(enforcerAddresses),\n    makeErc20TokenAllowanceDecoderConfig(enforcerAddresses),\n    makeTokenApprovalRevocationDecoderConfig(enforcerAddresses),\n  ];\n};\n"],"mappings":";AACA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,aAAa,mBAAmB;;;ACLzC,SAAS,4BAA4B;;;ACArC,SAAS,0BAA0B;AAQ5B,IAAM,gBACX;AAKK,IAAM,cACX;AAWK,IAAM,sBAAsB,KAAK,MAAM,KAAK,KAAK;AAsCjD,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA;AAAA,EACA,kBAAkB;AACpB,GAIe;AACb,MAAI;AAEJ,aAAW,UAAU,S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C,iBAAiB;AAAA,IACnD,oCAAoC,iBAAiB;AAAA,IACrD,qCAAqC,iBAAiB;AAAA,IACtD,yCAAyC,iBAAiB;AAAA,EAC5D;AACF;","names":["getChecksumAddress","getChecksumAddress","getChecksumAddress","getChecksumAddress","createERC20TokenPeriodTransferTerms","createValueLteTerms","hexToBigInt","validateAndDecodeData","hexToBigInt","createERC20TokenPeriodTransferTerms","createValueLteTerms","createValueLteTerms","bigIntToHex","hexToBigInt","validateAndDecodeData","bigIntToHex","hexToBigInt","createValueLteTerms","hexToBigInt","hexToNumber","validateAndDecodeData","hexToNumber","hexToBigInt","createExactCalldataTerms","createNativeTokenPeriodTransferTerms","bigIntToHex","hexToBigInt","validateAndDecodeData","bigIntToHex","hexToBigInt","createNativeTokenPeriodTransferTerms","createExactCalldataTerms","createExactCalldataTerms","bigIntToHex","hexToBigInt","validateAndDecodeData","bigIntToHex","hexToBigInt","createExactCalldataTerms","validateAndDecodeData","bigIntToHex","hexToBigInt","hexToBigInt","bigIntToHex"]}