This repository has been archived by the owner on Feb 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Adding Competition Solver tab to settlements page #590
Closed
0xaaiden
wants to merge
34
commits into
cowprotocol:develop
from
0xaaiden:feature/transactionScreens
Closed
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
b67c3b1
create the SolverCompetition screen
vicebas c0c8fdf
update Design
vicebas 27605de
update Design
vicebas b083b62
update Design
vicebas 439a82b
update Design
vicebas 1b938a4
update Design
vicebas 1dad41b
update Design
vicebas 857783f
Create Clearing Prices
vicebas 63c6676
Create Clearing Prices
vicebas 56f76c6
Fixes on the description screen
vicebas d655359
add cache to Erc20
vicebas 616ebae
add mobile capacities
vicebas 84eae43
fix solutions prices and executed orders
vicebas a9d0509
fix small issues
vicebas e450c8a
fix formatting issues
vicebas 5d6362a
avatar boring colors
vicebas 08bb57e
fix prices issues
vicebas a5efe4a
Update webpack.config.js
0xaaiden 9647448
Merge branch 'cowprotocol:develop' into feature/transactionScreens
0xaaiden 20685c5
fix prices issues with decimals
vicebas 3a26f19
Changes in display + tooltip info
4640729
Changes in display + tooltip info
4ff36d0
Change staging API back to barn
4b87d3c
fix native token per network
vicebas 3782e0b
fix native token per network
vicebas 8b22c10
add blockchain check before loading solvers
vicebas 0a2da0b
add blockchain check before loading solvers
vicebas 5f05d1b
Update webpack.config.js to redirect staging api to use prod endpoint…
0xaaiden ef5ceca
add blockchain check before loading solvers
vicebas 9594f68
add blockchain check before loading solvers
vicebas 657e099
change api being used to get currentBlock
vicebas 7a3a8bb
change api being used to get currentBlock
vicebas 2a761b6
Update webpack.config.js
0xaaiden 6d9e2e2
undo webpack changes
vicebas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import BigNumber from 'bignumber.js' | ||
|
||
const ETH_BLOCKCHAIN_URL = 'https://api.blockcypher.com/v1/eth/main' | ||
const XDAI_BLOCKCHAIN_URL = 'https://gnosis.blockscout.com/api/v2/stats' | ||
|
||
type ETHCurrentBlock = { | ||
name: string | ||
height: number | ||
hash: string | ||
time: Date | ||
latest_url: string | ||
previous_hash: string | ||
previous_url: string | ||
peer_count: number | ||
unconfirmed_count: number | ||
high_gas_price: BigNumber | ||
medium_gas_price: BigNumber | ||
low_gas_price: BigNumber | ||
high_priority_fee: BigNumber | ||
medium_priority_fee: BigNumber | ||
low_priority_fee: BigNumber | ||
base_fee: BigNumber | ||
last_fork_height: BigNumber | ||
last_fork_hash: string | ||
} | ||
|
||
export interface XDAICurrentBlock { | ||
average_block_time: number | ||
coin_price: string | ||
gas_prices: GasPrices | ||
gas_used_today: BigNumber | ||
market_cap: string | ||
network_utilization_percentage: number | ||
static_gas_price: BigNumber | ||
total_addresses: BigNumber | ||
total_blocks: number | ||
total_gas_used: BigNumber | ||
total_transactions: BigNumber | ||
transactions_today: BigNumber | ||
} | ||
|
||
export interface GasPrices { | ||
average: number | ||
fast: number | ||
slow: number | ||
} | ||
export interface CurrentBlockAPI { | ||
getETHCurrentBlock(): Promise<ETHCurrentBlock> | ||
getXDaiCurrentBlock(): Promise<XDAICurrentBlock> | ||
} | ||
|
||
export class CurrentBlockApiImpl { | ||
public async getETHCurrentBlock(): Promise<ETHCurrentBlock> { | ||
const response = await fetch(ETH_BLOCKCHAIN_URL, { | ||
method: 'GET', | ||
mode: 'no-cors', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}) | ||
return response.json() | ||
} | ||
|
||
public async getXDaiCurrentBlock(): Promise<XDAICurrentBlock> { | ||
const response = await fetch(XDAI_BLOCKCHAIN_URL, { | ||
method: 'GET', | ||
mode: 'no-cors', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}) | ||
return response.json() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { CurrentBlockAPI } from 'api/currentblock/currentBlockchainApi' | ||
import { CurrentBlockApiProxy } from 'api/currentblock/currentBlockApiProxy' | ||
|
||
export function createCurrentBlockchainAPI(): CurrentBlockAPI { | ||
const CurrentBlockApi: CurrentBlockAPI = new CurrentBlockApiProxy() | ||
window['CurrentBlockAPI'] = CurrentBlockApi | ||
return CurrentBlockApi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { useNetworkId } from 'state/network' | ||
import { useEffect, useState } from 'react' | ||
import { NATIVE_TOKEN_PER_NETWORK, XDAI } from 'const' | ||
import { createCurrentBlockchainAPI } from 'api/currentblock' | ||
|
||
export const useCurrentBlock = (): { isLoading: boolean; currentBlock: number | void | undefined } => { | ||
const network = useNetworkId() || undefined | ||
const [isLoading, setLoading] = useState<boolean>(false) | ||
const [currentBlock, setCurrentBlock] = useState<number | void>() | ||
const currentBlockApi = createCurrentBlockchainAPI() | ||
|
||
useEffect(() => { | ||
async function getCurrentBlock(): Promise<void> { | ||
if (network) { | ||
setLoading(true) | ||
try { | ||
if (NATIVE_TOKEN_PER_NETWORK[network] == XDAI) { | ||
const response = await currentBlockApi.getXDaiCurrentBlock() | ||
setCurrentBlock(response.total_blocks) | ||
} else { | ||
const response = await currentBlockApi.getETHCurrentBlock() | ||
setCurrentBlock(response.height) | ||
} | ||
} finally { | ||
setLoading(false) | ||
} | ||
} | ||
} | ||
getCurrentBlock() | ||
}, [network]) | ||
|
||
return { isLoading, currentBlock } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not needed, the blocknumber can be fetched from the chain using the
web3
apiexplorer/src/apps/explorer/api.ts
Line 4 in 43af8ff
Just call
web3.eth.getBlockNumber()
https://docs.web3js.org/api/web3-eth/function/getBlockNumber/You could add the blocknumber to the global state and have an updater running every ~15s.
Or have a more "local" state and instantiate the updater only when needed, which is when the tx details page is loaded & the block difference is < 65.
I'm going too far with ideas, I'll let you take your pick or propose something else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes made as advertised, just trying to keep it simple and clear