|
| 1 | +import * as t from 'io-ts'; |
| 2 | +import { httpRoute, httpRequest, optional } from '@api-ts/io-ts-http'; |
| 3 | +import { BitgoExpressError } from '../../schemas/error'; |
| 4 | +import { EIP1559, ForwarderVersion, CreateAddressFormat } from '../../schemas/address'; |
| 5 | + |
| 6 | +/** |
| 7 | + * Path parameters for creating a wallet address |
| 8 | + */ |
| 9 | +export const CreateAddressParams = { |
| 10 | + /** Coin ticker / chain identifier */ |
| 11 | + coin: t.string, |
| 12 | + /** The ID of the wallet. */ |
| 13 | + id: t.string, |
| 14 | +} as const; |
| 15 | + |
| 16 | +/** |
| 17 | + * Request body for creating a wallet address |
| 18 | + */ |
| 19 | +export const CreateAddressBody = { |
| 20 | + /** Address type for chains that support multiple address types */ |
| 21 | + type: optional(t.string), |
| 22 | + /** Chain on which the new address should be created. Default: 1 */ |
| 23 | + chain: optional(t.number), |
| 24 | + /** |
| 25 | + * (ETH only) Specify forwarder version to use in address creation. |
| 26 | + * 0: legacy forwarder; |
| 27 | + * 1: fee-improved forwarder; |
| 28 | + * 2: NFT-supported forwarder (v2 wallets); |
| 29 | + * 3: MPC wallets; |
| 30 | + * 4: EVM variants; |
| 31 | + * 5: new MPC wallets with wallet-version 6 |
| 32 | + */ |
| 33 | + forwarderVersion: optional(ForwarderVersion), |
| 34 | + /** EVM keyring reference address (EVM only) */ |
| 35 | + evmKeyRingReferenceAddress: optional(t.string), |
| 36 | + /** Create an address for the given token (OFC only) (eg. ofcbtc) */ |
| 37 | + onToken: optional(t.string), |
| 38 | + /** A human-readable label for the address (Max length: 250) */ |
| 39 | + label: optional(t.string), |
| 40 | + /** Whether the deployment should use a low priority fee key (ETH only) Default: false */ |
| 41 | + lowPriority: optional(t.boolean), |
| 42 | + /** Explicit gas price to use when deploying the forwarder contract (ETH only) */ |
| 43 | + gasPrice: optional(t.union([t.number, t.string])), |
| 44 | + /** EIP1559 fee parameters (ETH forwarderVersion: 0 wallets only) */ |
| 45 | + eip1559: optional(EIP1559), |
| 46 | + /** Format to use for the new address (e.g., 'cashaddr' for BCH) */ |
| 47 | + format: optional(CreateAddressFormat), |
| 48 | + /** Number of new addresses to create (maximum 250) */ |
| 49 | + count: optional(t.number), |
| 50 | + /** Base address of the wallet (if applicable) */ |
| 51 | + baseAddress: optional(t.string), |
| 52 | + /** When false, throw error if address verification is skipped */ |
| 53 | + allowSkipVerifyAddress: optional(t.boolean), |
| 54 | +} as const; |
| 55 | + |
| 56 | +/** Response for creating a wallet address */ |
| 57 | +export const CreateAddressResponse = { |
| 58 | + 200: t.unknown, |
| 59 | + 400: BitgoExpressError, |
| 60 | +} as const; |
| 61 | + |
| 62 | +/** |
| 63 | + * Create address for a wallet |
| 64 | + * |
| 65 | + * @tag express |
| 66 | + * @operationId express.v2.wallet.createAddress |
| 67 | + */ |
| 68 | +export const PostCreateAddress = httpRoute({ |
| 69 | + path: '/api/v2/{coin}/wallet/{walletId}/address', |
| 70 | + method: 'POST', |
| 71 | + request: httpRequest({ |
| 72 | + params: CreateAddressParams, |
| 73 | + body: CreateAddressBody, |
| 74 | + }), |
| 75 | + response: CreateAddressResponse, |
| 76 | +}); |
0 commit comments