Skip to content
Draft
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
39 changes: 38 additions & 1 deletion modules/bitgo/test/v2/unit/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,10 @@ describe('V2 Wallets:', function () {
type: 'custodial',
};

nock('https://bitgo.fakeurl')
.get('/api/v2/tss/settings')
.reply(200, { coinSettings: { sol: { walletCreationSettings: {} } } });

const walletNock = nock('https://bitgo.fakeurl')
.post('/api/v2/tsol/wallet/add')
.times(1)
Expand Down Expand Up @@ -1420,11 +1424,12 @@ describe('V2 Wallets:', function () {
sol: {
walletCreationSettings: {
multiSigTypeVersion: 'MPCv2',
custodialMultiSigTypeVersion: 'MPCv2',
},
},
},
};
nock('https://bitgo.fakeurl').get(`/api/v2/tss/settings`).times(2).reply(200, tssSettings);
nock('https://bitgo.fakeurl').get(`/api/v2/tss/settings`).times(3).reply(200, tssSettings);
});

afterEach(function () {
Expand Down Expand Up @@ -1534,6 +1539,38 @@ describe('V2 Wallets:', function () {
assert.ok(response.encryptedWalletPassphrase);
assert.ok(response.wallet);
});

it('should create a new tsol TSS EdDSA MPCv2 custodial wallet', async function () {
const keys = ['1', '2', '3'];
const testCoin = bitgo.coin('tsol');

const walletParams: GenerateWalletOptions = {
label: 'tss eddsa mpcv2 custodial wallet',
multisigType: 'tss',
enterprise: 'enterprise',
type: 'custodial',
};

const walletNock = nock('https://bitgo.fakeurl')
.post('/api/v2/tsol/wallet/add')
.times(1)
.reply(200, { ...walletParams, keys });

const wallets = new Wallets(bitgo, testCoin);

const res = await wallets.generateWallet(walletParams);
if (!isWalletWithKeychains(res)) {
throw new Error('wallet missing required keychains');
}
res.wallet.label().should.equal(walletParams.label);
should.equal(res.wallet.type(), walletParams.type);
res.wallet.multisigType().should.equal(walletParams.multisigType);
res.userKeychain.id.should.equal(keys[0]);
res.backupKeychain.id.should.equal(keys[1]);
res.bitgoKeychain.id.should.equal(keys[2]);

walletNock.isDone().should.be.true();
});
});

describe('Sharing', () => {
Expand Down
7 changes: 5 additions & 2 deletions modules/sdk-core/src/bitgo/wallet/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2013,13 +2013,16 @@ export class Wallets implements IWallets {
const reqId = new RequestTracer();
this.bitgo.setRequestTracer(reqId);

if (multisigType === 'tss' && this.baseCoin.getMPCAlgorithm() === 'ecdsa') {
if (multisigType === 'tss') {
const tssSettings: TssSettings = await this.bitgo
.get(this.bitgo.microservicesUrl('/api/v2/tss/settings'))
.result();
const multisigTypeVersion =
tssSettings.coinSettings[this.baseCoin.getFamily()]?.walletCreationSettings?.custodialMultiSigTypeVersion;
walletVersion = this.determineEcdsaMpcWalletVersion(walletVersion, multisigTypeVersion);

if (this.baseCoin.getMPCAlgorithm() === 'ecdsa') {
walletVersion = this.determineEcdsaMpcWalletVersion(walletVersion, multisigTypeVersion);
}
}

const finalWalletParams = {
Expand Down
Loading