Skip to content

Commit

Permalink
feat(sdk-coin-sui): support seed based MPC addresses
Browse files Browse the repository at this point in the history
TICKET: WIN-3296
  • Loading branch information
bhavidhingra committed Aug 23, 2024
1 parent b297c9a commit fb8348b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions modules/sdk-coin-sui/src/sui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
MAX_GAS_BUDGET,
MAX_OBJECT_LIMIT,
} from './lib/constants';
import { getDerivationPath } from '@bitgo/sdk-lib-mpc';

export interface ExplainTransactionOptions {
txHex: string;
Expand Down Expand Up @@ -335,7 +336,7 @@ export class Sui extends BaseCoin {
const MPC = await EDDSAMethods.getInitializedMpcInstance();

for (let idx = startIdx; idx < endIdx; idx++) {
const derivationPath = `m/${idx}`;
const derivationPath = (params.seed ? getDerivationPath(params.seed) : 'm') + `/${idx}`;
const derivedPublicKey = MPC.deriveUnhardened(bitgoKey, derivationPath).slice(0, 64);
const senderAddress = this.getAddressFromPublicKey(derivedPublicKey);
let availableBalance = new BigNumber(0);
Expand Down Expand Up @@ -633,7 +634,7 @@ export class Sui extends BaseCoin {

const bitgoKey = params.bitgoKey.replace(/\s/g, '');
const MPC = await EDDSAMethods.getInitializedMpcInstance();
const derivationPath = `m/0`;
const derivationPath = (params.seed ? getDerivationPath(params.seed) : 'm') + '/0';
const derivedPublicKey = MPC.deriveUnhardened(bitgoKey, derivationPath).slice(0, 64);
const baseAddress = this.getAddressFromPublicKey(derivedPublicKey);

Expand All @@ -645,6 +646,7 @@ export class Sui extends BaseCoin {
backupKey: params.backupKey,
bitgoKey: params.bitgoKey,
walletPassphrase: params.walletPassphrase,
seed: params.seed,
recoveryDestination: baseAddress,
startingScanIndex: idx,
scan: 1,
Expand Down

0 comments on commit fb8348b

Please sign in to comment.