diff --git a/package.json b/package.json index 3e81755b..033fad84 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "wallets-testing-modules2", + "name": "wallets-testing-modules10", "version": "7.0.0", "description": "Common modules for testing wallets", "sideEffects": false, diff --git a/packages/extensions/LICENSE.txt b/packages/extensions/LICENSE.txt deleted file mode 100644 index 357ce957..00000000 --- a/packages/extensions/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2021 Lido - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/packages/extensions/README.md b/packages/extensions/README.md deleted file mode 100644 index 1eeb8c86..00000000 --- a/packages/extensions/README.md +++ /dev/null @@ -1,34 +0,0 @@ -# Extensions Module - -Download extensions from chrome store - -## Install - -```bash -yarn add @lidofinance/wallets-testing-extensions -``` - -## Usage - -```ts -import {ExtensionService, ExtensionsModule} from "@lidofinance/wallets-testing-extensions"; - -@Module({ - imports: [ExtensionsModule], -}) -export class MyModule { -} - -// Usage -export class MyService { - constructor(private extensionService: ExtensionService) { - } - - async myMethod() { - const extensionDir = await extensionService.getExtensionDirFromId( - 'nkbihfbeogaeaoehlefnkodbefgpgknn', - ); - expect(extensionDir).toBeDefined(); - } -} -``` diff --git a/packages/extensions/package.json b/packages/extensions/package.json deleted file mode 100644 index d9e2f948..00000000 --- a/packages/extensions/package.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "name": "wallets-testing-extensions5", - "version": "1.0.0", - "main": "dist/src/index.js", - "types": "dist/src/index.d.ts", - "license": "MIT", - "private": false, - "homepage": "https://github.com/lidofinance/wallets-testing-modules", - "repository": { - "type": "git", - "url": "https://github.com/lidofinance/wallets-testing-modules.git", - "directory": "packages/extensions" - }, - "bugs": { - "url": "https://github.com/lidofinance/wallets-testing-modules/issues" - }, - "sideEffects": false, - "scripts": { - "release": "release-it --npm.skipChecks --no-git.requireCleanWorkingDir" - }, - "keywords": [ - "lido", - "lidofinance" - ], - "files": [ - "dist/*" - ], - "publishConfig": { - "registry": "https://registry.npmjs.org/", - "access": "public" - }, - "dependencies": { - "@nestjs/common": "^8.2.5", - "@nestjs/config": "^2.2.0", - "axios": "^0.27.2", - "playwright": "^1.29.1", - "reflect-metadata": "^0.1.13", - "rxjs": "^7.5.6", - "unzipper": "^0.10.11" - }, - "devDependencies": { - "@nestjs/common": "^8.2.5", - "@nestjs/core": "^8.2.5", - "@nestjs/testing": "^8.2.5", - "@types/unzipper": "^0.10.5" - }, - "release-it": { - "git": { - "commit": false, - "tag": false, - "push": false - } - } -} diff --git a/packages/extensions/src/extension.constants.ts b/packages/extensions/src/extension.constants.ts deleted file mode 100644 index c0d74846..00000000 --- a/packages/extensions/src/extension.constants.ts +++ /dev/null @@ -1,2 +0,0 @@ -export const CHROME_WEBSTORE_URL = 'https://chrome.google.com/'; -export const CHROME = '123213'; diff --git a/packages/extensions/src/extension.model.ts b/packages/extensions/src/extension.model.ts deleted file mode 100644 index 483fbd68..00000000 --- a/packages/extensions/src/extension.model.ts +++ /dev/null @@ -1,20 +0,0 @@ -export class Extension { - id: string; - url: string; - - constructor(id: string) { - this.id = id; - this.url = `chrome-extension://${id}`; - } -} - -export interface ExtensionVersionChange { - name: string; - before: string; - after: string; -} - -export enum Manifest { - v2 = 2, - v3 = 3, -} diff --git a/packages/extensions/src/extension.service.ts b/packages/extensions/src/extension.service.ts deleted file mode 100644 index acca42fd..00000000 --- a/packages/extensions/src/extension.service.ts +++ /dev/null @@ -1,133 +0,0 @@ -import * as fs from 'fs/promises'; -import * as os from 'os'; -import * as path from 'path'; -import { Injectable, Logger } from '@nestjs/common'; -import axios from 'axios'; -import * as unzipper from 'unzipper'; -import { once } from 'events'; -import { ExtensionVersionChange, Manifest } from './extension.model'; -import { ExtensionStorePage } from './extension.store.page'; -import { BrowserContext, chromium } from 'playwright'; -import { Readable } from 'node:stream'; - -@Injectable() -export class ExtensionService { - staleExtensionDirs: string[] = []; - urlToExtension: Record = {}; - idToExtension: Record = {}; - private readonly logger = new Logger(ExtensionService.name); - private versions: Map = new Map(); - - async getExtensionDirFromUrl(url: string): Promise { - await this.downloadFromUrl(url); - return this.urlToExtension[url]; - } - - async getExtensionDirFromId(id: string): Promise { - await this.downloadFromStore(id); - return this.idToExtension[id]; - } - - async getExtensionDir2FromId(id: string): Promise { - await this.downloadFromStore(id); - return this.idToExtension[id]; - } - - async getManifestVersion(extensionDir: string): Promise { - const content = await fs.readFile(extensionDir + '/manifest.json'); - return JSON.parse(String(content)).manifest_version; - } - - async downloadFromUrl(url: string) { - this.logger.debug(`Download extension from ${url}`); - const extensionDir = await fs.mkdtemp(os.tmpdir() + path.sep); - await axios.get(url, { responseType: 'stream' }).then((response) => { - const zip = unzipper.Extract({ path: extensionDir }); - response.data.pipe(zip); - return once(zip, 'close'); - }); - if (this.urlToExtension[url] !== undefined) { - this.staleExtensionDirs.push(this.urlToExtension[url]); - } - this.urlToExtension[url] = extensionDir; - } - - async downloadFromStore(id: string) { - this.logger.debug(`Download extension ${id} from chrome store`); - const extensionDir = await fs.mkdtemp(os.tmpdir() + path.sep); - const browser = await chromium.launch(); - const chromeVersion = browser.version(); - await browser.close(); - const url = `https://clients2.google.com/service/update2/crx?response=redirect&prodversion=${chromeVersion}&x=id%3D${id}%26installsource%3Dondemand%26uc&nacl_arch=x86-64&acceptformat=crx2,crx3`; - await axios - .get(url, { responseType: 'arraybuffer' }) - .then((response) => this.arrayBufferToStream(response.data)) - .then((response) => { - const zip = unzipper.Extract({ path: extensionDir }); - response.pipe(zip); - return once(zip, 'close'); - }); - if (this.idToExtension[id] !== undefined) { - this.staleExtensionDirs.push(this.idToExtension[id]); - } - this.idToExtension[id] = extensionDir; - } - - private arrayBufferToStream(arraybuffer: ArrayBuffer) { - let buf = new Uint8Array(arraybuffer); - let publicKeyLength, signatureLength, header, zipStartOffset; - if (buf[4] === 2) { - header = 16; - publicKeyLength = - 0 + buf[8] + (buf[9] << 8) + (buf[10] << 16) + (buf[11] << 24); - signatureLength = - 0 + buf[12] + (buf[13] << 8) + (buf[14] << 16) + (buf[15] << 24); - zipStartOffset = header + publicKeyLength + signatureLength; - } else { - publicKeyLength = - 0 + buf[8] + (buf[9] << 8) + (buf[10] << 16) + ((buf[11] << 24) >>> 0); - zipStartOffset = 12 + publicKeyLength; - } - // 16 = Magic number (4), CRX format version (4), lengths (2x4) - buf = buf.slice(zipStartOffset); - return Readable.from([buf]); - } - - async cleanupDownloadedExtensions() { - const extensions = this.staleExtensionDirs.length; - if (extensions > 0) { - for (const extensionDir of this.staleExtensionDirs) { - await fs.rm(extensionDir, { force: true, recursive: true }); - } - this.staleExtensionDirs = []; - this.logger.debug(`Removed ${extensions} stale extension dirs`); - } - } - - async lookUpVersionChanges( - context: BrowserContext, - extensions: Map, - ): Promise { - const changes: ExtensionVersionChange[] = []; - const versions = new Map(); - for (const [name, extensionId] of extensions) { - const page = new ExtensionStorePage(context, extensionId); - await page.navigate(); - const newVersion = await page.getVersion(); - versions.set(name, newVersion); - const currentVersion = this.versions.get(name); - if ( - currentVersion !== undefined && - newVersion !== this.versions.get(name) - ) - changes.push({ - name: name, - before: currentVersion, - after: newVersion, - }); - await page.close(); - } - this.versions = versions; - return changes; - } -} diff --git a/packages/extensions/src/extension.store.page.ts b/packages/extensions/src/extension.store.page.ts deleted file mode 100644 index 58e7ee66..00000000 --- a/packages/extensions/src/extension.store.page.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { BrowserContext, Page } from 'playwright'; -import { CHROME_WEBSTORE_URL } from './extension.constants'; - -export class ExtensionStorePage { - private page: Page | undefined; - constructor( - private browserContext: BrowserContext, - private extensionId: string, - ) {} - - async navigate() { - this.page = await this.browserContext.newPage(); - const url = new URL( - 'webstore/detail/' + this.extensionId, - CHROME_WEBSTORE_URL, - ); - await this.page.goto(url.href); - } - - async getVersion(): Promise { - if (!this.page) throw "Page isn't ready"; - return ( - (await this.page.textContent( - "span:near(:text('Version'):below(:text('Additional Information')))", - )) || 'version not found' - ); - } - - async close() { - if (this.page !== undefined) { - await this.page.close(); - this.page = undefined; - } - } -} diff --git a/packages/extensions/src/extensions.module.ts b/packages/extensions/src/extensions.module.ts deleted file mode 100644 index 42eeebd2..00000000 --- a/packages/extensions/src/extensions.module.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Module } from '@nestjs/common'; -import { ExtensionService } from './extension.service'; - -@Module({ - controllers: [], - providers: [ExtensionService], - exports: [ExtensionService], - imports: [], -}) -export class ExtensionsModule {} diff --git a/packages/extensions/src/index.ts b/packages/extensions/src/index.ts deleted file mode 100644 index 70134a1d..00000000 --- a/packages/extensions/src/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './extension.constants'; -export * from './extension.model'; -export * from './extension.store.page'; -export * from './extension.service'; -export * from './extensions.module'; diff --git a/packages/extensions/tsconfig.json b/packages/extensions/tsconfig.json deleted file mode 100644 index 057c0a55..00000000 --- a/packages/extensions/tsconfig.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "compilerOptions": { - "skipLibCheck": true, - "strict": true, - "esModuleInterop": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "strictNullChecks": true, - "noImplicitReturns": true, - "noImplicitThis": true, - "noImplicitAny": true, - "declaration": true, - "declarationMap": true, - "incremental": true, - "forceConsistentCasingInFileNames": true, - "moduleResolution": "node", - "module": "esnext", - "target": "es2017", - "resolveJsonModule": true, - "composite": true, - "outDir": "./dist", - "rootDir": "." - }, - "references": [] -} diff --git a/packages/nodes/LICENSE.txt b/packages/nodes/LICENSE.txt deleted file mode 100644 index 357ce957..00000000 --- a/packages/nodes/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2021 Lido - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/packages/nodes/README.md b/packages/nodes/README.md deleted file mode 100644 index a7549921..00000000 --- a/packages/nodes/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# Node Module - -Module for using local ganache node with playwright helpers - -## Install - -```bash -yarn add @lidofinance/wallets-testing-nodes -``` - -## Usage - -Import this module and provide `rpcUrl` parameter via factory - -```ts -@Module({ - imports: [ - NodeModule.forRoot( - (configService: ConfigService) => { - return { rpcUrl: configService.get('RPC_URL') }; - }, - [ConfigService], - [ConfigModule], - ), - ], -}) -export class MyModule {} - -// Usage -export class MyService { - constructor(private ethereumNodeService: EthereumNodeService) {} - - async myMethod() { - await this.ethereumNodeService.startNode(); - const state = await this.ethereumNodeService.state; - expect(state).toBeDefined() - await this.ethereumNodeService.stopNode(); - } -} -``` diff --git a/packages/nodes/package.json b/packages/nodes/package.json deleted file mode 100644 index 74692aac..00000000 --- a/packages/nodes/package.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "name": "wallets-testing-nodes5", - "version": "1.0.0", - "main": "dist/src/index.js", - "types": "dist/src/index.d.ts", - "license": "MIT", - "private": false, - "homepage": "https://github.com/lidofinance/wallets-testing-modules", - "repository": { - "type": "git", - "url": "https://github.com/lidofinance/wallets-testing-modules.git", - "directory": "packages/nodes" - }, - "bugs": { - "url": "https://github.com/lidofinance/wallets-testing-modules/issues" - }, - "sideEffects": false, - "scripts": { - "release": "release-it --npm.skipChecks --no-git.requireCleanWorkingDir" - }, - "keywords": [ - "lido", - "lidofinance" - ], - "files": [ - "dist/*" - ], - "publishConfig": { - "registry": "https://registry.npmjs.org/", - "access": "public" - }, - "dependencies": { - "@ganache/console.log": "^0.2.0", - "@nestjs/common": "^8.2.5", - "@nestjs/config": "^2.2.0", - "ethers": "^5.6.9", - "ganache": "7.5.0", - "playwright": "^1.29.1", - "reflect-metadata": "^0.1.13", - "rxjs": "^7.5.6" - }, - "devDependencies": { - "@nestjs/common": "^8.2.5", - "@nestjs/core": "^8.2.5", - "@nestjs/testing": "^8.2.5" - }, - "release-it": { - "git": { - "commit": false, - "tag": false, - "push": false - } - } -} diff --git a/packages/nodes/src/ethereum.node.service.ts b/packages/nodes/src/ethereum.node.service.ts deleted file mode 100644 index d835be01..00000000 --- a/packages/nodes/src/ethereum.node.service.ts +++ /dev/null @@ -1,156 +0,0 @@ -import { Inject, Injectable } from '@nestjs/common'; -import * as ganache from 'ganache'; -import { Server } from 'ganache'; -import { - Request, - APIRequestContext, - APIResponse, - BrowserContext, - Page, -} from 'playwright'; -import { providers, utils, BigNumber, Contract } from 'ethers'; -import { - EthereumNodeServiceOptions, - OPTIONS, - ServiceUnreachableError, - ERC20_SHORT_ABI, - Account, -} from './node.constants'; - -@Injectable() -export class EthereumNodeService { - state: - | { - node: Server; - nodeUrl: string; - accounts: Account[]; - } - | undefined; - - constructor(@Inject(OPTIONS) private options: EthereumNodeServiceOptions) {} - - async startNode() { - if (this.state !== undefined) return; - const node = ganache.server({ - chainId: this.options.chainId || 0x1, - fork: { url: this.options.rpcUrl }, - logging: { quiet: true }, - miner: { blockTime: 2 }, - wallet: { defaultBalance: this.options.defaultBalance || 1000 }, - }); - await node.listen(this.options.port || 7545); - const nodeUrl = `http://127.0.0.1:${this.options.port || 7545}`; - const initialAccounts = await node.provider.getInitialAccounts(); - const accounts: Account[] = Object.keys(initialAccounts).map((key) => { - return { address: key, secretKey: initialAccounts[key].secretKey }; - }); - await Promise.all( - accounts.map(async (account: Account) => { - await node.provider.send('evm_setAccountNonce', [ - account.address, - '0x' + Math.floor(Math.random() * 9) + 1, - ]); - }), - ); - - node.on('close', async () => { - this.state = undefined; - }); - this.state = { node, nodeUrl, accounts }; - } - - async stopNode() { - if (this.state !== undefined) await this.state.node.close(); - } - - async getBalance(account: Account) { - if (this.state === undefined) return undefined; - const response = await this.state.node.provider.request({ - method: 'eth_getBalance', - params: [account.address, 'latest'], - }); - return utils.formatEther(response); - } - - async setErc20Balance( - account: Account, - tokenAddress: string, - mappingSlot: number, - balance: number, - ) { - if (this.state === undefined) throw 'Node not ready'; - - const ethersProvider = new providers.Web3Provider( - this.state.node.provider as unknown as providers.ExternalProvider, - ); - const contract = new Contract( - tokenAddress, - ERC20_SHORT_ABI, - ethersProvider, - ); - const decimals = BigNumber.from(10).pow(await contract.decimals()); - // slot index for _balances mapping in the contract - const mappingSlotHex = BigNumber.from(mappingSlot).toHexString(); - - // calculate slot index for account address in the mapping - const slot = utils.solidityKeccak256( - ['bytes32', 'bytes32'], - [ - utils.hexZeroPad(account.address, 32), - utils.hexZeroPad(mappingSlotHex, 32), - ], - ); - - const value = BigNumber.from(balance).mul(decimals); - - await this.state.node.provider.request({ - method: 'evm_setAccountStorageAt', - params: [tokenAddress, slot, value.toHexString()], - }); - const balanceAfter = await contract.balanceOf(account.address); - return balanceAfter.div(decimals); - } - - async mockRoute(url: string, contextOrPage: BrowserContext | Page) { - await contextOrPage.route(url, async (route) => { - if (this.state === undefined) return; - const response = await this.fetchSafety( - contextOrPage.request, - this.state.nodeUrl, - { - method: route.request().method(), - data: route.request().postData(), - }, - ); - return route.fulfill({ - response: response, - }); - }); - } - - async fetchSafety( - request: APIRequestContext, - urlOrRequest: string | Request, - options: any, // eslint-disable-line @typescript-eslint/no-explicit-any - ): Promise { - let lastErr; - options.timeout = 0; - options.headers = { Connection: 'Keep-Alive', 'Keep-Alive': 'timeout=1' }; - for (let tryCount = 0; tryCount < 3; tryCount++) { - try { - return await request.fetch(urlOrRequest, options); - } catch (err) { - lastErr = err as { message: string }; - } - } - // it causes if we force recreate browser context and there is no problem - if ( - lastErr !== undefined && - !String(lastErr.message).includes( - 'Target page, context or browser has been closed', - ) - ) - throw new ServiceUnreachableError(lastErr, options); - else return undefined; - } -} diff --git a/packages/nodes/src/index.ts b/packages/nodes/src/index.ts deleted file mode 100644 index 91401312..00000000 --- a/packages/nodes/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './ethereum.node.service'; -export * from './node.module'; -export * from './node.constants'; diff --git a/packages/nodes/src/node.constants.ts b/packages/nodes/src/node.constants.ts deleted file mode 100644 index b1caebb4..00000000 --- a/packages/nodes/src/node.constants.ts +++ /dev/null @@ -1,25 +0,0 @@ -export const OPTIONS = 'RPC_NODE_OPTIONS'; -export const ERC20_SHORT_ABI = - '[{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}]'; - -export type EthereumNodeServiceOptions = { - rpcUrl: string; - port?: number; - chainId?: number; - defaultBalance?: number; -}; - -export type Account = { - address: string; - address1: string; - secretKey: string; -}; - -export class ServiceUnreachableError extends Error { - private cause: { message: string }; - //eslint-disable-next-line @typescript-eslint/no-explicit-any - constructor(error: { message: string }, options: any) { - super(error.message + `\n${JSON.stringify(options)}`); - this.cause = error; - } -} diff --git a/packages/nodes/src/node.module.ts b/packages/nodes/src/node.module.ts deleted file mode 100644 index cbc99742..00000000 --- a/packages/nodes/src/node.module.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { DynamicModule, Module } from '@nestjs/common'; -import { EthereumNodeService } from './ethereum.node.service'; -import { OPTIONS } from './node.constants'; - -@Module({}) -export class NodeModule { - /* eslint-disable @typescript-eslint/no-explicit-any */ - static forRoot( - useFactory: (...args: any[]) => { rpcUrl: string }, - inject?: any[], - imports?: any[], - ): DynamicModule { - return { - imports: imports, - module: NodeModule, - providers: [ - { - provide: OPTIONS, - useFactory: useFactory, - inject: inject, - }, - EthereumNodeService, - ], - exports: [EthereumNodeService], - }; - } -} diff --git a/packages/nodes/tsconfig.json b/packages/nodes/tsconfig.json deleted file mode 100644 index 651234f6..00000000 --- a/packages/nodes/tsconfig.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "compilerOptions": { - "skipLibCheck": true, - "alwaysStrict": true, - "strict": true, - "esModuleInterop": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "strictNullChecks": false, - "noImplicitReturns": true, - "noImplicitThis": true, - "noImplicitAny": false, - "declaration": true, - "declarationMap": true, - "incremental": true, - "forceConsistentCasingInFileNames": true, - "moduleResolution": "node", - "module": "commonjs", - "target": "ES2020", - "resolveJsonModule": true, - "composite": true, - "sourceMap": true, - "lib": ["ES2020"], - "outDir": "./dist", - "rootDir": "." - }, - "references": [] -} diff --git a/packages/wallets/LICENSE.txt b/packages/wallets/LICENSE.txt deleted file mode 100644 index 357ce957..00000000 --- a/packages/wallets/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2021 Lido - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/packages/wallets/README.md b/packages/wallets/README.md deleted file mode 100644 index f70114fa..00000000 --- a/packages/wallets/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# Wallets Module - -Module with playwright page objects for wallet extensions - -## Install - -```bash -yarn add @lidofinance/wallets-testing-wallets -``` - -## Usage - -```ts -import {BrowserContext} from "playwright"; -import {MetamaskPage} from "./metamask.page"; - -export class MyService { - constructor() { - } - - async goToMetamask(browserContext: BrowserContext) { - const metamask = new MetamaskPage(browserContext, "chrome-extension://{extensionId}", {}) - } -} -``` diff --git a/packages/wallets/package.json b/packages/wallets/package.json deleted file mode 100644 index 19c9cb21..00000000 --- a/packages/wallets/package.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "name": "wallets-testing-wallets4", - "version": "1.0.0", - "main": "dist/src/index.js", - "types": "dist/src/index.d.ts", - "license": "MIT", - "private": false, - "homepage": "https://github.com/lidofinance/wallets-testing-modules", - "repository": { - "type": "git", - "url": "https://github.com/lidofinance/wallets-testing-modules.git", - "directory": "packages/nodes" - }, - "bugs": { - "url": "https://github.com/lidofinance/wallets-testing-modules/issues" - }, - "sideEffects": false, - "scripts": { - "release": "release-it --npm.skipChecks --no-git.requireCleanWorkingDir" - }, - "keywords": [ - "lido", - "lidofinance" - ], - "files": [ - "dist/*" - ], - "publishConfig": { - "registry": "https://registry.npmjs.org/", - "access": "public" - }, - "dependencies": { - "@playwright/test": "^1.29.1", - "expect": "^28.1.3", - "playwright": "^1.29.1", - "reflect-metadata": "^0.1.13", - "rxjs": "^7.5.6" - }, - "release-it": { - "git": { - "commit": false, - "tag": false, - "push": false - } - } -} diff --git a/packages/wallets/src/coin98/coin98.constants.ts b/packages/wallets/src/coin98/coin98.constants.ts deleted file mode 100644 index caf1d197..00000000 --- a/packages/wallets/src/coin98/coin98.constants.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { CommonWalletConfig } from '../wallets.constants'; - -export const COIN98_COMMON_CONFIG: CommonWalletConfig = { - WALLET_NAME: 'coin98', - RPC_URL_PATTERN: 'https://mainnet.infura.io/v3/**', - STORE_EXTENSION_ID: 'aeachknmefphepccionboohckonoeemg', - CONNECT_BUTTON_NAME: 'Coin98', - SIMPLE_CONNECT: false, - EXTENSION_START_PATH: '/popup.html', -}; diff --git a/packages/wallets/src/coin98/coin98.page.ts b/packages/wallets/src/coin98/coin98.page.ts deleted file mode 100644 index bc84a31b..00000000 --- a/packages/wallets/src/coin98/coin98.page.ts +++ /dev/null @@ -1,92 +0,0 @@ -import { WalletConfig } from '../wallets.constants'; -import { WalletPage } from '../wallet.page'; -import { test, BrowserContext, Page } from '@playwright/test'; - -export class Coin98 implements WalletPage { - page: Page | undefined; - - constructor( - private browserContext: BrowserContext, - private extensionUrl: string, - public config: WalletConfig, - ) {} - - async navigate() { - await test.step('Navigate to Coin98', async () => { - this.page = await this.browserContext.newPage(); - await this.page.goto( - this.extensionUrl + this.config.COMMON.EXTENSION_START_PATH, - ); - await this.page.reload(); - await this.page.waitForTimeout(1000); - }); - } - - async setup(network: string) { - await test.step('Setup', async () => { - await this.navigate(); - if (!this.page) throw "Page isn't ready"; - const firstTime = - (await this.page.locator('text=Create Wallet').count()) > 0; - if (firstTime) await this.firstTimeSetup(network); - }); - } - - async firstTimeSetup(network: string) { - await test.step('First time setup', async () => { - if (!this.page) throw "Page isn't ready"; - await this.page.click('text=Restore Wallet'); - await this.page.click('text=Ok'); - await this.page.waitForSelector('input[type=password]'); - const inputs = await this.page.locator('input[type=password]'); - await inputs.nth(0).fill(this.config.PASSWORD); - await inputs.nth(1).fill(this.config.PASSWORD); - await this.page.click('button:has-text("Setup Password")'); - await this.page.click('button:has-text("Ok")'); - await this.page.click('button:has-text("Confirm")'); - await this.page.fill('[placeholder="Search chain"]', network); - await this.page.click('.box-logo'); - await this.page.fill('[placeholder="Wallet name"]', 'test'); - await this.page.fill( - '.content-editable--password', - this.config.SECRET_PHRASE, - ); - await this.page.click('button:has-text("Restore")'); - }); - } - - async importKey(key: string) { - await test.step('Import key', async () => { - if (!this.page) throw "Page isn't ready"; - await this.page.click('.icon-app_menu'); - await this.page.click('.icon-app_add_wallet'); - await this.page.fill('[placeholder="Search chain"]', 'eth'); - await this.page.click('.box-logo'); - await this.page.click('button:has-text("Restore")'); - await this.page.fill('[placeholder="Wallet name"]', 'ganache'); - await this.page.fill('.content-editable--password', key); - await this.page.click('button[type=submit]'); - }); - } - - async connectWallet(page: Page) { - await test.step('Connect wallet', async () => { - await page.click('button:has-text("Connect")'); - }); - } - - // eslint-disable-next-line - async assertTxAmount(page: Page, expectedAmount: string) {} - - async confirmTx(page: Page) { - await test.step('Confirm TX', async () => { - await page.click('button:has-text("Confirm")'); - }); - } - - // eslint-disable-next-line - async assertReceiptAddress(page: Page, expectedAmount: string) {} - - // eslint-disable-next-line - async addNetwork(networkName: string, networkUrl: string, chainId: number, tokenSymbol: string) {} -} diff --git a/packages/wallets/src/coin98/index.ts b/packages/wallets/src/coin98/index.ts deleted file mode 100644 index 79ae4a34..00000000 --- a/packages/wallets/src/coin98/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './coin98.constants'; -export * from './coin98.page'; diff --git a/packages/wallets/src/coinbase/coinbase.constants.ts b/packages/wallets/src/coinbase/coinbase.constants.ts deleted file mode 100644 index 338501b9..00000000 --- a/packages/wallets/src/coinbase/coinbase.constants.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { CommonWalletConfig } from '../wallets.constants'; - -export const COINBASE_COMMON_CONFIG: CommonWalletConfig = { - WALLET_NAME: 'coinbase', - RPC_URL_PATTERN: 'https://mainnet.infura.io/v3/**', - STORE_EXTENSION_ID: 'hnfanknocfeofbddgcijnmhnfnkdnaad', - CONNECT_BUTTON_NAME: 'Coinbase', - SIMPLE_CONNECT: false, - EXTENSION_START_PATH: '/index.html', -}; diff --git a/packages/wallets/src/coinbase/coinbase.page.ts b/packages/wallets/src/coinbase/coinbase.page.ts deleted file mode 100644 index e9e684cc..00000000 --- a/packages/wallets/src/coinbase/coinbase.page.ts +++ /dev/null @@ -1,134 +0,0 @@ -import { WalletConfig } from '../wallets.constants'; -import { WalletPage } from '../wallet.page'; -import expect from 'expect'; -import { test, BrowserContext, Page } from '@playwright/test'; - -export class CoinbasePage implements WalletPage { - page: Page | undefined; - - constructor( - private browserContext: BrowserContext, - private extensionUrl: string, - public config: WalletConfig, - ) {} - - async navigate() { - await test.step('Navigate to coinbase', async () => { - this.page = await this.browserContext.newPage(); - await this.page.goto( - this.extensionUrl + this.config.COMMON.EXTENSION_START_PATH, - ); - await this.page.reload(); - await this.page.waitForTimeout(1000); - await this.unlock(); - }); - } - - async setup() { - await test.step('Setup', async () => { - await this.navigate(); - if (!this.page) throw "Page isn't ready"; - const firstTime = - (await this.page - .locator('button:has-text("Create new wallet")') - .count()) > 0; - if (firstTime) await this.firstTimeSetup(); - }); - } - - async unlock() { - await test.step('Unlock', async () => { - if (!this.page) throw "Page isn't ready"; - if ((await this.page.locator('id=Unlock with password').count()) > 0) { - await this.page.fill('id=Unlock with password', this.config.PASSWORD); - await this.page.click('text=Unlock'); - } - }); - } - - async firstTimeSetup() { - await test.step('First time setup', async () => { - if (!this.page) throw "Page isn't ready"; - await this.page.click('text=I already have a wallet'); - await this.page.click('text=Enter recovery phrase'); - await this.page.fill('input[type=input]', this.config.SECRET_PHRASE); - await this.page.click('button:has-text("Import wallet")'); - await this.page.fill( - 'input[placeholder="Enter password"]', - this.config.PASSWORD, - ); - await this.page.fill( - 'input[placeholder="Enter password again"]', - this.config.PASSWORD, - ); - await this.page.click('data-testid=terms-and-privacy-policy'); - - await this.page.click('button:has-text("Submit")'); - //wait for complete of recover process(need to wait for wallet page to be opened after seed recover) - await this.page.waitForSelector('data-testid=portfolio-header--switcher'); - }); - } - - async addNetwork( - networkName: string, - networkUrl: string, - chainId: number, - tokenSymbol: string, - ) { - await test.step('Add network', async () => { - if (!this.page) throw "Page isn't ready"; - await this.navigate(); - await this.page.click('text="Settings"'); - await this.page.click('text="Networks"'); - const [addNetworkPage] = await Promise.all([ - this.page.context().waitForEvent('page', { timeout: 5000 }), - await this.page.click('button[data-testid="add-custom-network"]'), - ]); - await addNetworkPage.fill('input[name="chainName"]', networkName); - await addNetworkPage.fill('input[name="rpcUrls[0]"]', networkUrl); - await addNetworkPage.fill('input[name="chainId"]', String(chainId)); - await addNetworkPage.fill( - 'input[name="nativeCurrency.symbol"]', - tokenSymbol, - ); - await addNetworkPage.click('text=Save'); - }); - } - - //Check me if it persists - async closeTransactionPopover() { - await test.step('Close popover if exists', async () => { - if (!this.page) throw "Page isn't ready"; - const popover = (await this.page.locator('text="Got it"').count()) > 0; - if (popover) await this.page.click('text="Got it"'); - }); - } - - async connectWallet(page: Page) { - await test.step('Connect wallet', async () => { - await page.click('button:has-text("Connect")'); - }); - } - - async assertTxAmount(page: Page, expectedAmount: string) { - await test.step('Assert TX Amount', async () => { - expect(await page.textContent('.currency-display-component__text')).toBe( - expectedAmount, - ); - }); - } - - async confirmTx(page: Page) { - await test.step('Confirm TX', async () => { - await this.closeTransactionPopover(); - await page.click('button[data-testid="request-confirm-button"]'); - }); - } - - // eslint-disable-next-line - async assertReceiptAddress(page: Page, expectedAddress: string) { - } - - // eslint-disable-next-line - async importKey(key: string) {} -} diff --git a/packages/wallets/src/coinbase/index.ts b/packages/wallets/src/coinbase/index.ts deleted file mode 100644 index 2dfc9b2f..00000000 --- a/packages/wallets/src/coinbase/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './coinbase.constants'; -export * from './coinbase.page'; diff --git a/packages/wallets/src/exodus/exodus.constants.ts b/packages/wallets/src/exodus/exodus.constants.ts deleted file mode 100644 index e788a579..00000000 --- a/packages/wallets/src/exodus/exodus.constants.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { CommonWalletConfig } from '../wallets.constants'; - -export const EXODUS_COMMON_CONFIG: CommonWalletConfig = { - WALLET_NAME: 'exodus', - RPC_URL_PATTERN: '', - STORE_EXTENSION_ID: 'aholpfdialjgjfhomihkjbmgjidlcdno', - CONNECT_BUTTON_NAME: 'Exodus', - SIMPLE_CONNECT: false, - EXTENSION_START_PATH: '/onboarding.html', -}; diff --git a/packages/wallets/src/exodus/exodus.page.ts b/packages/wallets/src/exodus/exodus.page.ts deleted file mode 100644 index fec9d52b..00000000 --- a/packages/wallets/src/exodus/exodus.page.ts +++ /dev/null @@ -1,102 +0,0 @@ -import { WalletConfig } from '../wallets.constants'; -import { WalletPage } from '../wallet.page'; -import { test, BrowserContext, Page } from '@playwright/test'; - -export class ExodusPage implements WalletPage { - page: Page | undefined; - - constructor( - private browserContext: BrowserContext, - private extensionUrl: string, - public config: WalletConfig, - ) {} - - async navigate() { - await test.step('Navigate to exodus', async () => { - this.page = await this.browserContext.newPage(); - await this.page.goto( - this.extensionUrl + this.config.COMMON.EXTENSION_START_PATH, - ); - await this.page.reload(); - await this.page.waitForTimeout(1000); - await this.unlock(); - }); - } - - async setup() { - await test.step('Setup', async () => { - await this.navigate(); - if (!this.page) throw "Page isn't ready"; - const firstTime = - (await this.page.locator('text=I Have A Wallet').count()) > 0; - if (firstTime) await this.firstTimeSetup(); - }); - } - - async unlock() { - await test.step('Unlock', async () => { - if (!this.page) throw "Page isn't ready"; - if ( - (await this.page - .locator('input[placeholder="Enter password"]') - .count()) > 0 - ) { - await this.page.fill( - 'input[placeholder="Enter password"]', - this.config.PASSWORD, - ); - await this.page.click('text=Unlock'); - } - }); - } - - async firstTimeSetup() { - await test.step('First time setup', async () => { - if (!this.page) throw "Page isn't ready"; - await this.page.click('text=I Have A Wallet'); - await this.page.fill('input[type="text"]', this.config.SECRET_PHRASE); - await this.page.click(':nth-match(:text("Restore"), 2)'); - await this.page.fill( - "input[placeholder='Enter a unique password']", - this.config.PASSWORD, - ); - await this.page.click('text=Next'); - await this.page.fill( - "input[placeholder='Enter your password again']", - this.config.PASSWORD, - ); - await this.page.click('text=Restore'); - await this.page.waitForSelector('text=Continue'); - }); - } - - async connectWallet(page: Page) { - await test.step('Connect wallet', async () => { - await page.waitForTimeout(5000); - await page.click(':nth-match(:text("Connect"), 3)'); - await page.close(); - }); - } - - async confirmTx(page: Page) { - await test.step('Confirm TX', async () => { - await page.click('text=Confirm'); - }); - } - - // eslint-disable-next-line - async importKey(key: string) {} - - async addNetwork( - networkName: string, // eslint-disable-line - networkUrl: string, // eslint-disable-line - chainId: number, // eslint-disable-line - tokenSymbol: string, // eslint-disable-line - ) {} // eslint-disable-line - - // eslint-disable-next-line - async assertTxAmount(page: Page, expectedAmount: string) {} - - // eslint-disable-next-line - async assertReceiptAddress(page: Page, expectedAddress: string) {} -} diff --git a/packages/wallets/src/exodus/index.ts b/packages/wallets/src/exodus/index.ts deleted file mode 100644 index c6be80a4..00000000 --- a/packages/wallets/src/exodus/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './exodus.constants'; -export * from './exodus.page'; diff --git a/packages/wallets/src/gamestop/gamestop.constants.ts b/packages/wallets/src/gamestop/gamestop.constants.ts deleted file mode 100644 index d52b54b0..00000000 --- a/packages/wallets/src/gamestop/gamestop.constants.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { CommonWalletConfig } from '../wallets.constants'; - -export const GAMESTOP_COMMON_CONFIG: CommonWalletConfig = { - WALLET_NAME: 'gamestop', - RPC_URL_PATTERN: 'https://jsonrpc.maiziqianbao.net/**', - STORE_EXTENSION_ID: 'pkkjjapmlcncipeecdmlhaipahfdphkd', - CONNECT_BUTTON_NAME: 'GameStop', - SIMPLE_CONNECT: false, - EXTENSION_START_PATH: '/index.html?fullScreen', -}; diff --git a/packages/wallets/src/gamestop/gamestop.page.ts b/packages/wallets/src/gamestop/gamestop.page.ts deleted file mode 100644 index 8b9cf2df..00000000 --- a/packages/wallets/src/gamestop/gamestop.page.ts +++ /dev/null @@ -1,97 +0,0 @@ -import { WalletConfig } from '../wallets.constants'; -import { WalletPage } from '../wallet.page'; -import { test, BrowserContext, Page } from '@playwright/test'; - -export class GameStopPage implements WalletPage { - page: Page | undefined; - - constructor( - private browserContext: BrowserContext, - private extensionUrl: string, - public config: WalletConfig, - ) {} - - async navigate() { - await test.step('Navigate to GameStop', async () => { - this.page = await this.browserContext.newPage(); - await this.page.goto( - this.extensionUrl + this.config.COMMON.EXTENSION_START_PATH, - ); - await this.page.reload(); - await this.page.waitForTimeout(1000); - await this.unlock(); - }); - } - - async setup() { - await test.step('Setup', async () => { - await this.navigate(); - if (!this.page) throw "Page isn't ready"; - const firstTime = - (await this.page.locator('button:has-text("Recover Wallet")').count()) > - 0; - if (firstTime) await this.firstTimeSetup(); - }); - } - - async unlock() { - await test.step('Unlock', async () => { - if (!this.page) throw "Page isn't ready"; - if ((await this.page.locator('id=password').count()) > 0) { - await this.page.fill('id=password', this.config.PASSWORD); - await this.page.click('button:has-text("Unlock")'); - } - }); - } - - async firstTimeSetup() { - await test.step('First time setup', async () => { - if (!this.page) throw "Page isn't ready"; - await this.page.click('button:has-text("Recover Wallet")'); - await this.page.click('input[id="self-custody"]'); - await this.page.click('input[id="terms"]'); - await this.page.click('button:has-text("Recover My Wallet")'); - await this.page.fill('textarea', this.config.SECRET_PHRASE.trim()); - await this.page.click('button:has-text("Import Wallet")'); - await this.page.fill('input[id="password"]', this.config.PASSWORD); - await this.page.fill('input[id="password_conf"]', this.config.PASSWORD); - await this.page.click('button:has-text("Next")'); - await this.page.click('button:has-text("Next")'); - await this.page.click('button:has-text("View wallet")'); - }); - } - - async connectWallet(page: Page) { - await test.step('Connect wallet', async () => { - await page.click('button:has-text("Next")'); - await page.click('button:has-text("Connect")'); - await page.close(); - }); - } - - async confirmTx(page: Page) { - await test.step('Confirm TX', async () => { - await page.click('button:has-text("Approve")'); - }); - } - - async importKey(key: string) { - await test.step('Import key', async () => { - if (!this.page) throw "Page isn't ready"; - await this.navigate(); - await this.page.click('text=Account 1'); - await this.page.click('Import Account'); - await this.page.fill('id=private_key', key); - await this.page.click("text='Import Account'"); - }); - } - - // eslint-disable-next-line - async assertTxAmount(page: Page, expectedAmount: string) {} - - // eslint-disable-next-line - async assertReceiptAddress(page: Page, expectedAddress: string) {} - - // eslint-disable-next-line - async addNetwork(networkName: string, networkUrl: string, chainId: number, tokenSymbol: string) {} -} diff --git a/packages/wallets/src/gamestop/index.ts b/packages/wallets/src/gamestop/index.ts deleted file mode 100644 index 26dc1ffb..00000000 --- a/packages/wallets/src/gamestop/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './gamestop.constants'; -export * from './gamestop.page'; diff --git a/packages/wallets/src/index.ts b/packages/wallets/src/index.ts deleted file mode 100644 index 94a3ac48..00000000 --- a/packages/wallets/src/index.ts +++ /dev/null @@ -1,12 +0,0 @@ -export * from './wallet.page'; -export * from './wallets.constants'; -export * from './coin98'; -export * from './mathwallet'; -export * from './metamask'; -export * from './trustwallet'; -export * from './phantom'; -export * from './coinbase'; -export * from './taho'; -export * from './exodus'; -export * from './gamestop'; -export * from './xdefi'; diff --git a/packages/wallets/src/mathwallet/index.ts b/packages/wallets/src/mathwallet/index.ts deleted file mode 100644 index 08d1b198..00000000 --- a/packages/wallets/src/mathwallet/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './mathwallet.constants'; -export * from './mathwallet.page'; diff --git a/packages/wallets/src/mathwallet/mathwallet.constants.ts b/packages/wallets/src/mathwallet/mathwallet.constants.ts deleted file mode 100644 index 54159189..00000000 --- a/packages/wallets/src/mathwallet/mathwallet.constants.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { CommonWalletConfig } from '../wallets.constants'; - -export const MATHWALLET_COMMON_CONFIG: CommonWalletConfig = { - WALLET_NAME: 'mathwallet', - RPC_URL_PATTERN: 'https://jsonrpc.maiziqianbao.net/**', - STORE_EXTENSION_ID: 'afbcbjpbpfadlkmhmclhkeeodmamcflc', - CONNECT_BUTTON_NAME: 'MathWallet', - SIMPLE_CONNECT: true, - EXTENSION_START_PATH: '/popup/popup.html', -}; diff --git a/packages/wallets/src/mathwallet/mathwallet.page.ts b/packages/wallets/src/mathwallet/mathwallet.page.ts deleted file mode 100644 index 5374dcad..00000000 --- a/packages/wallets/src/mathwallet/mathwallet.page.ts +++ /dev/null @@ -1,82 +0,0 @@ -import { WalletConfig } from '../wallets.constants'; -import { WalletPage } from '../wallet.page'; -import { test, BrowserContext, Page } from '@playwright/test'; - -export class MathWalletPage implements WalletPage { - page: Page | undefined; - - constructor( - private browserContext: BrowserContext, - private extensionUrl: string, - public config: WalletConfig, - ) {} - - async navigate() { - await test.step('Navigate to MathWallet', async () => { - this.page = await this.browserContext.newPage(); - await this.page.goto( - this.extensionUrl + this.config.COMMON.EXTENSION_START_PATH, - ); - await this.page.reload(); - await this.page.waitForTimeout(1000); - }); - } - - async setup() { - await test.step('Setup', async () => { - await this.navigate(); - if (!this.page) throw "Page isn't ready"; - const firstTime = (await this.page.locator('text=Create').count()) > 0; - if (firstTime) await this.firstTimeSetup(); - }); - } - - async firstTimeSetup() { - await test.step('First time setup', async () => { - if (!this.page) throw "Page isn't ready"; - const inputs = this.page.locator('input[type=password]'); - await inputs.nth(0).fill(this.config.PASSWORD); - await inputs.nth(1).fill(this.config.PASSWORD); - await this.page.click('.create'); - await this.page.click('.select-net'); - await this.page.click('text=Ethereum'); - await this.page.click('.back'); - await this.page.click('.network-add'); - await this.page.click('text="Import Wallet"'); - await this.page.click('text="Import by mnemonic"'); - await this.page.fill('textarea', this.config.SECRET_PHRASE); - await this.page.click('text="Next"'); - await this.page.fill('[placeholder="Wallet Name"]', 'test'); - await this.page.click('text="Confirm"'); - }); - } - - async importKey(key: string) { - await test.step('Import key', async () => { - await this.navigate(); - if (!this.page) throw "Page isn't ready"; - await this.page.click('.network-add'); - await this.page.click('text="Import Wallet"'); - await this.page.click('text="Import by private key"'); - await this.page.fill('textarea', key); - await this.page.click('text="Next"'); - await this.page.fill('[placeholder="Wallet Name"]', 'test1'); - await this.page.click('text="Confirm"'); - }); - } - - // eslint-disable-next-line - async connectWallet(page: Page) {} - - // eslint-disable-next-line - async assertTxAmount(page: Page, expectedAmount: string) {} - - // eslint-disable-next-line - async confirmTx(page: Page) {} - - // eslint-disable-next-line - async assertReceiptAddress(page: Page, expectedAmount: string) {} - - // eslint-disable-next-line - async addNetwork(networkName: string, networkUrl: string, chainId: number, tokenSymbol: string) {} -} diff --git a/packages/wallets/src/metamask/index.ts b/packages/wallets/src/metamask/index.ts deleted file mode 100644 index 9f6cbd65..00000000 --- a/packages/wallets/src/metamask/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './metamask.constants'; -export * from './metamask.page'; diff --git a/packages/wallets/src/metamask/metamask.constants.ts b/packages/wallets/src/metamask/metamask.constants.ts deleted file mode 100644 index 822fdac6..00000000 --- a/packages/wallets/src/metamask/metamask.constants.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { CommonWalletConfig } from '../wallets.constants'; - -export const METAMASK_COMMON_CONFIG: CommonWalletConfig = { - WALLET_NAME: 'metamask', - RPC_URL_PATTERN: 'https://mainnet.infura.io/v3/**', - STORE_EXTENSION_ID: 'nkbihfbeogaeaoehlefnkodbefgpgknn', - CONNECT_BUTTON_NAME: 'Metamask', - SIMPLE_CONNECT: false, - EXTENSION_START_PATH: '/home.html', -}; diff --git a/packages/wallets/src/metamask/metamask.page.ts b/packages/wallets/src/metamask/metamask.page.ts deleted file mode 100644 index 2ef21085..00000000 --- a/packages/wallets/src/metamask/metamask.page.ts +++ /dev/null @@ -1,185 +0,0 @@ -import { WalletConfig } from '../wallets.constants'; -import { WalletPage } from '../wallet.page'; -import expect from 'expect'; -import { test, BrowserContext, Page } from '@playwright/test'; - -export class MetamaskPage implements WalletPage { - page: Page | undefined; - - constructor( - private browserContext: BrowserContext, - private extensionUrl: string, - public config: WalletConfig, - ) {} - - async navigate() { - await test.step('Navigate to metamask', async () => { - this.page = await this.browserContext.newPage(); - await this.page.goto( - this.extensionUrl + this.config.COMMON.EXTENSION_START_PATH, - ); - await this.page.reload(); - await this.page.waitForTimeout(1000); - await this.closePopover(); - await this.unlock(); - }); - } - - async setup() { - await test.step('Setup', async () => { - await this.navigate(); - if (!this.page) throw "Page isn't ready"; - const firstTime = - (await this.page.locator('data-testid=onboarding-welcome').count()) > 0; - if (firstTime) await this.firstTimeSetup(); - }); - } - - async unlock() { - await test.step('Unlock', async () => { - if (!this.page) throw "Page isn't ready"; - if ((await this.page.locator('id=password').count()) > 0) { - await this.page.fill('id=password', this.config.PASSWORD); - await this.page.click('text=Unlock'); - } - }); - } - - async importTokens(token: string) { - await test.step('Import token', async () => { - await this.navigate(); - if (!this.page) throw "Page isn't ready"; - await this.page.click("text='import tokens'"); - await this.page.click('text=Custom token'); - await this.page.type('id=custom-address', token); - }); - } - - async closePopover() { - await test.step('Close popover if exists', async () => { - if (!this.page) throw "Page isn't ready"; - const popover = - (await this.page.getByTestId('popover-close').count()) > 0; - if (popover) await this.page.click('data-testid=popover-close'); - }); - } - - async firstTimeSetup() { - await test.step('First time setup', async () => { - if (!this.page) throw "Page isn't ready"; - await this.page.click('data-testid=onboarding-terms-checkbox'); - await this.page.click('data-testid=onboarding-import-wallet'); - await this.page.click('data-testid=metametrics-i-agree'); - const inputs = this.page.locator( - '.import-srp__srp-word >> input[type=password]', - ); - const seedWords = this.config.SECRET_PHRASE.split(' '); - for (let i = 0; i < seedWords.length; i++) { - await inputs.nth(i).fill(seedWords[i]); - } - await this.page.click('data-testid=import-srp-confirm'); - await this.page.fill( - 'data-testid=create-password-new', - this.config.PASSWORD, - ); - await this.page.fill( - 'data-testid=create-password-confirm', - this.config.PASSWORD, - ); - await this.page.click('data-testid=create-password-terms'); - await this.page.click('data-testid=create-password-import'); - await this.page.click('data-testid=onboarding-complete-done'); - await this.page.click('data-testid=pin-extension-next'); - await this.page.click('data-testid=pin-extension-done'); - await this.closePopover(); - }); - } - - async addNetwork( - networkName: string, - networkUrl: string, - chainId: number, - tokenSymbol: string, - ) { - await test.step('Add network', async () => { - if (!this.page) throw "Page isn't ready"; - await this.navigate(); - await this.page.click('data-testid=account-options-menu-button'); - await this.page.click('text=Settings'); - await this.page.click("text='Networks'"); - await this.page.click('text=Add a network'); - await this.page.click("a :has-text('Add a network manually')"); - await this.page.fill( - ".form-field :has-text('Network Name') >> input", - networkName, - ); - await this.page.fill( - ".form-field :has-text('New RPC URL') >> input", - networkUrl, - ); - await this.page.fill( - ".form-field :has-text('Chain ID') >> input", - String(chainId), - ); - await this.page.fill( - ".form-field :has-text('Currency symbol') >> input", - tokenSymbol, - ); - await this.page.click('text=Save'); - await this.navigate(); - }); - } - - async importKey(key: string) { - await test.step('Import key', async () => { - if (!this.page) throw "Page isn't ready"; - await this.navigate(); - await this.page.click('data-testid=account-menu-icon'); - await this.page.click('text=Import account'); - await this.page.fill('id=private-key-box', key); - await this.page.click("text='Import'"); - }); - } - - async connectWallet(page: Page) { - await test.step('Connect wallet', async () => { - await page.click('text=Next'); - await page.click('data-testid=page-container-footer-next'); - await page.close(); - }); - } - - async assertTxAmount(page: Page, expectedAmount: string) { - await test.step('Assert TX Amount', async () => { - expect(await page.textContent('.currency-display-component__text')).toBe( - expectedAmount, - ); - }); - } - - async confirmTx(page: Page) { - await test.step('Confirm TX', async () => { - await page.click('text=Confirm'); - }); - } - - async approveTokenTx(page: Page) { - await test.step('Approve token tx', async () => { - await page.click('text=Use default'); - await page.click('text=Next'); - await page.waitForTimeout(2000); - await page.click('text=Approve'); - }); - } - - async assertReceiptAddress(page: Page, expectedAddress: string) { - await test.step('Assert receiptAddress/Contract', async () => { - await page.click('text=Liquid staked Ether 2.0'); - const receiptAddress = await page - .locator(`text=${expectedAddress}`) - .innerText(); - await page.click('button[data-testid=popover-close]'); - expect(receiptAddress).toBe(expectedAddress); - }); - } -} diff --git a/packages/wallets/src/phantom/index.ts b/packages/wallets/src/phantom/index.ts deleted file mode 100644 index 2f3bffe7..00000000 --- a/packages/wallets/src/phantom/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './phantom.constants'; -export * from './phantom.page'; diff --git a/packages/wallets/src/phantom/phantom.constants.ts b/packages/wallets/src/phantom/phantom.constants.ts deleted file mode 100644 index a5e1bf55..00000000 --- a/packages/wallets/src/phantom/phantom.constants.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { CommonWalletConfig } from '../wallets.constants'; - -export const PHANTOM_COMMON_CONFIG: CommonWalletConfig = { - WALLET_NAME: 'phantom', - RPC_URL_PATTERN: '', - STORE_EXTENSION_ID: 'bfnaelmomeimhlpmgjnjophhpkkoljpa', - CONNECT_BUTTON_NAME: 'Phantom', - SIMPLE_CONNECT: false, - EXTENSION_START_PATH: '/onboarding.html', -}; diff --git a/packages/wallets/src/phantom/phantom.page.ts b/packages/wallets/src/phantom/phantom.page.ts deleted file mode 100644 index f64b6db8..00000000 --- a/packages/wallets/src/phantom/phantom.page.ts +++ /dev/null @@ -1,117 +0,0 @@ -import { WalletConfig } from '../wallets.constants'; -import { WalletPage } from '../wallet.page'; -import expect from 'expect'; -import { test, BrowserContext, Page } from '@playwright/test'; - -export class PhantomPage implements WalletPage { - page: Page | undefined; - - constructor( - private browserContext: BrowserContext, - private extensionUrl: string, - public config: WalletConfig, - ) {} - - async navigate() { - await test.step('Navigate to phantom', async () => { - this.page = await this.browserContext.newPage(); - await this.page.goto(this.extensionUrl + '/popup.html'); - await this.page.reload(); - await this.page.waitForTimeout(1000); - await this.unlock(); - }); - } - - async setup() { - await test.step('Setup', async () => { - // added explicit route to /onboarding due to unexpected first time route from /popup.html to /onboarding - page is close - this.page = await this.browserContext.newPage(); - await this.page.goto(this.extensionUrl + '/onboarding.html'); - if (!this.page) throw "Page isn't ready"; - await this.page.waitForSelector( - 'button:has-text("I already have a wallet")', - ); - const firstTime = - (await this.page - .locator('button:has-text("I already have a wallet")') - .count()) > 0; - if (firstTime) await this.firstTimeSetup(); - }); - } - - async unlock() { - await test.step('Unlock', async () => { - if (!this.page) throw "Page isn't ready"; - if ((await this.page.locator('id=password').count()) > 0) { - await this.page.fill('input[name=password]', this.config.PASSWORD); - await this.page.click('text=Unlock'); - } - }); - } - - async firstTimeSetup() { - await test.step('First time setup', async () => { - if (!this.page) throw "Page isn't ready"; - await this.page.click('button:has-text("I already have a wallet")'); - const inputs = this.page.locator('input[data-testid]'); - const seedWords = this.config.SECRET_PHRASE.split(' '); - for (let i = 0; i < seedWords.length; i++) { - await inputs.nth(i).fill(seedWords[i]); - } - await this.page.click('button[type=submit]'); - await this.page.waitForSelector( - "button[data-testid='onboarding-form-submit-button']", - ); - await this.page.click( - "button[data-testid='onboarding-form-submit-button']", - ); - await this.page.fill('input[name=password]', this.config.PASSWORD); - await this.page.fill('input[name=confirmPassword]', this.config.PASSWORD); - await this.page.click('input[type=checkbox]'); - await this.page.click('button:has-text("Continue")'); - await this.page.click('button:has-text("Continue")'); - }); - } - - async importKey(key: string) { - await test.step('Import key', async () => { - if (!this.page) throw "Page isn't ready"; - await this.navigate(); - await this.page.click('text=W1'); - await this.page.click('div:has-text("Wallet 1")'); - await this.page.click('button:has-text("Add / Connect Wallet")'); - await this.page.click( - 'div[data-testid="add-account-create-new-wallet-button"]', - ); - await this.page.fill('textarea', key); - await this.page.click('button:has-text("Import")'); - }); - } - - async connectWallet(page: Page) { - await test.step('Connect wallet', async () => { - await page.click('button:has-text("Connect")'); - }); - } - - async assertTxAmount(page: Page, expectedAmount: string) { - await test.step('Assert TX Amount', async () => { - expect( - await page.locator(`text=Send ${expectedAmount} SOL`).count(), - ).toBe(1); - }); - } - - async confirmTx(page: Page) { - await test.step('Confirm TX', async () => { - await page.click('text=Approve'); - }); - } - - // eslint-disable-next-line - async assertReceiptAddress(page: Page, expectedAddress: string) { - } - - // eslint-disable-next-line - async addNetwork(networkName: string, networkUrl: string, chainId: number, tokenSymbol: string) {} -} diff --git a/packages/wallets/src/taho/index.ts b/packages/wallets/src/taho/index.ts deleted file mode 100644 index 353586dc..00000000 --- a/packages/wallets/src/taho/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './taho.constants'; -export * from './taho.page'; diff --git a/packages/wallets/src/taho/taho.constants.ts b/packages/wallets/src/taho/taho.constants.ts deleted file mode 100644 index 62e9593b..00000000 --- a/packages/wallets/src/taho/taho.constants.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { CommonWalletConfig } from '../wallets.constants'; - -export const TAHO_COMMON_CONFIG: CommonWalletConfig = { - WALLET_NAME: 'taho', - RPC_URL_PATTERN: 'https://mainnet.infura.io/v3/**', - STORE_EXTENSION_ID: 'eajafomhmkipbjmfmhebemolkcicgfmd', - CONNECT_BUTTON_NAME: 'Taho', - SIMPLE_CONNECT: false, - EXTENSION_START_PATH: '/popup.html', -}; diff --git a/packages/wallets/src/taho/taho.page.ts b/packages/wallets/src/taho/taho.page.ts deleted file mode 100644 index f4cfd0c2..00000000 --- a/packages/wallets/src/taho/taho.page.ts +++ /dev/null @@ -1,97 +0,0 @@ -import { WalletConfig } from '../wallets.constants'; -import { WalletPage } from '../wallet.page'; -import expect from 'expect'; -import { test, BrowserContext, Page } from '@playwright/test'; - -export class TahoPage implements WalletPage { - page: Page | undefined; - - constructor( - private browserContext: BrowserContext, - private extensionUrl: string, - public config: WalletConfig, - ) {} - - async navigate() { - await test.step('Navigate to taho', async () => { - this.page = await this.browserContext.newPage(); - await this.page.goto( - this.extensionUrl + this.config.COMMON.EXTENSION_START_PATH, - ); - await this.page.reload(); - await this.page.waitForTimeout(1000); - }); - } - - async setup() { - await test.step('Setup', async () => { - // added explicit route to /onboarding due to unexpected first time route from /home.html to /onboarding - page always closing - this.page = await this.browserContext.newPage(); - await this.page.goto(this.extensionUrl + '/tab.html#/onboarding'); - if (!this.page) throw "Page isn't ready"; - const firstTime = - (await this.page.locator('text=Use existing wallet').count()) > 0; - if (firstTime) await this.firstTimeSetup(); - }); - } - - async firstTimeSetup() { - await test.step('First time setup', async () => { - if (!this.page) throw "Page isn't ready"; - await this.page.click('text=Use existing wallet'); - await this.page.click('text=Import recovery phrase'); - await this.page.fill( - '[type=password]:above(:text("Password"))', - this.config.PASSWORD, - ); - await this.page.fill( - '[type=password]:near(:text("Repeat password"))', - this.config.PASSWORD, - ); - await this.page.click('text=Begin the hunt'); - await this.page.fill('id=recovery_phrase', this.config.SECRET_PHRASE); - await this.page.click('button:has-text("Import account")'); - }); - } - - async importKey(key: string) { - await test.step('Import key', async () => { - if (!this.page) throw "Page isn't ready"; - await this.navigate(); - await this.page.click('.profile_button'); - await this.page.click('text=Add wallet'); - await this.page.click('text=Import recovery phrase'); - await this.page.fill('id=recovery_phrase', key); - await this.page.click('button:has-text("Import account")'); - }); - } - - async connectWallet(page: Page) { - await test.step('Connect wallet', async () => { - await page.locator('button').nth(3).click(); - await page.locator('button').nth(1).click(); - await page.click('button:has-text("Connect")'); - await page.close(); - }); - } - - async assertTxAmount(page: Page, expectedAmount: string) { - await test.step('Assert TX Amount', async () => { - expect(await page.textContent('.currency-display-component__text')).toBe( - expectedAmount, - ); - }); - } - - async confirmTx(page: Page) { - await test.step('Confirm TX', async () => { - await page.click('text=Sign'); - }); - } - - // eslint-disable-next-line - async assertReceiptAddress(page: Page, expectedAddress: string) {} - - // eslint-disable-next-line - async addNetwork(networkName: string, networkUrl: string, chainId: number, tokenSymbol: string) {} -} diff --git a/packages/wallets/src/trustwallet/index.ts b/packages/wallets/src/trustwallet/index.ts deleted file mode 100644 index caf61c87..00000000 --- a/packages/wallets/src/trustwallet/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './trustwallet.constants'; -export * from './trustWalletPage'; diff --git a/packages/wallets/src/trustwallet/trustWalletPage.ts b/packages/wallets/src/trustwallet/trustWalletPage.ts deleted file mode 100644 index 5bd33ae4..00000000 --- a/packages/wallets/src/trustwallet/trustWalletPage.ts +++ /dev/null @@ -1,139 +0,0 @@ -import { WalletConfig } from '../wallets.constants'; -import { WalletPage } from '../wallet.page'; -import expect from 'expect'; -import { test, BrowserContext, Page } from '@playwright/test'; - -export class TrustWalletPage implements WalletPage { - page: Page | undefined; - - constructor( - private browserContext: BrowserContext, - private extensionUrl: string, - public config: WalletConfig, - ) {} - - async navigate() { - await test.step('Navigate to Trust wallet', async () => { - this.page = await this.browserContext.newPage(); - await this.page.goto( - this.extensionUrl + this.config.COMMON.EXTENSION_START_PATH, - ); - await this.page.waitForTimeout(1000); - await this.unlock(); - }); - } - - async setup() { - await test.step('Setup', async () => { - // added explicit route to /onboarding due to unexpected first time route from /home.html to /onboarding - page is close - this.page = await this.browserContext.newPage(); - await this.page.goto(this.extensionUrl + '/home.html#/onboarding'); - await this.page.waitForSelector( - 'div:has-text("Welcome to the Trust Wallet Extension")', - ); - if (!this.page) throw "Page isn't ready"; - const firstTime = - (await this.page.locator('text=Import or recover wallet').count()) > 0; - if (firstTime) await this.firstTimeSetup(); - }); - } - - async unlock() { - await test.step('Unlock', async () => { - if (!this.page) throw "Page isn't ready"; - if ((await this.page.locator('input[type=password]').count()) > 0) { - await this.page.fill('input[type=password]', this.config.PASSWORD); - await this.page.click('button:has-text("Unlock")'); - } - }); - } - - async firstTimeSetup() { - await test.step('First time setup', async () => { - if (!this.page) throw "Page isn't ready"; - await this.page.click('text="Import or recover wallet"'); - await this.page.fill( - 'input[placeholder="New password"]', - this.config.PASSWORD, - ); - await this.page.fill( - 'input[placeholder="Confirm new password"]', - this.config.PASSWORD, - ); - await this.page.click('span[aria-hidden=true]'); - await this.page.click('button:has-text("Next")'); - await this.page.waitForTimeout(2000); - const inputs = this.page.locator('input[type="password"]'); - const seedWords = this.config.SECRET_PHRASE.split(' '); - for (let i = 0; i < seedWords.length; i++) { - await inputs.nth(i).fill(seedWords[i]); - } - await this.page.click('button:has-text("next")'); - await this.page.click('button:has-text("No thanks")'); - await this.page.waitForSelector( - 'text=You have successfully imported your wallet!', - ); - }); - } - - async addNetwork( - networkName: string, - networkUrl: string, - chainId: number, - tokenSymbol: string, - ) { - await test.step('Add network', async () => { - if (!this.page) throw "Page isn't ready"; - await this.navigate(); - await this.page.click('text=Settings'); - await this.page.click('text=Network'); - await this.page.click('text=Add a network'); - await this.page.click('button:has-text("Add custom network")'); - await this.page.fill('input[placeholder="Network name"]', networkName); - await this.page.fill('input[placeholder="RPC URL"]', networkUrl); - await this.page.fill('input[placeholder="Chain ID"]', String(chainId)); - await this.page.fill('input[placeholder="Token symbol"]', tokenSymbol); - await this.page.click('button:has-text("Add custom network")'); - await this.navigate(); - }); - } - - async importTokens(token: string) { - await test.step('Import token', async () => { - await this.navigate(); - if (!this.page) throw "Page isn't ready"; - await this.page.click('id="manage-tokens-button"'); - await this.page.type( - 'input[placeholder="Token name or contract address"]', - token, - ); - }); - } - - async connectWallet(page: Page) { - await test.step('Connect wallet', async () => { - await page.waitForTimeout(1000); - await page.click('button:has-text("Connect")'); - }); - } - - async assertTxAmount(page: Page, expectedAmount: string) { - await test.step('Assert TX Amount', async () => { - expect(await page.textContent('.currency-display-component__text')).toBe( - expectedAmount, - ); - }); - } - - async confirmTx(page: Page) { - await test.step('Confirm TX', async () => { - await page.click('text=Confirm'); - }); - } - - // eslint-disable-next-line - async assertReceiptAddress(page: Page, expectedAddress: string) {} - - // eslint-disable-next-line - async importKey(key: string) {} -} diff --git a/packages/wallets/src/trustwallet/trustwallet.constants.ts b/packages/wallets/src/trustwallet/trustwallet.constants.ts deleted file mode 100644 index 13a92bea..00000000 --- a/packages/wallets/src/trustwallet/trustwallet.constants.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { CommonWalletConfig } from '../wallets.constants'; - -export const TRUST_WALLET_COMMON_CONFIG: CommonWalletConfig = { - WALLET_NAME: 'trust', - RPC_URL_PATTERN: 'https://mainnet.infura.io/v3/**', - STORE_EXTENSION_ID: 'egjidjbpglichdcondbcbdnbeeppgdph', - CONNECT_BUTTON_NAME: 'Trust Wallet', - SIMPLE_CONNECT: false, - EXTENSION_START_PATH: '/home.html', -}; diff --git a/packages/wallets/src/wallet.page.ts b/packages/wallets/src/wallet.page.ts deleted file mode 100644 index 5a7ca277..00000000 --- a/packages/wallets/src/wallet.page.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { Page } from 'playwright'; -import { WalletConfig } from './wallets.constants'; - -export interface WalletPage { - page: Page | undefined; - config: WalletConfig; - - setup(network?: string): Promise; - - importKey(key: string): Promise; - - connectWallet(page: Page): Promise; - - assertTxAmount(page: Page, expectedAmount: string): Promise; - - confirmTx(page: Page): Promise; - - approveTokenTx?(page: Page): Promise; - - assertReceiptAddress(page: Page, expectedAmount: string): Promise; - - addNetwork( - networkName: string, - networkUrl: string, - chainId: number, - tokenSymbol: string, - ): Promise; -} diff --git a/packages/wallets/src/wallets.constants.ts b/packages/wallets/src/wallets.constants.ts deleted file mode 100644 index f3f9527a..00000000 --- a/packages/wallets/src/wallets.constants.ts +++ /dev/null @@ -1,15 +0,0 @@ -export interface CommonWalletConfig { - WALLET_NAME: string; - RPC_URL_PATTERN: string; - STORE_EXTENSION_ID: string; - CONNECT_BUTTON_NAME: string; - SIMPLE_CONNECT: boolean; - EXTENSION_START_PATH: string; -} - -export interface WalletConfig { - SECRET_PHRASE: string; - PASSWORD: string; - COMMON: CommonWalletConfig; - EXTENSION_PATH?: string; -} diff --git a/packages/wallets/src/xdefi/index.ts b/packages/wallets/src/xdefi/index.ts deleted file mode 100644 index b50948ca..00000000 --- a/packages/wallets/src/xdefi/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './xdefi.page'; -export * from './xdefi.constants'; diff --git a/packages/wallets/src/xdefi/xdefi.constants.ts b/packages/wallets/src/xdefi/xdefi.constants.ts deleted file mode 100644 index f947b2ce..00000000 --- a/packages/wallets/src/xdefi/xdefi.constants.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { CommonWalletConfig } from '../wallets.constants'; - -export const XDEFI_COMMON_CONFIG: CommonWalletConfig = { - WALLET_NAME: 'xdefi', - RPC_URL_PATTERN: 'https://mainnet.infura.io/v3/**', - STORE_EXTENSION_ID: 'hmeobnfnfcmdkdcmlblgagmfpfboieaf', - CONNECT_BUTTON_NAME: 'XDEFI', - SIMPLE_CONNECT: false, - EXTENSION_START_PATH: '/app.html', -}; diff --git a/packages/wallets/src/xdefi/xdefi.page.ts b/packages/wallets/src/xdefi/xdefi.page.ts deleted file mode 100644 index 235ccb24..00000000 --- a/packages/wallets/src/xdefi/xdefi.page.ts +++ /dev/null @@ -1,115 +0,0 @@ -import { WalletConfig } from '../wallets.constants'; -import { WalletPage } from '../wallet.page'; -import expect from 'expect'; -import { test, BrowserContext, Page } from '@playwright/test'; - -export class XdefiPage implements WalletPage { - page: Page | undefined; - - constructor( - private browserContext: BrowserContext, - private extensionUrl: string, - public config: WalletConfig, - ) {} - - async navigate() { - await test.step('Navigate to xdefi', async () => { - this.page = await this.browserContext.newPage(); - await this.page.goto( - this.extensionUrl + this.config.COMMON.EXTENSION_START_PATH, - ); - await this.page.reload(); - await this.page.waitForTimeout(1000); - }); - } - - async setup() { - await test.step('Setup', async () => { - // added explicit route to /onboarding due to unexpected first time route from /home.html to /onboarding - page is close - this.page = await this.browserContext.newPage(); - await this.page.goto(this.extensionUrl + '/onboarding.html'); - if (!this.page) throw "Page isn't ready"; - const firstTime = await this.page.waitForSelector( - "text=Let's get started", - ); - if (firstTime) await this.firstTimeSetup(); - }); - } - - async importTokens(token: string) { - await test.step('Import token', async () => { - await this.navigate(); - if (!this.page) throw "Page isn't ready"; - await this.page.click('button[data-testid="addAssetsBtn"]'); - await this.page.click('li[data-testid="customTab"]'); - await this.page.type('input[name="address"]', token); - await this.page.click('button[data-testid="nextBtn"]'); - }); - } - - async firstTimeSetup() { - await test.step('First time setup', async () => { - if (!this.page) throw "Page isn't ready"; - await this.page.click('text=Restore XDEFI Wallet'); - await this.page.click('text=Restore with secret phrase'); - const inputs = this.page.locator('input[data-testid=input]'); - const seedWords = this.config.SECRET_PHRASE.split(' '); - for (let i = 0; i < seedWords.length; i++) { - await inputs.nth(i).fill(seedWords[i]); - } - await this.page.click('text=Next'); - await this.page.fill('input[name="password"]', this.config.PASSWORD); - await this.page.fill('input[name="cpassword"]', this.config.PASSWORD); - await this.page.click('div[data-testid=termsAndConditionsCheckbox]'); - await this.page.click('button[type="submit"]'); - await this.page.fill( - 'input[name="walletName"]', - this.config.COMMON.WALLET_NAME, - ); - await this.page.click('button[type="submit"]'); - await this.page.click('div[data-testid=prioritiesXdefiToggle]'); - await this.page.click('button[data-testid=nextBtn]'); - }); - } - - async importKey(key: string) { - await test.step('Import key', async () => { - if (!this.page) throw "Page isn't ready"; - await this.navigate(); - await this.page.click('button[data-testid="menuBtn"]'); - await this.page.click('li[data-testid="walletManagementBtn"]'); - await this.page.click('div[data-testid="importWalletBtn"]'); - await this.page.click('text=Seed Phrase'); - await this.page.fill('textarea[name="[phrase"]', key); - await this.page.click('svg:below(input)'); - await this.page.click('button[data-testid="importBtn"]'); - }); - } - - async connectWallet(page: Page) { - await test.step('Connect wallet', async () => { - await page.click('label[data-testid="selectAllBtn"]'); - await page.click('button[data-testid="nextBtn"]'); - await page.click('button[data-testid="connectBtn"]'); - await page.close(); - }); - } - - async assertTxAmount(page: Page, expectedAmount: string) { - await test.step('Assert TX Amount', async () => { - expect(await page.locator(`text=${expectedAmount} ETH`).count()).toBe(1); - }); - } - - async confirmTx(page: Page) { - await test.step('Confirm TX', async () => { - await page.click('button[data-testid="confirmBtn"]'); - }); - } - - // eslint-disable-next-line - async assertReceiptAddress(page: Page, expectedAddress: string) {} - - // eslint-disable-next-line - async addNetwork(networkName: string, networkUrl: string, chainId: number, tokenSymbol: string) {} -} diff --git a/packages/wallets/tsconfig.json b/packages/wallets/tsconfig.json deleted file mode 100644 index 10832f5a..00000000 --- a/packages/wallets/tsconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "compilerOptions": { - "strict": true, - "esModuleInterop": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "strictNullChecks": true, - "noImplicitReturns": true, - "noImplicitThis": true, - "noImplicitAny": true, - "declaration": true, - "declarationMap": true, - "incremental": true, - "forceConsistentCasingInFileNames": true, - "moduleResolution": "node", - "module": "esnext", - "target": "es2017", - "resolveJsonModule": true, - "composite": true, - "outDir": "./dist", - "rootDir": "." - }, - "references": [] -} diff --git a/packages/widgets/package.json b/packages/widgets/package.json index cc7fc81a..c9875c81 100644 --- a/packages/widgets/package.json +++ b/packages/widgets/package.json @@ -1,5 +1,5 @@ { - "name": "wallets-testing-widgets5", + "name": "wallets-testing-widgets10", "version": "1.0.0", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", diff --git a/wallets-testing/package.json b/wallets-testing/package.json index 4149a55b..846b53ba 100644 --- a/wallets-testing/package.json +++ b/wallets-testing/package.json @@ -1,5 +1,5 @@ { - "name": "wallets-testing5", + "name": "wallets-testing10", "version": "1.0.0", "description": "", "author": "",