Skip to content

Commit

Permalink
feat(sui): create broadcastable MPC transaction
Browse files Browse the repository at this point in the history
Ticket: WIN-3293
  • Loading branch information
bhavidhingra committed Aug 7, 2024
1 parent 932d6ca commit a5807e4
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 5 deletions.
8 changes: 6 additions & 2 deletions electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,14 +413,18 @@ async function createWindow() {
case 'dot':
case 'tdot':
case 'sol':
case 'tsol': {
case 'tsol':
case 'sui':
case 'tsui': {
const coinInstance = sdk.coin(coin) as
| Ada
| Tada
| Dot
| Tdot
| Sol
| Tsol;
| Tsol
| Sui
| Tsui;
return coinInstance.createBroadcastableSweepTransaction(parameters);
}
default:
Expand Down
2 changes: 2 additions & 0 deletions electron/preload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
createAdaBroadcastableSweepTransactionParameters,
createDotBroadcastableSweepTransactionParameters,
createSolBroadcastableSweepTransactionParameters,
createSuiBroadcastableSweepTransactionParameters,
DotRecoverConsolidationRecoveryBatch,
DotRecoveryConsolidationRecoveryOptions,
SolRecoverConsolidationRecoveryBatch,
Expand All @@ -47,6 +48,7 @@ type Commands = {
| createAdaBroadcastableSweepTransactionParameters
| createDotBroadcastableSweepTransactionParameters
| createSolBroadcastableSweepTransactionParameters
| createSuiBroadcastableSweepTransactionParameters
): Promise<Error | BroadcastableSweepTransaction>;
unlock(otp: string);
sweepV1(coin: string, parameters: V1SweepParams): ReturnType<typeof v1Sweep>;
Expand Down
5 changes: 5 additions & 0 deletions electron/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export type createDotBroadcastableSweepTransactionParameters =
export type createSolBroadcastableSweepTransactionParameters =
| Parameters<Sol['createBroadcastableSweepTransaction']>[0]
| Parameters<Tsol['createBroadcastableSweepTransaction']>[0];
export type createSuiBroadcastableSweepTransactionParameters =
| Parameters<Sui['createBroadcastableSweepTransaction']>[0]
| Parameters<Tsui['createBroadcastableSweepTransaction']>[0];

export type BroadcastableSweepTransaction = Awaited<
ReturnType<
Expand All @@ -27,6 +30,8 @@ export type BroadcastableSweepTransaction = Awaited<
| Tdot['createBroadcastableSweepTransaction']
| Sol['createBroadcastableSweepTransaction']
| Tsol['createBroadcastableSweepTransaction']
| Sui['createBroadcastableSweepTransaction']
| Tsui['createBroadcastableSweepTransaction']
>
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {
createAdaBroadcastableSweepTransactionParameters,
createDotBroadcastableSweepTransactionParameters,
createSolBroadcastableSweepTransactionParameters,
createSuiBroadcastableSweepTransactionParameters,
} from '~/utils/types';
import { assert, safeEnv } from '~/helpers';
import { useAlertBanner } from '~/contexts';
Expand All @@ -31,11 +32,13 @@ function isSignedTransaction(
): json is
| createAdaBroadcastableSweepTransactionParameters
| createDotBroadcastableSweepTransactionParameters
| createSolBroadcastableSweepTransactionParameters {
| createSolBroadcastableSweepTransactionParameters
| createSuiBroadcastableSweepTransactionParameters {
const signedTransaction = json as
| createAdaBroadcastableSweepTransactionParameters
| createDotBroadcastableSweepTransactionParameters
| createSolBroadcastableSweepTransactionParameters;
| createSolBroadcastableSweepTransactionParameters
| createSuiBroadcastableSweepTransactionParameters;
return (
signedTransaction &&
signedTransaction.signatureShares !== undefined &&
Expand Down Expand Up @@ -64,7 +67,8 @@ export function CreateBroadcastableTransactionIndex() {
const tx = JSON.parse(event.target?.result as string) as
| createAdaBroadcastableSweepTransactionParameters
| createDotBroadcastableSweepTransactionParameters
| createSolBroadcastableSweepTransactionParameters;
| createSolBroadcastableSweepTransactionParameters
| createSuiBroadcastableSweepTransactionParameters;

assert(isSignedTransaction(tx), 'Signed transaction not found');

Expand Down
2 changes: 2 additions & 0 deletions src/preload.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
createAdaBroadcastableSweepTransactionParameters,
createDotBroadcastableSweepTransactionParameters,
createSolBroadcastableSweepTransactionParameters,
createSuiBroadcastableSweepTransactionParameters,
DotRecoverConsolidationRecoveryBatch,
DotRecoveryConsolidationRecoveryOptions,
SolRecoverConsolidationRecoveryBatch,
Expand All @@ -44,6 +45,7 @@ type Commands = {
| createAdaBroadcastableSweepTransactionParameters
| createDotBroadcastableSweepTransactionParameters
| createSolBroadcastableSweepTransactionParameters
| createSuiBroadcastableSweepTransactionParameters
): Promise<Error | BroadcastableSweepTransaction>;
unlock(otp: string);
sweepV1(coin: string, parameters);
Expand Down
5 changes: 5 additions & 0 deletions src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export type createDotBroadcastableSweepTransactionParameters =
export type createSolBroadcastableSweepTransactionParameters =
| Parameters<Sol['createBroadcastableSweepTransaction']>[0]
| Parameters<Tsol['createBroadcastableSweepTransaction']>[0];
export type createSuiBroadcastableSweepTransactionParameters =
| Parameters<Sui['createBroadcastableSweepTransaction']>[0]
| Parameters<Tsui['createBroadcastableSweepTransaction']>[0];

export type BroadcastableSweepTransaction = Awaited<
ReturnType<
Expand All @@ -27,6 +30,8 @@ export type BroadcastableSweepTransaction = Awaited<
| Tdot['createBroadcastableSweepTransaction']
| Sol['createBroadcastableSweepTransaction']
| Tsol['createBroadcastableSweepTransaction']
| Sui['createBroadcastableSweepTransaction']
| Tsui['createBroadcastableSweepTransaction']
>
>;

Expand Down

0 comments on commit a5807e4

Please sign in to comment.