From c5087d08e51efdf4fa104dc9663079a55e793a5d Mon Sep 17 00:00:00 2001 From: Sero <69639595+Seroxdesign@users.noreply.github.com> Date: Wed, 12 Jun 2024 10:51:39 -0400 Subject: [PATCH] initial keplr set up --- wallets/keplr/cypress.config.ts | 16 ++++++++++ wallets/keplr/environment.d.ts | 19 ++++++++++++ wallets/keplr/package.json | 46 +++++++++++++++++++++++++++ wallets/keplr/playwright.config.ts | 50 ++++++++++++++++++++++++++++++ wallets/keplr/tsconfig.build.json | 12 +++++++ wallets/keplr/tsconfig.json | 12 +++++++ wallets/keplr/tsup.config.ts | 12 +++++++ wallets/keplr/vitetest.config.ts | 7 +++++ 8 files changed, 174 insertions(+) create mode 100644 wallets/keplr/cypress.config.ts create mode 100644 wallets/keplr/environment.d.ts create mode 100644 wallets/keplr/package.json create mode 100644 wallets/keplr/playwright.config.ts create mode 100644 wallets/keplr/tsconfig.build.json create mode 100644 wallets/keplr/tsconfig.json create mode 100644 wallets/keplr/tsup.config.ts create mode 100644 wallets/keplr/vitetest.config.ts diff --git a/wallets/keplr/cypress.config.ts b/wallets/keplr/cypress.config.ts new file mode 100644 index 000000000..e57319d60 --- /dev/null +++ b/wallets/keplr/cypress.config.ts @@ -0,0 +1,16 @@ +import { defineConfig } from 'cypress' +import { installSynpress } from './src/cypress' + +export default defineConfig({ + chromeWebSecurity: false, + e2e: { + baseUrl: 'http://localhost:9999', + specPattern: 'test/cypress/**/*.cy.{js,jsx,ts,tsx}', + supportFile: 'src/cypress/support/e2e.{js,jsx,ts,tsx}', + fixturesFolder: 'src/cypress/fixtures', + testIsolation: false, + async setupNodeEvents(on, config) { + return installSynpress(on, config) + } + } +}) diff --git a/wallets/keplr/environment.d.ts b/wallets/keplr/environment.d.ts new file mode 100644 index 000000000..fed78f861 --- /dev/null +++ b/wallets/keplr/environment.d.ts @@ -0,0 +1,19 @@ +declare global { + namespace NodeJS { + interface ProcessEnv { + CI: boolean + HEADLESS: boolean + } + } +} + +declare global { + interface Window { + ethereum: import('ethers').Eip1193Provider + } + + // biome-ignore lint/suspicious/noExplicitAny: Web3Mock is a mock object + const Web3Mock: any +} + +export {} diff --git a/wallets/keplr/package.json b/wallets/keplr/package.json new file mode 100644 index 000000000..f1d32e6fe --- /dev/null +++ b/wallets/keplr/package.json @@ -0,0 +1,46 @@ +{ + "name": "@synthetixio/keplr", + "version": "0.0.1-alpha.0", + "type": "module", + "exports": { + "types": "./types/index.d.ts", + "default": "./dist/index.js" + }, + "main": "./dist/index.js", + "types": "./types/index.d.ts", + "files": [ + "dist", + "src", + "types" + ], + "scripts": { + "build": "pnpm run clean && pnpm run build:dist && pnpm run build:types", + "build:dist": "tsup --tsconfig tsconfig.build.json", + "build:types": "tsc --emitDeclarationOnly --project tsconfig.build.json", + "clean": "rimraf dist types", + "test": "vitest run", + "test:coverage": "vitest run --coverage", + "test:e2e:headful": "playwright test", + "test:e2e:headless": "HEADLESS=true playwright test", + "test:e2e:headless:ui": "HEADLESS=true playwright test --ui", + "test:watch": "vitest watch", + "types:check": "tsc --noEmit" + }, + "dependencies": { + "@synthetixio/synpress-cache": "workspace:*", + "@synthetixio/synpress-core": "workspace:*" + }, + "devDependencies": { + "@synthetixio/synpress-tsconfig": "workspace:*", + "@types/node": "20.11.17", + "@vitest/coverage-v8": "1.2.2", + "cypress": "13.9.0", + "rimraf": "5.0.5", + "tsup": "8.0.2", + "typescript": "5.3.3", + "vitest": "1.2.2" + }, + "peerDependencies": { + "@playwright/test": "1.44.0" + } +} \ No newline at end of file diff --git a/wallets/keplr/playwright.config.ts b/wallets/keplr/playwright.config.ts new file mode 100644 index 000000000..a1c5c34e5 --- /dev/null +++ b/wallets/keplr/playwright.config.ts @@ -0,0 +1,50 @@ +import { defineConfig, devices } from '@playwright/test' + +/** + * See https://playwright.dev/docs/test-configuration. + */ +export default defineConfig({ + // Look for test files in the "test/e2e" directory, relative to this configuration file. + testDir: './test/playwright', + + // We're increasing the timeout to 60 seconds to allow all traces to be recorded. + // Sometimes it threw an error saying that traces were not recorded in the 30 seconds timeout limit. + timeout: 60_000, + + // Run all tests in parallel. + fullyParallel: true, + + // Fail the build on CI if you accidentally left test.only in the source code. + forbidOnly: !!process.env.CI, + + // Fail all remaining tests on CI after the first failure. We want to reduce the feedback loop on CI to minimum. + maxFailures: process.env.CI ? 1 : 0, + + // Opt out of parallel tests on CI since it supports only 1 worker. + workers: process.env.CI ? 1 : undefined, + + // Concise 'dot' for CI, default 'html' when running locally. + // See https://playwright.dev/docs/test-reporters. + reporter: process.env.CI + ? [['html', { open: 'never', outputFolder: `playwright-report-${process.env.HEADLESS ? 'headless' : 'headful'}` }]] + : 'html', + + // Shared settings for all the projects below. + // See https://playwright.dev/docs/api/class-testoptions. + use: { + // We are using locally deployed MetaMask Test Dapp. + baseURL: 'http://localhost:9999', + + // Collect all traces on CI, and only traces for failed tests when running locally. + // See https://playwright.dev/docs/trace-viewer. + trace: process.env.CI ? 'on' : 'retain-on-failure' + }, + + // Configure projects for major browsers. + projects: [ + { + name: 'chromium', + use: { ...devices['Desktop Chrome'] } + } + ] +}) diff --git a/wallets/keplr/tsconfig.build.json b/wallets/keplr/tsconfig.build.json new file mode 100644 index 000000000..9af73f809 --- /dev/null +++ b/wallets/keplr/tsconfig.build.json @@ -0,0 +1,12 @@ +{ + "extends": "@synthetixio/synpress-tsconfig/base.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "types", + "declaration": true, + "sourceMap": true, + "declarationMap": true + }, + "include": ["src"], + "files": ["environment.d.ts"] +} diff --git a/wallets/keplr/tsconfig.json b/wallets/keplr/tsconfig.json new file mode 100644 index 000000000..91c6d73bd --- /dev/null +++ b/wallets/keplr/tsconfig.json @@ -0,0 +1,12 @@ +{ + "type": "commonjs", + "extends": "./tsconfig.build.json", + "compilerOptions": { + "rootDir": ".", + "exactOptionalPropertyTypes": false, // Allows for `undefined` in `playwright.config.ts` + "types": ["cypress"], + "sourceMap": false + }, + "include": ["src", "test"], + "files": ["environment.d.ts", "playwright.config.ts", "vitest.config.ts"] +} diff --git a/wallets/keplr/tsup.config.ts b/wallets/keplr/tsup.config.ts new file mode 100644 index 000000000..98143fe6d --- /dev/null +++ b/wallets/keplr/tsup.config.ts @@ -0,0 +1,12 @@ +import { defineConfig } from 'tsup' + +export default defineConfig({ + name: 'keplr', + entry: ['src/index.ts'], + outDir: 'dist', + format: 'esm', + splitting: false, + treeshake: true, + sourcemap: true, + external: ['@playwright/test'] +}) diff --git a/wallets/keplr/vitetest.config.ts b/wallets/keplr/vitetest.config.ts new file mode 100644 index 000000000..42ec65bf9 --- /dev/null +++ b/wallets/keplr/vitetest.config.ts @@ -0,0 +1,7 @@ +import { defineConfig } from 'vitest/config' + +export default defineConfig({ + test: { + dir: 'test/unit' + } +})