@metamask-previews/eip-5792-middleware 2.0.0-preview-bfee350 → 2.0.0-preview-5c1b2b1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/getCapabilities.cjs.map +1 -1
- package/dist/hooks/getCapabilities.mjs.map +1 -1
- package/dist/methods/wallet_getCallsStatus.cjs.map +1 -1
- package/dist/methods/wallet_getCallsStatus.d.cts +1 -1
- package/dist/methods/wallet_getCallsStatus.d.cts.map +1 -1
- package/dist/methods/wallet_getCallsStatus.d.mts +1 -1
- package/dist/methods/wallet_getCallsStatus.d.mts.map +1 -1
- package/dist/methods/wallet_getCallsStatus.mjs.map +1 -1
- package/dist/methods/wallet_getCapabilities.cjs.map +1 -1
- package/dist/methods/wallet_getCapabilities.d.cts +1 -1
- package/dist/methods/wallet_getCapabilities.d.cts.map +1 -1
- package/dist/methods/wallet_getCapabilities.d.mts +1 -1
- package/dist/methods/wallet_getCapabilities.d.mts.map +1 -1
- package/dist/methods/wallet_getCapabilities.mjs.map +1 -1
- package/dist/methods/wallet_sendCalls.cjs.map +1 -1
- package/dist/methods/wallet_sendCalls.d.cts +1 -1
- package/dist/methods/wallet_sendCalls.d.cts.map +1 -1
- package/dist/methods/wallet_sendCalls.d.mts +1 -1
- package/dist/methods/wallet_sendCalls.d.mts.map +1 -1
- package/dist/methods/wallet_sendCalls.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCapabilities.cjs","sourceRoot":"","sources":["../../src/hooks/getCapabilities.ts"],"names":[],"mappings":";;;AAOA,gDAA6D;AAE7D,wCAAiD;AAsBjD;;;;;;;;GAQG;AACI,KAAK,UAAU,eAAe,CACnC,KAA2B,EAC3B,SAA2B,EAC3B,OAAY,EACZ,QAA2B;IAE3B,MAAM,EACJ,uCAAuC,EACvC,qBAAqB,EACrB,sBAAsB,EACtB,gBAAgB,EAChB,4BAA4B,EAC5B,y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AAQ,CAAC,CAAC;IAE/C,MAAM,mBAAmB,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QAChE,GAAG,OAAO;QACV,sBAAsB,EAAE,oBAAoB,CAAC,KAAK,CAAC;KACpD,CAAC,CAAC,CAAC;IAEJ,OAAO,QAAQ,CAAC,MAAM,CAAwB,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;QAC7D,MAAM,iBAAiB,GAAG,CAAC,mBAAmB,CAAC,IAAI,CACjD,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,YAAY,KAAK,OAAO,CACxD,IAAI,EAAE,CAEN,CAAC;QAEF,MAAM,EAAE,WAAW,GAAG,KAAK,EAAE,sBAAsB,EAAE,GAAG,iBAAiB,CAAC;QAE1E,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;QAC1D,MAAM,qBAAqB,GAAG,yBAAyB,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC;QAE1E,MAAM,gBAAgB,GACpB,iBAAiB;YACjB,CAAC,CAAC,kBAAkB,IAAI,qBAAqB,CAAC;gBAC5C,CAAC,WAAW,IAAI,sBAAsB,CAAC,CAAC,CAAC;QAE7C,IAAI,gBAAgB,EAAE,CAAC;YACrB,GAAG,CAAC,OAAc,CAAC,GAAG;gBACpB,gBAAgB,EAAE;oBAChB,SAAS,EAAE,IAAI;iBAChB;aACF,CAAC;QACJ,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC","sourcesContent":["import type {\n IsAtomicBatchSupportedResult,\n IsAtomicBatchSupportedResultEntry,\n TransactionController,\n} from '@metamask/transaction-controller';\nimport type { Hex } from '@metamask/utils';\n\nimport { KEYRING_TYPES_SUPPORTING_7702 } from '../constants';\nimport type { EIP5792Messenger, GetCapabilitiesResult } from '../types';\nimport { getAccountKeyringType } from '../utils';\n\n/**\n * Type definition for required controller hooks and utilities of {@link getCapabilities}\n */\nexport type GetCapabilitiesHooks = {\n /** Function to check if smart account suggestions are disabled */\n getDismissSmartAccountSuggestionEnabled: () => boolean;\n /** Function to check if a chain supports smart transactions */\n getIsSmartTransaction: (chainId: Hex) => boolean;\n /** Function to check if atomic batching is supported */\n isAtomicBatchSupported: TransactionController['isAtomicBatchSupported'];\n /** Function to check if relay is supported on a chain */\n isRelaySupported: (chainId: Hex) => Promise<boolean>;\n /** Function to get chains that support send bundle */\n getSendBundleSupportedChains: (\n chainIds: Hex[],\n ) => Promise<Record<string, boolean>>;\n /** Function to validate if auxiliary funds capability is supported. */\n isAuxiliaryFundsSupported: (chainId: Hex) => boolean;\n};\n\n/**\n * Retrieves the capabilities for atomic transactions on specified chains.\n *\n * @param hooks - Object containing required controller hooks and utilities.\n * @param messenger - Messenger instance for controller communication.\n * @param address - The account address to check capabilities for.\n * @param chainIds - Array of chain IDs to check capabilities for (if undefined, checks all configured networks).\n * @returns Promise resolving to GetCapabilitiesResult mapping chain IDs to their capabilities.\n */\nexport async function getCapabilities(\n hooks: GetCapabilitiesHooks,\n messenger: EIP5792Messenger,\n address: Hex,\n chainIds: Hex[] | undefined,\n) {\n const {\n getDismissSmartAccountSuggestionEnabled,\n getIsSmartTransaction,\n isAtomicBatchSupported,\n isRelaySupported,\n getSendBundleSupportedChains,\n isAuxiliaryFundsSupported,\n } = hooks;\n\n let chainIdsNormalized = chainIds?.map(\n (chainId) => chainId.toLowerCase() as Hex,\n );\n\n if (!chainIdsNormalized?.length) {\n const networkConfigurations = messenger.call(\n 'NetworkController:getState',\n ).networkConfigurationsByChainId;\n chainIdsNormalized = Object.keys(networkConfigurations) as Hex[];\n }\n\n const batchSupport = await isAtomicBatchSupported({\n address,\n chainIds: chainIdsNormalized,\n });\n\n const alternateGasFeesAcc = await getAlternateGasFeesCapability(\n chainIdsNormalized,\n batchSupport,\n getIsSmartTransaction,\n isRelaySupported,\n getSendBundleSupportedChains,\n messenger,\n );\n\n return chainIdsNormalized.reduce<GetCapabilitiesResult>((acc, chainId) => {\n const chainBatchSupport = (batchSupport.find(\n ({ chainId: batchChainId }) => batchChainId === chainId,\n ) ?? {}) as IsAtomicBatchSupportedResultEntry & {\n isRelaySupported: boolean;\n };\n\n const { delegationAddress, isSupported, upgradeContractAddress } =\n chainBatchSupport;\n\n const isUpgradeDisabled = getDismissSmartAccountSuggestionEnabled();\n let isSupportedAccount = false;\n\n try {\n const keyringType = getAccountKeyringType(address, messenger);\n isSupportedAccount = KEYRING_TYPES_SUPPORTING_7702.includes(keyringType);\n } catch {\n // Intentionally empty\n }\n\n const canUpgrade =\n !isUpgradeDisabled &&\n upgradeContractAddress &&\n !delegationAddress &&\n isSupportedAccount;\n\n if (!isSupported && !canUpgrade) {\n return acc;\n }\n\n const status = isSupported ? 'supported' : 'ready';\n const hexChainId = chainId as Hex;\n\n if (acc[hexChainId] === undefined) {\n acc[hexChainId] = {};\n }\n\n acc[hexChainId].atomic = {\n status,\n };\n\n if (isSupportedAccount && isAuxiliaryFundsSupported(chainId)) {\n acc[hexChainId].auxiliaryFunds = {\n supported: true,\n };\n }\n\n return acc;\n }, alternateGasFeesAcc);\n}\n\n/**\n * Determines alternate gas fees capability for the specified chains.\n *\n * @param chainIds - Array of chain IDs to check for alternate gas fees support.\n * @param batchSupport - Information about atomic batch support for each chain.\n * @param getIsSmartTransaction - Function to check if a chain supports smart transactions.\n * @param isRelaySupported - Function to check if relay is supported on a chain.\n * @param getSendBundleSupportedChains - Function to get chains that support send bundle.\n * @param messenger - Messenger instance for controller communication.\n * @returns Promise resolving to GetCapabilitiesResult with alternate gas fees information.\n */\nasync function getAlternateGasFeesCapability(\n chainIds: Hex[],\n batchSupport: IsAtomicBatchSupportedResult,\n getIsSmartTransaction: (chainId: Hex) => boolean,\n isRelaySupported: (chainId: Hex) => Promise<boolean>,\n getSendBundleSupportedChains: (\n chainIds: Hex[],\n ) => Promise<Record<string, boolean>>,\n messenger: EIP5792Messenger,\n) {\n const simulationEnabled = messenger.call(\n 'PreferencesController:getState',\n ).useTransactionSimulations;\n\n const relaySupportedChains = await Promise.all(\n batchSupport\n .map(({ chainId }) => chainId)\n .map((chainId) => isRelaySupported(chainId)),\n );\n\n const sendBundleSupportedChains =\n await getSendBundleSupportedChains(chainIds);\n\n const updatedBatchSupport = batchSupport.map((support, index) => ({\n ...support,\n relaySupportedForChain: relaySupportedChains[index],\n }));\n\n return chainIds.reduce<GetCapabilitiesResult>((acc, chainId) => {\n const chainBatchSupport = (updatedBatchSupport.find(\n ({ chainId: batchChainId }) => batchChainId === chainId,\n ) ?? {}) as IsAtomicBatchSupportedResultEntry & {\n relaySupportedForChain: boolean;\n };\n\n const { isSupported = false, relaySupportedForChain } = chainBatchSupport;\n\n const isSmartTransaction = getIsSmartTransaction(chainId);\n const isSendBundleSupported = sendBundleSupportedChains[chainId] ?? false;\n\n const alternateGasFees =\n simulationEnabled &&\n ((isSmartTransaction && isSendBundleSupported) ||\n (isSupported && relaySupportedForChain));\n\n if (alternateGasFees) {\n acc[chainId as Hex] = {\n alternateGasFees: {\n supported: true,\n },\n };\n }\n\n return acc;\n }, {});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"getCapabilities.cjs","sourceRoot":"","sources":["../../src/hooks/getCapabilities.ts"],"names":[],"mappings":";;;AAOA,gDAA6D;AAE7D,wCAAiD;AAsBjD;;;;;;;;GAQG;AACI,KAAK,UAAU,eAAe,CACnC,KAA2B,EAC3B,SAA2B,EAC3B,OAAY,EACZ,QAA2B;IAE3B,MAAM,EACJ,uCAAuC,EACvC,qBAAqB,EACrB,sBAAsB,EACtB,gBAAgB,EAChB,4BAA4B,EAC5B,yBAAyB,GAC1B,GAAG,KAAK,CAAC;IAEV,IAAI,kBAAkB,GAAG,QAAQ,EAAE,GAAG,CACpC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,EAAS,CAC1C,CAAC;IAEF,IAAI,CAAC,kBAAkB,EAAE,MAAM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CAAC,CAAC,CAAC;IAEJ,OAAO,QAAQ,CAAC,MAAM,CAAwB,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;QAC7D,MAAM,iBAAiB,GAAG,CAAC,mBAAmB,CAAC,IAAI,CACjD,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,YAAY,KAAK,OAAO,CACxD,IAAI,EAAE,CAEN,CAAC;QAEF,MAAM,EAAE,WAAW,GAAG,KAAK,EAAE,sBAAsB,EAAE,GAAG,iBAAiB,CAAC;QAE1E,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;QAC1D,MAAM,qBAAqB,GAAG,yBAAyB,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC;QAE1E,MAAM,gBAAgB,GACpB,iBAAiB;YACjB,CAAC,CAAC,kBAAkB,IAAI,qBAAqB,CAAC;gBAC5C,CAAC,WAAW,IAAI,sBAAsB,CAAC,CAAC,CAAC;QAE7C,IAAI,gBAAgB,EAAE,CAAC;YACrB,GAAG,CAAC,OAAO,CAAC,GAAG;gBACb,gBAAgB,EAAE;oBAChB,SAAS,EAAE,IAAI;iBAChB;aACF,CAAC;QACJ,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC","sourcesContent":["import type {\n IsAtomicBatchSupportedResult,\n IsAtomicBatchSupportedResultEntry,\n TransactionController,\n} from '@metamask/transaction-controller';\nimport type { Hex } from '@metamask/utils';\n\nimport { KEYRING_TYPES_SUPPORTING_7702 } from '../constants';\nimport type { EIP5792Messenger, GetCapabilitiesResult } from '../types';\nimport { getAccountKeyringType } from '../utils';\n\n/**\n * Type definition for required controller hooks and utilities of {@link getCapabilities}\n */\nexport type GetCapabilitiesHooks = {\n /** Function to check if smart account suggestions are disabled */\n getDismissSmartAccountSuggestionEnabled: () => boolean;\n /** Function to check if a chain supports smart transactions */\n getIsSmartTransaction: (chainId: Hex) => boolean;\n /** Function to check if atomic batching is supported */\n isAtomicBatchSupported: TransactionController['isAtomicBatchSupported'];\n /** Function to check if relay is supported on a chain */\n isRelaySupported: (chainId: Hex) => Promise<boolean>;\n /** Function to get chains that support send bundle */\n getSendBundleSupportedChains: (\n chainIds: Hex[],\n ) => Promise<Record<string, boolean>>;\n /** Function to validate if auxiliary funds capability is supported. */\n isAuxiliaryFundsSupported: (chainId: Hex) => boolean;\n};\n\n/**\n * Retrieves the capabilities for atomic transactions on specified chains.\n *\n * @param hooks - Object containing required controller hooks and utilities.\n * @param messenger - Messenger instance for controller communication.\n * @param address - The account address to check capabilities for.\n * @param chainIds - Array of chain IDs to check capabilities for (if undefined, checks all configured networks).\n * @returns Promise resolving to GetCapabilitiesResult mapping chain IDs to their capabilities.\n */\nexport async function getCapabilities(\n hooks: GetCapabilitiesHooks,\n messenger: EIP5792Messenger,\n address: Hex,\n chainIds: Hex[] | undefined,\n) {\n const {\n getDismissSmartAccountSuggestionEnabled,\n getIsSmartTransaction,\n isAtomicBatchSupported,\n isRelaySupported,\n getSendBundleSupportedChains,\n isAuxiliaryFundsSupported,\n } = hooks;\n\n let chainIdsNormalized = chainIds?.map(\n (chainId) => chainId.toLowerCase() as Hex,\n );\n\n if (!chainIdsNormalized?.length) {\n const networkConfigurations = messenger.call(\n 'NetworkController:getState',\n ).networkConfigurationsByChainId;\n chainIdsNormalized = Object.keys(networkConfigurations) as Hex[];\n }\n\n const batchSupport = await isAtomicBatchSupported({\n address,\n chainIds: chainIdsNormalized,\n });\n\n const alternateGasFeesAcc = await getAlternateGasFeesCapability(\n chainIdsNormalized,\n batchSupport,\n getIsSmartTransaction,\n isRelaySupported,\n getSendBundleSupportedChains,\n messenger,\n );\n\n return chainIdsNormalized.reduce<GetCapabilitiesResult>((acc, chainId) => {\n const chainBatchSupport = (batchSupport.find(\n ({ chainId: batchChainId }) => batchChainId === chainId,\n ) ?? {}) as IsAtomicBatchSupportedResultEntry & {\n isRelaySupported: boolean;\n };\n\n const { delegationAddress, isSupported, upgradeContractAddress } =\n chainBatchSupport;\n\n const isUpgradeDisabled = getDismissSmartAccountSuggestionEnabled();\n let isSupportedAccount = false;\n\n try {\n const keyringType = getAccountKeyringType(address, messenger);\n isSupportedAccount = KEYRING_TYPES_SUPPORTING_7702.includes(keyringType);\n } catch {\n // Intentionally empty\n }\n\n const canUpgrade =\n !isUpgradeDisabled &&\n upgradeContractAddress &&\n !delegationAddress &&\n isSupportedAccount;\n\n if (!isSupported && !canUpgrade) {\n return acc;\n }\n\n const status = isSupported ? 'supported' : 'ready';\n const hexChainId = chainId;\n\n if (acc[hexChainId] === undefined) {\n acc[hexChainId] = {};\n }\n\n acc[hexChainId].atomic = {\n status,\n };\n\n if (isSupportedAccount && isAuxiliaryFundsSupported(chainId)) {\n acc[hexChainId].auxiliaryFunds = {\n supported: true,\n };\n }\n\n return acc;\n }, alternateGasFeesAcc);\n}\n\n/**\n * Determines alternate gas fees capability for the specified chains.\n *\n * @param chainIds - Array of chain IDs to check for alternate gas fees support.\n * @param batchSupport - Information about atomic batch support for each chain.\n * @param getIsSmartTransaction - Function to check if a chain supports smart transactions.\n * @param isRelaySupported - Function to check if relay is supported on a chain.\n * @param getSendBundleSupportedChains - Function to get chains that support send bundle.\n * @param messenger - Messenger instance for controller communication.\n * @returns Promise resolving to GetCapabilitiesResult with alternate gas fees information.\n */\nasync function getAlternateGasFeesCapability(\n chainIds: Hex[],\n batchSupport: IsAtomicBatchSupportedResult,\n getIsSmartTransaction: (chainId: Hex) => boolean,\n isRelaySupported: (chainId: Hex) => Promise<boolean>,\n getSendBundleSupportedChains: (\n chainIds: Hex[],\n ) => Promise<Record<string, boolean>>,\n messenger: EIP5792Messenger,\n) {\n const simulationEnabled = messenger.call(\n 'PreferencesController:getState',\n ).useTransactionSimulations;\n\n const relaySupportedChains = await Promise.all(\n batchSupport\n .map(({ chainId }) => chainId)\n .map((chainId) => isRelaySupported(chainId)),\n );\n\n const sendBundleSupportedChains =\n await getSendBundleSupportedChains(chainIds);\n\n const updatedBatchSupport = batchSupport.map((support, index) => ({\n ...support,\n relaySupportedForChain: relaySupportedChains[index],\n }));\n\n return chainIds.reduce<GetCapabilitiesResult>((acc, chainId) => {\n const chainBatchSupport = (updatedBatchSupport.find(\n ({ chainId: batchChainId }) => batchChainId === chainId,\n ) ?? {}) as IsAtomicBatchSupportedResultEntry & {\n relaySupportedForChain: boolean;\n };\n\n const { isSupported = false, relaySupportedForChain } = chainBatchSupport;\n\n const isSmartTransaction = getIsSmartTransaction(chainId);\n const isSendBundleSupported = sendBundleSupportedChains[chainId] ?? false;\n\n const alternateGasFees =\n simulationEnabled &&\n ((isSmartTransaction && isSendBundleSupported) ||\n (isSupported && relaySupportedForChain));\n\n if (alternateGasFees) {\n acc[chainId] = {\n alternateGasFees: {\n supported: true,\n },\n };\n }\n\n return acc;\n }, {});\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCapabilities.mjs","sourceRoot":"","sources":["../../src/hooks/getCapabilities.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,6BAA6B,EAAE,yBAAqB;AAE7D,OAAO,EAAE,qBAAqB,EAAE,qBAAiB;AAsBjD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,KAA2B,EAC3B,SAA2B,EAC3B,OAAY,EACZ,QAA2B;IAE3B,MAAM,EACJ,uCAAuC,EACvC,qBAAqB,EACrB,sBAAsB,EACtB,gBAAgB,EAChB,4BAA4B,EAC5B,yBAAyB,GAC1B,GAAG,KAAK,CAAC;IAEV,IAAI,kBAAkB,GAAG,QAAQ,EAAE,GAAG,CACpC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,EAAS,CAC1C,CAAC;IAEF,IAAI,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC;QAChC,MAAM,qBAAqB,GAAG,SAAS,CAAC,IAAI,CAC1C,4BAA4B,CAC7B,CAAC,8BAA8B,CAAC;QACjC,kBAAkB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AAC,IAAI,CACjD,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,YAAY,KAAK,OAAO,CACxD,IAAI,EAAE,CAEN,CAAC;QAEF,MAAM,EAAE,WAAW,GAAG,KAAK,EAAE,sBAAsB,EAAE,GAAG,iBAAiB,CAAC;QAE1E,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;QAC1D,MAAM,qBAAqB,GAAG,yBAAyB,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC;QAE1E,MAAM,gBAAgB,GACpB,iBAAiB;YACjB,CAAC,CAAC,kBAAkB,IAAI,qBAAqB,CAAC;gBAC5C,CAAC,WAAW,IAAI,sBAAsB,CAAC,CAAC,CAAC;QAE7C,IAAI,gBAAgB,EAAE,CAAC;YACrB,GAAG,CAAC,OAAc,CAAC,GAAG;gBACpB,gBAAgB,EAAE;oBAChB,SAAS,EAAE,IAAI;iBAChB;aACF,CAAC;QACJ,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC","sourcesContent":["import type {\n IsAtomicBatchSupportedResult,\n IsAtomicBatchSupportedResultEntry,\n TransactionController,\n} from '@metamask/transaction-controller';\nimport type { Hex } from '@metamask/utils';\n\nimport { KEYRING_TYPES_SUPPORTING_7702 } from '../constants';\nimport type { EIP5792Messenger, GetCapabilitiesResult } from '../types';\nimport { getAccountKeyringType } from '../utils';\n\n/**\n * Type definition for required controller hooks and utilities of {@link getCapabilities}\n */\nexport type GetCapabilitiesHooks = {\n /** Function to check if smart account suggestions are disabled */\n getDismissSmartAccountSuggestionEnabled: () => boolean;\n /** Function to check if a chain supports smart transactions */\n getIsSmartTransaction: (chainId: Hex) => boolean;\n /** Function to check if atomic batching is supported */\n isAtomicBatchSupported: TransactionController['isAtomicBatchSupported'];\n /** Function to check if relay is supported on a chain */\n isRelaySupported: (chainId: Hex) => Promise<boolean>;\n /** Function to get chains that support send bundle */\n getSendBundleSupportedChains: (\n chainIds: Hex[],\n ) => Promise<Record<string, boolean>>;\n /** Function to validate if auxiliary funds capability is supported. */\n isAuxiliaryFundsSupported: (chainId: Hex) => boolean;\n};\n\n/**\n * Retrieves the capabilities for atomic transactions on specified chains.\n *\n * @param hooks - Object containing required controller hooks and utilities.\n * @param messenger - Messenger instance for controller communication.\n * @param address - The account address to check capabilities for.\n * @param chainIds - Array of chain IDs to check capabilities for (if undefined, checks all configured networks).\n * @returns Promise resolving to GetCapabilitiesResult mapping chain IDs to their capabilities.\n */\nexport async function getCapabilities(\n hooks: GetCapabilitiesHooks,\n messenger: EIP5792Messenger,\n address: Hex,\n chainIds: Hex[] | undefined,\n) {\n const {\n getDismissSmartAccountSuggestionEnabled,\n getIsSmartTransaction,\n isAtomicBatchSupported,\n isRelaySupported,\n getSendBundleSupportedChains,\n isAuxiliaryFundsSupported,\n } = hooks;\n\n let chainIdsNormalized = chainIds?.map(\n (chainId) => chainId.toLowerCase() as Hex,\n );\n\n if (!chainIdsNormalized?.length) {\n const networkConfigurations = messenger.call(\n 'NetworkController:getState',\n ).networkConfigurationsByChainId;\n chainIdsNormalized = Object.keys(networkConfigurations) as Hex[];\n }\n\n const batchSupport = await isAtomicBatchSupported({\n address,\n chainIds: chainIdsNormalized,\n });\n\n const alternateGasFeesAcc = await getAlternateGasFeesCapability(\n chainIdsNormalized,\n batchSupport,\n getIsSmartTransaction,\n isRelaySupported,\n getSendBundleSupportedChains,\n messenger,\n );\n\n return chainIdsNormalized.reduce<GetCapabilitiesResult>((acc, chainId) => {\n const chainBatchSupport = (batchSupport.find(\n ({ chainId: batchChainId }) => batchChainId === chainId,\n ) ?? {}) as IsAtomicBatchSupportedResultEntry & {\n isRelaySupported: boolean;\n };\n\n const { delegationAddress, isSupported, upgradeContractAddress } =\n chainBatchSupport;\n\n const isUpgradeDisabled = getDismissSmartAccountSuggestionEnabled();\n let isSupportedAccount = false;\n\n try {\n const keyringType = getAccountKeyringType(address, messenger);\n isSupportedAccount = KEYRING_TYPES_SUPPORTING_7702.includes(keyringType);\n } catch {\n // Intentionally empty\n }\n\n const canUpgrade =\n !isUpgradeDisabled &&\n upgradeContractAddress &&\n !delegationAddress &&\n isSupportedAccount;\n\n if (!isSupported && !canUpgrade) {\n return acc;\n }\n\n const status = isSupported ? 'supported' : 'ready';\n const hexChainId = chainId as Hex;\n\n if (acc[hexChainId] === undefined) {\n acc[hexChainId] = {};\n }\n\n acc[hexChainId].atomic = {\n status,\n };\n\n if (isSupportedAccount && isAuxiliaryFundsSupported(chainId)) {\n acc[hexChainId].auxiliaryFunds = {\n supported: true,\n };\n }\n\n return acc;\n }, alternateGasFeesAcc);\n}\n\n/**\n * Determines alternate gas fees capability for the specified chains.\n *\n * @param chainIds - Array of chain IDs to check for alternate gas fees support.\n * @param batchSupport - Information about atomic batch support for each chain.\n * @param getIsSmartTransaction - Function to check if a chain supports smart transactions.\n * @param isRelaySupported - Function to check if relay is supported on a chain.\n * @param getSendBundleSupportedChains - Function to get chains that support send bundle.\n * @param messenger - Messenger instance for controller communication.\n * @returns Promise resolving to GetCapabilitiesResult with alternate gas fees information.\n */\nasync function getAlternateGasFeesCapability(\n chainIds: Hex[],\n batchSupport: IsAtomicBatchSupportedResult,\n getIsSmartTransaction: (chainId: Hex) => boolean,\n isRelaySupported: (chainId: Hex) => Promise<boolean>,\n getSendBundleSupportedChains: (\n chainIds: Hex[],\n ) => Promise<Record<string, boolean>>,\n messenger: EIP5792Messenger,\n) {\n const simulationEnabled = messenger.call(\n 'PreferencesController:getState',\n ).useTransactionSimulations;\n\n const relaySupportedChains = await Promise.all(\n batchSupport\n .map(({ chainId }) => chainId)\n .map((chainId) => isRelaySupported(chainId)),\n );\n\n const sendBundleSupportedChains =\n await getSendBundleSupportedChains(chainIds);\n\n const updatedBatchSupport = batchSupport.map((support, index) => ({\n ...support,\n relaySupportedForChain: relaySupportedChains[index],\n }));\n\n return chainIds.reduce<GetCapabilitiesResult>((acc, chainId) => {\n const chainBatchSupport = (updatedBatchSupport.find(\n ({ chainId: batchChainId }) => batchChainId === chainId,\n ) ?? {}) as IsAtomicBatchSupportedResultEntry & {\n relaySupportedForChain: boolean;\n };\n\n const { isSupported = false, relaySupportedForChain } = chainBatchSupport;\n\n const isSmartTransaction = getIsSmartTransaction(chainId);\n const isSendBundleSupported = sendBundleSupportedChains[chainId] ?? false;\n\n const alternateGasFees =\n simulationEnabled &&\n ((isSmartTransaction && isSendBundleSupported) ||\n (isSupported && relaySupportedForChain));\n\n if (alternateGasFees) {\n acc[chainId as Hex] = {\n alternateGasFees: {\n supported: true,\n },\n };\n }\n\n return acc;\n }, {});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"getCapabilities.mjs","sourceRoot":"","sources":["../../src/hooks/getCapabilities.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,6BAA6B,EAAE,yBAAqB;AAE7D,OAAO,EAAE,qBAAqB,EAAE,qBAAiB;AAsBjD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,KAA2B,EAC3B,SAA2B,EAC3B,OAAY,EACZ,QAA2B;IAE3B,MAAM,EACJ,uCAAuC,EACvC,qBAAqB,EACrB,sBAAsB,EACtB,gBAAgB,EAChB,4BAA4B,EAC5B,yBAAyB,GAC1B,GAAG,KAAK,CAAC;IAEV,IAAI,kBAAkB,GAAG,QAAQ,EAAE,GAAG,CACpC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,EAAS,CAC1C,CAAC;IAEF,IAAI,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC;QAChC,MAAM,qBAAqB,GAAG,SAAS,CAAC,IAAI,CAC1C,4BAA4B,CAC7B,CAAC,8BAA8B,CAAC;QACjC,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAU,CAAC;IACnE,CAAC;IAED,MAAM,YAAY,GAAG,MAAM,sBAAsB,CAAC;QAChD,OAAO;QACP,QAAQ,EAAE,kBAAkB;KA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G,KAAK,EAAE,sBAAsB,EAAE,GAAG,iBAAiB,CAAC;QAE1E,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;QAC1D,MAAM,qBAAqB,GAAG,yBAAyB,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC;QAE1E,MAAM,gBAAgB,GACpB,iBAAiB;YACjB,CAAC,CAAC,kBAAkB,IAAI,qBAAqB,CAAC;gBAC5C,CAAC,WAAW,IAAI,sBAAsB,CAAC,CAAC,CAAC;QAE7C,IAAI,gBAAgB,EAAE,CAAC;YACrB,GAAG,CAAC,OAAO,CAAC,GAAG;gBACb,gBAAgB,EAAE;oBAChB,SAAS,EAAE,IAAI;iBAChB;aACF,CAAC;QACJ,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC","sourcesContent":["import type {\n IsAtomicBatchSupportedResult,\n IsAtomicBatchSupportedResultEntry,\n TransactionController,\n} from '@metamask/transaction-controller';\nimport type { Hex } from '@metamask/utils';\n\nimport { KEYRING_TYPES_SUPPORTING_7702 } from '../constants';\nimport type { EIP5792Messenger, GetCapabilitiesResult } from '../types';\nimport { getAccountKeyringType } from '../utils';\n\n/**\n * Type definition for required controller hooks and utilities of {@link getCapabilities}\n */\nexport type GetCapabilitiesHooks = {\n /** Function to check if smart account suggestions are disabled */\n getDismissSmartAccountSuggestionEnabled: () => boolean;\n /** Function to check if a chain supports smart transactions */\n getIsSmartTransaction: (chainId: Hex) => boolean;\n /** Function to check if atomic batching is supported */\n isAtomicBatchSupported: TransactionController['isAtomicBatchSupported'];\n /** Function to check if relay is supported on a chain */\n isRelaySupported: (chainId: Hex) => Promise<boolean>;\n /** Function to get chains that support send bundle */\n getSendBundleSupportedChains: (\n chainIds: Hex[],\n ) => Promise<Record<string, boolean>>;\n /** Function to validate if auxiliary funds capability is supported. */\n isAuxiliaryFundsSupported: (chainId: Hex) => boolean;\n};\n\n/**\n * Retrieves the capabilities for atomic transactions on specified chains.\n *\n * @param hooks - Object containing required controller hooks and utilities.\n * @param messenger - Messenger instance for controller communication.\n * @param address - The account address to check capabilities for.\n * @param chainIds - Array of chain IDs to check capabilities for (if undefined, checks all configured networks).\n * @returns Promise resolving to GetCapabilitiesResult mapping chain IDs to their capabilities.\n */\nexport async function getCapabilities(\n hooks: GetCapabilitiesHooks,\n messenger: EIP5792Messenger,\n address: Hex,\n chainIds: Hex[] | undefined,\n) {\n const {\n getDismissSmartAccountSuggestionEnabled,\n getIsSmartTransaction,\n isAtomicBatchSupported,\n isRelaySupported,\n getSendBundleSupportedChains,\n isAuxiliaryFundsSupported,\n } = hooks;\n\n let chainIdsNormalized = chainIds?.map(\n (chainId) => chainId.toLowerCase() as Hex,\n );\n\n if (!chainIdsNormalized?.length) {\n const networkConfigurations = messenger.call(\n 'NetworkController:getState',\n ).networkConfigurationsByChainId;\n chainIdsNormalized = Object.keys(networkConfigurations) as Hex[];\n }\n\n const batchSupport = await isAtomicBatchSupported({\n address,\n chainIds: chainIdsNormalized,\n });\n\n const alternateGasFeesAcc = await getAlternateGasFeesCapability(\n chainIdsNormalized,\n batchSupport,\n getIsSmartTransaction,\n isRelaySupported,\n getSendBundleSupportedChains,\n messenger,\n );\n\n return chainIdsNormalized.reduce<GetCapabilitiesResult>((acc, chainId) => {\n const chainBatchSupport = (batchSupport.find(\n ({ chainId: batchChainId }) => batchChainId === chainId,\n ) ?? {}) as IsAtomicBatchSupportedResultEntry & {\n isRelaySupported: boolean;\n };\n\n const { delegationAddress, isSupported, upgradeContractAddress } =\n chainBatchSupport;\n\n const isUpgradeDisabled = getDismissSmartAccountSuggestionEnabled();\n let isSupportedAccount = false;\n\n try {\n const keyringType = getAccountKeyringType(address, messenger);\n isSupportedAccount = KEYRING_TYPES_SUPPORTING_7702.includes(keyringType);\n } catch {\n // Intentionally empty\n }\n\n const canUpgrade =\n !isUpgradeDisabled &&\n upgradeContractAddress &&\n !delegationAddress &&\n isSupportedAccount;\n\n if (!isSupported && !canUpgrade) {\n return acc;\n }\n\n const status = isSupported ? 'supported' : 'ready';\n const hexChainId = chainId;\n\n if (acc[hexChainId] === undefined) {\n acc[hexChainId] = {};\n }\n\n acc[hexChainId].atomic = {\n status,\n };\n\n if (isSupportedAccount && isAuxiliaryFundsSupported(chainId)) {\n acc[hexChainId].auxiliaryFunds = {\n supported: true,\n };\n }\n\n return acc;\n }, alternateGasFeesAcc);\n}\n\n/**\n * Determines alternate gas fees capability for the specified chains.\n *\n * @param chainIds - Array of chain IDs to check for alternate gas fees support.\n * @param batchSupport - Information about atomic batch support for each chain.\n * @param getIsSmartTransaction - Function to check if a chain supports smart transactions.\n * @param isRelaySupported - Function to check if relay is supported on a chain.\n * @param getSendBundleSupportedChains - Function to get chains that support send bundle.\n * @param messenger - Messenger instance for controller communication.\n * @returns Promise resolving to GetCapabilitiesResult with alternate gas fees information.\n */\nasync function getAlternateGasFeesCapability(\n chainIds: Hex[],\n batchSupport: IsAtomicBatchSupportedResult,\n getIsSmartTransaction: (chainId: Hex) => boolean,\n isRelaySupported: (chainId: Hex) => Promise<boolean>,\n getSendBundleSupportedChains: (\n chainIds: Hex[],\n ) => Promise<Record<string, boolean>>,\n messenger: EIP5792Messenger,\n) {\n const simulationEnabled = messenger.call(\n 'PreferencesController:getState',\n ).useTransactionSimulations;\n\n const relaySupportedChains = await Promise.all(\n batchSupport\n .map(({ chainId }) => chainId)\n .map((chainId) => isRelaySupported(chainId)),\n );\n\n const sendBundleSupportedChains =\n await getSendBundleSupportedChains(chainIds);\n\n const updatedBatchSupport = batchSupport.map((support, index) => ({\n ...support,\n relaySupportedForChain: relaySupportedChains[index],\n }));\n\n return chainIds.reduce<GetCapabilitiesResult>((acc, chainId) => {\n const chainBatchSupport = (updatedBatchSupport.find(\n ({ chainId: batchChainId }) => batchChainId === chainId,\n ) ?? {}) as IsAtomicBatchSupportedResultEntry & {\n relaySupportedForChain: boolean;\n };\n\n const { isSupported = false, relaySupportedForChain } = chainBatchSupport;\n\n const isSmartTransaction = getIsSmartTransaction(chainId);\n const isSendBundleSupported = sendBundleSupportedChains[chainId] ?? false;\n\n const alternateGasFees =\n simulationEnabled &&\n ((isSmartTransaction && isSendBundleSupported) ||\n (isSupported && relaySupportedForChain));\n\n if (alternateGasFees) {\n acc[chainId] = {\n alternateGasFees: {\n supported: true,\n },\n };\n }\n\n return acc;\n }, {});\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet_getCallsStatus.cjs","sourceRoot":"","sources":["../../src/methods/wallet_getCallsStatus.ts"],"names":[],"mappings":";;;AAAA,qDAAiD;AAGjD,
|
|
1
|
+
{"version":3,"file":"wallet_getCallsStatus.cjs","sourceRoot":"","sources":["../../src/methods/wallet_getCallsStatus.ts"],"names":[],"mappings":";;;AAAA,qDAAiD;AAGjD,wCAAgD;AAEhD,wCAA0C;AAE1C;;;;;;;GAOG;AACI,KAAK,UAAU,oBAAoB,CACxC,GAAmB,EACnB,GAA2B,EAC3B,EACE,cAAc,GAGf;IAED,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,sBAAS,CAAC,kBAAkB,EAAE,CAAC;IACvC,CAAC;IAED,IAAA,sBAAc,EAAC,GAAG,CAAC,MAAM,EAAE,4BAAoB,CAAC,CAAC;IAEjD,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAEzB,GAAG,CAAC,MAAM,GAAG,MAAM,cAAc,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;AAC7C,CAAC;AAlBD,oDAkBC","sourcesContent":["import { rpcErrors } from '@metamask/rpc-errors';\nimport type { JsonRpcRequest, PendingJsonRpcResponse } from '@metamask/utils';\n\nimport { GetCallsStatusStruct } from '../types';\nimport type { GetCallsStatusHook } from '../types';\nimport { validateParams } from '../utils';\n\n/**\n * The RPC method handler middleware for `wallet_getCallStatus`\n *\n * @param req - The JSON RPC request's end callback.\n * @param res - The JSON RPC request's pending response object.\n * @param hooks - The hooks object.\n * @param hooks.getCallsStatus - Function that retrieves the status of a transaction batch by its ID.\n */\nexport async function walletGetCallsStatus(\n req: JsonRpcRequest,\n res: PendingJsonRpcResponse,\n {\n getCallsStatus,\n }: {\n getCallsStatus?: GetCallsStatusHook;\n },\n): Promise<void> {\n if (!getCallsStatus) {\n throw rpcErrors.methodNotSupported();\n }\n\n validateParams(req.params, GetCallsStatusStruct);\n\n const id = req.params[0];\n\n res.result = await getCallsStatus(id, req);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet_getCallsStatus.d.cts","sourceRoot":"","sources":["../../src/methods/wallet_getCallsStatus.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,wBAAwB;
|
|
1
|
+
{"version":3,"file":"wallet_getCallsStatus.d.cts","sourceRoot":"","sources":["../../src/methods/wallet_getCallsStatus.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,wBAAwB;AAG9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,qBAAiB;AAGnD;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,sBAAsB,EAC3B,EACE,cAAc,GACf,EAAE;IACD,cAAc,CAAC,EAAE,kBAAkB,CAAC;CACrC,GACA,OAAO,CAAC,IAAI,CAAC,CAUf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet_getCallsStatus.d.mts","sourceRoot":"","sources":["../../src/methods/wallet_getCallsStatus.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,wBAAwB;
|
|
1
|
+
{"version":3,"file":"wallet_getCallsStatus.d.mts","sourceRoot":"","sources":["../../src/methods/wallet_getCallsStatus.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,wBAAwB;AAG9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,qBAAiB;AAGnD;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,sBAAsB,EAC3B,EACE,cAAc,GACf,EAAE;IACD,cAAc,CAAC,EAAE,kBAAkB,CAAC;CACrC,GACA,OAAO,CAAC,IAAI,CAAC,CAUf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet_getCallsStatus.mjs","sourceRoot":"","sources":["../../src/methods/wallet_getCallsStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,6BAA6B;AAGjD,OAAO,
|
|
1
|
+
{"version":3,"file":"wallet_getCallsStatus.mjs","sourceRoot":"","sources":["../../src/methods/wallet_getCallsStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,6BAA6B;AAGjD,OAAO,EAAE,oBAAoB,EAAE,qBAAiB;AAEhD,OAAO,EAAE,cAAc,EAAE,qBAAiB;AAE1C;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,GAAmB,EACnB,GAA2B,EAC3B,EACE,cAAc,GAGf;IAED,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,SAAS,CAAC,kBAAkB,EAAE,CAAC;IACvC,CAAC;IAED,cAAc,CAAC,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAEjD,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAEzB,GAAG,CAAC,MAAM,GAAG,MAAM,cAAc,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import { rpcErrors } from '@metamask/rpc-errors';\nimport type { JsonRpcRequest, PendingJsonRpcResponse } from '@metamask/utils';\n\nimport { GetCallsStatusStruct } from '../types';\nimport type { GetCallsStatusHook } from '../types';\nimport { validateParams } from '../utils';\n\n/**\n * The RPC method handler middleware for `wallet_getCallStatus`\n *\n * @param req - The JSON RPC request's end callback.\n * @param res - The JSON RPC request's pending response object.\n * @param hooks - The hooks object.\n * @param hooks.getCallsStatus - Function that retrieves the status of a transaction batch by its ID.\n */\nexport async function walletGetCallsStatus(\n req: JsonRpcRequest,\n res: PendingJsonRpcResponse,\n {\n getCallsStatus,\n }: {\n getCallsStatus?: GetCallsStatusHook;\n },\n): Promise<void> {\n if (!getCallsStatus) {\n throw rpcErrors.methodNotSupported();\n }\n\n validateParams(req.params, GetCallsStatusStruct);\n\n const id = req.params[0];\n\n res.result = await getCallsStatus(id, req);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet_getCapabilities.cjs","sourceRoot":"","sources":["../../src/methods/wallet_getCapabilities.ts"],"names":[],"mappings":";;;AAAA,qDAAiD;AAGjD,
|
|
1
|
+
{"version":3,"file":"wallet_getCapabilities.cjs","sourceRoot":"","sources":["../../src/methods/wallet_getCapabilities.ts"],"names":[],"mappings":";;;AAAA,qDAAiD;AAGjD,wCAAiD;AAEjD,wCAAyE;AAEzE;;;;;;;;GAQG;AACI,KAAK,UAAU,qBAAqB,CACzC,GAAmB,EACnB,GAA2B,EAC3B,EACE,WAAW,EACX,eAAe,GAIhB;IAED,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,sBAAS,CAAC,kBAAkB,EAAE,CAAC;IACvC,CAAC;IAED,IAAA,sBAAc,EAAC,GAAG,CAAC,MAAM,EAAE,6BAAqB,CAAC,CAAC;IAElD,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC9B,MAAM,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAE/B,MAAM,IAAA,qCAA6B,EAAC,OAAO,EAAE,GAAG,EAAE;QAChD,WAAW;KACZ,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,MAAM,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;IAEnE,GAAG,CAAC,MAAM,GAAG,YAAY,CAAC;AAC5B,CAAC;AA3BD,sDA2BC","sourcesContent":["import { rpcErrors } from '@metamask/rpc-errors';\nimport type { JsonRpcRequest, PendingJsonRpcResponse } from '@metamask/utils';\n\nimport { GetCapabilitiesStruct } from '../types';\nimport type { GetCapabilitiesHook } from '../types';\nimport { validateAndNormalizeKeyholder, validateParams } from '../utils';\n\n/**\n * The RPC method handler middleware for `wallet_getCapabilities`\n *\n * @param req - The JSON RPC request's end callback.\n * @param res - The JSON RPC request's pending response object.\n * @param hooks - The hooks object.\n * @param hooks.getAccounts - Function that retrieves available accounts.\n * @param hooks.getCapabilities - Function that retrieves the capabilities for atomic transactions on specified chains.\n */\nexport async function walletGetCapabilities(\n req: JsonRpcRequest,\n res: PendingJsonRpcResponse,\n {\n getAccounts,\n getCapabilities,\n }: {\n getAccounts: (req: JsonRpcRequest) => Promise<string[]>;\n getCapabilities?: GetCapabilitiesHook;\n },\n): Promise<void> {\n if (!getCapabilities) {\n throw rpcErrors.methodNotSupported();\n }\n\n validateParams(req.params, GetCapabilitiesStruct);\n\n const address = req.params[0];\n const chainIds = req.params[1];\n\n await validateAndNormalizeKeyholder(address, req, {\n getAccounts,\n });\n\n const capabilities = await getCapabilities(address, chainIds, req);\n\n res.result = capabilities;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { JsonRpcRequest, PendingJsonRpcResponse } from "@metamask/utils";
|
|
2
|
-
import {
|
|
2
|
+
import type { GetCapabilitiesHook } from "../types.cjs";
|
|
3
3
|
/**
|
|
4
4
|
* The RPC method handler middleware for `wallet_getCapabilities`
|
|
5
5
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet_getCapabilities.d.cts","sourceRoot":"","sources":["../../src/methods/wallet_getCapabilities.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,wBAAwB;
|
|
1
|
+
{"version":3,"file":"wallet_getCapabilities.d.cts","sourceRoot":"","sources":["../../src/methods/wallet_getCapabilities.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,wBAAwB;AAG9E,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAiB;AAGpD;;;;;;;;GAQG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,sBAAsB,EAC3B,EACE,WAAW,EACX,eAAe,GAChB,EAAE;IACD,WAAW,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACxD,eAAe,CAAC,EAAE,mBAAmB,CAAC;CACvC,GACA,OAAO,CAAC,IAAI,CAAC,CAiBf"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { JsonRpcRequest, PendingJsonRpcResponse } from "@metamask/utils";
|
|
2
|
-
import {
|
|
2
|
+
import type { GetCapabilitiesHook } from "../types.mjs";
|
|
3
3
|
/**
|
|
4
4
|
* The RPC method handler middleware for `wallet_getCapabilities`
|
|
5
5
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet_getCapabilities.d.mts","sourceRoot":"","sources":["../../src/methods/wallet_getCapabilities.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,wBAAwB;
|
|
1
|
+
{"version":3,"file":"wallet_getCapabilities.d.mts","sourceRoot":"","sources":["../../src/methods/wallet_getCapabilities.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,wBAAwB;AAG9E,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAiB;AAGpD;;;;;;;;GAQG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,sBAAsB,EAC3B,EACE,WAAW,EACX,eAAe,GAChB,EAAE;IACD,WAAW,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACxD,eAAe,CAAC,EAAE,mBAAmB,CAAC;CACvC,GACA,OAAO,CAAC,IAAI,CAAC,CAiBf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet_getCapabilities.mjs","sourceRoot":"","sources":["../../src/methods/wallet_getCapabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,6BAA6B;AAGjD,OAAO,
|
|
1
|
+
{"version":3,"file":"wallet_getCapabilities.mjs","sourceRoot":"","sources":["../../src/methods/wallet_getCapabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,6BAA6B;AAGjD,OAAO,EAAE,qBAAqB,EAAE,qBAAiB;AAEjD,OAAO,EAAE,6BAA6B,EAAE,cAAc,EAAE,qBAAiB;AAEzE;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,GAAmB,EACnB,GAA2B,EAC3B,EACE,WAAW,EACX,eAAe,GAIhB;IAED,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,SAAS,CAAC,kBAAkB,EAAE,CAAC;IACvC,CAAC;IAED,cAAc,CAAC,GAAG,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IAElD,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC9B,MAAM,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAE/B,MAAM,6BAA6B,CAAC,OAAO,EAAE,GAAG,EAAE;QAChD,WAAW;KACZ,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,MAAM,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;IAEnE,GAAG,CAAC,MAAM,GAAG,YAAY,CAAC;AAC5B,CAAC","sourcesContent":["import { rpcErrors } from '@metamask/rpc-errors';\nimport type { JsonRpcRequest, PendingJsonRpcResponse } from '@metamask/utils';\n\nimport { GetCapabilitiesStruct } from '../types';\nimport type { GetCapabilitiesHook } from '../types';\nimport { validateAndNormalizeKeyholder, validateParams } from '../utils';\n\n/**\n * The RPC method handler middleware for `wallet_getCapabilities`\n *\n * @param req - The JSON RPC request's end callback.\n * @param res - The JSON RPC request's pending response object.\n * @param hooks - The hooks object.\n * @param hooks.getAccounts - Function that retrieves available accounts.\n * @param hooks.getCapabilities - Function that retrieves the capabilities for atomic transactions on specified chains.\n */\nexport async function walletGetCapabilities(\n req: JsonRpcRequest,\n res: PendingJsonRpcResponse,\n {\n getAccounts,\n getCapabilities,\n }: {\n getAccounts: (req: JsonRpcRequest) => Promise<string[]>;\n getCapabilities?: GetCapabilitiesHook;\n },\n): Promise<void> {\n if (!getCapabilities) {\n throw rpcErrors.methodNotSupported();\n }\n\n validateParams(req.params, GetCapabilitiesStruct);\n\n const address = req.params[0];\n const chainIds = req.params[1];\n\n await validateAndNormalizeKeyholder(address, req, {\n getAccounts,\n });\n\n const capabilities = await getCapabilities(address, chainIds, req);\n\n res.result = capabilities;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet_sendCalls.cjs","sourceRoot":"","sources":["../../src/methods/wallet_sendCalls.ts"],"names":[],"mappings":";;;AAAA,qDAAiD;AAGjD,
|
|
1
|
+
{"version":3,"file":"wallet_sendCalls.cjs","sourceRoot":"","sources":["../../src/methods/wallet_sendCalls.ts"],"names":[],"mappings":";;;AAAA,qDAAiD;AAGjD,wCAA2C;AAE3C,wCAAyE;AAEzE;;;;;;;;GAQG;AACI,KAAK,UAAU,eAAe,CACnC,GAAmB,EACnB,GAA2B,EAC3B,EACE,WAAW,EACX,gBAAgB,GAIjB;IAED,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,MAAM,sBAAS,CAAC,kBAAkB,EAAE,CAAC;IACvC,CAAC;IAED,IAAA,sBAAc,EAAC,GAAG,CAAC,MAAM,EAAE,uBAAe,CAAC,CAAC;IAE5C,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAE7B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI;QACtB,CAAC,CAAC,MAAM,IAAA,qCAA6B,EAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;YACpD,WAAW;SACZ,CAAC;QACJ,CAAC,CAAC,SAAS,CAAC;IAEd,MAAM,SAAS,GAAqB;QAClC,GAAG,MAAM;QACT,IAAI;KACL,CAAC;IAEF,GAAG,CAAC,MAAM,GAAG,MAAM,gBAAgB,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;AACtD,CAAC;AA/BD,0CA+BC","sourcesContent":["import { rpcErrors } from '@metamask/rpc-errors';\nimport type { JsonRpcRequest, PendingJsonRpcResponse } from '@metamask/utils';\n\nimport { SendCallsStruct } from '../types';\nimport type { ProcessSendCallsHook, SendCallsPayload } from '../types';\nimport { validateAndNormalizeKeyholder, validateParams } from '../utils';\n\n/**\n * The RPC method handler middleware for `wallet_sendCalls`\n *\n * @param req - The JSON RPC request's end callback.\n * @param res - The JSON RPC request's pending response object.\n * @param hooks - The hooks object.\n * @param hooks.getAccounts - Function that retrieves available accounts.\n * @param hooks.processSendCalls - Function that processes a sendCalls request for EIP-5792 transactions.\n */\nexport async function walletSendCalls(\n req: JsonRpcRequest,\n res: PendingJsonRpcResponse,\n {\n getAccounts,\n processSendCalls,\n }: {\n getAccounts: (req: JsonRpcRequest) => Promise<string[]>;\n processSendCalls?: ProcessSendCallsHook;\n },\n): Promise<void> {\n if (!processSendCalls) {\n throw rpcErrors.methodNotSupported();\n }\n\n validateParams(req.params, SendCallsStruct);\n\n const params = req.params[0];\n\n const from = params.from\n ? await validateAndNormalizeKeyholder(params.from, req, {\n getAccounts,\n })\n : undefined;\n\n const sendCalls: SendCallsPayload = {\n ...params,\n from,\n };\n\n res.result = await processSendCalls(sendCalls, req);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet_sendCalls.d.cts","sourceRoot":"","sources":["../../src/methods/wallet_sendCalls.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,wBAAwB;
|
|
1
|
+
{"version":3,"file":"wallet_sendCalls.d.cts","sourceRoot":"","sources":["../../src/methods/wallet_sendCalls.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,wBAAwB;AAG9E,OAAO,KAAK,EAAE,oBAAoB,EAAoB,qBAAiB;AAGvE;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,sBAAsB,EAC3B,EACE,WAAW,EACX,gBAAgB,GACjB,EAAE;IACD,WAAW,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACxD,gBAAgB,CAAC,EAAE,oBAAoB,CAAC;CACzC,GACA,OAAO,CAAC,IAAI,CAAC,CAqBf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet_sendCalls.d.mts","sourceRoot":"","sources":["../../src/methods/wallet_sendCalls.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,wBAAwB;
|
|
1
|
+
{"version":3,"file":"wallet_sendCalls.d.mts","sourceRoot":"","sources":["../../src/methods/wallet_sendCalls.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,wBAAwB;AAG9E,OAAO,KAAK,EAAE,oBAAoB,EAAoB,qBAAiB;AAGvE;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,sBAAsB,EAC3B,EACE,WAAW,EACX,gBAAgB,GACjB,EAAE;IACD,WAAW,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACxD,gBAAgB,CAAC,EAAE,oBAAoB,CAAC;CACzC,GACA,OAAO,CAAC,IAAI,CAAC,CAqBf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet_sendCalls.mjs","sourceRoot":"","sources":["../../src/methods/wallet_sendCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,6BAA6B;AAGjD,OAAO,
|
|
1
|
+
{"version":3,"file":"wallet_sendCalls.mjs","sourceRoot":"","sources":["../../src/methods/wallet_sendCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,6BAA6B;AAGjD,OAAO,EAAE,eAAe,EAAE,qBAAiB;AAE3C,OAAO,EAAE,6BAA6B,EAAE,cAAc,EAAE,qBAAiB;AAEzE;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,GAAmB,EACnB,GAA2B,EAC3B,EACE,WAAW,EACX,gBAAgB,GAIjB;IAED,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,MAAM,SAAS,CAAC,kBAAkB,EAAE,CAAC;IACvC,CAAC;IAED,cAAc,CAAC,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAE5C,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAE7B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI;QACtB,CAAC,CAAC,MAAM,6BAA6B,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;YACpD,WAAW;SACZ,CAAC;QACJ,CAAC,CAAC,SAAS,CAAC;IAEd,MAAM,SAAS,GAAqB;QAClC,GAAG,MAAM;QACT,IAAI;KACL,CAAC;IAEF,GAAG,CAAC,MAAM,GAAG,MAAM,gBAAgB,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;AACtD,CAAC","sourcesContent":["import { rpcErrors } from '@metamask/rpc-errors';\nimport type { JsonRpcRequest, PendingJsonRpcResponse } from '@metamask/utils';\n\nimport { SendCallsStruct } from '../types';\nimport type { ProcessSendCallsHook, SendCallsPayload } from '../types';\nimport { validateAndNormalizeKeyholder, validateParams } from '../utils';\n\n/**\n * The RPC method handler middleware for `wallet_sendCalls`\n *\n * @param req - The JSON RPC request's end callback.\n * @param res - The JSON RPC request's pending response object.\n * @param hooks - The hooks object.\n * @param hooks.getAccounts - Function that retrieves available accounts.\n * @param hooks.processSendCalls - Function that processes a sendCalls request for EIP-5792 transactions.\n */\nexport async function walletSendCalls(\n req: JsonRpcRequest,\n res: PendingJsonRpcResponse,\n {\n getAccounts,\n processSendCalls,\n }: {\n getAccounts: (req: JsonRpcRequest) => Promise<string[]>;\n processSendCalls?: ProcessSendCallsHook;\n },\n): Promise<void> {\n if (!processSendCalls) {\n throw rpcErrors.methodNotSupported();\n }\n\n validateParams(req.params, SendCallsStruct);\n\n const params = req.params[0];\n\n const from = params.from\n ? await validateAndNormalizeKeyholder(params.from, req, {\n getAccounts,\n })\n : undefined;\n\n const sendCalls: SendCallsPayload = {\n ...params,\n from,\n };\n\n res.result = await processSendCalls(sendCalls, req);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/eip-5792-middleware",
|
|
3
|
-
"version": "2.0.0-preview-
|
|
3
|
+
"version": "2.0.0-preview-5c1b2b1",
|
|
4
4
|
"description": "Implements the JSON-RPC methods for sending multiple calls from the user's wallet, and checking their status, as referenced in EIP-5792",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|