-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: remove metametrics circular dependency (#30037)
This PR solves an issue with circular dependencies. It does not change the behavior of the application. It only rearranges functions/files to avoid circular references. <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. ## **Description** [](https://codespaces.new/MetaMask/metamask-extension/pull/30037?quickstart=1) ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. -->
- Loading branch information
1 parent
042d7cb
commit 103d92c
Showing
8 changed files
with
88 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import type { Provider } from '@metamask/network-controller'; | ||
import type { FetchGasFeeEstimateOptions } from '@metamask/gas-fee-controller'; | ||
import type { SmartTransaction } from '@metamask/smart-transactions-controller/dist/types'; | ||
import type { TransactionMeta } from '@metamask/transaction-controller'; | ||
import type { | ||
MetaMetricsEventFragment, | ||
MetaMetricsPageObject, | ||
MetaMetricsReferrerObject, | ||
} from '../constants/metametrics'; | ||
import type { TokenStandard } from '../constants/transaction'; | ||
import type { HardwareKeyringType } from '../constants/hardware-wallets'; | ||
// TODO: Remove restricted import | ||
// eslint-disable-next-line import/no-restricted-paths | ||
import type { SnapAndHardwareMessenger } from '../../app/scripts/lib/snap-keyring/metrics'; | ||
|
||
export type TransactionMetricsRequest = { | ||
createEventFragment: ( | ||
options: Omit<MetaMetricsEventFragment, 'id'>, | ||
) => MetaMetricsEventFragment; | ||
finalizeEventFragment: ( | ||
fragmentId: string, | ||
options?: { | ||
abandoned?: boolean; | ||
page?: MetaMetricsPageObject; | ||
referrer?: MetaMetricsReferrerObject; | ||
}, | ||
) => void; | ||
getEventFragmentById: (fragmentId: string) => MetaMetricsEventFragment; | ||
updateEventFragment: ( | ||
fragmentId: string, | ||
payload: Partial<MetaMetricsEventFragment>, | ||
) => void; | ||
getAccountType: ( | ||
address: string, | ||
) => Promise<'hardware' | 'imported' | 'MetaMask'>; | ||
getDeviceModel: ( | ||
address: string, | ||
) => Promise<'ledger' | 'lattice' | 'N/A' | string>; | ||
getHardwareTypeForMetric: (address: string) => Promise<HardwareKeyringType>; | ||
// According to the type GasFeeState returned from getEIP1559GasFeeEstimates | ||
// doesn't include some properties used in buildEventFragmentProperties, | ||
// hence returning any here to avoid type errors. | ||
// TODO: Replace `any` with type | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
getEIP1559GasFeeEstimates(options?: FetchGasFeeEstimateOptions): Promise<any>; | ||
getParticipateInMetrics: () => boolean; | ||
getSelectedAddress: () => string; | ||
getTokenStandardAndDetails: () => Promise<{ | ||
decimals?: string; | ||
balance?: string; | ||
symbol?: string; | ||
standard?: TokenStandard; | ||
}>; | ||
getTransaction: (transactionId: string) => TransactionMeta; | ||
provider: Provider; | ||
snapAndHardwareMessenger: SnapAndHardwareMessenger; | ||
// TODO: Replace `any` with type | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
trackEvent: (payload: any) => void; | ||
getIsSmartTransaction: () => boolean; | ||
getSmartTransactionByMinedTxHash: ( | ||
txhash: string | undefined, | ||
) => SmartTransaction; | ||
getMethodData: (data: string) => Promise<{ name: string }>; | ||
getIsConfirmationAdvancedDetailsOpen: () => boolean; | ||
}; | ||
|
||
export type TransactionEventPayload = { | ||
transactionMeta: TransactionMeta; | ||
actionId?: string; | ||
error?: string; | ||
}; | ||
|
||
export type TransactionMetaEventPayload = TransactionMeta & { | ||
actionId?: string; | ||
error?: string; | ||
}; |