{"version":3,"sources":["/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/7715-permission-types/dist/index.cjs","../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"],"names":[],"mappings":"AAAA;ACCA;AACE;AACA;AAAA,2DACK;AACP,wCAAyC;ADCzC;AACA;AEPA;AFSA;AACA;AGVA;AAQO,IAAM,cAAA,EACX,oEAAA;AAKK,IAAM,YAAA,EACX,oEAAA;AAWK,IAAM,oBAAA,EAAsB,GAAA,EAAK,IAAA,EAAM,GAAA,EAAK,GAAA,EAAK,EAAA;AAsCjD,SAAS,kBAAA,CAAmB;AAAA,EACjC,OAAA;AAAA,EACA,QAAA;AAAA,EACA,gBAAA,EAAkB;AACpB,CAAA,EAIe;AACb,EAAA,IAAI,cAAA;AAEJ,EAAA,IAAA,CAAA,MAAW,OAAA,GAAU,OAAA,EAAS;AAC5B,IAAA,GAAA,CAAI,MAAA,CAAO,SAAA,IAAa,QAAA,EAAU;AAChC,MAAA,QAAA;AAAA,IACF;AAEA,IAAA,GAAA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EAAA;AAG9D,EAAA;AACF;AxB8+CA;AACA;AyB9+CO;AAGL,EAAA;AAEA,EAAA;AAAO,IAAA;AAC+C,IAAA;AACE,IAAA;AACC,IAAA;AACJ,IAAA;AACE,IAAA;AACC,IAAA;AACI,EAAA;AAE9D;AzB6+CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/7715-permission-types/dist/index.cjs","sourcesContent":[null,"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"]}