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

feat: export json in activity detail #1331

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
ActivityStatus,
CoSignersListItem,
exportMultisigTransaction,
hasSigned,
SharedWalletTransactionDetails,
SignPolicy,
Expand All @@ -13,6 +14,7 @@ import { useSharedWalletData } from '@hooks';
import { AddressListType, getTransactionData } from '@views/browser/features/activity';
import { useAddressBookContext, withAddressBookContext } from '@src/features/address-book/context';
import { TransactionActivityDetail, TxDirection, TxDirections } from '@types';
import { Serialization } from '@cardano-sdk/core';

interface SharedWalletTransactionDetailsProxyProps {
amountTransformer: (amount: string) => string;
Expand Down Expand Up @@ -49,7 +51,8 @@ export const SharedWalletTransactionDetailsWrapper = withAddressBookContext(
const {
walletUI: { cardanoCoin },
walletInfo,
activityDetail
activityDetail,
currentChain
} = useWalletStore();
const { sharedWalletKey, getSignPolicy, coSigners } = useSharedWalletData();
const [signPolicy, setSignPolicy] = useState<SignPolicy>();
Expand Down Expand Up @@ -95,6 +98,11 @@ export const SharedWalletTransactionDetailsWrapper = withAddressBookContext(
[addressToNameMap, amountTransformer, cardanoCoin, txSummary]
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't you also need coSigners to be watched for changes?

Suggested change
[addressToNameMap, amountTransformer, cardanoCoin, txSummary]
[addressToNameMap, amountTransformer, cardanoCoin, txSummary, coSigners]

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 in slack.

);

const onExportTransaction = async () => {
const cbor = Serialization.Transaction.fromCore(activityDetail.activity as Wallet.Cardano.Tx).toCbor();
await exportMultisigTransaction(cbor, sharedWalletKey, currentChain);
};

return (
<SharedWalletTransactionDetails
amountTransformer={amountTransformer}
Expand All @@ -109,6 +117,7 @@ export const SharedWalletTransactionDetailsWrapper = withAddressBookContext(
}}
status={ActivityStatus.AWAITING_COSIGNATURES}
txInitiator={sharedWalletKey}
onExportTransaction={onExportTransaction}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable complexity */
import { Box, SummaryExpander, Text, TransactionSummary } from '@input-output-hk/lace-ui-toolkit';
import { Box, Button, Flex, SummaryExpander, Text, TransactionSummary } from '@input-output-hk/lace-ui-toolkit';
import { Wallet } from '@lace/cardano';
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
Expand All @@ -17,6 +17,7 @@ export interface SharedWalletTransactionDetailsProps {
coinSymbol: string;
cosigners: CoSignersListItem[];
fee: string;
onExportTransaction?: () => void;
ownSharedKey: Wallet.Crypto.Bip32PublicKeyHex;
rows: OutputSummaryProps[];
signPolicy: SignPolicy;
Expand All @@ -34,6 +35,7 @@ export const SharedWalletTransactionDetails = ({
txInitiator,
ownSharedKey,
rows,
onExportTransaction,
}: SharedWalletTransactionDetailsProps): React.ReactElement => {
const { t } = useTranslation();
const [isSummaryOpen, setIsSummaryOpen] = useState(true);
Expand Down Expand Up @@ -125,6 +127,19 @@ export const SharedWalletTransactionDetails = ({
</Box>
</SummaryExpander>
</div>
{signed.length > 0 && (
<Flex mb="$20" alignItems="center" flexDirection="column">
<Button.CallToAction
w="$fill"
onClick={onExportTransaction}
data-testid="download-json-button"
label={t('sharedWallets.transaction.download.button')}
/>
<Box my="$12">
<Text.Body.Normal>{t('sharedWallets.transaction.summary.forwardTransaction')}</Text.Body.Normal>
</Box>
</Flex>
)}
</Transaction.Content>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@
"sharedWallets.transaction.summary.validityPeriod.title": "Transaction validity period",
"sharedWallets.transaction.summary.validityPeriod.value": "{{hours}} Hours",
"sharedWallets.transaction.summary.validityPeriod.tooltip": "The maximum duration a transaction remains valid before it is automatically canceled if not completed with all the required signatures.",
"sharedWallets.transaction.summary.forwardTransaction": "Forward the transaction JSON to your chosen cosigner.",
"sharedWallets.transaction.cosigners.title": "Co-signers",
"sharedWallets.transaction.download.button": "Download transaction JSON",
"sharedWallets.transaction.cosigners.quorum.reached": "Quorum reached. Transaction ready for network submission.",
"sharedWallets.transaction.cosigners.quorum.required": "Additional co-signatures are required before transaction can be submitted.",
"sharedWallets.transaction.cosigners.quorum.current": "<stat><b>{{quorum}}</b> of <b>{{participants}}</b></stat><span>required</span>",
Expand Down
Loading