Skip to content

Commit ce1d32a

Browse files
committed
feat: optional walletLabel key card
- the new UI will allow users to create keycards before specifying a wallet label, so we need to make this field optional & not render the label if its not specified Ticket: CE-6422
1 parent 8200432 commit ce1d32a

File tree

5 files changed

+26
-13
lines changed

5 files changed

+26
-13
lines changed

modules/key-card/src/drawKeycard.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,20 @@ export async function drawKeycard({
149149
const date = new Date().toDateString();
150150
y = moveDown(y, margin);
151151
doc.setFontSize(font.body).setTextColor(color.gray);
152-
const title = curve ? KeyCurveName[curve] + ' key:' : 'wallet named:';
153-
doc.text('Created on ' + date + ' for ' + title, left(0), y);
154-
// copy
155-
y = moveDown(y, 25);
156-
doc.setFontSize(font.subheader).setTextColor(color.black);
157-
doc.text(walletLabel, left(0), y);
152+
153+
if (curve || walletLabel) {
154+
const title = curve ? KeyCurveName[curve] + ' key:' : 'wallet named:';
155+
doc.text('Created on ' + date + ' for ' + title, left(0), y);
156+
// copy
157+
y = moveDown(y, 25);
158+
if (walletLabel) {
159+
doc.setFontSize(font.subheader).setTextColor(color.black);
160+
doc.text(walletLabel, left(0), y);
161+
}
162+
} else {
163+
doc.text('Created on ' + date, left(0), y);
164+
y = moveDown(y, 25);
165+
}
158166
if (!curve) {
159167
// Red Bar
160168
y = moveDown(y, 20);

modules/key-card/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ export async function generateKeycard(params: GenerateKeycardParams): Promise<vo
1515
const questions = generateFaq(params.coin.fullName);
1616
const qrData = generateQrData(params);
1717
const keycard = await drawKeycard({ ...params, questions, qrData });
18-
keycard.save(`BitGo Keycard for ${params.walletLabel}.pdf`);
18+
const label = params.walletLabel || params.coin.fullName;
19+
keycard.save(`BitGo Keycard for ${label}.pdf`);
1920
} else if ('curve' in params) {
2021
const data = generateParamsForKeyCreation(params);
2122
const keycard = await drawKeycard(data);
22-
keycard.save(`BitGo Keycard for ${params.walletLabel}.pdf`);
23+
const label = params.walletLabel || params.curve;
24+
keycard.save(`BitGo Keycard for ${label}.pdf`);
2325
} else {
2426
throw new Error('Either curve or coin must be provided');
2527
}

modules/key-card/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export interface IDrawKeyCard {
5454
keyCardImage?: HTMLImageElement;
5555
qrData: QrData;
5656
questions: FAQ[];
57-
walletLabel: string;
57+
walletLabel?: string;
5858
curve?: KeyCurve;
5959
}
6060

modules/web-demo/src/components/KeyCard/fixtures.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export async function downloadKeycardForDKLsTSS() {
112112
});
113113
}
114114

115-
export async function downloadKeycardForHotLtcWallet() {
115+
export async function downloadKeycardForHotLtcWallet(walletLabel = '') {
116116
const userKeychain: Keychain = {
117117
id: '63e107b5ef7bba0007145e41065b26a6',
118118
pub: 'xpub661MyMwAqRbcFXFJ8wZhWjEiFg9wM89UamPyP3XsnEHg2VJ4m7wE7ALLszakPiEEy5cH9FCAvCrx1cL6rLE6jewaa1ubP8DjqsDtP4R7w5g',
@@ -142,7 +142,7 @@ export async function downloadKeycardForHotLtcWallet() {
142142
passcodeEncryptionCode: '654321',
143143
passphrase: 'test_wallet_passphrase',
144144
userKeychain,
145-
walletLabel: 'Hot LTC Wallet',
145+
walletLabel,
146146
});
147147
}
148148

modules/web-demo/src/components/KeyCard/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ const KeyCard = () => {
1313
<React.Fragment>
1414
<h3>Key Card</h3>
1515
<br />
16-
<button onClick={downloadKeycardForHotLtcWallet}>
17-
Download for Hot LTC Wallet
16+
<button onClick={() => downloadKeycardForHotLtcWallet('Hot LTC Wallet')}>
17+
Download for Hot LTC Wallet (With Label)
18+
</button>
19+
<button onClick={() => downloadKeycardForHotLtcWallet('')}>
20+
Download for Hot LTC Wallet (Without Label)
1821
</button>
1922
<button onClick={downloadKeycardForDKLsTSS}>
2023
Download for Hot DKLS Wallet

0 commit comments

Comments
 (0)