Skip to content

Commit

Permalink
feat(WRW): change tss coins recovery form format
Browse files Browse the repository at this point in the history
  • Loading branch information
alia-bitgo committed Sep 7, 2023
1 parent ce22212 commit 1946e4e
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -843,12 +843,17 @@ function Form() {
try {
await window.commands.setBitGoEnvironment(bitGoEnvironment, coin);
const chainData = await window.queries.getChain(coin);
const { publicKey, secretKey } = values;
const durableNonce =
publicKey && secretKey ? { publicKey, secretKey } : undefined;
const recoverData = await window.commands.recover(coin, {
bitgoKey: values.bitgoKey.replace(/\s+/g, ''),
ignoreAddressTypes: [],
userKey: '',
backupKey: '',
recoveryDestination: values.recoveryDestination,
seed: values.seed,
durableNonce,
});
assert(
isRecoveryTransaction(recoverData),
Expand Down Expand Up @@ -914,6 +919,7 @@ function Form() {
userKey: '',
backupKey: '',
recoveryDestination: values.recoveryDestination,
seed: values.seed,
});
assert(
isRecoveryTransaction(recoverData),
Expand Down
26 changes: 8 additions & 18 deletions src/containers/BuildUnsignedSweepCoin/CardanoForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import {
const validationSchema = Yup.object({
bitgoKey: Yup.string().required(),
recoveryDestination: Yup.string().required(),
scan: Yup.number().required(),
startingScanIndex: Yup.number().required(),
seed: Yup.string(),
}).required();

export type CardanoFormProps = {
Expand All @@ -32,8 +31,7 @@ export function CardanoForm({ onSubmit }: CardanoFormProps) {
initialValues: {
bitgoKey: '',
recoveryDestination: '',
scan: 20,
startingScanIndex: 0,
seed: undefined,
},
validationSchema,
});
Expand All @@ -54,25 +52,17 @@ export function CardanoForm({ onSubmit }: CardanoFormProps) {
</div>
<div className="tw-mb-4">
<FormikTextfield
HelperText="The address your recovery transaction will send to."
Label="Destination Address"
name="recoveryDestination"
HelperText="Your user seed as found on your KeyCard as Key ID. Most wallets will not have this and you can leave it blank."
Label="Seed (optional)"
name="seed"
Width="fill"
/>
</div>
<div className="tw-mb-4">
<FormikTextfield
HelperText="The amount of addresses without transactions to scan before stopping the tool."
Label="Address Scanning Factor"
name="scan"
Width="fill"
/>
</div>
<div className="tw-mb-4">
<FormikTextfield
HelperText="This is the index to start scanning from, typically used to scan more indexes. You can call this recover function again starting from scanIndex + 1."
Label="Starting Scan Index"
name="startingScanIndex"
HelperText="The address your recovery transaction will send to."
Label="Destination Address"
name="recoveryDestination"
Width="fill"
/>
</div>
Expand Down
30 changes: 10 additions & 20 deletions src/containers/BuildUnsignedSweepCoin/SolanaForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import {
const validationSchema = Yup.object({
bitgoKey: Yup.string().required(),
recoveryDestination: Yup.string().required(),
scan: Yup.number().required(),
startingScanIndex: Yup.number().required(),
seed: Yup.string(),
})
.required()
.shape(
Expand Down Expand Up @@ -50,10 +49,9 @@ export function SolanaForm({ onSubmit }: SolanaFormProps) {
initialValues: {
bitgoKey: '',
recoveryDestination: '',
scan: 20,
startingScanIndex: 0,
publicKey: '',
secretKey: '',
seed: undefined,
},
validationSchema,
});
Expand Down Expand Up @@ -82,6 +80,14 @@ export function SolanaForm({ onSubmit }: SolanaFormProps) {
Width="fill"
/>
</div>
<div className="tw-mb-4">
<FormikTextfield
HelperText="Your user seed as found on your KeyCard as Key ID. Most wallets will not have this and you can leave it blank."
Label="Seed (optional)"
name="seed"
Width="fill"
/>
</div>
<div className="tw-mb-4">
<FormikTextfield
HelperText="The address your recovery transaction will send to."
Expand All @@ -108,22 +114,6 @@ export function SolanaForm({ onSubmit }: SolanaFormProps) {
Width="fill"
/>
</div>
<div className="tw-mb-4">
<FormikTextfield
HelperText="The amount of addresses without transactions to scan before stopping the tool."
Label="Address Scanning Factor"
name="scan"
Width="fill"
/>
</div>
<div className="tw-mb-4">
<FormikTextfield
HelperText="This is the index to start scanning from, typically used to scan more indexes. You can call this recover function again starting from scanIndex + 1."
Label="Starting Scan Index"
name="startingScanIndex"
Width="fill"
/>
</div>
<div className="tw-flex tw-flex-col-reverse sm:tw-justify-between sm:tw-flex-row tw-gap-1 tw-mt-4">
<Button Tag={Link} to="/" Variant="secondary" Width="hug">
Cancel
Expand Down
20 changes: 0 additions & 20 deletions src/containers/NonBitGoRecoveryCoin/CardanoForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ const validationSchema = Yup.object({
.oneOf(['keyternal', 'bitgoKRSv2', 'dai'])
.label('Key Recovery Service'),
recoveryDestination: Yup.string().required(),
scan: Yup.number().required(),
startingScanIndex: Yup.number().required(),
userKey: Yup.string().required(),
walletPassphrase: Yup.string().required(),
}).required();
Expand All @@ -38,8 +36,6 @@ export function CardanoForm({ onSubmit }: CardanoFormProps) {
bitgoKey: '',
krsProvider: '',
recoveryDestination: '',
scan: 20,
startingScanIndex: 0,
userKey: '',
walletPassphrase: '',
},
Expand Down Expand Up @@ -101,22 +97,6 @@ export function CardanoForm({ onSubmit }: CardanoFormProps) {
Width="fill"
/>
</div>
<div className="tw-mb-4">
<FormikTextfield
HelperText="The amount of addresses without transactions to scan before stopping the tool."
Label="Address Scanning Factor"
name="scan"
Width="fill"
/>
</div>
<div className="tw-mb-4">
<FormikTextfield
HelperText="This is the index to start scanning from, typically used to scan more indexes. You can call this recover function again starting from scanIndex + 1."
Label="Starting Scan Index"
name="startingScanIndex"
Width="fill"
/>
</div>
<div className="tw-flex tw-flex-col-reverse sm:tw-justify-between sm:tw-flex-row tw-gap-1 tw-mt-4">
<Button Tag={Link} to="/" Variant="secondary" Width="hug">
Cancel
Expand Down
9 changes: 1 addition & 8 deletions src/containers/NonBitGoRecoveryCoin/NonBitGoRecoveryCoin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ function Form() {
const chainData = await window.queries.getChain(coin);
const recoverData = await window.commands.recover(coin, {
...values,
scan: Number(values.scan),
startingScanIndex: Number(values.startingScanIndex),
bitgoKey: values.bitgoKey.replace(/\s+/g, ''),
ignoreAddressTypes: ['p2wsh'],
});
assert(
Expand Down Expand Up @@ -164,8 +161,6 @@ function Form() {
const chainData = await window.queries.getChain(coin);
const recoverData = await window.commands.recover(coin, {
...values,
scan: Number(values.scan),
startingScanIndex: Number(values.startingScanIndex),
bitgoKey: values.bitgoKey.replace(/\s+/g, ''),
ignoreAddressTypes: [],
});
Expand Down Expand Up @@ -219,14 +214,12 @@ function Form() {
try {
await window.commands.setBitGoEnvironment(bitGoEnvironment, coin);
const chainData = await window.queries.getChain(coin);
const { publicKey, secretKey, scan, startingScanIndex, ...rest } =
const { publicKey, secretKey, ...rest } =
values;
const durableNonce =
publicKey && secretKey ? { publicKey, secretKey } : undefined;
const recoverData = await window.commands.recover(coin, {
...rest,
scan: Number(scan),
startingScanIndex: Number(startingScanIndex),
durableNonce,
bitgoKey: values.bitgoKey.replace(/\s+/g, ''),
ignoreAddressTypes: [],
Expand Down
20 changes: 0 additions & 20 deletions src/containers/NonBitGoRecoveryCoin/PolkadotForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ const validationSchema = Yup.object({
.oneOf(['keyternal', 'bitgoKRSv2', 'dai'])
.label('Key Recovery Service'),
recoveryDestination: Yup.string().required(),
scan: Yup.number().required(),
startingScanIndex: Yup.number().required(),
userKey: Yup.string().required(),
walletPassphrase: Yup.string().required(),
}).required();
Expand All @@ -38,8 +36,6 @@ export function PolkadotForm({ onSubmit }: PolkadotFormProps) {
bitgoKey: '',
krsProvider: '',
recoveryDestination: '',
scan: 20,
startingScanIndex: 0,
userKey: '',
walletPassphrase: '',
},
Expand Down Expand Up @@ -114,22 +110,6 @@ export function PolkadotForm({ onSubmit }: PolkadotFormProps) {
Width="fill"
/>
</div>
<div className="tw-mb-4">
<FormikTextfield
HelperText="The amount of addresses without transactions to scan before stopping the tool."
Label="Address Scanning Factor"
name="scan"
Width="fill"
/>
</div>
<div className="tw-mb-4">
<FormikTextfield
HelperText="This is the index to start scanning from, typically used to scan more indexes. You can call this recover function again starting from scanIndex + 1."
Label="Starting Scan Index"
name="startingScanIndex"
Width="fill"
/>
</div>
<div className="tw-flex tw-flex-col-reverse sm:tw-justify-between sm:tw-flex-row tw-gap-1 tw-mt-4">
<Button Tag={Link} to="/" Variant="secondary" Width="hug">
Cancel
Expand Down
20 changes: 0 additions & 20 deletions src/containers/NonBitGoRecoveryCoin/SolanaForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ const validationSchema = Yup.object({
.oneOf(['keyternal', 'bitgoKRSv2', 'dai'])
.label('Key Recovery Service'),
recoveryDestination: Yup.string().required(),
scan: Yup.number().required(),
startingScanIndex: Yup.number().required(),
userKey: Yup.string().required(),
walletPassphrase: Yup.string().required(),
})
Expand Down Expand Up @@ -59,8 +57,6 @@ export function SolanaForm({ onSubmit }: SolanaFormProps) {
krsProvider: '',
publicKey: '',
recoveryDestination: '',
scan: 20,
startingScanIndex: 0,
secretKey: '',
userKey: '',
walletPassphrase: '',
Expand Down Expand Up @@ -164,22 +160,6 @@ export function SolanaForm({ onSubmit }: SolanaFormProps) {
Width="fill"
/>
</div>
<div className="tw-mb-4">
<FormikTextfield
HelperText="The amount of addresses without transactions to scan before stopping the tool."
Label="Address Scanning Factor"
name="scan"
Width="fill"
/>
</div>
<div className="tw-mb-4">
<FormikTextfield
HelperText="This is the index to start scanning from, typically used to scan more indexes. You can call this recover function again starting from scanIndex + 1."
Label="Starting Scan Index"
name="startingScanIndex"
Width="fill"
/>
</div>
<div className="tw-flex tw-flex-col-reverse sm:tw-justify-between sm:tw-flex-row tw-gap-1 tw-mt-4">
<Button Tag={Link} to="/" Variant="secondary" Width="hug">
Cancel
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ export function isRecoveryTransaction(
('tx' in value && !!value['tx']) ||
('transaction' in value && !!value['transaction']) ||
('txid' in value && !!value['txid']) ||
('serializedTx' in value && !!value['serializedTx'])
('serializedTx' in value && !!value['serializedTx']) ||
('txRequests' in value && !!value['txRequests'])
);
}

Expand Down
1 change: 1 addition & 0 deletions src/preload.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ type Commands = {
};
tokenAddress?: string;
startingScanIndex?: number;
seed?: string;
}
): Promise<BackupKeyRecoveryTransansaction | FormattedOfflineVaultTxInfo>;
wrongChainRecover(
Expand Down

0 comments on commit 1946e4e

Please sign in to comment.