Skip to content

Commit 7da4e23

Browse files
feat: nest vault keys under walletType
WCN-1192 TICKET: WCN-1192
1 parent 06f2597 commit 7da4e23

3 files changed

Lines changed: 35 additions & 9 deletions

File tree

modules/sdk-core/src/bitgo/vault/codecs.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,37 @@ export const VaultPermission = t.keyof(
4242
/** An ordered [userKeyId, backupKeyId, bitgoKeyId] triplet — same shape/order as wallet.keys[]. */
4343
export const RootKeyTriplet = t.tuple([t.string, t.string, t.string], 'RootKeyTriplet');
4444

45-
/** The 12 static root key ids, by (curve, scheme). */
46-
export const VaultRootKeys = t.type(
45+
/** The 12 root key ids for a single custody model, keyed by (curve, scheme). */
46+
export const RootKeysByType = t.type(
4747
{
4848
secp256k1Multisig: RootKeyTriplet,
4949
ecdsaMpc: RootKeyTriplet,
5050
eddsaMpc: RootKeyTriplet,
5151
ed25519Multisig: RootKeyTriplet,
5252
},
53+
'RootKeysByType'
54+
);
55+
56+
/** Custody models a vault's roots can be created under. v1 implements `hot` only. */
57+
export const VaultCustodyType = t.keyof(
58+
{
59+
hot: null,
60+
cold: null,
61+
custodial: null,
62+
},
63+
'VaultCustodyType'
64+
);
65+
66+
/**
67+
* A vault's root keys grouped by custody model — each model holds its own set of 4 (curve, scheme)
68+
* root triplets. Only `hot` is populated in v1; `cold`/`custodial` are reserved for later phases.
69+
*/
70+
export const VaultRootKeys = t.partial(
71+
{
72+
hot: RootKeysByType,
73+
cold: RootKeysByType,
74+
custodial: RootKeysByType,
75+
},
5376
'VaultRootKeys'
5477
);
5578

@@ -100,7 +123,6 @@ export const VaultData = t.intersection(
100123
id: t.string,
101124
enterpriseId: t.string,
102125
label: t.string,
103-
// freeze is NOT a status — a frozen vault stays 'active' with the freeze field set (wallet precedent)
104126
status: VaultStatus,
105127
creator: t.string,
106128
users: t.array(VaultMembershipData),
@@ -174,5 +196,5 @@ export const InitializeVaultBody = t.type({ label: t.string }, 'InitializeVaultB
174196
/** POST /enterprise/:eId/vaults/:vId/finalize — the 12 key ids as 4 ordered triplets. */
175197
export const FinalizeVaultBody = t.type({ rootKeys: VaultRootKeys }, 'FinalizeVaultBody');
176198

177-
/** POST/DELETE /enterprise/:eId/vaults/:vId/freeze */
199+
/** POST /enterprise/:eId/vaults/:vId/freeze */
178200
export const FreezeVaultBody = t.partial({ duration: t.number }, 'FreezeVaultBody');

modules/sdk-core/src/bitgo/vault/iVault.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import * as VaultCodecs from './codecs';
1212

1313
export type RootKeyType = t.TypeOf<typeof VaultCodecs.RootKeyType>;
1414
export type VaultPermission = t.TypeOf<typeof VaultCodecs.VaultPermission>;
15+
export type VaultCustodyType = t.TypeOf<typeof VaultCodecs.VaultCustodyType>;
16+
export type RootKeysByType = t.TypeOf<typeof VaultCodecs.RootKeysByType>;
1517
export type VaultRootKeys = t.TypeOf<typeof VaultCodecs.VaultRootKeys>;
1618
export type VaultMembershipData = t.TypeOf<typeof VaultCodecs.VaultMembershipData>;
1719
export type VaultShareRequest = t.TypeOf<typeof VaultCodecs.VaultShareRequest>;
@@ -87,7 +89,7 @@ export interface IVault {
8789
status(): VaultData['status'];
8890
url(extra?: string): string;
8991
createWallet(params: CreateVaultWalletOptions): Promise<Wallet>;
90-
// whole-vault: view/admin/spend; spend opens a key share (also how a spender services a
92+
// whole-vault: view/admin/spend/dapp; spend opens a key share (also how a spender services a
9193
// vaultShareRequests entry in UMS orgs)
9294
addMember(params: AddVaultMemberOptions): Promise<VaultData>;
9395
// share ONE vault wallet, not the whole vault

modules/sdk-core/test/unit/bitgo/vault/vaults.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ describe('Vaults', function () {
4141
await vaults
4242
.finalizeVault('vid', {
4343
rootKeys: {
44-
secp256k1Multisig: ['u', 'b', 'g'],
45-
ecdsaMpc: ['u', 'b', 'g'],
46-
eddsaMpc: ['u', 'b', 'g'],
47-
ed25519Multisig: ['u', 'b', 'g'],
44+
hot: {
45+
secp256k1Multisig: ['u', 'b', 'g'],
46+
ecdsaMpc: ['u', 'b', 'g'],
47+
eddsaMpc: ['u', 'b', 'g'],
48+
ed25519Multisig: ['u', 'b', 'g'],
49+
},
4850
},
4951
})
5052
.should.be.rejectedWith(/not yet implemented .*Phase 2/);

0 commit comments

Comments
 (0)