diff --git a/.env b/.env index 071c9e8df..e800b7d45 100644 --- a/.env +++ b/.env @@ -8,4 +8,9 @@ REACT_APP_FORTMATIC_KEY="pk_live_F937DF033A1666BF" REACT_APP_MOONPAY_KEY="pk_live_72EGoobLnlgc8WB7AaxyiWu2S43dj8eY" REACT_APP_TRANSAK_KEY="258960cf-1e17-4419-bf7f-77443282f5da" REACT_APP_GRAPH_API_URL="https://polygon.furadao.org/subgraphs/name/quickswap" -REACT_APP_PRDT_URL="https://prdt-quickswap-main.pages.dev/" \ No newline at end of file +REACT_APP_PRDT_URL="https://prdt-quickswap-main.pages.dev/" +REACT_APP_SCAN_BASE_URL="https://polygonscan.com" +REACT_APP_TOKEN_LIST_DEFAULT_URL="https://unpkg.com/quickswap-default-token-list@latest/build/quickswap-default.tokenlist.json" +REACT_APP_STAKING_LIST_DEFAULT_URL="https://unpkg.com/quickswap-default-staking-list@latest/build/quickswap-default.lpfarms.json" +REACT_APP_DUAL_STAKING_LIST_DEFAULT_URL="https://unpkg.com/quickswap-default-staking-list@latest/build/quickswap-default.dualfarms.json" +REACT_APP_SYRUP_LIST_DEFAULT_URL="https://unpkg.com/quickswap-default-staking-list@latest/build/quickswap-default.syrups.json" diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md index 29d46960f..f4b5bf03e 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -10,9 +10,10 @@ assignees: '' A clear and concise description of the bug. **Steps to Reproduce** + 1. Go to ... 2. Click on ... -... + ... **Expected Behavior** A clear and concise description of what you expected to happen. diff --git a/README.md b/README.md index 95c1e8e89..ac620e246 100755 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ Enabling users to: - Participate in Dragon's syrup running on QuickSwap protocol Useful links: + - Website: [quickswap.exchange](https://quickswap.exchange/) - Beta: [beta.quickswap.exchange](https://beta.quickswap.exchange/) - Info: [info.quickswap.exchange](https://info.quickswap.exchange) @@ -24,7 +25,6 @@ To access the QuickSwap Interface, use an IPFS gateway link from the [latest release](https://github.com/QuickSwap/interface-v2/releases/latest), or visit [quickswap.exchange](https://quickswap.exchange). - The QuickSwap interface is hosted on IPFS in a decentralized manner. `quickswap.exchange` just holds a CNAME record to the Cloudflare IPFS gateway. You can use [any](https://ipfs.github.io/public-gateway-checker/) public or private IPFS gateway supporting origin isolation to access QuickSwap interface if for some reason the Cloudflare gateway doesn't work for you Just go to `/ipns/quickswap.exchange` diff --git a/cypress/integration/add-liquidity.test.ts b/cypress/integration/add-liquidity.test.ts index 13aba26cc..549b49704 100644 --- a/cypress/integration/add-liquidity.test.ts +++ b/cypress/integration/add-liquidity.test.ts @@ -1,26 +1,56 @@ describe('Add Liquidity', () => { it('loads the two correct tokens', () => { - cy.visit('/pools?currency0=0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6¤cy1=0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619') - cy.get('#add-liquidity-input-tokena .token-symbol-container').should('contain.text', 'WBTC') - cy.get('#add-liquidity-input-tokenb .token-symbol-container').should('contain.text', 'ETH') - }) + cy.visit( + '/pools?currency0=0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6¤cy1=0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619', + ); + cy.get('#add-liquidity-input-tokena .token-symbol-container').should( + 'contain.text', + 'WBTC', + ); + cy.get('#add-liquidity-input-tokenb .token-symbol-container').should( + 'contain.text', + 'ETH', + ); + }); it('does not crash if ETH is duplicated', () => { - cy.visit('/pools?currency0=0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619¤cy1=0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619') - cy.get('#add-liquidity-input-tokena .token-symbol-container').should('not.contain.text', 'ETH') - cy.get('#add-liquidity-input-tokenb .token-symbol-container').should('contain.text', 'ETH') - }) + cy.visit( + '/pools?currency0=0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619¤cy1=0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619', + ); + cy.get('#add-liquidity-input-tokena .token-symbol-container').should( + 'not.contain.text', + 'ETH', + ); + cy.get('#add-liquidity-input-tokenb .token-symbol-container').should( + 'contain.text', + 'ETH', + ); + }); it('token not in storage is loaded', () => { - cy.visit('/pools?currency0=0x64aFDF9e28946419E325d801Fb3053d8B8FFdC23¤cy1=0x60bB3D364B765C497C8cE50AE0Ae3f0882c5bD05') - cy.get('#add-liquidity-input-tokena .token-symbol-container').should('contain.text', 'MEEB') - cy.get('#add-liquidity-input-tokenb .token-symbol-container').should('contain.text', 'IMX') - }) + cy.visit( + '/pools?currency0=0x64aFDF9e28946419E325d801Fb3053d8B8FFdC23¤cy1=0x60bB3D364B765C497C8cE50AE0Ae3f0882c5bD05', + ); + cy.get('#add-liquidity-input-tokena .token-symbol-container').should( + 'contain.text', + 'MEEB', + ); + cy.get('#add-liquidity-input-tokenb .token-symbol-container').should( + 'contain.text', + 'IMX', + ); + }); it('single token can be selected', () => { - cy.visit('/pools?currency0=0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6') - cy.get('#add-liquidity-input-tokena .token-symbol-container').should('contain.text', 'WBTC') - cy.visit('/pools?currency0=0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619') - cy.get('#add-liquidity-input-tokena .token-symbol-container').should('contain.text', 'ETH') - }) -}) + cy.visit('/pools?currency0=0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6'); + cy.get('#add-liquidity-input-tokena .token-symbol-container').should( + 'contain.text', + 'WBTC', + ); + cy.visit('/pools?currency0=0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619'); + cy.get('#add-liquidity-input-tokena .token-symbol-container').should( + 'contain.text', + 'ETH', + ); + }); +}); diff --git a/cypress/integration/landing.test.ts b/cypress/integration/landing.test.ts index 375946a32..b32068815 100644 --- a/cypress/integration/landing.test.ts +++ b/cypress/integration/landing.test.ts @@ -1,39 +1,38 @@ -import { TEST_ADDRESS_NEVER_USE_SHORTENED } from '../support/commands' +import { TEST_ADDRESS_NEVER_USE_SHORTENED } from '../support/commands'; describe('Landing Page', () => { - beforeEach(() => cy.visit('/')) + beforeEach(() => cy.visit('/')); it('loads landing page', () => { - cy.get('#landing-page') - }) - + cy.get('#landing-page'); + }); it('allows navigation to pool', () => { - cy.get('#pools-page-link').click() - cy.url().should('include', '/pools') - }) + cy.get('#pools-page-link').click(); + cy.url().should('include', '/pools'); + }); it('allows navigation to swap', () => { - cy.get('#swap-page-link').click() - cy.url().should('include', '/swap') - }) + cy.get('#swap-page-link').click(); + cy.url().should('include', '/swap'); + }); it('allows navigation to farm', () => { - cy.get('#farm-page-link').click() - cy.url().should('include', '/farm') - }) + cy.get('#farm-page-link').click(); + cy.url().should('include', '/farm'); + }); it('allows navigation to dragons lair', () => { - cy.get('#dragons-page-link').click() - cy.url().should('include', '/dragons') - }) + cy.get('#dragons-page-link').click(); + cy.url().should('include', '/dragons'); + }); it('allows navigation to analytics', () => { - cy.get('#analytics-page-link').click() - cy.url().should('include', '/analytics') - }) + cy.get('#analytics-page-link').click(); + cy.url().should('include', '/analytics'); + }); /**it('is connected', () => { cy.get('#web3-status-connected').click() cy.get('#web3-account-identifier-row').contains(TEST_ADDRESS_NEVER_USE_SHORTENED) })*/ -}) +}); diff --git a/cypress/integration/lists.test.ts b/cypress/integration/lists.test.ts index e8879691a..eeda6042d 100644 --- a/cypress/integration/lists.test.ts +++ b/cypress/integration/lists.test.ts @@ -1,20 +1,20 @@ describe('Lists', () => { beforeEach(() => { - cy.visit('/swap') - }) + cy.visit('/swap'); + }); it('defaults to uniswap list', () => { - cy.get('#swap-currency-output .open-currency-select-button').click() - cy.get('#currency-search-selected-list-name').should('contain', 'Uniswap') - }) + cy.get('#swap-currency-output .open-currency-select-button').click(); + cy.get('#currency-search-selected-list-name').should('contain', 'Uniswap'); + }); it('change list', () => { - cy.get('#swap-currency-output .open-currency-select-button').click() - cy.get('#currency-search-change-list-button').click() - cy.get('#list-row-tokens-1inch-eth .select-button').click() - cy.get('#currency-search-selected-list-name').should('contain', '1inch') - cy.get('#currency-search-change-list-button').click() - cy.get('#list-row-tokens-uniswap-eth .select-button').click() - cy.get('#currency-search-selected-list-name').should('contain', 'Uniswap') - }) -}) + cy.get('#swap-currency-output .open-currency-select-button').click(); + cy.get('#currency-search-change-list-button').click(); + cy.get('#list-row-tokens-1inch-eth .select-button').click(); + cy.get('#currency-search-selected-list-name').should('contain', '1inch'); + cy.get('#currency-search-change-list-button').click(); + cy.get('#list-row-tokens-uniswap-eth .select-button').click(); + cy.get('#currency-search-selected-list-name').should('contain', 'Uniswap'); + }); +}); diff --git a/cypress/integration/migrate-v1.test.ts b/cypress/integration/migrate-v1.test.ts index 362504828..ed1748d54 100644 --- a/cypress/integration/migrate-v1.test.ts +++ b/cypress/integration/migrate-v1.test.ts @@ -1,8 +1,8 @@ describe('Migrate V1 Liquidity', () => { describe('Remove V1 liquidity', () => { it('renders the correct page', () => { - cy.visit('/remove/v1/0x93bB63aFe1E0180d0eF100D774B473034fd60C36') - cy.get('#remove-v1-exchange').should('contain', 'MKR/ETH') - }) - }) -}) + cy.visit('/remove/v1/0x93bB63aFe1E0180d0eF100D774B473034fd60C36'); + cy.get('#remove-v1-exchange').should('contain', 'MKR/ETH'); + }); + }); +}); diff --git a/cypress/integration/pool.test.ts b/cypress/integration/pool.test.ts index 5969abce7..c7b28a795 100644 --- a/cypress/integration/pool.test.ts +++ b/cypress/integration/pool.test.ts @@ -1,12 +1,12 @@ describe('Pool', () => { - beforeEach(() => cy.visit('/pool')) + beforeEach(() => cy.visit('/pool')); it('add liquidity links to /add/ETH', () => { - cy.get('#join-pool-button').click() - cy.url().should('contain', '/add/ETH') - }) + cy.get('#join-pool-button').click(); + cy.url().should('contain', '/add/ETH'); + }); it('import pool links to /import', () => { - cy.get('#import-pool-link').click() - cy.url().should('contain', '/find') - }) -}) + cy.get('#import-pool-link').click(); + cy.url().should('contain', '/find'); + }); +}); diff --git a/cypress/integration/remove-liquidity.test.ts b/cypress/integration/remove-liquidity.test.ts index 63c8e1a36..ebdec747e 100644 --- a/cypress/integration/remove-liquidity.test.ts +++ b/cypress/integration/remove-liquidity.test.ts @@ -1,39 +1,47 @@ describe('Remove Liquidity', () => { it('redirects', () => { - cy.visit('/remove/0xc778417E063141139Fce010982780140Aa0cD5Ab-0xF9bA5210F91D0474bd1e1DcDAeC4C58E359AaD85') + cy.visit( + '/remove/0xc778417E063141139Fce010982780140Aa0cD5Ab-0xF9bA5210F91D0474bd1e1DcDAeC4C58E359AaD85', + ); cy.url().should( 'contain', - '/remove/0xc778417E063141139Fce010982780140Aa0cD5Ab/0xF9bA5210F91D0474bd1e1DcDAeC4C58E359AaD85' - ) - }) + '/remove/0xc778417E063141139Fce010982780140Aa0cD5Ab/0xF9bA5210F91D0474bd1e1DcDAeC4C58E359AaD85', + ); + }); it('eth remove', () => { - cy.visit('/remove/ETH/0xF9bA5210F91D0474bd1e1DcDAeC4C58E359AaD85') - cy.get('#remove-liquidity-tokena-symbol').should('contain.text', 'ETH') - cy.get('#remove-liquidity-tokenb-symbol').should('contain.text', 'MKR') - }) + cy.visit('/remove/ETH/0xF9bA5210F91D0474bd1e1DcDAeC4C58E359AaD85'); + cy.get('#remove-liquidity-tokena-symbol').should('contain.text', 'ETH'); + cy.get('#remove-liquidity-tokenb-symbol').should('contain.text', 'MKR'); + }); it('eth remove swap order', () => { - cy.visit('/remove/0xF9bA5210F91D0474bd1e1DcDAeC4C58E359AaD85/ETH') - cy.get('#remove-liquidity-tokena-symbol').should('contain.text', 'MKR') - cy.get('#remove-liquidity-tokenb-symbol').should('contain.text', 'ETH') - }) + cy.visit('/remove/0xF9bA5210F91D0474bd1e1DcDAeC4C58E359AaD85/ETH'); + cy.get('#remove-liquidity-tokena-symbol').should('contain.text', 'MKR'); + cy.get('#remove-liquidity-tokenb-symbol').should('contain.text', 'ETH'); + }); it('loads the two correct tokens', () => { - cy.visit('/remove/0xc778417E063141139Fce010982780140Aa0cD5Ab-0xF9bA5210F91D0474bd1e1DcDAeC4C58E359AaD85') - cy.get('#remove-liquidity-tokena-symbol').should('contain.text', 'WETH') - cy.get('#remove-liquidity-tokenb-symbol').should('contain.text', 'MKR') - }) + cy.visit( + '/remove/0xc778417E063141139Fce010982780140Aa0cD5Ab-0xF9bA5210F91D0474bd1e1DcDAeC4C58E359AaD85', + ); + cy.get('#remove-liquidity-tokena-symbol').should('contain.text', 'WETH'); + cy.get('#remove-liquidity-tokenb-symbol').should('contain.text', 'MKR'); + }); it('does not crash if ETH is duplicated', () => { - cy.visit('/remove/0xc778417E063141139Fce010982780140Aa0cD5Ab-0xc778417E063141139Fce010982780140Aa0cD5Ab') - cy.get('#remove-liquidity-tokena-symbol').should('contain.text', 'WETH') - cy.get('#remove-liquidity-tokenb-symbol').should('contain.text', 'WETH') - }) + cy.visit( + '/remove/0xc778417E063141139Fce010982780140Aa0cD5Ab-0xc778417E063141139Fce010982780140Aa0cD5Ab', + ); + cy.get('#remove-liquidity-tokena-symbol').should('contain.text', 'WETH'); + cy.get('#remove-liquidity-tokenb-symbol').should('contain.text', 'WETH'); + }); it('token not in storage is loaded', () => { - cy.visit('/remove/0xb290b2f9f8f108d03ff2af3ac5c8de6de31cdf6d-0xF9bA5210F91D0474bd1e1DcDAeC4C58E359AaD85') - cy.get('#remove-liquidity-tokena-symbol').should('contain.text', 'SKL') - cy.get('#remove-liquidity-tokenb-symbol').should('contain.text', 'MKR') - }) -}) + cy.visit( + '/remove/0xb290b2f9f8f108d03ff2af3ac5c8de6de31cdf6d-0xF9bA5210F91D0474bd1e1DcDAeC4C58E359AaD85', + ); + cy.get('#remove-liquidity-tokena-symbol').should('contain.text', 'SKL'); + cy.get('#remove-liquidity-tokenb-symbol').should('contain.text', 'MKR'); + }); +}); diff --git a/cypress/integration/send.test.ts b/cypress/integration/send.test.ts index 35b8dee10..d0339e65b 100644 --- a/cypress/integration/send.test.ts +++ b/cypress/integration/send.test.ts @@ -1,11 +1,14 @@ describe('Send', () => { it('should redirect', () => { - cy.visit('/send') - cy.url().should('include', '/swap') - }) + cy.visit('/send'); + cy.url().should('include', '/swap'); + }); it('should redirect with url params', () => { - cy.visit('/send?outputCurrency=ETH&recipient=bob.argent.xyz') - cy.url().should('contain', '/swap?outputCurrency=ETH&recipient=bob.argent.xyz') - }) -}) + cy.visit('/send?outputCurrency=ETH&recipient=bob.argent.xyz'); + cy.url().should( + 'contain', + '/swap?outputCurrency=ETH&recipient=bob.argent.xyz', + ); + }); +}); diff --git a/cypress/integration/swap.test.ts b/cypress/integration/swap.test.ts index 06cedb3f5..9c2e2e296 100644 --- a/cypress/integration/swap.test.ts +++ b/cypress/integration/swap.test.ts @@ -1,75 +1,82 @@ describe('Swap', () => { beforeEach(() => { - cy.visit('/swap') - }) + cy.visit('/swap'); + }); it('can enter an amount into input', () => { cy.get('#swap-currency-input .token-amount-input') .type('0.001', { delay: 200 }) - .should('have.value', '0.001') - }) + .should('have.value', '0.001'); + }); it('zero swap amount', () => { cy.get('#swap-currency-input .token-amount-input') .type('0.0', { delay: 200 }) - .should('have.value', '0.0') - }) + .should('have.value', '0.0'); + }); it('invalid swap amount', () => { cy.get('#swap-currency-input .token-amount-input') .type('\\', { delay: 200 }) - .should('have.value', '') - }) + .should('have.value', ''); + }); it('can enter an amount into output', () => { cy.get('#swap-currency-output .token-amount-input') .type('0.001', { delay: 200 }) - .should('have.value', '0.001') - }) + .should('have.value', '0.001'); + }); it('zero output amount', () => { cy.get('#swap-currency-output .token-amount-input') .type('0.0', { delay: 200 }) - .should('have.value', '0.0') - }) + .should('have.value', '0.0'); + }); it('can swap ETH for DAI', () => { - cy.get('#swap-currency-output .open-currency-select-button').click() - cy.get('.token-item-0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735').should('be.visible') - cy.get('.token-item-0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735').click({ force: true }) - cy.get('#swap-currency-input .token-amount-input').should('be.visible') - cy.get('#swap-currency-input .token-amount-input').type('0.001', { force: true, delay: 200 }) - cy.get('#swap-currency-output .token-amount-input').should('not.equal', '') - cy.get('#swap-button').click() - cy.get('#confirm-swap-or-send').should('contain', 'Confirm Swap') - }) + cy.get('#swap-currency-output .open-currency-select-button').click(); + cy.get('.token-item-0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735').should( + 'be.visible', + ); + cy.get('.token-item-0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735').click({ + force: true, + }); + cy.get('#swap-currency-input .token-amount-input').should('be.visible'); + cy.get('#swap-currency-input .token-amount-input').type('0.001', { + force: true, + delay: 200, + }); + cy.get('#swap-currency-output .token-amount-input').should('not.equal', ''); + cy.get('#swap-button').click(); + cy.get('#confirm-swap-or-send').should('contain', 'Confirm Swap'); + }); it('add a recipient does not exist unless in expert mode', () => { - cy.get('#add-recipient-button').should('not.exist') - }) + cy.get('#add-recipient-button').should('not.exist'); + }); describe('expert mode', () => { beforeEach(() => { - cy.window().then(win => { - cy.stub(win, 'prompt').returns('confirm') - }) - cy.get('#open-settings-dialog-button').click() - cy.get('#toggle-expert-mode-button').click() - cy.get('#confirm-expert-mode').click() - }) + cy.window().then((win) => { + cy.stub(win, 'prompt').returns('confirm'); + }); + cy.get('#open-settings-dialog-button').click(); + cy.get('#toggle-expert-mode-button').click(); + cy.get('#confirm-expert-mode').click(); + }); it('add a recipient is visible', () => { - cy.get('#add-recipient-button').should('be.visible') - }) + cy.get('#add-recipient-button').should('be.visible'); + }); it('add a recipient', () => { - cy.get('#add-recipient-button').click() - cy.get('#recipient').should('exist') - }) + cy.get('#add-recipient-button').click(); + cy.get('#recipient').should('exist'); + }); it('remove recipient', () => { - cy.get('#add-recipient-button').click() - cy.get('#remove-recipient-button').click() - cy.get('#recipient').should('not.exist') - }) - }) -}) + cy.get('#add-recipient-button').click(); + cy.get('#remove-recipient-button').click(); + cy.get('#recipient').should('not.exist'); + }); + }); +}); diff --git a/cypress/integration/token-warning.ts b/cypress/integration/token-warning.ts index 0e0254c0a..e4ad13adb 100644 --- a/cypress/integration/token-warning.ts +++ b/cypress/integration/token-warning.ts @@ -1,17 +1,17 @@ describe('Warning', () => { beforeEach(() => { - cy.visit('/swap?outputCurrency=0x0a40f26d74274b7f22b28556a27b35d97ce08e0a') - }) + cy.visit('/swap?outputCurrency=0x0a40f26d74274b7f22b28556a27b35d97ce08e0a'); + }); it('Check that warning is displayed', () => { - cy.get('.token-warning-container').should('be.visible') - }) + cy.get('.token-warning-container').should('be.visible'); + }); it('Check that warning hides after button dismissal', () => { - cy.get('.token-dismiss-button').should('be.disabled') - cy.get('.understand-checkbox').click() - cy.get('.token-dismiss-button').should('not.be.disabled') - cy.get('.token-dismiss-button').click() - cy.get('.token-warning-container').should('not.be.visible') - }) -}) + cy.get('.token-dismiss-button').should('be.disabled'); + cy.get('.understand-checkbox').click(); + cy.get('.token-dismiss-button').should('not.be.disabled'); + cy.get('.token-dismiss-button').click(); + cy.get('.token-warning-container').should('not.be.visible'); + }); +}); diff --git a/cypress/support/commands.d.ts b/cypress/support/commands.d.ts index e7eba62fd..43b011509 100644 --- a/cypress/support/commands.d.ts +++ b/cypress/support/commands.d.ts @@ -1,6 +1,6 @@ -export const TEST_ADDRESS_NEVER_USE: string +export const TEST_ADDRESS_NEVER_USE: string; -export const TEST_ADDRESS_NEVER_USE_SHORTENED: string +export const TEST_ADDRESS_NEVER_USE_SHORTENED: string; // declare namespace Cypress { // // eslint-disable-next-line @typescript-eslint/class-name-casing diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 243e5a1d1..819128171 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -4,70 +4,72 @@ // https://on.cypress.io/custom-commands // *********************************************** -import { Eip1193Bridge } from '@ethersproject/experimental/lib/eip1193-bridge' -import { JsonRpcProvider } from '@ethersproject/providers' -import { Wallet } from '@ethersproject/wallet' +import { Eip1193Bridge } from '@ethersproject/experimental/lib/eip1193-bridge'; +import { JsonRpcProvider } from '@ethersproject/providers'; +import { Wallet } from '@ethersproject/wallet'; // todo: figure out how env vars actually work in CI // const TEST_PRIVATE_KEY = Cypress.env('INTEGRATION_TEST_PRIVATE_KEY') -const TEST_PRIVATE_KEY = '0xad20c82497421e9784f18460ad2fe84f73569068e98e270b3e63743268af5763' +const TEST_PRIVATE_KEY = + '0xad20c82497421e9784f18460ad2fe84f73569068e98e270b3e63743268af5763'; // address of the above key -export const TEST_ADDRESS_NEVER_USE = new Wallet(TEST_PRIVATE_KEY).address +export const TEST_ADDRESS_NEVER_USE = new Wallet(TEST_PRIVATE_KEY).address; export const TEST_ADDRESS_NEVER_USE_SHORTENED = `${TEST_ADDRESS_NEVER_USE.substr( 0, - 6 -)}...${TEST_ADDRESS_NEVER_USE.substr(-4, 4)}` + 6, +)}...${TEST_ADDRESS_NEVER_USE.substr(-4, 4)}`; class CustomizedBridge extends Eip1193Bridge { - chainId = 80001 + chainId = 80001; async sendAsync(...args) { - console.debug('sendAsync called', ...args) - return this.send(...args) + console.debug('sendAsync called', ...args); + return this.send(...args); } async send(...args) { - console.debug('send called', ...args) - const isCallbackForm = typeof args[0] === 'object' && typeof args[1] === 'function' - let callback - let method - let params + console.debug('send called', ...args); + const isCallbackForm = + typeof args[0] === 'object' && typeof args[1] === 'function'; + let callback; + let method; + let params; if (isCallbackForm) { - callback = args[1] - method = args[0].method - params = args[0].params + callback = args[1]; + method = args[0].method; + params = args[0].params; } else { - method = args[0] - params = args[1] + method = args[0]; + params = args[1]; } if (method === 'eth_requestAccounts' || method === 'eth_accounts') { if (isCallbackForm) { - callback({ result: [TEST_ADDRESS_NEVER_USE] }) + callback({ result: [TEST_ADDRESS_NEVER_USE] }); } else { - return Promise.resolve([TEST_ADDRESS_NEVER_USE]) + return Promise.resolve([TEST_ADDRESS_NEVER_USE]); } } if (method === 'eth_chainId') { if (isCallbackForm) { - callback(null, { result: '0x4' }) + callback(null, { result: '0x4' }); } else { - return Promise.resolve('0x4') + return Promise.resolve('0x4'); } } try { - const result = await super.send(method, params) - console.debug('result received', method, params, result) + const result = await super.send(method, params); + console.debug('result received', method, params, result); if (isCallbackForm) { - callback(null, { result }) + callback(null, { result }); } else { - return result + return result; } } catch (error) { if (isCallbackForm) { - callback(error, null) + callback(error, null); } else { - throw error + throw error; } } } @@ -76,14 +78,22 @@ class CustomizedBridge extends Eip1193Bridge { // sets up the injected provider to be a mock ethereum provider with the given mnemonic/index // eslint-disable-next-line no-undef Cypress.Commands.overwrite('visit', (original, url, options) => { - return original(url.startsWith('/') && url.length > 2 && !url.startsWith('/#') ? `/#${url}` : url, { - ...options, - onBeforeLoad(win) { - options && options.onBeforeLoad && options.onBeforeLoad(win) - win.localStorage.clear() - const provider = new JsonRpcProvider('https://rpc-mumbai.matic.today', 80001) - const signer = new Wallet(TEST_PRIVATE_KEY, provider) - win.ethereum = new CustomizedBridge(signer, provider) + return original( + url.startsWith('/') && url.length > 2 && !url.startsWith('/#') + ? `/#${url}` + : url, + { + ...options, + onBeforeLoad(win) { + options && options.onBeforeLoad && options.onBeforeLoad(win); + win.localStorage.clear(); + const provider = new JsonRpcProvider( + 'https://rpc-mumbai.matic.today', + 80001, + ); + const signer = new Wallet(TEST_PRIVATE_KEY, provider); + win.ethereum = new CustomizedBridge(signer, provider); + }, }, - }) -}) \ No newline at end of file + ); +}); diff --git a/cypress/support/index.js b/cypress/support/index.js index 3d834ebd4..1c85b1e96 100644 --- a/cypress/support/index.js +++ b/cypress/support/index.js @@ -6,4 +6,4 @@ // *********************************************************** // Import commands.ts using ES2015 syntax: -import './commands' +import './commands'; diff --git a/public/index.html b/public/index.html index 9c7b0d99a..a48cfbd8a 100755 --- a/public/index.html +++ b/public/index.html @@ -17,6 +17,19 @@ +