|
| 1 | +import type { BitGoRequest, DecryptOptions, EncryptionVersion, EncryptOptions } from '../api'; |
| 2 | + |
| 3 | +/** |
| 4 | + * Minimal BitGo client surface used by the **v1** Wallets facade |
| 5 | + * (`modules/sdk-api/src/v1/wallets.ts`). |
| 6 | + * |
| 7 | + * Intentionally **not** {@link BitGoBase}: importing `BitGoBase` here would |
| 8 | + * create a circular module dependency with `bitgoBase.ts`. |
| 9 | + * Import graph: `bitgoBase → v1Wallets → api` (acyclic). |
| 10 | + * |
| 11 | + * @see BitGoApiV1Wallets for the collection returned by `bitgo.wallets()` |
| 12 | + * @see IWallets for the **v2** coin wallets API (`bitgo.coin(name).wallets()`) |
| 13 | + */ |
| 14 | +export type BitGoApiV1BitGo = { |
| 15 | + get(url: string): BitGoRequest; |
| 16 | + post(url: string): BitGoRequest; |
| 17 | + del(url: string): BitGoRequest; |
| 18 | + url(path: string, version?: number): string; |
| 19 | + encrypt(params: EncryptOptions): Promise<string>; |
| 20 | + decrypt(params: DecryptOptions): Promise<string>; |
| 21 | + getECDHKeychain(): Promise<{ encryptedXprv?: string; xprv?: string }>; |
| 22 | + keychains(): BitGoApiV1Keychains; |
| 23 | +}; |
| 24 | + |
| 25 | +/** |
| 26 | + * v1 keychains surface used by `createWalletWithKeychains` on |
| 27 | + * {@link BitGoApiV1Wallets}. Distinct from the v2 `IKeychains` API. |
| 28 | + */ |
| 29 | +export type BitGoApiV1Keychains = { |
| 30 | + create(): { xpub: string; xprv?: string; encryptedXprv?: string }; |
| 31 | + add(keychainData: Record<string, unknown>): Promise<unknown>; |
| 32 | + createBackup(params: { provider: string; disableKRSEmail?: boolean }): Promise<{ xpub: string }>; |
| 33 | + createBitGo(): Promise<{ xpub: string }>; |
| 34 | +}; |
| 35 | + |
| 36 | +/** Legacy Node-style callback used by v1 wallet APIs. */ |
| 37 | +export type BitGoApiV1Callback<T = unknown> = (err?: Error | null, result?: T) => void; |
| 38 | + |
| 39 | +/** |
| 40 | + * Structural hints for a CommonJS v1 Wallet instance |
| 41 | + * (`modules/sdk-api/src/v1/wallet.ts`) when used as a **parameter**. |
| 42 | + * |
| 43 | + * Not the v2 {@link IWallet} / {@link Wallet} class. |
| 44 | + * |
| 45 | + * Methods that **return** a v1 wallet (`get` / `getWallet` / `add`) still use |
| 46 | + * `Promise<any>`: a stub return type with an index signature broke consumers |
| 47 | + * (e.g. `abstract-utxo` recovery expects `.recover` / `.sweep` and a local |
| 48 | + * `WalletV1` shape). Full typing of `v1/wallet.ts` is a follow-up. |
| 49 | + */ |
| 50 | +export type BitGoApiV1Wallet = { |
| 51 | + id?: string; |
| 52 | + createAddress?: (params?: Record<string, unknown>) => Promise<unknown>; |
| 53 | +}; |
| 54 | + |
| 55 | +/** Params for {@link BitGoApiV1Wallets.list}. */ |
| 56 | +export type BitGoApiV1ListWalletsParams = { |
| 57 | + skip?: number; |
| 58 | + prevId?: string; |
| 59 | + limit?: number; |
| 60 | + getbalances?: boolean; |
| 61 | +}; |
| 62 | + |
| 63 | +/** Params for {@link BitGoApiV1Wallets.get} / {@link BitGoApiV1Wallets.getWallet}. */ |
| 64 | +export type BitGoApiV1GetWalletParams = { |
| 65 | + id: string; |
| 66 | + gpk?: boolean | number; |
| 67 | +}; |
| 68 | + |
| 69 | +/** Params for {@link BitGoApiV1Wallets.cancelInvite}. */ |
| 70 | +export type BitGoApiV1WalletInviteParams = { |
| 71 | + walletInviteId: string; |
| 72 | +}; |
| 73 | + |
| 74 | +/** Params for v1 wallet-share methods on {@link BitGoApiV1Wallets}. */ |
| 75 | +export type BitGoApiV1WalletShareParams = { |
| 76 | + walletShareId: string; |
| 77 | + state?: string; |
| 78 | + encryptedXprv?: string; |
| 79 | + userPassword?: string; |
| 80 | + newWalletPassphrase?: string; |
| 81 | + overrideEncryptedXprv?: string; |
| 82 | + encryptionVersion?: EncryptionVersion; |
| 83 | +}; |
| 84 | + |
| 85 | +/** Params for {@link BitGoApiV1Wallets.createWalletWithKeychains}. */ |
| 86 | +export type BitGoApiV1CreateWalletWithKeychainsParams = { |
| 87 | + passphrase: string; |
| 88 | + label?: string; |
| 89 | + backupXpub?: string; |
| 90 | + backupXpubProvider?: string; |
| 91 | + enterprise?: string; |
| 92 | + passcodeEncryptionCode?: string; |
| 93 | + disableTransactionNotifications?: boolean; |
| 94 | + disableKRSEmail?: boolean; |
| 95 | + encryptionVersion?: EncryptionVersion; |
| 96 | +}; |
| 97 | + |
| 98 | +/** Params for {@link BitGoApiV1Wallets.createForwardWallet}. */ |
| 99 | +export type BitGoApiV1CreateForwardWalletParams = { |
| 100 | + privKey: string; |
| 101 | + sourceAddress: string; |
| 102 | + destinationWallet: BitGoApiV1Wallet; |
| 103 | + label?: string; |
| 104 | + enterprise?: string; |
| 105 | +}; |
| 106 | + |
| 107 | +/** Params for {@link BitGoApiV1Wallets.add}. */ |
| 108 | +export type BitGoApiV1AddWalletParams = { |
| 109 | + label?: string; |
| 110 | + m: number; |
| 111 | + n: number; |
| 112 | + keychains: { xpub: string }[]; |
| 113 | + enterprise?: string; |
| 114 | + disableTransactionNotifications?: boolean; |
| 115 | +}; |
| 116 | + |
| 117 | +/** Params for {@link BitGoApiV1Wallets.remove}. */ |
| 118 | +export type BitGoApiV1RemoveWalletParams = { |
| 119 | + id: string; |
| 120 | +}; |
| 121 | + |
| 122 | +/** |
| 123 | + * **Deprecated v1** wallet collection facade returned by |
| 124 | + * {@link BitGoBase.wallets} / `BitGoAPI.wallets()`. |
| 125 | + * |
| 126 | + * Source of truth: `modules/sdk-api/src/v1/wallets.ts` (CommonJS prototype). |
| 127 | + * |
| 128 | + * | Accessor | Type | API | |
| 129 | + * | --- | --- | --- | |
| 130 | + * | `bitgo.wallets()` | {@link BitGoApiV1Wallets} | **v1** (this type) | |
| 131 | + * | `bitgo.coin(name).wallets()` | {@link IWallets} | **v2** (not this type) | |
| 132 | + * |
| 133 | + * Replaces the previous `wallets(): any` on {@link BitGoBase}. |
| 134 | + * |
| 135 | + * @deprecated Prefer `bitgo.coin(coinName).wallets()` ({@link IWallets}). |
| 136 | + */ |
| 137 | +export type BitGoApiV1Wallets = { |
| 138 | + /** Owning BitGo client (v1 surface only; see {@link BitGoApiV1BitGo}). */ |
| 139 | + bitgo: BitGoApiV1BitGo; |
| 140 | + list(params?: BitGoApiV1ListWalletsParams, callback?: BitGoApiV1Callback): Promise<unknown>; |
| 141 | + /** |
| 142 | + * Returns a CommonJS v1 Wallet instance. |
| 143 | + * Typed as `any` until `sdk-api/src/v1/wallet.ts` is fully typed (call sites |
| 144 | + * use `.recover` / `.sweep` / local `WalletV1` shapes). |
| 145 | + */ |
| 146 | + getWallet(params: BitGoApiV1GetWalletParams, callback?: BitGoApiV1Callback): Promise<any>; |
| 147 | + /** Shorthand for {@link BitGoApiV1Wallets.getWallet}. */ |
| 148 | + get(params: BitGoApiV1GetWalletParams, callback?: BitGoApiV1Callback): Promise<any>; |
| 149 | + listInvites(params?: Record<string, unknown>, callback?: BitGoApiV1Callback): Promise<unknown>; |
| 150 | + cancelInvite(params: BitGoApiV1WalletInviteParams, callback?: BitGoApiV1Callback): Promise<unknown>; |
| 151 | + listShares(params?: Record<string, unknown>, callback?: BitGoApiV1Callback): Promise<unknown>; |
| 152 | + resendShareInvite(params: BitGoApiV1WalletShareParams, callback?: BitGoApiV1Callback): Promise<unknown>; |
| 153 | + getShare(params: BitGoApiV1WalletShareParams, callback?: BitGoApiV1Callback): Promise<unknown>; |
| 154 | + updateShare(params: BitGoApiV1WalletShareParams, callback?: BitGoApiV1Callback): Promise<unknown>; |
| 155 | + cancelShare(params: BitGoApiV1WalletShareParams, callback?: BitGoApiV1Callback): Promise<unknown>; |
| 156 | + acceptShare(params: BitGoApiV1WalletShareParams, callback?: BitGoApiV1Callback): Promise<unknown>; |
| 157 | + createKey(params?: Record<string, unknown>): { address: string; key: string }; |
| 158 | + createWalletWithKeychains( |
| 159 | + params: BitGoApiV1CreateWalletWithKeychainsParams, |
| 160 | + callback?: BitGoApiV1Callback |
| 161 | + ): Promise<unknown>; |
| 162 | + createForwardWallet(params: BitGoApiV1CreateForwardWalletParams, callback?: BitGoApiV1Callback): Promise<unknown>; |
| 163 | + /** Returns a CommonJS v1 Wallet instance (`any` — see {@link BitGoApiV1Wallets.getWallet}). */ |
| 164 | + add(params: BitGoApiV1AddWalletParams, callback?: BitGoApiV1Callback): Promise<any>; |
| 165 | + remove(params: BitGoApiV1RemoveWalletParams, callback?: BitGoApiV1Callback): Promise<unknown>; |
| 166 | +}; |
0 commit comments