Skip to content

Commit fe5f85c

Browse files
authored
test: rename the GanacheContractAddressRegistry class in preparation for ganache migration (#28595)
<!-- 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** The Contract Registry class, is going to be used as it is, in Anvil too. In the efforts of making [the migration PR](https://github.com/MetaMask/metamask-extension/pull/27246/files#diff-06cb4d4aa42b7e7467cb49bd17a4282672cc4a352ee698d122e566f25e906692) smaller, this PR tackles the re-naming of this class `GanacheContractAddressRegistry` to a more generic name that can be used both by Ganache and Anvil `ContractAddressRegistry`. Note: this PR doesn't introduce any functional change in the tests, so we can skip the quality gate for sparing ci credits. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28595?quickstart=1) ## **Related issues** Fixes: MetaMask/MetaMask-planning#3662 ## **Manual testing steps** 1. Check all tests continues to work fine ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.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.
1 parent 197c201 commit fe5f85c

15 files changed

+47
-47
lines changed

test/e2e/helpers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const convertETHToHexGwei = (eth) => convertToHexValue(eth * 10 ** 18);
4242
/**
4343
* @typedef {object} Fixtures
4444
* @property {import('./webdriver/driver').Driver} driver - The driver number.
45-
* @property {GanacheContractAddressRegistry | undefined} contractRegistry - The contract registry.
45+
* @property {ContractAddressRegistry | undefined} contractRegistry - The contract registry.
4646
* @property {Ganache | undefined} ganacheServer - The Ganache server.
4747
* @property {Ganache | undefined} secondaryGanacheServer - The secondary Ganache server.
4848
* @property {mockttp.MockedEndpoint[]} mockedEndpoint - The mocked endpoint.

test/e2e/json-rpc/eth_call.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { defaultGanacheOptions, withFixtures } from '../helpers';
44
import { Driver } from '../webdriver/driver';
55
import FixtureBuilder from '../fixture-builder';
66
import { Ganache } from '../seeder/ganache';
7-
import GanacheContractAddressRegistry from '../seeder/ganache-contract-address-registry';
7+
import ContractAddressRegistry from '../seeder/contract-address-registry';
88
import { SMART_CONTRACTS } from '../seeder/smart-contracts';
99
import { loginWithBalanceValidation } from '../page-objects/flows/login.flow';
1010

@@ -28,7 +28,7 @@ describe('eth_call', function () {
2828
}: {
2929
driver: Driver;
3030
ganacheServer?: Ganache;
31-
contractRegistry: GanacheContractAddressRegistry;
31+
contractRegistry: ContractAddressRegistry;
3232
}) => {
3333
const contract = contractRegistry.getContractAddress(smartContract);
3434
await loginWithBalanceValidation(driver, ganacheServer);

test/e2e/seeder/ganache-contract-address-registry.js renamed to test/e2e/seeder/contract-address-registry.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
22
* Use this class to store pre-deployed smart contract addresses of the contracts deployed to
3-
* a local blockchain instance ran by Ganache.
3+
* a local blockchain instance.
44
*/
5-
class GanacheContractAddressRegistry {
5+
class ContractAddressRegistry {
66
#addresses = {};
77

88
/**
@@ -25,4 +25,4 @@ class GanacheContractAddressRegistry {
2525
}
2626
}
2727

28-
module.exports = GanacheContractAddressRegistry;
28+
module.exports = ContractAddressRegistry;

test/e2e/seeder/ganache-seeder.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ const { ContractFactory, Contract } = require('@ethersproject/contracts');
33

44
const { ENTRYPOINT, GANACHE_ACCOUNT } = require('../constants');
55
const { SMART_CONTRACTS, contractConfiguration } = require('./smart-contracts');
6-
const GanacheContractAddressRegistry = require('./ganache-contract-address-registry');
6+
const ContractAddressRegistry = require('./contract-address-registry');
77

88
/*
99
* Ganache seeder is used to seed initial smart contract or set initial blockchain state.
1010
*/
1111
class GanacheSeeder {
1212
constructor(ganacheProvider) {
13-
this.smartContractRegistry = new GanacheContractAddressRegistry();
13+
this.smartContractRegistry = new ContractAddressRegistry();
1414
this.ganacheProvider = ganacheProvider;
1515
}
1616

@@ -125,7 +125,7 @@ class GanacheSeeder {
125125
/**
126126
* Return an instance of the currently used smart contract registry.
127127
*
128-
* @returns GanacheContractAddressRegistry
128+
* @returns ContractAddressRegistry
129129
*/
130130
getContractRegistry() {
131131
return this.smartContractRegistry;

test/e2e/tests/account/snap-account-contract-interaction.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Suite } from 'mocha';
22
import { Driver } from '../../webdriver/driver';
33
import FixtureBuilder from '../../fixture-builder';
44
import { Ganache } from '../../seeder/ganache';
5-
import GanacheContractAddressRegistry from '../../seeder/ganache-contract-address-registry';
5+
import ContractAddressRegistry from '../../seeder/contract-address-registry';
66
import {
77
multipleGanacheOptionsForType2Transactions,
88
PRIVATE_KEY_TWO,
@@ -42,7 +42,7 @@ describe('Snap Account Contract interaction @no-mmi', function (this: Suite) {
4242
ganacheServer,
4343
}: {
4444
driver: Driver;
45-
contractRegistry: GanacheContractAddressRegistry;
45+
contractRegistry: ContractAddressRegistry;
4646
ganacheServer?: Ganache;
4747
}) => {
4848
await loginWithBalanceValidation(driver, ganacheServer);
@@ -62,7 +62,7 @@ describe('Snap Account Contract interaction @no-mmi', function (this: Suite) {
6262
// Open Dapp with contract
6363
const testDapp = new TestDapp(driver);
6464
const contractAddress = await (
65-
contractRegistry as GanacheContractAddressRegistry
65+
contractRegistry as ContractAddressRegistry
6666
).getContractAddress(smartContract);
6767
await testDapp.openTestDappPage({ contractAddress });
6868
await testDapp.check_pageIsLoaded();

test/e2e/tests/confirmations/alerts/queued-confirmations.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
openDAppWithContract,
1111
TestSuiteArguments,
1212
} from '../transactions/shared';
13-
import GanacheContractAddressRegistry from '../../../seeder/ganache-contract-address-registry';
13+
import ContractAddressRegistry from '../../../seeder/contract-address-registry';
1414

1515
const FixtureBuilder = require('../../../fixture-builder');
1616
const {
@@ -168,7 +168,7 @@ describe('Queued Confirmations', function () {
168168
await openDAppWithContract(driver, contractRegistry, smartContract);
169169

170170
const contractAddress = await (
171-
contractRegistry as GanacheContractAddressRegistry
171+
contractRegistry as ContractAddressRegistry
172172
).getContractAddress(smartContract);
173173

174174
await connectToDappTwoAndSwitchBackToOne(driver, contractAddress);
@@ -317,7 +317,7 @@ describe('Queued Confirmations', function () {
317317
await openDAppWithContract(driver, contractRegistry, smartContract);
318318

319319
const contractAddress = await (
320-
contractRegistry as GanacheContractAddressRegistry
320+
contractRegistry as ContractAddressRegistry
321321
).getContractAddress(smartContract);
322322

323323
await connectToDappTwoAndSwitchBackToOne(driver, contractAddress);

test/e2e/tests/confirmations/transactions/contract-interaction-redesign.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { Mockttp } from 'mockttp';
33
import { openDapp, unlockWallet } from '../../../helpers';
44
import { createDappTransaction } from '../../../page-objects/flows/transaction';
5-
import GanacheContractAddressRegistry from '../../../seeder/ganache-contract-address-registry';
5+
import ContractAddressRegistry from '../../../seeder/contract-address-registry';
66
import { Driver } from '../../../webdriver/driver';
77
import { MockedEndpoint } from '../../../mock-e2e';
88
import {
@@ -165,7 +165,7 @@ describe('Confirmation Redesign Contract Interaction Component', function () {
165165
await createLayer2Transaction(driver);
166166

167167
const contractAddress = await (
168-
contractRegistry as GanacheContractAddressRegistry
168+
contractRegistry as ContractAddressRegistry
169169
).getContractAddress(smartContract);
170170

171171
await openDapp(driver, contractAddress);

test/e2e/tests/confirmations/transactions/erc1155-revoke-set-approval-for-all-redesign.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { unlockWallet, WINDOW_TITLES } from '../../../helpers';
55
import { Mockttp } from '../../../mock-e2e';
66
import SetApprovalForAllTransactionConfirmation from '../../../page-objects/pages/confirmations/redesign/set-approval-for-all-transaction-confirmation';
77
import TestDapp from '../../../page-objects/pages/test-dapp';
8-
import GanacheContractAddressRegistry from '../../../seeder/ganache-contract-address-registry';
8+
import ContractAddressRegistry from '../../../seeder/contract-address-registry';
99
import { Driver } from '../../../webdriver/driver';
1010
import { withRedesignConfirmationFixtures } from '../helpers';
1111
import { mocked4BytesSetApprovalForAll } from './erc721-revoke-set-approval-for-all-redesign';
@@ -47,12 +47,12 @@ async function mocks(server: Mockttp) {
4747

4848
async function createTransactionAndAssertDetails(
4949
driver: Driver,
50-
contractRegistry?: GanacheContractAddressRegistry,
50+
contractRegistry?: ContractAddressRegistry,
5151
) {
5252
await unlockWallet(driver);
5353

5454
const contractAddress = await (
55-
contractRegistry as GanacheContractAddressRegistry
55+
contractRegistry as ContractAddressRegistry
5656
).getContractAddress(SMART_CONTRACTS.NFTS);
5757

5858
const testDapp = new TestDapp(driver);

test/e2e/tests/confirmations/transactions/erc1155-set-approval-for-all-redesign.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { DAPP_URL, unlockWallet, WINDOW_TITLES } from '../../../helpers';
44
import { Mockttp } from '../../../mock-e2e';
55
import SetApprovalForAllTransactionConfirmation from '../../../page-objects/pages/confirmations/redesign/set-approval-for-all-transaction-confirmation';
66
import TestDapp from '../../../page-objects/pages/test-dapp';
7-
import GanacheContractAddressRegistry from '../../../seeder/ganache-contract-address-registry';
7+
import ContractAddressRegistry from '../../../seeder/contract-address-registry';
88
import { Driver } from '../../../webdriver/driver';
99
import { withRedesignConfirmationFixtures } from '../helpers';
1010
import { TestSuiteArguments } from './shared';
@@ -75,12 +75,12 @@ export async function mocked4BytesSetApprovalForAll(mockServer: Mockttp) {
7575

7676
async function createTransactionAssertDetailsAndConfirm(
7777
driver: Driver,
78-
contractRegistry?: GanacheContractAddressRegistry,
78+
contractRegistry?: ContractAddressRegistry,
7979
) {
8080
await unlockWallet(driver);
8181

8282
const contractAddress = await (
83-
contractRegistry as GanacheContractAddressRegistry
83+
contractRegistry as ContractAddressRegistry
8484
).getContractAddress(SMART_CONTRACTS.NFTS);
8585

8686
const testDapp = new TestDapp(driver);

test/e2e/tests/confirmations/transactions/erc20-token-send-redesign.spec.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import TokenTransferTransactionConfirmation from '../../../page-objects/pages/co
1212
import HomePage from '../../../page-objects/pages/homepage';
1313
import SendTokenPage from '../../../page-objects/pages/send/send-token-page';
1414
import TestDapp from '../../../page-objects/pages/test-dapp';
15-
import GanacheContractAddressRegistry from '../../../seeder/ganache-contract-address-registry';
15+
import ContractAddressRegistry from '../../../seeder/contract-address-registry';
1616
import { Driver } from '../../../webdriver/driver';
1717
import { withRedesignConfirmationFixtures } from '../helpers';
1818
import { TestSuiteArguments } from './shared';
@@ -115,12 +115,12 @@ export async function mockedSourcifyTokenSend(mockServer: Mockttp) {
115115

116116
async function createWalletInitiatedTransactionAndAssertDetails(
117117
driver: Driver,
118-
contractRegistry?: GanacheContractAddressRegistry,
118+
contractRegistry?: ContractAddressRegistry,
119119
) {
120120
await unlockWallet(driver);
121121

122122
const contractAddress = await (
123-
contractRegistry as GanacheContractAddressRegistry
123+
contractRegistry as ContractAddressRegistry
124124
).getContractAddress(SMART_CONTRACTS.HST);
125125

126126
const testDapp = new TestDapp(driver);
@@ -160,12 +160,12 @@ async function createWalletInitiatedTransactionAndAssertDetails(
160160

161161
async function createDAppInitiatedTransactionAndAssertDetails(
162162
driver: Driver,
163-
contractRegistry?: GanacheContractAddressRegistry,
163+
contractRegistry?: ContractAddressRegistry,
164164
) {
165165
await unlockWallet(driver);
166166

167167
const contractAddress = await (
168-
contractRegistry as GanacheContractAddressRegistry
168+
contractRegistry as ContractAddressRegistry
169169
).getContractAddress(SMART_CONTRACTS.HST);
170170

171171
const testDapp = new TestDapp(driver);

test/e2e/tests/confirmations/transactions/erc721-revoke-set-approval-for-all-redesign.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { unlockWallet, WINDOW_TITLES } from '../../../helpers';
55
import { Mockttp } from '../../../mock-e2e';
66
import SetApprovalForAllTransactionConfirmation from '../../../page-objects/pages/confirmations/redesign/set-approval-for-all-transaction-confirmation';
77
import TestDapp from '../../../page-objects/pages/test-dapp';
8-
import GanacheContractAddressRegistry from '../../../seeder/ganache-contract-address-registry';
8+
import ContractAddressRegistry from '../../../seeder/contract-address-registry';
99
import { Driver } from '../../../webdriver/driver';
1010
import { withRedesignConfirmationFixtures } from '../helpers';
1111
import { TestSuiteArguments } from './shared';
@@ -70,12 +70,12 @@ export async function mocked4BytesSetApprovalForAll(mockServer: Mockttp) {
7070

7171
async function createTransactionAndAssertDetails(
7272
driver: Driver,
73-
contractRegistry?: GanacheContractAddressRegistry,
73+
contractRegistry?: ContractAddressRegistry,
7474
) {
7575
await unlockWallet(driver);
7676

7777
const contractAddress = await (
78-
contractRegistry as GanacheContractAddressRegistry
78+
contractRegistry as ContractAddressRegistry
7979
).getContractAddress(SMART_CONTRACTS.NFTS);
8080

8181
const testDapp = new TestDapp(driver);

test/e2e/tests/confirmations/transactions/erc721-set-approval-for-all-redesign.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { DAPP_URL, unlockWallet, WINDOW_TITLES } from '../../../helpers';
44
import { Mockttp } from '../../../mock-e2e';
55
import SetApprovalForAllTransactionConfirmation from '../../../page-objects/pages/confirmations/redesign/set-approval-for-all-transaction-confirmation';
66
import TestDapp from '../../../page-objects/pages/test-dapp';
7-
import GanacheContractAddressRegistry from '../../../seeder/ganache-contract-address-registry';
7+
import ContractAddressRegistry from '../../../seeder/contract-address-registry';
88
import { Driver } from '../../../webdriver/driver';
99
import { withRedesignConfirmationFixtures } from '../helpers';
1010
import { TestSuiteArguments } from './shared';
@@ -75,12 +75,12 @@ export async function mocked4BytesSetApprovalForAll(mockServer: Mockttp) {
7575

7676
async function createTransactionAssertDetailsAndConfirm(
7777
driver: Driver,
78-
contractRegistry?: GanacheContractAddressRegistry,
78+
contractRegistry?: ContractAddressRegistry,
7979
) {
8080
await unlockWallet(driver);
8181

8282
const contractAddress = await (
83-
contractRegistry as GanacheContractAddressRegistry
83+
contractRegistry as ContractAddressRegistry
8484
).getContractAddress(SMART_CONTRACTS.NFTS);
8585

8686
const testDapp = new TestDapp(driver);

test/e2e/tests/confirmations/transactions/increase-token-allowance-redesign.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
withFixtures,
99
} from '../../../helpers';
1010
import { Mockttp } from '../../../mock-e2e';
11-
import GanacheContractAddressRegistry from '../../../seeder/ganache-contract-address-registry';
11+
import ContractAddressRegistry from '../../../seeder/contract-address-registry';
1212
import { SMART_CONTRACTS } from '../../../seeder/smart-contracts';
1313
import { Driver } from '../../../webdriver/driver';
1414
import { scrollAndConfirmAndAssertConfirm } from '../helpers';
@@ -111,7 +111,7 @@ function generateFixtureOptionsForEIP1559Tx(mochaContext: Mocha.Context) {
111111
async function createAndAssertIncreaseAllowanceSubmission(
112112
driver: Driver,
113113
newSpendingCap: string,
114-
contractRegistry?: GanacheContractAddressRegistry,
114+
contractRegistry?: ContractAddressRegistry,
115115
) {
116116
await openDAppWithContract(driver, contractRegistry, SMART_CONTRACTS.HST);
117117

test/e2e/tests/confirmations/transactions/nft-token-send-redesign.spec.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import HomePage from '../../../page-objects/pages/homepage';
1414
import NFTDetailsPage from '../../../page-objects/pages/nft-details-page';
1515
import SendTokenPage from '../../../page-objects/pages/send/send-token-page';
1616
import TestDapp from '../../../page-objects/pages/test-dapp';
17-
import GanacheContractAddressRegistry from '../../../seeder/ganache-contract-address-registry';
17+
import ContractAddressRegistry from '../../../seeder/contract-address-registry';
1818
import { Driver } from '../../../webdriver/driver';
1919
import { withRedesignConfirmationFixtures } from '../helpers';
2020
import { TestSuiteArguments } from './shared';
@@ -184,12 +184,12 @@ export async function mockedERC11554BytesNFTTokenSend(mockServer: Mockttp) {
184184

185185
async function createERC721WalletInitiatedTransactionAndAssertDetails(
186186
driver: Driver,
187-
contractRegistry?: GanacheContractAddressRegistry,
187+
contractRegistry?: ContractAddressRegistry,
188188
) {
189189
await unlockWallet(driver);
190190

191191
const contractAddress = await (
192-
contractRegistry as GanacheContractAddressRegistry
192+
contractRegistry as ContractAddressRegistry
193193
).getContractAddress(SMART_CONTRACTS.NFTS);
194194

195195
const testDapp = new TestDapp(driver);
@@ -231,12 +231,12 @@ async function createERC721WalletInitiatedTransactionAndAssertDetails(
231231

232232
async function createERC721DAppInitiatedTransactionAndAssertDetails(
233233
driver: Driver,
234-
contractRegistry?: GanacheContractAddressRegistry,
234+
contractRegistry?: ContractAddressRegistry,
235235
) {
236236
await unlockWallet(driver);
237237

238238
const contractAddress = await (
239-
contractRegistry as GanacheContractAddressRegistry
239+
contractRegistry as ContractAddressRegistry
240240
).getContractAddress(SMART_CONTRACTS.NFTS);
241241

242242
const testDapp = new TestDapp(driver);
@@ -266,12 +266,12 @@ async function createERC721DAppInitiatedTransactionAndAssertDetails(
266266

267267
async function createERC1155WalletInitiatedTransactionAndAssertDetails(
268268
driver: Driver,
269-
contractRegistry?: GanacheContractAddressRegistry,
269+
contractRegistry?: ContractAddressRegistry,
270270
) {
271271
await unlockWallet(driver);
272272

273273
const contractAddress = await (
274-
contractRegistry as GanacheContractAddressRegistry
274+
contractRegistry as ContractAddressRegistry
275275
).getContractAddress(SMART_CONTRACTS.ERC1155);
276276

277277
const testDapp = new TestDapp(driver);

test/e2e/tests/confirmations/transactions/shared.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { MockedEndpoint } from 'mockttp';
33
import { veryLargeDelayMs } from '../../../helpers';
44
import { Ganache } from '../../../seeder/ganache';
5-
import GanacheContractAddressRegistry from '../../../seeder/ganache-contract-address-registry';
5+
import ContractAddressRegistry from '../../../seeder/contract-address-registry';
66
import { Driver } from '../../../webdriver/driver';
77

88
const {
@@ -15,17 +15,17 @@ const { scrollAndConfirmAndAssertConfirm } = require('../helpers');
1515
export type TestSuiteArguments = {
1616
driver: Driver;
1717
ganacheServer?: Ganache;
18-
contractRegistry?: GanacheContractAddressRegistry;
18+
contractRegistry?: ContractAddressRegistry;
1919
mockedEndpoint?: MockedEndpoint | MockedEndpoint[];
2020
};
2121

2222
export async function openDAppWithContract(
2323
driver: Driver,
24-
contractRegistry: GanacheContractAddressRegistry | undefined,
24+
contractRegistry: ContractAddressRegistry | undefined,
2525
smartContract: string,
2626
) {
2727
const contractAddress = await (
28-
contractRegistry as GanacheContractAddressRegistry
28+
contractRegistry as ContractAddressRegistry
2929
).getContractAddress(smartContract);
3030

3131
await logInWithBalanceValidation(driver);

0 commit comments

Comments
 (0)