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

Release 6.15.0 #1438

Merged
merged 7 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 15 additions & 7 deletions app/frontend/actions/delegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,16 @@ export default (store: Store) => {
}
await setPoolInfo(state)
const poolHash = state.shelleyDelegation.selectedPool.poolHash as string
const isStakingKeyRegistered = getSourceAccountInfo(state).shelleyAccountInfo.hasStakingKey
const stakingAddress = getSourceAccountInfo(state).stakingAddress
const {
shelleyAccountInfo: {hasStakingKey: isStakingKeyRegistered, hasVoteDelegation},
stakingAddress,
} = getSourceAccountInfo(state)
const txPlanResult = prepareTxPlan({
poolHash,
stakingAddress,
isStakingKeyRegistered,
txType: TxType.DELEGATE,
hasVoteDelegation,
})
const newState = getState()
if (hasPoolIdentifiersChanged(newState)) {
Expand Down Expand Up @@ -180,15 +183,20 @@ export default (store: Store) => {
}

state = getState()
const sourceAccount = getSourceAccountInfo(state)
const rewards = getSourceAccountInfo(state).shelleyBalances.rewardsAccountBalance as Lovelace
const balance = getSourceAccountInfo(state).balance as Lovelace
const {
accountIndex,
balance,
stakingAddress,
shelleyAccountInfo: {hasVoteDelegation},
shelleyBalances: {rewardsAccountBalance: rewards},
} = getSourceAccountInfo(state)

loadingAction(state, 'Preparing transaction...')
const txPlanResult = prepareTxPlan({
txType: TxType.DEREGISTER_STAKE_KEY,
rewards,
stakingAddress: sourceAccount.stakingAddress,
stakingAddress,
hasVoteDelegation,
})
if (txPlanResult.success === true) {
const summary = {
Expand All @@ -199,7 +207,7 @@ export default (store: Store) => {

setTransactionSummary(getState(), {plan: txPlanResult.txPlan, transactionSummary: summary})
await confirmTransaction(getState(), {
sourceAccountIndex: sourceAccount.accountIndex,
sourceAccountIndex: accountIndex,
txPlan: txPlanResult.txPlan,
txConfirmType: TxType.DEREGISTER_STAKE_KEY,
})
Expand Down
20 changes: 10 additions & 10 deletions app/frontend/actions/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ export default (store: Store) => {
let txAux
try {
if (txPlan) {
txAux = await getWallet()
.getAccount(sourceAccountIndex)
.prepareTxAux(txPlan)
txAux = await getWallet().getAccount(sourceAccountIndex).prepareTxAux(txPlan)
} else {
loadingAction(state, 'Preparing transaction plan...')
await sleep(1000) // wait for plan to be set in case of unfortunate timing
Expand Down Expand Up @@ -220,12 +218,8 @@ export default (store: Store) => {
let sendResponse
try {
assert(txSummary.plan != null)
const txAux = await getWallet()
.getAccount(sourceAccountIndex)
.prepareTxAux(txSummary.plan)
const signedTx = await getWallet()
.getAccount(sourceAccountIndex)
.signTxAux(txAux)
const txAux = await getWallet().getAccount(sourceAccountIndex).prepareTxAux(txSummary.plan)
const signedTx = await getWallet().getAccount(sourceAccountIndex).signTxAux(txAux)
if (isHwWallet(cryptoProviderType)) {
setState({waitingHwWalletOperation: null})
stopLoadingAction(state)
Expand Down Expand Up @@ -330,7 +324,13 @@ export default (store: Store) => {
// TODO: rewards should be of type Lovelace
const rewards = getSourceAccountInfo(state).shelleyBalances.rewardsAccountBalance as Lovelace
const stakingAddress = getSourceAccountInfo(state).stakingAddress
const txPlanResult = prepareTxPlan({rewards, stakingAddress, txType: TxType.WITHDRAW})
const hasVoteDelegation = getSourceAccountInfo(state).shelleyAccountInfo.hasVoteDelegation
const txPlanResult = prepareTxPlan({
rewards,
stakingAddress,
hasVoteDelegation,
txType: TxType.WITHDRAW,
})
// TODO: balance should be of type Lovelace
const balance = getSourceAccountInfo(state).balance as Lovelace

Expand Down
14 changes: 14 additions & 0 deletions app/frontend/components/common/infoModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ class InfoModal extends Component<Props, {dontShowAgainCheckbox: boolean; should
<section className="welcome">
<div className="welcome-body">
<h2 className="welcome-title">AdaLite News</h2>
<NewsSection
date={'11/27/2024'}
children={
<Fragment>
<Article title="AdaLite is now Chang Hardfork #2 ready" icon="">
<p className="info-spaced-paragraph">
When you delegate, re-delegate or withdraw rewards, we will automatically set
the DRep delegation for you to "Always Abstain", if you weren't delegating to
a DRep already. If you want to know more, please check "Voting" tab.
</p>
</Article>
</Fragment>
}
/>
<NewsSection
date={'11/13/2024'}
children={
Expand Down
13 changes: 8 additions & 5 deletions app/frontend/components/pages/dashboard/dashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ import {formatAccountIndex} from '../../../helpers/formatAccountIndex'
import ConfirmTransactionDialog from '../sendAda/confirmTransactionDialog'
import SendTransactionModal from '../accounts/sendTransactionModal'
import DelegationModal from '../accounts/delegationModal'
import VotingCard from '../voting/votingCard'
import VotingDialog from '../voting/votingDialog'
import CatalystVotingCard from '../voting/catalyst/catalystVotingCard'
import VotingDialog from '../voting/catalyst/votingDialog'
import {WalletOperationStatusType} from './walletOperationStatus'
import NufiBanner from '../../common/nufiBanner'
import {isEqual} from 'lodash'
import GovernanceVotingCard from '../voting/governance/governanceVotingCard'

const StakingPage = ({screenType}: {screenType: ScreenType}) => {
const subTabs = [SubTabs.DELEGATE_ADA, SubTabs.CURRENT_DELEGATION, SubTabs.STAKING_HISTORY]
Expand Down Expand Up @@ -171,9 +172,11 @@ const VotingPage = ({screenType}: {screenType: ScreenType}) => {
) : (
<div className="dashboard desktop">
<div className="dashboard-column">
<VotingCard />
<CatalystVotingCard />
</div>
<div className="dashboard-column">
<GovernanceVotingCard />
</div>
<div className="dashboard-column" />
</div>
)}
</Fragment>
Expand Down Expand Up @@ -225,7 +228,7 @@ const SubPages: {[key in SubTabs]: any} = {
[SubTabs.BALANCE]: <Balance />,
[SubTabs.SHELLEY_BALANCES]: <ShelleyBalances />,
[SubTabs.MY_ADDRESSES_REDIRECT]: <ReceiveRedirect />,
[SubTabs.VOTING]: <VotingCard />,
[SubTabs.VOTING]: <CatalystVotingCard />,
}

const DashboardPage = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {Fragment, h} from 'preact'
import {useState, useEffect} from 'preact/hooks'
import {encryptWithPassword} from '../../../helpers/catalyst'
import * as QRious from '../../../libs/qrious'
import Alert from '../../common/alert'
import {encryptWithPassword} from '../../../../helpers/catalyst'
import * as QRious from '../../../../libs/qrious'
import Alert from '../../../common/alert'
import VotingDialogBottom from './votingDialogBottom'
import styles from './voting.module.scss'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import {h} from 'preact'
import actions from '../../../actions'
import {useActions, useSelector} from '../../../helpers/connect'
import tooltip from '../../common/tooltip'
import {getVotingRegistrationStatus, shouldDisableSendingButton} from '../../../helpers/common'
import actions from '../../../../actions'
import {useActions, useSelector} from '../../../../helpers/connect'
import tooltip from '../../../common/tooltip'
import {getVotingRegistrationStatus, shouldDisableSendingButton} from '../../../../helpers/common'
import {
hasStakingKey,
useActiveAccount,
useHasEnoughFundsForCatalyst,
useIsWalletFeatureSupported,
} from '../../../selectors'
import {CATALYST_MIN_THRESHOLD} from '../../../wallet/constants'
import {CryptoProviderFeature, Lovelace} from '../../../types'
import {toAda} from '../../../helpers/adaConverters'
} from '../../../../selectors'
import {CATALYST_MIN_THRESHOLD} from '../../../../wallet/constants'
import {CryptoProviderFeature, Lovelace} from '../../../../types'
import {toAda} from '../../../../helpers/adaConverters'
import styles from './voting.module.scss'
import * as QRious from '../../../libs/qrious'
import * as QRious from '../../../../libs/qrious'
import BigNumber from 'bignumber.js'

const AppDownloadInfo = ({url, imageSrc}: {url: string; imageSrc: string}) => (
Expand All @@ -32,7 +32,7 @@ const AppDownloadInfo = ({url, imageSrc}: {url: string; imageSrc: string}) => (
</div>
)

const VotingCard = (): h.JSX.Element => {
const CatalystVotingCard = (): h.JSX.Element => {
const {openVotingDialog} = useActions(actions)
const {walletOperationStatusType} = useSelector((state) => ({
walletOperationStatusType: state.walletOperationStatusType,
Expand Down Expand Up @@ -67,7 +67,7 @@ const VotingCard = (): h.JSX.Element => {

return (
<div className="card" data-cy="VotingCard">
<h2 className="card-title">Voting</h2>
<h2 className="card-title">Catalyst Voting</h2>
<p className="advanced-label">Download the Catalyst Voting APP</p>
<p>
In order to participate in Catalyst Funds, first you have to download the Catalyst mobile
Expand Down Expand Up @@ -104,4 +104,4 @@ const VotingCard = (): h.JSX.Element => {
)
}

export default VotingCard
export default CatalystVotingCard
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {Fragment, h} from 'preact'
import {Ref, useState} from 'preact/hooks'
import {stripNonNumericCharacters} from '../../../helpers/common'
import {VOTING_PIN_LENGTH} from '../../../wallet/constants'
import Alert from '../../common/alert'
import {stripNonNumericCharacters} from '../../../../helpers/common'
import {VOTING_PIN_LENGTH} from '../../../../wallet/constants'
import Alert from '../../../common/alert'
import VotingDialogBottom from './votingDialogBottom'
import styles from './voting.module.scss'
import {useActions} from '../../../../frontend/helpers/connect'
import actions from '../../../../frontend/actions'
import {useActions} from '../../../../../frontend/helpers/connect'
import actions from '../../../../../frontend/actions'

const PinPage = ({
pin,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {Fragment, h} from 'preact'
import actions from '../../../actions'
import {useActions, useSelector} from '../../../helpers/connect'
import {HexString} from '../../../types'
import Alert from '../../common/alert'
import actions from '../../../../actions'
import {useActions, useSelector} from '../../../../helpers/connect'
import {HexString} from '../../../../types'
import Alert from '../../../common/alert'
import VotingDialogBottom from './votingDialogBottom'
import styles from './voting.module.scss'
import {WalletOperationStatusType} from '../dashboard/walletOperationStatus'
import {shouldDisableSendingButton} from '../../../helpers/common'
import {WalletOperationStatusType} from '../../dashboard/walletOperationStatus'
import {shouldDisableSendingButton} from '../../../../helpers/common'

const TransactionPage = ({
nextStep,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '../../../variables.scss';
@import '../../../../variables.scss';

.progressBar {
display: grid;
Expand Down Expand Up @@ -119,7 +119,7 @@
background-position: center;
background-repeat: no-repeat;
background-size: contain;
background-image: url('../../../../public/assets/alert_icon_success.svg');
background-image: url('../../../../../public/assets/alert_icon_success.svg');
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {h} from 'preact'
import {useEffect, useRef, useState} from 'preact/hooks'
import actions from '../../../actions'
import assertUnreachable from '../../../helpers/assertUnreachable'
import {stripNonNumericCharacters} from '../../../helpers/common'
import {useActions} from '../../../helpers/connect'
import {VOTING_PIN_LENGTH} from '../../../wallet/constants'
import mnemonicToWalletSecretDef from '../../../wallet/helpers/mnemonicToWalletSecretDef'
import {generateMnemonic} from '../../../wallet/mnemonic'
import Modal from '../../common/modal'
import actions from '../../../../actions'
import assertUnreachable from '../../../../helpers/assertUnreachable'
import {stripNonNumericCharacters} from '../../../../helpers/common'
import {useActions} from '../../../../helpers/connect'
import {VOTING_PIN_LENGTH} from '../../../../wallet/constants'
import mnemonicToWalletSecretDef from '../../../../wallet/helpers/mnemonicToWalletSecretDef'
import {generateMnemonic} from '../../../../wallet/mnemonic'
import Modal from '../../../common/modal'
import PinPage from './pinPage'
import ProgressBar from './progressBar'
import QRPage from './QRPage'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import {h} from 'preact'

const GovernanceVotingCard = (): h.JSX.Element => {
return (
<div className="card" data-cy="VotingCard">
<h2 className="card-title">Cardano Governance Voting</h2>
<p className="info-spaced-paragraph">
You can use your ADA's voting power in governance-related decisions that shape how Cardano
blockchain is run! You can also delegate your ADA's voting power and allow a DRep to vote on
your behalf.
</p>
<p className="info-spaced-paragraph">
To vote or to delegate your voting rights, you'll need to connect your wallet to{' '}
<a href="https://gov.tools" target="_blank">
gov.tools
</a>{' '}
- Cardano's governance portal.
</p>
<p className="info-spaced-paragraph">
In order to receive staking rewards, you have to delegate your voting power to a DRep. On
AdaLite, we handle this by automatically setting your delegation to "Always Abstain" when
you make your first stake delegation or withdrawal request. If you wish to participate in
Cardano Governance, please migrate to our Web3 wallet,{' '}
<a
href="https://chromewebstore.google.com/detail/nufi/gpnihlnnodeiiaakbikldcihojploeca"
target="_blank"
>
NuFi
</a>
, and then connect to{' '}
<a href="https://gov.tools" target="_blank">
gov.tools
</a>{' '}
(BitBox wallet support coming soon to NuFi!)
</p>
</div>
)
}

export default GovernanceVotingCard
5 changes: 5 additions & 0 deletions app/frontend/helpers/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,8 @@ export function getCexplorerUrl() {
SANCHONET: 'https://sancho.cexplorer.io',
}[ADALITE_CONFIG.ADALITE_NETWORK]
}

// https://stackoverflow.com/questions/39419170/how-do-i-check-that-a-switch-block-is-exhaustive-in-typescript
export const safeAssertUnreachable = (x: never): never => {
throw new Error(`Unreachable switch case:${x}`)
}
1 change: 1 addition & 0 deletions app/frontend/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ const initialState: State = {
currentEpoch: 0,
delegation: {},
hasStakingKey: false,
hasVoteDelegation: false,
rewards: '0',
rewardDetails: {
upcoming: null,
Expand Down
5 changes: 5 additions & 0 deletions app/frontend/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export enum CertificateType {
STAKING_KEY_DEREGISTRATION = 1,
DELEGATION = 2,
STAKEPOOL_REGISTRATION = 3,
VOTE_DELEGATION = 9,
}

export enum CryptoProviderFeature {
Expand Down Expand Up @@ -171,6 +172,7 @@ export type AccountInfo = {
currentEpoch: number
delegation: any
hasStakingKey: boolean
hasVoteDelegation: boolean
rewards: string
rewardDetails: {
upcoming: any
Expand Down Expand Up @@ -267,13 +269,15 @@ export type WithdrawRewardsTxPlanArgs = {
txType: TxType.WITHDRAW
rewards: Lovelace
stakingAddress: Address
hasVoteDelegation: boolean
}

export type DelegateAdaTxPlanArgs = {
txType: TxType.DELEGATE
poolHash: string
isStakingKeyRegistered: boolean
stakingAddress: Address
hasVoteDelegation: boolean
}

export type PoolOwnerTxPlanArgs = {
Expand All @@ -285,6 +289,7 @@ export type DeregisterStakingKeyTxPlanArgs = {
txType: TxType.DEREGISTER_STAKE_KEY
rewards: Lovelace
stakingAddress: Address
hasVoteDelegation: boolean
}

export type VotingRegistrationTxPlanArgs = {
Expand Down
Loading
Loading