Skip to content

Commit

Permalink
Merge pull request #506 from BitGo/WIN-3470-sui-token-recovery
Browse files Browse the repository at this point in the history
feat(sui): add sui token support
  • Loading branch information
bhavidhingra authored Sep 20, 2024
2 parents 3a6e523 + 01a6de6 commit b2b0c19
Show file tree
Hide file tree
Showing 10 changed files with 422 additions and 49 deletions.
2 changes: 1 addition & 1 deletion electron/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Dot, Tdot } from '@bitgo/sdk-coin-dot';
import { Sol, Tsol } from '@bitgo/sdk-coin-sol';
import { Hbar, Thbar } from '@bitgo/sdk-coin-hbar';
import { Algo, Talgo } from '@bitgo/sdk-coin-algo';
import { Sui, Tsui } from '@bitgo-beta/sdk-coin-sui';
import { Sui, Tsui } from '@bitgo/sdk-coin-sui';

export type createAdaBroadcastableSweepTransactionParameters =
| Parameters<Ada['createBroadcastableSweepTransaction']>[0]
Expand Down
72 changes: 36 additions & 36 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"dependencies": {
"@bitgo/abstract-cosmos": "11.0.5",
"@bitgo/abstract-utxo": "8.14.2",
"@bitgo/sdk-opensslbytes": "^2.0.0",
"@bitgo/sdk-api": "1.54.1",
"@bitgo/sdk-coin-ada": "4.2.14",
"@bitgo/sdk-coin-algo": "2.1.34",
Expand Down Expand Up @@ -44,13 +43,14 @@
"@bitgo/sdk-coin-polygon": "21.0.5",
"@bitgo/sdk-coin-sei": "3.0.5",
"@bitgo/sdk-coin-sol": "4.5.2",
"@bitgo/sdk-coin-sui": "5.6.4",
"@bitgo/sdk-coin-sui": "5.7.0",
"@bitgo/sdk-coin-tia": "3.0.5",
"@bitgo/sdk-coin-trx": "2.0.36",
"@bitgo/sdk-coin-xlm": "3.2.10",
"@bitgo/sdk-coin-xrp": "2.1.17",
"@bitgo/sdk-coin-zec": "2.0.36",
"@bitgo/sdk-coin-zeta": "3.0.5",
"@bitgo/sdk-opensslbytes": "^2.0.0",
"@bitgo/utxo-lib": "10.3.0",
"@ethereumjs/common": "2.6.5",
"@lottiefiles/react-lottie-player": "3.4.9",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import {
import { TronForm } from '~/containers/BuildUnsignedConsolidation/TronForm';
import { TronTokenForm } from '~/containers/BuildUnsignedConsolidation/TronTokenForm';
import { CoinsSelectAutocomplete } from '~/components';
import { buildUnsignedConsolidationCoins } from '~/helpers/config';
import { buildUnsignedConsolidationCoins, tokenParentCoins } from '~/helpers/config';
import { BackToHomeHelperText } from '~/components/BackToHomeHelperText';
import { ConsolidationRecoveryBatch } from '@bitgo/sdk-coin-trx';
import { useAlertBanner } from '~/contexts';
import { GenericEcdsaForm } from '~/containers/BuildUnsignedConsolidation/GenericEcdsaForm';
import { SolForm } from '~/containers/BuildUnsignedConsolidation/SolForm';
import { SolTokenForm } from '~/containers/BuildUnsignedConsolidation/SolTokenForm';
import { SuiTokenForm } from '~/containers/BuildUnsignedConsolidation/SuiTokenForm';

type ConsolidationFormProps = {
coin?: string;
Expand All @@ -25,10 +26,9 @@ type ConsolidationFormProps = {
function isRecoveryConsolidationTransaction(
result: any
): result is ConsolidationRecoveryBatch {
const consolidationRecoveryBatch = result as ConsolidationRecoveryBatch;
return (
consolidationRecoveryBatch &&
consolidationRecoveryBatch.transactions !== undefined
('txRequests' in result && !!result['txRequests']) ||
('transactions' in result && !!result['transactions'])
);
}

Expand Down Expand Up @@ -343,6 +343,60 @@ function ConsolidationForm({ coin, environment }: ConsolidationFormProps) {
console.log(e);
}

setSubmitting(false);
}
}}
/>
);
case 'suiToken':
case 'tsuiToken':
return (
<SuiTokenForm
onSubmit={async (values, { setSubmitting }) => {
setSubmitting(true);
try {
await window.commands.setBitGoEnvironment(environment);
const parentCoin = tokenParentCoins[coin];
const chainData = await window.queries.getChain(parentCoin);
const consolidateData = await window.commands.recoverConsolidations(parentCoin, {
...(await updateKeysFromIds(parentCoin, values)),
bitgoKey: values.bitgoKey.replace(/\s+/g, ''),
tokenContractAddress: values.packageId,
seed: values.seed,
});

if (consolidateData instanceof Error) {
throw consolidateData;
}

const showSaveDialogData = await window.commands.showSaveDialog({
filters: [
{
name: 'Custom File Type',
extensions: ['json'],
},
],
defaultPath: `~/${chainData}-unsigned-consolidation-${Date.now()}.json`,
});
if (!showSaveDialogData.filePath) {
throw new Error('No file path selected');
}

await window.commands.writeFile(
showSaveDialogData.filePath,
JSON.stringify(consolidateData, null, 2),
{ encoding: 'utf8' }
);
navigate(
`/${environment}/build-unsigned-consolidation/${coin}/success`
);
} catch (e) {
if (e instanceof Error) {
setAlert(e.message);
} else {
console.log(e);
}

setSubmitting(false);
}
}}
Expand Down
Loading

0 comments on commit b2b0c19

Please sign in to comment.