diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index facd3bb8..cb6308ae 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -101,15 +101,14 @@ jobs: - CIDv0: `${{ steps.upload.outputs.hash }}` - CIDv1: `${{ steps.convert_cidv0.outputs.cidv1 }}` - The latest release is always accessible via our alias to the Cloudflare IPFS gateway at [app.reflexer.finance](https://app.reflexer.finance). + The latest release is always accessible via our alias to the Cloudflare at [app.reflexer.finance](https://app.reflexer.finance). You can also access the Reflexer app directly from an IPFS gateway. **BEWARE**: The Reflexer app uses [`localStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) to remember your settings, such as transactions hashes. - **You should always use an IPFS gateway that enforces origin separation**, or our alias to the latest release at [ipfs.reflexer.finance](https://ipfs.reflexer.finance). + **You should always use an IPFS gateway that enforces origin separation**, or our alias to the latest release IPFS gateways: - https://${{ steps.convert_cidv0.outputs.cidv1 }}.ipfs.dweb.link/ - - https://${{ steps.convert_cidv0.outputs.cidv1 }}.ipfs.cf-ipfs.com/ - [ipfs://${{ steps.upload.outputs.hash }}/](ipfs://${{ steps.upload.outputs.hash }}/) ${{ needs.bump_version.outputs.changelog }} diff --git a/README.md b/README.md index 1c1689e1..4b64f9c4 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ Deposit your crypto assets, generate RAI and lever up your position. - Website: [reflexer.finance](https://reflexer.finance/) - App: [app.reflexer.finance](https://app.reflexer.finance) - Analytics: [stats.reflexer.finance](https://stats.reflexer.finance/) +- Tokenomics: [tokenomics.reflexer.finance](https://tokenomics.reflexer.finance/) - Docs: [docs.reflexer.finance](https://docs.reflexer.finance/) - Twitter: [@reflexerfinance](https://twitter.com/reflexerfinance) - Discord: [Reflexer](https://discord.com/invite/83t3xKT) @@ -20,7 +21,7 @@ Deposit your crypto assets, generate RAI and lever up your position. ## Accessing the Uniswap Interface -To access the Uniswap Interface, use an IPFS gateway link from the +To access the Reflexer Interface, use an IPFS gateway link from the [latest release](https://github.com/reflexer-labs/geb-app/releases/latest), or visit [https://app.reflexer.finance](https://app.reflexer.finance). @@ -47,6 +48,7 @@ To have the app default to a different network when a wallet is not connected: 2. Change `REACT_APP_NETWORK_ID` to `"42"` 3. Change `REACT_APP_NETWORK_URL` to e.g. `"https://kovan.infura.io/v3/{YOUR_INFURA_KEY}"` 4. Change `REACT_APP_COIN_TICKER_STAGING` to `"RAI"` +4. Change `REACT_APP_SHOW_AUCTIONS` to `"1"` ## Testing diff --git a/cypress/integration/landing-no-proxy.test.ts b/cypress/integration/landing-no-proxy.test.ts index fb0f0e88..c9b89d6c 100644 --- a/cypress/integration/landing-no-proxy.test.ts +++ b/cypress/integration/landing-no-proxy.test.ts @@ -12,7 +12,7 @@ describe('App Page - No Proxy', () => { cy.visit('/', { qs: { type: 'no_proxy' }, }) - cy.wait(2000) + cy.wait(5000) cy.get('body').then((body) => { if (body.find('[data-test-id="waiting-modal"]').length > 0) { cy.get('[data-test-id="waiting-modal"]').then((e) => { @@ -47,7 +47,7 @@ describe('App Page - No Proxy', () => { cy.get('#step1 > div').contains('Create Account') cy.contains('✓ Accept').click() cy.get('[data-test-id="steps-btn"]').contains('Create Account').click() - cy.wait(2000) + cy.wait(5000) cy.contains('Transaction Failed').should('be.visible') cy.contains('Dismiss').should('be.visible') }) diff --git a/cypress/integration/landing-no-safes.test.ts b/cypress/integration/landing-no-safes.test.ts index e62d4034..f7d2450f 100644 --- a/cypress/integration/landing-no-safes.test.ts +++ b/cypress/integration/landing-no-safes.test.ts @@ -11,7 +11,7 @@ describe('App Page - No Safes', () => { cy.visit('/', { qs: { type: 'no_safes' }, }) - cy.wait(2000) + cy.wait(5000) cy.get('body').then((body) => { if (body.find('[data-test-id="waiting-modal"]').length > 0) { cy.get('[data-test-id="waiting-modal"]').then((e) => { @@ -41,14 +41,14 @@ describe('App Page - No Safes', () => { cy.contains('✓ Accept').click() cy.get('#step2 > div').contains('Create a Safe') cy.get('[data-test-id="steps-btn"]').contains('Create a Safe').click() - cy.wait(2000) + cy.wait(5000) cy.url().should('include', 'create') }) it('creates a new safe', () => { cy.contains('✓ Accept').click() cy.get('[data-test-id="steps-btn"]').contains('Create a Safe').click() - cy.wait(2000) + cy.wait(5000) cy.url().should('include', 'create') cy.get('[data-test-id="deposit_borrow"]').type('4') cy.get('[data-test-id="repay_withdraw"]').type('1000') diff --git a/cypress/integration/landing-safes.test.ts b/cypress/integration/landing-safes.test.ts index 0bb72c10..a310332a 100644 --- a/cypress/integration/landing-safes.test.ts +++ b/cypress/integration/landing-safes.test.ts @@ -8,7 +8,7 @@ import { describe('App Page - Has Safes', () => { beforeEach(() => { cy.visit('/') - cy.wait(2000) + cy.wait(5000) cy.get('body').then((body) => { if (body.find('[data-test-id="waiting-modal"]').length > 0) { cy.get('[data-test-id="waiting-modal"]').then((e) => { diff --git a/cypress/integration/safe-details.test.ts b/cypress/integration/safe-details.test.ts index 3900f719..88897e2e 100644 --- a/cypress/integration/safe-details.test.ts +++ b/cypress/integration/safe-details.test.ts @@ -10,7 +10,7 @@ describe('App Page - Safe Details', () => { beforeEach(() => { cy.visit('/') - cy.wait(2000) + cy.wait(5000) cy.get('body').then((body) => { if (body.find('[data-test-id="waiting-modal"]').length > 0) { cy.get('[data-test-id="waiting-modal"]').then((e) => { @@ -24,7 +24,7 @@ describe('App Page - Safe Details', () => { }) cy.contains('✓ Accept').click() cy.get('.safeBlock').first().click() - cy.wait(2000) + cy.wait(5000) cy.get('body').then((body) => { if (body.find('[data-test-id="waiting-modal"]').length > 0) { cy.get('[data-test-id="waiting-modal"]').then((e) => { @@ -61,7 +61,7 @@ describe('App Page - Safe Details', () => { cy.get('[data-test-id="deposit_borrow_right"]').type( getValue(tx) ) - cy.wait(2000) + cy.wait(5000) cy.contains('140.00%') }) }) @@ -131,7 +131,7 @@ describe('App Page - Safe Details', () => { () => Cypress.$(e).text() === 'Transaction Submitted', { timeout: 100000, - interval: 2000, + interval: 5000, } ) ) @@ -154,7 +154,7 @@ describe('App Page - Safe Details', () => { () => Cypress.$(e).text() === 'Transaction Submitted', { timeout: 100000, - interval: 2000, + interval: 5000, } ) ) diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index de99d804..7241518a 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -139,6 +139,12 @@ const returnWallet = (type: string) => { } } +Cypress.on('uncaught:exception', (err, runnable) => { + // returning false here prevents Cypress from + // failing the test + return false +}) + Cypress.Commands.overwrite('visit', (original, url, options) => { const { privateKey, walletAddress, allowTx } = returnWallet( options && options.qs ? options.qs.type : '' diff --git a/package.json b/package.json index 5c754666..e360e3a4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "geb-app", "version": "0.1.0", - "homepage": "./", + "homepage": ".", "private": true, "dependencies": { "@ethersproject/address": "^5.0.10", @@ -54,14 +54,15 @@ "react-transition-group": "^4.4.1", "styled-components": "^5.2.0", "typescript": "3.8.3", - "walletlink": "^2.1.0" + "walletlink": "^2.1.0", + "web3-react-types": "npm:@web3-react/types@^6.0.7" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", "prettier": "prettier --write \"{,**/*.{ts,tsx,json,js,md}}\"", "test": "react-scripts test", - "test:e2e": "start-server-and-test start http://localhost:3000 'cypress run'", + "test:e2e": "start-server-and-test 'serve build -l 3000' http://localhost:3000 'cypress run'", "eject": "react-scripts eject" }, "eslintConfig": { @@ -93,7 +94,7 @@ "@types/react-transition-group": "^4.4.0", "@types/styled-components": "^5.1.3", "crypto": "^1.0.1", - "cypress": "^6.4.0", + "cypress": "^7.7.0", "cypress-wait-until": "^1.7.1", "husky": "^5.0.9", "lint-staged": "^10.5.4", diff --git a/src/App.tsx b/src/App.tsx index ff4619ab..d43f772d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,29 +1,28 @@ import React, { Suspense, useEffect } from 'react' import i18next from 'i18next' -import { HashRouter as Router, Redirect, Route, Switch } from 'react-router-dom' +import { Redirect, Route, Switch } from 'react-router-dom' import { ThemeProvider } from 'styled-components' import { I18nextProvider } from 'react-i18next' import ErrorBoundary from './ErrorBoundary' import { useStoreState } from './store' import { darkTheme } from './utils/themes/dark' import { Theme } from './utils/interfaces' -import OnBoarding from './containers/OnBoarding' +import Safes from './containers/Safes' import { initI18n } from './utils/i18n' import GlobalStyle from './GlobalStyle' import Shared from './containers/Shared' import Web3ReactManager from './components/Web3ReactManager' -import SafeDetails from './containers/OnBoarding/SafeDetails' +import SafeDetails from './containers/Safes/SafeDetails' import Privacy from './containers/Privacy' import CustomToast from './components/CustomToast' import Auctions from './containers/Auctions' import GoogleTagManager from './components/Analytics/GoogleTagManager' import { SHOW_AUCTIONS } from './utils/constants' -import SafeSaviour from './containers/OnBoarding/Saviour/SafeSaviour' +import SafeSaviour from './containers/Safes/Saviour/SafeSaviour' import Staking from './containers/Earn/Staking' import Incentives from './containers/Earn/Incentives' -import CreateSafe from './containers/OnBoarding/CreateSafe' -// import MoneyGodLeague from './containers/Earn/MoneyGodLeague' +import CreateSafe from './containers/Safes/CreateSafe' // Toast css @@ -46,98 +45,90 @@ const App = () => { - - - - - - - {SHOW_AUCTIONS && - SHOW_AUCTIONS === '1' ? ( - - ) : null} + + + + + + {SHOW_AUCTIONS && SHOW_AUCTIONS === '1' ? ( - {/* */} - - - - - - - - - - - - - - - - + ) : null} + + + + + + + + + + + + + + + + + diff --git a/src/abis/Erc20.ts b/src/abis/Erc20.ts index 058fb6f3..9342fbae 100644 --- a/src/abis/Erc20.ts +++ b/src/abis/Erc20.ts @@ -16,7 +16,7 @@ import { } from 'ethers' import { FunctionFragment, Result, EventFragment } from '@ethersproject/abi' import { Listener, Provider } from '@ethersproject/providers' -import { TypedEventFilter, TypedEvent, TypedListener, OnEvent } from './common' +import { TypedEventFilter, TypedEvent, TypedListener } from './common' export interface Erc20Interface extends utils.Interface { functions: { @@ -81,45 +81,56 @@ export interface Erc20Interface extends utils.Interface { getEvent(nameOrSignatureOrTopic: 'Transfer'): EventFragment } -export type ApprovalEvent = TypedEvent< +export type ApprovalEventFilter = TypedEventFilter< [string, string, BigNumber], - { owner: string; spender: string; value: BigNumber } + { from: string; to: string; value: BigNumber } > -export type ApprovalEventFilter = TypedEventFilter - -export type TransferEvent = TypedEvent< +export type TransferEventFilter = TypedEventFilter< [string, string, BigNumber], { from: string; to: string; value: BigNumber } > -export type TransferEventFilter = TypedEventFilter - export interface Erc20 extends BaseContract { connect(signerOrProvider: Signer | Provider | string): this attach(addressOrName: string): this deployed(): Promise - interface: Erc20Interface - - queryFilter( - event: TypedEventFilter, - fromBlockOrBlockhash?: string | number | undefined, - toBlock?: string | number | undefined - ): Promise> + listeners, EventArgsObject>( + eventFilter?: TypedEventFilter + ): Array> + off, EventArgsObject>( + eventFilter: TypedEventFilter, + listener: TypedListener + ): this + on, EventArgsObject>( + eventFilter: TypedEventFilter, + listener: TypedListener + ): this + once, EventArgsObject>( + eventFilter: TypedEventFilter, + listener: TypedListener + ): this + removeListener, EventArgsObject>( + eventFilter: TypedEventFilter, + listener: TypedListener + ): this + removeAllListeners, EventArgsObject>( + eventFilter: TypedEventFilter + ): this - listeners( - eventFilter?: TypedEventFilter - ): Array> listeners(eventName?: string): Array - removeAllListeners( - eventFilter: TypedEventFilter - ): this + off(eventName: string, listener: Listener): this + on(eventName: string, listener: Listener): this + once(eventName: string, listener: Listener): this + removeListener(eventName: string, listener: Listener): this removeAllListeners(eventName?: string): this - off: OnEvent - on: OnEvent - once: OnEvent - removeListener: OnEvent + + queryFilter, EventArgsObject>( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>> functions: { name(overrides?: CallOverrides): Promise<[string]> diff --git a/src/abis/Multicall.ts b/src/abis/Multicall.ts new file mode 100644 index 00000000..3a8e3a99 --- /dev/null +++ b/src/abis/Multicall.ts @@ -0,0 +1,171 @@ +import { MulticallRequest } from '@reflexer-finance/geb-contract-base' +import { Provider, Listener } from '@ethersproject/providers' +import { BytesLike } from '@ethersproject/bytes' +import { BigNumberish } from '@ethersproject/bignumber' +import { BigNumber } from '@ethersproject/bignumber' +import { FunctionFragment, Result } from 'ethers/lib/utils' +import { + BaseContract, + ethers, + Signer, + CallOverrides, + ContractTransaction, + Overrides, +} from 'ethers' +import { TypedEvent, TypedEventFilter, TypedListener } from './common' + +export type CallStruct = { target: string; callData: BytesLike } + +export type CallStructOutput = [string, string] & { + target: string + callData: string +} + +interface MulticallInterface extends ethers.utils.Interface { + functions: { + 'getCurrentBlockTimestamp()': FunctionFragment + 'getEthBalance(address)': FunctionFragment + 'multicall(tuple[])': FunctionFragment + } + + encodeFunctionData( + functionFragment: 'getCurrentBlockTimestamp', + values?: undefined + ): string + encodeFunctionData( + functionFragment: 'getEthBalance', + values: [string] + ): string + encodeFunctionData( + functionFragment: 'multicall', + values: [ + { target: string; gasLimit: BigNumberish; callData: BytesLike }[] + ] + ): string + + decodeFunctionResult( + functionFragment: 'getCurrentBlockTimestamp', + data: BytesLike + ): Result + decodeFunctionResult( + functionFragment: 'getEthBalance', + data: BytesLike + ): Result + decodeFunctionResult(functionFragment: 'multicall', data: BytesLike): Result + + events: {} +} + +export declare class Multicall extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this + attach(addressOrName: string): this + deployed(): Promise + + listeners, EventArgsObject>( + eventFilter?: TypedEventFilter + ): Array> + off, EventArgsObject>( + eventFilter: TypedEventFilter, + listener: TypedListener + ): this + on, EventArgsObject>( + eventFilter: TypedEventFilter, + listener: TypedListener + ): this + once, EventArgsObject>( + eventFilter: TypedEventFilter, + listener: TypedListener + ): this + removeListener, EventArgsObject>( + eventFilter: TypedEventFilter, + listener: TypedListener + ): this + removeAllListeners, EventArgsObject>( + eventFilter: TypedEventFilter + ): this + + listeners(eventName?: string): Array + off(eventName: string, listener: Listener): this + on(eventName: string, listener: Listener): this + once(eventName: string, listener: Listener): this + removeListener(eventName: string, listener: Listener): this + removeAllListeners(eventName?: string): this + + queryFilter, EventArgsObject>( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>> + interface: MulticallInterface + aggregate( + calls: { + target: string + callData: BytesLike + }[] + ): Promise<{ + blockNumber: BigNumber + returnData: string[] + }> + aggregate_readOnly( + calls: { + target: string + callData: BytesLike + }[] + ): Promise<{ + blockNumber: BigNumber + returnData: string[] + }> + aggregate_readOnly( + calls: { + target: string + callData: BytesLike + }[], + multicall: true + ): MulticallRequest<{ + blockNumber: BigNumber + returnData: string[] + }> + getBlockHash(blockNumber: BigNumberish): Promise + getBlockHash( + blockNumber: BigNumberish, + multicall: true + ): MulticallRequest + getCurrentBlockCoinbase(): Promise + getCurrentBlockCoinbase(multicall: true): MulticallRequest + getCurrentBlockDifficulty(): Promise + getCurrentBlockDifficulty(multicall: true): MulticallRequest + getCurrentBlockGasLimit(): Promise + getCurrentBlockGasLimit(multicall: true): MulticallRequest + getCurrentBlockTimestamp(): Promise + getCurrentBlockTimestamp(multicall: true): MulticallRequest + getEthBalance(addr: string): Promise + getEthBalance(addr: string, multicall: true): MulticallRequest + getLastBlockHash(): Promise + getLastBlockHash(multicall: true): MulticallRequest + functions: { + aggregate( + calls: CallStruct[], + overrides?: Overrides & { from?: string | Promise } + ): Promise + getCurrentBlockTimestamp( + overrides?: CallOverrides + ): Promise<[BigNumber] & { timestamp: BigNumber }> + getEthBalance( + addr: string, + overrides?: CallOverrides + ): Promise<[BigNumber] & { balance: BigNumber }> + } + callStatic: { + aggregate( + calls: CallStruct[], + overrides?: CallOverrides + ): Promise< + [BigNumber, string[]] & { + blockNumber: BigNumber + returnData: string[] + } + > + getCurrentBlockTimestamp(overrides?: CallOverrides): Promise + getEthBalance(addr: string): Promise + } +} diff --git a/src/abis/Multicall2.ts b/src/abis/Multicall2.ts deleted file mode 100644 index 863111bf..00000000 --- a/src/abis/Multicall2.ts +++ /dev/null @@ -1,428 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ -/* tslint:disable */ -/* eslint-disable */ -import { - BaseContract, - BigNumber, - BigNumberish, - BytesLike, - CallOverrides, - ContractTransaction, - Overrides, - PopulatedTransaction, - Signer, - utils, -} from "ethers"; -import { FunctionFragment, Result } from "@ethersproject/abi"; -import { Listener, Provider } from "@ethersproject/providers"; -import { TypedEventFilter, TypedEvent, TypedListener, OnEvent } from "./common"; - -export type CallStruct = { target: string; callData: BytesLike }; - -export type CallStructOutput = [string, string] & { - target: string; - callData: string; -}; - -export type ResultStruct = { success: boolean; returnData: BytesLike }; - -export type ResultStructOutput = [boolean, string] & { - success: boolean; - returnData: string; -}; - -export interface Multicall2Interface extends utils.Interface { - functions: { - "aggregate((address,bytes)[])": FunctionFragment; - "blockAndAggregate((address,bytes)[])": FunctionFragment; - "getBlockHash(uint256)": FunctionFragment; - "getBlockNumber()": FunctionFragment; - "getCurrentBlockCoinbase()": FunctionFragment; - "getCurrentBlockDifficulty()": FunctionFragment; - "getCurrentBlockGasLimit()": FunctionFragment; - "getCurrentBlockTimestamp()": FunctionFragment; - "getEthBalance(address)": FunctionFragment; - "getLastBlockHash()": FunctionFragment; - "tryAggregate(bool,(address,bytes)[])": FunctionFragment; - "tryBlockAndAggregate(bool,(address,bytes)[])": FunctionFragment; - }; - - encodeFunctionData( - functionFragment: "aggregate", - values: [CallStruct[]] - ): string; - encodeFunctionData( - functionFragment: "blockAndAggregate", - values: [CallStruct[]] - ): string; - encodeFunctionData( - functionFragment: "getBlockHash", - values: [BigNumberish] - ): string; - encodeFunctionData( - functionFragment: "getBlockNumber", - values?: undefined - ): string; - encodeFunctionData( - functionFragment: "getCurrentBlockCoinbase", - values?: undefined - ): string; - encodeFunctionData( - functionFragment: "getCurrentBlockDifficulty", - values?: undefined - ): string; - encodeFunctionData( - functionFragment: "getCurrentBlockGasLimit", - values?: undefined - ): string; - encodeFunctionData( - functionFragment: "getCurrentBlockTimestamp", - values?: undefined - ): string; - encodeFunctionData( - functionFragment: "getEthBalance", - values: [string] - ): string; - encodeFunctionData( - functionFragment: "getLastBlockHash", - values?: undefined - ): string; - encodeFunctionData( - functionFragment: "tryAggregate", - values: [boolean, CallStruct[]] - ): string; - encodeFunctionData( - functionFragment: "tryBlockAndAggregate", - values: [boolean, CallStruct[]] - ): string; - - decodeFunctionResult(functionFragment: "aggregate", data: BytesLike): Result; - decodeFunctionResult( - functionFragment: "blockAndAggregate", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "getBlockHash", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "getBlockNumber", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "getCurrentBlockCoinbase", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "getCurrentBlockDifficulty", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "getCurrentBlockGasLimit", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "getCurrentBlockTimestamp", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "getEthBalance", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "getLastBlockHash", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "tryAggregate", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "tryBlockAndAggregate", - data: BytesLike - ): Result; - - events: {}; -} - -export interface Multicall2 extends BaseContract { - connect(signerOrProvider: Signer | Provider | string): this; - attach(addressOrName: string): this; - deployed(): Promise; - - interface: Multicall2Interface; - - queryFilter( - event: TypedEventFilter, - fromBlockOrBlockhash?: string | number | undefined, - toBlock?: string | number | undefined - ): Promise>; - - listeners( - eventFilter?: TypedEventFilter - ): Array>; - listeners(eventName?: string): Array; - removeAllListeners( - eventFilter: TypedEventFilter - ): this; - removeAllListeners(eventName?: string): this; - off: OnEvent; - on: OnEvent; - once: OnEvent; - removeListener: OnEvent; - - functions: { - aggregate( - calls: CallStruct[], - overrides?: Overrides & { from?: string | Promise } - ): Promise; - - blockAndAggregate( - calls: CallStruct[], - overrides?: Overrides & { from?: string | Promise } - ): Promise; - - getBlockHash( - blockNumber: BigNumberish, - overrides?: CallOverrides - ): Promise<[string] & { blockHash: string }>; - - getBlockNumber( - overrides?: CallOverrides - ): Promise<[BigNumber] & { blockNumber: BigNumber }>; - - getCurrentBlockCoinbase( - overrides?: CallOverrides - ): Promise<[string] & { coinbase: string }>; - - getCurrentBlockDifficulty( - overrides?: CallOverrides - ): Promise<[BigNumber] & { difficulty: BigNumber }>; - - getCurrentBlockGasLimit( - overrides?: CallOverrides - ): Promise<[BigNumber] & { gaslimit: BigNumber }>; - - getCurrentBlockTimestamp( - overrides?: CallOverrides - ): Promise<[BigNumber] & { timestamp: BigNumber }>; - - getEthBalance( - addr: string, - overrides?: CallOverrides - ): Promise<[BigNumber] & { balance: BigNumber }>; - - getLastBlockHash( - overrides?: CallOverrides - ): Promise<[string] & { blockHash: string }>; - - tryAggregate( - requireSuccess: boolean, - calls: CallStruct[], - overrides?: Overrides & { from?: string | Promise } - ): Promise; - - tryBlockAndAggregate( - requireSuccess: boolean, - calls: CallStruct[], - overrides?: Overrides & { from?: string | Promise } - ): Promise; - }; - - aggregate( - calls: CallStruct[], - overrides?: Overrides & { from?: string | Promise } - ): Promise; - - blockAndAggregate( - calls: CallStruct[], - overrides?: Overrides & { from?: string | Promise } - ): Promise; - - getBlockHash( - blockNumber: BigNumberish, - overrides?: CallOverrides - ): Promise; - - getBlockNumber(overrides?: CallOverrides): Promise; - - getCurrentBlockCoinbase(overrides?: CallOverrides): Promise; - - getCurrentBlockDifficulty(overrides?: CallOverrides): Promise; - - getCurrentBlockGasLimit(overrides?: CallOverrides): Promise; - - getCurrentBlockTimestamp(overrides?: CallOverrides): Promise; - - getEthBalance(addr: string, overrides?: CallOverrides): Promise; - - getLastBlockHash(overrides?: CallOverrides): Promise; - - tryAggregate( - requireSuccess: boolean, - calls: CallStruct[], - overrides?: Overrides & { from?: string | Promise } - ): Promise; - - tryBlockAndAggregate( - requireSuccess: boolean, - calls: CallStruct[], - overrides?: Overrides & { from?: string | Promise } - ): Promise; - - callStatic: { - aggregate( - calls: CallStruct[], - overrides?: CallOverrides - ): Promise< - [BigNumber, string[]] & { blockNumber: BigNumber; returnData: string[] } - >; - - blockAndAggregate( - calls: CallStruct[], - overrides?: CallOverrides - ): Promise< - [BigNumber, string, ResultStructOutput[]] & { - blockNumber: BigNumber; - blockHash: string; - returnData: ResultStructOutput[]; - } - >; - - getBlockHash( - blockNumber: BigNumberish, - overrides?: CallOverrides - ): Promise; - - getBlockNumber(overrides?: CallOverrides): Promise; - - getCurrentBlockCoinbase(overrides?: CallOverrides): Promise; - - getCurrentBlockDifficulty(overrides?: CallOverrides): Promise; - - getCurrentBlockGasLimit(overrides?: CallOverrides): Promise; - - getCurrentBlockTimestamp(overrides?: CallOverrides): Promise; - - getEthBalance(addr: string, overrides?: CallOverrides): Promise; - - getLastBlockHash(overrides?: CallOverrides): Promise; - - tryAggregate( - requireSuccess: boolean, - calls: CallStruct[], - overrides?: CallOverrides - ): Promise; - - tryBlockAndAggregate( - requireSuccess: boolean, - calls: CallStruct[], - overrides?: CallOverrides - ): Promise< - [BigNumber, string, ResultStructOutput[]] & { - blockNumber: BigNumber; - blockHash: string; - returnData: ResultStructOutput[]; - } - >; - }; - - filters: {}; - - estimateGas: { - aggregate( - calls: CallStruct[], - overrides?: Overrides & { from?: string | Promise } - ): Promise; - - blockAndAggregate( - calls: CallStruct[], - overrides?: Overrides & { from?: string | Promise } - ): Promise; - - getBlockHash( - blockNumber: BigNumberish, - overrides?: CallOverrides - ): Promise; - - getBlockNumber(overrides?: CallOverrides): Promise; - - getCurrentBlockCoinbase(overrides?: CallOverrides): Promise; - - getCurrentBlockDifficulty(overrides?: CallOverrides): Promise; - - getCurrentBlockGasLimit(overrides?: CallOverrides): Promise; - - getCurrentBlockTimestamp(overrides?: CallOverrides): Promise; - - getEthBalance(addr: string, overrides?: CallOverrides): Promise; - - getLastBlockHash(overrides?: CallOverrides): Promise; - - tryAggregate( - requireSuccess: boolean, - calls: CallStruct[], - overrides?: Overrides & { from?: string | Promise } - ): Promise; - - tryBlockAndAggregate( - requireSuccess: boolean, - calls: CallStruct[], - overrides?: Overrides & { from?: string | Promise } - ): Promise; - }; - - populateTransaction: { - aggregate( - calls: CallStruct[], - overrides?: Overrides & { from?: string | Promise } - ): Promise; - - blockAndAggregate( - calls: CallStruct[], - overrides?: Overrides & { from?: string | Promise } - ): Promise; - - getBlockHash( - blockNumber: BigNumberish, - overrides?: CallOverrides - ): Promise; - - getBlockNumber(overrides?: CallOverrides): Promise; - - getCurrentBlockCoinbase( - overrides?: CallOverrides - ): Promise; - - getCurrentBlockDifficulty( - overrides?: CallOverrides - ): Promise; - - getCurrentBlockGasLimit( - overrides?: CallOverrides - ): Promise; - - getCurrentBlockTimestamp( - overrides?: CallOverrides - ): Promise; - - getEthBalance( - addr: string, - overrides?: CallOverrides - ): Promise; - - getLastBlockHash(overrides?: CallOverrides): Promise; - - tryAggregate( - requireSuccess: boolean, - calls: CallStruct[], - overrides?: Overrides & { from?: string | Promise } - ): Promise; - - tryBlockAndAggregate( - requireSuccess: boolean, - calls: CallStruct[], - overrides?: Overrides & { from?: string | Promise } - ): Promise; - }; -} diff --git a/src/abis/common.ts b/src/abis/common.ts index d95ad5ca..903d55e2 100644 --- a/src/abis/common.ts +++ b/src/abis/common.ts @@ -1,45 +1,37 @@ /* Autogenerated file. Do not edit manually. */ /* tslint:disable */ /* eslint-disable */ -// @ts-nocheck -import type { Listener } from '@ethersproject/providers' -import type { Event, EventFilter } from 'ethers' -export interface TypedEvent< - TArgsArray extends Array = any, - TArgsObject = any -> extends Event { - args: TArgsArray & TArgsObject -} +import { EventFilter, Event } from 'ethers' +import { Result } from '@ethersproject/abi' -export interface TypedEventFilter<_TEvent extends TypedEvent> +export interface TypedEventFilter<_EventArgsArray, _EventArgsObject> extends EventFilter {} -export interface TypedListener { - (...listenerArg: [...__TypechainArgsArray, TEvent]): void +export interface TypedEvent extends Event { + args: EventArgs } -type __TypechainArgsArray = T extends TypedEvent ? U : never - -export interface OnEvent { - ( - eventFilter: TypedEventFilter, - listener: TypedListener - ): TRes - (eventName: string, listener: Listener): TRes -} +export type TypedListener< + EventArgsArray extends Array, + EventArgsObject +> = ( + ...listenerArg: [ + // @ts-ignore + ...EventArgsArray, + TypedEvent + ] +) => 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 diff --git a/src/abis/multicall.json b/src/abis/multicall.json index 08a075de..44a55961 100644 --- a/src/abis/multicall.json +++ b/src/abis/multicall.json @@ -1,330 +1,330 @@ [ - { - "inputs": [ - { - "components": [ - { - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "internalType": "bytes", - "name": "callData", - "type": "bytes" - } + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + } + ], + "internalType": "struct Multicall2.Call[]", + "name": "calls", + "type": "tuple[]" + } ], - "internalType": "struct Multicall2.Call[]", - "name": "calls", - "type": "tuple[]" - } - ], - "name": "aggregate", - "outputs": [ - { - "internalType": "uint256", - "name": "blockNumber", - "type": "uint256" - }, - { - "internalType": "bytes[]", - "name": "returnData", - "type": "bytes[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "internalType": "bytes", - "name": "callData", - "type": "bytes" - } + "name": "aggregate", + "outputs": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + }, + { + "internalType": "bytes[]", + "name": "returnData", + "type": "bytes[]" + } ], - "internalType": "struct Multicall2.Call[]", - "name": "calls", - "type": "tuple[]" - } - ], - "name": "blockAndAggregate", - "outputs": [ - { - "internalType": "uint256", - "name": "blockNumber", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "blockHash", - "type": "bytes32" - }, - { - "components": [ - { - "internalType": "bool", - "name": "success", - "type": "bool" - }, - { - "internalType": "bytes", - "name": "returnData", - "type": "bytes" - } + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + } + ], + "internalType": "struct Multicall2.Call[]", + "name": "calls", + "type": "tuple[]" + } ], - "internalType": "struct Multicall2.Result[]", - "name": "returnData", - "type": "tuple[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "blockNumber", - "type": "uint256" - } - ], - "name": "getBlockHash", - "outputs": [ - { - "internalType": "bytes32", - "name": "blockHash", - "type": "bytes32" - }, - { - "components": [ - { - "internalType": "bool", - "name": "success", - "type": "bool" - }, - { - "internalType": "bytes", - "name": "returnData", - "type": "bytes" - } + "name": "blockAndAggregate", + "outputs": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "blockHash", + "type": "bytes32" + }, + { + "components": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "returnData", + "type": "bytes" + } + ], + "internalType": "struct Multicall2.Result[]", + "name": "returnData", + "type": "tuple[]" + } ], - "internalType": "struct Multicall2.Result[]", - "name": "returnData", - "type": "tuple[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getBlockNumber", - "outputs": [ - { - "internalType": "uint256", - "name": "blockNumber", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getCurrentBlockCoinbase", - "outputs": [ - { - "internalType": "address", - "name": "coinbase", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getCurrentBlockDifficulty", - "outputs": [ - { - "internalType": "uint256", - "name": "difficulty", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getCurrentBlockGasLimit", - "outputs": [ - { - "internalType": "uint256", - "name": "gaslimit", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getCurrentBlockTimestamp", - "outputs": [ - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "addr", - "type": "address" - } - ], - "name": "getEthBalance", - "outputs": [ - { - "internalType": "uint256", - "name": "balance", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getLastBlockHash", - "outputs": [ - { - "internalType": "bytes32", - "name": "blockHash", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bool", - "name": "requireSuccess", - "type": "bool" - }, - { - "components": [ - { - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "internalType": "bytes", - "name": "callData", - "type": "bytes" - } + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + } ], - "internalType": "struct Multicall2.Call[]", - "name": "calls", - "type": "tuple[]" - } - ], - "name": "tryAggregate", - "outputs": [ - { - "components": [ - { - "internalType": "bool", - "name": "success", - "type": "bool" - }, - { - "internalType": "bytes", - "name": "returnData", - "type": "bytes" - } + "name": "getBlockHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "blockHash", + "type": "bytes32" + }, + { + "components": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "returnData", + "type": "bytes" + } + ], + "internalType": "struct Multicall2.Result[]", + "name": "returnData", + "type": "tuple[]" + } ], - "internalType": "struct Multicall2.Result[]", - "name": "returnData", - "type": "tuple[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bool", - "name": "requireSuccess", - "type": "bool" - }, - { - "components": [ - { - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "internalType": "bytes", - "name": "callData", - "type": "bytes" - } + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBlockNumber", + "outputs": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + } ], - "internalType": "struct Multicall2.Call[]", - "name": "calls", - "type": "tuple[]" - } - ], - "name": "tryBlockAndAggregate", - "outputs": [ - { - "internalType": "uint256", - "name": "blockNumber", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "blockHash", - "type": "bytes32" - }, - { - "components": [ - { - "internalType": "bool", - "name": "success", - "type": "bool" - }, - { - "internalType": "bytes", - "name": "returnData", - "type": "bytes" - } + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentBlockCoinbase", + "outputs": [ + { + "internalType": "address", + "name": "coinbase", + "type": "address" + } ], - "internalType": "struct Multicall2.Result[]", - "name": "returnData", - "type": "tuple[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - } + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentBlockDifficulty", + "outputs": [ + { + "internalType": "uint256", + "name": "difficulty", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentBlockGasLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "gaslimit", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentBlockTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "name": "getEthBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getLastBlockHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "blockHash", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "requireSuccess", + "type": "bool" + }, + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + } + ], + "internalType": "struct Multicall2.Call[]", + "name": "calls", + "type": "tuple[]" + } + ], + "name": "tryAggregate", + "outputs": [ + { + "components": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "returnData", + "type": "bytes" + } + ], + "internalType": "struct Multicall2.Result[]", + "name": "returnData", + "type": "tuple[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "requireSuccess", + "type": "bool" + }, + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + } + ], + "internalType": "struct Multicall2.Call[]", + "name": "calls", + "type": "tuple[]" + } + ], + "name": "tryBlockAndAggregate", + "outputs": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "blockHash", + "type": "bytes32" + }, + { + "components": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "returnData", + "type": "bytes" + } + ], + "internalType": "struct Multicall2.Result[]", + "name": "returnData", + "type": "tuple[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } ] diff --git a/src/abis/multicall2.json b/src/abis/multicall2.json deleted file mode 100644 index 76cadf4c..00000000 --- a/src/abis/multicall2.json +++ /dev/null @@ -1,165 +0,0 @@ -[ - { - "inputs": [ - { - "components": [ - { "internalType": "address", "name": "target", "type": "address" }, - { "internalType": "bytes", "name": "callData", "type": "bytes" } - ], - "internalType": "struct Multicall2.Call[]", - "name": "calls", - "type": "tuple[]" - } - ], - "name": "aggregate", - "outputs": [ - { "internalType": "uint256", "name": "blockNumber", "type": "uint256" }, - { "internalType": "bytes[]", "name": "returnData", "type": "bytes[]" } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { "internalType": "address", "name": "target", "type": "address" }, - { "internalType": "bytes", "name": "callData", "type": "bytes" } - ], - "internalType": "struct Multicall2.Call[]", - "name": "calls", - "type": "tuple[]" - } - ], - "name": "blockAndAggregate", - "outputs": [ - { "internalType": "uint256", "name": "blockNumber", "type": "uint256" }, - { "internalType": "bytes32", "name": "blockHash", "type": "bytes32" }, - { - "components": [ - { "internalType": "bool", "name": "success", "type": "bool" }, - { "internalType": "bytes", "name": "returnData", "type": "bytes" } - ], - "internalType": "struct Multicall2.Result[]", - "name": "returnData", - "type": "tuple[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "blockNumber", "type": "uint256" }], - "name": "getBlockHash", - "outputs": [{ "internalType": "bytes32", "name": "blockHash", "type": "bytes32" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getBlockNumber", - "outputs": [{ "internalType": "uint256", "name": "blockNumber", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getCurrentBlockCoinbase", - "outputs": [{ "internalType": "address", "name": "coinbase", "type": "address" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getCurrentBlockDifficulty", - "outputs": [{ "internalType": "uint256", "name": "difficulty", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getCurrentBlockGasLimit", - "outputs": [{ "internalType": "uint256", "name": "gaslimit", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getCurrentBlockTimestamp", - "outputs": [{ "internalType": "uint256", "name": "timestamp", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "address", "name": "addr", "type": "address" }], - "name": "getEthBalance", - "outputs": [{ "internalType": "uint256", "name": "balance", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getLastBlockHash", - "outputs": [{ "internalType": "bytes32", "name": "blockHash", "type": "bytes32" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "bool", "name": "requireSuccess", "type": "bool" }, - { - "components": [ - { "internalType": "address", "name": "target", "type": "address" }, - { "internalType": "bytes", "name": "callData", "type": "bytes" } - ], - "internalType": "struct Multicall2.Call[]", - "name": "calls", - "type": "tuple[]" - } - ], - "name": "tryAggregate", - "outputs": [ - { - "components": [ - { "internalType": "bool", "name": "success", "type": "bool" }, - { "internalType": "bytes", "name": "returnData", "type": "bytes" } - ], - "internalType": "struct Multicall2.Result[]", - "name": "returnData", - "type": "tuple[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "bool", "name": "requireSuccess", "type": "bool" }, - { - "components": [ - { "internalType": "address", "name": "target", "type": "address" }, - { "internalType": "bytes", "name": "callData", "type": "bytes" } - ], - "internalType": "struct Multicall2.Call[]", - "name": "calls", - "type": "tuple[]" - } - ], - "name": "tryBlockAndAggregate", - "outputs": [ - { "internalType": "uint256", "name": "blockNumber", "type": "uint256" }, - { "internalType": "bytes32", "name": "blockHash", "type": "bytes32" }, - { - "components": [ - { "internalType": "bool", "name": "success", "type": "bool" }, - { "internalType": "bytes", "name": "returnData", "type": "bytes" } - ], - "internalType": "struct Multicall2.Result[]", - "name": "returnData", - "type": "tuple[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - } -] diff --git a/src/components/AuctionBlock.tsx b/src/components/AuctionBlock.tsx index b5317acf..389bbf77 100644 --- a/src/components/AuctionBlock.tsx +++ b/src/components/AuctionBlock.tsx @@ -74,7 +74,7 @@ const AuctionBlock = (auction: Props) => { const amountBN = BigNumber.from(amount) return formatNumber(parseWad(gebUtils.decimalShift(amountBN, -9)), 2) } - + // kickstart bid as in first bid when auction started const kickBidder = { bidder: _.get(auction, 'startedBy', ''), buyAmount: _.get(auction, 'buyInitialAmount', ''), diff --git a/src/connectors/NetworkConnector.ts b/src/connectors/NetworkConnector.ts index 1c87ff15..905fb37f 100644 --- a/src/connectors/NetworkConnector.ts +++ b/src/connectors/NetworkConnector.ts @@ -1,21 +1,6 @@ -// Copyright (C) 2020 Uniswap -// https://github.com/Uniswap/uniswap-interface - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -import { ConnectorUpdate } from '@web3-react/types' -import { AbstractConnector } from '@web3-react/abstract-connector' import invariant from 'tiny-invariant' +import { AbstractConnector } from '@web3-react/abstract-connector' +import { ConnectorUpdate } from 'web3-react-types' interface NetworkConnectorArguments { urls: { [chainId: number]: string } @@ -54,11 +39,19 @@ class MiniRpcProvider implements AsyncSendable { public readonly path: string public readonly batchWaitTimeMs: number + private readonly connector: NetworkConnector + private nextId = 1 private batchTimeoutId: ReturnType | null = null private batch: BatchItem[] = [] - constructor(chainId: number, url: string, batchWaitTimeMs?: number) { + constructor( + connector: NetworkConnector, + chainId: number, + url: string, + batchWaitTimeMs?: number + ) { + this.connector = connector this.chainId = chainId this.url = url const parsed = new URL(url) @@ -70,7 +63,26 @@ class MiniRpcProvider implements AsyncSendable { public readonly clearBatch = async () => { console.debug('Clearing batch', this.batch) - const batch = this.batch + let batch = this.batch + + batch = batch.filter((b) => { + if (b.request.method === 'wallet_switchEthereumChain') { + try { + this.connector.changeChainId( + parseInt( + (b.request.params as [{ chainId: string }])[0] + .chainId + ) + ) + b.resolve({ id: b.request.id }) + } catch (error) { + b.reject(error) + } + return false + } + return true + }) + this.batch = [] this.batchTimeoutId = null let response: Response @@ -124,26 +136,24 @@ class MiniRpcProvider implements AsyncSendable { reject, request: { method }, } = byKey[result.id] - if (resolve && reject) { - if ('error' in result) { - reject( - new RequestError( - result?.error?.message, - result?.error?.code, - result?.error?.data - ) + if ('error' in result) { + reject( + new RequestError( + result?.error?.message, + result?.error?.code, + result?.error?.data ) - } else if ('result' in result) { - resolve(result.result) - } else { - reject( - new RequestError( - `Received unexpected JSON-RPC response to ${method} request.`, - -32000, - result - ) + ) + } else if ('result' in result && resolve) { + resolve(result.result) + } else { + reject( + new RequestError( + `Received unexpected JSON-RPC response to ${method} request.`, + -32000, + result ) - } + ) } } } @@ -153,7 +163,7 @@ class MiniRpcProvider implements AsyncSendable { jsonrpc: '2.0' id: number | string | null method: string - params?: unknown[] | object + params?: unknown[] | Record }, callback: (error: any, response: any) => void ): void => { @@ -166,7 +176,7 @@ class MiniRpcProvider implements AsyncSendable { public readonly request = async ( method: string | { method: string; params: unknown[] }, - params?: unknown[] | object + params?: unknown[] | Record ): Promise => { if (typeof method !== 'string') { return this.request(method.method, method.params) @@ -206,11 +216,12 @@ export class NetworkConnector extends AbstractConnector { supportedChainIds: Object.keys(urls).map((k): number => Number(k)), }) - this.currentChainId = defaultChainId || Number(Object.keys(urls)[0]) + this.currentChainId = defaultChainId ?? Number(Object.keys(urls)[0]) this.providers = Object.keys(urls).reduce<{ [chainId: number]: MiniRpcProvider }>((accumulator, chainId) => { accumulator[Number(chainId)] = new MiniRpcProvider( + this, Number(chainId), urls[Number(chainId)] ) @@ -245,4 +256,21 @@ export class NetworkConnector extends AbstractConnector { public deactivate() { return } + + /** + * Meant to be called only by MiniRpcProvider + * @param chainId the new chain id + */ + public changeChainId(chainId: number) { + if (chainId in this.providers) { + this.currentChainId = chainId + this.emitUpdate({ + chainId, + account: null, + provider: this.providers[chainId], + }) + } else { + throw new Error(`Unsupported chain ID: ${chainId}`) + } + } } diff --git a/src/containers/Auctions/AuctionsList.tsx b/src/containers/Auctions/AuctionsList.tsx index 1e52fcd1..57119f42 100644 --- a/src/containers/Auctions/AuctionsList.tsx +++ b/src/containers/Auctions/AuctionsList.tsx @@ -21,10 +21,15 @@ const AuctionsList = ({ type }: Props) => { connectWalletModel: connectWalletState, } = useStoreState((state) => state) const { popupsModel: popupsActions } = useStoreActions((state) => state) + // internalbalance = user's RAI balance in the protocol + // protInternalBalance = user's FLX balance in the protocol const { internalBalance, protInternalBalance } = auctionsState const { proxyAddress } = connectWalletState + + // auctions list const auctions = useAuctions() + // handle clicking to claim const handleClick = (modalType: string) => { if (!account) { popupsActions.setIsConnectorsWalletOpen(true) diff --git a/src/containers/Earn/Incentives/index.tsx b/src/containers/Earn/Incentives/index.tsx index be18215e..8c2211a5 100644 --- a/src/containers/Earn/Incentives/index.tsx +++ b/src/containers/Earn/Incentives/index.tsx @@ -10,6 +10,7 @@ const Incentives = () => { const [isFetching, setIsFetching] = useState(true) const [error, setError] = useState('') + // fetching incentives rounds useEffect(() => { async function fetchIncentives() { try { diff --git a/src/containers/Earn/LiquidityPool/AddLiquidity.tsx b/src/containers/Earn/LiquidityPool/AddLiquidity.tsx deleted file mode 100644 index b4c12629..00000000 --- a/src/containers/Earn/LiquidityPool/AddLiquidity.tsx +++ /dev/null @@ -1,220 +0,0 @@ -import React from 'react' -import { PlusCircle } from 'react-feather' -import styled from 'styled-components' -import Button from '../../../components/Button' -import DecimalInput from '../../../components/DecimalInput' -import useGeb from '../../../hooks/useGeb' -import { - useAddLiquidity, - useInputsHandlers, - useLiquidityInfo, -} from '../../../hooks/useLiquidityPool' -import { - ApprovalState, - useTokenApproval, -} from '../../../hooks/useTokenApproval' -import { formatNumber } from '../../../utils/helper' - -const AddLiquidity = () => { - const { - error, - balances: currencyBalances, - parsedAmounts, - } = useLiquidityInfo() - const geb = useGeb() - - const isValid = !error - - const { onEthInput, onRaiInput } = useInputsHandlers() - - const { addLiquidityCallback } = useAddLiquidity() - - const [depositApprovalState, approveDeposit] = useTokenApproval( - parsedAmounts.raiAmount, - 'coin', - geb?.contracts.uniswapV3TwoTrancheLiquidityManager.address - ) - - const ethValue = parsedAmounts.ethAmount - ? Number(parsedAmounts.ethAmount) > 0 - ? (formatNumber(parsedAmounts.ethAmount) as string) - : parsedAmounts.ethAmount - : '' - const raiValue = parsedAmounts.raiAmount - ? Number(parsedAmounts.raiAmount) > 0 - ? (formatNumber(parsedAmounts.raiAmount) as string) - : parsedAmounts.raiAmount - : '' - const liqBValue = - parsedAmounts && parsedAmounts.totalLiquidity - ? (formatNumber(parsedAmounts.totalLiquidity) as string) - : '0' - - const onEthMaxAmount = () => onEthInput(currencyBalances.eth.toString()) - const onRaiMaxAmount = () => onRaiInput(currencyBalances.rai.toString()) - - const handleAddLiquidity = async () => { - try { - await addLiquidityCallback() - onEthInput('') - onRaiInput('') - } catch (error) { - console.log(error) - } - } - - return ( - - - - - {`RAI (Available: ${formatNumber( - currencyBalances.rai.toString() - )})`} - - - - - - - - - - {`ETH (Available: ${formatNumber( - currencyBalances.eth.toString() - )})`} - - - - - - - - {liqBValue} RAI/ETH - - - - - {isValid && - (depositApprovalState === ApprovalState.PENDING || - depositApprovalState === ApprovalState.NOT_APPROVED) ? ( -