{"version":3,"file":"transaction.cjs","sourceRoot":"","sources":["../../../src/types/handlers/transaction.ts"],"names":[],"mappings":";;;AAKA;;;;;;GAMG;AACH,IAAY,aAEX;AAFD,WAAY,aAAa;IACvB,sCAAqB,CAAA;AACvB,CAAC,EAFW,aAAa,6BAAb,aAAa,QAExB","sourcesContent":["import type { CaipChainId } from '@metamask/utils';\n\nimport type { ComponentOrElement } from '..';\nimport type { EnumToUnion } from '../../internals';\n\n/**\n * The severity level of content being returned from a transaction insight.\n * Currently only one level is supported:\n *\n * - `critical` - The transaction is critical and should not be submitted by the\n * user.\n */\nexport enum SeverityLevel {\n  Critical = 'critical',\n}\n\n/**\n * An EIP-1559 (type 2) transaction object.\n *\n * @property from - The address the transaction is being sent from.\n * @property to - The address the transaction is being sent to.\n * @property nonce - The nonce of the transaction.\n * @property value - The value of the transaction.\n * @property data - The data of the transaction.\n * @property gas - The gas limit of the transaction.\n * @property maxFeePerGas - The maximum fee per gas of the transaction.\n * @property maxPriorityFeePerGas - The maximum priority fee per gas of the\n * transaction.\n * @property estimateSuggested - The suggested gas price for the transaction.\n * @property estimateUsed - The gas price used for the transaction.\n * @see https://eips.ethereum.org/EIPS/eip-1559\n */\nexport type EIP1559Transaction = {\n  from: string;\n  to: string;\n  nonce: string;\n  value: string;\n  data: string;\n  gas: string;\n  maxFeePerGas: string;\n  maxPriorityFeePerGas: string;\n  estimateSuggested: string;\n  estimateUsed: string;\n};\n\n/**\n * A legacy (type \"0\") transaction object.\n *\n * @property from - The address the transaction is being sent from.\n * @property to - The address the transaction is being sent to.\n * @property nonce - The nonce of the transaction.\n * @property value - The value of the transaction.\n * @property data - The data of the transaction.\n * @property gas - The gas limit of the transaction.\n * @property gasPrice - The gas price of the transaction.\n * @property estimateSuggested - The suggested gas price for the transaction.\n * @property estimateUsed - The gas price used for the transaction.\n */\nexport type LegacyTransaction = {\n  from: string;\n  to: string;\n  nonce: string;\n  value: string;\n  data: string;\n  gas: string;\n  gasPrice: string;\n  estimateSuggested: string;\n  estimateUsed: string;\n};\n\n/**\n * A transaction object. This can be either an EIP-1559 transaction or a legacy\n * transaction.\n *\n * @see EIP1559Transaction\n * @see LegacyTransaction\n */\nexport type Transaction = EIP1559Transaction | LegacyTransaction;\n\n/**\n * The `onTransaction` handler. This is called whenever a transaction is\n * submitted to the snap. It can return insights about the transaction, which\n * will be displayed to the user.\n *\n * Note that using this handler requires the `endowment:transaction-insights`\n * permission.\n *\n * @param args - The request arguments.\n * @param args.transaction - The transaction object, containing the address,\n * value, data, and other properties of the transaction.\n * @param args.chainId - The CAIP-2 {@link CaipChainId} of the network the\n * transaction is being submitted to.\n * @param args.transactionOrigin - The origin of the transaction. This is the\n * URL of the website that submitted the transaction or 'metamask'.\n * This is only available if the Snap has enabled the `allowTransactionOrigin`\n * option in the `endowment:transaction-insight` permission.\n * @returns An object containing insights about the transaction. See\n * {@link OnTransactionResponse}. Can also return `null` if no insights are\n * available.\n */\nexport type OnTransactionHandler = (args: {\n  transaction: Transaction;\n  chainId: CaipChainId;\n  transactionOrigin?: string;\n}) => Promise<OnTransactionResponse | null>;\n\n/**\n * The response from a Snap's `onTransaction` handler.\n *\n * @property component - A custom UI component, that will be shown in MetaMask.\n * @property id - A Snap interface ID.\n * @property severity - The severity level of the content. Currently only one\n * level is supported: `critical`.\n */\nexport type OnTransactionResponse =\n  | {\n      content: ComponentOrElement;\n      severity?: EnumToUnion<SeverityLevel>;\n    }\n  | {\n      id: string;\n      severity?: EnumToUnion<SeverityLevel>;\n    };\n"]}