Skip to content

Commit

Permalink
♻️ refactor(mm): Remove experimental object
Browse files Browse the repository at this point in the history
  • Loading branch information
duckception committed Jan 2, 2024
1 parent b35e52a commit f0d2f98
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 23 deletions.
15 changes: 4 additions & 11 deletions wallets/metamask/src/metamask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,27 +169,20 @@ export class MetaMask {

// ---- EXPERIMENTAL FEATURES ----

public readonly experimental = {
confirmTransactionAndWaitForMining: async (options?: { gasSetting?: GasSetting }) =>
await this.confirmTransactionAndWaitForMining(options),
// Note: `txIndex` starts from 0.
openTransactionDetails: async (txIndex: number) => await this.openTransactionDetails(txIndex),
closeTransactionDetails: async () => await this.closeTransactionDetails()
}

private async confirmTransactionAndWaitForMining(options?: { gasSetting?: GasSetting }) {
async confirmTransactionAndWaitForMining(options?: { gasSetting?: GasSetting }) {
if (!this.extensionId) {
throw NO_EXTENSION_ID_ERROR
}

await this.notificationPage.confirmTransactionAndWaitForMining(this.extensionId, options)
}

private async openTransactionDetails(txIndex: number) {
// Note: `txIndex` starts from 0.
async openTransactionDetails(txIndex: number) {
await this.homePage.openTransactionDetails(txIndex)
}

private async closeTransactionDetails() {
async closeTransactionDetails() {
await this.homePage.closeTransactionDetails()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ test('should close transaction details', async ({ page, metamask, metamaskPage,
await connectToAnvil()

await page.locator('#sendEIP1559Button').click()
await metamask.experimental.confirmTransactionAndWaitForMining()
await metamask.confirmTransactionAndWaitForMining()

await metamask.experimental.openTransactionDetails(0)
await metamask.openTransactionDetails(0)

await metamask.experimental.closeTransactionDetails()
await metamask.closeTransactionDetails()

await expect(metamaskPage.locator(metamask.homePage.selectors.popover.closeButton)).toBeHidden()
})
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test.skip('should confirm contract deployment and wait for mining', async ({ pag
await expect(page.locator('#tokenAddresses')).toBeEmpty()
await page.locator('#createToken').click()

await metamask.experimental.confirmTransactionAndWaitForMining()
await metamask.confirmTransactionAndWaitForMining()

await expect(page.locator('#tokenAddresses')).toContainText(/^0x/)
})
Expand All @@ -22,15 +22,15 @@ test.skip('should confirm legacy transaction and wait for mining', async ({ page

await page.locator('#sendButton').click()

await metamask.experimental.confirmTransactionAndWaitForMining()
await metamask.confirmTransactionAndWaitForMining()
})

test.skip('should confirm EIP-1559 transaction and wait for mining', async ({ page, metamask, connectToAnvil }) => {
await connectToAnvil()

await page.locator('#sendEIP1559Button').click()

await metamask.experimental.confirmTransactionAndWaitForMining()
await metamask.confirmTransactionAndWaitForMining()
})

test.skip('should work correctly when calling sequentially', async ({ page, metamask, connectToAnvil }) => {
Expand All @@ -40,11 +40,11 @@ test.skip('should work correctly when calling sequentially', async ({ page, meta
await connectToAnvil()

await page.locator('#sendEIP1559Button').click()
await metamask.experimental.confirmTransactionAndWaitForMining()
await metamask.confirmTransactionAndWaitForMining()

await page.locator('#sendEIP1559Button').click()
await metamask.experimental.confirmTransactionAndWaitForMining()
await metamask.confirmTransactionAndWaitForMining()

await page.locator('#sendEIP1559Button').click()
await metamask.experimental.confirmTransactionAndWaitForMining()
await metamask.confirmTransactionAndWaitForMining()
})
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ test('should open transaction details', async ({ page, metamask, metamaskPage, c
await connectToAnvil()

await page.locator('#sendEIP1559Button').click()
await metamask.experimental.confirmTransactionAndWaitForMining()
await metamask.confirmTransactionAndWaitForMining()

await metamask.experimental.openTransactionDetails(0)
await metamask.openTransactionDetails(0)

await expect(metamaskPage.locator(metamask.homePage.selectors.popover.closeButton)).toBeVisible()
})

test('should throw an error if the passed transaction index is out of bounds', async ({ metamask }) => {
await expect(metamask.experimental.openTransactionDetails(0)).rejects.toThrowError(
await expect(metamask.openTransactionDetails(0)).rejects.toThrowError(
'[OpenTransactionDetails] Transaction with index 0 is not visible. There are only 0 transactions visible.'
)
})

0 comments on commit f0d2f98

Please sign in to comment.