Skip to content
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

wip: inline staking #1585

Merged
merged 58 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
f91de84
wip: chaindata staking config
0xKheops Aug 12, 2024
be57f63
wip: inline staking modal
0xKheops Aug 15, 2024
17430f3
feat: account picker
0xKheops Aug 16, 2024
98a17e8
feat: available balance
0xKheops Aug 16, 2024
f59d5be
wip: pool picker
0xKheops Aug 16, 2024
18a73ae
feat: green & red colors update
0xKheops Aug 19, 2024
47903d0
wip: pool picker
0xKheops Aug 19, 2024
f2c4089
wip: inline staking input form
0xKheops Aug 19, 2024
384eb03
fix: ts
0xKheops Aug 19, 2024
14c034e
refactor: single atom for the wizard
0xKheops Aug 20, 2024
433b785
feat: review form + polishing
0xKheops Aug 20, 2024
5c21305
feat: ui for tx submit & follow up
0xKheops Aug 20, 2024
8f85879
Merge branch 'dev' into feat/inline-staking
0xKheops Aug 22, 2024
e3d78b5
feat: compute apr
0xKheops Aug 22, 2024
8d2dd70
feat: scale api for frontend
0xKheops Aug 23, 2024
5be3ed8
chore: cleanup
0xKheops Aug 23, 2024
973e8ed
wip: tx submit
0xKheops Aug 23, 2024
390c921
feat: sapi signing
0xKheops Aug 26, 2024
e6a8283
wip: sapi send button
0xKheops Aug 26, 2024
16282f1
feat: fee estimate
0xKheops Aug 27, 2024
dde349f
feat: sapi sign ledger
0xKheops Aug 27, 2024
bed2b3d
feat: sapi sign with vault (+fix fee estimate)
0xKheops Aug 27, 2024
9ec8b41
feat: error management
0xKheops Aug 28, 2024
eb201e6
feat: nom pools on more chains + bunch fine tuning
0xKheops Aug 28, 2024
af1e3ea
chore: cleanup
0xKheops Aug 28, 2024
5ca7186
refactor: eliminate suspenses - I hate jotai
0xKheops Aug 28, 2024
bc84050
feat: dashboard stake button
0xKheops Aug 29, 2024
f2680c8
chore: cleanup
0xKheops Aug 29, 2024
12873b6
feat: unbonding period on review form too
0xKheops Aug 29, 2024
ba6f947
feat: claim permissions
0xKheops Aug 29, 2024
50c228c
feat: unstaking
0xKheops Aug 29, 2024
d8aa00a
chore: cleanup
0xKheops Aug 29, 2024
e7fbacc
feat: unbond from popup
0xKheops Aug 30, 2024
9a7e41d
fix: better unbonding pill
0xKheops Aug 30, 2024
714927e
fix: remove unstake context menu entry
0xKheops Aug 30, 2024
cb619c3
feat: nom pool withdrawal flow
0xKheops Aug 30, 2024
65efd71
refactor: nom pool unbound folder
0xKheops Aug 30, 2024
22aa230
refactor: nom pool bond folder
0xKheops Aug 30, 2024
c74747c
feat: bond extra
0xKheops Sep 2, 2024
1f2e87e
refactor: folder structure
0xKheops Sep 2, 2024
e8a4c96
chore: better comments
0xKheops Sep 2, 2024
aaeb67d
chore: cleanup
0xKheops Sep 2, 2024
8b220b8
chore: cleanup
0xKheops Sep 2, 2024
cd5a940
chore: revert chaindata provider changes
0xKheops Sep 2, 2024
4f1f3d1
feat: remove some pjs
0xKheops Sep 2, 2024
455add9
chore: rollback icon
0xKheops Sep 2, 2024
ec6b538
chore: cleanup
0xKheops Sep 2, 2024
5cc0249
chore: log
0xKheops Sep 2, 2024
101c59e
chore: cleanup
0xKheops Sep 2, 2024
a9a0f97
refactor: main stake button
0xKheops Sep 3, 2024
7e5bd6c
feat: stake from portfolio & remove banners
0xKheops Sep 3, 2024
d4b5a1d
feat: portfolio stake buttons
0xKheops Sep 4, 2024
2e0563a
fix: error message layout
0xKheops Sep 4, 2024
b6417f8
fix: azero and avail specifics
0xKheops Sep 4, 2024
ec6edc5
chore: changeset
0xKheops Sep 4, 2024
986c33b
feat: analytics on submit
0xKheops Sep 6, 2024
09c7782
chore: rename arg
0xKheops Sep 6, 2024
3b36aa5
fix: requested changes
0xKheops Sep 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wicked-pugs-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@talismn/icons": minor
---

staking icons
8 changes: 8 additions & 0 deletions apps/extension/src/ui/api/api.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { HexString } from "@polkadot/util/types"
import { SignerPayloadJSON } from "extension-core"

import PortMessageService from "@common/PortMessageService"

import MessageTypes from "./types"
Expand Down Expand Up @@ -329,6 +332,11 @@ export const api: MessageTypes = {
params,
isCacheable,
}) as Promise<T>,
subSubmit: (payload: SignerPayloadJSON, signature?: HexString) =>
messageService.sendMessage("pri(substrate.rpc.submit)", {
payload,
signature,
}),
subChainMetadata: (genesisHash, specVersion, blockHash) =>
messageService.sendMessage("pri(substrate.metadata.get)", {
genesisHash,
Expand Down
1 change: 1 addition & 0 deletions apps/extension/src/ui/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ export default interface MessageTypes {
params: unknown[],
isCacheable?: boolean
) => Promise<T>
subSubmit: (payload: SignerPayloadJSON, signature?: HexString) => Promise<{ hash: HexString }>

// substrate chain metadata
subChainMetadata: (
Expand Down
13 changes: 10 additions & 3 deletions apps/extension/src/ui/apps/dashboard/layout/DashboardLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { classNames } from "@talismn/util"
import { FC, Suspense, useEffect, useRef, useState } from "react"
import { useLocation } from "react-router-dom"

import { BackButton } from "@talisman/components/BackButton"
import { SuspenseTracker } from "@talisman/components/SuspenseTracker"
import { classNames } from "@talismn/util"
import { AnalyticsPage } from "@ui/api/analytics"
import { AccountExportModal } from "@ui/domains/Account/AccountExportModal"
import { AccountExportPrivateKeyModal } from "@ui/domains/Account/AccountExportPrivateKeyModal"
Expand All @@ -9,9 +12,10 @@ import { AccountRenameModal } from "@ui/domains/Account/AccountRenameModal"
import { BuyTokensModal } from "@ui/domains/Asset/Buy/BuyTokensModal"
import { CopyAddressModal } from "@ui/domains/CopyAddress"
import { MigratePasswordModal } from "@ui/domains/Settings/MigratePassword/MigratePasswordModal"
import { NomPoolBondModal } from "@ui/domains/Staking/NomPoolBond/NomPoolBondModal"
import { NomPoolUnbondModal } from "@ui/domains/Staking/NomPoolUnbond/NomPoolUnbondModal"
import { NomPoolWithdrawModal } from "@ui/domains/Staking/NomPoolWithdraw/NomPoolWithdrawModal"
import { ExplorerNetworkPickerModal } from "@ui/domains/ViewOnExplorer"
import { FC, Suspense, useEffect, useRef, useState } from "react"
import { useLocation } from "react-router-dom"

import DashboardNotifications from "./DashboardNotifications"
import { BackupWarningModal } from "./DashboardNotifications/BackupWarningModal"
Expand Down Expand Up @@ -58,6 +62,9 @@ const DashboardNotificationsAndModals = () => {
<ExplorerNetworkPickerModal />
<MigratePasswordModal />
<OnboardingToast />
<NomPoolBondModal />
<NomPoolUnbondModal />
<NomPoolWithdrawModal />
</Suspense>
)
}
Expand Down
25 changes: 18 additions & 7 deletions apps/extension/src/ui/apps/popup/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { AUTH_PREFIX } from "@extension/core"
import { SIGNING_TYPES } from "@extension/core"
import { METADATA_PREFIX } from "@extension/core"
import { ETH_NETWORK_ADD_PREFIX, WATCH_ASSET_PREFIX } from "@extension/core"
import { ENCRYPT_DECRYPT_PREFIX, ENCRYPT_ENCRYPT_PREFIX } from "@extension/core"
import { Suspense, useEffect } from "react"
import { Navigate, Route, Routes } from "react-router-dom"

import {
AUTH_PREFIX,
ENCRYPT_DECRYPT_PREFIX,
ENCRYPT_ENCRYPT_PREFIX,
ETH_NETWORK_ADD_PREFIX,
METADATA_PREFIX,
SIGNING_TYPES,
WATCH_ASSET_PREFIX,
} from "@extension/core"
import { FadeIn } from "@talisman/components/FadeIn"
import { SuspenseTracker } from "@talisman/components/SuspenseTracker"
import { api } from "@ui/api"
Expand All @@ -12,10 +19,11 @@ import { AccountRemoveModal } from "@ui/domains/Account/AccountRemoveModal"
import { AccountRenameModal } from "@ui/domains/Account/AccountRenameModal"
import { CopyAddressModal } from "@ui/domains/CopyAddress"
import { DatabaseErrorAlert } from "@ui/domains/Settings/DatabaseErrorAlert"
import { NomPoolBondModal } from "@ui/domains/Staking/NomPoolBond/NomPoolBondModal"
import { NomPoolUnbondModal } from "@ui/domains/Staking/NomPoolUnbond/NomPoolUnbondModal"
import { NomPoolWithdrawModal } from "@ui/domains/Staking/NomPoolWithdraw/NomPoolWithdrawModal"
import { ExplorerNetworkPickerModal } from "@ui/domains/ViewOnExplorer"
import { useLoginCheck } from "@ui/hooks/useLoginCheck"
import { Suspense, useEffect } from "react"
import { Navigate, Route, Routes } from "react-router-dom"

import { BackupWarningDrawer } from "./components/BackupWarningDrawer"
import { LedgerPolkadotUpgradeAlertDrawer } from "./components/LedgerPolkadotUpgradeDrawer"
Expand Down Expand Up @@ -73,6 +81,9 @@ const Popup = () => {
<ExplorerNetworkPickerModal />
<BackupWarningDrawer />
<LedgerPolkadotUpgradeAlertDrawer />
<NomPoolBondModal />
<NomPoolUnbondModal />
<NomPoolWithdrawModal />
</Suspense>
{/* Render outside of suspense or it will never show in case of migration error */}
<DatabaseErrorAlert container="popup" />
Expand Down
3 changes: 2 additions & 1 deletion apps/extension/src/ui/atoms/balances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const balancesHydrateAtom = atom(async (get) => {
return { chains, evmNetworks, tokens, tokenRates } as HydrateDb
})

const allBalancesAtom = atom(async (get) => {
export const allBalancesAtom = atom(async (get) => {
const [rawBalances, hydrate] = await Promise.all([
get(filteredRawBalancesAtom),
get(balancesHydrateAtom),
Expand All @@ -77,6 +77,7 @@ const allBalancesAtom = atom(async (get) => {

type BalanceQueryParams = { address?: Address; tokenId?: TokenId }

/** @deprecated this suspenses for every new key, try to use another approach */
export const balancesAtomFamily = atomFamily(
({ address, tokenId }: BalanceQueryParams) =>
atom(async (get) => {
Expand Down
13 changes: 2 additions & 11 deletions apps/extension/src/ui/atoms/chaindata.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { HexString } from "@polkadot/util/types"
import {
Chain,
ChainId,
ChainList,
CustomChain,
EvmNetworkId,
EvmNetworkList,
TokenId,
Expand Down Expand Up @@ -201,19 +199,12 @@ const activeChainsWithoutTestnetsMapAtom = atom(async (get) => {
return Object.fromEntries(chains.map((network) => [network.id, network])) as ChainList
})

const chainsByGenesisHashMapAtom = atom(async (get) => {
const chains = await get(allChainsAtom)
return Object.fromEntries(chains.map((chain) => [chain.genesisHash, chain])) as Record<
HexString,
Chain | CustomChain
>
})

/** @deprecated this suspenses for every new key, try to use another approach */
export const chainByGenesisHashAtomFamily = atomFamily(
(genesisHash: HexString | null | undefined) =>
atom(async (get) => {
if (!genesisHash) return null
const chains = await get(chainsByGenesisHashMapAtom)
const chains = await get(allChainsMapByGenesisHashAtom)
return chains[genesisHash] || null
})
)
Expand Down
1 change: 1 addition & 0 deletions apps/extension/src/ui/atoms/tokenRates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const tokenRatesMapAtom = atom(async (get) => {
return Object.fromEntries(tokenRates.map(({ tokenId, rates }) => [tokenId, rates]))
})

/** @deprecated this suspenses for every new key, try to use another approach */
export const tokenRatesByIdFamily = atomFamily((tokenId: TokenId | null | undefined) =>
atom(async (get) => {
if (!tokenId) return null
Expand Down
16 changes: 14 additions & 2 deletions apps/extension/src/ui/domains/Asset/TokensAndFiat.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { BalanceFormatter } from "@talismn/balances"
import { FC, Suspense, useMemo } from "react"

import { useSelectedCurrency } from "@ui/hooks/useCurrency"
import useToken from "@ui/hooks/useToken"
import { useTokenRates } from "@ui/hooks/useTokenRates"
import { FC, Suspense, useMemo } from "react"

import { Fiat } from "./Fiat"
import Tokens from "./Tokens"
Expand All @@ -16,6 +17,8 @@ type TokensAndFiatProps = {
noCountUp?: boolean
isBalance?: boolean
noFiat?: boolean
tokensClassName?: string
fiatClassName?: string
}

const TokensAndFiatInner: FC<TokensAndFiatProps> = ({
Expand All @@ -26,6 +29,8 @@ const TokensAndFiatInner: FC<TokensAndFiatProps> = ({
noCountUp,
isBalance,
noFiat,
tokensClassName,
fiatClassName,
}) => {
const token = useToken(tokenId)
const tokenRates = useTokenRates(tokenId)
Expand All @@ -50,13 +55,20 @@ const TokensAndFiatInner: FC<TokensAndFiatProps> = ({
noCountUp={noCountUp}
noTooltip={noTooltip}
isBalance={isBalance}
className={tokensClassName}
/>
{/* warning : some tokens (ex: EQ) have a fiatRates object, but with null values for all fiat currencies */}
{balance.fiat(currency) !== null && !noFiat ? (
<>
{" "}
(
<Fiat amount={balance} isBalance={isBalance} noCountUp={noCountUp} />)
<Fiat
amount={balance}
isBalance={isBalance}
noCountUp={noCountUp}
className={fiatClassName}
/>
)
</>
) : null}
</span>
Expand Down
Loading
Loading