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 39e130b
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 47 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
82 changes: 41 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}
},
"dependencies": {
"@bitgo-beta/sdk-coin-sui": "^1.4.1-alpha.158",
"@bitgo-beta/sdk-coin-sui": "^1.4.1-alpha.160",
"@bitgo/abstract-cosmos": "10.0.24",
"@bitgo/abstract-utxo": "8.9.0",
"@bitgo/sdk-api": "1.50.0",
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 39e130b

Please sign in to comment.