|
5 | 5 | * changes) before the public release. |
6 | 6 | */ |
7 | 7 | import * as t from 'io-ts'; |
8 | | -import { FinalizeSafeBody, InitializeSafeBody, RootKeyTriplet, RootKeyType, SafeData } from '@bitgo/public-types'; |
| 8 | +import { |
| 9 | + FinalizeSafeBody, |
| 10 | + InitializeSafeBody, |
| 11 | + InitializeSafeResponse, |
| 12 | + RootKeyTriplet, |
| 13 | + RootKeyType, |
| 14 | + SafeData, |
| 15 | +} from '@bitgo/public-types'; |
9 | 16 | import { Environments } from '../../common'; |
10 | 17 | import { IBaseCoin } from '../baseCoin'; |
11 | 18 | import { BitGoBase } from '../bitgoBase'; |
@@ -87,19 +94,19 @@ export class Safes implements ISafes { |
87 | 94 | */ |
88 | 95 | async generateSafe(params: CreateSafeOptions): Promise<Safe> { |
89 | 96 | const safe = await this.initializeSafe({ label: params.label }); |
90 | | - const rootKeys = await this.createSafeKeys({ ...params, safeId: safe.id() }); |
91 | | - return await this.finalizeSafe(safe.id(), rootKeys); |
| 97 | + const rootKeys = await this.createSafeKeys({ ...params, safeId: safe.id }); |
| 98 | + return await this.finalizeSafe(safe.id, rootKeys); |
92 | 99 | } |
93 | 100 |
|
94 | 101 | /** |
95 | 102 | * Phase 1 — initialize a safe (metadata only, no key material). |
96 | 103 | * POST /api/v2/enterprise/:eId/safes { label } |
| 104 | + * Response is just `{ id, status }` — the safe has no label/roster/etc. yet. |
97 | 105 | * @experimental |
98 | 106 | */ |
99 | | - async initializeSafe(params: InitializeSafeOptions): Promise<Safe> { |
| 107 | + async initializeSafe(params: InitializeSafeOptions): Promise<InitializeSafeResponse> { |
100 | 108 | const response = await postWithCodec(this.bitgo, this.url(), InitializeSafeBody, params).result(); |
101 | | - const safeData = decodeWithCodec(SafeData, response, 'SafeData'); |
102 | | - return new Safe(this.bitgo, safeData); |
| 109 | + return decodeWithCodec(InitializeSafeResponse, response, 'InitializeSafeResponse'); |
103 | 110 | } |
104 | 111 |
|
105 | 112 | /** |
|
0 commit comments