90f72e05b9
* init refactor * upgrade to 3.2.6 and refactor more uses of chainid * cleaned up lock file * remove console log and add placeholder * use supported chains type for switch fn * allow passing of all chainIds to switcher * additional typecast * better casting solution * yarn.lock cleanup * prettier * better casting for rpc * prettier * deprecate no longer needed addresses * better isSupported checking * deprecate redundant fn * cleanup toSupportedChainId * address initial ocmments * pretier * includes testnet * remove unused export * merge conflicts * spread for mutable copy * explorer text * check is supported before activating chain * remove extra uses of mumbai * remove cast to MockChainId * retain var name supportedChainId * updated prettier * use t for explorer translation * use mockchainid for test * feat: Add Avalanche support (#6776) * init avax * add most avax props * add logo * correct subgraph * update avax blocksPerFetch * add square logo * upgrade ur sdk * version syntax * correct tokens * remove unused token * remove unused token * update token list and add coming soon to searchbar * add coming soon to token explore page * names to ids * cleaned up routing * usdc token * upgrade default token list * update SOR * upgrade SOR * merge conflicts * snowtrace * upgrade SOR * handle be avax support * temp hide avax * show pool positions * whole * spotprice update * not yet supported * BACKEND_SUPPORTED_CHAINS * add avax to BE not supported * update multicall blocks to 5 * add todo * updated prettier --------- Co-authored-by: Charles Bachmeier <charlie@genie.xyz> * be added avax token balances * validateUrlChainParam should return eth for backend unsupported chain * readonly * respond to comments --------- Co-authored-by: Charles Bachmeier <charlie@genie.xyz>
73 lines
2.2 KiB
TypeScript
73 lines
2.2 KiB
TypeScript
/**
|
|
* Updates cy.visit() to include an injected window.ethereum provider.
|
|
*/
|
|
|
|
import { Eip1193Bridge } from '@ethersproject/experimental/lib/eip1193-bridge'
|
|
import { JsonRpcProvider } from '@ethersproject/providers'
|
|
import { Wallet } from '@ethersproject/wallet'
|
|
import { ChainId } from '@uniswap/sdk-core'
|
|
|
|
// todo: figure out how env vars actually work in CI
|
|
// const TEST_PRIVATE_KEY = Cypress.env('INTEGRATION_TEST_PRIVATE_KEY')
|
|
const TEST_PRIVATE_KEY = '0xe580410d7c37d26c6ad1a837bbae46bc27f9066a466fb3a66e770523b4666d19'
|
|
|
|
// address of the above key
|
|
const TEST_ADDRESS_NEVER_USE = new Wallet(TEST_PRIVATE_KEY).address
|
|
const CHAIN_ID = ChainId.GOERLI
|
|
const HEXLIFIED_CHAIN_ID = `0x${CHAIN_ID.toString(16)}`
|
|
|
|
const provider = new JsonRpcProvider('https://goerli.infura.io/v3/4bf032f2d38a4ed6bb975b80d6340847', 5)
|
|
const signer = new Wallet(TEST_PRIVATE_KEY, provider)
|
|
export const injected = new (class extends Eip1193Bridge {
|
|
chainId = CHAIN_ID
|
|
|
|
async sendAsync(...args: any[]) {
|
|
console.debug('sendAsync called', ...args)
|
|
return this.send(...args)
|
|
}
|
|
async send(...args: any[]) {
|
|
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
|
|
} else {
|
|
method = args[0]
|
|
params = args[1]
|
|
}
|
|
if (method === 'eth_requestAccounts' || method === 'eth_accounts') {
|
|
if (isCallbackForm) {
|
|
callback({ result: [TEST_ADDRESS_NEVER_USE] })
|
|
} else {
|
|
return Promise.resolve([TEST_ADDRESS_NEVER_USE])
|
|
}
|
|
}
|
|
if (method === 'eth_chainId') {
|
|
if (isCallbackForm) {
|
|
callback(null, { result: HEXLIFIED_CHAIN_ID })
|
|
} else {
|
|
return Promise.resolve(HEXLIFIED_CHAIN_ID)
|
|
}
|
|
}
|
|
try {
|
|
const result = await super.send(method, params)
|
|
console.debug('result received', method, params, result)
|
|
if (isCallbackForm) {
|
|
callback(null, { result })
|
|
} else {
|
|
return result
|
|
}
|
|
} catch (error) {
|
|
if (isCallbackForm) {
|
|
callback(error, null)
|
|
} else {
|
|
throw error
|
|
}
|
|
}
|
|
}
|
|
})(signer, provider)
|