Skip to content

Commit 00abc84

Browse files
authored
Merge pull request #7720 from BitGo/COIN-6822
feat: added evmKeyRingReferenceWalletId in GenerateWalletBody
2 parents 1c4b78a + f40414b commit 00abc84

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

modules/express/src/typedRoutes/api/v2/generateWallet.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ export const GenerateWalletBody = {
4343
bitgoKeyId: optional(t.string),
4444
/** Common keychain for self-managed cold MPC wallets */
4545
commonKeychain: optional(t.string),
46+
/** Reference wallet ID for creating EVM keyring child wallets. When provided, the new wallet inherits keys and properties from the reference wallet, enabling unified addresses across EVM chains. */
47+
evmKeyRingReferenceWalletId: optional(t.string),
4648
} as const;
4749

4850
export const GenerateWalletResponse200 = t.union([

modules/express/test/unit/typedRoutes/generateWallet.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,55 @@ describe('Generate Wallet Typed Routes Tests', function () {
276276
generateWalletStub.firstCall.args[0].should.have.property('bitgoKeyId', bitgoKeyId);
277277
generateWalletStub.firstCall.args[0].should.have.property('commonKeychain', commonKeychain);
278278
});
279+
280+
it('should successfully generate EVM keyring wallet with evmKeyRingReferenceWalletId', async function () {
281+
const coin = 'tpolygon';
282+
const label = 'EVM Keyring Child Wallet';
283+
const evmKeyRingReferenceWalletId = 'referenceWallet123';
284+
285+
const mockWallet = {
286+
id: 'walletKeyring',
287+
coin,
288+
label,
289+
evmKeyRingReferenceWalletId,
290+
toJSON: sinon.stub().returns({
291+
id: 'walletKeyring',
292+
coin,
293+
label,
294+
evmKeyRingReferenceWalletId,
295+
multisigType: 'tss',
296+
}),
297+
};
298+
299+
const walletResponse = {
300+
wallet: mockWallet,
301+
userKeychain: { id: 'userKeyKeyring' },
302+
backupKeychain: { id: 'backupKeyKeyring' },
303+
bitgoKeychain: { id: 'bitgoKeyKeyring' },
304+
};
305+
306+
const generateWalletStub = sinon.stub().resolves(walletResponse);
307+
const walletsStub = { generateWallet: generateWalletStub } as any;
308+
const coinStub = { wallets: sinon.stub().returns(walletsStub) } as any;
309+
310+
sinon.stub(BitGo.prototype, 'coin').returns(coinStub);
311+
312+
const res = await agent.post(`/api/v2/${coin}/wallet/generate`).send({
313+
label,
314+
evmKeyRingReferenceWalletId,
315+
});
316+
317+
res.status.should.equal(200);
318+
res.body.should.have.property('wallet');
319+
res.body.wallet.should.have.property('evmKeyRingReferenceWalletId', evmKeyRingReferenceWalletId);
320+
321+
generateWalletStub.should.have.been.calledOnce();
322+
generateWalletStub.firstCall.args[0].should.have.property('label', label);
323+
generateWalletStub.firstCall.args[0].should.have.property(
324+
'evmKeyRingReferenceWalletId',
325+
evmKeyRingReferenceWalletId
326+
);
327+
});
279328
});
280329

281330
describe('Codec Validation', function () {

0 commit comments

Comments
 (0)