-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Tab: IBC #795
Merged
New Tab: IBC #795
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
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
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,9 @@ | ||
import { Card } from '@penumbra-zone/ui'; | ||
|
||
export const IbcInForm = () => { | ||
return ( | ||
<Card gradient className='md:p-5'> | ||
To come... | ||
</Card> | ||
); | ||
}; |
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,25 @@ | ||
import { LoaderFunction } from 'react-router-dom'; | ||
import { testnetIbcChains } from '@penumbra-zone/constants/src/chains'; | ||
import { BalancesResponse } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/view/v1/view_pb'; | ||
import { getBalances } from '../../fetchers/balances'; | ||
import { useStore } from '../../state'; | ||
import { filterBalancesPerChain } from '../../state/ibc'; | ||
|
||
export type IbcLoaderResponse = BalancesResponse[]; | ||
|
||
export const IbcLoader: LoaderFunction = async (): Promise<IbcLoaderResponse> => { | ||
const assetBalances = await getBalances(); | ||
|
||
if (assetBalances[0]) { | ||
const initialChain = testnetIbcChains[0]; | ||
const initialSelection = filterBalancesPerChain(assetBalances, initialChain)[0]; | ||
|
||
// set initial account if accounts exist and asset if account has asset list | ||
useStore.setState(state => { | ||
state.ibc.selection = initialSelection; | ||
state.ibc.chain = initialChain; | ||
}); | ||
} | ||
|
||
return assetBalances; | ||
}; |
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,90 @@ | ||
import { Button, Card, Input } from '@penumbra-zone/ui'; | ||
import { ChainSelector } from './chain-selector'; | ||
import { useLoaderData } from 'react-router-dom'; | ||
import { useStore } from '../../state'; | ||
import { filterBalancesPerChain, ibcSelector, ibcValidationErrors } from '../../state/ibc'; | ||
import InputToken from '../shared/input-token'; | ||
import { InputBlock } from '../shared/input-block'; | ||
import { IbcLoaderResponse } from './ibc-loader'; | ||
|
||
export const IbcOutForm = () => { | ||
const assetBalances = useLoaderData() as IbcLoaderResponse; | ||
const { | ||
sendIbcWithdraw, | ||
destinationChainAddress, | ||
setDestinationChainAddress, | ||
amount, | ||
setAmount, | ||
selection, | ||
setSelection, | ||
chain, | ||
} = useStore(ibcSelector); | ||
const filteredBalances = filterBalancesPerChain(assetBalances, chain); | ||
const validationErrors = useStore(ibcValidationErrors); | ||
|
||
return ( | ||
<Card gradient className='md:p-5'> | ||
<form | ||
className='flex flex-col gap-4' | ||
onSubmit={e => { | ||
e.preventDefault(); | ||
void sendIbcWithdraw(); | ||
}} | ||
> | ||
<ChainSelector /> | ||
<InputToken | ||
label='Amount to send' | ||
placeholder='Enter an amount' | ||
className='mb-1' | ||
selection={selection} | ||
setSelection={setSelection} | ||
value={amount} | ||
onChange={e => { | ||
if (Number(e.target.value) < 0) return; | ||
setAmount(e.target.value); | ||
}} | ||
validations={[ | ||
{ | ||
type: 'error', | ||
issue: 'insufficient funds', | ||
checkFn: () => validationErrors.amountErr, | ||
}, | ||
]} | ||
balances={filteredBalances} | ||
/> | ||
<InputBlock | ||
label='Recipient on destination chain' | ||
className='mb-1' | ||
value={destinationChainAddress} | ||
validations={[ | ||
{ | ||
type: 'error', | ||
issue: 'address not valid', | ||
checkFn: () => validationErrors.recipientErr, | ||
}, | ||
]} | ||
> | ||
<Input | ||
variant='transparent' | ||
placeholder='Enter the address' | ||
value={destinationChainAddress} | ||
onChange={e => setDestinationChainAddress(e.target.value)} | ||
/> | ||
</InputBlock> | ||
<Button | ||
type='submit' | ||
variant='gradient' | ||
className='mt-9' | ||
disabled={ | ||
!Number(amount) || | ||
!destinationChainAddress || | ||
!!Object.values(validationErrors).find(Boolean) || | ||
!selection | ||
} | ||
> | ||
Send | ||
</Button> | ||
</form> | ||
</Card> | ||
); | ||
}; |
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,11 @@ | ||
import { IbcInForm } from './ibc-in-form'; | ||
import { IbcOutForm } from './ibc-out-form'; | ||
|
||
export const IbcLayout = () => { | ||
return ( | ||
<div className='grid md:grid-cols-2 md:gap-5'> | ||
<IbcInForm /> | ||
<IbcOutForm /> | ||
</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
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
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.
Fixes bug where tx approval window does not scroll all the way down given approve/deny buttons overlap it with a fixed position