@coinbase-sample/prime-sdk-ts 0.7.1 → 0.8.1

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.
Files changed (114) hide show
  1. package/dist/activities/index.js +14 -0
  2. package/dist/addressBooks/index.js +10 -0
  3. package/dist/allocations/index.js +12 -0
  4. package/dist/assets/index.js +4 -0
  5. package/dist/balances/index.js +15 -0
  6. package/dist/commission/index.js +4 -0
  7. package/dist/constants.js +1 -1
  8. package/dist/financing/index.js +70 -0
  9. package/dist/futures/index.js +53 -0
  10. package/dist/index.js +7 -1
  11. package/dist/invoices/index.js +4 -0
  12. package/dist/model/DateOfBirth.js +21 -0
  13. package/dist/model/DetailedAddress.js +21 -0
  14. package/dist/model/GetFcmSettingsResponse.js +21 -0
  15. package/dist/model/GetUnstakingStatusResponse.js +21 -0
  16. package/dist/model/ListFinancingEligibleAssetsResponse.js +21 -0
  17. package/dist/model/ListTFObligationsResponse.js +21 -0
  18. package/dist/model/NaturalPersonName.js +21 -0
  19. package/dist/model/PreviewUnstakeRequest.js +21 -0
  20. package/dist/model/PreviewUnstakeResponse.js +21 -0
  21. package/dist/model/ProcessRequirements.js +21 -0
  22. package/dist/model/RewardMetadata.js +21 -0
  23. package/dist/model/SetFcmSettingsRequest.js +21 -0
  24. package/dist/model/SetFcmSettingsResponse.js +21 -0
  25. package/dist/model/TFAsset.js +21 -0
  26. package/dist/model/TFObligation.js +21 -0
  27. package/dist/model/TravelRuleEntry.js +21 -0
  28. package/dist/model/TravelRuleParty.js +21 -0
  29. package/dist/model/TravelRuleWalletDetails.js +21 -0
  30. package/dist/model/UnstakingStatus.js +21 -0
  31. package/dist/model/VASP.js +21 -0
  32. package/dist/model/ValidatorUnstakingInfo.js +21 -0
  33. package/dist/model/enums/CandlesGranularity.js +3 -3
  34. package/dist/model/enums/EstimateType.js +28 -0
  35. package/dist/model/enums/OrderType.js +2 -1
  36. package/dist/model/enums/PegOffsetType.js +31 -0
  37. package/dist/model/enums/RewardSubtype.js +34 -0
  38. package/dist/model/enums/TransactionType.js +3 -1
  39. package/dist/model/enums/TravelRuleStatus.js +28 -0
  40. package/dist/model/enums/TravelRuleWalletType.js +31 -0
  41. package/dist/model/enums/UnstakeType.js +28 -0
  42. package/dist/model/enums/UserRole.js +2 -1
  43. package/dist/model/enums/XMCallType.js +2 -1
  44. package/dist/model/enums/XMEntityCallStatus.js +2 -1
  45. package/dist/model/enums/index.js +14 -2
  46. package/dist/onchainAddressBook/index.js +14 -0
  47. package/dist/orders/index.js +59 -0
  48. package/dist/paymentMethods/index.js +8 -0
  49. package/dist/portfolios/index.js +10 -0
  50. package/dist/positions/index.js +7 -0
  51. package/dist/products/index.js +11 -0
  52. package/dist/shared/__tests__/validation.test.js +270 -0
  53. package/dist/shared/validation.js +210 -0
  54. package/dist/staking/index.js +63 -0
  55. package/dist/transactions/index.js +42 -0
  56. package/dist/types/activities/types.d.ts +1 -0
  57. package/dist/types/constants.d.ts +1 -1
  58. package/dist/types/financing/index.d.ts +5 -1
  59. package/dist/types/financing/types.d.ts +7 -1
  60. package/dist/types/futures/index.d.ts +6 -2
  61. package/dist/types/futures/types.d.ts +10 -1
  62. package/dist/types/index.d.ts +3 -0
  63. package/dist/types/model/CreateOrderRequest.d.ts +8 -1
  64. package/dist/types/model/CreatePortfolioAddressBookEntryRequest.d.ts +6 -0
  65. package/dist/types/model/DateOfBirth.d.ts +24 -0
  66. package/dist/types/model/DetailedAddress.d.ts +28 -0
  67. package/dist/types/model/GetFcmSettingsResponse.d.ts +25 -0
  68. package/dist/types/model/GetUnstakingStatusResponse.d.ts +42 -0
  69. package/dist/types/model/ListFinancingEligibleAssetsResponse.d.ts +26 -0
  70. package/dist/types/model/ListTFObligationsResponse.d.ts +26 -0
  71. package/dist/types/model/NaturalPersonName.d.ts +24 -0
  72. package/dist/types/model/NetworkDetails.d.ts +4 -0
  73. package/dist/types/model/Order.d.ts +12 -0
  74. package/dist/types/model/OrderPreviewRequest.d.ts +7 -0
  75. package/dist/types/model/PreviewUnstakeRequest.d.ts +28 -0
  76. package/dist/types/model/PreviewUnstakeResponse.d.ts +28 -0
  77. package/dist/types/model/ProcessRequirements.d.ts +23 -0
  78. package/dist/types/model/RewardMetadata.d.ts +23 -0
  79. package/dist/types/model/SetFcmSettingsRequest.d.ts +25 -0
  80. package/dist/types/model/SetFcmSettingsResponse.d.ts +25 -0
  81. package/dist/types/model/TFAsset.d.ts +33 -0
  82. package/dist/types/model/TFObligation.d.ts +41 -0
  83. package/dist/types/model/Transaction.d.ts +2 -0
  84. package/dist/types/model/TransactionMetadata.d.ts +2 -0
  85. package/dist/types/model/TravelRuleEntry.d.ts +38 -0
  86. package/dist/types/model/TravelRuleParty.d.ts +32 -0
  87. package/dist/types/model/TravelRuleWalletDetails.d.ts +28 -0
  88. package/dist/types/model/UnstakingStatus.d.ts +45 -0
  89. package/dist/types/model/VASP.d.ts +27 -0
  90. package/dist/types/model/ValidatorUnstakingInfo.d.ts +30 -0
  91. package/dist/types/model/enums/CandlesGranularity.d.ts +3 -3
  92. package/dist/types/model/enums/EstimateType.d.ts +24 -0
  93. package/dist/types/model/enums/OrderType.d.ts +3 -2
  94. package/dist/types/model/enums/PegOffsetType.d.ts +27 -0
  95. package/dist/types/model/enums/RewardSubtype.d.ts +30 -0
  96. package/dist/types/model/enums/TransactionType.d.ts +4 -2
  97. package/dist/types/model/enums/TravelRuleStatus.d.ts +24 -0
  98. package/dist/types/model/enums/TravelRuleWalletType.d.ts +27 -0
  99. package/dist/types/model/enums/UnstakeType.d.ts +24 -0
  100. package/dist/types/model/enums/UserRole.d.ts +3 -2
  101. package/dist/types/model/enums/XMCallType.d.ts +3 -2
  102. package/dist/types/model/enums/XMEntityCallStatus.d.ts +3 -2
  103. package/dist/types/model/enums/index.d.ts +6 -0
  104. package/dist/types/model/index.d.ts +21 -0
  105. package/dist/types/orders/types.d.ts +1 -1
  106. package/dist/types/shared/__tests__/validation.test.d.ts +1 -0
  107. package/dist/types/shared/validation.d.ts +88 -0
  108. package/dist/types/staking/index.d.ts +5 -1
  109. package/dist/types/staking/types.d.ts +12 -1
  110. package/dist/types/transactions/types.d.ts +3 -1
  111. package/dist/types/wallets/types.d.ts +2 -1
  112. package/dist/users/index.js +7 -0
  113. package/dist/wallets/index.js +27 -0
  114. package/package.json +13 -9
@@ -12,6 +12,7 @@ export { AssetChangeType } from './AssetChangeType';
12
12
  export { Benchmark } from './Benchmark';
13
13
  export { CandlesGranularity } from './CandlesGranularity';
14
14
  export { DestinationType } from './DestinationType';
15
+ export { EstimateType } from './EstimateType';
15
16
  export { FcmFuturesSweepStatus } from './FcmFuturesSweepStatus';
16
17
  export { FcmMarginCallState } from './FcmMarginCallState';
17
18
  export { FcmMarginCallType } from './FcmMarginCallType';
@@ -27,16 +28,21 @@ export { OrderSide } from './OrderSide';
27
28
  export { OrderStatus } from './OrderStatus';
28
29
  export { OrderType } from './OrderType';
29
30
  export { PaymentMethodType } from './PaymentMethodType';
31
+ export { PegOffsetType } from './PegOffsetType';
30
32
  export { PortfolioBalanceType } from './PortfolioBalanceType';
31
33
  export { PositionReferenceType } from './PositionReferenceType';
32
34
  export { ProductPermissions } from './ProductPermissions';
33
35
  export { RateType } from './RateType';
36
+ export { RewardSubtype } from './RewardSubtype';
34
37
  export { SigningStatus } from './SigningStatus';
35
38
  export { SortDirection } from './SortDirection';
36
39
  export { TimeInForceType } from './TimeInForceType';
37
40
  export { TransactionStatus } from './TransactionStatus';
38
41
  export { TransactionType } from './TransactionType';
39
42
  export { TransferLocationType } from './TransferLocationType';
43
+ export { TravelRuleStatus } from './TravelRuleStatus';
44
+ export { TravelRuleWalletType } from './TravelRuleWalletType';
45
+ export { UnstakeType } from './UnstakeType';
40
46
  export { UserRole } from './UserRole';
41
47
  export { ValidatorStatus } from './ValidatorStatus';
42
48
  export { VisibilityStatus } from './VisibilityStatus';
@@ -43,8 +43,10 @@ export type { CreateWalletResponse } from './CreateWalletResponse';
43
43
  export type { CreateWalletTransferResponse } from './CreateWalletTransferResponse';
44
44
  export type { CreateWalletWithdrawalResponse } from './CreateWalletWithdrawalResponse';
45
45
  export type { CrossMarginOverview } from './CrossMarginOverview';
46
+ export type { DateOfBirth } from './DateOfBirth';
46
47
  export type { DefiBalance } from './DefiBalance';
47
48
  export type { DestinationAlloc } from './DestinationAlloc';
49
+ export type { DetailedAddress } from './DetailedAddress';
48
50
  export type { EditOrderResponse } from './EditOrderResponse';
49
51
  export type { EntityBalance } from './EntityBalance';
50
52
  export type { EntityUser } from './EntityUser';
@@ -70,6 +72,7 @@ export type { GetExistingLocatesResponse } from './GetExistingLocatesResponse';
70
72
  export type { GetFcmBalanceResponse } from './GetFcmBalanceResponse';
71
73
  export type { GetFcmMarginCallDetailsResponse } from './GetFcmMarginCallDetailsResponse';
72
74
  export type { GetFcmRiskLimitsResponse } from './GetFcmRiskLimitsResponse';
75
+ export type { GetFcmSettingsResponse } from './GetFcmSettingsResponse';
73
76
  export type { GetFuturesSweepsResponse } from './GetFuturesSweepsResponse';
74
77
  export type { GetInterestAccrualsResponse } from './GetInterestAccrualsResponse';
75
78
  export type { GetInvoicesResponse } from './GetInvoicesResponse';
@@ -100,6 +103,7 @@ export type { GetPositionsResponse } from './GetPositionsResponse';
100
103
  export type { GetPostTradeCreditResponse } from './GetPostTradeCreditResponse';
101
104
  export type { GetTFTieredPricingFeesResponse } from './GetTFTieredPricingFeesResponse';
102
105
  export type { GetTransactionResponse } from './GetTransactionResponse';
106
+ export type { GetUnstakingStatusResponse } from './GetUnstakingStatusResponse';
103
107
  export type { GetWalletBalanceResponse } from './GetWalletBalanceResponse';
104
108
  export type { GetWalletDepositInstructionsResponse } from './GetWalletDepositInstructionsResponse';
105
109
  export type { GetWalletResponse } from './GetWalletResponse';
@@ -111,7 +115,9 @@ export type { InvoiceItem } from './InvoiceItem';
111
115
  export type { ListAggregateEntityPositionsResponse } from './ListAggregateEntityPositionsResponse';
112
116
  export type { ListEntityBalancesResponse } from './ListEntityBalancesResponse';
113
117
  export type { ListEntityPositionsResponse } from './ListEntityPositionsResponse';
118
+ export type { ListFinancingEligibleAssetsResponse } from './ListFinancingEligibleAssetsResponse';
114
119
  export type { ListOnchainAddressGroupsResponse } from './ListOnchainAddressGroupsResponse';
120
+ export type { ListTFObligationsResponse } from './ListTFObligationsResponse';
115
121
  export type { ListTransactionValidatorsResponse } from './ListTransactionValidatorsResponse';
116
122
  export type { ListWalletAddressesResponse } from './ListWalletAddressesResponse';
117
123
  export type { ListWeb3WalletBalancesResponse } from './ListWeb3WalletBalancesResponse';
@@ -126,6 +132,7 @@ export type { MarketRate } from './MarketRate';
126
132
  export type { MatchMetadata } from './MatchMetadata';
127
133
  export type { NFTCollection } from './NFTCollection';
128
134
  export type { NFTItem } from './NFTItem';
135
+ export type { NaturalPersonName } from './NaturalPersonName';
129
136
  export type { Network } from './Network';
130
137
  export type { NetworkDetails } from './NetworkDetails';
131
138
  export type { OnchainTransactionDetails } from './OnchainTransactionDetails';
@@ -145,23 +152,35 @@ export type { Position } from './Position';
145
152
  export type { PositionReference } from './PositionReference';
146
153
  export type { PostOrderPreviewResponse } from './PostOrderPreviewResponse';
147
154
  export type { PostTradeCreditInformation } from './PostTradeCreditInformation';
155
+ export type { PreviewUnstakeResponse } from './PreviewUnstakeResponse';
156
+ export type { ProcessRequirements } from './ProcessRequirements';
148
157
  export type { Product } from './Product';
149
158
  export type { QuoteResponse } from './QuoteResponse';
150
159
  export type { RFQProductDetails } from './RFQProductDetails';
160
+ export type { RewardMetadata } from './RewardMetadata';
151
161
  export type { RiskAssessment } from './RiskAssessment';
152
162
  export type { RpcConfig } from './RpcConfig';
153
163
  export type { ScheduleFuturesSweepResponse } from './ScheduleFuturesSweepResponse';
154
164
  export type { SetAutoSweepResponse } from './SetAutoSweepResponse';
165
+ export type { SetFcmSettingsResponse } from './SetFcmSettingsResponse';
155
166
  export type { ShortCollateral } from './ShortCollateral';
156
167
  export type { StakingClaimRewardsResponse } from './StakingClaimRewardsResponse';
157
168
  export type { StakingInitiateResponse } from './StakingInitiateResponse';
158
169
  export type { StakingUnstakeResponse } from './StakingUnstakeResponse';
170
+ export type { TFAsset } from './TFAsset';
171
+ export type { TFObligation } from './TFObligation';
159
172
  export type { TieredPricingFee } from './TieredPricingFee';
160
173
  export type { Transaction } from './Transaction';
161
174
  export type { TransactionMetadata } from './TransactionMetadata';
162
175
  export type { TransactionValidator } from './TransactionValidator';
163
176
  export type { TransferLocation } from './TransferLocation';
177
+ export type { TravelRuleEntry } from './TravelRuleEntry';
178
+ export type { TravelRuleParty } from './TravelRuleParty';
179
+ export type { TravelRuleWalletDetails } from './TravelRuleWalletDetails';
180
+ export type { UnstakingStatus } from './UnstakingStatus';
164
181
  export type { UserAction } from './UserAction';
182
+ export type { VASP } from './VASP';
183
+ export type { ValidatorUnstakingInfo } from './ValidatorUnstakingInfo';
165
184
  export type { Wallet } from './Wallet';
166
185
  export type { WalletClaimRewardsInputs } from './WalletClaimRewardsInputs';
167
186
  export type { WalletCryptoDepositInstructions } from './WalletCryptoDepositInstructions';
@@ -192,8 +211,10 @@ export type { ListTransactionValidatorsRequest } from './ListTransactionValidato
192
211
  export type { OrderPreviewRequest } from './OrderPreviewRequest';
193
212
  export type { PortfolioStakingInitiateRequest } from './PortfolioStakingInitiateRequest';
194
213
  export type { PortfolioStakingUnstakeRequest } from './PortfolioStakingUnstakeRequest';
214
+ export type { PreviewUnstakeRequest } from './PreviewUnstakeRequest';
195
215
  export type { ScheduleFuturesSweepRequest } from './ScheduleFuturesSweepRequest';
196
216
  export type { SetAutoSweepRequest } from './SetAutoSweepRequest';
217
+ export type { SetFcmSettingsRequest } from './SetFcmSettingsRequest';
197
218
  export type { StakingClaimRewardsRequest } from './StakingClaimRewardsRequest';
198
219
  export type { StakingInitiateRequest } from './StakingInitiateRequest';
199
220
  export type { StakingUnstakeRequest } from './StakingUnstakeRequest';
@@ -53,7 +53,7 @@ export type ListOpenOrdersRequest = Pagination & {
53
53
  orderType?: OrderType;
54
54
  orderSide?: OrderSide;
55
55
  startDate?: string;
56
- endDate: string;
56
+ endDate?: string;
57
57
  };
58
58
  export type BaseListOpenOrdersResponse = Brand<GetOpenOrdersResponse, 'ListOpenOrdersResponse'>;
59
59
  export type ListOpenOrdersResponse = BaseListOpenOrdersResponse & PaginatedResponseMethods<ListOpenOrdersRequest & BasePaginatedRequest, BaseListOpenOrdersResponse, any>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Represents a validation error for a specific parameter
3
+ */
4
+ export interface ValidationError {
5
+ paramName: string;
6
+ message: string;
7
+ value?: any;
8
+ }
9
+ /**
10
+ * Validates that a string is a valid UUID v4 format
11
+ */
12
+ export declare function isValidUUID(value: string): boolean;
13
+ /**
14
+ * Creates a validator with property accessor support for automatic field name inference.
15
+ *
16
+ * @param source - The source object containing the fields to validate
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * validate(request)
21
+ * .requiredUUID(r => r.portfolioId)
22
+ * .requiredUUID(r => r.orderId)
23
+ * .check();
24
+ * ```
25
+ */
26
+ export declare function validate<T extends Record<string, any>>(source: T): PropertyValidator<T>;
27
+ /**
28
+ * Validator with property accessor support for automatic field name inference.
29
+ * Uses Proxy to track property accesses and extract field names automatically.
30
+ */
31
+ export declare class PropertyValidator<T extends Record<string, any>> {
32
+ private errors;
33
+ private source;
34
+ constructor(source: T);
35
+ /**
36
+ * Validates that a required UUID field is present and valid.
37
+ * Automatically extracts the field name from the property accessor.
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * validate(request)
42
+ * .requiredUUID(r => r.portfolioId)
43
+ * .check();
44
+ * ```
45
+ */
46
+ requiredUUID(accessor: (source: T) => string | undefined | null): this;
47
+ /**
48
+ * Validates that an optional UUID field is valid if provided.
49
+ */
50
+ optionalUUID(accessor: (source: T) => string | undefined | null): this;
51
+ /**
52
+ * Validates that a required string field is present and not empty.
53
+ */
54
+ requiredString(accessor: (source: T) => string | undefined | null): this;
55
+ /**
56
+ * Validates that an optional string field is not empty if provided.
57
+ */
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;
67
+ /**
68
+ * Throws if there are validation errors.
69
+ */
70
+ check(contextMessage?: string): void;
71
+ /**
72
+ * Add a validation error
73
+ */
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[];
83
+ /**
84
+ * Extracts the property name and value from a property accessor function.
85
+ * Uses a Proxy to track which property was accessed.
86
+ */
87
+ private extractProperty;
88
+ }
@@ -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 } from './types';
17
+ import { CreateStakeRequest, CreateStakeResponse, CreateUnstakeRequest, CreateUnstakeResponse, CreatePortfolioStakeRequest, CreatePortfolioStakeResponse, CreatePortfolioUnstakeRequest, CreatePortfolioUnstakeResponse, QueryTransactionValidatorsRequest, QueryTransactionValidatorsResponse, ClaimRewardsRequest, ClaimRewardsResponse, PreviewUnstakeRequest, PreviewUnstakeResponse, GetUnstakingStatusRequest, GetUnstakingStatusResponse } 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>;
@@ -22,6 +22,8 @@ export interface IStakingService {
22
22
  createPortfolioUnstake(request: CreatePortfolioUnstakeRequest, options?: CoinbaseCallOptions): Promise<CreatePortfolioUnstakeResponse>;
23
23
  queryTransactionValidators(request: QueryTransactionValidatorsRequest, options?: CoinbaseCallOptions): Promise<QueryTransactionValidatorsResponse>;
24
24
  claimRewards(request: ClaimRewardsRequest, options?: CoinbaseCallOptions): Promise<ClaimRewardsResponse>;
25
+ previewUnstake(request: PreviewUnstakeRequest, options?: CoinbaseCallOptions): Promise<PreviewUnstakeResponse>;
26
+ getUnstakingStatus(request: GetUnstakingStatusRequest, options?: CoinbaseCallOptions): Promise<GetUnstakingStatusResponse>;
25
27
  }
26
28
  export declare class StakingService implements IStakingService {
27
29
  private client;
@@ -32,4 +34,6 @@ export declare class StakingService implements IStakingService {
32
34
  createPortfolioUnstake(request: CreatePortfolioUnstakeRequest, options?: CoinbaseCallOptions): Promise<CreatePortfolioUnstakeResponse>;
33
35
  queryTransactionValidators(request: QueryTransactionValidatorsRequest, options?: CoinbaseCallOptions): Promise<QueryTransactionValidatorsResponse>;
34
36
  claimRewards(request: ClaimRewardsRequest, options?: CoinbaseCallOptions): Promise<ClaimRewardsResponse>;
37
+ previewUnstake(request: PreviewUnstakeRequest, options?: CoinbaseCallOptions): Promise<PreviewUnstakeResponse>;
38
+ getUnstakingStatus(request: GetUnstakingStatusRequest, options?: CoinbaseCallOptions): Promise<GetUnstakingStatusResponse>;
35
39
  }
@@ -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 } 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 } from 'src/model/';
19
19
  export type CreateStakeRequest = StakingInitiateRequest & {
20
20
  portfolioId: string;
21
21
  walletId: string;
@@ -45,3 +45,14 @@ export type ClaimRewardsRequest = internalStakingClaimRewardsRequest & {
45
45
  walletId: string;
46
46
  };
47
47
  export type ClaimRewardsResponse = Brand<internalStakingClaimRewardsResponse, 'ClaimRewardsResponse'>;
48
+ export type PreviewUnstakeRequest = {
49
+ portfolioId: string;
50
+ walletId: string;
51
+ amount: string;
52
+ };
53
+ export type PreviewUnstakeResponse = Brand<internalPreviewUnstakeResponse, 'PreviewUnstakeResponse'>;
54
+ export type GetUnstakingStatusRequest = {
55
+ portfolioId: string;
56
+ walletId: string;
57
+ };
58
+ export type GetUnstakingStatusResponse = Brand<internalGetUnstakingStatusResponse, 'GetUnstakingStatusResponse'>;
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { Brand } from '../shared/brand';
17
- import { TransactionType } from '../model/enums/';
17
+ import { TransactionType, TravelRuleStatus } from '../model/enums/';
18
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/';
19
19
  import { Pagination } from '../shared/pagination';
20
20
  import { PaginatedResponseMethods, BasePaginatedRequest } from '../shared/paginatedResponse';
@@ -24,6 +24,8 @@ export type ListPortfolioTransactionsRequest = Pagination & {
24
24
  types?: TransactionType[];
25
25
  startTime?: string;
26
26
  endTime?: string;
27
+ getNetworkUnifiedTransactions?: boolean;
28
+ travelRuleStatus?: TravelRuleStatus[];
27
29
  };
28
30
  type BaseListPortfolioTransactionsResponse = Brand<GetPortfolioTransactionsResponse, 'ListPortfolioTransactionsResponse'>;
29
31
  export type ListPortfolioTransactionsResponse = BaseListPortfolioTransactionsResponse & PaginatedResponseMethods<ListPortfolioTransactionsRequest & BasePaginatedRequest, BaseListPortfolioTransactionsResponse, any>;
@@ -20,8 +20,9 @@ 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: WalletType;
23
+ type?: WalletType;
24
24
  symbols?: string[];
25
+ getNetworkUnifiedWallets?: boolean;
25
26
  };
26
27
  export type BaseListWalletsResponse = Brand<GetWalletsResponse, 'ListWalletsResponse'>;
27
28
  export type ListWalletsResponse = BaseListWalletsResponse & PaginatedResponseMethods<ListWalletsRequest & BasePaginatedRequest, BaseListWalletsResponse, any>;
@@ -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);
@@ -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.7.1",
3
+ "version": "0.8.1",
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": "echo \"Error: no test specified\" && exit 1",
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,16 +58,18 @@
56
58
  "license": "ISC",
57
59
  "description": "",
58
60
  "devDependencies": {
61
+ "@types/jest": "^29.5.12",
59
62
  "@types/node": "^22.14.0",
60
- "@typescript-eslint/eslint-plugin": "^8.39.1",
61
- "@typescript-eslint/parser": "^8.39.1",
62
- "dotenv": "^17.2.1",
63
- "eslint": "^9.33.0",
63
+ "@typescript-eslint/eslint-plugin": "^8.49.0",
64
+ "@typescript-eslint/parser": "^8.49.0",
65
+ "dotenv": "^17.2.3",
66
+ "eslint": "^9.39.1",
64
67
  "eslint-config-prettier": "^10.1.8",
65
68
  "eslint-plugin-prettier": "^5.5.4",
66
- "js-yaml": "^4.1.0",
67
- "prettier": "^3.6.2",
68
- "typescript": "^5.9.2"
69
+ "js-yaml": "^4.1.1",
70
+ "prettier": "^3.7.4",
71
+ "ts-jest": "^29.1.2",
72
+ "typescript": "^5.9.3"
69
73
  },
70
74
  "dependencies": {
71
75
  "@coinbase-sample/core-ts": "^0.2.1"