Skip to content

Commit

Permalink
Merge pull request #49 from AstraProtocol/dev
Browse files Browse the repository at this point in the history
feat: merge main
  • Loading branch information
Tien Dao authored Jul 24, 2023
2 parents 339a891 + bee6cfd commit b36bd54
Show file tree
Hide file tree
Showing 73 changed files with 1,241 additions and 1,131 deletions.
15 changes: 15 additions & 0 deletions .env-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
NEXT_PUBLIC_CHAIN_ID=11115
NEXT_PUBLIC_NODE_1=https://rpc.astranaut.dev
NEXT_PUBLIC_NODE_2=https://rpc.astranaut.dev
NEXT_PUBLIC_NODE_3=https://rpc.astranaut.dev
NEXT_PUBLIC_NODE_PRODUCTION=https://rpc.astranaut.dev
NEXT_PUBLIC_HOST=http://localhost:3000
NEXT_PUBLIC_EXPLORER=https://explorer.astranaut.dev
NEXT_PUBLIC_GTAG=
NEXT_PUBLIC_FEE=100
NEXT_PUBLIC_TITLE=SolarSwap
NEXT_PUBLIC_WALLET_CONNECT_RELAY=wc-relay.astranaut.dev
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=af3dd8c81db591806b87e9dbdd42d470
NEXT_PUBLIC_DEFAULT_OUTPUT_CURRENCY=0x2039A56173fDac411975Bce6F756059Ac33d0d79
NEXT_PUBLIC_GN_INFO_CLIENT=https://graph-node.astranaut.dev/subgraphs/name/solarswap/exchange-v1
NEXT_PUBLIC_GN_BLOCK_CLIENT=https://graph-node.astranaut.dev/subgraphs/name/solarswap/blocks-v1
15 changes: 15 additions & 0 deletions .env-prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
NEXT_PUBLIC_CHAIN_ID=11110
NEXT_PUBLIC_NODE_1=https://rpc.astranaut.io
NEXT_PUBLIC_NODE_2=https://rpc.astranaut.io
NEXT_PUBLIC_NODE_3=https://rpc.astranaut.io
NEXT_PUBLIC_NODE_PRODUCTION=https://rpc.astranaut.io
NEXT_PUBLIC_HOST=http://localhost:3000
NEXT_PUBLIC_EXPLORER=https://explorer.astranaut.io
NEXT_PUBLIC_GTAG=
NEXT_PUBLIC_FEE=100
NEXT_PUBLIC_TITLE=SolarSwap
NEXT_PUBLIC_WALLET_CONNECT_RELAY=wc-relay.astranaut.io
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=af3dd8c81db591806b87e9dbdd42d470
NEXT_PUBLIC_DEFAULT_OUTPUT_CURRENCY=0xa0161089652A33eeA83168dCd74287E58b390910
NEXT_PUBLIC_GN_INFO_CLIENT=https://graph-node.astranaut.io/subgraphs/name/solarswap/exchange-v1
NEXT_PUBLIC_GN_BLOCK_CLIENT=https://graph-node.astranaut.io/subgraphs/name/solarswap/blocks-v1
32 changes: 30 additions & 2 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,42 @@
import { defineConfig } from 'cypress'
import { ChainId } from '@solarswap/sdk'
require('dotenv').config()

const CHAIN_ID = process.env.NEXT_PUBLIC_CHAIN_ID

export default defineConfig({
fixturesFolder: false,
video: false,
defaultCommandTimeout: 10000,
defaultCommandTimeout: 20000,
chromeWebSecurity: false,
pageLoadTimeout: 10000,
pageLoadTimeout: 20000,
projectId: 'qjg2v4',
blockHosts: ['vitals.vercel-insights.com', '*sentry.io', '*googletagmanager.com'],

env: {
...process.env,
WASA:
CHAIN_ID === ChainId.MAINNET.toString()
? '0xEAd8b0094072CAAa333DD2Ca72E5856f808e83Cf'
: '0xA625BF1c3565775B1859B579DF980Fef324E7315',
USDT:
CHAIN_ID === ChainId.MAINNET.toString()
? '0xa0161089652A33eeA83168dCd74287E58b390910'
: '0x2039A56173fDac411975Bce6F756059Ac33d0d79',
TNT:
CHAIN_ID === ChainId.MAINNET.toString()
? '0x65136E09653713dCFDda550aD29E9b20E4a457C7'
: '0xEC846C99BB9Cb375DeC6c6E07DA0F35258F22548',
TNT2:
CHAIN_ID === ChainId.MAINNET.toString()
? '0x5e7311ce6E87D023751F073005555193b4Ef83F7'
: '0xe65585B6Aa50f27d8C8aFac544c01d8668850f21',
BUSD:
CHAIN_ID === ChainId.MAINNET.toString()
? '0xAc948B5E841Ba4207a681331d646577240c7fcA8'
: '0x092d93f258ceea20c94ba01e8771115141dd7c20',
},

retries: {
runMode: 2,
},
Expand Down
114 changes: 40 additions & 74 deletions cypress/e2e/exchange/add-liquidity.cy.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
import { ChainId } from '@solarswap/sdk'

describe('Add Liquidity', () => {
const HOST = 'http://localhost:3000'

/**
* Use contracts:
* WASA: 0xA625BF1c3565775B1859B579DF980Fef324E7315
* USDT: 0x2039A56173fDac411975Bce6F756059Ac33d0d79
* TNT: 0xEC846C99BB9Cb375DeC6c6E07DA0F35258F22548
* TNT2: 0xe65585B6Aa50f27d8C8aFac544c01d8668850f21
*/
const WASA = Cypress.env('WASA')
const USDT = Cypress.env('USDT')
const TNT = Cypress.env('TNT')
const TNT2 = Cypress.env('TNT2')

/** Normal Add Liquidity */

it('loads the two correct tokens', () => {
cy.visit(`${HOST}/add/0x2039A56173fDac411975Bce6F756059Ac33d0d79/0xEC846C99BB9Cb375DeC6c6E07DA0F35258F22548`)
cy.visit(`${HOST}/add/${USDT}/${TNT}`)
cy.get('#add-liquidity-input-tokena #pair').should('contain.text', 'USDT')
cy.get('#add-liquidity-input-tokenb #pair').should('contain.text', 'TNT')
})

it('loads the ASA and tokens', () => {
cy.visit(`${HOST}/add/ASA/0x2039A56173fDac411975Bce6F756059Ac33d0d79`)
cy.visit(`${HOST}/add/ASA/${USDT}`)
cy.get('#add-liquidity-input-tokena #pair').should('contain.text', 'ASA')
cy.get('#add-liquidity-input-tokenb #pair').should('contain.text', 'USDT')
})

it('loads the WASA and tokens', () => {
cy.visit(`${HOST}/add/0xA625BF1c3565775B1859B579DF980Fef324E7315/0xEC846C99BB9Cb375DeC6c6E07DA0F35258F22548`)
cy.visit(`${HOST}/add/${WASA}/${TNT}`)
cy.get('#add-liquidity-input-tokena #pair').should('contain.text', 'WASA')
cy.get('#add-liquidity-input-tokenb #pair').should('contain.text', 'TNT')
})
Expand All @@ -36,80 +34,67 @@ describe('Add Liquidity', () => {
})

it('does not crash if address is duplicated', () => {
cy.visit(`${HOST}/add/0xEC846C99BB9Cb375DeC6c6E07DA0F35258F22548/0xEC846C99BB9Cb375DeC6c6E07DA0F35258F22548`)
cy.visit(`${HOST}/add/${TNT}/${TNT}`)
cy.get('#add-liquidity-input-tokena #pair').should('contain.text', 'TNT')
cy.get('#add-liquidity-input-tokenb #pair').should('not.contain.text', 'TNT')
})

it('token not in storage is loaded', () => {
cy.visit(`${HOST}/add/0xe65585B6Aa50f27d8C8aFac544c01d8668850f21/0xEC846C99BB9Cb375DeC6c6E07DA0F35258F22548`)
cy.visit(`${HOST}/add/${TNT2}/${TNT}`)
cy.get('#add-liquidity-input-tokena #pair').should('contain.text', 'TNT2')
cy.get('#add-liquidity-input-tokenb #pair').should('contain.text', 'TNT')
})

it('single token can be selected', () => {
cy.visit(`${HOST}/add/0xe65585B6Aa50f27d8C8aFac544c01d8668850f21`)
cy.visit(`${HOST}/add/${TNT2}`)
cy.get('#add-liquidity-input-tokena #pair').should('contain.text', 'TNT2')
cy.visit(`${HOST}/add/0x2039A56173fDac411975Bce6F756059Ac33d0d79`)
cy.visit(`${HOST}/add/${USDT}`)
cy.get('#add-liquidity-input-tokena #pair').should('contain.text', 'USDT')
cy.visit(`${HOST}/add/ASA`)
cy.get('#add-liquidity-input-tokena #pair').should('contain.text', 'ASA')
})

it('redirects /add/token-token to add/token/token', () => {
cy.visit(`${HOST}/add/0xEC846C99BB9Cb375DeC6c6E07DA0F35258F22548-0x2039A56173fDac411975Bce6F756059Ac33d0d79`)
cy.url().should(
'contain',
'/add/0xEC846C99BB9Cb375DeC6c6E07DA0F35258F22548/0x2039A56173fDac411975Bce6F756059Ac33d0d79',
)
cy.visit(`${HOST}/add/${TNT}-${USDT}`)
cy.url().should('contain', `/add/${TNT}/${USDT}`)
})

it('redirects /add/ASA-token to /add/ASA/token', () => {
cy.visit(`${HOST}/add/ASA-0x2039A56173fDac411975Bce6F756059Ac33d0d79`)
cy.url().should('contain', '/add/ASA/0x2039A56173fDac411975Bce6F756059Ac33d0d79')
cy.visit(`${HOST}/add/ASA-${USDT}`)
cy.url().should('contain', `/add/ASA/${USDT}`)
})

it('redirects /add/token-ASA to /add/token/ASA', () => {
cy.visit(`${HOST}/add/0x2039A56173fDac411975Bce6F756059Ac33d0d79-ASA`)
cy.url().should('contain', '/add/0x2039A56173fDac411975Bce6F756059Ac33d0d79/ASA')
cy.visit(`${HOST}/add/${USDT}-ASA`)
cy.url().should('contain', `/add/${USDT}/ASA`)
})

it('redirects /add/WASA-token to /add/WASA/token', () => {
cy.visit(`${HOST}/add/0xA625BF1c3565775B1859B579DF980Fef324E7315-0xEC846C99BB9Cb375DeC6c6E07DA0F35258F22548`)
cy.url().should(
'contain',
'/add/0xA625BF1c3565775B1859B579DF980Fef324E7315/0xEC846C99BB9Cb375DeC6c6E07DA0F35258F22548',
)
cy.visit(`${HOST}/add/${WASA}-${TNT}`)
cy.url().should('contain', `/add/${WASA}/${TNT}`)
})

it('redirects /add/token-WASA to /add/token/WASA', () => {
cy.visit(`${HOST}/add/0xEC846C99BB9Cb375DeC6c6E07DA0F35258F22548-0xA625BF1c3565775B1859B579DF980Fef324E7315`)
cy.url().should(
'contain',
'/add/0xEC846C99BB9Cb375DeC6c6E07DA0F35258F22548/0xA625BF1c3565775B1859B579DF980Fef324E7315',
)
cy.visit(`${HOST}/add/${TNT}-${WASA}`)
cy.url().should('contain', `/add/${TNT}/${WASA}`)
})

/** Single-sided Add Liquidity */

it('Single-sided - loads the two correct tokens', () => {
cy.visit(
`${HOST}/add-single/0x2039A56173fDac411975Bce6F756059Ac33d0d79/0xEC846C99BB9Cb375DeC6c6E07DA0F35258F22548`,
)
cy.visit(`${HOST}/add-single/${USDT}/${TNT}`)
cy.get('#add-liquidity-input-tokena #pair').should('contain.text', 'USDT')
cy.get('#add-liquidity-input-tokenb #pair').should('contain.text', 'TNT')
})

it('Single-sided - loads the ASA and tokens', () => {
cy.visit(`${HOST}/add-single/ASA/0x2039A56173fDac411975Bce6F756059Ac33d0d79`)
cy.visit(`${HOST}/add-single/ASA/${USDT}`)
cy.get('#add-liquidity-input-tokena #pair').should('contain.text', 'ASA')
cy.get('#add-liquidity-input-tokenb #pair').should('contain.text', 'USDT')
})

it('Single-sided - loads the WASA and tokens', () => {
cy.visit(
`${HOST}/add-single/0xA625BF1c3565775B1859B579DF980Fef324E7315/0xEC846C99BB9Cb375DeC6c6E07DA0F35258F22548`,
)
cy.visit(`${HOST}/add-single/${WASA}/${TNT}`)
cy.get('#add-liquidity-input-tokena #pair').should('contain.text', 'WASA')
cy.get('#add-liquidity-input-tokenb #pair').should('contain.text', 'TNT')
})
Expand All @@ -121,67 +106,48 @@ describe('Add Liquidity', () => {
})

it('Single-sided - does not crash if address is duplicated', () => {
cy.visit(
`${HOST}/add-single/0xEC846C99BB9Cb375DeC6c6E07DA0F35258F22548/0xEC846C99BB9Cb375DeC6c6E07DA0F35258F22548`,
)
cy.visit(`${HOST}/add-single/${TNT}/${TNT}`)
cy.get('#add-liquidity-input-tokena #pair').should('contain.text', 'TNT')
cy.get('#add-liquidity-input-tokenb #pair').should('not.contain.text', 'TNT')
})

it('Single-sided - token not in storage is loaded', () => {
cy.visit(
`${HOST}/add-single/0xe65585B6Aa50f27d8C8aFac544c01d8668850f21/0xEC846C99BB9Cb375DeC6c6E07DA0F35258F22548`,
)
cy.visit(`${HOST}/add-single/${TNT2}/${TNT}`)
cy.get('#add-liquidity-input-tokena #pair').should('contain.text', 'TNT2')
cy.get('#add-liquidity-input-tokenb #pair').should('contain.text', 'TNT')
})

it('Single-sided - single token can be selected', () => {
cy.visit(`${HOST}/add-single/0xe65585B6Aa50f27d8C8aFac544c01d8668850f21`)
cy.visit(`${HOST}/add-single/${TNT2}`)
cy.get('#add-liquidity-input-tokena #pair').should('contain.text', 'TNT2')
cy.visit(`${HOST}/add-single/0x2039A56173fDac411975Bce6F756059Ac33d0d79`)
cy.visit(`${HOST}/add-single/${USDT}`)
cy.get('#add-liquidity-input-tokena #pair').should('contain.text', 'USDT')
cy.visit(`${HOST}/add-single/ASA`)
cy.get('#add-liquidity-input-tokena #pair').should('contain.text', 'ASA')
})

it('Single-sided - redirects /add-single/token-token to add-single/token/token', () => {
cy.visit(
`${HOST}/add-single/0xEC846C99BB9Cb375DeC6c6E07DA0F35258F22548-0x2039A56173fDac411975Bce6F756059Ac33d0d79`,
)
cy.url().should(
'contain',
'/add/0xEC846C99BB9Cb375DeC6c6E07DA0F35258F22548/0x2039A56173fDac411975Bce6F756059Ac33d0d79',
)
cy.visit(`${HOST}/add-single/${TNT}-${USDT}`)
cy.url().should('contain', `/add/${TNT}/${USDT}`)
})

it('Single-sided - redirects /add-single/ASA-token to /add-single/ASA/token', () => {
cy.visit(`${HOST}/add-single/ASA-0x2039A56173fDac411975Bce6F756059Ac33d0d79`)
cy.url().should('contain', '/add-single/ASA/0x2039A56173fDac411975Bce6F756059Ac33d0d79')
cy.visit(`${HOST}/add-single/ASA-${USDT}`)
cy.url().should('contain', `/add-single/ASA/${USDT}`)
})

it('Single-sided - redirects /add-single/token-ASA to /add-single/token/ASA', () => {
cy.visit(`${HOST}/add-single/0x2039A56173fDac411975Bce6F756059Ac33d0d79-ASA`)
cy.url().should('contain', '/add-single/0x2039A56173fDac411975Bce6F756059Ac33d0d79/ASA')
cy.visit(`${HOST}/add-single/${USDT}-ASA`)
cy.url().should('contain', `/add-single/${USDT}/ASA`)
})

it('Single-sided - redirects /add-single/WASA-token to /add-single/WASA/token', () => {
cy.visit(
`${HOST}/add-single/0xA625BF1c3565775B1859B579DF980Fef324E7315-0xEC846C99BB9Cb375DeC6c6E07DA0F35258F22548`,
)
cy.url().should(
'contain',
'/add/0xA625BF1c3565775B1859B579DF980Fef324E7315/0xEC846C99BB9Cb375DeC6c6E07DA0F35258F22548',
)
cy.visit(`${HOST}/add-single/${WASA}-${TNT}`)
cy.url().should('contain', `/add/${WASA}/${TNT}`)
})

it('Single-sided - redirects /add-single/token-WASA to /add-single/token/WASA', () => {
cy.visit(
`${HOST}/add-single/0xEC846C99BB9Cb375DeC6c6E07DA0F35258F22548-0xA625BF1c3565775B1859B579DF980Fef324E7315`,
)
cy.url().should(
'contain',
'/add/0xEC846C99BB9Cb375DeC6c6E07DA0F35258F22548/0xA625BF1c3565775B1859B579DF980Fef324E7315',
)
cy.visit(`${HOST}/add-single/${TNT}-${WASA}`)
cy.url().should('contain', `/add/${TNT}/${WASA}`)
})
})
2 changes: 1 addition & 1 deletion cypress/e2e/exchange/liquidity.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('Pool', () => {
const HOST = 'http://localHOST:3000'
const HOST = 'http://localhost:3000'

beforeEach(() => cy.visit(`${HOST}/liquidity`))
it('add liquidity links to /add/', () => {
Expand Down
8 changes: 5 additions & 3 deletions cypress/e2e/exchange/lists.cy.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { ChainId } from '@solarswap/sdk'

describe('Lists', () => {
const HOST = 'http://localhost:3000'
const busd = '0x092d93f258ceea20c94ba01e8771115141dd7c20'
const BUSD = Cypress.env('BUSD')
beforeEach(() => {
cy.visit(`${HOST}/swap`)
})

it('import token from url', () => {
// Visit url
cy.visit(`${HOST}/swap?inputCurrency=${busd}&outputCurrency=ASA`)
cy.visit(`${HOST}/swap?inputCurrency=${BUSD}&outputCurrency=ASA`)

// Modal confirm
cy.get('#import-token-understand').click()
Expand All @@ -17,7 +19,7 @@ describe('Lists', () => {

it('import token', () => {
cy.get('#swap-currency-output .open-currency-select-button').click()
cy.get('#token-search-input').type(busd)
cy.get('#token-search-input').type(BUSD)
cy.get('.token-search-import-button').click()

// Modal confirm
Expand Down
Loading

0 comments on commit b36bd54

Please sign in to comment.