Skip to content

Commit e7bdf69

Browse files
committed
fix(sdk-core): pass correct walletVersion to wallet platform
Ticket: COIN-2021
1 parent 6ac4ba3 commit e7bdf69

File tree

3 files changed

+116
-2
lines changed

3 files changed

+116
-2
lines changed

modules/abstract-eth/src/abstractEthLikeNewCoins.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2389,7 +2389,7 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
23892389
);
23902390
}
23912391

2392-
if (impliedForwarderVersion === 0 || impliedForwarderVersion === 3) {
2392+
if (impliedForwarderVersion === 0 || impliedForwarderVersion === 3 || impliedForwarderVersion === 6) {
23932393
return true;
23942394
} else {
23952395
const ethNetwork = this.getNetwork();

modules/bitgo/test/v2/unit/wallets.ts

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,120 @@ describe('V2 Wallets:', function () {
944944
});
945945
});
946946

947+
it(`should create a new hteth TSS MPCv2 wallet with walletVersion 6`, async function () {
948+
const testCoin = bitgo.coin('hteth');
949+
const stubbedKeychainsTriplet: KeychainsTriplet = {
950+
userKeychain: {
951+
id: '1',
952+
commonKeychain: 'userPub',
953+
type: 'tss',
954+
source: 'user',
955+
},
956+
backupKeychain: {
957+
id: '2',
958+
commonKeychain: 'userPub',
959+
type: 'tss',
960+
source: 'backup',
961+
},
962+
bitgoKeychain: {
963+
id: '3',
964+
commonKeychain: 'userPub',
965+
type: 'tss',
966+
source: 'bitgo',
967+
},
968+
};
969+
const stubCreateKeychains = sandbox
970+
.stub(ECDSAUtils.EcdsaMPCv2Utils.prototype, 'createKeychains')
971+
.resolves(stubbedKeychainsTriplet);
972+
973+
const walletNock = nock('https://bitgo.fakeurl')
974+
.post(`/api/v2/hteth/wallet`, (body) => {
975+
body.walletVersion.should.equal(6);
976+
return true;
977+
})
978+
.reply(200);
979+
980+
const wallets = new Wallets(bitgo, testCoin);
981+
982+
const params = {
983+
label: 'tss wallet',
984+
passphrase: 'tss password',
985+
multisigType: 'tss' as const,
986+
enterprise: 'enterprise',
987+
passcodeEncryptionCode: 'originalPasscodeEncryptionCode',
988+
walletVersion: 6,
989+
};
990+
991+
const response = await wallets.generateWallet(params);
992+
993+
walletNock.isDone().should.be.true();
994+
stubCreateKeychains.calledOnce.should.be.true();
995+
996+
assert.ok(response.encryptedWalletPassphrase);
997+
assert.ok(response.wallet);
998+
assert.equal(
999+
bitgo.decrypt({ input: response.encryptedWalletPassphrase, password: params.passcodeEncryptionCode }),
1000+
params.passphrase
1001+
);
1002+
});
1003+
1004+
it(`should create a new MPCv2 wallet with version 5 if walletVersion passed is not 5 or 6`, async function () {
1005+
const testCoin = bitgo.coin('hteth');
1006+
const stubbedKeychainsTriplet: KeychainsTriplet = {
1007+
userKeychain: {
1008+
id: '1',
1009+
commonKeychain: 'userPub',
1010+
type: 'tss',
1011+
source: 'user',
1012+
},
1013+
backupKeychain: {
1014+
id: '2',
1015+
commonKeychain: 'userPub',
1016+
type: 'tss',
1017+
source: 'backup',
1018+
},
1019+
bitgoKeychain: {
1020+
id: '3',
1021+
commonKeychain: 'userPub',
1022+
type: 'tss',
1023+
source: 'bitgo',
1024+
},
1025+
};
1026+
const stubCreateKeychains = sandbox
1027+
.stub(ECDSAUtils.EcdsaMPCv2Utils.prototype, 'createKeychains')
1028+
.resolves(stubbedKeychainsTriplet);
1029+
1030+
const walletNock = nock('https://bitgo.fakeurl')
1031+
.post(`/api/v2/hteth/wallet`, (body) => {
1032+
body.walletVersion.should.equal(5);
1033+
return true;
1034+
})
1035+
.reply(200);
1036+
1037+
const wallets = new Wallets(bitgo, testCoin);
1038+
1039+
const params = {
1040+
label: 'tss wallet',
1041+
passphrase: 'tss password',
1042+
multisigType: 'tss' as const,
1043+
enterprise: 'enterprise',
1044+
passcodeEncryptionCode: 'originalPasscodeEncryptionCode',
1045+
walletVersion: 3,
1046+
};
1047+
1048+
const response = await wallets.generateWallet(params);
1049+
1050+
walletNock.isDone().should.be.true();
1051+
stubCreateKeychains.calledOnce.should.be.true();
1052+
1053+
assert.ok(response.encryptedWalletPassphrase);
1054+
assert.ok(response.wallet);
1055+
assert.equal(
1056+
bitgo.decrypt({ input: response.encryptedWalletPassphrase, password: params.passcodeEncryptionCode }),
1057+
params.passphrase
1058+
);
1059+
});
1060+
9471061
it('should throw for a cold wallet using wallet version 5', async function () {
9481062
const hteth = bitgo.coin('hteth');
9491063
const wallets = new Wallets(bitgo, hteth);

modules/sdk-core/src/bitgo/wallet/wallets.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ export class Wallets implements IWallets {
982982
.result();
983983
const multisigTypeVersion =
984984
tssSettings.coinSettings[this.baseCoin.getFamily()]?.walletCreationSettings?.multiSigTypeVersion;
985-
if (this.baseCoin.isEVM() && multisigTypeVersion === 'MPCv2') {
985+
if (!walletVersion && this.baseCoin.isEVM() && multisigTypeVersion === 'MPCv2') {
986986
walletVersion = 5;
987987
}
988988
}

0 commit comments

Comments
 (0)