import { Caveat } from '@metamask/delegation-core'; import { Hex as Hex$1 } from '@metamask/utils'; type Hex = `0x${string}`; type BasePermission = { type: string; isAdjustmentAllowed: boolean; data: Record; }; type Rule = { type: string; data: Record; }; type MetaMaskBasePermissionData = { justification?: string | null; }; type RecursivePopulated = TParent extends (infer U)[] ? RecursivePopulated[] : TParent extends object ? { [P in keyof TParent]-?: RecursivePopulated>; } : Exclude; type Populated = RecursivePopulated; type NativeTokenStreamPermission = BasePermission & { type: 'native-token-stream'; data: MetaMaskBasePermissionData & { initialAmount?: Hex | null; maxAmount?: Hex | null; amountPerSecond: Hex; startTime?: number | null; }; }; type NativeTokenPeriodicPermission = BasePermission & { type: 'native-token-periodic'; data: MetaMaskBasePermissionData & { periodAmount: Hex; periodDuration: number; startTime?: number | null; }; }; type Erc20TokenStreamPermission = BasePermission & { type: 'erc20-token-stream'; data: MetaMaskBasePermissionData & { initialAmount?: Hex | null; maxAmount?: Hex | null; amountPerSecond: Hex; startTime?: number | null; tokenAddress: Hex; }; }; type Erc20TokenPeriodicPermission = BasePermission & { type: 'erc20-token-periodic'; data: MetaMaskBasePermissionData & { periodAmount: Hex; periodDuration: number; startTime?: number | null; tokenAddress: Hex; }; }; type NativeTokenAllowancePermission = BasePermission & { type: 'native-token-allowance'; data: MetaMaskBasePermissionData & { allowanceAmount: Hex; startTime?: number | null; }; }; type Erc20TokenAllowancePermission = BasePermission & { type: 'erc20-token-allowance'; data: MetaMaskBasePermissionData & { allowanceAmount: Hex; startTime?: number | null; tokenAddress: Hex; }; }; type Erc20TokenRevocationPermission = BasePermission & { type: 'erc20-token-revocation'; data: MetaMaskBasePermissionData; }; type TokenApprovalRevocationPermission = BasePermission & { type: 'token-approval-revocation'; data: MetaMaskBasePermissionData & { erc20Approve: boolean; erc721Approve: boolean; erc721SetApprovalForAll: boolean; permit2Approve: boolean; permit2Lockdown: boolean; permit2InvalidateNonces: boolean; }; }; type PermissionTypes = NativeTokenStreamPermission | NativeTokenPeriodicPermission | NativeTokenAllowancePermission | Erc20TokenStreamPermission | Erc20TokenPeriodicPermission | Erc20TokenAllowancePermission | Erc20TokenRevocationPermission | TokenApprovalRevocationPermission; type PermissionRequest = { chainId: Hex; from?: Hex; to: Hex; permission: TPermission; rules?: Rule[] | null; }; type PermissionResponse = PermissionRequest & { context: Hex; dependencies: { factory: Hex; factoryData: Hex; }[]; delegationManager: Hex; }; type RevokeExecutionPermissionRequestParams = { permissionContext: Hex; }; type RevokeExecutionPermissionResponseResult = Record; type ChecksumCaveat = Caveat; type DecodedPermissionData = TPermissionType['data']; type PermissionType = PermissionTypes['type']; type RuleDecoder = (args: { contractAddresses: EnforcerAddressesByName; caveats: ChecksumCaveat[]; requiredEnforcers: Map; }) => Rule | null; type PermissionDecoderConfig = { permissionType: PermissionType; contractAddresses: EnforcerAddressesByName; optionalEnforcers: Hex[]; requiredEnforcers: Record; rules: RuleDecoder[]; validateAndDecodeData: (caveats: ChecksumCaveat[], contractAddresses: EnforcerAddressesByName) => DecodedPermissionData; }; type EnforcerContractName = 'erc20StreamingEnforcer' | 'erc20PeriodTransferEnforcer' | 'nativeTokenStreamingEnforcer' | 'nativeTokenPeriodTransferEnforcer' | 'approvalRevocationEnforcer' | 'exactCalldataEnforcer' | 'valueLteEnforcer' | 'timestampEnforcer' | 'nonceEnforcer' | 'allowedCalldataEnforcer' | 'allowedTargetsEnforcer' | 'redeemerEnforcer'; type EnforcerAddressesByName = Record; type Erc20TokenStreamEnforcers = Pick; declare function createErc20TokenStreamCaveats({ permission, contracts, }: { permission: Populated; contracts: Erc20TokenStreamEnforcers; }): Caveat[]; type Erc20TokenPeriodicEnforcers = Pick; declare function createErc20TokenPeriodicCaveats({ permission, contracts, }: { permission: Populated; contracts: Erc20TokenPeriodicEnforcers; }): Caveat[]; type Erc20TokenAllowanceEnforcers = Pick; declare function createErc20TokenAllowanceCaveats({ permission, contracts, }: { permission: Populated; contracts: Erc20TokenAllowanceEnforcers; }): Caveat[]; type NativeTokenStreamEnforcers = Pick; declare function createNativeTokenStreamCaveats({ permission, contracts, }: { permission: Populated; contracts: NativeTokenStreamEnforcers; }): Caveat[]; type NativeTokenPeriodicEnforcers = Pick; declare function createNativeTokenPeriodicCaveats({ permission, contracts, }: { permission: Populated; contracts: NativeTokenPeriodicEnforcers; }): Caveat[]; type NativeTokenAllowanceEnforcers = Pick; declare function createNativeTokenAllowanceCaveats({ permission, contracts, }: { permission: Populated; contracts: NativeTokenAllowanceEnforcers; }): Caveat[]; type TokenApprovalRevocationEnforcers = Pick; declare function createTokenApprovalRevocationCaveats({ permission, contracts, }: { permission: Populated; contracts: TokenApprovalRevocationEnforcers; }): Caveat[]; type ExpiryRule = { type: 'expiry'; data: { timestamp: number; }; }; type PayeeRule = { type: 'payee'; data: { addresses: Hex[]; }; }; type RedeemerRule = { type: 'redeemer'; data: { addresses: Hex[]; }; }; type I18nFunction = (key: string, args?: (string | number | undefined | null)[]) => string; type I18nValue = { key: string; args?: (string | number)[]; }; type FieldView = 'confirmation' | 'reviewDetail' | 'reviewSummary'; type ReviewFieldView = Exclude; type PermissionRenderContext = { permission: { type: string; data: Record; justification?: string; }; expiry: number | null; redeemerAddresses?: string[] | null; payeeAddresses?: string[] | null; chainId: Hex$1; origin?: string; to?: string; tokenInfo?: { symbol: string; decimals: number | undefined; imageUrl?: string; }; streamTotalExposure?: bigint | null; }; type TokenVariant = 'native' | 'erc20'; type TranslationKeys = 'account' | 'amount' | 'confirmFieldAllowance' | 'confirmFieldAvailablePerDay' | 'confirmFieldFrequency' | 'confirmFieldTotalExposure' | 'gatorPermissionsExpirationDate' | 'gatorPermissionsInitialAllowance' | 'gatorPermissionsJustification' | 'gatorPermissionsMaxAllowance' | 'gatorPermissionsRevocationMethods' | 'gatorPermissionsStartDate' | 'gatorPermissionsStreamingAmountLabel' | 'gatorPermissionsStreamRate' | 'gatorPermissionTokenPeriodicFrequencyLabel' | 'gatorPermissionTokenStreamFrequencyLabel' | 'payee' | 'recipient' | 'redeemer' | 'redeemers' | 'requestFrom' | 'revokeTokenApprovals' | 'unknownPermissionType'; type BaseField = { type: TType; labelKey: TranslationKeys; testId: string; getValue: (ctx: PermissionRenderContext) => TValueType; isVisible: (ctx: PermissionRenderContext) => boolean; includeInViews: FieldView[]; }; type TooltipFieldConfig = { tooltip?: string; }; type AmountField = BaseField<'amount', bigint> & TooltipFieldConfig & { getTokenAddress?: (ctx: PermissionRenderContext) => Hex$1; isRatePerSecond?: boolean; }; type TextField = BaseField<'text', I18nValue> & TooltipFieldConfig; type RawTextField = BaseField<'raw-text', string> & TooltipFieldConfig; type ListField = BaseField<'list', string[]> & TooltipFieldConfig; type DateField = BaseField<'date', number> & TooltipFieldConfig; type ExpiryField = BaseField<'expiry', number | null>; type DividerElement = { type: 'divider'; includeInViews: FieldView[]; }; type JustificationField = BaseField<'justification', string | I18nValue>; type AccountField = BaseField<'account', undefined>; type OriginField = BaseField<'origin', string | undefined> & TooltipFieldConfig; type AddressField = BaseField<'address', string | undefined>; type RuleAddressField = BaseField<'rule-address', string[] | undefined>; type NetworkField = { type: 'network'; includeInViews: FieldView[]; }; type SchemaElement = AmountField | TextField | RawTextField | ListField | DateField | ExpiryField | DividerElement | JustificationField | AccountField | OriginField | AddressField | NetworkField | RuleAddressField; type SchemaSection = { testId: string; elements: SchemaElement[]; }; type TokenResolution = { kind: 'native'; } | { kind: 'erc20'; getTokenAddress: (permission: { data: Record; }) => string; } | { kind: 'none'; }; type PermissionSchemaEntry = { tokenVariant: TokenVariant | 'none'; tokenResolution: TokenResolution; validate?: (permission: { data: Record; }) => void; sections: SchemaSection[]; }; type PermissionSchemaRegistry = Record, PermissionSchemaEntry>; declare const SECOND = 1000; declare const HOUR: number; declare const DAY: number; declare const WEEK: number; declare const FORTNIGHT: number; declare const MONTH: number; declare const YEAR: number; declare const MAX_UINT256 = "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"; declare const METAMASK_FACILITATOR_ADDRESSES: readonly ["0xB01caEa8c6C47bbf4F4b4c5080Ca642043359C2E", "0xC066ac5D385419B1A8c43A0E146fA439837a8B8c", "0xB42F812A44c22cc6b861478900401ee759EbEAD6"]; declare const METAMASK_FACILITATOR_ADDRESSES_DEV: readonly ["0xb4827A2a066CD2Ef88560EFdf063dD05C6c41cC7"]; declare const ALL_METAMASK_FACILITATOR_ADDRESSES: readonly ["0xB01caEa8c6C47bbf4F4b4c5080Ca642043359C2E", "0xC066ac5D385419B1A8c43A0E146fA439837a8B8c", "0xB42F812A44c22cc6b861478900401ee759EbEAD6", "0xb4827A2a066CD2Ef88560EFdf063dD05C6c41cC7"]; declare function isMetaMaskFacilitatorAddress(address: string): boolean; declare function areOnlyMetaMaskFacilitatorAddresses(addresses: string[] | null | undefined): boolean; declare function parseHexPermissionAmount(value: string): bigint; declare function getPeriodFrequencyValueTranslationKey(periodDurationInSeconds: number): string; declare function formatPermissionPeriodDuration(periodSeconds: number): I18nValue; declare function convertMillisecondsToSeconds(milliseconds: number): number; declare function convertAmountPerSecondToAmountPerPeriod(amountPerSecond: Hex$1, period: 'weekly' | 'monthly' | 'fortnightly' | 'yearly'): Hex$1; declare function getPermissionSchemaEntry(permissionType: string, throwIfUnknown?: boolean): PermissionSchemaEntry; declare const makePermissionDecoderConfigs: (contracts: EnforcerAddressesByName) => PermissionDecoderConfig[]; export { ALL_METAMASK_FACILITATOR_ADDRESSES, type AccountField, type AddressField, type AmountField, type BasePermission, DAY, type DateField, type DividerElement, type EnforcerAddressesByName, type Erc20TokenAllowanceEnforcers, type Erc20TokenAllowancePermission, type Erc20TokenPeriodicEnforcers, type Erc20TokenPeriodicPermission, type Erc20TokenRevocationPermission, type Erc20TokenStreamEnforcers, type Erc20TokenStreamPermission, type ExpiryField, type ExpiryRule, FORTNIGHT, type FieldView, HOUR, type Hex, type I18nFunction, type I18nValue, type JustificationField, type ListField, MAX_UINT256, METAMASK_FACILITATOR_ADDRESSES, METAMASK_FACILITATOR_ADDRESSES_DEV, MONTH, type MetaMaskBasePermissionData, type NativeTokenAllowanceEnforcers, type NativeTokenAllowancePermission, type NativeTokenPeriodicEnforcers, type NativeTokenPeriodicPermission, type NativeTokenStreamEnforcers, type NativeTokenStreamPermission, type NetworkField, type OriginField, type PayeeRule, type PermissionDecoderConfig, type PermissionRenderContext, type PermissionRequest, type PermissionResponse, type PermissionSchemaEntry, type PermissionSchemaRegistry, type PermissionTypes, type Populated, type RawTextField, type RedeemerRule, type ReviewFieldView, type RevokeExecutionPermissionRequestParams, type RevokeExecutionPermissionResponseResult, type Rule, type RuleAddressField, SECOND, type SchemaElement, type SchemaSection, type TextField, type TokenApprovalRevocationEnforcers, type TokenApprovalRevocationPermission, type TokenResolution, type TokenVariant, type TranslationKeys, WEEK, YEAR, areOnlyMetaMaskFacilitatorAddresses, convertAmountPerSecondToAmountPerPeriod, convertMillisecondsToSeconds, createErc20TokenAllowanceCaveats, createErc20TokenPeriodicCaveats, createErc20TokenStreamCaveats, createNativeTokenAllowanceCaveats, createNativeTokenPeriodicCaveats, createNativeTokenStreamCaveats, createTokenApprovalRevocationCaveats, formatPermissionPeriodDuration, getPeriodFrequencyValueTranslationKey, getPermissionSchemaEntry, isMetaMaskFacilitatorAddress, makePermissionDecoderConfigs, parseHexPermissionAmount };