From 28bdebb4f8b15628732d81e2494b25023894f321 Mon Sep 17 00:00:00 2001 From: Aik Date: Mon, 18 Dec 2023 15:59:22 +0700 Subject: [PATCH 01/17] test: add playwright --- .github/workflows/playwright.yml | 27 ++ .gitignore | 4 + e2e/example.spec.ts | 18 ++ package.json | 6 +- playwright.config.ts | 77 +++++ tests-examples/demo-todo-app.spec.ts | 437 +++++++++++++++++++++++++++ yarn.lock | 26 ++ 7 files changed, 593 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/playwright.yml create mode 100644 e2e/example.spec.ts create mode 100644 playwright.config.ts create mode 100644 tests-examples/demo-todo-app.spec.ts diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml new file mode 100644 index 0000000..fc61546 --- /dev/null +++ b/.github/workflows/playwright.yml @@ -0,0 +1,27 @@ +name: Playwright Tests +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] +jobs: + test: + timeout-minutes: 60 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Install dependencies + run: npm install -g yarn && yarn + - name: Install Playwright Browsers + run: yarn playwright install --with-deps + - name: Run Playwright tests + run: yarn playwright test + - uses: actions/upload-artifact@v3 + if: always() + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 diff --git a/.gitignore b/.gitignore index 21d9056..b4108c8 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,7 @@ next-env.d.ts # npm lock package-lock.json _static +/test-results/ +/playwright-report/ +/blob-report/ +/playwright/.cache/ diff --git a/e2e/example.spec.ts b/e2e/example.spec.ts new file mode 100644 index 0000000..54a906a --- /dev/null +++ b/e2e/example.spec.ts @@ -0,0 +1,18 @@ +import { test, expect } from '@playwright/test'; + +test('has title', async ({ page }) => { + await page.goto('https://playwright.dev/'); + + // Expect a title "to contain" a substring. + await expect(page).toHaveTitle(/Playwright/); +}); + +test('get started link', async ({ page }) => { + await page.goto('https://playwright.dev/'); + + // Click the get started link. + await page.getByRole('link', { name: 'Get started' }).click(); + + // Expects page to have a heading with the name of Installation. + await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); +}); diff --git a/package.json b/package.json index fc89bbc..570aa5c 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "dev": "next dev", "build": "next build", "start": "next start -H 0.0.0.0 -p ${PORT:-8080}", - "lint": "next lint" + "lint": "next lint", + "e2e": "playwright test" }, "dependencies": { "@headlessui/react": "^1.7.17", @@ -39,6 +40,7 @@ "yaml": "^2.3.3" }, "devDependencies": { + "@playwright/test": "^1.40.1", "@types/node": "^20", "@types/react": "^18", "@types/react-dom": "^18", @@ -47,4 +49,4 @@ "tailwindcss": "^3", "typescript": "^5" } -} \ No newline at end of file +} diff --git a/playwright.config.ts b/playwright.config.ts new file mode 100644 index 0000000..bfe3e83 --- /dev/null +++ b/playwright.config.ts @@ -0,0 +1,77 @@ +import { defineConfig, devices } from '@playwright/test'; + +/** + * Read environment variables from file. + * https://github.com/motdotla/dotenv + */ +// require('dotenv').config(); + +/** + * See https://playwright.dev/docs/test-configuration. + */ +export default defineConfig({ + testDir: './e2e', + /* Run tests in files in parallel */ + fullyParallel: true, + /* Fail the build on CI if you accidentally left test.only in the source code. */ + forbidOnly: !!process.env.CI, + /* Retry on CI only */ + retries: process.env.CI ? 2 : 0, + /* Opt out of parallel tests on CI. */ + workers: process.env.CI ? 1 : undefined, + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ + reporter: 'html', + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + use: { + /* Base URL to use in actions like `await page.goto('/')`. */ + // baseURL: 'http://127.0.0.1:3000', + + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: 'on-first-retry', + }, + + /* Configure projects for major browsers */ + projects: [ + { + name: 'chromium', + use: { ...devices['Desktop Chrome'] }, + }, + + { + name: 'firefox', + use: { ...devices['Desktop Firefox'] }, + }, + + { + name: 'webkit', + use: { ...devices['Desktop Safari'] }, + }, + + /* Test against mobile viewports. */ + // { + // name: 'Mobile Chrome', + // use: { ...devices['Pixel 5'] }, + // }, + // { + // name: 'Mobile Safari', + // use: { ...devices['iPhone 12'] }, + // }, + + /* Test against branded browsers. */ + // { + // name: 'Microsoft Edge', + // use: { ...devices['Desktop Edge'], channel: 'msedge' }, + // }, + // { + // name: 'Google Chrome', + // use: { ...devices['Desktop Chrome'], channel: 'chrome' }, + // }, + ], + + /* Run your local dev server before starting the tests */ + // webServer: { + // command: 'npm run start', + // url: 'http://127.0.0.1:3000', + // reuseExistingServer: !process.env.CI, + // }, +}); diff --git a/tests-examples/demo-todo-app.spec.ts b/tests-examples/demo-todo-app.spec.ts new file mode 100644 index 0000000..2fd6016 --- /dev/null +++ b/tests-examples/demo-todo-app.spec.ts @@ -0,0 +1,437 @@ +import { test, expect, type Page } from '@playwright/test'; + +test.beforeEach(async ({ page }) => { + await page.goto('https://demo.playwright.dev/todomvc'); +}); + +const TODO_ITEMS = [ + 'buy some cheese', + 'feed the cat', + 'book a doctors appointment' +]; + +test.describe('New Todo', () => { + test('should allow me to add todo items', async ({ page }) => { + // create a new todo locator + const newTodo = page.getByPlaceholder('What needs to be done?'); + + // Create 1st todo. + await newTodo.fill(TODO_ITEMS[0]); + await newTodo.press('Enter'); + + // Make sure the list only has one todo item. + await expect(page.getByTestId('todo-title')).toHaveText([ + TODO_ITEMS[0] + ]); + + // Create 2nd todo. + await newTodo.fill(TODO_ITEMS[1]); + await newTodo.press('Enter'); + + // Make sure the list now has two todo items. + await expect(page.getByTestId('todo-title')).toHaveText([ + TODO_ITEMS[0], + TODO_ITEMS[1] + ]); + + await checkNumberOfTodosInLocalStorage(page, 2); + }); + + test('should clear text input field when an item is added', async ({ page }) => { + // create a new todo locator + const newTodo = page.getByPlaceholder('What needs to be done?'); + + // Create one todo item. + await newTodo.fill(TODO_ITEMS[0]); + await newTodo.press('Enter'); + + // Check that input is empty. + await expect(newTodo).toBeEmpty(); + await checkNumberOfTodosInLocalStorage(page, 1); + }); + + test('should append new items to the bottom of the list', async ({ page }) => { + // Create 3 items. + await createDefaultTodos(page); + + // create a todo count locator + const todoCount = page.getByTestId('todo-count') + + // Check test using different methods. + await expect(page.getByText('3 items left')).toBeVisible(); + await expect(todoCount).toHaveText('3 items left'); + await expect(todoCount).toContainText('3'); + await expect(todoCount).toHaveText(/3/); + + // Check all items in one call. + await expect(page.getByTestId('todo-title')).toHaveText(TODO_ITEMS); + await checkNumberOfTodosInLocalStorage(page, 3); + }); +}); + +test.describe('Mark all as completed', () => { + test.beforeEach(async ({ page }) => { + await createDefaultTodos(page); + await checkNumberOfTodosInLocalStorage(page, 3); + }); + + test.afterEach(async ({ page }) => { + await checkNumberOfTodosInLocalStorage(page, 3); + }); + + test('should allow me to mark all items as completed', async ({ page }) => { + // Complete all todos. + await page.getByLabel('Mark all as complete').check(); + + // Ensure all todos have 'completed' class. + await expect(page.getByTestId('todo-item')).toHaveClass(['completed', 'completed', 'completed']); + await checkNumberOfCompletedTodosInLocalStorage(page, 3); + }); + + test('should allow me to clear the complete state of all items', async ({ page }) => { + const toggleAll = page.getByLabel('Mark all as complete'); + // Check and then immediately uncheck. + await toggleAll.check(); + await toggleAll.uncheck(); + + // Should be no completed classes. + await expect(page.getByTestId('todo-item')).toHaveClass(['', '', '']); + }); + + test('complete all checkbox should update state when items are completed / cleared', async ({ page }) => { + const toggleAll = page.getByLabel('Mark all as complete'); + await toggleAll.check(); + await expect(toggleAll).toBeChecked(); + await checkNumberOfCompletedTodosInLocalStorage(page, 3); + + // Uncheck first todo. + const firstTodo = page.getByTestId('todo-item').nth(0); + await firstTodo.getByRole('checkbox').uncheck(); + + // Reuse toggleAll locator and make sure its not checked. + await expect(toggleAll).not.toBeChecked(); + + await firstTodo.getByRole('checkbox').check(); + await checkNumberOfCompletedTodosInLocalStorage(page, 3); + + // Assert the toggle all is checked again. + await expect(toggleAll).toBeChecked(); + }); +}); + +test.describe('Item', () => { + + test('should allow me to mark items as complete', async ({ page }) => { + // create a new todo locator + const newTodo = page.getByPlaceholder('What needs to be done?'); + + // Create two items. + for (const item of TODO_ITEMS.slice(0, 2)) { + await newTodo.fill(item); + await newTodo.press('Enter'); + } + + // Check first item. + const firstTodo = page.getByTestId('todo-item').nth(0); + await firstTodo.getByRole('checkbox').check(); + await expect(firstTodo).toHaveClass('completed'); + + // Check second item. + const secondTodo = page.getByTestId('todo-item').nth(1); + await expect(secondTodo).not.toHaveClass('completed'); + await secondTodo.getByRole('checkbox').check(); + + // Assert completed class. + await expect(firstTodo).toHaveClass('completed'); + await expect(secondTodo).toHaveClass('completed'); + }); + + test('should allow me to un-mark items as complete', async ({ page }) => { + // create a new todo locator + const newTodo = page.getByPlaceholder('What needs to be done?'); + + // Create two items. + for (const item of TODO_ITEMS.slice(0, 2)) { + await newTodo.fill(item); + await newTodo.press('Enter'); + } + + const firstTodo = page.getByTestId('todo-item').nth(0); + const secondTodo = page.getByTestId('todo-item').nth(1); + const firstTodoCheckbox = firstTodo.getByRole('checkbox'); + + await firstTodoCheckbox.check(); + await expect(firstTodo).toHaveClass('completed'); + await expect(secondTodo).not.toHaveClass('completed'); + await checkNumberOfCompletedTodosInLocalStorage(page, 1); + + await firstTodoCheckbox.uncheck(); + await expect(firstTodo).not.toHaveClass('completed'); + await expect(secondTodo).not.toHaveClass('completed'); + await checkNumberOfCompletedTodosInLocalStorage(page, 0); + }); + + test('should allow me to edit an item', async ({ page }) => { + await createDefaultTodos(page); + + const todoItems = page.getByTestId('todo-item'); + const secondTodo = todoItems.nth(1); + await secondTodo.dblclick(); + await expect(secondTodo.getByRole('textbox', { name: 'Edit' })).toHaveValue(TODO_ITEMS[1]); + await secondTodo.getByRole('textbox', { name: 'Edit' }).fill('buy some sausages'); + await secondTodo.getByRole('textbox', { name: 'Edit' }).press('Enter'); + + // Explicitly assert the new text value. + await expect(todoItems).toHaveText([ + TODO_ITEMS[0], + 'buy some sausages', + TODO_ITEMS[2] + ]); + await checkTodosInLocalStorage(page, 'buy some sausages'); + }); +}); + +test.describe('Editing', () => { + test.beforeEach(async ({ page }) => { + await createDefaultTodos(page); + await checkNumberOfTodosInLocalStorage(page, 3); + }); + + test('should hide other controls when editing', async ({ page }) => { + const todoItem = page.getByTestId('todo-item').nth(1); + await todoItem.dblclick(); + await expect(todoItem.getByRole('checkbox')).not.toBeVisible(); + await expect(todoItem.locator('label', { + hasText: TODO_ITEMS[1], + })).not.toBeVisible(); + await checkNumberOfTodosInLocalStorage(page, 3); + }); + + test('should save edits on blur', async ({ page }) => { + const todoItems = page.getByTestId('todo-item'); + await todoItems.nth(1).dblclick(); + await todoItems.nth(1).getByRole('textbox', { name: 'Edit' }).fill('buy some sausages'); + await todoItems.nth(1).getByRole('textbox', { name: 'Edit' }).dispatchEvent('blur'); + + await expect(todoItems).toHaveText([ + TODO_ITEMS[0], + 'buy some sausages', + TODO_ITEMS[2], + ]); + await checkTodosInLocalStorage(page, 'buy some sausages'); + }); + + test('should trim entered text', async ({ page }) => { + const todoItems = page.getByTestId('todo-item'); + await todoItems.nth(1).dblclick(); + await todoItems.nth(1).getByRole('textbox', { name: 'Edit' }).fill(' buy some sausages '); + await todoItems.nth(1).getByRole('textbox', { name: 'Edit' }).press('Enter'); + + await expect(todoItems).toHaveText([ + TODO_ITEMS[0], + 'buy some sausages', + TODO_ITEMS[2], + ]); + await checkTodosInLocalStorage(page, 'buy some sausages'); + }); + + test('should remove the item if an empty text string was entered', async ({ page }) => { + const todoItems = page.getByTestId('todo-item'); + await todoItems.nth(1).dblclick(); + await todoItems.nth(1).getByRole('textbox', { name: 'Edit' }).fill(''); + await todoItems.nth(1).getByRole('textbox', { name: 'Edit' }).press('Enter'); + + await expect(todoItems).toHaveText([ + TODO_ITEMS[0], + TODO_ITEMS[2], + ]); + }); + + test('should cancel edits on escape', async ({ page }) => { + const todoItems = page.getByTestId('todo-item'); + await todoItems.nth(1).dblclick(); + await todoItems.nth(1).getByRole('textbox', { name: 'Edit' }).fill('buy some sausages'); + await todoItems.nth(1).getByRole('textbox', { name: 'Edit' }).press('Escape'); + await expect(todoItems).toHaveText(TODO_ITEMS); + }); +}); + +test.describe('Counter', () => { + test('should display the current number of todo items', async ({ page }) => { + // create a new todo locator + const newTodo = page.getByPlaceholder('What needs to be done?'); + + // create a todo count locator + const todoCount = page.getByTestId('todo-count') + + await newTodo.fill(TODO_ITEMS[0]); + await newTodo.press('Enter'); + + await expect(todoCount).toContainText('1'); + + await newTodo.fill(TODO_ITEMS[1]); + await newTodo.press('Enter'); + await expect(todoCount).toContainText('2'); + + await checkNumberOfTodosInLocalStorage(page, 2); + }); +}); + +test.describe('Clear completed button', () => { + test.beforeEach(async ({ page }) => { + await createDefaultTodos(page); + }); + + test('should display the correct text', async ({ page }) => { + await page.locator('.todo-list li .toggle').first().check(); + await expect(page.getByRole('button', { name: 'Clear completed' })).toBeVisible(); + }); + + test('should remove completed items when clicked', async ({ page }) => { + const todoItems = page.getByTestId('todo-item'); + await todoItems.nth(1).getByRole('checkbox').check(); + await page.getByRole('button', { name: 'Clear completed' }).click(); + await expect(todoItems).toHaveCount(2); + await expect(todoItems).toHaveText([TODO_ITEMS[0], TODO_ITEMS[2]]); + }); + + test('should be hidden when there are no items that are completed', async ({ page }) => { + await page.locator('.todo-list li .toggle').first().check(); + await page.getByRole('button', { name: 'Clear completed' }).click(); + await expect(page.getByRole('button', { name: 'Clear completed' })).toBeHidden(); + }); +}); + +test.describe('Persistence', () => { + test('should persist its data', async ({ page }) => { + // create a new todo locator + const newTodo = page.getByPlaceholder('What needs to be done?'); + + for (const item of TODO_ITEMS.slice(0, 2)) { + await newTodo.fill(item); + await newTodo.press('Enter'); + } + + const todoItems = page.getByTestId('todo-item'); + const firstTodoCheck = todoItems.nth(0).getByRole('checkbox'); + await firstTodoCheck.check(); + await expect(todoItems).toHaveText([TODO_ITEMS[0], TODO_ITEMS[1]]); + await expect(firstTodoCheck).toBeChecked(); + await expect(todoItems).toHaveClass(['completed', '']); + + // Ensure there is 1 completed item. + await checkNumberOfCompletedTodosInLocalStorage(page, 1); + + // Now reload. + await page.reload(); + await expect(todoItems).toHaveText([TODO_ITEMS[0], TODO_ITEMS[1]]); + await expect(firstTodoCheck).toBeChecked(); + await expect(todoItems).toHaveClass(['completed', '']); + }); +}); + +test.describe('Routing', () => { + test.beforeEach(async ({ page }) => { + await createDefaultTodos(page); + // make sure the app had a chance to save updated todos in storage + // before navigating to a new view, otherwise the items can get lost :( + // in some frameworks like Durandal + await checkTodosInLocalStorage(page, TODO_ITEMS[0]); + }); + + test('should allow me to display active items', async ({ page }) => { + const todoItem = page.getByTestId('todo-item'); + await page.getByTestId('todo-item').nth(1).getByRole('checkbox').check(); + + await checkNumberOfCompletedTodosInLocalStorage(page, 1); + await page.getByRole('link', { name: 'Active' }).click(); + await expect(todoItem).toHaveCount(2); + await expect(todoItem).toHaveText([TODO_ITEMS[0], TODO_ITEMS[2]]); + }); + + test('should respect the back button', async ({ page }) => { + const todoItem = page.getByTestId('todo-item'); + await page.getByTestId('todo-item').nth(1).getByRole('checkbox').check(); + + await checkNumberOfCompletedTodosInLocalStorage(page, 1); + + await test.step('Showing all items', async () => { + await page.getByRole('link', { name: 'All' }).click(); + await expect(todoItem).toHaveCount(3); + }); + + await test.step('Showing active items', async () => { + await page.getByRole('link', { name: 'Active' }).click(); + }); + + await test.step('Showing completed items', async () => { + await page.getByRole('link', { name: 'Completed' }).click(); + }); + + await expect(todoItem).toHaveCount(1); + await page.goBack(); + await expect(todoItem).toHaveCount(2); + await page.goBack(); + await expect(todoItem).toHaveCount(3); + }); + + test('should allow me to display completed items', async ({ page }) => { + await page.getByTestId('todo-item').nth(1).getByRole('checkbox').check(); + await checkNumberOfCompletedTodosInLocalStorage(page, 1); + await page.getByRole('link', { name: 'Completed' }).click(); + await expect(page.getByTestId('todo-item')).toHaveCount(1); + }); + + test('should allow me to display all items', async ({ page }) => { + await page.getByTestId('todo-item').nth(1).getByRole('checkbox').check(); + await checkNumberOfCompletedTodosInLocalStorage(page, 1); + await page.getByRole('link', { name: 'Active' }).click(); + await page.getByRole('link', { name: 'Completed' }).click(); + await page.getByRole('link', { name: 'All' }).click(); + await expect(page.getByTestId('todo-item')).toHaveCount(3); + }); + + test('should highlight the currently applied filter', async ({ page }) => { + await expect(page.getByRole('link', { name: 'All' })).toHaveClass('selected'); + + //create locators for active and completed links + const activeLink = page.getByRole('link', { name: 'Active' }); + const completedLink = page.getByRole('link', { name: 'Completed' }); + await activeLink.click(); + + // Page change - active items. + await expect(activeLink).toHaveClass('selected'); + await completedLink.click(); + + // Page change - completed items. + await expect(completedLink).toHaveClass('selected'); + }); +}); + +async function createDefaultTodos(page: Page) { + // create a new todo locator + const newTodo = page.getByPlaceholder('What needs to be done?'); + + for (const item of TODO_ITEMS) { + await newTodo.fill(item); + await newTodo.press('Enter'); + } +} + +async function checkNumberOfTodosInLocalStorage(page: Page, expected: number) { + return await page.waitForFunction(e => { + return JSON.parse(localStorage['react-todos']).length === e; + }, expected); +} + +async function checkNumberOfCompletedTodosInLocalStorage(page: Page, expected: number) { + return await page.waitForFunction(e => { + return JSON.parse(localStorage['react-todos']).filter((todo: any) => todo.completed).length === e; + }, expected); +} + +async function checkTodosInLocalStorage(page: Page, title: string) { + return await page.waitForFunction(t => { + return JSON.parse(localStorage['react-todos']).map((todo: any) => todo.title).includes(t); + }, title); +} diff --git a/yarn.lock b/yarn.lock index 90f3523..5b7a01b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1688,6 +1688,13 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" +"@playwright/test@^1.40.1": + version "1.40.1" + resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.40.1.tgz#9e66322d97b1d74b9f8718bacab15080f24cde65" + integrity sha512-EaaawMTOeEItCRvfmkI9v6rBkF1svM8wjl/YPRrg2N2Wmp+4qJYkWtJsbew1szfKKDm6fPLy4YAanBhIlf9dWw== + dependencies: + playwright "1.40.1" + "@rainbow-me/rainbowkit@^1.1.3": version "1.1.3" resolved "https://registry.yarnpkg.com/@rainbow-me/rainbowkit/-/rainbowkit-1.1.3.tgz#593d11e7f5bdee5be35b4c8d890eb55884632730" @@ -4596,6 +4603,11 @@ fs.realpath@^1.0.0: resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== +fsevents@2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" + integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== + fsevents@~2.3.2: version "2.3.3" resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" @@ -5754,6 +5766,20 @@ pirates@^4.0.1: resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.6.tgz#3018ae32ecfcff6c29ba2267cbf21166ac1f36b9" integrity sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg== +playwright-core@1.40.1: + version "1.40.1" + resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.40.1.tgz#442d15e86866a87d90d07af528e0afabe4c75c05" + integrity sha512-+hkOycxPiV534c4HhpfX6yrlawqVUzITRKwHAmYfmsVreltEl6fAZJ3DPfLMOODw0H3s1Itd6MDCWmP1fl/QvQ== + +playwright@1.40.1: + version "1.40.1" + resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.40.1.tgz#a11bf8dca15be5a194851dbbf3df235b9f53d7ae" + integrity sha512-2eHI7IioIpQ0bS1Ovg/HszsN/XKNwEG1kbzSDDmADpclKc7CyqkHw7Mg2JCz/bbCxg25QUPcjksoMW7JcIFQmw== + dependencies: + playwright-core "1.40.1" + optionalDependencies: + fsevents "2.3.2" + pngjs@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/pngjs/-/pngjs-5.0.0.tgz#e79dd2b215767fd9c04561c01236df960bce7fbb" From 8b0b9add2e31457cbbc7ee970b5db39b76b8287a Mon Sep 17 00:00:00 2001 From: Aik Date: Mon, 18 Dec 2023 16:04:23 +0700 Subject: [PATCH 02/17] refactor: lib/wagmi --- lib/wagmi.ts | 23 +++++++++++++++++++++++ pages/_app.tsx | 28 +++------------------------- 2 files changed, 26 insertions(+), 25 deletions(-) create mode 100644 lib/wagmi.ts diff --git a/lib/wagmi.ts b/lib/wagmi.ts new file mode 100644 index 0000000..1e7938a --- /dev/null +++ b/lib/wagmi.ts @@ -0,0 +1,23 @@ +import { getDefaultWallets } from "@rainbow-me/rainbowkit"; +import { configureChains, createConfig } from "wagmi"; +import { publicProvider } from "wagmi/providers/public"; +import { PACMON_CHAIN } from "@/config/url"; + +const { chains, publicClient } = configureChains( + [PACMON_CHAIN], + [publicProvider()] +); + +const { connectors } = getDefaultWallets({ + appName: "PACMON RainbowKit", + projectId: "309458b43f1f93c51ffd76536a7ccb74", + chains, +}); + +export const wagmiConfig = createConfig({ + autoConnect: true, + connectors, + publicClient, +}); + +export { chains }; diff --git a/pages/_app.tsx b/pages/_app.tsx index 964570e..0e19605 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -11,34 +11,12 @@ import Layout from "@/components/Layout"; import "@rainbow-me/rainbowkit/styles.css"; -import { - darkTheme, - getDefaultWallets, - RainbowKitProvider, -} from "@rainbow-me/rainbowkit"; -import { configureChains, createConfig, WagmiConfig } from "wagmi"; -import { publicProvider } from "wagmi/providers/public"; -import { PACMON_CHAIN } from "@/config/url"; +import { darkTheme, RainbowKitProvider } from "@rainbow-me/rainbowkit"; +import { WagmiConfig } from "wagmi"; +import { chains, wagmiConfig } from "@/lib/wagmi"; const inter = Roboto_Mono({ subsets: ["latin"] }); -const { chains, publicClient } = configureChains( - [PACMON_CHAIN], - [publicProvider()] -); - -const { connectors } = getDefaultWallets({ - appName: "PACMON RainbowKit", - projectId: "309458b43f1f93c51ffd76536a7ccb74", - chains, -}); - -const wagmiConfig = createConfig({ - autoConnect: true, - connectors, - publicClient, -}); - export default function RootLayout({ Component, pageProps }: AppProps) { return (
From da85be62502161f111fa5336543d6d671195650e Mon Sep 17 00:00:00 2001 From: Aik Date: Mon, 18 Dec 2023 16:34:02 +0700 Subject: [PATCH 03/17] test: add sample demo test --- e2e/demo.spec.ts | 8 ++++++++ package.json | 2 +- playwright.config.ts | 32 ++++++++++++++++---------------- 3 files changed, 25 insertions(+), 17 deletions(-) create mode 100644 e2e/demo.spec.ts diff --git a/e2e/demo.spec.ts b/e2e/demo.spec.ts new file mode 100644 index 0000000..dad3d79 --- /dev/null +++ b/e2e/demo.spec.ts @@ -0,0 +1,8 @@ +import { test, expect } from "@playwright/test"; + +test("has title", async ({ page }) => { + await page.goto("./"); + + // Expect a title "to contain" a substring. + await expect(page).toHaveTitle(/PACMON/); +}); diff --git a/package.json b/package.json index 570aa5c..78666fc 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "build": "next build", "start": "next start -H 0.0.0.0 -p ${PORT:-8080}", "lint": "next lint", - "e2e": "playwright test" + "e2e": "TESTING=true playwright test" }, "dependencies": { "@headlessui/react": "^1.7.17", diff --git a/playwright.config.ts b/playwright.config.ts index bfe3e83..f198564 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -1,4 +1,4 @@ -import { defineConfig, devices } from '@playwright/test'; +import { defineConfig, devices } from "@playwright/test"; /** * Read environment variables from file. @@ -10,7 +10,7 @@ import { defineConfig, devices } from '@playwright/test'; * See https://playwright.dev/docs/test-configuration. */ export default defineConfig({ - testDir: './e2e', + testDir: "./e2e", /* Run tests in files in parallel */ fullyParallel: true, /* Fail the build on CI if you accidentally left test.only in the source code. */ @@ -20,31 +20,31 @@ export default defineConfig({ /* Opt out of parallel tests on CI. */ workers: process.env.CI ? 1 : undefined, /* Reporter to use. See https://playwright.dev/docs/test-reporters */ - reporter: 'html', + reporter: "html", /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { /* Base URL to use in actions like `await page.goto('/')`. */ - // baseURL: 'http://127.0.0.1:3000', + baseURL: "http://127.0.0.1:3000", /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ - trace: 'on-first-retry', + trace: "on-first-retry", }, /* Configure projects for major browsers */ projects: [ { - name: 'chromium', - use: { ...devices['Desktop Chrome'] }, + name: "chromium", + use: { ...devices["Desktop Chrome"] }, }, { - name: 'firefox', - use: { ...devices['Desktop Firefox'] }, + name: "firefox", + use: { ...devices["Desktop Firefox"] }, }, { - name: 'webkit', - use: { ...devices['Desktop Safari'] }, + name: "webkit", + use: { ...devices["Desktop Safari"] }, }, /* Test against mobile viewports. */ @@ -69,9 +69,9 @@ export default defineConfig({ ], /* Run your local dev server before starting the tests */ - // webServer: { - // command: 'npm run start', - // url: 'http://127.0.0.1:3000', - // reuseExistingServer: !process.env.CI, - // }, + webServer: { + command: "npm run dev", + url: "http://127.0.0.1:3000", + reuseExistingServer: !process.env.CI, + }, }); From 328eb6b8a228231a9e35ec117345e523d981cfbb Mon Sep 17 00:00:00 2001 From: Aik Date: Mon, 18 Dec 2023 17:26:33 +0700 Subject: [PATCH 04/17] chore: update config --- config/url.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/config/url.ts b/config/url.ts index 595cd45..8af3c05 100644 --- a/config/url.ts +++ b/config/url.ts @@ -1,7 +1,6 @@ import { Chain } from "@rainbow-me/rainbowkit"; export const BASE_API = "https://o.pacmon.suijin.xyz/api"; - export const PACMON_CHAIN: Chain = { id: 1337, name: "Pacmon", @@ -26,9 +25,8 @@ export const PACMON_CHAIN: Chain = { }; // export const BASE_API = "http://localhost:3033"; - // export const PACMON_CHAIN: Chain = { -// id: 31337, +// id: 1337, // name: "Pacmon", // network: "pacmon", // iconUrl: "https://example.com/icon.svg", @@ -39,12 +37,12 @@ export const PACMON_CHAIN: Chain = { // symbol: "PAC", // }, // rpcUrls: { -// public: { http: ["http://localhost:8545/"] }, -// default: { http: ["http://localhost:8545/"] }, +// public: { http: ["http://localhost:8545"] }, +// default: { http: ["http://localhost:8545"] }, // }, // blockExplorers: { -// default: { name: "PacmonScan", url: "https://etherscan.io" }, -// etherscan: { name: "PacmonScan", url: "https://etherscan.io" }, +// default: { name: "PacmonScan", url: "http://localhost:5100" }, +// etherscan: { name: "PacmonScan", url: "http://localhost:5100" }, // }, // contracts: {}, // testnet: true, From 44c92e898213d6678aee1e74a8377a546d587d2b Mon Sep 17 00:00:00 2001 From: Aik Date: Mon, 18 Dec 2023 17:33:22 +0700 Subject: [PATCH 05/17] test: connect wallet --- e2e/demo.spec.ts | 14 ++- e2e/example.spec.ts | 18 ---- e2e/utils.ts | 80 +++++++++++++++++ lib/wagmi.ts | 13 +-- package.json | 3 +- playwright.config.ts | 18 ++-- yarn.lock | 204 +++++++++++++++++++++++++++++++++++++++++-- 7 files changed, 310 insertions(+), 40 deletions(-) delete mode 100644 e2e/example.spec.ts create mode 100644 e2e/utils.ts diff --git a/e2e/demo.spec.ts b/e2e/demo.spec.ts index dad3d79..dcf8244 100644 --- a/e2e/demo.spec.ts +++ b/e2e/demo.spec.ts @@ -1,8 +1,20 @@ import { test, expect } from "@playwright/test"; test("has title", async ({ page }) => { - await page.goto("./"); + await page.goto("./demo"); // Expect a title "to contain" a substring. await expect(page).toHaveTitle(/PACMON/); }); + +test("can connect wallet", async ({ page }) => { + await page.goto("./demo"); + + await expect(page.getByText("Connect Wallet")).toBeVisible(); + await page.getByText("Connect Wallet").click(); + + await expect(page.getByText("Mock Wallet")).toBeVisible(); + await page.getByText("Mock Wallet").click(); + + await expect(page.getByText("0x67…340e")).toBeVisible(); +}); diff --git a/e2e/example.spec.ts b/e2e/example.spec.ts deleted file mode 100644 index 54a906a..0000000 --- a/e2e/example.spec.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { test, expect } from '@playwright/test'; - -test('has title', async ({ page }) => { - await page.goto('https://playwright.dev/'); - - // Expect a title "to contain" a substring. - await expect(page).toHaveTitle(/Playwright/); -}); - -test('get started link', async ({ page }) => { - await page.goto('https://playwright.dev/'); - - // Click the get started link. - await page.getByRole('link', { name: 'Get started' }).click(); - - // Expects page to have a heading with the name of Installation. - await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); -}); diff --git a/e2e/utils.ts b/e2e/utils.ts new file mode 100644 index 0000000..1315bf2 --- /dev/null +++ b/e2e/utils.ts @@ -0,0 +1,80 @@ +import { PACMON_CHAIN } from "@/config/url"; +import { MockConnector } from "@wagmi/core/connectors/mock"; +import { Chain, createWalletClient, http } from "viem"; +import { configureChains, createConfig } from "wagmi"; + +import { + connectorsForWallets, + type Wallet as RainbowWallet, +} from "@rainbow-me/rainbowkit"; +import { privateKeyToAccount } from "viem/accounts"; +import { publicProvider } from "wagmi/providers/public"; + +const PRIVATE_KEY = + "0x26e86e45f6fc45ec6e2ecd128cec80fa1d1505e5507dcd2ae58c3130a7a97b48"; + +export const CHAIN: Chain = { + id: 1337, + name: "Pacmon", + network: "pacmon", + nativeCurrency: { + decimals: 18, + name: "Pacmon Ether", + symbol: "PAC", + }, + rpcUrls: { + public: { http: ["http://localhost:8545"] }, + default: { http: ["http://localhost:8545"] }, + }, + blockExplorers: { + default: { name: "PacmonScan", url: "http://localhost:5100" }, + etherscan: { name: "PacmonScan", url: "http://localhost:5100" }, + }, + contracts: {}, + testnet: true, +}; + +const { chains, publicClient } = configureChains( + [PACMON_CHAIN], + [publicProvider()] +); + +const mockWallet = (): RainbowWallet => ({ + createConnector: () => ({ + connector: new MockConnector({ + chains, + options: { + walletClient: createWalletClient({ + account: privateKeyToAccount(PRIVATE_KEY), + chain: CHAIN, + transport: http("http://localhost:8545"), + pollingInterval: 100, + }), + flags: { + failConnect: false, + failSwitchChain: false, + isAuthorized: true, + noSwitchChain: false, + }, + }, + }), + }), + id: "mock", + iconBackground: "tomato", + iconUrl: async () => "", + name: "Mock Wallet", +}); + +const connectors = connectorsForWallets([ + { + groupName: "Testing", + wallets: [mockWallet()], + }, +]); + +export function createTestConfig() { + return createConfig({ + connectors, + publicClient, + }); +} diff --git a/lib/wagmi.ts b/lib/wagmi.ts index 1e7938a..c6599bd 100644 --- a/lib/wagmi.ts +++ b/lib/wagmi.ts @@ -2,6 +2,7 @@ import { getDefaultWallets } from "@rainbow-me/rainbowkit"; import { configureChains, createConfig } from "wagmi"; import { publicProvider } from "wagmi/providers/public"; import { PACMON_CHAIN } from "@/config/url"; +import { createTestConfig } from "@/e2e/utils"; const { chains, publicClient } = configureChains( [PACMON_CHAIN], @@ -14,10 +15,12 @@ const { connectors } = getDefaultWallets({ chains, }); -export const wagmiConfig = createConfig({ - autoConnect: true, - connectors, - publicClient, -}); +export const wagmiConfig = process.env.NEXT_PUBLIC_PLAYWRIGHT_TESTING + ? createTestConfig() + : createConfig({ + autoConnect: true, + connectors, + publicClient, + }); export { chains }; diff --git a/package.json b/package.json index 78666fc..e08b677 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "build": "next build", "start": "next start -H 0.0.0.0 -p ${PORT:-8080}", "lint": "next lint", - "e2e": "TESTING=true playwright test" + "e2e": "NEXT_PUBLIC_PLAYWRIGHT_TESTING=true playwright test" }, "dependencies": { "@headlessui/react": "^1.7.17", @@ -41,6 +41,7 @@ }, "devDependencies": { "@playwright/test": "^1.40.1", + "@testing-library/react": "^14.1.2", "@types/node": "^20", "@types/react": "^18", "@types/react-dom": "^18", diff --git a/playwright.config.ts b/playwright.config.ts index f198564..d05a1ac 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -20,7 +20,7 @@ export default defineConfig({ /* Opt out of parallel tests on CI. */ workers: process.env.CI ? 1 : undefined, /* Reporter to use. See https://playwright.dev/docs/test-reporters */ - reporter: "html", + reporter: [["line"], ["html"]], /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { /* Base URL to use in actions like `await page.goto('/')`. */ @@ -37,15 +37,15 @@ export default defineConfig({ use: { ...devices["Desktop Chrome"] }, }, - { - name: "firefox", - use: { ...devices["Desktop Firefox"] }, - }, + // { + // name: "firefox", + // use: { ...devices["Desktop Firefox"] }, + // }, - { - name: "webkit", - use: { ...devices["Desktop Safari"] }, - }, + // { + // name: "webkit", + // use: { ...devices["Desktop Safari"] }, + // }, /* Test against mobile viewports. */ // { diff --git a/yarn.lock b/yarn.lock index 5b7a01b..9e31847 100644 --- a/yarn.lock +++ b/yarn.lock @@ -22,6 +22,28 @@ resolved "https://registry.yarnpkg.com/@alloc/quick-lru/-/quick-lru-5.2.0.tgz#7bf68b20c0a350f936915fcae06f58e32007ce30" integrity sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw== +"@babel/code-frame@^7.10.4": + version "7.23.5" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.23.5.tgz#9009b69a8c602293476ad598ff53e4562e15c244" + integrity sha512-CgH3s1a96LipHCmSUmYFPwY7MNx8C3avkq7i4Wl3cfa662ldtUe4VM1TPXX70pfmrlWTb6jLqTYrZyT2ZTJBgA== + dependencies: + "@babel/highlight" "^7.23.4" + chalk "^2.4.2" + +"@babel/helper-validator-identifier@^7.22.20": + version "7.22.20" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz#c4ae002c61d2879e724581d96665583dbc1dc0e0" + integrity sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A== + +"@babel/highlight@^7.23.4": + version "7.23.4" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.23.4.tgz#edaadf4d8232e1a961432db785091207ead0621b" + integrity sha512-acGdbYSfp2WheJoJm/EBBBLh/ID8KDc64ISZ9DYtBmC8/Q204PZJLHyzeB5qMzJ5trcOkybd78M4x2KWsUq++A== + dependencies: + "@babel/helper-validator-identifier" "^7.22.20" + chalk "^2.4.2" + js-tokens "^4.0.0" + "@babel/runtime@^7.12.5", "@babel/runtime@^7.17.2", "@babel/runtime@^7.18.6", "@babel/runtime@^7.20.13", "@babel/runtime@^7.20.7", "@babel/runtime@^7.21.0", "@babel/runtime@^7.23.2": version "7.23.2" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.23.2.tgz#062b0ac103261d68a966c4c7baf2ae3e62ec3885" @@ -2643,6 +2665,34 @@ "@tanstack/query-core" "4.36.1" use-sync-external-store "^1.2.0" +"@testing-library/dom@^9.0.0": + version "9.3.3" + resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-9.3.3.tgz#108c23a5b0ef51121c26ae92eb3179416b0434f5" + integrity sha512-fB0R+fa3AUqbLHWyxXa2kGVtf1Fe1ZZFr0Zp6AIbIAzXb2mKbEXl+PCQNUOaq5lbTab5tfctfXRNsWXxa2f7Aw== + dependencies: + "@babel/code-frame" "^7.10.4" + "@babel/runtime" "^7.12.5" + "@types/aria-query" "^5.0.1" + aria-query "5.1.3" + chalk "^4.1.0" + dom-accessibility-api "^0.5.9" + lz-string "^1.5.0" + pretty-format "^27.0.2" + +"@testing-library/react@^14.1.2": + version "14.1.2" + resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-14.1.2.tgz#a2b9e9ee87721ec9ed2d7cfc51cc04e474537c32" + integrity sha512-z4p7DVBTPjKM5qDZ0t5ZjzkpSNb+fZy1u6bzO7kk8oeGagpPCAtgh4cx1syrfp7a+QWkM021jGqjJaxJJnXAZg== + dependencies: + "@babel/runtime" "^7.12.5" + "@testing-library/dom" "^9.0.0" + "@types/react-dom" "^18.0.0" + +"@types/aria-query@^5.0.1": + version "5.0.4" + resolved "https://registry.yarnpkg.com/@types/aria-query/-/aria-query-5.0.4.tgz#1a31c3d378850d2778dabb6374d036dcba4ba708" + integrity sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw== + "@types/color-convert@*": version "2.0.2" resolved "https://registry.yarnpkg.com/@types/color-convert/-/color-convert-2.0.2.tgz#a5fa5da9b866732f8bf86b01964869011e2a2356" @@ -2760,6 +2810,13 @@ dependencies: "@types/react" "*" +"@types/react-dom@^18.0.0": + version "18.2.18" + resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-18.2.18.tgz#16946e6cd43971256d874bc3d0a72074bb8571dd" + integrity sha512-TJxDm6OfAX2KJWJdMEVTwWke5Sc/E/RlnPGvGfS0W7+6ocy2xhDVQVh/KvC2Uf7kACs+gDytdusDSdWfWkaNzw== + dependencies: + "@types/react" "*" + "@types/react@*", "@types/react@^18": version "18.2.33" resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.33.tgz#055356243dc4350a9ee6c6a2c07c5cae12e38877" @@ -3397,6 +3454,13 @@ ansi-regex@^5.0.1: resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== +ansi-styles@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" + integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== + dependencies: + color-convert "^1.9.0" + ansi-styles@^4.0.0, ansi-styles@^4.1.0: version "4.3.0" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" @@ -3404,6 +3468,11 @@ ansi-styles@^4.0.0, ansi-styles@^4.1.0: dependencies: color-convert "^2.0.1" +ansi-styles@^5.0.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-5.2.0.tgz#07449690ad45777d1924ac2abb2fc8895dba836b" + integrity sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA== + any-promise@^1.0.0: version "1.3.0" resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f" @@ -3427,6 +3496,13 @@ argparse@^2.0.1: resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== +aria-query@5.1.3: + version "5.1.3" + resolved "https://registry.yarnpkg.com/aria-query/-/aria-query-5.1.3.tgz#19db27cd101152773631396f7a95a3b58c22c35e" + integrity sha512-R5iJ5lkuHybztUfuOAznmboyjWq8O6sqNqtK7CLOqdydi54VNbORp49mb14KbWgG1QD3JFO9hJdZ+y4KutfdOQ== + dependencies: + deep-equal "^2.0.5" + aria-query@^5.1.3: version "5.3.0" resolved "https://registry.yarnpkg.com/aria-query/-/aria-query-5.3.0.tgz#650c569e41ad90b51b3d7df5e5eed1c7549c103e" @@ -3709,7 +3785,16 @@ caniuse-lite@^1.0.30001406, caniuse-lite@^1.0.30001538, caniuse-lite@^1.0.300015 resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001555.tgz#e36f4d49e345337d6788f32093867cec8d951789" integrity sha512-NzbUFKUnJ3DTcq6YyZB6+qqhfD112uR3uoEnkmfzm2wVzUNsFkU7AwBjKQ654Sp5cau0JxhFyRSn/tQZ+XfygA== -chalk@^4.0.0, chalk@^4.1.1: +chalk@^2.4.2: + version "2.4.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" + integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== + dependencies: + ansi-styles "^3.2.1" + escape-string-regexp "^1.0.5" + supports-color "^5.3.0" + +chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.1: version "4.1.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== @@ -3778,6 +3863,13 @@ codemirror@^6.0.0: "@codemirror/state" "^6.0.0" "@codemirror/view" "^6.0.0" +color-convert@^1.9.0: + version "1.9.3" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" + integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== + dependencies: + color-name "1.1.3" + color-convert@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" @@ -3785,6 +3877,11 @@ color-convert@^2.0.1: dependencies: color-name "~1.1.4" +color-name@1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" + integrity sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw== + color-name@^1.0.0, color-name@~1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" @@ -3932,6 +4029,30 @@ decode-uri-component@^0.2.0, decode-uri-component@^0.2.2: resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.2.tgz#e69dbe25d37941171dd540e024c444cd5188e1e9" integrity sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ== +deep-equal@^2.0.5: + version "2.2.3" + resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-2.2.3.tgz#af89dafb23a396c7da3e862abc0be27cf51d56e1" + integrity sha512-ZIwpnevOurS8bpT4192sqAowWM76JDKSHYzMLty3BZGSswgq6pBaH3DhCSW5xVAZICZyKdOBPjwww5wfgT/6PA== + dependencies: + array-buffer-byte-length "^1.0.0" + call-bind "^1.0.5" + es-get-iterator "^1.1.3" + get-intrinsic "^1.2.2" + is-arguments "^1.1.1" + is-array-buffer "^3.0.2" + is-date-object "^1.0.5" + is-regex "^1.1.4" + is-shared-array-buffer "^1.0.2" + isarray "^2.0.5" + object-is "^1.1.5" + object-keys "^1.1.1" + object.assign "^4.1.4" + regexp.prototype.flags "^1.5.1" + side-channel "^1.0.4" + which-boxed-primitive "^1.0.2" + which-collection "^1.0.1" + which-typed-array "^1.1.13" + deep-is@^0.1.3: version "0.1.4" resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.4.tgz#a6f2dce612fadd2ef1f519b73551f17e85199831" @@ -4021,6 +4142,11 @@ doctrine@^3.0.0: dependencies: esutils "^2.0.2" +dom-accessibility-api@^0.5.9: + version "0.5.16" + resolved "https://registry.yarnpkg.com/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz#5a7429e6066eb3664d911e33fb0e45de8eb08453" + integrity sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg== + duplexify@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/duplexify/-/duplexify-4.1.2.tgz#18b4f8d28289132fa0b9573c898d9f903f81c7b0" @@ -4111,6 +4237,21 @@ es-abstract@^1.22.1: unbox-primitive "^1.0.2" which-typed-array "^1.1.13" +es-get-iterator@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/es-get-iterator/-/es-get-iterator-1.1.3.tgz#3ef87523c5d464d41084b2c3c9c214f1199763d6" + integrity sha512-sPZmqHBe6JIiTfN5q2pEi//TwxmAFHwj/XEuYjTuse78i8KxaqMTTzxPoFKuzRpDpTJ+0NAbpfenkmH2rePtuw== + dependencies: + call-bind "^1.0.2" + get-intrinsic "^1.1.3" + has-symbols "^1.0.3" + is-arguments "^1.1.1" + is-map "^2.0.2" + is-set "^2.0.2" + is-string "^1.0.7" + isarray "^2.0.5" + stop-iteration-iterator "^1.0.0" + es-iterator-helpers@^1.0.12: version "1.0.15" resolved "https://registry.yarnpkg.com/es-iterator-helpers/-/es-iterator-helpers-1.0.15.tgz#bd81d275ac766431d19305923707c3efd9f1ae40" @@ -4173,6 +4314,11 @@ escalade@^3.1.1: resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== +escape-string-regexp@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg== + escape-string-regexp@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" @@ -4771,6 +4917,11 @@ has-bigints@^1.0.1, has-bigints@^1.0.2: resolved "https://registry.yarnpkg.com/has-bigints/-/has-bigints-1.0.2.tgz#0871bd3e3d51626f6ca0966668ba35d5602d6eaa" integrity sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ== +has-flag@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" + integrity sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw== + has-flag@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" @@ -4877,7 +5028,7 @@ inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.4: resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== -internal-slot@^1.0.5: +internal-slot@^1.0.4, internal-slot@^1.0.5: version "1.0.6" resolved "https://registry.yarnpkg.com/internal-slot/-/internal-slot-1.0.6.tgz#37e756098c4911c5e912b8edbf71ed3aa116f930" integrity sha512-Xj6dv+PsbtwyPpEflsejS+oIZxmMlV44zAhG479uYu89MsjcYOhCFnNyKrkJrihbsiasQyY0afoCl/9BLR65bg== @@ -4903,7 +5054,7 @@ invariant@^2.2.4: dependencies: loose-envify "^1.0.0" -is-arguments@^1.0.4: +is-arguments@^1.0.4, is-arguments@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/is-arguments/-/is-arguments-1.1.1.tgz#15b3f88fda01f2a97fec84ca761a560f123efa9b" integrity sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA== @@ -5004,7 +5155,7 @@ is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3, is-glob@~4.0.1: dependencies: is-extglob "^2.1.1" -is-map@^2.0.1: +is-map@^2.0.1, is-map@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/is-map/-/is-map-2.0.2.tgz#00922db8c9bf73e81b7a335827bc2a43f2b91127" integrity sha512-cOZFQQozTha1f4MxLFzlgKYPTyj26picdZTx82hbc/Xf4K/tZOOXSCkMvU4pKioRXGDLJRn0GM7Upe7kR721yg== @@ -5039,7 +5190,7 @@ is-regex@^1.1.4: call-bind "^1.0.2" has-tostringtag "^1.0.0" -is-set@^2.0.1: +is-set@^2.0.1, is-set@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/is-set/-/is-set-2.0.2.tgz#90755fa4c2562dc1c5d4024760d6119b94ca18ec" integrity sha512-+2cnTEZeY5z/iXGbLhPrOAaK/Mau5k5eXq9j14CpRTftq0pAJu2MwVRSZhyZWBzx3o6X795Lz6Bpb6R0GKf37g== @@ -5161,7 +5312,7 @@ js-sha3@0.8.0: resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.8.0.tgz#b9b7a5da73afad7dedd0f8c463954cbde6818840" integrity sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q== -"js-tokens@^3.0.0 || ^4.0.0": +"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== @@ -5379,6 +5530,11 @@ lru-cache@^6.0.0: dependencies: yallist "^4.0.0" +lz-string@^1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/lz-string/-/lz-string-1.5.0.tgz#c1ab50f77887b712621201ba9fd4e3a6ed099941" + integrity sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ== + make-plural@*: version "7.3.0" resolved "https://registry.yarnpkg.com/make-plural/-/make-plural-7.3.0.tgz#2889dbafca2fb097037c47967d3e3afa7e48a52c" @@ -5547,6 +5703,14 @@ object-inspect@^1.13.1, object-inspect@^1.9.0: resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.13.1.tgz#b96c6109324ccfef6b12216a956ca4dc2ff94bc2" integrity sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ== +object-is@^1.1.5: + version "1.1.5" + resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.1.5.tgz#b9deeaa5fc7f1846a0faecdceec138e5778f53ac" + integrity sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.3" + object-keys@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" @@ -5853,6 +6017,15 @@ prettier@^2.8.8: resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== +pretty-format@^27.0.2: + version "27.5.1" + resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-27.5.1.tgz#2181879fdea51a7a5851fb39d920faa63f01d88e" + integrity sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ== + dependencies: + ansi-regex "^5.0.1" + ansi-styles "^5.0.0" + react-is "^17.0.1" + process-warning@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/process-warning/-/process-warning-1.0.0.tgz#980a0b25dc38cd6034181be4b7726d89066b4616" @@ -5959,6 +6132,11 @@ react-is@^16.13.1: resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== +react-is@^17.0.1: + version "17.0.2" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" + integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w== + react-jazzicon@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/react-jazzicon/-/react-jazzicon-1.0.4.tgz#31e5f6908e042786ba93a9093b852dea1870e7a0" @@ -6329,6 +6507,13 @@ split2@^4.0.0: resolved "https://registry.yarnpkg.com/split2/-/split2-4.2.0.tgz#c9c5920904d148bab0b9f67145f245a86aadbfa4" integrity sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg== +stop-iteration-iterator@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/stop-iteration-iterator/-/stop-iteration-iterator-1.0.0.tgz#6a60be0b4ee757d1ed5254858ec66b10c49285e4" + integrity sha512-iCGQj+0l0HOdZ2AEeBADlsRC+vsnDsZsbdSiH1yNSjcfKM7fdpCMfqAL/dwF5BLiw/XhRft/Wax6zQbhq2BcjQ== + dependencies: + internal-slot "^1.0.4" + stream-browserify@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/stream-browserify/-/stream-browserify-3.0.0.tgz#22b0a2850cdf6503e73085da1fc7b7d0c2122f2f" @@ -6462,6 +6647,13 @@ superstruct@^1.0.3: resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-1.0.3.tgz#de626a5b49c6641ff4d37da3c7598e7a87697046" integrity sha512-8iTn3oSS8nRGn+C2pgXSKPI3jmpm6FExNazNpjvqS6ZUJQCej3PUXEKM8NjHBOs54ExM+LPW/FBRhymrdcCiSg== +supports-color@^5.3.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" + integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== + dependencies: + has-flag "^3.0.0" + supports-color@^7.1.0: version "7.2.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" From f2038b45b80862bd0fb00fd47723c72324b7cd6b Mon Sep 17 00:00:00 2001 From: Aik Date: Wed, 20 Dec 2023 19:03:10 +0700 Subject: [PATCH 06/17] test(e2e): config --- components/demo/DemoApp.tsx | 4 +- config/url.ts | 58 +- e2e/abi/PacDemo.json | 456 +++++++++++ e2e/abi/PacERC20.json | 412 ++++++++++ e2e/abi/PacPriceFeed.json | 237 ++++++ e2e/abi/PacUniswapV2Pair.json | 682 ++++++++++++++++ e2e/demo.spec.ts | 48 ++ e2e/pacmonsdk.ts | 133 ++++ e2e/typechain/PacDemo.ts | 448 +++++++++++ e2e/typechain/PacERC20.ts | 377 +++++++++ e2e/typechain/PacPriceFeed.ts | 238 ++++++ e2e/typechain/PacUniswapV2Pair.ts | 750 ++++++++++++++++++ e2e/typechain/common.ts | 131 +++ e2e/typechain/factories/PacDemo__factory.ts | 473 +++++++++++ e2e/typechain/factories/PacERC20__factory.ts | 429 ++++++++++ .../factories/PacPriceFeed__factory.ts | 257 ++++++ .../factories/PacUniswapV2Pair__factory.ts | 705 ++++++++++++++++ e2e/typechain/factories/index.ts | 7 + e2e/typechain/index.ts | 12 + package.json | 6 + playwright.config.ts | 2 + yarn.lock | 234 +++++- 22 files changed, 6061 insertions(+), 38 deletions(-) create mode 100644 e2e/abi/PacDemo.json create mode 100644 e2e/abi/PacERC20.json create mode 100644 e2e/abi/PacPriceFeed.json create mode 100644 e2e/abi/PacUniswapV2Pair.json create mode 100644 e2e/pacmonsdk.ts create mode 100644 e2e/typechain/PacDemo.ts create mode 100644 e2e/typechain/PacERC20.ts create mode 100644 e2e/typechain/PacPriceFeed.ts create mode 100644 e2e/typechain/PacUniswapV2Pair.ts create mode 100644 e2e/typechain/common.ts create mode 100644 e2e/typechain/factories/PacDemo__factory.ts create mode 100644 e2e/typechain/factories/PacERC20__factory.ts create mode 100644 e2e/typechain/factories/PacPriceFeed__factory.ts create mode 100644 e2e/typechain/factories/PacUniswapV2Pair__factory.ts create mode 100644 e2e/typechain/factories/index.ts create mode 100644 e2e/typechain/index.ts diff --git a/components/demo/DemoApp.tsx b/components/demo/DemoApp.tsx index 7fe2335..c6a77bc 100644 --- a/components/demo/DemoApp.tsx +++ b/components/demo/DemoApp.tsx @@ -421,9 +421,7 @@ const DemoInteraction = (props: DemoInteractionProps) => { export default function DemoApp() { const [contractAddressTouched, setContractAddressTouched] = useState(false); - const [contractAddress, setContractAddress] = useState( - "0xa5dDBd1D4e7A680eB09dCd28bb21C86f910540B9" - ); + const [contractAddress, setContractAddress] = useState(""); const account = useAccount(); const blockNumber = useBlockNumber(); diff --git a/config/url.ts b/config/url.ts index 8af3c05..723fa50 100644 --- a/config/url.ts +++ b/config/url.ts @@ -1,30 +1,6 @@ import { Chain } from "@rainbow-me/rainbowkit"; -export const BASE_API = "https://o.pacmon.suijin.xyz/api"; -export const PACMON_CHAIN: Chain = { - id: 1337, - name: "Pacmon", - network: "pacmon", - iconUrl: "https://example.com/icon.svg", - iconBackground: "#fff", - nativeCurrency: { - decimals: 18, - name: "Pacmon Ether", - symbol: "PAC", - }, - rpcUrls: { - public: { http: ["https://o.pacmon.suijin.xyz/rpc/"] }, - default: { http: ["https://o.pacmon.suijin.xyz/rpc/"] }, - }, - blockExplorers: { - default: { name: "PacmonScan", url: "https://etherscan.io" }, - etherscan: { name: "PacmonScan", url: "https://etherscan.io" }, - }, - contracts: {}, - testnet: true, -}; - -// export const BASE_API = "http://localhost:3033"; +// export const BASE_API = "https://o.pacmon.suijin.xyz/api"; // export const PACMON_CHAIN: Chain = { // id: 1337, // name: "Pacmon", @@ -37,13 +13,37 @@ export const PACMON_CHAIN: Chain = { // symbol: "PAC", // }, // rpcUrls: { -// public: { http: ["http://localhost:8545"] }, -// default: { http: ["http://localhost:8545"] }, +// public: { http: ["https://o.pacmon.suijin.xyz/rpc/"] }, +// default: { http: ["https://o.pacmon.suijin.xyz/rpc/"] }, // }, // blockExplorers: { -// default: { name: "PacmonScan", url: "http://localhost:5100" }, -// etherscan: { name: "PacmonScan", url: "http://localhost:5100" }, +// default: { name: "PacmonScan", url: "https://etherscan.io" }, +// etherscan: { name: "PacmonScan", url: "https://etherscan.io" }, // }, // contracts: {}, // testnet: true, // }; + +export const BASE_API = "http://localhost:3033"; +export const PACMON_CHAIN: Chain = { + id: 1337, + name: "Pacmon", + network: "pacmon", + iconUrl: "https://example.com/icon.svg", + iconBackground: "#fff", + nativeCurrency: { + decimals: 18, + name: "Pacmon Ether", + symbol: "PAC", + }, + rpcUrls: { + public: { http: ["http://localhost:8545"] }, + default: { http: ["http://localhost:8545"] }, + }, + blockExplorers: { + default: { name: "PacmonScan", url: "http://localhost:5100" }, + etherscan: { name: "PacmonScan", url: "http://localhost:5100" }, + }, + contracts: {}, + testnet: true, +}; diff --git a/e2e/abi/PacDemo.json b/e2e/abi/PacDemo.json new file mode 100644 index 0000000..a25d80b --- /dev/null +++ b/e2e/abi/PacDemo.json @@ -0,0 +1,456 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "_token0", + "type": "address" + }, + { + "internalType": "address", + "name": "_token1", + "type": "address" + }, + { + "internalType": "address", + "name": "_pair", + "type": "address" + }, + { + "internalType": "address", + "name": "_pricefeed0", + "type": "address" + }, + { + "internalType": "address", + "name": "_pricefeed1", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "PRICE_PRECISION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "fromToken", + "type": "address" + }, + { + "internalType": "address", + "name": "toToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "_swap", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "balance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "balances0", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "balances1", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "deposit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "depositEnabled", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAMMPrices", + "outputs": [ + { + "internalType": "uint256", + "name": "ammPrice0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "ammPrice1", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPrice0", + "outputs": [ + { + "internalType": "uint256", + "name": "price", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPrice1", + "outputs": [ + { + "internalType": "uint256", + "name": "price", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPrices", + "outputs": [ + { + "internalType": "uint256", + "name": "price0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "price1", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getReserves", + "outputs": [ + { + "internalType": "uint256", + "name": "reserve0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserve1", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getValue0", + "outputs": [ + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getValue1", + "outputs": [ + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getValues", + "outputs": [ + { + "internalType": "uint256", + "name": "value0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "value1", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "gov", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pair", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pricefeed0", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pricefeed1", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "_depositEnabled", + "type": "bool" + } + ], + "name": "setDepositEnabled", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "_withdrawEnabled", + "type": "bool" + } + ], + "name": "setWithdrawEnabled", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "fromToken", + "type": "address" + }, + { + "internalType": "address", + "name": "toToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "swap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "token0", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "token1", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "withdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawEnabled", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/e2e/abi/PacERC20.json b/e2e/abi/PacERC20.json new file mode 100644 index 0000000..aca8c12 --- /dev/null +++ b/e2e/abi/PacERC20.json @@ -0,0 +1,412 @@ +[ + { + "inputs": [ + { + "internalType": "string", + "name": "_name", + "type": "string" + }, + { + "internalType": "string", + "name": "_symbol", + "type": "string" + }, + { + "internalType": "uint8", + "name": "_decimals", + "type": "uint8" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "allowance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "needed", + "type": "uint256" + } + ], + "name": "ERC20InsufficientAllowance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "needed", + "type": "uint256" + } + ], + "name": "ERC20InsufficientBalance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "approver", + "type": "address" + } + ], + "name": "ERC20InvalidApprover", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "ERC20InvalidReceiver", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "ERC20InvalidSender", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "ERC20InvalidSpender", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Burn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/e2e/abi/PacPriceFeed.json b/e2e/abi/PacPriceFeed.json new file mode 100644 index 0000000..9baa2f3 --- /dev/null +++ b/e2e/abi/PacPriceFeed.json @@ -0,0 +1,237 @@ +[ + { + "inputs": [ + { + "internalType": "string", + "name": "_description", + "type": "string" + }, + { + "internalType": "uint8", + "name": "_decimals", + "type": "uint8" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "answer", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint80", + "name": "", + "type": "uint80" + } + ], + "name": "answers", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "description", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint80", + "name": "_roundId", + "type": "uint80" + } + ], + "name": "getRoundData", + "outputs": [ + { + "internalType": "uint80", + "name": "", + "type": "uint80" + }, + { + "internalType": "int256", + "name": "", + "type": "int256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint80", + "name": "", + "type": "uint80" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "gov", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "isAdmin", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "latestRoundData", + "outputs": [ + { + "internalType": "uint80", + "name": "", + "type": "uint80" + }, + { + "internalType": "int256", + "name": "", + "type": "int256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint80", + "name": "", + "type": "uint80" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "roundId", + "outputs": [ + { + "internalType": "uint80", + "name": "", + "type": "uint80" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "bool", + "name": "_isAdmin", + "type": "bool" + } + ], + "name": "setAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "_answer", + "type": "int256" + } + ], + "name": "setLatestAnswer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "version", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/e2e/abi/PacUniswapV2Pair.json b/e2e/abi/PacUniswapV2Pair.json new file mode 100644 index 0000000..22bb0cc --- /dev/null +++ b/e2e/abi/PacUniswapV2Pair.json @@ -0,0 +1,682 @@ +[ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "Burn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0In", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1In", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0Out", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1Out", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "Swap", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint112", + "name": "reserve0", + "type": "uint112" + }, + { + "indexed": false, + "internalType": "uint112", + "name": "reserve1", + "type": "uint112" + } + ], + "name": "Sync", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MINIMUM_LIQUIDITY", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PERMIT_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "burn", + "outputs": [ + { + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getReserves", + "outputs": [ + { + "internalType": "uint112", + "name": "_reserve0", + "type": "uint112" + }, + { + "internalType": "uint112", + "name": "_reserve1", + "type": "uint112" + }, + { + "internalType": "uint32", + "name": "_blockTimestampLast", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_token0", + "type": "address" + }, + { + "internalType": "address", + "name": "_token1", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "kLast", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "uint256", + "name": "liquidity", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "nonces", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "permit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "price0CumulativeLast", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "price1CumulativeLast", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "name": "setTokenAmounts", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "skim", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount0Out", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1Out", + "type": "uint256" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "swap", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "sync", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "token0", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "token1", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/e2e/demo.spec.ts b/e2e/demo.spec.ts index dcf8244..c23413a 100644 --- a/e2e/demo.spec.ts +++ b/e2e/demo.spec.ts @@ -1,4 +1,5 @@ import { test, expect } from "@playwright/test"; +import { PacmonDemoSDK } from "./pacmonsdk"; test("has title", async ({ page }) => { await page.goto("./demo"); @@ -17,4 +18,51 @@ test("can connect wallet", async ({ page }) => { await page.getByText("Mock Wallet").click(); await expect(page.getByText("0x67…340e")).toBeVisible(); + + await expect(page.getByText("Balance Pool")).toBeHidden(); +}); + +test.describe("demo", () => { + let pacmon: PacmonDemoSDK; + + test.beforeAll(async () => { + pacmon = new PacmonDemoSDK(24, "http://localhost:3033"); + await pacmon.init(94); + }); + + test.beforeEach(async ({ page }) => { + await page.goto("./demo"); + await page.getByText("Connect Wallet").click(); + await page.getByText("Mock Wallet").click(); + }); + + test("can input contract address", async ({ page }) => { + await expect(page.getByText("Balance Pool")).toBeHidden(); + await page + .getByLabel("PacDemo Contact Address") + .fill(pacmon.contracts.demo); + await expect(page.getByText("Balance Pool")).toBeVisible(); + }); + + test.describe("config", () => { + test.beforeEach(async ({ page }) => { + await pacmon.disableDeposit(); + await pacmon.disableWithdraw(); + await page + .getByLabel("PacDemo Contact Address") + .fill(pacmon.contracts.demo); + }); + + test("deposit enabled", async ({ page }) => { + await expect(page.getByText("Deposit Disabled")).toBeVisible(); + await pacmon.enableDeposit(); + await expect(page.getByText("Deposit Enabled")).toBeVisible(); + }); + + test("withdraw enabled", async ({ page }) => { + await expect(page.getByText("Withdraw Disabled")).toBeVisible(); + await pacmon.enableWithdraw(); + await expect(page.getByText("Withdraw Enabled")).toBeVisible(); + }); + }); }); diff --git a/e2e/pacmonsdk.ts b/e2e/pacmonsdk.ts new file mode 100644 index 0000000..863ae6e --- /dev/null +++ b/e2e/pacmonsdk.ts @@ -0,0 +1,133 @@ +import _ from "lodash"; +import { PacDemo__factory } from "./typechain"; +import { PacDemoInterface } from "./typechain/PacDemo"; +import axios, { Axios } from "axios"; + +interface Contracts { + demo: string; + pool: string; + pricefeed1: string; + pricefeed2: string; + token1: string; + token2: string; +} + +interface Interfaces { + demo: PacDemoInterface; +} + +interface NodeInfoResp { + contracts: { sequence: number; name: string; address: string }[]; + signers: { address: string }[]; +} + +export class PacmonSDK { + projectId: number; + nodeId?: number; + axiosClient: Axios; + + constructor(projectId: number, api: string) { + this.projectId = projectId; + this.axiosClient = axios.create({ + baseURL: api, + timeout: 300000, + }); + } + + async createNode() { + const resp = await this.axiosClient.post(`projects/deploy`, { + projectId: this.projectId, + nodeName: "Test Node", + }); + return resp.data.id; + } + + async deleteNode() { + const resp = await this.axiosClient.post(`nodes/delete`, { + nodeId: this.nodeId, + }); + } + + async getNodeInfo() { + const resp = await this.axiosClient.get( + `nodes/${this.nodeId}` + ); + return resp.data; + } + + async call(contractAddress: string, data: string, callerAddress: string) { + const resp = await this.axiosClient.post(`/nodes/call`, { + nodeId: this.nodeId, + contractAddress, + encodedData: data, + callerAddress, + }); + } +} + +export class PacmonDemoSDK extends PacmonSDK { + contracts: Contracts; + interfaces: Interfaces; + signerAddress: string; + + constructor(projectId: number, api: string) { + super(projectId, api); + this.contracts = { + demo: "", + pool: "", + pricefeed1: "", + pricefeed2: "", + token1: "", + token2: "", + }; + this.interfaces = { + demo: PacDemo__factory.createInterface(), + }; + this.signerAddress = ""; + } + + async init(nodeId?: number) { + this.nodeId = nodeId || (await this.createNode()); + const { contracts, signers } = await this.getNodeInfo(); + const sortedContracts = _.sortBy(contracts, "sequence"); + this.contracts = { + token1: sortedContracts[0].address, + token2: sortedContracts[1].address, + pool: sortedContracts[2].address, + pricefeed1: sortedContracts[3].address, + pricefeed2: sortedContracts[4].address, + demo: sortedContracts[5].address, + }; + this.signerAddress = signers[0].address; + } + + async enableDeposit() { + const data = this.interfaces.demo.encodeFunctionData("setDepositEnabled", [ + true, + ]); + await this.call(this.contracts.demo, data, this.signerAddress); + } + + async disableDeposit() { + const data = this.interfaces.demo.encodeFunctionData("setDepositEnabled", [ + false, + ]); + await this.call(this.contracts.demo, data, this.signerAddress); + } + + async enableWithdraw() { + const data = this.interfaces.demo.encodeFunctionData("setWithdrawEnabled", [ + true, + ]); + await this.call(this.contracts.demo, data, this.signerAddress); + } + + async disableWithdraw() { + const data = this.interfaces.demo.encodeFunctionData("setWithdrawEnabled", [ + false, + ]); + await this.call(this.contracts.demo, data, this.signerAddress); + } + + async setPrice1(price: number) {} +} diff --git a/e2e/typechain/PacDemo.ts b/e2e/typechain/PacDemo.ts new file mode 100644 index 0000000..f5dec83 --- /dev/null +++ b/e2e/typechain/PacDemo.ts @@ -0,0 +1,448 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumberish, + BytesLike, + FunctionFragment, + Result, + Interface, + AddressLike, + ContractRunner, + ContractMethod, + Listener, +} from "ethers"; +import type { + TypedContractEvent, + TypedDeferredTopicFilter, + TypedEventLog, + TypedListener, + TypedContractMethod, +} from "./common"; + +export interface PacDemoInterface extends Interface { + getFunction( + nameOrSignature: + | "PRICE_PRECISION" + | "_swap" + | "balance" + | "balances0" + | "balances1" + | "deposit" + | "depositEnabled" + | "getAMMPrices" + | "getPrice0" + | "getPrice1" + | "getPrices" + | "getReserves" + | "getValue0" + | "getValue1" + | "getValues" + | "gov" + | "pair" + | "pricefeed0" + | "pricefeed1" + | "setDepositEnabled" + | "setWithdrawEnabled" + | "swap" + | "token0" + | "token1" + | "withdraw" + | "withdrawEnabled" + ): FunctionFragment; + + encodeFunctionData( + functionFragment: "PRICE_PRECISION", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "_swap", + values: [AddressLike, AddressLike, BigNumberish] + ): string; + encodeFunctionData(functionFragment: "balance", values?: undefined): string; + encodeFunctionData( + functionFragment: "balances0", + values: [AddressLike] + ): string; + encodeFunctionData( + functionFragment: "balances1", + values: [AddressLike] + ): string; + encodeFunctionData( + functionFragment: "deposit", + values: [AddressLike, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "depositEnabled", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getAMMPrices", + values?: undefined + ): string; + encodeFunctionData(functionFragment: "getPrice0", values?: undefined): string; + encodeFunctionData(functionFragment: "getPrice1", values?: undefined): string; + encodeFunctionData(functionFragment: "getPrices", values?: undefined): string; + encodeFunctionData( + functionFragment: "getReserves", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getValue0", + values: [AddressLike] + ): string; + encodeFunctionData( + functionFragment: "getValue1", + values: [AddressLike] + ): string; + encodeFunctionData( + functionFragment: "getValues", + values: [AddressLike] + ): string; + encodeFunctionData(functionFragment: "gov", values?: undefined): string; + encodeFunctionData(functionFragment: "pair", values?: undefined): string; + encodeFunctionData( + functionFragment: "pricefeed0", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "pricefeed1", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "setDepositEnabled", + values: [boolean] + ): string; + encodeFunctionData( + functionFragment: "setWithdrawEnabled", + values: [boolean] + ): string; + encodeFunctionData( + functionFragment: "swap", + values: [AddressLike, AddressLike, BigNumberish] + ): string; + encodeFunctionData(functionFragment: "token0", values?: undefined): string; + encodeFunctionData(functionFragment: "token1", values?: undefined): string; + encodeFunctionData( + functionFragment: "withdraw", + values: [AddressLike, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "withdrawEnabled", + values?: undefined + ): string; + + decodeFunctionResult( + functionFragment: "PRICE_PRECISION", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "_swap", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "balance", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "balances0", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "balances1", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "deposit", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "depositEnabled", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getAMMPrices", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "getPrice0", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "getPrice1", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "getPrices", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "getReserves", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "getValue0", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "getValue1", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "getValues", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "gov", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "pair", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "pricefeed0", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "pricefeed1", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "setDepositEnabled", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "setWithdrawEnabled", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "swap", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "token0", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "token1", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "withdraw", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "withdrawEnabled", + data: BytesLike + ): Result; +} + +export interface PacDemo extends BaseContract { + connect(runner?: ContractRunner | null): PacDemo; + waitForDeployment(): Promise; + + interface: PacDemoInterface; + + queryFilter( + event: TCEvent, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + queryFilter( + filter: TypedDeferredTopicFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + + on( + event: TCEvent, + listener: TypedListener + ): Promise; + on( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + once( + event: TCEvent, + listener: TypedListener + ): Promise; + once( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + listeners( + event: TCEvent + ): Promise>>; + listeners(eventName?: string): Promise>; + removeAllListeners( + event?: TCEvent + ): Promise; + + PRICE_PRECISION: TypedContractMethod<[], [bigint], "view">; + + _swap: TypedContractMethod< + [fromToken: AddressLike, toToken: AddressLike, amount: BigNumberish], + [void], + "nonpayable" + >; + + balance: TypedContractMethod<[], [void], "nonpayable">; + + balances0: TypedContractMethod<[arg0: AddressLike], [bigint], "view">; + + balances1: TypedContractMethod<[arg0: AddressLike], [bigint], "view">; + + deposit: TypedContractMethod< + [token: AddressLike, amount: BigNumberish], + [void], + "nonpayable" + >; + + depositEnabled: TypedContractMethod<[], [boolean], "view">; + + getAMMPrices: TypedContractMethod< + [], + [[bigint, bigint] & { ammPrice0: bigint; ammPrice1: bigint }], + "view" + >; + + getPrice0: TypedContractMethod<[], [bigint], "view">; + + getPrice1: TypedContractMethod<[], [bigint], "view">; + + getPrices: TypedContractMethod< + [], + [[bigint, bigint] & { price0: bigint; price1: bigint }], + "view" + >; + + getReserves: TypedContractMethod< + [], + [[bigint, bigint] & { reserve0: bigint; reserve1: bigint }], + "view" + >; + + getValue0: TypedContractMethod<[account: AddressLike], [bigint], "view">; + + getValue1: TypedContractMethod<[account: AddressLike], [bigint], "view">; + + getValues: TypedContractMethod< + [account: AddressLike], + [ + [bigint, bigint, bigint] & { + value0: bigint; + value1: bigint; + value: bigint; + } + ], + "view" + >; + + gov: TypedContractMethod<[], [string], "view">; + + pair: TypedContractMethod<[], [string], "view">; + + pricefeed0: TypedContractMethod<[], [string], "view">; + + pricefeed1: TypedContractMethod<[], [string], "view">; + + setDepositEnabled: TypedContractMethod< + [_depositEnabled: boolean], + [void], + "nonpayable" + >; + + setWithdrawEnabled: TypedContractMethod< + [_withdrawEnabled: boolean], + [void], + "nonpayable" + >; + + swap: TypedContractMethod< + [fromToken: AddressLike, toToken: AddressLike, amount: BigNumberish], + [bigint], + "nonpayable" + >; + + token0: TypedContractMethod<[], [string], "view">; + + token1: TypedContractMethod<[], [string], "view">; + + withdraw: TypedContractMethod< + [token: AddressLike, amount: BigNumberish], + [void], + "nonpayable" + >; + + withdrawEnabled: TypedContractMethod<[], [boolean], "view">; + + getFunction( + key: string | FunctionFragment + ): T; + + getFunction( + nameOrSignature: "PRICE_PRECISION" + ): TypedContractMethod<[], [bigint], "view">; + getFunction( + nameOrSignature: "_swap" + ): TypedContractMethod< + [fromToken: AddressLike, toToken: AddressLike, amount: BigNumberish], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "balance" + ): TypedContractMethod<[], [void], "nonpayable">; + getFunction( + nameOrSignature: "balances0" + ): TypedContractMethod<[arg0: AddressLike], [bigint], "view">; + getFunction( + nameOrSignature: "balances1" + ): TypedContractMethod<[arg0: AddressLike], [bigint], "view">; + getFunction( + nameOrSignature: "deposit" + ): TypedContractMethod< + [token: AddressLike, amount: BigNumberish], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "depositEnabled" + ): TypedContractMethod<[], [boolean], "view">; + getFunction( + nameOrSignature: "getAMMPrices" + ): TypedContractMethod< + [], + [[bigint, bigint] & { ammPrice0: bigint; ammPrice1: bigint }], + "view" + >; + getFunction( + nameOrSignature: "getPrice0" + ): TypedContractMethod<[], [bigint], "view">; + getFunction( + nameOrSignature: "getPrice1" + ): TypedContractMethod<[], [bigint], "view">; + getFunction( + nameOrSignature: "getPrices" + ): TypedContractMethod< + [], + [[bigint, bigint] & { price0: bigint; price1: bigint }], + "view" + >; + getFunction( + nameOrSignature: "getReserves" + ): TypedContractMethod< + [], + [[bigint, bigint] & { reserve0: bigint; reserve1: bigint }], + "view" + >; + getFunction( + nameOrSignature: "getValue0" + ): TypedContractMethod<[account: AddressLike], [bigint], "view">; + getFunction( + nameOrSignature: "getValue1" + ): TypedContractMethod<[account: AddressLike], [bigint], "view">; + getFunction( + nameOrSignature: "getValues" + ): TypedContractMethod< + [account: AddressLike], + [ + [bigint, bigint, bigint] & { + value0: bigint; + value1: bigint; + value: bigint; + } + ], + "view" + >; + getFunction( + nameOrSignature: "gov" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "pair" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "pricefeed0" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "pricefeed1" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "setDepositEnabled" + ): TypedContractMethod<[_depositEnabled: boolean], [void], "nonpayable">; + getFunction( + nameOrSignature: "setWithdrawEnabled" + ): TypedContractMethod<[_withdrawEnabled: boolean], [void], "nonpayable">; + getFunction( + nameOrSignature: "swap" + ): TypedContractMethod< + [fromToken: AddressLike, toToken: AddressLike, amount: BigNumberish], + [bigint], + "nonpayable" + >; + getFunction( + nameOrSignature: "token0" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "token1" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "withdraw" + ): TypedContractMethod< + [token: AddressLike, amount: BigNumberish], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "withdrawEnabled" + ): TypedContractMethod<[], [boolean], "view">; + + filters: {}; +} diff --git a/e2e/typechain/PacERC20.ts b/e2e/typechain/PacERC20.ts new file mode 100644 index 0000000..8e5a7bd --- /dev/null +++ b/e2e/typechain/PacERC20.ts @@ -0,0 +1,377 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumberish, + BytesLike, + FunctionFragment, + Result, + Interface, + EventFragment, + AddressLike, + ContractRunner, + ContractMethod, + Listener, +} from "ethers"; +import type { + TypedContractEvent, + TypedDeferredTopicFilter, + TypedEventLog, + TypedLogDescription, + TypedListener, + TypedContractMethod, +} from "./common"; + +export interface PacERC20Interface extends Interface { + getFunction( + nameOrSignature: + | "allowance" + | "approve" + | "balanceOf" + | "burn" + | "decimals" + | "mint" + | "name" + | "symbol" + | "totalSupply" + | "transfer" + | "transferFrom" + ): FunctionFragment; + + getEvent( + nameOrSignatureOrTopic: "Approval" | "Burn" | "Mint" | "Transfer" + ): EventFragment; + + encodeFunctionData( + functionFragment: "allowance", + values: [AddressLike, AddressLike] + ): string; + encodeFunctionData( + functionFragment: "approve", + values: [AddressLike, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "balanceOf", + values: [AddressLike] + ): string; + encodeFunctionData(functionFragment: "burn", values: [BigNumberish]): string; + encodeFunctionData(functionFragment: "decimals", values?: undefined): string; + encodeFunctionData( + functionFragment: "mint", + values: [AddressLike, BigNumberish] + ): string; + encodeFunctionData(functionFragment: "name", values?: undefined): string; + encodeFunctionData(functionFragment: "symbol", values?: undefined): string; + encodeFunctionData( + functionFragment: "totalSupply", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "transfer", + values: [AddressLike, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "transferFrom", + values: [AddressLike, AddressLike, BigNumberish] + ): string; + + decodeFunctionResult(functionFragment: "allowance", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "approve", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "balanceOf", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "burn", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "decimals", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "mint", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "name", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "symbol", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "totalSupply", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "transfer", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "transferFrom", + data: BytesLike + ): Result; +} + +export namespace ApprovalEvent { + export type InputTuple = [ + owner: AddressLike, + spender: AddressLike, + value: BigNumberish + ]; + export type OutputTuple = [owner: string, spender: string, value: bigint]; + export interface OutputObject { + owner: string; + spender: string; + value: bigint; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace BurnEvent { + export type InputTuple = [from: AddressLike, value: BigNumberish]; + export type OutputTuple = [from: string, value: bigint]; + export interface OutputObject { + from: string; + value: bigint; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace MintEvent { + export type InputTuple = [to: AddressLike, value: BigNumberish]; + export type OutputTuple = [to: string, value: bigint]; + export interface OutputObject { + to: string; + value: bigint; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace TransferEvent { + export type InputTuple = [ + from: AddressLike, + to: AddressLike, + value: BigNumberish + ]; + export type OutputTuple = [from: string, to: string, value: bigint]; + export interface OutputObject { + from: string; + to: string; + value: bigint; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export interface PacERC20 extends BaseContract { + connect(runner?: ContractRunner | null): PacERC20; + waitForDeployment(): Promise; + + interface: PacERC20Interface; + + queryFilter( + event: TCEvent, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + queryFilter( + filter: TypedDeferredTopicFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + + on( + event: TCEvent, + listener: TypedListener + ): Promise; + on( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + once( + event: TCEvent, + listener: TypedListener + ): Promise; + once( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + listeners( + event: TCEvent + ): Promise>>; + listeners(eventName?: string): Promise>; + removeAllListeners( + event?: TCEvent + ): Promise; + + allowance: TypedContractMethod< + [owner: AddressLike, spender: AddressLike], + [bigint], + "view" + >; + + approve: TypedContractMethod< + [spender: AddressLike, value: BigNumberish], + [boolean], + "nonpayable" + >; + + balanceOf: TypedContractMethod<[account: AddressLike], [bigint], "view">; + + burn: TypedContractMethod<[_amount: BigNumberish], [boolean], "nonpayable">; + + decimals: TypedContractMethod<[], [bigint], "view">; + + mint: TypedContractMethod< + [_to: AddressLike, _amount: BigNumberish], + [boolean], + "nonpayable" + >; + + name: TypedContractMethod<[], [string], "view">; + + symbol: TypedContractMethod<[], [string], "view">; + + totalSupply: TypedContractMethod<[], [bigint], "view">; + + transfer: TypedContractMethod< + [to: AddressLike, value: BigNumberish], + [boolean], + "nonpayable" + >; + + transferFrom: TypedContractMethod< + [from: AddressLike, to: AddressLike, value: BigNumberish], + [boolean], + "nonpayable" + >; + + getFunction( + key: string | FunctionFragment + ): T; + + getFunction( + nameOrSignature: "allowance" + ): TypedContractMethod< + [owner: AddressLike, spender: AddressLike], + [bigint], + "view" + >; + getFunction( + nameOrSignature: "approve" + ): TypedContractMethod< + [spender: AddressLike, value: BigNumberish], + [boolean], + "nonpayable" + >; + getFunction( + nameOrSignature: "balanceOf" + ): TypedContractMethod<[account: AddressLike], [bigint], "view">; + getFunction( + nameOrSignature: "burn" + ): TypedContractMethod<[_amount: BigNumberish], [boolean], "nonpayable">; + getFunction( + nameOrSignature: "decimals" + ): TypedContractMethod<[], [bigint], "view">; + getFunction( + nameOrSignature: "mint" + ): TypedContractMethod< + [_to: AddressLike, _amount: BigNumberish], + [boolean], + "nonpayable" + >; + getFunction( + nameOrSignature: "name" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "symbol" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "totalSupply" + ): TypedContractMethod<[], [bigint], "view">; + getFunction( + nameOrSignature: "transfer" + ): TypedContractMethod< + [to: AddressLike, value: BigNumberish], + [boolean], + "nonpayable" + >; + getFunction( + nameOrSignature: "transferFrom" + ): TypedContractMethod< + [from: AddressLike, to: AddressLike, value: BigNumberish], + [boolean], + "nonpayable" + >; + + getEvent( + key: "Approval" + ): TypedContractEvent< + ApprovalEvent.InputTuple, + ApprovalEvent.OutputTuple, + ApprovalEvent.OutputObject + >; + getEvent( + key: "Burn" + ): TypedContractEvent< + BurnEvent.InputTuple, + BurnEvent.OutputTuple, + BurnEvent.OutputObject + >; + getEvent( + key: "Mint" + ): TypedContractEvent< + MintEvent.InputTuple, + MintEvent.OutputTuple, + MintEvent.OutputObject + >; + getEvent( + key: "Transfer" + ): TypedContractEvent< + TransferEvent.InputTuple, + TransferEvent.OutputTuple, + TransferEvent.OutputObject + >; + + filters: { + "Approval(address,address,uint256)": TypedContractEvent< + ApprovalEvent.InputTuple, + ApprovalEvent.OutputTuple, + ApprovalEvent.OutputObject + >; + Approval: TypedContractEvent< + ApprovalEvent.InputTuple, + ApprovalEvent.OutputTuple, + ApprovalEvent.OutputObject + >; + + "Burn(address,uint256)": TypedContractEvent< + BurnEvent.InputTuple, + BurnEvent.OutputTuple, + BurnEvent.OutputObject + >; + Burn: TypedContractEvent< + BurnEvent.InputTuple, + BurnEvent.OutputTuple, + BurnEvent.OutputObject + >; + + "Mint(address,uint256)": TypedContractEvent< + MintEvent.InputTuple, + MintEvent.OutputTuple, + MintEvent.OutputObject + >; + Mint: TypedContractEvent< + MintEvent.InputTuple, + MintEvent.OutputTuple, + MintEvent.OutputObject + >; + + "Transfer(address,address,uint256)": TypedContractEvent< + TransferEvent.InputTuple, + TransferEvent.OutputTuple, + TransferEvent.OutputObject + >; + Transfer: TypedContractEvent< + TransferEvent.InputTuple, + TransferEvent.OutputTuple, + TransferEvent.OutputObject + >; + }; +} diff --git a/e2e/typechain/PacPriceFeed.ts b/e2e/typechain/PacPriceFeed.ts new file mode 100644 index 0000000..65be033 --- /dev/null +++ b/e2e/typechain/PacPriceFeed.ts @@ -0,0 +1,238 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumberish, + BytesLike, + FunctionFragment, + Result, + Interface, + AddressLike, + ContractRunner, + ContractMethod, + Listener, +} from "ethers"; +import type { + TypedContractEvent, + TypedDeferredTopicFilter, + TypedEventLog, + TypedListener, + TypedContractMethod, +} from "./common"; + +export interface PacPriceFeedInterface extends Interface { + getFunction( + nameOrSignature: + | "answer" + | "answers" + | "decimals" + | "description" + | "getRoundData" + | "gov" + | "isAdmin" + | "latestRoundData" + | "roundId" + | "setAdmin" + | "setLatestAnswer" + | "version" + ): FunctionFragment; + + encodeFunctionData(functionFragment: "answer", values?: undefined): string; + encodeFunctionData( + functionFragment: "answers", + values: [BigNumberish] + ): string; + encodeFunctionData(functionFragment: "decimals", values?: undefined): string; + encodeFunctionData( + functionFragment: "description", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getRoundData", + values: [BigNumberish] + ): string; + encodeFunctionData(functionFragment: "gov", values?: undefined): string; + encodeFunctionData( + functionFragment: "isAdmin", + values: [AddressLike] + ): string; + encodeFunctionData( + functionFragment: "latestRoundData", + values?: undefined + ): string; + encodeFunctionData(functionFragment: "roundId", values?: undefined): string; + encodeFunctionData( + functionFragment: "setAdmin", + values: [AddressLike, boolean] + ): string; + encodeFunctionData( + functionFragment: "setLatestAnswer", + values: [BigNumberish] + ): string; + encodeFunctionData(functionFragment: "version", values?: undefined): string; + + decodeFunctionResult(functionFragment: "answer", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "answers", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "decimals", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "description", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getRoundData", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "gov", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "isAdmin", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "latestRoundData", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "roundId", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "setAdmin", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "setLatestAnswer", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "version", data: BytesLike): Result; +} + +export interface PacPriceFeed extends BaseContract { + connect(runner?: ContractRunner | null): PacPriceFeed; + waitForDeployment(): Promise; + + interface: PacPriceFeedInterface; + + queryFilter( + event: TCEvent, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + queryFilter( + filter: TypedDeferredTopicFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + + on( + event: TCEvent, + listener: TypedListener + ): Promise; + on( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + once( + event: TCEvent, + listener: TypedListener + ): Promise; + once( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + listeners( + event: TCEvent + ): Promise>>; + listeners(eventName?: string): Promise>; + removeAllListeners( + event?: TCEvent + ): Promise; + + answer: TypedContractMethod<[], [bigint], "view">; + + answers: TypedContractMethod<[arg0: BigNumberish], [bigint], "view">; + + decimals: TypedContractMethod<[], [bigint], "view">; + + description: TypedContractMethod<[], [string], "view">; + + getRoundData: TypedContractMethod< + [_roundId: BigNumberish], + [[bigint, bigint, bigint, bigint, bigint]], + "view" + >; + + gov: TypedContractMethod<[], [string], "view">; + + isAdmin: TypedContractMethod<[arg0: AddressLike], [boolean], "view">; + + latestRoundData: TypedContractMethod< + [], + [[bigint, bigint, bigint, bigint, bigint]], + "view" + >; + + roundId: TypedContractMethod<[], [bigint], "view">; + + setAdmin: TypedContractMethod< + [_account: AddressLike, _isAdmin: boolean], + [void], + "nonpayable" + >; + + setLatestAnswer: TypedContractMethod< + [_answer: BigNumberish], + [void], + "nonpayable" + >; + + version: TypedContractMethod<[], [bigint], "view">; + + getFunction( + key: string | FunctionFragment + ): T; + + getFunction( + nameOrSignature: "answer" + ): TypedContractMethod<[], [bigint], "view">; + getFunction( + nameOrSignature: "answers" + ): TypedContractMethod<[arg0: BigNumberish], [bigint], "view">; + getFunction( + nameOrSignature: "decimals" + ): TypedContractMethod<[], [bigint], "view">; + getFunction( + nameOrSignature: "description" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "getRoundData" + ): TypedContractMethod< + [_roundId: BigNumberish], + [[bigint, bigint, bigint, bigint, bigint]], + "view" + >; + getFunction( + nameOrSignature: "gov" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "isAdmin" + ): TypedContractMethod<[arg0: AddressLike], [boolean], "view">; + getFunction( + nameOrSignature: "latestRoundData" + ): TypedContractMethod< + [], + [[bigint, bigint, bigint, bigint, bigint]], + "view" + >; + getFunction( + nameOrSignature: "roundId" + ): TypedContractMethod<[], [bigint], "view">; + getFunction( + nameOrSignature: "setAdmin" + ): TypedContractMethod< + [_account: AddressLike, _isAdmin: boolean], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "setLatestAnswer" + ): TypedContractMethod<[_answer: BigNumberish], [void], "nonpayable">; + getFunction( + nameOrSignature: "version" + ): TypedContractMethod<[], [bigint], "view">; + + filters: {}; +} diff --git a/e2e/typechain/PacUniswapV2Pair.ts b/e2e/typechain/PacUniswapV2Pair.ts new file mode 100644 index 0000000..9ccf7e2 --- /dev/null +++ b/e2e/typechain/PacUniswapV2Pair.ts @@ -0,0 +1,750 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumberish, + BytesLike, + FunctionFragment, + Result, + Interface, + EventFragment, + AddressLike, + ContractRunner, + ContractMethod, + Listener, +} from "ethers"; +import type { + TypedContractEvent, + TypedDeferredTopicFilter, + TypedEventLog, + TypedLogDescription, + TypedListener, + TypedContractMethod, +} from "./common"; + +export interface PacUniswapV2PairInterface extends Interface { + getFunction( + nameOrSignature: + | "DOMAIN_SEPARATOR" + | "MINIMUM_LIQUIDITY" + | "PERMIT_TYPEHASH" + | "admin" + | "allowance" + | "approve" + | "balanceOf" + | "burn" + | "decimals" + | "getReserves" + | "initialize" + | "kLast" + | "mint" + | "name" + | "nonces" + | "permit" + | "price0CumulativeLast" + | "price1CumulativeLast" + | "setTokenAmounts" + | "skim" + | "swap" + | "symbol" + | "sync" + | "token0" + | "token1" + | "totalSupply" + | "transfer" + | "transferFrom" + ): FunctionFragment; + + getEvent( + nameOrSignatureOrTopic: + | "Approval" + | "Burn" + | "Mint" + | "Swap" + | "Sync" + | "Transfer" + ): EventFragment; + + encodeFunctionData( + functionFragment: "DOMAIN_SEPARATOR", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "MINIMUM_LIQUIDITY", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "PERMIT_TYPEHASH", + values?: undefined + ): string; + encodeFunctionData(functionFragment: "admin", values?: undefined): string; + encodeFunctionData( + functionFragment: "allowance", + values: [AddressLike, AddressLike] + ): string; + encodeFunctionData( + functionFragment: "approve", + values: [AddressLike, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "balanceOf", + values: [AddressLike] + ): string; + encodeFunctionData(functionFragment: "burn", values: [AddressLike]): string; + encodeFunctionData(functionFragment: "decimals", values?: undefined): string; + encodeFunctionData( + functionFragment: "getReserves", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "initialize", + values: [AddressLike, AddressLike] + ): string; + encodeFunctionData(functionFragment: "kLast", values?: undefined): string; + encodeFunctionData(functionFragment: "mint", values: [AddressLike]): string; + encodeFunctionData(functionFragment: "name", values?: undefined): string; + encodeFunctionData(functionFragment: "nonces", values: [AddressLike]): string; + encodeFunctionData( + functionFragment: "permit", + values: [ + AddressLike, + AddressLike, + BigNumberish, + BigNumberish, + BigNumberish, + BytesLike, + BytesLike + ] + ): string; + encodeFunctionData( + functionFragment: "price0CumulativeLast", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "price1CumulativeLast", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "setTokenAmounts", + values: [BigNumberish, BigNumberish] + ): string; + encodeFunctionData(functionFragment: "skim", values: [AddressLike]): string; + encodeFunctionData( + functionFragment: "swap", + values: [BigNumberish, BigNumberish, AddressLike, BytesLike] + ): string; + encodeFunctionData(functionFragment: "symbol", values?: undefined): string; + encodeFunctionData(functionFragment: "sync", values?: undefined): string; + encodeFunctionData(functionFragment: "token0", values?: undefined): string; + encodeFunctionData(functionFragment: "token1", values?: undefined): string; + encodeFunctionData( + functionFragment: "totalSupply", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "transfer", + values: [AddressLike, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "transferFrom", + values: [AddressLike, AddressLike, BigNumberish] + ): string; + + decodeFunctionResult( + functionFragment: "DOMAIN_SEPARATOR", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "MINIMUM_LIQUIDITY", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "PERMIT_TYPEHASH", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "admin", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "allowance", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "approve", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "balanceOf", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "burn", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "decimals", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "getReserves", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "initialize", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "kLast", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "mint", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "name", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "nonces", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "permit", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "price0CumulativeLast", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "price1CumulativeLast", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "setTokenAmounts", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "skim", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "swap", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "symbol", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "sync", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "token0", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "token1", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "totalSupply", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "transfer", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "transferFrom", + data: BytesLike + ): Result; +} + +export namespace ApprovalEvent { + export type InputTuple = [ + owner: AddressLike, + spender: AddressLike, + value: BigNumberish + ]; + export type OutputTuple = [owner: string, spender: string, value: bigint]; + export interface OutputObject { + owner: string; + spender: string; + value: bigint; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace BurnEvent { + export type InputTuple = [ + sender: AddressLike, + amount0: BigNumberish, + amount1: BigNumberish, + to: AddressLike + ]; + export type OutputTuple = [ + sender: string, + amount0: bigint, + amount1: bigint, + to: string + ]; + export interface OutputObject { + sender: string; + amount0: bigint; + amount1: bigint; + to: string; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace MintEvent { + export type InputTuple = [ + sender: AddressLike, + amount0: BigNumberish, + amount1: BigNumberish + ]; + export type OutputTuple = [sender: string, amount0: bigint, amount1: bigint]; + export interface OutputObject { + sender: string; + amount0: bigint; + amount1: bigint; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace SwapEvent { + export type InputTuple = [ + sender: AddressLike, + amount0In: BigNumberish, + amount1In: BigNumberish, + amount0Out: BigNumberish, + amount1Out: BigNumberish, + to: AddressLike + ]; + export type OutputTuple = [ + sender: string, + amount0In: bigint, + amount1In: bigint, + amount0Out: bigint, + amount1Out: bigint, + to: string + ]; + export interface OutputObject { + sender: string; + amount0In: bigint; + amount1In: bigint; + amount0Out: bigint; + amount1Out: bigint; + to: string; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace SyncEvent { + export type InputTuple = [reserve0: BigNumberish, reserve1: BigNumberish]; + export type OutputTuple = [reserve0: bigint, reserve1: bigint]; + export interface OutputObject { + reserve0: bigint; + reserve1: bigint; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace TransferEvent { + export type InputTuple = [ + from: AddressLike, + to: AddressLike, + value: BigNumberish + ]; + export type OutputTuple = [from: string, to: string, value: bigint]; + export interface OutputObject { + from: string; + to: string; + value: bigint; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export interface PacUniswapV2Pair extends BaseContract { + connect(runner?: ContractRunner | null): PacUniswapV2Pair; + waitForDeployment(): Promise; + + interface: PacUniswapV2PairInterface; + + queryFilter( + event: TCEvent, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + queryFilter( + filter: TypedDeferredTopicFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + + on( + event: TCEvent, + listener: TypedListener + ): Promise; + on( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + once( + event: TCEvent, + listener: TypedListener + ): Promise; + once( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + listeners( + event: TCEvent + ): Promise>>; + listeners(eventName?: string): Promise>; + removeAllListeners( + event?: TCEvent + ): Promise; + + DOMAIN_SEPARATOR: TypedContractMethod<[], [string], "view">; + + MINIMUM_LIQUIDITY: TypedContractMethod<[], [bigint], "view">; + + PERMIT_TYPEHASH: TypedContractMethod<[], [string], "view">; + + admin: TypedContractMethod<[], [string], "view">; + + allowance: TypedContractMethod< + [arg0: AddressLike, arg1: AddressLike], + [bigint], + "view" + >; + + approve: TypedContractMethod< + [spender: AddressLike, value: BigNumberish], + [boolean], + "nonpayable" + >; + + balanceOf: TypedContractMethod<[arg0: AddressLike], [bigint], "view">; + + burn: TypedContractMethod< + [to: AddressLike], + [[bigint, bigint] & { amount0: bigint; amount1: bigint }], + "nonpayable" + >; + + decimals: TypedContractMethod<[], [bigint], "view">; + + getReserves: TypedContractMethod< + [], + [ + [bigint, bigint, bigint] & { + _reserve0: bigint; + _reserve1: bigint; + _blockTimestampLast: bigint; + } + ], + "view" + >; + + initialize: TypedContractMethod< + [_token0: AddressLike, _token1: AddressLike], + [void], + "nonpayable" + >; + + kLast: TypedContractMethod<[], [bigint], "view">; + + mint: TypedContractMethod<[to: AddressLike], [bigint], "nonpayable">; + + name: TypedContractMethod<[], [string], "view">; + + nonces: TypedContractMethod<[arg0: AddressLike], [bigint], "view">; + + permit: TypedContractMethod< + [ + owner: AddressLike, + spender: AddressLike, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike + ], + [void], + "nonpayable" + >; + + price0CumulativeLast: TypedContractMethod<[], [bigint], "view">; + + price1CumulativeLast: TypedContractMethod<[], [bigint], "view">; + + setTokenAmounts: TypedContractMethod< + [amount0: BigNumberish, amount1: BigNumberish], + [boolean], + "nonpayable" + >; + + skim: TypedContractMethod<[to: AddressLike], [void], "nonpayable">; + + swap: TypedContractMethod< + [ + amount0Out: BigNumberish, + amount1Out: BigNumberish, + to: AddressLike, + data: BytesLike + ], + [void], + "nonpayable" + >; + + symbol: TypedContractMethod<[], [string], "view">; + + sync: TypedContractMethod<[], [void], "nonpayable">; + + token0: TypedContractMethod<[], [string], "view">; + + token1: TypedContractMethod<[], [string], "view">; + + totalSupply: TypedContractMethod<[], [bigint], "view">; + + transfer: TypedContractMethod< + [to: AddressLike, value: BigNumberish], + [boolean], + "nonpayable" + >; + + transferFrom: TypedContractMethod< + [from: AddressLike, to: AddressLike, value: BigNumberish], + [boolean], + "nonpayable" + >; + + getFunction( + key: string | FunctionFragment + ): T; + + getFunction( + nameOrSignature: "DOMAIN_SEPARATOR" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "MINIMUM_LIQUIDITY" + ): TypedContractMethod<[], [bigint], "view">; + getFunction( + nameOrSignature: "PERMIT_TYPEHASH" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "admin" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "allowance" + ): TypedContractMethod< + [arg0: AddressLike, arg1: AddressLike], + [bigint], + "view" + >; + getFunction( + nameOrSignature: "approve" + ): TypedContractMethod< + [spender: AddressLike, value: BigNumberish], + [boolean], + "nonpayable" + >; + getFunction( + nameOrSignature: "balanceOf" + ): TypedContractMethod<[arg0: AddressLike], [bigint], "view">; + getFunction( + nameOrSignature: "burn" + ): TypedContractMethod< + [to: AddressLike], + [[bigint, bigint] & { amount0: bigint; amount1: bigint }], + "nonpayable" + >; + getFunction( + nameOrSignature: "decimals" + ): TypedContractMethod<[], [bigint], "view">; + getFunction( + nameOrSignature: "getReserves" + ): TypedContractMethod< + [], + [ + [bigint, bigint, bigint] & { + _reserve0: bigint; + _reserve1: bigint; + _blockTimestampLast: bigint; + } + ], + "view" + >; + getFunction( + nameOrSignature: "initialize" + ): TypedContractMethod< + [_token0: AddressLike, _token1: AddressLike], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "kLast" + ): TypedContractMethod<[], [bigint], "view">; + getFunction( + nameOrSignature: "mint" + ): TypedContractMethod<[to: AddressLike], [bigint], "nonpayable">; + getFunction( + nameOrSignature: "name" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "nonces" + ): TypedContractMethod<[arg0: AddressLike], [bigint], "view">; + getFunction( + nameOrSignature: "permit" + ): TypedContractMethod< + [ + owner: AddressLike, + spender: AddressLike, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike + ], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "price0CumulativeLast" + ): TypedContractMethod<[], [bigint], "view">; + getFunction( + nameOrSignature: "price1CumulativeLast" + ): TypedContractMethod<[], [bigint], "view">; + getFunction( + nameOrSignature: "setTokenAmounts" + ): TypedContractMethod< + [amount0: BigNumberish, amount1: BigNumberish], + [boolean], + "nonpayable" + >; + getFunction( + nameOrSignature: "skim" + ): TypedContractMethod<[to: AddressLike], [void], "nonpayable">; + getFunction( + nameOrSignature: "swap" + ): TypedContractMethod< + [ + amount0Out: BigNumberish, + amount1Out: BigNumberish, + to: AddressLike, + data: BytesLike + ], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "symbol" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "sync" + ): TypedContractMethod<[], [void], "nonpayable">; + getFunction( + nameOrSignature: "token0" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "token1" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "totalSupply" + ): TypedContractMethod<[], [bigint], "view">; + getFunction( + nameOrSignature: "transfer" + ): TypedContractMethod< + [to: AddressLike, value: BigNumberish], + [boolean], + "nonpayable" + >; + getFunction( + nameOrSignature: "transferFrom" + ): TypedContractMethod< + [from: AddressLike, to: AddressLike, value: BigNumberish], + [boolean], + "nonpayable" + >; + + getEvent( + key: "Approval" + ): TypedContractEvent< + ApprovalEvent.InputTuple, + ApprovalEvent.OutputTuple, + ApprovalEvent.OutputObject + >; + getEvent( + key: "Burn" + ): TypedContractEvent< + BurnEvent.InputTuple, + BurnEvent.OutputTuple, + BurnEvent.OutputObject + >; + getEvent( + key: "Mint" + ): TypedContractEvent< + MintEvent.InputTuple, + MintEvent.OutputTuple, + MintEvent.OutputObject + >; + getEvent( + key: "Swap" + ): TypedContractEvent< + SwapEvent.InputTuple, + SwapEvent.OutputTuple, + SwapEvent.OutputObject + >; + getEvent( + key: "Sync" + ): TypedContractEvent< + SyncEvent.InputTuple, + SyncEvent.OutputTuple, + SyncEvent.OutputObject + >; + getEvent( + key: "Transfer" + ): TypedContractEvent< + TransferEvent.InputTuple, + TransferEvent.OutputTuple, + TransferEvent.OutputObject + >; + + filters: { + "Approval(address,address,uint256)": TypedContractEvent< + ApprovalEvent.InputTuple, + ApprovalEvent.OutputTuple, + ApprovalEvent.OutputObject + >; + Approval: TypedContractEvent< + ApprovalEvent.InputTuple, + ApprovalEvent.OutputTuple, + ApprovalEvent.OutputObject + >; + + "Burn(address,uint256,uint256,address)": TypedContractEvent< + BurnEvent.InputTuple, + BurnEvent.OutputTuple, + BurnEvent.OutputObject + >; + Burn: TypedContractEvent< + BurnEvent.InputTuple, + BurnEvent.OutputTuple, + BurnEvent.OutputObject + >; + + "Mint(address,uint256,uint256)": TypedContractEvent< + MintEvent.InputTuple, + MintEvent.OutputTuple, + MintEvent.OutputObject + >; + Mint: TypedContractEvent< + MintEvent.InputTuple, + MintEvent.OutputTuple, + MintEvent.OutputObject + >; + + "Swap(address,uint256,uint256,uint256,uint256,address)": TypedContractEvent< + SwapEvent.InputTuple, + SwapEvent.OutputTuple, + SwapEvent.OutputObject + >; + Swap: TypedContractEvent< + SwapEvent.InputTuple, + SwapEvent.OutputTuple, + SwapEvent.OutputObject + >; + + "Sync(uint112,uint112)": TypedContractEvent< + SyncEvent.InputTuple, + SyncEvent.OutputTuple, + SyncEvent.OutputObject + >; + Sync: TypedContractEvent< + SyncEvent.InputTuple, + SyncEvent.OutputTuple, + SyncEvent.OutputObject + >; + + "Transfer(address,address,uint256)": TypedContractEvent< + TransferEvent.InputTuple, + TransferEvent.OutputTuple, + TransferEvent.OutputObject + >; + Transfer: TypedContractEvent< + TransferEvent.InputTuple, + TransferEvent.OutputTuple, + TransferEvent.OutputObject + >; + }; +} diff --git a/e2e/typechain/common.ts b/e2e/typechain/common.ts new file mode 100644 index 0000000..56b5f21 --- /dev/null +++ b/e2e/typechain/common.ts @@ -0,0 +1,131 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + FunctionFragment, + Typed, + EventFragment, + ContractTransaction, + ContractTransactionResponse, + DeferredTopicFilter, + EventLog, + TransactionRequest, + LogDescription, +} from "ethers"; + +export interface TypedDeferredTopicFilter<_TCEvent extends TypedContractEvent> + extends DeferredTopicFilter {} + +export interface TypedContractEvent< + InputTuple extends Array = any, + OutputTuple extends Array = any, + OutputObject = any +> { + (...args: Partial): TypedDeferredTopicFilter< + TypedContractEvent + >; + name: string; + fragment: EventFragment; + getFragment(...args: Partial): EventFragment; +} + +type __TypechainAOutputTuple = T extends TypedContractEvent< + infer _U, + infer W +> + ? W + : never; +type __TypechainOutputObject = T extends TypedContractEvent< + infer _U, + infer _W, + infer V +> + ? V + : never; + +export interface TypedEventLog + extends Omit { + args: __TypechainAOutputTuple & __TypechainOutputObject; +} + +export interface TypedLogDescription + extends Omit { + args: __TypechainAOutputTuple & __TypechainOutputObject; +} + +export type TypedListener = ( + ...listenerArg: [ + ...__TypechainAOutputTuple, + TypedEventLog, + ...undefined[] + ] +) => void; + +export type MinEthersFactory = { + deploy(...a: ARGS[]): Promise; +}; + +export type GetContractTypeFromFactory = F extends MinEthersFactory< + infer C, + any +> + ? C + : never; +export type GetARGsTypeFromFactory = F extends MinEthersFactory + ? Parameters + : never; + +export type StateMutability = "nonpayable" | "payable" | "view"; + +export type BaseOverrides = Omit; +export type NonPayableOverrides = Omit< + BaseOverrides, + "value" | "blockTag" | "enableCcipRead" +>; +export type PayableOverrides = Omit< + BaseOverrides, + "blockTag" | "enableCcipRead" +>; +export type ViewOverrides = Omit; +export type Overrides = S extends "nonpayable" + ? NonPayableOverrides + : S extends "payable" + ? PayableOverrides + : ViewOverrides; + +export type PostfixOverrides, S extends StateMutability> = + | A + | [...A, Overrides]; +export type ContractMethodArgs< + A extends Array, + S extends StateMutability +> = PostfixOverrides<{ [I in keyof A]-?: A[I] | Typed }, S>; + +export type DefaultReturnType = R extends Array ? R[0] : R; + +// export interface ContractMethod = Array, R = any, D extends R | ContractTransactionResponse = R | ContractTransactionResponse> { +export interface TypedContractMethod< + A extends Array = Array, + R = any, + S extends StateMutability = "payable" +> { + (...args: ContractMethodArgs): S extends "view" + ? Promise> + : Promise; + + name: string; + + fragment: FunctionFragment; + + getFragment(...args: ContractMethodArgs): FunctionFragment; + + populateTransaction( + ...args: ContractMethodArgs + ): Promise; + staticCall( + ...args: ContractMethodArgs + ): Promise>; + send(...args: ContractMethodArgs): Promise; + estimateGas(...args: ContractMethodArgs): Promise; + staticCallResult(...args: ContractMethodArgs): Promise; +} diff --git a/e2e/typechain/factories/PacDemo__factory.ts b/e2e/typechain/factories/PacDemo__factory.ts new file mode 100644 index 0000000..cb029d7 --- /dev/null +++ b/e2e/typechain/factories/PacDemo__factory.ts @@ -0,0 +1,473 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Interface, type ContractRunner } from "ethers"; +import type { PacDemo, PacDemoInterface } from "../PacDemo"; + +const _abi = [ + { + inputs: [ + { + internalType: "address", + name: "_token0", + type: "address", + }, + { + internalType: "address", + name: "_token1", + type: "address", + }, + { + internalType: "address", + name: "_pair", + type: "address", + }, + { + internalType: "address", + name: "_pricefeed0", + type: "address", + }, + { + internalType: "address", + name: "_pricefeed1", + type: "address", + }, + ], + stateMutability: "nonpayable", + type: "constructor", + }, + { + inputs: [], + name: "PRICE_PRECISION", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "fromToken", + type: "address", + }, + { + internalType: "address", + name: "toToken", + type: "address", + }, + { + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "_swap", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "balance", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + name: "balances0", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + name: "balances1", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "token", + type: "address", + }, + { + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "deposit", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "depositEnabled", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getAMMPrices", + outputs: [ + { + internalType: "uint256", + name: "ammPrice0", + type: "uint256", + }, + { + internalType: "uint256", + name: "ammPrice1", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getPrice0", + outputs: [ + { + internalType: "uint256", + name: "price", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getPrice1", + outputs: [ + { + internalType: "uint256", + name: "price", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getPrices", + outputs: [ + { + internalType: "uint256", + name: "price0", + type: "uint256", + }, + { + internalType: "uint256", + name: "price1", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getReserves", + outputs: [ + { + internalType: "uint256", + name: "reserve0", + type: "uint256", + }, + { + internalType: "uint256", + name: "reserve1", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address", + }, + ], + name: "getValue0", + outputs: [ + { + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address", + }, + ], + name: "getValue1", + outputs: [ + { + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address", + }, + ], + name: "getValues", + outputs: [ + { + internalType: "uint256", + name: "value0", + type: "uint256", + }, + { + internalType: "uint256", + name: "value1", + type: "uint256", + }, + { + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "gov", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "pair", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "pricefeed0", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "pricefeed1", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "bool", + name: "_depositEnabled", + type: "bool", + }, + ], + name: "setDepositEnabled", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bool", + name: "_withdrawEnabled", + type: "bool", + }, + ], + name: "setWithdrawEnabled", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "fromToken", + type: "address", + }, + { + internalType: "address", + name: "toToken", + type: "address", + }, + { + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "swap", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "token0", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "token1", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "token", + type: "address", + }, + { + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "withdraw", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "withdrawEnabled", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const; + +export class PacDemo__factory { + static readonly abi = _abi; + static createInterface(): PacDemoInterface { + return new Interface(_abi) as PacDemoInterface; + } + static connect(address: string, runner?: ContractRunner | null): PacDemo { + return new Contract(address, _abi, runner) as unknown as PacDemo; + } +} diff --git a/e2e/typechain/factories/PacERC20__factory.ts b/e2e/typechain/factories/PacERC20__factory.ts new file mode 100644 index 0000000..77518e0 --- /dev/null +++ b/e2e/typechain/factories/PacERC20__factory.ts @@ -0,0 +1,429 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Interface, type ContractRunner } from "ethers"; +import type { PacERC20, PacERC20Interface } from "../PacERC20"; + +const _abi = [ + { + inputs: [ + { + internalType: "string", + name: "_name", + type: "string", + }, + { + internalType: "string", + name: "_symbol", + type: "string", + }, + { + internalType: "uint8", + name: "_decimals", + type: "uint8", + }, + ], + stateMutability: "nonpayable", + type: "constructor", + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address", + }, + { + internalType: "uint256", + name: "allowance", + type: "uint256", + }, + { + internalType: "uint256", + name: "needed", + type: "uint256", + }, + ], + name: "ERC20InsufficientAllowance", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "uint256", + name: "balance", + type: "uint256", + }, + { + internalType: "uint256", + name: "needed", + type: "uint256", + }, + ], + name: "ERC20InsufficientBalance", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "approver", + type: "address", + }, + ], + name: "ERC20InvalidApprover", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "receiver", + type: "address", + }, + ], + name: "ERC20InvalidReceiver", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address", + }, + ], + name: "ERC20InvalidSender", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address", + }, + ], + name: "ERC20InvalidSpender", + type: "error", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "spender", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + name: "Approval", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "from", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + name: "Burn", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "to", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + name: "Mint", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "from", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + name: "Transfer", + type: "event", + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address", + }, + { + internalType: "address", + name: "spender", + type: "address", + }, + ], + name: "allowance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address", + }, + { + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + name: "approve", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address", + }, + ], + name: "balanceOf", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_amount", + type: "uint256", + }, + ], + name: "burn", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "decimals", + outputs: [ + { + internalType: "uint8", + name: "", + type: "uint8", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_to", + type: "address", + }, + { + internalType: "uint256", + name: "_amount", + type: "uint256", + }, + ], + name: "mint", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "name", + outputs: [ + { + internalType: "string", + name: "", + type: "string", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "symbol", + outputs: [ + { + internalType: "string", + name: "", + type: "string", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address", + }, + { + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + name: "transfer", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "from", + type: "address", + }, + { + internalType: "address", + name: "to", + type: "address", + }, + { + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + name: "transferFrom", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, +] as const; + +export class PacERC20__factory { + static readonly abi = _abi; + static createInterface(): PacERC20Interface { + return new Interface(_abi) as PacERC20Interface; + } + static connect(address: string, runner?: ContractRunner | null): PacERC20 { + return new Contract(address, _abi, runner) as unknown as PacERC20; + } +} diff --git a/e2e/typechain/factories/PacPriceFeed__factory.ts b/e2e/typechain/factories/PacPriceFeed__factory.ts new file mode 100644 index 0000000..c56a378 --- /dev/null +++ b/e2e/typechain/factories/PacPriceFeed__factory.ts @@ -0,0 +1,257 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Interface, type ContractRunner } from "ethers"; +import type { PacPriceFeed, PacPriceFeedInterface } from "../PacPriceFeed"; + +const _abi = [ + { + inputs: [ + { + internalType: "string", + name: "_description", + type: "string", + }, + { + internalType: "uint8", + name: "_decimals", + type: "uint8", + }, + ], + stateMutability: "nonpayable", + type: "constructor", + }, + { + inputs: [], + name: "answer", + outputs: [ + { + internalType: "int256", + name: "", + type: "int256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint80", + name: "", + type: "uint80", + }, + ], + name: "answers", + outputs: [ + { + internalType: "int256", + name: "", + type: "int256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "decimals", + outputs: [ + { + internalType: "uint8", + name: "", + type: "uint8", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "description", + outputs: [ + { + internalType: "string", + name: "", + type: "string", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint80", + name: "_roundId", + type: "uint80", + }, + ], + name: "getRoundData", + outputs: [ + { + internalType: "uint80", + name: "", + type: "uint80", + }, + { + internalType: "int256", + name: "", + type: "int256", + }, + { + internalType: "uint256", + name: "", + type: "uint256", + }, + { + internalType: "uint256", + name: "", + type: "uint256", + }, + { + internalType: "uint80", + name: "", + type: "uint80", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "gov", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + name: "isAdmin", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "latestRoundData", + outputs: [ + { + internalType: "uint80", + name: "", + type: "uint80", + }, + { + internalType: "int256", + name: "", + type: "int256", + }, + { + internalType: "uint256", + name: "", + type: "uint256", + }, + { + internalType: "uint256", + name: "", + type: "uint256", + }, + { + internalType: "uint80", + name: "", + type: "uint80", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "roundId", + outputs: [ + { + internalType: "uint80", + name: "", + type: "uint80", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_account", + type: "address", + }, + { + internalType: "bool", + name: "_isAdmin", + type: "bool", + }, + ], + name: "setAdmin", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "int256", + name: "_answer", + type: "int256", + }, + ], + name: "setLatestAnswer", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "version", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const; + +export class PacPriceFeed__factory { + static readonly abi = _abi; + static createInterface(): PacPriceFeedInterface { + return new Interface(_abi) as PacPriceFeedInterface; + } + static connect( + address: string, + runner?: ContractRunner | null + ): PacPriceFeed { + return new Contract(address, _abi, runner) as unknown as PacPriceFeed; + } +} diff --git a/e2e/typechain/factories/PacUniswapV2Pair__factory.ts b/e2e/typechain/factories/PacUniswapV2Pair__factory.ts new file mode 100644 index 0000000..0e933dc --- /dev/null +++ b/e2e/typechain/factories/PacUniswapV2Pair__factory.ts @@ -0,0 +1,705 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Interface, type ContractRunner } from "ethers"; +import type { + PacUniswapV2Pair, + PacUniswapV2PairInterface, +} from "../PacUniswapV2Pair"; + +const _abi = [ + { + inputs: [], + stateMutability: "nonpayable", + type: "constructor", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "spender", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + name: "Approval", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "sender", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amount0", + type: "uint256", + }, + { + indexed: false, + internalType: "uint256", + name: "amount1", + type: "uint256", + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address", + }, + ], + name: "Burn", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "sender", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amount0", + type: "uint256", + }, + { + indexed: false, + internalType: "uint256", + name: "amount1", + type: "uint256", + }, + ], + name: "Mint", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "sender", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amount0In", + type: "uint256", + }, + { + indexed: false, + internalType: "uint256", + name: "amount1In", + type: "uint256", + }, + { + indexed: false, + internalType: "uint256", + name: "amount0Out", + type: "uint256", + }, + { + indexed: false, + internalType: "uint256", + name: "amount1Out", + type: "uint256", + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address", + }, + ], + name: "Swap", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint112", + name: "reserve0", + type: "uint112", + }, + { + indexed: false, + internalType: "uint112", + name: "reserve1", + type: "uint112", + }, + ], + name: "Sync", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "from", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + name: "Transfer", + type: "event", + }, + { + inputs: [], + name: "DOMAIN_SEPARATOR", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "MINIMUM_LIQUIDITY", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "PERMIT_TYPEHASH", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "admin", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + { + internalType: "address", + name: "", + type: "address", + }, + ], + name: "allowance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address", + }, + { + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + name: "approve", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + name: "balanceOf", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address", + }, + ], + name: "burn", + outputs: [ + { + internalType: "uint256", + name: "amount0", + type: "uint256", + }, + { + internalType: "uint256", + name: "amount1", + type: "uint256", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "decimals", + outputs: [ + { + internalType: "uint8", + name: "", + type: "uint8", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getReserves", + outputs: [ + { + internalType: "uint112", + name: "_reserve0", + type: "uint112", + }, + { + internalType: "uint112", + name: "_reserve1", + type: "uint112", + }, + { + internalType: "uint32", + name: "_blockTimestampLast", + type: "uint32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_token0", + type: "address", + }, + { + internalType: "address", + name: "_token1", + type: "address", + }, + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "kLast", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address", + }, + ], + name: "mint", + outputs: [ + { + internalType: "uint256", + name: "liquidity", + type: "uint256", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "name", + outputs: [ + { + internalType: "string", + name: "", + type: "string", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + name: "nonces", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address", + }, + { + internalType: "address", + name: "spender", + type: "address", + }, + { + internalType: "uint256", + name: "value", + type: "uint256", + }, + { + internalType: "uint256", + name: "deadline", + type: "uint256", + }, + { + internalType: "uint8", + name: "v", + type: "uint8", + }, + { + internalType: "bytes32", + name: "r", + type: "bytes32", + }, + { + internalType: "bytes32", + name: "s", + type: "bytes32", + }, + ], + name: "permit", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "price0CumulativeLast", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "price1CumulativeLast", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount0", + type: "uint256", + }, + { + internalType: "uint256", + name: "amount1", + type: "uint256", + }, + ], + name: "setTokenAmounts", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address", + }, + ], + name: "skim", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount0Out", + type: "uint256", + }, + { + internalType: "uint256", + name: "amount1Out", + type: "uint256", + }, + { + internalType: "address", + name: "to", + type: "address", + }, + { + internalType: "bytes", + name: "data", + type: "bytes", + }, + ], + name: "swap", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "symbol", + outputs: [ + { + internalType: "string", + name: "", + type: "string", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "sync", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "token0", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "token1", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address", + }, + { + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + name: "transfer", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "from", + type: "address", + }, + { + internalType: "address", + name: "to", + type: "address", + }, + { + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + name: "transferFrom", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, +] as const; + +export class PacUniswapV2Pair__factory { + static readonly abi = _abi; + static createInterface(): PacUniswapV2PairInterface { + return new Interface(_abi) as PacUniswapV2PairInterface; + } + static connect( + address: string, + runner?: ContractRunner | null + ): PacUniswapV2Pair { + return new Contract(address, _abi, runner) as unknown as PacUniswapV2Pair; + } +} diff --git a/e2e/typechain/factories/index.ts b/e2e/typechain/factories/index.ts new file mode 100644 index 0000000..d89182a --- /dev/null +++ b/e2e/typechain/factories/index.ts @@ -0,0 +1,7 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export { PacDemo__factory } from "./PacDemo__factory"; +export { PacERC20__factory } from "./PacERC20__factory"; +export { PacPriceFeed__factory } from "./PacPriceFeed__factory"; +export { PacUniswapV2Pair__factory } from "./PacUniswapV2Pair__factory"; diff --git a/e2e/typechain/index.ts b/e2e/typechain/index.ts new file mode 100644 index 0000000..c63976a --- /dev/null +++ b/e2e/typechain/index.ts @@ -0,0 +1,12 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export type { PacDemo } from "./PacDemo"; +export type { PacERC20 } from "./PacERC20"; +export type { PacPriceFeed } from "./PacPriceFeed"; +export type { PacUniswapV2Pair } from "./PacUniswapV2Pair"; +export * as factories from "./factories"; +export { PacDemo__factory } from "./factories/PacDemo__factory"; +export { PacERC20__factory } from "./factories/PacERC20__factory"; +export { PacPriceFeed__factory } from "./factories/PacPriceFeed__factory"; +export { PacUniswapV2Pair__factory } from "./factories/PacUniswapV2Pair__factory"; diff --git a/package.json b/package.json index e08b677..8a1d4df 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "build": "next build", "start": "next start -H 0.0.0.0 -p ${PORT:-8080}", "lint": "next lint", + "e2e:typechain": "typechain --target ethers-v6 --out-dir e2e/typechain 'e2e/abi/*.json'", "e2e": "NEXT_PUBLIC_PLAYWRIGHT_TESTING=true playwright test" }, "dependencies": { @@ -18,6 +19,7 @@ "@uiw/codemirror-theme-vscode": "^4.21.20", "@uiw/codemirror-themes": "^4.21.20", "@uiw/react-codemirror": "^4.21.20", + "axios": "^1.6.2", "date-fns": "^2.30.0", "eslint": "^8.51.0", "eslint-config-next": "^13.5.6", @@ -42,12 +44,16 @@ "devDependencies": { "@playwright/test": "^1.40.1", "@testing-library/react": "^14.1.2", + "@typechain/ethers-v5": "^11.1.2", + "@typechain/ethers-v6": "^0.5.1", + "@types/axios": "^0.14.0", "@types/node": "^20", "@types/react": "^18", "@types/react-dom": "^18", "autoprefixer": "^10", "postcss": "^8", "tailwindcss": "^3", + "typechain": "^8.3.2", "typescript": "^5" } } diff --git a/playwright.config.ts b/playwright.config.ts index d05a1ac..f6387e7 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -30,6 +30,8 @@ export default defineConfig({ trace: "on-first-retry", }, + timeout: 5 * 60 * 1000, + /* Configure projects for major browsers */ projects: [ { diff --git a/yarn.lock b/yarn.lock index 9e31847..b6eaba7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2688,11 +2688,34 @@ "@testing-library/dom" "^9.0.0" "@types/react-dom" "^18.0.0" +"@typechain/ethers-v5@^11.1.2": + version "11.1.2" + resolved "https://registry.yarnpkg.com/@typechain/ethers-v5/-/ethers-v5-11.1.2.tgz#82510c1744f37a2f906b9e0532ac18c0b74ffe69" + integrity sha512-ID6pqWkao54EuUQa0P5RgjvfA3MYqxUQKpbGKERbsjBW5Ra7EIXvbMlPp2pcP5IAdUkyMCFYsP2SN5q7mPdLDQ== + dependencies: + lodash "^4.17.15" + ts-essentials "^7.0.1" + +"@typechain/ethers-v6@^0.5.1": + version "0.5.1" + resolved "https://registry.yarnpkg.com/@typechain/ethers-v6/-/ethers-v6-0.5.1.tgz#42fe214a19a8b687086c93189b301e2b878797ea" + integrity sha512-F+GklO8jBWlsaVV+9oHaPh5NJdd6rAKN4tklGfInX1Q7h0xPgVLP39Jl3eCulPB5qexI71ZFHwbljx4ZXNfouA== + dependencies: + lodash "^4.17.15" + ts-essentials "^7.0.1" + "@types/aria-query@^5.0.1": version "5.0.4" resolved "https://registry.yarnpkg.com/@types/aria-query/-/aria-query-5.0.4.tgz#1a31c3d378850d2778dabb6374d036dcba4ba708" integrity sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw== +"@types/axios@^0.14.0": + version "0.14.0" + resolved "https://registry.yarnpkg.com/@types/axios/-/axios-0.14.0.tgz#ec2300fbe7d7dddd7eb9d3abf87999964cafce46" + integrity sha512-KqQnQbdYE54D7oa/UmYVMZKq7CO4l8DEENzOKc4aBRwxCXSlJXGz83flFx5L7AWrOQnmuN3kVsRdt+GZPPjiVQ== + dependencies: + axios "*" + "@types/color-convert@*": version "2.0.2" resolved "https://registry.yarnpkg.com/@types/color-convert/-/color-convert-2.0.2.tgz#a5fa5da9b866732f8bf86b01964869011e2a2356" @@ -2798,6 +2821,11 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.55.tgz#c329cbd434c42164f846b909bd6f85b5537f6240" integrity sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ== +"@types/prettier@^2.1.1": + version "2.7.3" + resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.7.3.tgz#3e51a17e291d01d17d3fc61422015a933af7a08f" + integrity sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA== + "@types/prop-types@*": version "15.7.9" resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.9.tgz#b6f785caa7ea1fe4414d9df42ee0ab67f23d8a6d" @@ -3510,6 +3538,16 @@ aria-query@^5.1.3: dependencies: dequal "^2.0.3" +array-back@^3.0.1, array-back@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/array-back/-/array-back-3.1.0.tgz#b8859d7a508871c9a7b2cf42f99428f65e96bfb0" + integrity sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q== + +array-back@^4.0.1, array-back@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/array-back/-/array-back-4.0.2.tgz#8004e999a6274586beeb27342168652fdb89fa1e" + integrity sha512-NbdMezxqf94cnNfWLL7V/im0Ub+Anbb0IoZhvzie8+4HJ4nMQuzHuy49FkGYCJK2yAloZ3meiB6AVMClbrI1vg== + array-buffer-byte-length@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/array-buffer-byte-length/-/array-buffer-byte-length-1.0.0.tgz#fabe8bc193fea865f317fe7807085ee0dee5aead" @@ -3608,6 +3646,11 @@ asynciterator.prototype@^1.0.0: dependencies: has-symbols "^1.0.3" +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== + atomic-sleep@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/atomic-sleep/-/atomic-sleep-1.0.0.tgz#eb85b77a601fc932cfe432c5acd364a9e2c9075b" @@ -3635,6 +3678,15 @@ axe-core@^4.6.2: resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-4.8.2.tgz#2f6f3cde40935825cf4465e3c1c9e77b240ff6ae" integrity sha512-/dlp0fxyM3R8YW7MFzaHWXrf4zzbr0vaYb23VBFCl83R7nWNPg/yaQw2Dc8jzCMmDVLhSdzH8MjrsuIUuvX+6g== +axios@*, axios@^1.6.2: + version "1.6.2" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.2.tgz#de67d42c755b571d3e698df1b6504cde9b0ee9f2" + integrity sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A== + dependencies: + follow-redirects "^1.15.0" + form-data "^4.0.0" + proxy-from-env "^1.1.0" + axobject-query@^3.1.1: version "3.2.1" resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-3.2.1.tgz#39c378a6e3b06ca679f29138151e45b2b32da62a" @@ -3908,11 +3960,38 @@ color@^4.2.3: color-convert "^2.0.1" color-string "^1.9.0" +combined-stream@^1.0.8: + version "1.0.8" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" + integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== + dependencies: + delayed-stream "~1.0.0" + command-exists@^1.2.8: version "1.2.9" resolved "https://registry.yarnpkg.com/command-exists/-/command-exists-1.2.9.tgz#c50725af3808c8ab0260fd60b01fbfa25b954f69" integrity sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w== +command-line-args@^5.1.1: + version "5.2.1" + resolved "https://registry.yarnpkg.com/command-line-args/-/command-line-args-5.2.1.tgz#c44c32e437a57d7c51157696893c5909e9cec42e" + integrity sha512-H4UfQhZyakIjC74I9d34fGYDwk3XpSr17QhEd0Q3I9Xq1CETHo4Hcuo87WyWHpAF1aSLjLRf5lD9ZGX2qStUvg== + dependencies: + array-back "^3.1.0" + find-replace "^3.0.0" + lodash.camelcase "^4.3.0" + typical "^4.0.0" + +command-line-usage@^6.1.0: + version "6.1.3" + resolved "https://registry.yarnpkg.com/command-line-usage/-/command-line-usage-6.1.3.tgz#428fa5acde6a838779dfa30e44686f4b6761d957" + integrity sha512-sH5ZSPr+7UStsloltmDh7Ce5fb8XPlHyoPzTpyyMuYCtervL65+ubVZ6Q61cFtFl62UyJlc8/JwERRbAFPUqgw== + dependencies: + array-back "^4.0.2" + chalk "^2.4.2" + table-layout "^1.0.2" + typical "^5.2.0" + commander@^2.20.3: version "2.20.3" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" @@ -4012,7 +4091,7 @@ debug@^3.2.7: dependencies: ms "^2.1.1" -debug@^4.1.1, debug@^4.3.2, debug@^4.3.4: +debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.4: version "4.3.4" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== @@ -4053,6 +4132,11 @@ deep-equal@^2.0.5: which-collection "^1.0.1" which-typed-array "^1.1.13" +deep-extend@~0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" + integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== + deep-is@^0.1.3: version "0.1.4" resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.4.tgz#a6f2dce612fadd2ef1f519b73551f17e85199831" @@ -4091,6 +4175,11 @@ delay@^5.0.0: resolved "https://registry.yarnpkg.com/delay/-/delay-5.0.0.tgz#137045ef1b96e5071060dd5be60bf9334436bd1d" integrity sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw== +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== + dequal@^2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/dequal/-/dequal-2.0.3.tgz#2644214f1997d39ed0ee0ece72335490a7ac67be" @@ -4683,6 +4772,13 @@ filter-obj@^1.1.0: resolved "https://registry.yarnpkg.com/filter-obj/-/filter-obj-1.1.0.tgz#9b311112bc6c6127a16e016c6c5d7f19e0805c5b" integrity sha512-8rXg1ZnX7xzy2NGDVkBVaAy+lSlPNwad13BtgSlLuxfIslyt5Vg64U7tFcCt4WS1R0hvtnQybT/IyCkGZ3DpXQ== +find-replace@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/find-replace/-/find-replace-3.0.0.tgz#3e7e23d3b05167a76f770c9fbd5258b0def68c38" + integrity sha512-6Tb2myMioCAgv5kfvP5/PkZZ/ntTpVK39fHY7WkWBgvbeE+VHd/tZuZ4mrC+bxh4cfOZeYKVPaJIZtZXV7GNCQ== + dependencies: + array-back "^3.0.1" + find-up@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" @@ -4718,7 +4814,7 @@ flatted@^3.2.9: resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.9.tgz#7eb4c67ca1ba34232ca9d2d93e9886e611ad7daf" integrity sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ== -follow-redirects@^1.12.1: +follow-redirects@^1.12.1, follow-redirects@^1.15.0: version "1.15.3" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.3.tgz#fe2f3ef2690afce7e82ed0b44db08165b207123a" integrity sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q== @@ -4730,6 +4826,15 @@ for-each@^0.3.3: dependencies: is-callable "^1.1.3" +form-data@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452" + integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.8" + mime-types "^2.1.12" + fraction.js@^4.3.6: version "4.3.7" resolved "https://registry.yarnpkg.com/fraction.js/-/fraction.js-4.3.7.tgz#06ca0085157e42fda7f9e726e79fefc4068840f7" @@ -4744,6 +4849,15 @@ framer-motion@^10.16.4: optionalDependencies: "@emotion/is-prop-valid" "^0.8.2" +fs-extra@^7.0.0: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9" + integrity sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw== + dependencies: + graceful-fs "^4.1.2" + jsonfile "^4.0.0" + universalify "^0.1.0" + fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" @@ -4902,7 +5016,7 @@ gopd@^1.0.1: dependencies: get-intrinsic "^1.1.3" -graceful-fs@^4.1.2, graceful-fs@^4.2.4: +graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.4: version "4.2.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3" integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== @@ -5307,7 +5421,7 @@ jiti@^1.19.1: resolved "https://registry.yarnpkg.com/jiti/-/jiti-1.20.0.tgz#2d823b5852ee8963585c8dd8b7992ffc1ae83b42" integrity sha512-3TV69ZbrvV6U5DfQimop50jE9Dl6J8O1ja1dvBbMba/sZ3YBEQqJ2VZRoQPVnhlzjNtU1vaXRZVrVjU4qtm8yA== -js-sha3@0.8.0: +js-sha3@0.8.0, js-sha3@^0.8.0: version "0.8.0" resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.8.0.tgz#b9b7a5da73afad7dedd0f8c463954cbde6818840" integrity sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q== @@ -5364,6 +5478,13 @@ json5@^1.0.2: dependencies: minimist "^1.2.0" +jsonfile@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" + integrity sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg== + optionalDependencies: + graceful-fs "^4.1.6" + jsonparse@^1.2.0: version "1.3.1" resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" @@ -5476,6 +5597,11 @@ locate-path@^6.0.0: dependencies: p-locate "^5.0.0" +lodash.camelcase@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" + integrity sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA== + lodash.foreach@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.foreach/-/lodash.foreach-4.5.0.tgz#1a6a35eace401280c7f06dddec35165ab27e3e53" @@ -5511,7 +5637,7 @@ lodash.omit@^4.5.0: resolved "https://registry.yarnpkg.com/lodash.omit/-/lodash.omit-4.5.0.tgz#6eb19ae5a1ee1dd9df0b969e66ce0b7fa30b5e60" integrity sha512-XeqSp49hNGmlkj2EJlfrQFIzQ6lXdNro9sddtQzcJY8QaoC2GO0DT7xaIokHeyM+mIT0mPMlPvkYzg2xCuHdZg== -lodash@*, lodash@^4.17.21: +lodash@*, lodash@^4.17.15, lodash@^4.17.21: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== @@ -5570,6 +5696,18 @@ micromatch@^4.0.4, micromatch@^4.0.5: braces "^3.0.2" picomatch "^2.3.1" +mime-db@1.52.0: + version "1.52.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" + integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== + +mime-types@^2.1.12: + version "2.1.35" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" + integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== + dependencies: + mime-db "1.52.0" + minimalistic-assert@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" @@ -5587,6 +5725,11 @@ minimist@^1.2.0, minimist@^1.2.6: resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== +mkdirp@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" + integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== + motion@10.16.2: version "10.16.2" resolved "https://registry.yarnpkg.com/motion/-/motion-10.16.2.tgz#7dc173c6ad62210a7e9916caeeaf22c51e598d21" @@ -6012,7 +6155,7 @@ prelude-ls@^1.2.1: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== -prettier@^2.8.8: +prettier@^2.3.1, prettier@^2.8.8: version "2.8.8" resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== @@ -6045,6 +6188,11 @@ proxy-compare@2.5.1: resolved "https://registry.yarnpkg.com/proxy-compare/-/proxy-compare-2.5.1.tgz#17818e33d1653fbac8c2ec31406bce8a2966f600" integrity sha512-oyfc0Tx87Cpwva5ZXezSp5V9vht1c7dZBhvuV/y3ctkgMVUmiAGDVeeB0dKhGSyT0v1ZTEQYpe/RXlBVBNuCLA== +proxy-from-env@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" + integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== + punycode@^2.1.0: version "2.3.0" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.0.tgz#f67fa67c94da8f4d0cfff981aee4118064199b8f" @@ -6234,6 +6382,11 @@ real-require@^0.1.0: resolved "https://registry.yarnpkg.com/real-require/-/real-require-0.1.0.tgz#736ac214caa20632847b7ca8c1056a0767df9381" integrity sha512-r/H9MzAWtrv8aSVjPCMFpDMl5q66GqtmmRkRjpHTsp4zBAa+snZyiQNlMONiUmEJcsnaw0wCauJ2GWODr/aFkg== +reduce-flatten@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/reduce-flatten/-/reduce-flatten-2.0.0.tgz#734fd84e65f375d7ca4465c69798c25c9d10ae27" + integrity sha512-EJ4UNY/U1t2P/2k6oqotuX2Cc3T6nxJwsM0N0asT7dhrtH1ltUxDn4NalSYmPE2rCkVpcf/X6R0wDwcFpzhd4w== + reflect.getprototypeof@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/reflect.getprototypeof/-/reflect.getprototypeof-1.0.4.tgz#aaccbf41aca3821b87bb71d9dcbc7ad0ba50a3f3" @@ -6537,6 +6690,11 @@ strict-uri-encode@^2.0.0: resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546" integrity sha512-QwiXZgpRcKkhTj2Scnn++4PKtWsH0kpzZ62L2R6c/LUVYv7hVnZqcg2+sMuT6R7Jusu1vviK/MFsu6kNJfWlEQ== +string-format@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/string-format/-/string-format-2.0.0.tgz#f2df2e7097440d3b65de31b6d40d54c96eaffb9b" + integrity sha512-bbEs3scLeYNXLecRRuk6uJxdXUSj6le/8rNPHChIJTn2V79aXVTR1EH2OH5zLKKoz0V02fOUKZZcw01pLUShZA== + string-width@^4.1.0, string-width@^4.2.0: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" @@ -6674,6 +6832,16 @@ swr@^2.2.4: client-only "^0.0.1" use-sync-external-store "^1.2.0" +table-layout@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/table-layout/-/table-layout-1.0.2.tgz#c4038a1853b0136d63365a734b6931cf4fad4a04" + integrity sha512-qd/R7n5rQTRFi+Zf2sk5XVVd9UQl6ZkduPFC3S7WEGJAmetDTjY3qPN50eSKzwuzEyQKy5TN2TiZdkIjos2L6A== + dependencies: + array-back "^4.0.1" + deep-extend "~0.6.0" + typical "^5.2.0" + wordwrapjs "^4.0.0" + tailwind-merge@^1.14.0: version "1.14.0" resolved "https://registry.yarnpkg.com/tailwind-merge/-/tailwind-merge-1.14.0.tgz#e677f55d864edc6794562c63f5001f45093cdb8b" @@ -6784,6 +6952,21 @@ ts-api-utils@^1.0.1: resolved "https://registry.yarnpkg.com/ts-api-utils/-/ts-api-utils-1.0.3.tgz#f12c1c781d04427313dbac808f453f050e54a331" integrity sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg== +ts-command-line-args@^2.2.0: + version "2.5.1" + resolved "https://registry.yarnpkg.com/ts-command-line-args/-/ts-command-line-args-2.5.1.tgz#e64456b580d1d4f6d948824c274cf6fa5f45f7f0" + integrity sha512-H69ZwTw3rFHb5WYpQya40YAX2/w7Ut75uUECbgBIsLmM+BNuYnxsltfyyLMxy6sEeKxgijLTnQtLd0nKd6+IYw== + dependencies: + chalk "^4.1.0" + command-line-args "^5.1.1" + command-line-usage "^6.1.0" + string-format "^2.0.0" + +ts-essentials@^7.0.1: + version "7.0.3" + resolved "https://registry.yarnpkg.com/ts-essentials/-/ts-essentials-7.0.3.tgz#686fd155a02133eedcc5362dc8b5056cde3e5a38" + integrity sha512-8+gr5+lqO3G84KdiTSMRLtuyJ+nTBVRKuCrK4lidMPdVeEp0uqC875uE5NMcaA7YYMN7XsNiFQuMvasF8HT/xQ== + ts-interface-checker@^0.1.9: version "0.1.13" resolved "https://registry.yarnpkg.com/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz#784fd3d679722bc103b1b4b8030bcddb5db2a699" @@ -6826,6 +7009,22 @@ type-fest@^0.20.2: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4" integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ== +typechain@^8.3.2: + version "8.3.2" + resolved "https://registry.yarnpkg.com/typechain/-/typechain-8.3.2.tgz#1090dd8d9c57b6ef2aed3640a516bdbf01b00d73" + integrity sha512-x/sQYr5w9K7yv3es7jo4KTX05CLxOf7TRWwoHlrjRh8H82G64g+k7VuWPJlgMo6qrjfCulOdfBjiaDtmhFYD/Q== + dependencies: + "@types/prettier" "^2.1.1" + debug "^4.3.1" + fs-extra "^7.0.0" + glob "7.1.7" + js-sha3 "^0.8.0" + lodash "^4.17.15" + mkdirp "^1.0.4" + prettier "^2.3.1" + ts-command-line-args "^2.2.0" + ts-essentials "^7.0.1" + typed-array-buffer@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/typed-array-buffer/-/typed-array-buffer-1.0.0.tgz#18de3e7ed7974b0a729d3feecb94338d1472cd60" @@ -6877,6 +7076,16 @@ typescript@^5: resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.2.2.tgz#5ebb5e5a5b75f085f22bc3f8460fba308310fa78" integrity sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w== +typical@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/typical/-/typical-4.0.0.tgz#cbeaff3b9d7ae1e2bbfaf5a4e6f11eccfde94fc4" + integrity sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw== + +typical@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/typical/-/typical-5.2.0.tgz#4daaac4f2b5315460804f0acf6cb69c52bb93066" + integrity sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg== + uint8arrays@^3.0.0, uint8arrays@^3.1.0: version "3.1.1" resolved "https://registry.yarnpkg.com/uint8arrays/-/uint8arrays-3.1.1.tgz#2d8762acce159ccd9936057572dade9459f65ae0" @@ -6899,6 +7108,11 @@ undici-types@~5.26.4: resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== +universalify@^0.1.0: + version "0.1.2" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" + integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== + update-browserslist-db@^1.0.13: version "1.0.13" resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz#3c5e4f5c083661bd38ef64b6328c26ed6c8248c4" @@ -7312,6 +7526,14 @@ which@^2.0.1: dependencies: isexe "^2.0.0" +wordwrapjs@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/wordwrapjs/-/wordwrapjs-4.0.1.tgz#d9790bccfb110a0fc7836b5ebce0937b37a8b98f" + integrity sha512-kKlNACbvHrkpIw6oPeYDSmdCTu2hdMHoyXLTcUKala++lx5Y+wjJ/e474Jqv5abnVmwxw08DiTuHmw69lJGksA== + dependencies: + reduce-flatten "^2.0.0" + typical "^5.2.0" + wrap-ansi@^6.2.0: version "6.2.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-6.2.0.tgz#e9393ba07102e6c91a3b221478f0257cd2856e53" From dc0cfd7d9547a586b304d7797aa3200412beec73 Mon Sep 17 00:00:00 2001 From: Aik Date: Wed, 20 Dec 2023 19:22:11 +0700 Subject: [PATCH 07/17] test(e2e): demo initial values --- components/demo/DemoApp.tsx | 14 ++++++++++---- e2e/demo.spec.ts | 30 ++++++++++++++++++++++++++++-- playwright.config.ts | 2 +- 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/components/demo/DemoApp.tsx b/components/demo/DemoApp.tsx index c6a77bc..4503ffb 100644 --- a/components/demo/DemoApp.tsx +++ b/components/demo/DemoApp.tsx @@ -203,19 +203,23 @@ const DemoTokenBox = ({ Oracle Price: - ${formatBigInt(price, PRICE_PRECISION)} + + ${formatBigInt(price, PRICE_PRECISION)} + AMM Price: - ${formatBigInt(ammPrice * quotePrice, PRICE_PRECISION * 2)} + + ${formatBigInt(ammPrice * quotePrice, PRICE_PRECISION * 2)} + Deposited Balance: - + {formatBigInt(balance, Number(baseTokenInfo.decimals))} {bSymbol} @@ -223,7 +227,9 @@ const DemoTokenBox = ({ Deposited Value: - ${formatBigInt(value, PRICE_PRECISION)} + + ${formatBigInt(value, PRICE_PRECISION)} + diff --git a/e2e/demo.spec.ts b/e2e/demo.spec.ts index c23413a..0b143f5 100644 --- a/e2e/demo.spec.ts +++ b/e2e/demo.spec.ts @@ -55,14 +55,40 @@ test.describe("demo", () => { test("deposit enabled", async ({ page }) => { await expect(page.getByText("Deposit Disabled")).toBeVisible(); - await pacmon.enableDeposit(); + expect(await pacmon.enableDeposit()).not.toThrow(); await expect(page.getByText("Deposit Enabled")).toBeVisible(); }); test("withdraw enabled", async ({ page }) => { await expect(page.getByText("Withdraw Disabled")).toBeVisible(); - await pacmon.enableWithdraw(); + expect(await pacmon.enableWithdraw()).not.toThrow(); await expect(page.getByText("Withdraw Enabled")).toBeVisible(); }); }); + + test.describe("deposit", () => { + test.beforeEach(async ({ page }) => { + await pacmon.enableDeposit(); + await pacmon.enableWithdraw(); + await page + .getByLabel("PacDemo Contact Address") + .fill(pacmon.contracts.demo); + }); + + test("initial values", async ({ page }) => { + await expect(page.getByTestId("oracle-price-tBTC")).toHaveText("$35,000"); + await expect(page.getByTestId("amm-price-tBTC")).toHaveText("$35,000"); + await expect(page.getByTestId("deposited-balance-tBTC")).toHaveText( + "0 tBTC" + ); + await expect(page.getByTestId("deposited-value-tBTC")).toHaveText("$0"); + + await expect(page.getByTestId("oracle-price-tUSDC")).toHaveText("$1"); + await expect(page.getByTestId("amm-price-tUSDC")).toHaveText("$1"); + await expect(page.getByTestId("deposited-balance-tUSDC")).toHaveText( + "0 tUSDC" + ); + await expect(page.getByTestId("deposited-value-tUSDC")).toHaveText("$0"); + }); + }); }); diff --git a/playwright.config.ts b/playwright.config.ts index f6387e7..1666bfd 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -12,7 +12,7 @@ import { defineConfig, devices } from "@playwright/test"; export default defineConfig({ testDir: "./e2e", /* Run tests in files in parallel */ - fullyParallel: true, + fullyParallel: false, /* Fail the build on CI if you accidentally left test.only in the source code. */ forbidOnly: !!process.env.CI, /* Retry on CI only */ From 30e210710b503edd6bcc9ec3f2041f12b8a5f29d Mon Sep 17 00:00:00 2001 From: Aik Date: Thu, 21 Dec 2023 12:22:08 +0700 Subject: [PATCH 08/17] test: add data-testid --- components/demo/DemoApp.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/demo/DemoApp.tsx b/components/demo/DemoApp.tsx index 4503ffb..2c3d0d5 100644 --- a/components/demo/DemoApp.tsx +++ b/components/demo/DemoApp.tsx @@ -253,12 +253,14 @@ const DemoTokenBox = ({ placeholder="0" type="number" size="md" + data-testid={`deposit-input-${baseTokenInfo.symbol}`} />
@@ -266,6 +268,7 @@ const DemoTokenBox = ({ className="w-full" isDisabled={!canDeposit} onPress={onPressDeposit} + data-testid={`deposit-execute-${baseTokenInfo.symbol}`} > Deposit @@ -285,12 +288,14 @@ const DemoTokenBox = ({ placeholder="0" type="number" size="md" + data-testid={`withdraw-input-${baseTokenInfo.symbol}`} />
From 9ecef5930d964aa5d319f1aca72831ea24fd946f Mon Sep 17 00:00:00 2001 From: Aik Date: Thu, 21 Dec 2023 12:22:26 +0700 Subject: [PATCH 09/17] test: demo deposit --- e2e/demo.spec.ts | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/e2e/demo.spec.ts b/e2e/demo.spec.ts index 0b143f5..1bc51b3 100644 --- a/e2e/demo.spec.ts +++ b/e2e/demo.spec.ts @@ -27,7 +27,7 @@ test.describe("demo", () => { test.beforeAll(async () => { pacmon = new PacmonDemoSDK(24, "http://localhost:3033"); - await pacmon.init(94); + await pacmon.init(); }); test.beforeEach(async ({ page }) => { @@ -55,13 +55,13 @@ test.describe("demo", () => { test("deposit enabled", async ({ page }) => { await expect(page.getByText("Deposit Disabled")).toBeVisible(); - expect(await pacmon.enableDeposit()).not.toThrow(); + await pacmon.enableDeposit(); await expect(page.getByText("Deposit Enabled")).toBeVisible(); }); test("withdraw enabled", async ({ page }) => { await expect(page.getByText("Withdraw Disabled")).toBeVisible(); - expect(await pacmon.enableWithdraw()).not.toThrow(); + await pacmon.enableWithdraw(); await expect(page.getByText("Withdraw Enabled")).toBeVisible(); }); }); @@ -90,5 +90,26 @@ test.describe("demo", () => { ); await expect(page.getByTestId("deposited-value-tUSDC")).toHaveText("$0"); }); + + test("deposit tBTC", async ({ page }) => { + await expect(page.getByTestId("deposit-approve-tBTC")).toBeDisabled(); + await expect(page.getByTestId("deposit-execute-tBTC")).toBeDisabled(); + await page.getByTestId("deposit-input-tBTC").fill("1"); + await expect(page.getByTestId("deposit-approve-tBTC")).not.toBeDisabled(); + await page.getByTestId("deposit-approve-tBTC").click(); + await expect(page.getByText("Approve tBTC success")).toBeVisible(); + await expect(page.getByTestId("deposit-execute-tBTC")).not.toBeDisabled(); + await page.getByTestId("deposit-execute-tBTC").click(); + await expect(page.getByText("Deposit 1 tBTC success")).toBeVisible(); + + await expect(page.getByTestId("oracle-price-tBTC")).toHaveText("$35,000"); + await expect(page.getByTestId("amm-price-tBTC")).toHaveText("$35,000"); + await expect(page.getByTestId("deposited-balance-tBTC")).toHaveText( + "1 tBTC" + ); + await expect(page.getByTestId("deposited-value-tBTC")).toHaveText( + "$35,000" + ); + }); }); }); From 8ced530453007aa0e7e3b1813f8c30d40355f4e9 Mon Sep 17 00:00:00 2001 From: Aik Date: Thu, 21 Dec 2023 19:09:55 +0700 Subject: [PATCH 10/17] test: demo flow --- components/demo/DemoApp.tsx | 88 ++++++++++++++++++++++--------------- e2e/demo.spec.ts | 53 +++++++++++++++++++++- playwright.config.ts | 2 - 3 files changed, 105 insertions(+), 38 deletions(-) diff --git a/components/demo/DemoApp.tsx b/components/demo/DemoApp.tsx index 2c3d0d5..ff61f2e 100644 --- a/components/demo/DemoApp.tsx +++ b/components/demo/DemoApp.tsx @@ -200,38 +200,41 @@ const DemoTokenBox = ({
{bSymbol}
- - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + +
Oracle Price: - - ${formatBigInt(price, PRICE_PRECISION)} - -
AMM Price: - - ${formatBigInt(ammPrice * quotePrice, PRICE_PRECISION * 2)} - -
Deposited Balance: - - {formatBigInt(balance, Number(baseTokenInfo.decimals))} {bSymbol} - -
Deposited Value: - - ${formatBigInt(value, PRICE_PRECISION)} - -
Oracle Price: + + ${formatBigInt(price, PRICE_PRECISION)} + +
AMM Price: + + ${formatBigInt(ammPrice * quotePrice, PRICE_PRECISION * 2)} + +
Deposited Balance: + + {formatBigInt(balance, Number(baseTokenInfo.decimals))}{" "} + {bSymbol} + +
Deposited Value: + + ${formatBigInt(value, PRICE_PRECISION)} + +
setAction(act)} > - +
- + { />
-
diff --git a/e2e/demo.spec.ts b/e2e/demo.spec.ts index 1bc51b3..599a170 100644 --- a/e2e/demo.spec.ts +++ b/e2e/demo.spec.ts @@ -30,6 +30,10 @@ test.describe("demo", () => { await pacmon.init(); }); + test.afterAll(async () => { + await pacmon.deleteNode(); + }); + test.beforeEach(async ({ page }) => { await page.goto("./demo"); await page.getByText("Connect Wallet").click(); @@ -66,7 +70,7 @@ test.describe("demo", () => { }); }); - test.describe("deposit", () => { + test.describe("interactions flow", () => { test.beforeEach(async ({ page }) => { await pacmon.enableDeposit(); await pacmon.enableWithdraw(); @@ -111,5 +115,52 @@ test.describe("demo", () => { "$35,000" ); }); + + test("deposit tUSDC", async ({ page }) => { + await expect(page.getByTestId("deposit-approve-tUSDC")).toBeDisabled(); + await expect(page.getByTestId("deposit-execute-tUSDC")).toBeDisabled(); + await page.getByTestId("deposit-input-tUSDC").fill("65000"); + await expect( + page.getByTestId("deposit-approve-tUSDC") + ).not.toBeDisabled(); + await page.getByTestId("deposit-approve-tUSDC").click(); + await expect(page.getByText("Approve tUSDC success")).toBeVisible(); + await expect( + page.getByTestId("deposit-execute-tUSDC") + ).not.toBeDisabled(); + await page.getByTestId("deposit-execute-tUSDC").click(); + await expect( + page.getByText("Deposit 65,000 tUSDC success") + ).toBeVisible(); + + await expect(page.getByTestId("oracle-price-tUSDC")).toHaveText("$1"); + await expect(page.getByTestId("amm-price-tUSDC")).toHaveText("$1"); + await expect(page.getByTestId("deposited-balance-tUSDC")).toHaveText( + "65,000 tUSDC" + ); + await expect(page.getByTestId("deposited-value-tUSDC")).toHaveText( + "$65,000" + ); + }); + + test("balance", async ({ page }) => { + await page.getByTestId("balance-token-button").click(); + await expect(page.getByText("Balancing")).toBeVisible(); + await expect(page.getByText("Balance success")).toBeVisible(); + + await expect(page.getByTestId("deposited-balance-tBTC")).toHaveText( + "1.4271032192 tBTC" + ); + await expect(page.getByTestId("deposited-value-tBTC")).toHaveText( + "$49,948.6126713571" + ); + + await expect(page.getByTestId("deposited-balance-tUSDC")).toHaveText( + "50,000 tUSDC" + ); + await expect(page.getByTestId("deposited-value-tUSDC")).toHaveText( + "$50,000" + ); + }); }); }); diff --git a/playwright.config.ts b/playwright.config.ts index 1666bfd..ac12a7e 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -30,8 +30,6 @@ export default defineConfig({ trace: "on-first-retry", }, - timeout: 5 * 60 * 1000, - /* Configure projects for major browsers */ projects: [ { From ce831c150482153aad47df92b6d8b84339659c88 Mon Sep 17 00:00:00 2001 From: Aik Date: Thu, 21 Dec 2023 19:19:20 +0700 Subject: [PATCH 11/17] config --- config/url.ts | 62 ++++++++++++++++++++++++++---------------------- e2e/demo.spec.ts | 5 +++- e2e/utils.ts | 12 ++++++---- 3 files changed, 45 insertions(+), 34 deletions(-) diff --git a/config/url.ts b/config/url.ts index 723fa50..c53ba11 100644 --- a/config/url.ts +++ b/config/url.ts @@ -1,30 +1,12 @@ import { Chain } from "@rainbow-me/rainbowkit"; -// export const BASE_API = "https://o.pacmon.suijin.xyz/api"; -// export const PACMON_CHAIN: Chain = { -// id: 1337, -// name: "Pacmon", -// network: "pacmon", -// iconUrl: "https://example.com/icon.svg", -// iconBackground: "#fff", -// nativeCurrency: { -// decimals: 18, -// name: "Pacmon Ether", -// symbol: "PAC", -// }, -// rpcUrls: { -// public: { http: ["https://o.pacmon.suijin.xyz/rpc/"] }, -// default: { http: ["https://o.pacmon.suijin.xyz/rpc/"] }, -// }, -// blockExplorers: { -// default: { name: "PacmonScan", url: "https://etherscan.io" }, -// etherscan: { name: "PacmonScan", url: "https://etherscan.io" }, -// }, -// contracts: {}, -// testnet: true, -// }; +const RPC = process.env.NEXT_PUBLIC_RPC || "https://o.pacmon.suijin.xyz/rpc/"; +const EXPLORER = + process.env.NEXT_PUBLIC_EXPLORER || "https://o.pacmon.suijin.xyz/explorer/"; + +export const BASE_API = + process.env.NEXT_PUBLIC_API_URL || "https://o.pacmon.suijin.xyz/api"; -export const BASE_API = "http://localhost:3033"; export const PACMON_CHAIN: Chain = { id: 1337, name: "Pacmon", @@ -37,13 +19,37 @@ export const PACMON_CHAIN: Chain = { symbol: "PAC", }, rpcUrls: { - public: { http: ["http://localhost:8545"] }, - default: { http: ["http://localhost:8545"] }, + public: { http: [RPC] }, + default: { http: [RPC] }, }, blockExplorers: { - default: { name: "PacmonScan", url: "http://localhost:5100" }, - etherscan: { name: "PacmonScan", url: "http://localhost:5100" }, + default: { name: "PacmonScan", url: EXPLORER }, + etherscan: { name: "PacmonScan", url: EXPLORER }, }, contracts: {}, testnet: true, }; + +// export const BASE_API = "http://localhost:3033"; +// export const PACMON_CHAIN: Chain = { +// id: 1337, +// name: "Pacmon", +// network: "pacmon", +// iconUrl: "https://example.com/icon.svg", +// iconBackground: "#fff", +// nativeCurrency: { +// decimals: 18, +// name: "Pacmon Ether", +// symbol: "PAC", +// }, +// rpcUrls: { +// public: { http: ["http://localhost:8545"] }, +// default: { http: ["http://localhost:8545"] }, +// }, +// blockExplorers: { +// default: { name: "PacmonScan", url: "http://localhost:5100" }, +// etherscan: { name: "PacmonScan", url: "http://localhost:5100" }, +// }, +// contracts: {}, +// testnet: true, +// }; diff --git a/e2e/demo.spec.ts b/e2e/demo.spec.ts index 599a170..74500ba 100644 --- a/e2e/demo.spec.ts +++ b/e2e/demo.spec.ts @@ -8,6 +8,9 @@ test("has title", async ({ page }) => { await expect(page).toHaveTitle(/PACMON/); }); +const API_URL = process.env.NEXT_PUBLIC_API_URL || "http://localhost:3033"; +const PROJECT_ID = Number(process.env.NEXT_PUBLIC_PROJECT_ID || "24"); + test("can connect wallet", async ({ page }) => { await page.goto("./demo"); @@ -26,7 +29,7 @@ test.describe("demo", () => { let pacmon: PacmonDemoSDK; test.beforeAll(async () => { - pacmon = new PacmonDemoSDK(24, "http://localhost:3033"); + pacmon = new PacmonDemoSDK(PROJECT_ID, API_URL); await pacmon.init(); }); diff --git a/e2e/utils.ts b/e2e/utils.ts index 1315bf2..733360f 100644 --- a/e2e/utils.ts +++ b/e2e/utils.ts @@ -12,6 +12,8 @@ import { publicProvider } from "wagmi/providers/public"; const PRIVATE_KEY = "0x26e86e45f6fc45ec6e2ecd128cec80fa1d1505e5507dcd2ae58c3130a7a97b48"; +const RPC = process.env.NEXT_PUBLIC_RPC || "http://localhost:8545"; +const EXPLORER = process.env.NEXT_PUBLIC_EXPLORER || "http://localhost:5100"; export const CHAIN: Chain = { id: 1337, @@ -23,12 +25,12 @@ export const CHAIN: Chain = { symbol: "PAC", }, rpcUrls: { - public: { http: ["http://localhost:8545"] }, - default: { http: ["http://localhost:8545"] }, + public: { http: [RPC] }, + default: { http: [RPC] }, }, blockExplorers: { - default: { name: "PacmonScan", url: "http://localhost:5100" }, - etherscan: { name: "PacmonScan", url: "http://localhost:5100" }, + default: { name: "PacmonScan", url: EXPLORER }, + etherscan: { name: "PacmonScan", url: EXPLORER }, }, contracts: {}, testnet: true, @@ -47,7 +49,7 @@ const mockWallet = (): RainbowWallet => ({ walletClient: createWalletClient({ account: privateKeyToAccount(PRIVATE_KEY), chain: CHAIN, - transport: http("http://localhost:8545"), + transport: http(RPC), pollingInterval: 100, }), flags: { From 114a46e9e122a649fce9dd215e0c9ab320183605 Mon Sep 17 00:00:00 2001 From: Aik Date: Thu, 21 Dec 2023 19:22:33 +0700 Subject: [PATCH 12/17] test: github action --- .github/workflows/playwright.yml | 8 +++++++- e2e/demo.spec.ts | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index fc61546..a898a42 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -18,7 +18,13 @@ jobs: - name: Install Playwright Browsers run: yarn playwright install --with-deps - name: Run Playwright tests - run: yarn playwright test + run: yarn playwright e2e + env: + NEXT_PUBLIC_RPC: https://o.pacmon.suijin.xyz/rpc/ + NEXT_PUBLIC_EXPLORER: https://o.pacmon.suijin.xyz/explorer + NEXT_PUBLIC_API_URL: https://o.pacmon.suijin.xyz/api + NEXT_PUBLIC_PLAYWRIGHT_TESTING: 1 + NEXT_PUBLIC_PLAYWRIGHT_PROJECT_ID: 24 - uses: actions/upload-artifact@v3 if: always() with: diff --git a/e2e/demo.spec.ts b/e2e/demo.spec.ts index 74500ba..b006d02 100644 --- a/e2e/demo.spec.ts +++ b/e2e/demo.spec.ts @@ -9,7 +9,9 @@ test("has title", async ({ page }) => { }); const API_URL = process.env.NEXT_PUBLIC_API_URL || "http://localhost:3033"; -const PROJECT_ID = Number(process.env.NEXT_PUBLIC_PROJECT_ID || "24"); +const PROJECT_ID = Number( + process.env.NEXT_PUBLIC_PLAYWRIGHT_PROJECT_ID || "24" +); test("can connect wallet", async ({ page }) => { await page.goto("./demo"); From 5bc0a40f86361287e4035cf2841577553589282b Mon Sep 17 00:00:00 2001 From: Aik Date: Thu, 21 Dec 2023 19:25:06 +0700 Subject: [PATCH 13/17] test: fix action --- .github/workflows/playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index a898a42..4034fc3 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -18,7 +18,7 @@ jobs: - name: Install Playwright Browsers run: yarn playwright install --with-deps - name: Run Playwright tests - run: yarn playwright e2e + run: yarn e2e env: NEXT_PUBLIC_RPC: https://o.pacmon.suijin.xyz/rpc/ NEXT_PUBLIC_EXPLORER: https://o.pacmon.suijin.xyz/explorer From 5dccce72ec121a0a2cc29e349cd37cbabfefa699 Mon Sep 17 00:00:00 2001 From: Aik Date: Sat, 23 Dec 2023 17:06:49 +0700 Subject: [PATCH 14/17] test: e2e example --- .github/workflows/playwright.yml | 2 +- .gitignore | 1 + e2e/demo.spec.ts | 8 +++++--- package.json | 1 + yarn.lock | 5 +++++ 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 4034fc3..ef018d0 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -24,7 +24,7 @@ jobs: NEXT_PUBLIC_EXPLORER: https://o.pacmon.suijin.xyz/explorer NEXT_PUBLIC_API_URL: https://o.pacmon.suijin.xyz/api NEXT_PUBLIC_PLAYWRIGHT_TESTING: 1 - NEXT_PUBLIC_PLAYWRIGHT_PROJECT_ID: 24 + NEXT_PUBLIC_PLAYWRIGHT_PROJECT_ID: 1 - uses: actions/upload-artifact@v3 if: always() with: diff --git a/.gitignore b/.gitignore index b4108c8..d470f9f 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,4 @@ _static /playwright-report/ /blob-report/ /playwright/.cache/ +.env \ No newline at end of file diff --git a/e2e/demo.spec.ts b/e2e/demo.spec.ts index b006d02..608ab2a 100644 --- a/e2e/demo.spec.ts +++ b/e2e/demo.spec.ts @@ -1,5 +1,6 @@ import { test, expect } from "@playwright/test"; import { PacmonDemoSDK } from "./pacmonsdk"; +import "dotenv/config"; test("has title", async ({ page }) => { await page.goto("./demo"); @@ -9,9 +10,10 @@ test("has title", async ({ page }) => { }); const API_URL = process.env.NEXT_PUBLIC_API_URL || "http://localhost:3033"; -const PROJECT_ID = Number( - process.env.NEXT_PUBLIC_PLAYWRIGHT_PROJECT_ID || "24" -); +const PROJECT_ID = Number(process.env.NEXT_PUBLIC_PLAYWRIGHT_PROJECT_ID || "1"); + +console.log("PROJECT_ID:", PROJECT_ID); +console.log("API_URL:", API_URL); test("can connect wallet", async ({ page }) => { await page.goto("./demo"); diff --git a/package.json b/package.json index 8a1d4df..f02c819 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "@types/react": "^18", "@types/react-dom": "^18", "autoprefixer": "^10", + "dotenv": "^16.3.1", "postcss": "^8", "tailwindcss": "^3", "typechain": "^8.3.2", diff --git a/yarn.lock b/yarn.lock index b6eaba7..d73a244 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4236,6 +4236,11 @@ dom-accessibility-api@^0.5.9: resolved "https://registry.yarnpkg.com/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz#5a7429e6066eb3664d911e33fb0e45de8eb08453" integrity sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg== +dotenv@^16.3.1: + version "16.3.1" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.3.1.tgz#369034de7d7e5b120972693352a3bf112172cc3e" + integrity sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ== + duplexify@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/duplexify/-/duplexify-4.1.2.tgz#18b4f8d28289132fa0b9573c898d9f903f81c7b0" From 42783b4d311195a318d755a8e137780f15a2acef Mon Sep 17 00:00:00 2001 From: Aik Date: Sat, 23 Dec 2023 17:20:05 +0700 Subject: [PATCH 15/17] ci: playwright test cmd --- .github/workflows/playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index ef018d0..a307f90 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -18,7 +18,7 @@ jobs: - name: Install Playwright Browsers run: yarn playwright install --with-deps - name: Run Playwright tests - run: yarn e2e + run: npx playwright test env: NEXT_PUBLIC_RPC: https://o.pacmon.suijin.xyz/rpc/ NEXT_PUBLIC_EXPLORER: https://o.pacmon.suijin.xyz/explorer From 7b30f459a68c67750bd3f76276a6b1be268ae1b5 Mon Sep 17 00:00:00 2001 From: chimz Date: Sun, 24 Dec 2023 22:30:21 +0700 Subject: [PATCH 16/17] move PacmonSDK to lib --- e2e/pacmonsdk.ts | 51 +----------------------------------------------- lib/PacmonSDK.ts | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 50 deletions(-) create mode 100644 lib/PacmonSDK.ts diff --git a/e2e/pacmonsdk.ts b/e2e/pacmonsdk.ts index 863ae6e..d438e84 100644 --- a/e2e/pacmonsdk.ts +++ b/e2e/pacmonsdk.ts @@ -1,7 +1,7 @@ import _ from "lodash"; import { PacDemo__factory } from "./typechain"; import { PacDemoInterface } from "./typechain/PacDemo"; -import axios, { Axios } from "axios"; +import { PacmonSDK } from "@/lib/PacmonSDK"; interface Contracts { demo: string; @@ -16,55 +16,6 @@ interface Interfaces { demo: PacDemoInterface; } -interface NodeInfoResp { - contracts: { sequence: number; name: string; address: string }[]; - signers: { address: string }[]; -} - -export class PacmonSDK { - projectId: number; - nodeId?: number; - axiosClient: Axios; - - constructor(projectId: number, api: string) { - this.projectId = projectId; - this.axiosClient = axios.create({ - baseURL: api, - timeout: 300000, - }); - } - - async createNode() { - const resp = await this.axiosClient.post(`projects/deploy`, { - projectId: this.projectId, - nodeName: "Test Node", - }); - return resp.data.id; - } - - async deleteNode() { - const resp = await this.axiosClient.post(`nodes/delete`, { - nodeId: this.nodeId, - }); - } - - async getNodeInfo() { - const resp = await this.axiosClient.get( - `nodes/${this.nodeId}` - ); - return resp.data; - } - - async call(contractAddress: string, data: string, callerAddress: string) { - const resp = await this.axiosClient.post(`/nodes/call`, { - nodeId: this.nodeId, - contractAddress, - encodedData: data, - callerAddress, - }); - } -} - export class PacmonDemoSDK extends PacmonSDK { contracts: Contracts; interfaces: Interfaces; diff --git a/lib/PacmonSDK.ts b/lib/PacmonSDK.ts new file mode 100644 index 0000000..8276c37 --- /dev/null +++ b/lib/PacmonSDK.ts @@ -0,0 +1,50 @@ +import axios, { Axios } from "axios"; + +interface NodeInfoResp { + contracts: { sequence: number; name: string; address: string }[]; + signers: { address: string }[]; +} + +export class PacmonSDK { + projectId: number; + nodeId?: number; + axiosClient: Axios; + + constructor(projectId: number, api: string) { + this.projectId = projectId; + this.axiosClient = axios.create({ + baseURL: api, + timeout: 300000, + }); + } + + async createNode() { + const resp = await this.axiosClient.post(`projects/deploy`, { + projectId: this.projectId, + nodeName: "Test Node", + }); + return resp.data.id; + } + + async deleteNode() { + const resp = await this.axiosClient.post(`nodes/delete`, { + nodeId: this.nodeId, + }); + } + + async getNodeInfo() { + const resp = await this.axiosClient.get( + `nodes/${this.nodeId}` + ); + return resp.data; + } + + async call(contractAddress: string, data: string, callerAddress: string) { + const resp = await this.axiosClient.post(`/nodes/call`, { + nodeId: this.nodeId, + contractAddress, + encodedData: data, + callerAddress, + }); + } +} From 668991db5eed0412b474f601f787d338f4c2a704 Mon Sep 17 00:00:00 2001 From: chimz Date: Sun, 24 Dec 2023 22:34:18 +0700 Subject: [PATCH 17/17] remove hackathon name --- pages/_app.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/_app.tsx b/pages/_app.tsx index 0e19605..b5ab599 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -21,7 +21,7 @@ export default function RootLayout({ Component, pageProps }: AppProps) { return (
- PACMON : BKKBUIDL2023 + PACMON