-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from base-org/lukas/types-refactor
types / write refactor & finalize hooks
- Loading branch information
Showing
43 changed files
with
1,565 additions
and
614 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
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,29 @@ | ||
type AssetTypeToggleProps = { | ||
selectedAssetType: 'eth' | 'erc20' | ||
setSelectedAssetType: (assetType: 'eth' | 'erc20') => void | ||
} | ||
|
||
export function AssetTypeToggle({ selectedAssetType, setSelectedAssetType }: AssetTypeToggleProps) { | ||
return ( | ||
<div className='flex flex-row justify-center items-center self-center w-48 rounded-full divide-x bg-white'> | ||
<button | ||
className={`w-24 flex items-center justify-center h-8 rounded-l-full ${ | ||
selectedAssetType === 'eth' ? 'bg-blue-500 text-white shadow-inner shadow-stone-900' : 'bg-white text-black' | ||
}`} | ||
onClick={() => setSelectedAssetType('eth')} | ||
> | ||
ETH | ||
</button> | ||
<button | ||
className={`w-24 flex items-center justify-center h-8 rounded-r-full ${ | ||
selectedAssetType === 'erc20' | ||
? 'bg-blue-500 text-white shadow-inner shadow-stone-900' | ||
: 'bg-white text-black' | ||
}`} | ||
onClick={() => setSelectedAssetType('erc20')} | ||
> | ||
ERC-20 | ||
</button> | ||
</div> | ||
) | ||
} |
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,45 @@ | ||
type BridgeToggleProps = { | ||
action: 'deposit' | 'withdraw' | 'prove' | 'finalize' | ||
setAction: (action: 'deposit' | 'withdraw' | 'prove' | 'finalize') => void | ||
} | ||
|
||
export function BridgeToggle({ action, setAction }: BridgeToggleProps) { | ||
return ( | ||
<div className='flex flex-row justify-center items-center self-center w-72 rounded-full divide-x bg-white'> | ||
<div className='flex flex-row divide-x'> | ||
<button | ||
onClick={() => setAction('deposit')} | ||
className={`w-36 flex items-center justify-center h-12 rounded-l-full ${ | ||
action === 'deposit' ? 'bg-blue-500 text-white shadow-inner shadow-stone-900' : 'bg-white text-black' | ||
}`} | ||
> | ||
Deposit | ||
</button> | ||
<button | ||
onClick={() => setAction('withdraw')} | ||
className={`w-36 flex items-center justify-center h-12 ${ | ||
action === 'withdraw' ? 'bg-blue-500 text-white shadow-inner shadow-stone-900' : 'bg-white text-black' | ||
}`} | ||
> | ||
Withdraw | ||
</button> | ||
<button | ||
onClick={() => setAction('prove')} | ||
className={`w-36 flex items-center justify-center h-12 ${ | ||
action === 'prove' ? 'bg-blue-500 text-white shadow-inner shadow-stone-900' : 'bg-white text-black' | ||
}`} | ||
> | ||
Prove | ||
</button> | ||
<button | ||
onClick={() => setAction('finalize')} | ||
className={`w-36 flex items-center justify-center h-12 rounded-r-full ${ | ||
action === 'finalize' ? 'bg-blue-500 text-white shadow-inner shadow-stone-900' : 'bg-white text-black' | ||
}`} | ||
> | ||
Finalize | ||
</button> | ||
</div> | ||
</div> | ||
) | ||
} |
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,24 @@ | ||
import { useState } from 'react' | ||
import { AssetTypeToggle } from './AssetTypeToggle' | ||
import { DepositERC20 } from './DepositERC20' | ||
import { DepositETH } from './DepositETH' | ||
import { NetworkSelector } from './NetworkSelector' | ||
|
||
const networkToChainId: Record<'optimism' | 'base', number> = { | ||
base: 84531, | ||
optimism: 420, | ||
} | ||
|
||
export function DepositContainer() { | ||
const [selectedAssetType, setSelectedAssetType] = useState<'eth' | 'erc20'>('eth') | ||
const [selectedNetwork, setSelectedNetwork] = useState<'optimism' | 'base'>('base') | ||
return ( | ||
<div className='w-full flex flex-col items-center space-y-4'> | ||
<AssetTypeToggle selectedAssetType={selectedAssetType} setSelectedAssetType={setSelectedAssetType} /> | ||
<span className='text-white'>To</span> | ||
<NetworkSelector selectedNetwork={selectedNetwork} setSelectedNetwork={setSelectedNetwork} /> | ||
{selectedAssetType === 'eth' && <DepositETH selectedChainId={networkToChainId[selectedNetwork]} />} | ||
{selectedAssetType === 'erc20' && <DepositERC20 selectedChainId={networkToChainId[selectedNetwork]} />} | ||
</div> | ||
) | ||
} |
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
Oops, something went wrong.