Skip to content
Merged
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
2 changes: 2 additions & 0 deletions modules/express/src/typedRoutes/api/v2/generateWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
49 changes: 49 additions & 0 deletions modules/express/test/unit/typedRoutes/generateWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down