Skip to content
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
26 changes: 17 additions & 9 deletions apps/browser-extension-wallet/src/lib/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,26 @@
"outgoing": "Sent",
"sending": "Sending",
"self": "Self Transaction",
"vote": "Vote Signing",
"HardForkInitiationAction": "Hard Fork Initiation Action",
"NewConstitution": "New Constitution Action",
"NoConfidence": "No Confidence Action",
"ParameterChangeAction": "Parameter Change Action",
"TreasuryWithdrawalsAction": "Treasury Withdrawals Action",
"UpdateCommittee": "Update Committee Action",
"InfoAction": "Info Action",
"UpdateDelegateRepresentativeCertificate": "Update DRep",
"StakeVoteDelegationCertificate": "Stake Vote Delegation Certificate",
"StakeRegistrationDelegationCertificate": "Stake Registration Delegation Certificate",
"VoteRegistrationDelegationCertificate": "Vote Registration Delegation Certificate",
"StakeVoteRegistrationDelegationCertificate": "Stake Vote Registration Delegation Certificate",
"ResignCommitteeColdCertificate": "Resign Committee",
"AuthorizeCommitteeHotCertificate": "Authorise Committee",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"AuthorizeCommitteeHotCertificate": "Authorise Committee",
"AuthorizeCommitteeHotCertificate": "Authorize Committee",

To reflect US english

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

"RegisterDelegateRepresentativeCertificate": "DRep Registration",
"UnregisterDelegateRepresentativeCertificate": "DRep De-Registration",
"UpdateDelegateRepresentativeCertificate": "DRep Update",
"ResignCommitteeColdCertificate": "Resign Committee",
"StakeRegistrationDelegationCertificate": "Stake Key Registration & Delgation",
"StakeVoteDelegationCertificate": "Stake Key Registration & DRep Delegation",
"StakeVoteRegistrationDelegationCertificate": "Stake Key Registration, Delegation, & DRep Delegation",
"VoteRegistrationDelegationCertificate": "Stake Key Registration & DRep Delegation",
"AuthorizeCommitteeHotCertificate": "Authorize Committee",
"VoteDelegationCertificate": "Vote Delegation",
"vote": "Vote Signing",
"submitProposal": "Governance Proposal"

"submitProposal": "Confirm Vote"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be Confirm Governance Action, please contact design if we need figma updating, otherwise we're using the wrong key if this pertains to confirming a vote in dApp connector

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does not exist anymore

},
"certificates": {
"headings": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { inspectTxValues } from '@src/utils/tx-inspection';
import { firstValueFrom } from 'rxjs';
import { getAssetsInformation } from '@src/utils/get-assets-information';
import { MAX_POOLS_COUNT } from '@lace/staking';
import { ActivityStatus, DelegationTransactionType, TransactionActivityType } from '@lace/core';
import { ActivityStatus, DelegationActivityType, TransactionActivityType } from '@lace/core';
import type { ActivityType } from '@lace/core';
import { formatDate, formatTime } from '@src/utils/format-date';
import {
Expand Down Expand Up @@ -65,11 +65,11 @@ const shouldIncludeFee = (
delegationInfo: Wallet.Cardano.StakeDelegationCertificate[] | undefined
) =>
!(
type === DelegationTransactionType.delegationRegistration ||
type === DelegationActivityType.delegationRegistration ||
// Existence of any (new) delegationInfo means that this "de-registration"
// activity is accompanied by a "delegation" activity, which carries the fees.
// However, fees should be shown if de-registration activity is standalone.
(type === DelegationTransactionType.delegationDeregistration && !!delegationInfo?.length)
(type === DelegationActivityType.delegationDeregistration && !!delegationInfo?.length)
);

const getPoolInfos = async (poolIds: Wallet.Cardano.PoolId[], stakePoolProvider: Wallet.StakePoolProvider) => {
Expand Down Expand Up @@ -191,14 +191,14 @@ const buildGetActivityDetail =
const deposit =
// since one tx can be split into two (delegation, registration) actions,
// ensure only the registration tx carries the deposit
implicitCoin.deposit && type === DelegationTransactionType.delegationRegistration
implicitCoin.deposit && type === DelegationActivityType.delegationRegistration
? Wallet.util.lovelacesToAdaString(implicitCoin.deposit.toString())
: undefined;
const depositReclaimValue = Wallet.util.calculateDepositReclaim(implicitCoin);
const depositReclaim =
// since one tx can be split into two (delegation, de-registration) actions,
// ensure only the de-registration tx carries the reclaimed deposit
depositReclaimValue && type === DelegationTransactionType.delegationDeregistration
depositReclaimValue && type === DelegationActivityType.delegationDeregistration
? Wallet.util.lovelacesToAdaString(depositReclaimValue.toString())
: undefined;
const feeInAda = Wallet.util.lovelacesToAdaString(tx.body.fee.toString());
Expand Down Expand Up @@ -226,7 +226,7 @@ const buildGetActivityDetail =
certificates: certificateTransformer(cardanoCoin, tx.body.certificates)
};

if (type === DelegationTransactionType.delegation && delegationInfo) {
if (type === DelegationActivityType.delegation && delegationInfo) {
const pools = await getPoolInfos(
delegationInfo.map(({ poolId }) => poolId),
stakePoolProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
ActivityStatus,
AssetActivityItemProps,
AssetActivityListProps,
DelegationTransactionType,
DelegationActivityType,
TransactionActivityType
} from '@lace/core';
import { CurrencyInfo, TxDirections } from '@src/types';
Expand Down Expand Up @@ -66,20 +66,20 @@ type MappedActivityListProps = Omit<AssetActivityListProps, 'items'> & {
export type FetchWalletActivitiesReturn = Observable<Promise<MappedActivityListProps[]>>;

type DelegationActivityItemProps = Omit<ExtendedActivityProps, 'type'> & {
type: DelegationTransactionType;
type: DelegationActivityType;
};

const isDelegationActivity = (activity: ExtendedActivityProps): activity is DelegationActivityItemProps =>
activity.type in DelegationTransactionType;
activity.type in DelegationActivityType;

const getDelegationAmount = (activity: DelegationActivityItemProps) => {
const fee = new BigNumber(Number.parseFloat(activity.fee));

if (activity.type === DelegationTransactionType.delegationRegistration) {
if (activity.type === DelegationActivityType.delegationRegistration) {
return fee.plus(activity.deposit);
}

if (activity.type === DelegationTransactionType.delegationDeregistration) {
if (activity.type === DelegationActivityType.delegationDeregistration) {
return new BigNumber(activity.depositReclaim).minus(fee);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,9 @@ describe('testing tx-inspection utils', () => {
rewardAccount: REWARD_ACCOUNT,
// eslint-disable-next-line unicorn/no-null
anchor: null,
governanceAction: {} as Wallet.Cardano.GovernanceAction,
governanceAction: {
__typename: Wallet.Cardano.GovernanceActionType.parameter_change_action
} as Wallet.Cardano.GovernanceAction,
deposit: BigInt(1)
}
]
Expand All @@ -438,7 +440,7 @@ describe('testing tx-inspection utils', () => {
{ address: ADDRESS_1, rewardAccount: REWARD_ACCOUNT }
] as Wallet.KeyManagement.GroupedAddress[]
});
expect(result).toEqual('submitProposal');
expect(result).toEqual('ParameterChangeAction');
});
});
});
Expand Down
5 changes: 0 additions & 5 deletions apps/browser-extension-wallet/src/utils/mocks/certificates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ export const mockConwayCertificates: Partial<
dRepCredential: CREDENTIAL,
anchor: null
},
[ConwayEraCertificatesTypes.VoteDelegation]: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to keep this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted

__typename: Wallet.Cardano.CertificateType.VoteDelegation,
dRep: CREDENTIAL,
stakeCredential: CREDENTIAL
},
[ConwayEraCertificatesTypes.StakeVoteDelegation]: {
__typename: Wallet.Cardano.CertificateType.StakeVoteDelegation,
stakeCredential: CREDENTIAL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,3 @@ export const drepRetirementTx: Wallet.Cardano.HydratedTx = {
certificates: [mockConwayCertificates[ConwayEraCertificatesTypes.UnregisterDelegateRepresentative]]
}
};

export const voteDelegationTx: Wallet.Cardano.HydratedTx = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should remain

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted

...tx,
body: {
...tx.body,
certificates: [mockConwayCertificates[ConwayEraCertificatesTypes.VoteDelegation]]
}
};
37 changes: 29 additions & 8 deletions apps/browser-extension-wallet/src/utils/tx-inspection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import {
import { Wallet } from '@lace/cardano';
import {
ActivityType,
DelegationTransactionType,
DelegationActivityType,
TransactionActivityType,
ConwayEraGovernanceActions,
ConwayEraCertificatesTypes
ConwayEraCertificatesTypes,
Cip1694GovernanceActivityType
} from '@lace/core';
import { TxDirection, TxDirections } from '@src/types';

Expand Down Expand Up @@ -60,8 +61,6 @@ const governanceCertificateInspection = (
return ConwayEraCertificatesTypes.UnregisterDelegateRepresentative;
case signedCertificateTypenames.includes(CertificateType.UpdateDelegateRepresentative):
return ConwayEraCertificatesTypes.UpdateDelegateRepresentative;
case signedCertificateTypenames.includes(CertificateType.VoteDelegation):
return ConwayEraCertificatesTypes.VoteDelegation;
case signedCertificateTypenames.includes(CertificateType.StakeVoteDelegation):
return ConwayEraCertificatesTypes.StakeVoteDelegation;
case signedCertificateTypenames.includes(CertificateType.StakeRegistrationDelegation):
Expand All @@ -77,6 +76,28 @@ const governanceCertificateInspection = (
}
};

// Assumes single procedure only
export const cip1694GovernanceActionsInspection = (
procedure: Wallet.Cardano.ProposalProcedure
): Cip1694GovernanceActivityType => {
switch (procedure.governanceAction.__typename) {
case Wallet.Cardano.GovernanceActionType.parameter_change_action:
return Cip1694GovernanceActivityType.ParameterChangeAction;
case Wallet.Cardano.GovernanceActionType.hard_fork_initiation_action:
return Cip1694GovernanceActivityType.HardForkInitiationAction;
case Wallet.Cardano.GovernanceActionType.treasury_withdrawals_action:
return Cip1694GovernanceActivityType.TreasuryWithdrawalsAction;
case Wallet.Cardano.GovernanceActionType.no_confidence:
return Cip1694GovernanceActivityType.NoConfidence;
case Wallet.Cardano.GovernanceActionType.update_committee:
return Cip1694GovernanceActivityType.UpdateCommittee;
case Wallet.Cardano.GovernanceActionType.new_constitution:
return Cip1694GovernanceActivityType.NewConstitution;
case Wallet.Cardano.GovernanceActionType.info_action:
return Cip1694GovernanceActivityType.InfoAction;
}
};

const getWalletAccounts = (walletAddresses: Wallet.KeyManagement.GroupedAddress[]) =>
walletAddresses.reduce(
(acc, curr) => ({
Expand Down Expand Up @@ -145,17 +166,17 @@ export const inspectTxType = ({
if (inspectionProperties.sent.inputs.length > 0 || withRewardsWithdrawal) {
switch (true) {
case !!inspectionProperties.delegation[0]?.poolId:
return DelegationTransactionType.delegation;
return DelegationActivityType.delegation;
case inspectionProperties.stakeKeyRegistration.length > 0:
return DelegationTransactionType.delegationRegistration;
return DelegationActivityType.delegationRegistration;
case inspectionProperties.stakeKeyDeregistration.length > 0:
return DelegationTransactionType.delegationDeregistration;
return DelegationActivityType.delegationDeregistration;
// Voting procedures take priority over proposals
// TODO: use proper inspector when available on sdk side (LW-9569)
case tx.body.votingProcedures?.length > 0:
return ConwayEraGovernanceActions.vote;
case tx.body.proposalProcedures?.length > 0:
return ConwayEraGovernanceActions.submitProposal;
return cip1694GovernanceActionsInspection(tx.body.proposalProcedures[0]);
case inspectionProperties.selfTransaction:
return TransactionActivityType.self;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
useTranslate,
RewardsDetails,
TransactionActivityType,
DelegationTransactionType
DelegationActivityType
} from '@lace/core';
import type { ActivityType } from '@lace/core';
import { PriceResult } from '@hooks';
Expand Down Expand Up @@ -80,9 +80,8 @@ interface ActivityDetailProps {
}

const getTypeLabel = (type: ActivityType, t: ReturnType<typeof useTranslate>['t']) => {
if (type === DelegationTransactionType.delegationRegistration) return t('package.core.activityDetails.registration');
if (type === DelegationTransactionType.delegationDeregistration)
return t('package.core.activityDetails.deregistration');
if (type === DelegationActivityType.delegationRegistration) return t('package.core.activityDetails.registration');
if (type === DelegationActivityType.delegationDeregistration) return t('package.core.activityDetails.deregistration');
if (type === TransactionActivityType.incoming) return t('package.core.activityDetails.received');
if (type === TransactionActivityType.outgoing) return t('package.core.activityDetails.sent');
return t(`package.core.activityDetails.${type}`);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { ReactElement, useMemo } from 'react';
import { ActivityStatus, DelegationTransactionType, TransactionDetails } from '@lace/core';
import { ActivityStatus, DelegationActivityType, TransactionDetails } from '@lace/core';
import { AddressListType, getTransactionData } from './ActivityDetail';
import { useWalletStore } from '@src/stores';
import { useAnalyticsContext, useExternalLinkOpener } from '@providers';
Expand Down Expand Up @@ -37,7 +37,7 @@ export const TransactionDetailsProxy = withAddressBookContext(
return `${CEXPLORER_BASE_URL[environmentName]}/${CEXPLORER_URL_PATHS.Tx}`;
}, [CEXPLORER_BASE_URL, CEXPLORER_URL_PATHS.Tx, environmentName]);
const getHeaderDescription = () => {
if (activityInfo.type === DelegationTransactionType.delegation) return '1 token';
if (activityInfo.type === DelegationActivityType.delegation) return '1 token';
return ` (${activityInfo?.assetAmount})`;
};
const isIncomingTransaction = direction === TxDirections.Incoming;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getTransactionTotalAmount } from '@src/utils/get-transaction-total-amou
import type { TransformedActivity, TransformedTransactionActivity } from './types';
import {
ActivityStatus,
DelegationTransactionType,
DelegationActivityType,
TxDetails,
TxDetailsCertificateTitles,
TxDetailsVotingProceduresTitles,
Expand Down Expand Up @@ -54,13 +54,13 @@ const splitDelegationTx = (tx: TransformedActivity): TransformedTransactionActiv
return [
{
...tx,
type: DelegationTransactionType.delegation,
type: DelegationActivityType.delegation,
// Deposit already shown in the delegationRegistration
deposit: undefined
},
{
...tx,
type: DelegationTransactionType.delegationRegistration,
type: DelegationActivityType.delegationRegistration,
// Let registration show just the deposit,
// and the other transaction show fee to avoid duplicity
fee: '0'
Expand All @@ -70,13 +70,13 @@ const splitDelegationTx = (tx: TransformedActivity): TransformedTransactionActiv
return [
{
...tx,
type: DelegationTransactionType.delegation,
type: DelegationActivityType.delegation,
// Reclaimed deposit already shown in the delegationDeregistration
depositReclaim: undefined
},
{
...tx,
type: DelegationTransactionType.delegationDeregistration,
type: DelegationActivityType.delegationDeregistration,
// Let de-registration show just the returned deposit,
// and the other transaction show fee to avoid duplicity
fee: '0'
Expand All @@ -87,7 +87,7 @@ const splitDelegationTx = (tx: TransformedActivity): TransformedTransactionActiv
return [
{
...tx,
type: DelegationTransactionType.delegation
type: DelegationActivityType.delegation
}
];
};
Expand Down Expand Up @@ -184,7 +184,7 @@ export const txTransformer = async ({
// SDK Ticket LW-8767 should fix the type of Input in TxInFlight to contain the address
const type = inspectTxType({ walletAddresses, tx: tx as unknown as Wallet.Cardano.HydratedTx });

if (type === DelegationTransactionType.delegation) {
if (type === DelegationActivityType.delegation) {
return splitDelegationTx(baseTransformedActivity);
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/core/src/ui/assets/icons/ban-outline.component.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading