Skip to content

Commit 927f03a

Browse files
authored
Merge pull request #6880 from BitGo/revert-6872-COIN-5193-EVMkeyring
Revert "feat(sdk-core): EVM keyring wallet and address creation changes"
2 parents c9e4fb8 + be4a440 commit 927f03a

File tree

7 files changed

+3
-554
lines changed

7 files changed

+3
-554
lines changed

modules/sdk-core/src/bitgo/baseCoin/iBaseCoin.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ export interface SupplementGenerateWalletOptions {
208208
type: 'hot' | 'cold' | 'custodial';
209209
subType?: 'lightningCustody' | 'lightningSelfCustody' | 'onPrem';
210210
coinSpecific?: { [coinName: string]: unknown };
211-
referenceWalletId?: string;
212211
}
213212

214213
export interface FeeEstimateOptions {

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,6 @@ export interface CreateAddressOptions {
500500
derivedAddress?: string;
501501
index?: number;
502502
onToken?: string;
503-
referenceCoin?: string;
504-
referenceAddress?: string;
505503
}
506504

507505
export interface UpdateAddressOptions {

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ export interface GenerateWalletOptions {
7070
commonKeychain?: string;
7171
type?: 'hot' | 'cold' | 'custodial';
7272
subType?: 'lightningCustody' | 'lightningSelfCustody';
73-
referenceWalletId?: string;
7473
}
7574

7675
export const GenerateLightningWalletOptionsCodec = t.strict(
@@ -171,7 +170,6 @@ export interface AddWalletOptions {
171170
initializationTxs?: any;
172171
disableTransactionNotifications?: boolean;
173172
gasPrice?: number;
174-
referenceWalletId?: string;
175173
}
176174

177175
type KeySignatures = {

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

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,8 +1251,6 @@ export class Wallet implements IWallet {
12511251
baseAddress,
12521252
allowSkipVerifyAddress = true,
12531253
onToken,
1254-
referenceCoin,
1255-
referenceAddress,
12561254
} = params;
12571255

12581256
if (!_.isUndefined(chain)) {
@@ -1327,30 +1325,6 @@ export class Wallet implements IWallet {
13271325
}
13281326
}
13291327

1330-
// Validate EVM keyring params, referenceAddress is required and referenceCoin is optional for EVM keyring
1331-
if (!_.isUndefined(referenceAddress)) {
1332-
if (!_.isString(referenceAddress)) {
1333-
throw new Error('referenceAddress has to be a string');
1334-
}
1335-
if (!this.baseCoin.isEVM()) {
1336-
throw new Error('referenceAddress is only supported for EVM chains');
1337-
}
1338-
if (!this.baseCoin.isValidAddress(referenceAddress)) {
1339-
throw new Error('referenceAddress must be a valid address');
1340-
}
1341-
addressParams.referenceAddress = referenceAddress;
1342-
1343-
if (!_.isUndefined(referenceCoin)) {
1344-
if (!_.isString(referenceCoin)) {
1345-
throw new Error('referenceCoin has to be a string');
1346-
}
1347-
addressParams.referenceCoin = referenceCoin;
1348-
}
1349-
} else if (!_.isUndefined(referenceCoin)) {
1350-
// referenceCoin cannot be used without referenceAddress
1351-
throw new Error('referenceAddress is required when using referenceCoin for EVM keyring');
1352-
}
1353-
13541328
// get keychains for address verification
13551329
const keychains = await Promise.all(this._wallet.keys.map((k) => this.baseCoin.keychains().get({ id: k, reqId })));
13561330
const rootAddress = _.get(this._wallet, 'receiveAddress.address');

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

Lines changed: 3 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,8 @@ export class Wallets implements IWallets {
101101
throw new Error('missing required string parameter label');
102102
}
103103

104-
// Validate referenceWalletId parameter
105-
if (params.referenceWalletId) {
106-
if (!_.isString(params.referenceWalletId)) {
107-
throw new Error('invalid referenceWalletId argument, expecting string');
108-
}
109-
if (!this.baseCoin.isEVM()) {
110-
throw new Error('referenceWalletId is only supported for EVM chains');
111-
}
112-
}
113-
114-
// For wallets with referenceWalletId, skip multisig validation as configuration is inherited
115-
if (params.referenceWalletId) {
116-
// Skip all multisig validation - configuration will be inherited from reference wallet
117-
} else if (params.type !== 'custodial') {
118-
// Standard validation for non-custodial wallets without referenceWalletId
104+
// no need to pass keys for (single) custodial wallets
105+
if (params.type !== 'custodial') {
119106
if (Array.isArray(params.keys) === false || !_.isNumber(params.m) || !_.isNumber(params.n)) {
120107
throw new Error('invalid argument');
121108
}
@@ -285,10 +272,9 @@ export class Wallets implements IWallets {
285272
throw new Error('missing required string parameter label');
286273
}
287274

288-
const { type = 'hot', label, passphrase, enterprise, isDistributedCustody, referenceWalletId } = params;
275+
const { type = 'hot', label, passphrase, enterprise, isDistributedCustody } = params;
289276
const isTss = params.multisigType === 'tss' && this.baseCoin.supportsTss();
290277
const canEncrypt = !!passphrase && typeof passphrase === 'string';
291-
const isEVMWithReference = this.baseCoin.isEVM() && referenceWalletId;
292278

293279
const walletParams: SupplementGenerateWalletOptions = {
294280
label: label,
@@ -298,11 +284,6 @@ export class Wallets implements IWallets {
298284
type: !!params.userKey && params.multisigType !== 'onchain' ? 'cold' : type,
299285
};
300286

301-
// Add referenceWalletId to walletParams if provided for EVM chains
302-
if (isEVMWithReference) {
303-
walletParams.referenceWalletId = referenceWalletId;
304-
}
305-
306287
if (!_.isUndefined(params.passcodeEncryptionCode)) {
307288
if (!_.isString(params.passcodeEncryptionCode)) {
308289
throw new Error('passcodeEncryptionCode must be a string');
@@ -316,59 +297,15 @@ export class Wallets implements IWallets {
316297
walletParams.enterprise = enterprise;
317298
}
318299

319-
// Validate referenceWalletId for EVM keyring
320-
if (!_.isUndefined(referenceWalletId)) {
321-
if (!_.isString(referenceWalletId)) {
322-
throw new Error('invalid referenceWalletId argument, expecting string');
323-
}
324-
if (!this.baseCoin.isEVM()) {
325-
throw new Error('referenceWalletId is only supported for EVM chains');
326-
}
327-
}
328-
329300
// EVM TSS wallets must use wallet version 3, 5 and 6
330-
// Skip this validation for EVM keyring wallets as they inherit version from reference wallet
331301
if (
332302
isTss &&
333303
this.baseCoin.isEVM() &&
334-
!referenceWalletId &&
335304
!(params.walletVersion === 3 || params.walletVersion === 5 || params.walletVersion === 6)
336305
) {
337306
throw new Error('EVM TSS wallets are only supported for wallet version 3, 5 and 6');
338307
}
339308

340-
// Handle EVM keyring wallet creation with referenceWalletId
341-
if (isEVMWithReference) {
342-
// For EVM keyring wallets, multisigType will be inferred from the reference wallet
343-
// No need to explicitly validate TSS requirement here as it will be handled by bgms
344-
345-
// For EVM keyring wallets, we use the add method directly with referenceWalletId
346-
// This bypasses the normal key generation process since keys are shared via keyring
347-
const addWalletParams = {
348-
label,
349-
referenceWalletId,
350-
};
351-
352-
const newWallet = await this.bitgo.post(this.baseCoin.url('/wallet/add')).send(addWalletParams).result();
353-
354-
// For EVM keyring wallets, we need to get the keychains from the reference wallet
355-
const userKeychain = this.baseCoin.keychains().get({ id: newWallet.keys[KeyIndices.USER] });
356-
const backupKeychain = this.baseCoin.keychains().get({ id: newWallet.keys[KeyIndices.BACKUP] });
357-
const bitgoKeychain = this.baseCoin.keychains().get({ id: newWallet.keys[KeyIndices.BITGO] });
358-
359-
const [userKey, backupKey, bitgoKey] = await Promise.all([userKeychain, backupKeychain, bitgoKeychain]);
360-
361-
const result: WalletWithKeychains = {
362-
wallet: new Wallet(this.bitgo, this.baseCoin, newWallet),
363-
userKeychain: userKey,
364-
backupKeychain: backupKey,
365-
bitgoKeychain: bitgoKey,
366-
responseType: 'WalletWithKeychains',
367-
};
368-
369-
return result;
370-
}
371-
372309
if (isTss) {
373310
if (!this.baseCoin.supportsTss()) {
374311
throw new Error(`coin ${this.baseCoin.getFamily()} does not support TSS at this time`);

0 commit comments

Comments
 (0)