@coinbase-sample/prime-sdk-ts 0.8.0 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/activities/index.js +14 -0
- package/dist/addressBooks/index.js +10 -0
- package/dist/allocations/index.js +12 -0
- package/dist/assets/index.js +4 -0
- package/dist/balances/index.js +15 -0
- package/dist/commission/index.js +4 -0
- package/dist/constants.js +1 -1
- package/dist/financing/index.js +52 -0
- package/dist/futures/index.js +33 -0
- package/dist/index.js +7 -1
- package/dist/invoices/index.js +4 -0
- package/dist/model/GetStakingStatusResponse.js +21 -0
- package/dist/model/StakingStatus.js +21 -0
- package/dist/model/SubmitDepositTravelRuleDataResponse.js +21 -0
- package/dist/model/TravelRuleData.js +21 -0
- package/dist/model/ValidatorStakingInfo.js +21 -0
- package/dist/model/enums/StakeType.js +28 -0
- package/dist/model/enums/index.js +4 -2
- package/dist/model/googleTypeDate.js +21 -0
- package/dist/model/requestToSubmitTravelRuleDataForAnExistingDepositTransaction.js +21 -0
- package/dist/onchainAddressBook/index.js +14 -0
- package/dist/orders/index.js +59 -0
- package/dist/paymentMethods/index.js +8 -0
- package/dist/portfolios/index.js +10 -0
- package/dist/positions/index.js +7 -0
- package/dist/products/index.js +11 -0
- package/dist/shared/__tests__/validation.test.js +184 -124
- package/dist/shared/validation.js +90 -260
- package/dist/staking/index.js +55 -0
- package/dist/transactions/index.js +58 -0
- package/dist/types/constants.d.ts +1 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/types/model/Balance.d.ts +4 -0
- package/dist/types/model/CreatePortfolioAddressBookEntryRequest.d.ts +0 -2
- package/dist/types/model/CreateWalletWithdrawalRequest.d.ts +2 -0
- package/dist/types/model/GetStakingStatusResponse.d.ts +42 -0
- package/dist/types/model/StakingStatus.d.ts +39 -0
- package/dist/types/model/SubmitDepositTravelRuleDataResponse.d.ts +22 -0
- package/dist/types/model/TravelRuleData.d.ts +37 -0
- package/dist/types/model/TravelRuleParty.d.ts +19 -4
- package/dist/types/model/ValidatorStakingInfo.d.ts +30 -0
- package/dist/types/model/enums/StakeType.d.ts +24 -0
- package/dist/types/model/enums/index.d.ts +1 -0
- package/dist/types/model/googleTypeDate.d.ts +36 -0
- package/dist/types/model/index.d.ts +7 -0
- package/dist/types/model/requestToSubmitTravelRuleDataForAnExistingDepositTransaction.d.ts +26 -0
- package/dist/types/orders/types.d.ts +1 -1
- package/dist/types/shared/validation.d.ts +19 -107
- package/dist/types/staking/index.d.ts +3 -1
- package/dist/types/staking/types.d.ts +6 -1
- package/dist/types/transactions/index.d.ts +3 -1
- package/dist/types/transactions/types.d.ts +6 -1
- package/dist/types/wallets/types.d.ts +1 -1
- package/dist/users/index.js +7 -0
- package/dist/wallets/index.js +27 -0
- package/package.json +6 -2
|
@@ -6,113 +6,10 @@ export interface ValidationError {
|
|
|
6
6
|
message: string;
|
|
7
7
|
value?: any;
|
|
8
8
|
}
|
|
9
|
-
/**
|
|
10
|
-
* Validation result that accumulates errors with fluent/builder pattern support
|
|
11
|
-
*/
|
|
12
|
-
export declare class ValidationResult {
|
|
13
|
-
private errors;
|
|
14
|
-
/**
|
|
15
|
-
* Add a validation error
|
|
16
|
-
*/
|
|
17
|
-
addError(paramName: string, message: string, value?: any): void;
|
|
18
|
-
/**
|
|
19
|
-
* Check if there are any validation errors
|
|
20
|
-
*/
|
|
21
|
-
hasErrors(): boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Get all validation errors
|
|
24
|
-
*/
|
|
25
|
-
getErrors(): ValidationError[];
|
|
26
|
-
/**
|
|
27
|
-
* Validates that a required UUID parameter is present and valid.
|
|
28
|
-
* Returns this for method chaining.
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```typescript
|
|
32
|
-
* validator
|
|
33
|
-
* .validateRequiredUUID(request.portfolioId, 'portfolioId')
|
|
34
|
-
* .validateRequiredUUID(request.orderId, 'orderId')
|
|
35
|
-
* .check();
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
validateRequiredUUID(value: string | undefined | null, paramName: string): this;
|
|
39
|
-
/**
|
|
40
|
-
* Validates that an optional UUID parameter is valid if provided.
|
|
41
|
-
* Returns this for method chaining.
|
|
42
|
-
*/
|
|
43
|
-
validateOptionalUUID(value: string | undefined | null, paramName: string): this;
|
|
44
|
-
/**
|
|
45
|
-
* Validates that a required string parameter is present and not empty.
|
|
46
|
-
* Returns this for method chaining.
|
|
47
|
-
*/
|
|
48
|
-
validateRequiredString(value: string | undefined | null, paramName: string): this;
|
|
49
|
-
/**
|
|
50
|
-
* Validates that an optional string parameter is not empty if provided.
|
|
51
|
-
* Returns this for method chaining.
|
|
52
|
-
*/
|
|
53
|
-
validateOptionalString(value: string | undefined | null, paramName: string): this;
|
|
54
|
-
/**
|
|
55
|
-
* Throw an exception if there are validation errors.
|
|
56
|
-
* Automatically detects the calling method name if no context is provided.
|
|
57
|
-
*
|
|
58
|
-
* @param contextMessage - Optional context message. If not provided, attempts to detect method name.
|
|
59
|
-
* @throws {CoinbasePrimeClientException} if there are validation errors
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* ```typescript
|
|
63
|
-
* const validator = createValidator();
|
|
64
|
-
* validateRequiredUUID(validator, request.id, 'id');
|
|
65
|
-
* validator.throwIfInvalid(); // Automatically detects calling method
|
|
66
|
-
* ```
|
|
67
|
-
*/
|
|
68
|
-
throwIfInvalid(contextMessage?: string): void;
|
|
69
|
-
/**
|
|
70
|
-
* Alias for throwIfInvalid() - more natural for fluent/builder pattern.
|
|
71
|
-
* Throw an exception if there are validation errors.
|
|
72
|
-
*
|
|
73
|
-
* @param contextMessage - Optional context message. If not provided, attempts to detect method name.
|
|
74
|
-
* @throws {CoinbasePrimeClientException} if there are validation errors
|
|
75
|
-
*
|
|
76
|
-
* @example
|
|
77
|
-
* ```typescript
|
|
78
|
-
* validator
|
|
79
|
-
* .validateRequiredUUID(request.portfolioId, 'portfolioId')
|
|
80
|
-
* .validateRequiredUUID(request.orderId, 'orderId')
|
|
81
|
-
* .check(); // ✅ Fluent pattern
|
|
82
|
-
* ```
|
|
83
|
-
*/
|
|
84
|
-
check(contextMessage?: string): void;
|
|
85
|
-
/**
|
|
86
|
-
* Attempts to extract the calling method name from the stack trace.
|
|
87
|
-
* This provides automatic context for validation errors.
|
|
88
|
-
* Falls back to 'Request validation failed' if method name cannot be determined.
|
|
89
|
-
*/
|
|
90
|
-
private getCallerContext;
|
|
91
|
-
}
|
|
92
9
|
/**
|
|
93
10
|
* Validates that a string is a valid UUID v4 format
|
|
94
11
|
*/
|
|
95
12
|
export declare function isValidUUID(value: string): boolean;
|
|
96
|
-
/**
|
|
97
|
-
* Validates that a required UUID parameter is present and valid
|
|
98
|
-
*/
|
|
99
|
-
export declare function validateRequiredUUID(validator: ValidationResult, value: string | undefined | null, paramName: string): void;
|
|
100
|
-
/**
|
|
101
|
-
* Validates that an optional UUID parameter is valid if provided
|
|
102
|
-
*/
|
|
103
|
-
export declare function validateOptionalUUID(validator: ValidationResult, value: string | undefined | null, paramName: string): void;
|
|
104
|
-
/**
|
|
105
|
-
* Validates that a required string parameter is present and not empty
|
|
106
|
-
*/
|
|
107
|
-
export declare function validateRequiredString(validator: ValidationResult, value: string | undefined | null, paramName: string): void;
|
|
108
|
-
/**
|
|
109
|
-
* Validates that an optional string parameter is not empty if provided
|
|
110
|
-
*/
|
|
111
|
-
export declare function validateOptionalString(validator: ValidationResult, value: string | undefined | null, paramName: string): void;
|
|
112
|
-
/**
|
|
113
|
-
* Convenience function to create a new ValidationResult
|
|
114
|
-
*/
|
|
115
|
-
export declare function createValidator(): ValidationResult;
|
|
116
13
|
/**
|
|
117
14
|
* Creates a validator with property accessor support for automatic field name inference.
|
|
118
15
|
*
|
|
@@ -132,7 +29,7 @@ export declare function validate<T extends Record<string, any>>(source: T): Prop
|
|
|
132
29
|
* Uses Proxy to track property accesses and extract field names automatically.
|
|
133
30
|
*/
|
|
134
31
|
export declare class PropertyValidator<T extends Record<string, any>> {
|
|
135
|
-
private
|
|
32
|
+
private errors;
|
|
136
33
|
private source;
|
|
137
34
|
constructor(source: T);
|
|
138
35
|
/**
|
|
@@ -159,15 +56,30 @@ export declare class PropertyValidator<T extends Record<string, any>> {
|
|
|
159
56
|
* Validates that an optional string field is not empty if provided.
|
|
160
57
|
*/
|
|
161
58
|
optionalString(accessor: (source: T) => string | undefined | null): this;
|
|
59
|
+
/**
|
|
60
|
+
* Validates that a required array field is present and not empty.
|
|
61
|
+
*/
|
|
62
|
+
requiredArray(accessor: (source: T) => any[] | undefined | null): this;
|
|
63
|
+
/**
|
|
64
|
+
* Validates that a required boolean field is present.
|
|
65
|
+
*/
|
|
66
|
+
requiredBoolean(accessor: (source: T) => boolean | undefined | null): this;
|
|
162
67
|
/**
|
|
163
68
|
* Throws if there are validation errors.
|
|
164
|
-
* Automatically detects the calling method name.
|
|
165
69
|
*/
|
|
166
70
|
check(contextMessage?: string): void;
|
|
167
71
|
/**
|
|
168
|
-
*
|
|
72
|
+
* Add a validation error
|
|
169
73
|
*/
|
|
170
|
-
|
|
74
|
+
addError(paramName: string, message: string, value?: any): void;
|
|
75
|
+
/**
|
|
76
|
+
* Check if there are any validation errors
|
|
77
|
+
*/
|
|
78
|
+
hasErrors(): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Get all validation errors
|
|
81
|
+
*/
|
|
82
|
+
getErrors(): ValidationError[];
|
|
171
83
|
/**
|
|
172
84
|
* Extracts the property name and value from a property accessor function.
|
|
173
85
|
* Uses a Proxy to track which property was accessed.
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { IPrimeApiClient, CoinbaseCallOptions } from '../clients';
|
|
17
|
-
import { CreateStakeRequest, CreateStakeResponse, CreateUnstakeRequest, CreateUnstakeResponse, CreatePortfolioStakeRequest, CreatePortfolioStakeResponse, CreatePortfolioUnstakeRequest, CreatePortfolioUnstakeResponse, QueryTransactionValidatorsRequest, QueryTransactionValidatorsResponse, ClaimRewardsRequest, ClaimRewardsResponse, PreviewUnstakeRequest, PreviewUnstakeResponse, GetUnstakingStatusRequest, GetUnstakingStatusResponse } from './types';
|
|
17
|
+
import { CreateStakeRequest, CreateStakeResponse, CreateUnstakeRequest, CreateUnstakeResponse, CreatePortfolioStakeRequest, CreatePortfolioStakeResponse, CreatePortfolioUnstakeRequest, CreatePortfolioUnstakeResponse, QueryTransactionValidatorsRequest, QueryTransactionValidatorsResponse, ClaimRewardsRequest, ClaimRewardsResponse, PreviewUnstakeRequest, PreviewUnstakeResponse, GetUnstakingStatusRequest, GetUnstakingStatusResponse, GetStakingStatusRequest, GetStakingStatusResponse } from './types';
|
|
18
18
|
export interface IStakingService {
|
|
19
19
|
createStake(request: CreateStakeRequest, options?: CoinbaseCallOptions): Promise<CreateStakeResponse>;
|
|
20
20
|
createUnstake(request: CreateUnstakeRequest, options?: CoinbaseCallOptions): Promise<CreateUnstakeResponse>;
|
|
@@ -24,6 +24,7 @@ export interface IStakingService {
|
|
|
24
24
|
claimRewards(request: ClaimRewardsRequest, options?: CoinbaseCallOptions): Promise<ClaimRewardsResponse>;
|
|
25
25
|
previewUnstake(request: PreviewUnstakeRequest, options?: CoinbaseCallOptions): Promise<PreviewUnstakeResponse>;
|
|
26
26
|
getUnstakingStatus(request: GetUnstakingStatusRequest, options?: CoinbaseCallOptions): Promise<GetUnstakingStatusResponse>;
|
|
27
|
+
getStakingStatus(request: GetStakingStatusRequest, options?: CoinbaseCallOptions): Promise<GetStakingStatusResponse>;
|
|
27
28
|
}
|
|
28
29
|
export declare class StakingService implements IStakingService {
|
|
29
30
|
private client;
|
|
@@ -36,4 +37,5 @@ export declare class StakingService implements IStakingService {
|
|
|
36
37
|
claimRewards(request: ClaimRewardsRequest, options?: CoinbaseCallOptions): Promise<ClaimRewardsResponse>;
|
|
37
38
|
previewUnstake(request: PreviewUnstakeRequest, options?: CoinbaseCallOptions): Promise<PreviewUnstakeResponse>;
|
|
38
39
|
getUnstakingStatus(request: GetUnstakingStatusRequest, options?: CoinbaseCallOptions): Promise<GetUnstakingStatusResponse>;
|
|
40
|
+
getStakingStatus(request: GetStakingStatusRequest, options?: CoinbaseCallOptions): Promise<GetStakingStatusResponse>;
|
|
39
41
|
}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { Brand } from '../shared/brand';
|
|
17
17
|
import { BasePaginatedRequest, PaginatedResponseMethods } from '../shared/paginatedResponse';
|
|
18
|
-
import { StakingInitiateResponse, StakingInitiateRequest, StakingUnstakeResponse, PortfolioStakingInitiateRequest, PortfolioStakingInitiateResponse, PortfolioStakingUnstakeRequest, PortfolioStakingUnstakeResponse, ListTransactionValidatorsResponse as internalListTransactionValidatorsResponse, StakingClaimRewardsRequest as internalStakingClaimRewardsRequest, StakingClaimRewardsResponse as internalStakingClaimRewardsResponse, PreviewUnstakeResponse as internalPreviewUnstakeResponse, GetUnstakingStatusResponse as internalGetUnstakingStatusResponse } from 'src/model/';
|
|
18
|
+
import { StakingInitiateResponse, StakingInitiateRequest, StakingUnstakeResponse, PortfolioStakingInitiateRequest, PortfolioStakingInitiateResponse, PortfolioStakingUnstakeRequest, PortfolioStakingUnstakeResponse, ListTransactionValidatorsResponse as internalListTransactionValidatorsResponse, StakingClaimRewardsRequest as internalStakingClaimRewardsRequest, StakingClaimRewardsResponse as internalStakingClaimRewardsResponse, PreviewUnstakeResponse as internalPreviewUnstakeResponse, GetUnstakingStatusResponse as internalGetUnstakingStatusResponse, GetStakingStatusResponse as internalGetStakingStatusResponse } from 'src/model/';
|
|
19
19
|
export type CreateStakeRequest = StakingInitiateRequest & {
|
|
20
20
|
portfolioId: string;
|
|
21
21
|
walletId: string;
|
|
@@ -56,3 +56,8 @@ export type GetUnstakingStatusRequest = {
|
|
|
56
56
|
walletId: string;
|
|
57
57
|
};
|
|
58
58
|
export type GetUnstakingStatusResponse = Brand<internalGetUnstakingStatusResponse, 'GetUnstakingStatusResponse'>;
|
|
59
|
+
export type GetStakingStatusRequest = {
|
|
60
|
+
portfolioId: string;
|
|
61
|
+
walletId: string;
|
|
62
|
+
};
|
|
63
|
+
export type GetStakingStatusResponse = Brand<internalGetStakingStatusResponse, 'GetStakingStatusResponse'>;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { IPrimeApiClient, CoinbaseCallOptions } from '../clients';
|
|
17
|
-
import { CreateConversionRequest, CreateConversionResponse, CreateOnchainTransactionRequest, CreateOnchainTransactionResponse, CreateTransferRequest, CreateTransferResponse, CreateWithdrawalRequest, CreateWithdrawalResponse, GetTransactionRequest, GetTransactionResponse, ListPortfolioTransactionsRequest, ListPortfolioTransactionsResponse, ListWalletTransactionsRequest, ListWalletTransactionsResponse } from './types';
|
|
17
|
+
import { CreateConversionRequest, CreateConversionResponse, CreateOnchainTransactionRequest, CreateOnchainTransactionResponse, CreateTransferRequest, CreateTransferResponse, CreateWithdrawalRequest, CreateWithdrawalResponse, GetTransactionRequest, GetTransactionResponse, ListPortfolioTransactionsRequest, ListPortfolioTransactionsResponse, ListWalletTransactionsRequest, ListWalletTransactionsResponse, SubmitDepositTravelRuleRequest, SubmitDepositTravelRuleResponse } from './types';
|
|
18
18
|
export interface ITransactionsService {
|
|
19
19
|
getTransaction(request: GetTransactionRequest, options?: CoinbaseCallOptions): Promise<GetTransactionResponse>;
|
|
20
20
|
listPortfolioTransactions(request: ListPortfolioTransactionsRequest, options?: CoinbaseCallOptions): Promise<ListPortfolioTransactionsResponse>;
|
|
@@ -23,6 +23,7 @@ export interface ITransactionsService {
|
|
|
23
23
|
createTransfer(request: CreateTransferRequest, options?: CoinbaseCallOptions): Promise<CreateTransferResponse>;
|
|
24
24
|
createWithdrawal(request: CreateWithdrawalRequest, options?: CoinbaseCallOptions): Promise<CreateWithdrawalResponse>;
|
|
25
25
|
createOnchainTransaction(request: CreateOnchainTransactionRequest, options?: CoinbaseCallOptions): Promise<CreateOnchainTransactionResponse>;
|
|
26
|
+
submitDepositTravelRule(request: SubmitDepositTravelRuleRequest, options?: CoinbaseCallOptions): Promise<SubmitDepositTravelRuleResponse>;
|
|
26
27
|
}
|
|
27
28
|
export declare class TransactionsService implements ITransactionsService {
|
|
28
29
|
private client;
|
|
@@ -34,4 +35,5 @@ export declare class TransactionsService implements ITransactionsService {
|
|
|
34
35
|
createTransfer(request: CreateTransferRequest, options?: CoinbaseCallOptions): Promise<CreateTransferResponse>;
|
|
35
36
|
createWithdrawal(request: CreateWithdrawalRequest, options?: CoinbaseCallOptions): Promise<CreateWithdrawalResponse>;
|
|
36
37
|
createOnchainTransaction(request: CreateOnchainTransactionRequest, options?: CoinbaseCallOptions): Promise<CreateOnchainTransactionResponse>;
|
|
38
|
+
submitDepositTravelRule(request: SubmitDepositTravelRuleRequest, options?: CoinbaseCallOptions): Promise<SubmitDepositTravelRuleResponse>;
|
|
37
39
|
}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { Brand } from '../shared/brand';
|
|
17
17
|
import { TransactionType, TravelRuleStatus } from '../model/enums/';
|
|
18
|
-
import { GetPortfolioTransactionsResponse, GetWalletTransactionsResponse, GetTransactionResponse as internalGet, CreateConversionRequest as internalCreateConversion, CreateConversionResponse as internalCreateConversionResp, CreateATransferBetweenTwoWallets, CreateWalletWithdrawalRequest, CreateWalletWithdrawalResponse, CreateWalletTransferResponse, CreateOnchainTransactionRequest as internalCreate, CreateOnchainTransactionResponse as internalCreateResp } from '../model/';
|
|
18
|
+
import { GetPortfolioTransactionsResponse, GetWalletTransactionsResponse, GetTransactionResponse as internalGet, CreateConversionRequest as internalCreateConversion, CreateConversionResponse as internalCreateConversionResp, CreateATransferBetweenTwoWallets, CreateWalletWithdrawalRequest, CreateWalletWithdrawalResponse, CreateWalletTransferResponse, CreateOnchainTransactionRequest as internalCreate, CreateOnchainTransactionResponse as internalCreateResp, RequestToSubmitTravelRuleDataForAnExistingDepositTransaction, SubmitDepositTravelRuleDataResponse as internalSubmitTravelRuleResp } from '../model/';
|
|
19
19
|
import { Pagination } from '../shared/pagination';
|
|
20
20
|
import { PaginatedResponseMethods, BasePaginatedRequest } from '../shared/paginatedResponse';
|
|
21
21
|
export type ListPortfolioTransactionsRequest = Pagination & {
|
|
@@ -63,4 +63,9 @@ export type CreateOnchainTransactionRequest = internalCreate & {
|
|
|
63
63
|
walletId: string;
|
|
64
64
|
};
|
|
65
65
|
export type CreateOnchainTransactionResponse = Brand<internalCreateResp, 'CreateOnchainTransactionResponse'>;
|
|
66
|
+
export type SubmitDepositTravelRuleRequest = RequestToSubmitTravelRuleDataForAnExistingDepositTransaction & {
|
|
67
|
+
portfolioId: string;
|
|
68
|
+
transactionId: string;
|
|
69
|
+
};
|
|
70
|
+
export type SubmitDepositTravelRuleResponse = Brand<internalSubmitTravelRuleResp, 'SubmitDepositTravelRuleResponse'>;
|
|
66
71
|
export {};
|
|
@@ -20,7 +20,7 @@ import { Pagination } from '../shared/pagination';
|
|
|
20
20
|
import { BasePaginatedRequest, PaginatedResponseMethods } from '../shared/paginatedResponse';
|
|
21
21
|
export type ListWalletsRequest = Pagination & {
|
|
22
22
|
portfolioId: string;
|
|
23
|
-
type
|
|
23
|
+
type?: WalletType;
|
|
24
24
|
symbols?: string[];
|
|
25
25
|
getNetworkUnifiedWallets?: boolean;
|
|
26
26
|
};
|
package/dist/users/index.js
CHANGED
|
@@ -21,6 +21,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.UsersService = void 0;
|
|
24
|
+
const validation_1 = require("../shared/validation");
|
|
24
25
|
const paginatedResponse_1 = require("../shared/paginatedResponse");
|
|
25
26
|
class UsersService {
|
|
26
27
|
constructor(client) {
|
|
@@ -28,6 +29,9 @@ class UsersService {
|
|
|
28
29
|
}
|
|
29
30
|
listUsers(request, options) {
|
|
30
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
(0, validation_1.validate)(request)
|
|
33
|
+
.requiredUUID((r) => r.entityId)
|
|
34
|
+
.check();
|
|
31
35
|
const paginationParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
32
36
|
const { limit, cursor, sortDirection, entityId } = request, queryParams = __rest(request, ["limit", "cursor", "sortDirection", "entityId"]);
|
|
33
37
|
const finalQueryParams = Object.assign(Object.assign({}, paginationParams), queryParams);
|
|
@@ -43,6 +47,9 @@ class UsersService {
|
|
|
43
47
|
}
|
|
44
48
|
listPortfolioUsers(request, options) {
|
|
45
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
(0, validation_1.validate)(request)
|
|
51
|
+
.requiredUUID((r) => r.portfolioId)
|
|
52
|
+
.check();
|
|
46
53
|
const paginationParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
47
54
|
const { limit, cursor, sortDirection, portfolioId } = request, queryParams = __rest(request, ["limit", "cursor", "sortDirection", "portfolioId"]);
|
|
48
55
|
const finalQueryParams = Object.assign(Object.assign({}, paginationParams), queryParams);
|
package/dist/wallets/index.js
CHANGED
|
@@ -37,6 +37,7 @@ exports.WalletsService = void 0;
|
|
|
37
37
|
* limitations under the License.
|
|
38
38
|
*/
|
|
39
39
|
const clients_1 = require("../clients");
|
|
40
|
+
const validation_1 = require("../shared/validation");
|
|
40
41
|
const paginatedResponse_1 = require("../shared/paginatedResponse");
|
|
41
42
|
class WalletsService {
|
|
42
43
|
constructor(client) {
|
|
@@ -44,6 +45,9 @@ class WalletsService {
|
|
|
44
45
|
}
|
|
45
46
|
listWallets(request, options) {
|
|
46
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
(0, validation_1.validate)(request)
|
|
49
|
+
.requiredUUID((r) => r.portfolioId)
|
|
50
|
+
.check();
|
|
47
51
|
const paginationParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
48
52
|
const { limit, cursor, portfolioId } = request, queryParams = __rest(request, ["limit", "cursor", "portfolioId"]);
|
|
49
53
|
const finalQueryParams = Object.assign(Object.assign({}, paginationParams), queryParams);
|
|
@@ -60,6 +64,10 @@ class WalletsService {
|
|
|
60
64
|
}
|
|
61
65
|
getWallet(request, options) {
|
|
62
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
(0, validation_1.validate)(request)
|
|
68
|
+
.requiredUUID((r) => r.portfolioId)
|
|
69
|
+
.requiredUUID((r) => r.walletId)
|
|
70
|
+
.check();
|
|
63
71
|
const response = yield this.client.request({
|
|
64
72
|
url: `portfolios/${request.portfolioId}/wallets/${request.walletId}`,
|
|
65
73
|
callOptions: options,
|
|
@@ -69,6 +77,11 @@ class WalletsService {
|
|
|
69
77
|
}
|
|
70
78
|
getWalletDepositInstructions(request, options) {
|
|
71
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
(0, validation_1.validate)(request)
|
|
81
|
+
.requiredUUID((r) => r.portfolioId)
|
|
82
|
+
.requiredUUID((r) => r.walletId)
|
|
83
|
+
.requiredString((r) => r.depositType)
|
|
84
|
+
.check();
|
|
72
85
|
let queryParams = {
|
|
73
86
|
depositType: request.depositType,
|
|
74
87
|
};
|
|
@@ -88,6 +101,10 @@ class WalletsService {
|
|
|
88
101
|
}
|
|
89
102
|
listWalletAddresses(request, options) {
|
|
90
103
|
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
+
(0, validation_1.validate)(request)
|
|
105
|
+
.requiredUUID((r) => r.portfolioId)
|
|
106
|
+
.requiredUUID((r) => r.walletId)
|
|
107
|
+
.check();
|
|
91
108
|
const paginationParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
92
109
|
const { limit, cursor, portfolioId, walletId } = request, queryParams = __rest(request, ["limit", "cursor", "portfolioId", "walletId"]);
|
|
93
110
|
const finalQueryParams = Object.assign(Object.assign({}, paginationParams), queryParams);
|
|
@@ -104,6 +121,11 @@ class WalletsService {
|
|
|
104
121
|
}
|
|
105
122
|
createWallet(request, options) {
|
|
106
123
|
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
(0, validation_1.validate)(request)
|
|
125
|
+
.requiredUUID((r) => r.portfolioId)
|
|
126
|
+
.requiredString((r) => r.name)
|
|
127
|
+
.requiredString((r) => r.symbol)
|
|
128
|
+
.check();
|
|
107
129
|
const bodyParams = Object.assign(Object.assign({}, request), { portfolioId: undefined });
|
|
108
130
|
const response = yield this.client.request({
|
|
109
131
|
url: `portfolios/${request.portfolioId}/wallets`,
|
|
@@ -116,6 +138,11 @@ class WalletsService {
|
|
|
116
138
|
}
|
|
117
139
|
createWalletDepositAddress(request, options) {
|
|
118
140
|
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
+
(0, validation_1.validate)(request)
|
|
142
|
+
.requiredUUID((r) => r.portfolioId)
|
|
143
|
+
.requiredUUID((r) => r.walletId)
|
|
144
|
+
.requiredString((r) => r.networkId)
|
|
145
|
+
.check();
|
|
119
146
|
const bodyParams = {
|
|
120
147
|
networkId: request.networkId,
|
|
121
148
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase-sample/prime-sdk-ts",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/types/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -35,7 +35,9 @@
|
|
|
35
35
|
"./package.json": "./package.json"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
|
-
"test": "
|
|
38
|
+
"test": "jest",
|
|
39
|
+
"test:watch": "jest --watch",
|
|
40
|
+
"test:coverage": "jest --coverage",
|
|
39
41
|
"build": "tsc",
|
|
40
42
|
"lint": "eslint . --ext .js,.ts",
|
|
41
43
|
"format": "prettier --write \"**/*.{js,ts,tsx,json,css,md}\"",
|
|
@@ -56,6 +58,7 @@
|
|
|
56
58
|
"license": "ISC",
|
|
57
59
|
"description": "",
|
|
58
60
|
"devDependencies": {
|
|
61
|
+
"@types/jest": "^29.5.12",
|
|
59
62
|
"@types/node": "^22.14.0",
|
|
60
63
|
"@typescript-eslint/eslint-plugin": "^8.49.0",
|
|
61
64
|
"@typescript-eslint/parser": "^8.49.0",
|
|
@@ -65,6 +68,7 @@
|
|
|
65
68
|
"eslint-plugin-prettier": "^5.5.4",
|
|
66
69
|
"js-yaml": "^4.1.1",
|
|
67
70
|
"prettier": "^3.7.4",
|
|
71
|
+
"ts-jest": "^29.1.2",
|
|
68
72
|
"typescript": "^5.9.3"
|
|
69
73
|
},
|
|
70
74
|
"dependencies": {
|