Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Release SDK 1.0.2 #35

Merged
merged 3 commits into from
Jun 1, 2023
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
36 changes: 22 additions & 14 deletions example/src/screens/DeviceAdditionDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,32 @@ export const DeviceAdditionDemo = () => {
await initMPCWalletService(apiKeyName, privateKey);

if (!showStep5) {
await addDevice(deviceGroupName, deviceName);
}
const operationName = await addDevice(deviceGroupName, deviceName);
setShowStep5(true);

// Process operation.
const pendingDeviceOperations = await pollForPendingDevices(
deviceGroupName
);

for (let i = pendingDeviceOperations.length - 1; i >= 0; i--) {
const pendingOperation = pendingDeviceOperations[i];

setShowStep5(true);
if (pendingOperation?.Operation === operationName) {
await computeAddDeviceMPCOperation(
pendingOperation!.MPCData,
passcode,
deviceBackup
);
setShowStep6(true);

// Process operation.
const pendingDeviceOperations = await pollForPendingDevices(
deviceGroupName
);
return;
}
}

for (let i = pendingDeviceOperations.length - 1; i >= 0; i--) {
const pendingOperation = pendingDeviceOperations[i];
await computeAddDeviceMPCOperation(
pendingOperation!.MPCData,
passcode,
deviceBackup
throw new Error(
`could not find operation with name ${operationName}`
);
setShowStep6(true);
}
} catch (error) {
setResultError(error as Error);
Expand Down
28 changes: 22 additions & 6 deletions example/src/screens/DeviceBackupDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
initMPCWalletService,
pollForPendingDeviceBackups,
prepareDeviceBackup,
PrepareDeviceBackupOperation,
} from '@coinbase/waas-sdk-react-native';
import { ContinueButton } from '../components/ContinueButton';
import { DemoStep } from '../components/DemoStep';
Expand Down Expand Up @@ -60,21 +61,36 @@ export const DeviceBackupDemo = () => {
await initMPCSdk(true);
await initMPCKeyService(apiKeyName, privateKey);
await initMPCWalletService(apiKeyName, privateKey);
await prepareDeviceBackup(deviceGroupName, deviceName);
let operationName = await prepareDeviceBackup(
deviceGroupName,
deviceName
);

// Process operation.
const pendingDeviceBackupOperations = await pollForPendingDeviceBackups(
deviceGroupName
);

let pendingOperation!: PrepareDeviceBackupOperation;
for (let i = pendingDeviceBackupOperations.length - 1; i >= 0; i--) {
const pendingOperation = pendingDeviceBackupOperations[i];
await computePrepareDeviceBackupMPCOperation(
pendingOperation!.MPCData,
passcode
if (pendingDeviceBackupOperations[i]?.Operation === operationName) {
pendingOperation = pendingDeviceBackupOperations[
i
] as PrepareDeviceBackupOperation;
}
}

if (!pendingOperation) {
throw new Error(
`could not find operation with name ${operationName}`
);
setShowStep5(true);
}

await computePrepareDeviceBackupMPCOperation(
pendingOperation!.MPCData,
passcode
);
setShowStep5(true);
} catch (error) {
setResultError(error as Error);
setShowError(true);
Expand Down
36 changes: 26 additions & 10 deletions example/src/screens/MPCKeyExportDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
computePrepareDeviceArchiveMPCOperation,
getDeviceGroup,
pollForPendingDeviceArchives,
PrepareDeviceArchiveOperation,
} from '@coinbase/waas-sdk-react-native';
import { ContinueButton } from '../components/ContinueButton';
import { DemoStep } from '../components/DemoStep';
Expand Down Expand Up @@ -62,7 +63,6 @@ export const MPCKeyExportDemo = () => {
apiKeyName === '' ||
privateKey === '' ||
!showStep2 ||
showStep4 ||
showStep7
) {
return;
Expand All @@ -75,22 +75,38 @@ export const MPCKeyExportDemo = () => {
await initMPCWalletService(apiKeyName, privateKey);

if (!showStep3) {
await prepareDeviceArchive(deviceGroupName, deviceName);
}

setShowStep3(true);
const operationName = (await prepareDeviceArchive(
deviceGroupName,
deviceName
)) as string;
setShowStep3(true);

if (showStep3 && !showStep4) {
const pendingDeviceArchiveOperations =
await pollForPendingDeviceArchives(deviceGroupName);

let pendingOperation!: PrepareDeviceArchiveOperation;

for (let i = pendingDeviceArchiveOperations.length - 1; i >= 0; i--) {
const pendingOperation = pendingDeviceArchiveOperations[i];
await computePrepareDeviceArchiveMPCOperation(
pendingOperation!.MPCData,
passcode
if (
pendingDeviceArchiveOperations[i]?.Operation === operationName
) {
pendingOperation = pendingDeviceArchiveOperations[
i
] as PrepareDeviceArchiveOperation;

break;
}
}

if (!pendingOperation) {
throw new Error(
`could not find operation with name ${operationName}`
);
}
await computePrepareDeviceArchiveMPCOperation(
pendingOperation!.MPCData,
passcode
);

const retrievedDeviceGroup = await getDeviceGroup(deviceGroupName);
setMpcKeyExportMetadata(retrievedDeviceGroup.MPCKeyExportMetadata);
Expand Down
Loading