Skip to content

Commit

Permalink
Merge pull request #701 from secretkeylabs/vic/more-rc-fixes
Browse files Browse the repository at this point in the history
Fix balance breakdown label for ordinals and tooltip, batch sign loader for listing
  • Loading branch information
victorkirov authored Oct 23, 2024
2 parents a9390e8 + 743ae32 commit 95fc2d2
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 11 deletions.
17 changes: 8 additions & 9 deletions src/app/components/batchPsbtSigning/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ function BatchPsbtSigning({ onSigned, psbts, onCancel, onPostSignDone }: BatchPs
const [isSigningComplete, setIsSigningComplete] = useState(false);
const [signingPsbtIndex, setSigningPsbtIndex] = useState(1);
const [currentPsbtIndex, setCurrentPsbtIndex] = useState(0);
const singlePsbt = psbts.length === 1;
const [reviewTransaction, setReviewTransaction] = useState(singlePsbt);
const [reviewTransaction, setReviewTransaction] = useState(false);
const [isLoading, setIsLoading] = useState(true);
const [parsedPsbts, setParsedPsbts] = useState<ParsedPsbt[]>([]);
const [isLedgerModalVisible, setIsLedgerModalVisible] = useState(false);
Expand Down Expand Up @@ -196,12 +195,6 @@ function BatchPsbtSigning({ onSigned, psbts, onCancel, onPostSignDone }: BatchPs
});

const renderBody = () => {
if (hasDuplicateInputs) {
// if there are duplicate inputs on the individual transactions, we won't show a summary
// and will have to ask the user to review each txn individually
return null;
}

if (isLoading) {
return (
<LoaderContainer>
Expand All @@ -210,6 +203,12 @@ function BatchPsbtSigning({ onSigned, psbts, onCancel, onPostSignDone }: BatchPs
);
}

if (hasDuplicateInputs) {
// if there are duplicate inputs on the individual transactions, we won't show a summary
// and will have to ask the user to review each txn individually
return null;
}

return (
<>
<OuterContainer>
Expand Down Expand Up @@ -247,7 +246,7 @@ function BatchPsbtSigning({ onSigned, psbts, onCancel, onPostSignDone }: BatchPs
{renderBody()}
<StyledSheet
header=""
visible={reviewTransaction || hasDuplicateInputs}
visible={(reviewTransaction || hasDuplicateInputs) && !isLoading}
onClose={hasDuplicateInputs ? undefined : onReviewDone}
>
<OuterContainer>
Expand Down
25 changes: 24 additions & 1 deletion src/app/components/btcAddressTypeLabel/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as btc from '@scure/btc-signer';
import type { BtcAddressType, NetworkType } from '@secretkeylabs/xverse-core';
import { useTranslation } from 'react-i18next';
import { Tooltip } from 'react-tooltip';
import styled from 'styled-components';

const LabelContainer = styled.div((props) => ({
Expand All @@ -11,14 +13,35 @@ const LabelContainer = styled.div((props) => ({
const labelMap: Record<BtcAddressType, string> = {
native: 'Native SegWit',
nested: 'Nested SegWit',
taproot: 'Taproot',
taproot: 'Ordinals',
};

// TODO: centralize this tooltip with the styles
const StyledTooltip = styled(Tooltip)`
${(props) => props.theme.typography.body_bold_m}
max-width: 200px;
background-color: ${(props) => props.theme.colors.white_0};
color: #12151e;
border-radius: ${(props) => props.theme.space.s};
padding: 10px 12px;
`;

type BtcAddressTypeLabelProps = {
addressType: BtcAddressType;
};

export function BtcAddressTypeLabel({ addressType }: BtcAddressTypeLabelProps) {
const { t } = useTranslation('translation', { keyPrefix: 'INFORMATION' });
if (addressType === 'taproot') {
return (
<>
<LabelContainer id="ordinals_address_anchor">{labelMap[addressType]}</LabelContainer>
<StyledTooltip anchorId="ordinals_address_anchor" variant="light">
{t('ORDINALS_ADDRESS_TOOLTIP')}
</StyledTooltip>
</>
);
}
return <LabelContainer>{labelMap[addressType]}</LabelContainer>;
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/components/tooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const StyledCallout = styled(Callout)(() => ({
}));

type Props = CalloutProps & {
target: MutableRefObject<HTMLButtonElement | null>;
target: MutableRefObject<HTMLElement | null>;
positionVertical?: 'top' | 'bottom';
positionHorizontal?: 'left' | 'right';
};
Expand Down
3 changes: 3 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"OPTIONS": "Options",
"UNDO": "Undo"
},
"INFORMATION": {
"ORDINALS_ADDRESS_TOOLTIP": "These sats are used for your ordinals and runes. They cannot be spent with Xverse wallet."
},
"UNITS": {
"SATS_PER_VB": "sats/vB"
},
Expand Down

0 comments on commit 95fc2d2

Please sign in to comment.