-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: TAO staking * fix: remove unused config value * fix: remove unused config value * fix: tidy up * fix: tidy up * feat: implemented product feedback * feat: implemented product feedback * feat: implemented more product feedback * feat: implemented more product feedback * feat: chainflip ux rework (#1141) * feat: wip chainflip ux rework * feat: quote, side panel and more * feat: select rebuild, connect eth, balances, max, and more * feat: balances stuff * feat: everything working, 3 minor todos remaining * feat: arbitrary target address, history compatibility, expired status, fix max, more * feat: better handling of evm accounts * fix: missing ui recipes * feat: substrate account prefix * feat: protocol agnostic swap (#1142) * feat: allow mainnet to mainnet swap, but what if we can do protocol agnostic swap * feat: lots of progress on protocol agnostic swap * feat: chainflip swap ok, remaining accounts ux refactor * feat: states improvements * refactor: refactor and cleanup * feat: improve quote ux * feat: good accounts ux, hopefully * fix: swap route name * feat: usd value and other ux improvements * fix: selecting to account * feat: check existential deposit * Feat/protocol agnostic swap (#1145) * feat: allow mainnet to mainnet swap, but what if we can do protocol agnostic swap * feat: lots of progress on protocol agnostic swap * feat: chainflip swap ok, remaining accounts ux refactor * feat: states improvements * refactor: refactor and cleanup * feat: improve quote ux * feat: good accounts ux, hopefully * fix: swap route name * feat: usd value and other ux improvements * fix: selecting to account * feat: check existential deposit * feat: done * feat: better mobile responsiveness * feat: downgrade chainflip sdk and capture swap ids for quest points * fix: swaps not getting saved correctly * feat: only swap to and from dot, adjust fee * feat: show token even before they are added to coingecko * feat: remove flip token * feat: better tokens loading, show talisman fees * feat: fees tooltip and gas estimation * feat: better gas estimation and fast balances * fix: balance loading * fix: yarn lock * fix: shut up playwright * fix: crypto * fix: vite build and better chainflip error * chore: skip portal storybook deplyment * feat: enable deploy storybook workflow * fix: include node polyfills * fix: missed lockfile * fix: include qa workflow * fix: resume workflow * fix: need qa for portal storybook * fix: downgrade chainflip sdk: (#1149) * fix: include withSignedTransaction (#1150) * fix: update bifrost api (#1152) * feat: avail nompool staking (#1153) * feat: added avail to nompool config * fix: remove serif fallback font * fix: broken searchbar on portfolio * fix: use avail extensions in apipromise * fix: show coming soon instead of apr for avail * fix: more coming soon text for avail * fix: add avail indexer * fix: input width * feat: improved swap amount (#1154) * feat: TAO staking * fix: remove duped bittensor * fix: dedupe deps --------- Co-authored-by: Chris Ling <81092286+chrisling-dev@users.noreply.github.com> Co-authored-by: Will Urban <will.urban.dev@gmail.com> Co-authored-by: chrisling-dev <chrisling.dev@gmail.com>
- Loading branch information
1 parent
d265ba2
commit 8aca9e0
Showing
45 changed files
with
2,951 additions
and
71 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
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
110 changes: 110 additions & 0 deletions
110
apps/portal/src/components/widgets/staking/subtensor/AddStakeDialog.tsx
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,110 @@ | ||
import type { Account } from '../../../../domains/accounts' | ||
import { useExtrinsicInBlockOrErrorEffect } from '../../../../domains/common' | ||
import { useAddStakeForm } from '../../../../domains/staking/subtensor/hooks/forms' | ||
import { useDelegate } from '../../../../domains/staking/subtensor/hooks/useDelegate' | ||
import { type Stake } from '../../../../domains/staking/subtensor/hooks/useStake' | ||
import { AddStakeDialog as _AddStakeDialog } from '../../../recipes/AddStakeDialog' | ||
import DelegatePickerDialog from './DelegatePickerDialog' | ||
import { CircularProgressIndicator } from '@talismn/ui' | ||
import { useState } from 'react' | ||
|
||
type SubtensorAddStakeDialogProps = { | ||
account: Account | ||
stake: Stake | ||
delegate: string | ||
onRequestDismiss: () => void | ||
} | ||
|
||
const SubtensorAddStakeDialog = (props: SubtensorAddStakeDialogProps) => { | ||
const { input, setInput, amount, transferable, resulting, extrinsic, ready, error } = useAddStakeForm( | ||
props.account, | ||
props.stake, | ||
props.delegate | ||
) | ||
|
||
useExtrinsicInBlockOrErrorEffect(() => props.onRequestDismiss(), extrinsic) | ||
|
||
const delegateName = useDelegate(props.delegate)?.name | ||
|
||
return ( | ||
<_AddStakeDialog | ||
message={ | ||
delegateName | ||
? `Increase your stake below. Talisman will automatically stake this towards the ${delegateName} delegate.` | ||
: `Increase your stake below. Talisman will automatically stake this towards your chosen delegate.` | ||
} | ||
confirmState={extrinsic.state === 'loading' ? 'pending' : !ready ? 'disabled' : undefined} | ||
isError={error !== undefined} | ||
availableToStake={transferable.decimalAmount.toLocaleString()} | ||
amount={input} | ||
onChangeAmount={setInput} | ||
onRequestMaxAmount={() => setInput(transferable.decimalAmount.toString())} | ||
fiatAmount={amount.localizedFiatAmount ?? ''} | ||
newAmount={resulting.decimalAmount?.toLocaleString() ?? <CircularProgressIndicator size="1em" />} | ||
newFiatAmount={resulting.localizedFiatAmount ?? <CircularProgressIndicator size="1em" />} | ||
onConfirm={() => { | ||
extrinsic.signAndSend(props.account.address).then(() => props.onRequestDismiss()) | ||
}} | ||
inputSupportingText={error?.message} | ||
onDismiss={props.onRequestDismiss} | ||
/> | ||
) | ||
} | ||
|
||
type MultiDelegateAddStakeDialogProps = { | ||
account: Account | ||
stake: Stake | ||
onRequestDismiss: () => void | ||
} | ||
|
||
const MultiDelegateAddStakeDialog = (props: MultiDelegateAddStakeDialogProps) => { | ||
const [delegate, setDelegate] = useState<string>() | ||
|
||
return delegate === undefined ? ( | ||
<DelegatePickerDialog | ||
title="Select a delegate to increase stake" | ||
account={props.account} | ||
onSelect={setDelegate} | ||
onRequestDismiss={props.onRequestDismiss} | ||
/> | ||
) : ( | ||
<SubtensorAddStakeDialog | ||
account={props.account} | ||
stake={props.stake} | ||
delegate={delegate} | ||
onRequestDismiss={props.onRequestDismiss} | ||
/> | ||
) | ||
} | ||
|
||
type AddStakeDialogProps = { | ||
account: Account | ||
stake: Stake | ||
onRequestDismiss: () => void | ||
} | ||
|
||
const AddStakeDialog = (props: AddStakeDialogProps) => { | ||
if (props.stake.stakes?.length === 1) | ||
return ( | ||
<SubtensorAddStakeDialog | ||
account={props.account} | ||
stake={props.stake} | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain | ||
delegate={props.stake.stakes.at(0)?.hotkey!} | ||
onRequestDismiss={props.onRequestDismiss} | ||
/> | ||
) | ||
|
||
if ((props.stake.stakes?.length ?? 0) > 1) | ||
return ( | ||
<MultiDelegateAddStakeDialog | ||
account={props.account} | ||
stake={props.stake} | ||
onRequestDismiss={props.onRequestDismiss} | ||
/> | ||
) | ||
|
||
return null | ||
} | ||
|
||
export default AddStakeDialog |
Oops, something went wrong.