Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions src/public-api/services/deposit-accounts.ts
Original file line number Diff line number Diff line change
@@ -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<CreateCryptoDepositAccountResponse> {
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<WithIdempotency<WithAuthorization<CryptoCreateParams>>>;
}

export class PrivyDepositAccountsService extends DepositAccounts {
override crypto: PrivyDepositAccountsCryptoService;

constructor(privyApiClient: PrivyAPI, privyClient: PrivyClient) {
super(privyApiClient);
this.crypto = new PrivyDepositAccountsCryptoService(privyApiClient, privyClient);
}
}
3 changes: 3 additions & 0 deletions src/public-api/services/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand All @@ -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);
Expand Down
Loading