Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic provider rebased #16

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
8 changes: 4 additions & 4 deletions packages/transaction-controller/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ module.exports = merge(baseConfig, {
// An object that configures minimum threshold enforcement for coverage results
coverageThreshold: {
global: {
branches: 93.65,
functions: 98.38,
lines: 98.84,
statements: 98.85,
branches: 91.98,
functions: 97.68,
lines: 97.52,
statements: 97.5,
},
},

Expand Down
2 changes: 2 additions & 0 deletions packages/transaction-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"devDependencies": {
"@babel/runtime": "^7.23.9",
"@metamask/auto-changelog": "^3.4.4",
"@metamask/eth-block-tracker": "^10.0.0",
"@metamask/eth-json-rpc-provider": "^4.0.0",
"@metamask/ethjs-provider-http": "^0.3.0",
"@metamask/keyring-api": "^8.0.0",
Expand All @@ -88,6 +89,7 @@
"@babel/runtime": "^7.23.9",
"@metamask/accounts-controller": "^17.0.0",
"@metamask/approval-controller": "^7.0.0",
"@metamask/eth-block-tracker": ">=9",
"@metamask/gas-fee-controller": "^17.0.0",
"@metamask/network-controller": "^19.0.0"
},
Expand Down
27 changes: 24 additions & 3 deletions packages/transaction-controller/src/TransactionController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,6 @@ describe('TransactionController', () => {
...network.state,
};
const provider = network.provider ?? new FakeProvider();
const blockTracker =
network.blockTracker ?? new FakeBlockTracker({ provider });
const onNetworkDidChangeListeners: ((state: NetworkState) => void)[] = [];
const changeNetwork = ({
selectedNetworkClientId,
Expand Down Expand Up @@ -603,11 +601,14 @@ describe('TransactionController', () => {
);

const { messenger: givenRestrictedMessenger, ...otherOptions } = {
blockTracker,
disableHistory: false,
disableSendFlowHistory: false,
disableSwaps: false,
getCurrentNetworkEIP1559Compatibility: async () => false,
getGlobalProviderAndBlockTracker: () => ({
provider: network.provider,
blockTracker: network.blockTracker,
}),
getNetworkState: () => networkState,
// TODO: Replace with a real type
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -804,6 +805,23 @@ describe('TransactionController', () => {
return pendingTransactionTrackerMock;
});

multichainTrackingHelperClassMock.mockImplementation(
({ getGlobalProviderAndBlockTracker }) => {
multichainTrackingHelperMock = {
getEthQuery: jest.fn().mockImplementation(() => {
return new EthQuery(
getGlobalProviderAndBlockTracker()?.provider as Provider,
);
}),
checkForPendingTransactionAndStartPolling: jest.fn(),
getNonceLock: getNonceLockSpy,
initialize: jest.fn(),
has: jest.fn().mockReturnValue(false),
} as unknown as jest.Mocked<MultichainTrackingHelper>;
return multichainTrackingHelperMock;
},
);
/*
multichainTrackingHelperClassMock.mockImplementation(({ provider }) => {
multichainTrackingHelperMock = {
getEthQuery: jest.fn().mockImplementation(() => {
Expand All @@ -819,6 +837,7 @@ describe('TransactionController', () => {
} as unknown as jest.Mocked<MultichainTrackingHelper>;
return multichainTrackingHelperMock;
});
*/

defaultGasFeeFlowClassMock.mockImplementation(() => {
defaultGasFeeFlowMock = {
Expand Down Expand Up @@ -1431,6 +1450,8 @@ describe('TransactionController', () => {
to: ACCOUNT_MOCK,
});

await flushPromises();

const expectedInitialSnapshot = {
actionId: undefined,
chainId: expect.any(String),
Expand Down
Loading
Loading