-
-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor chainselect into own component
- Loading branch information
1 parent
f4cd13c
commit 532c440
Showing
2 changed files
with
61 additions
and
47 deletions.
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,55 @@ | ||
import { | ||
JuiceListbox, | ||
JuiceListboxOption, | ||
} from 'components/inputs/JuiceListbox' | ||
import { NETWORKS } from 'constants/networks' | ||
import { SuckerPair } from 'juice-sdk-core' | ||
|
||
export const ChainSelect = ({ | ||
value, | ||
onChange, | ||
suckers, | ||
}: { | ||
value: { | ||
label: string | ||
value: number | ||
} | ||
onChange: (chainId: JuiceListboxOption<number>) => void | ||
suckers: SuckerPair[] | ||
}) => { | ||
const allowedChainIds = new Set(suckers?.map(sucker => sucker.peerChainId)) | ||
const networkOptions = Object.entries(NETWORKS) | ||
.filter(([chainId]) => allowedChainIds.has(parseInt(chainId))) | ||
.map(([chainId, networkInfo]) => ({ | ||
label: networkInfo.label, | ||
value: parseInt(chainId), | ||
})) | ||
|
||
// const fetchGasEstimates = async () => { | ||
// const estimates = await Promise.allSettled( | ||
// Array.from(allowedChainIds).map(async chainId => { | ||
// await estimateGas(config, { | ||
// chainId: chainId, | ||
// // TODO pass in tx data and contract address | ||
// // to: '0xd2135CfB216b74109775236E36d4b433F1DF507B', | ||
// // value: parseEther('0.01'), | ||
// }) | ||
// }), | ||
// ) | ||
// // setGasEstimates(estimates) | ||
// } | ||
|
||
return ( | ||
<JuiceListbox | ||
value={value} | ||
onChange={onChange} | ||
options={networkOptions.map(option => ({ | ||
...option, | ||
label: `${option.label}`, | ||
// - Gas: ${ | ||
// gasEstimates[option.value] || 'Loading...' | ||
// }`, | ||
}))} | ||
/> | ||
) | ||
} |
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