From f40414b556f652a3595ec1522684b50638f89fff Mon Sep 17 00:00:00 2001 From: neha-kri Date: Tue, 9 Dec 2025 17:08:01 +0530 Subject: [PATCH] feat: added evmKeyRingReferenceWalletId in GenerateWalletBody TICKET: COIN-6822 TICKET: COIN-6822 --- .../src/typedRoutes/api/v2/generateWallet.ts | 2 + .../test/unit/typedRoutes/generateWallet.ts | 49 +++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/modules/express/src/typedRoutes/api/v2/generateWallet.ts b/modules/express/src/typedRoutes/api/v2/generateWallet.ts index d7be65db55..0166cc94cd 100644 --- a/modules/express/src/typedRoutes/api/v2/generateWallet.ts +++ b/modules/express/src/typedRoutes/api/v2/generateWallet.ts @@ -43,6 +43,8 @@ export const GenerateWalletBody = { bitgoKeyId: optional(t.string), /** Common keychain for self-managed cold MPC wallets */ commonKeychain: optional(t.string), + /** 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. */ + evmKeyRingReferenceWalletId: optional(t.string), } as const; export const GenerateWalletResponse200 = t.union([ diff --git a/modules/express/test/unit/typedRoutes/generateWallet.ts b/modules/express/test/unit/typedRoutes/generateWallet.ts index f89ddca14b..eebd53a15d 100644 --- a/modules/express/test/unit/typedRoutes/generateWallet.ts +++ b/modules/express/test/unit/typedRoutes/generateWallet.ts @@ -276,6 +276,55 @@ describe('Generate Wallet Typed Routes Tests', function () { generateWalletStub.firstCall.args[0].should.have.property('bitgoKeyId', bitgoKeyId); generateWalletStub.firstCall.args[0].should.have.property('commonKeychain', commonKeychain); }); + + it('should successfully generate EVM keyring wallet with evmKeyRingReferenceWalletId', async function () { + const coin = 'tpolygon'; + const label = 'EVM Keyring Child Wallet'; + const evmKeyRingReferenceWalletId = 'referenceWallet123'; + + const mockWallet = { + id: 'walletKeyring', + coin, + label, + evmKeyRingReferenceWalletId, + toJSON: sinon.stub().returns({ + id: 'walletKeyring', + coin, + label, + evmKeyRingReferenceWalletId, + multisigType: 'tss', + }), + }; + + const walletResponse = { + wallet: mockWallet, + userKeychain: { id: 'userKeyKeyring' }, + backupKeychain: { id: 'backupKeyKeyring' }, + bitgoKeychain: { id: 'bitgoKeyKeyring' }, + }; + + const generateWalletStub = sinon.stub().resolves(walletResponse); + const walletsStub = { generateWallet: generateWalletStub } as any; + const coinStub = { wallets: sinon.stub().returns(walletsStub) } as any; + + sinon.stub(BitGo.prototype, 'coin').returns(coinStub); + + const res = await agent.post(`/api/v2/${coin}/wallet/generate`).send({ + label, + evmKeyRingReferenceWalletId, + }); + + res.status.should.equal(200); + res.body.should.have.property('wallet'); + res.body.wallet.should.have.property('evmKeyRingReferenceWalletId', evmKeyRingReferenceWalletId); + + generateWalletStub.should.have.been.calledOnce(); + generateWalletStub.firstCall.args[0].should.have.property('label', label); + generateWalletStub.firstCall.args[0].should.have.property( + 'evmKeyRingReferenceWalletId', + evmKeyRingReferenceWalletId + ); + }); }); describe('Codec Validation', function () {