diff --git a/src/public-api/services/deposit-accounts.ts b/src/public-api/services/deposit-accounts.ts new file mode 100644 index 00000000..c192ab52 --- /dev/null +++ b/src/public-api/services/deposit-accounts.ts @@ -0,0 +1,51 @@ +import { PrivyAPI } from '../../client'; +import { prepareRequest } from '../../lib/authorization'; +import { Crypto, CryptoCreateParams } from '../../resources/wallets/deposit-accounts/crypto'; +import { DepositAccounts } from '../../resources/wallets/deposit-accounts/deposit-accounts'; +import { CreateCryptoDepositAccountResponse } from '../../resources/wallets/wallets'; +import { PrivyClient } from '../PrivyClient'; +import { Prettify, WithAuthorization, WithIdempotency } from './types'; + +export class PrivyDepositAccountsCryptoService extends Crypto { + private privyClient: PrivyClient; + + constructor(privyApiClient: PrivyAPI, privyClient: PrivyClient) { + super(privyApiClient); + this.privyClient = privyClient; + } + + public async create( + walletId: string, + { + authorization_context: authorizationContext = {}, + idempotency_key: idempotencyKey, + ...params + }: PrivyDepositAccountsCryptoService.CreateInput, + ): Promise { + const { headers } = await prepareRequest(this.privyClient, this._client.appID, { + authorizationContext, + idempotencyKey, + requestExpiry: this.privyClient.getRequestExpiry(), + method: 'POST', + url: `${this._client.baseURL}/v1/wallets/${walletId}/deposit_accounts/crypto`, + body: params, + }); + + return await this._create(walletId, { ...params, ...headers }); + } +} + +// prettier-ignore +export namespace PrivyDepositAccountsCryptoService { + /** The input type for the {@link PrivyDepositAccountsCryptoService.create} method. */ + export type CreateInput = Prettify>>; +} + +export class PrivyDepositAccountsService extends DepositAccounts { + override crypto: PrivyDepositAccountsCryptoService; + + constructor(privyApiClient: PrivyAPI, privyClient: PrivyClient) { + super(privyApiClient); + this.crypto = new PrivyDepositAccountsCryptoService(privyApiClient, privyClient); + } +} diff --git a/src/public-api/services/wallets.ts b/src/public-api/services/wallets.ts index 099f920f..617f6a55 100644 --- a/src/public-api/services/wallets.ts +++ b/src/public-api/services/wallets.ts @@ -21,6 +21,7 @@ import { } from '../../resources'; import { TransferActionResponse } from '../../resources/wallets/actions'; import { PrivyClient } from '../PrivyClient'; +import { PrivyDepositAccountsService } from './deposit-accounts'; import { PrivyEarnService } from './earn'; import { PrivyEthereumService } from './ethereum'; import { PrivySolanaService } from './solana'; @@ -29,6 +30,7 @@ import { PrivySwapsService } from './swaps'; import { Prettify, WithAuthorization, WithExpiry, WithIdempotency } from './types'; export class PrivyWalletsService extends Wallets { + override depositAccounts: PrivyDepositAccountsService; private ethereumService: PrivyEthereumService; private solanaService: PrivySolanaService; private tronService: PrivyTronService; @@ -39,6 +41,7 @@ export class PrivyWalletsService extends Wallets { constructor(privyApiClient: PrivyAPI, privyClient: PrivyClient) { super(privyApiClient); this.privyClient = privyClient; + this.depositAccounts = new PrivyDepositAccountsService(privyApiClient, privyClient); this.ethereumService = new PrivyEthereumService(this); this.solanaService = new PrivySolanaService(this); this.tronService = new PrivyTronService(this);