@coinbase-sample/prime-sdk-ts 0.7.1 → 0.8.0
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/financing/index.js +18 -0
- package/dist/futures/index.js +20 -0
- package/dist/model/DateOfBirth.js +21 -0
- package/dist/model/DetailedAddress.js +21 -0
- package/dist/model/GetFcmSettingsResponse.js +21 -0
- package/dist/model/GetUnstakingStatusResponse.js +21 -0
- package/dist/model/ListFinancingEligibleAssetsResponse.js +21 -0
- package/dist/model/ListTFObligationsResponse.js +21 -0
- package/dist/model/NaturalPersonName.js +21 -0
- package/dist/model/PreviewUnstakeRequest.js +21 -0
- package/dist/model/PreviewUnstakeResponse.js +21 -0
- package/dist/model/ProcessRequirements.js +21 -0
- package/dist/model/RewardMetadata.js +21 -0
- package/dist/model/SetFcmSettingsRequest.js +21 -0
- package/dist/model/SetFcmSettingsResponse.js +21 -0
- package/dist/model/TFAsset.js +21 -0
- package/dist/model/TFObligation.js +21 -0
- package/dist/model/TravelRuleEntry.js +21 -0
- package/dist/model/TravelRuleParty.js +21 -0
- package/dist/model/TravelRuleWalletDetails.js +21 -0
- package/dist/model/UnstakingStatus.js +21 -0
- package/dist/model/VASP.js +21 -0
- package/dist/model/ValidatorUnstakingInfo.js +21 -0
- package/dist/model/enums/CandlesGranularity.js +3 -3
- package/dist/model/enums/EstimateType.js +28 -0
- package/dist/model/enums/OrderType.js +2 -1
- package/dist/model/enums/PegOffsetType.js +31 -0
- package/dist/model/enums/RewardSubtype.js +34 -0
- package/dist/model/enums/TransactionType.js +3 -1
- package/dist/model/enums/TravelRuleStatus.js +28 -0
- package/dist/model/enums/TravelRuleWalletType.js +31 -0
- package/dist/model/enums/UnstakeType.js +28 -0
- package/dist/model/enums/UserRole.js +2 -1
- package/dist/model/enums/XMCallType.js +2 -1
- package/dist/model/enums/XMEntityCallStatus.js +2 -1
- package/dist/model/enums/index.js +14 -2
- package/dist/shared/__tests__/validation.test.js +210 -0
- package/dist/shared/validation.js +380 -0
- package/dist/staking/index.js +22 -0
- package/dist/types/activities/types.d.ts +1 -0
- package/dist/types/financing/index.d.ts +5 -1
- package/dist/types/financing/types.d.ts +7 -1
- package/dist/types/futures/index.d.ts +6 -2
- package/dist/types/futures/types.d.ts +10 -1
- package/dist/types/model/CreateOrderRequest.d.ts +8 -1
- package/dist/types/model/CreatePortfolioAddressBookEntryRequest.d.ts +6 -0
- package/dist/types/model/DateOfBirth.d.ts +24 -0
- package/dist/types/model/DetailedAddress.d.ts +28 -0
- package/dist/types/model/GetFcmSettingsResponse.d.ts +25 -0
- package/dist/types/model/GetUnstakingStatusResponse.d.ts +42 -0
- package/dist/types/model/ListFinancingEligibleAssetsResponse.d.ts +26 -0
- package/dist/types/model/ListTFObligationsResponse.d.ts +26 -0
- package/dist/types/model/NaturalPersonName.d.ts +24 -0
- package/dist/types/model/NetworkDetails.d.ts +4 -0
- package/dist/types/model/Order.d.ts +12 -0
- package/dist/types/model/OrderPreviewRequest.d.ts +7 -0
- package/dist/types/model/PreviewUnstakeRequest.d.ts +28 -0
- package/dist/types/model/PreviewUnstakeResponse.d.ts +28 -0
- package/dist/types/model/ProcessRequirements.d.ts +23 -0
- package/dist/types/model/RewardMetadata.d.ts +23 -0
- package/dist/types/model/SetFcmSettingsRequest.d.ts +25 -0
- package/dist/types/model/SetFcmSettingsResponse.d.ts +25 -0
- package/dist/types/model/TFAsset.d.ts +33 -0
- package/dist/types/model/TFObligation.d.ts +41 -0
- package/dist/types/model/Transaction.d.ts +2 -0
- package/dist/types/model/TransactionMetadata.d.ts +2 -0
- package/dist/types/model/TravelRuleEntry.d.ts +38 -0
- package/dist/types/model/TravelRuleParty.d.ts +32 -0
- package/dist/types/model/TravelRuleWalletDetails.d.ts +28 -0
- package/dist/types/model/UnstakingStatus.d.ts +45 -0
- package/dist/types/model/VASP.d.ts +27 -0
- package/dist/types/model/ValidatorUnstakingInfo.d.ts +30 -0
- package/dist/types/model/enums/CandlesGranularity.d.ts +3 -3
- package/dist/types/model/enums/EstimateType.d.ts +24 -0
- package/dist/types/model/enums/OrderType.d.ts +3 -2
- package/dist/types/model/enums/PegOffsetType.d.ts +27 -0
- package/dist/types/model/enums/RewardSubtype.d.ts +30 -0
- package/dist/types/model/enums/TransactionType.d.ts +4 -2
- package/dist/types/model/enums/TravelRuleStatus.d.ts +24 -0
- package/dist/types/model/enums/TravelRuleWalletType.d.ts +27 -0
- package/dist/types/model/enums/UnstakeType.d.ts +24 -0
- package/dist/types/model/enums/UserRole.d.ts +3 -2
- package/dist/types/model/enums/XMCallType.d.ts +3 -2
- package/dist/types/model/enums/XMEntityCallStatus.d.ts +3 -2
- package/dist/types/model/enums/index.d.ts +6 -0
- package/dist/types/model/index.d.ts +21 -0
- package/dist/types/shared/__tests__/validation.test.d.ts +1 -0
- package/dist/types/shared/validation.d.ts +176 -0
- package/dist/types/staking/index.d.ts +5 -1
- package/dist/types/staking/types.d.ts +12 -1
- package/dist/types/transactions/types.d.ts +3 -1
- package/dist/types/wallets/types.d.ts +1 -0
- package/package.json +8 -8
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.TransactionType = void 0;
|
|
23
23
|
/**
|
|
24
|
-
* - TRANSACTION_TYPE_UNKNOWN: An unknown transaction type - DEPOSIT: A fiat or crypto deposit - WITHDRAWAL: A fiat or crypto withdrawal - INTERNAL_DEPOSIT: An internal fiat or crypto deposit - INTERNAL_WITHDRAWAL: An internal fiat or crypto withdrawal - SWEEP_DEPOSIT: Internal automated deposit to a cold address from a restored address - SWEEP_WITHDRAWAL: Internal automated withdrawal from a restored address to a cold address - PROXY_DEPOSIT: On-chain deposit of funds into proxy contract from cold address - PROXY_WITHDRAWAL: On-chain withdrawal of funds from proxy contract to cold address - BILLING_WITHDRAWAL: Coinbase Prime automated invoice settlement payment - REWARD: Reward payment to an associated address for a staked asset - COINBASE_REFUND: Coinbase Prime refund for the leftover amount for a CPFP (child pays for parent) transaction - TRANSACTION_TYPE_OTHER: An OTHER type of transaction - WITHDRAWAL_ADJUSTMENT: A manual adjustment withdrawal transaction - DEPOSIT_ADJUSTMENT: A manual adjustment deposit transaction - KEY_REGISTRATION: An on-chain registration for an address - DELEGATION: An on-chain delegation transaction - UNDELEGATION: An on-chain undelegation transaction - RESTAKE: On-chain restaking transaction - COMPLETE_UNBONDING: On-chain unbonding event transaction - WITHDRAW_UNBONDED: On-chain event indicating unbonding period is over - STAKE_ACCOUNT_CREATE: On-chain transaction to begin staking from an address - CHANGE_VALIDATOR: On-chain transaction alter validator - STAKE: On-chain transaction to begin staking in Cryptocurrency network - UNSTAKE: On-chain transaction to stop staking in Cryptocurrency network - REMOVE_AUTHORIZED_PARTY: On-chain transaction to remove a party from a multi-signature wallet - STAKE_AUTHORIZE_WITH_SEED: On-chain transaction to begin staking from a seed account - SLASH: On-chain transaction indicating a slash event has occurred - COINBASE_DEPOSIT: On-chain transaction deposit for the purpose of transaction operations - CONVERSION: Internal conversion between two assets - CLAIM_REWARDS: On-chain transaction to claim rewards from Vote Account - VOTE_AUTHORIZE: On-chain transaction to transfer the reward claiming permission to other pubkey - WEB3_TRANSACTION: On-chain transaction initiated with Prime Onchain Wallet Deprecated: Use ONCHAIN_TRANSACTION instead - ONCHAIN_TRANSACTION: On-chain transaction initiated with Prime Onchain Wallet
|
|
24
|
+
* - TRANSACTION_TYPE_UNKNOWN: An unknown transaction type - DEPOSIT: A fiat or crypto deposit - WITHDRAWAL: A fiat or crypto withdrawal - INTERNAL_DEPOSIT: An internal fiat or crypto deposit - INTERNAL_WITHDRAWAL: An internal fiat or crypto withdrawal - SWEEP_DEPOSIT: Internal automated deposit to a cold address from a restored address - SWEEP_WITHDRAWAL: Internal automated withdrawal from a restored address to a cold address - PROXY_DEPOSIT: On-chain deposit of funds into proxy contract from cold address - PROXY_WITHDRAWAL: On-chain withdrawal of funds from proxy contract to cold address - BILLING_WITHDRAWAL: Coinbase Prime automated invoice settlement payment - REWARD: Reward payment to an associated address for a staked asset - COINBASE_REFUND: Coinbase Prime refund for the leftover amount for a CPFP (child pays for parent) transaction - TRANSACTION_TYPE_OTHER: An OTHER type of transaction - WITHDRAWAL_ADJUSTMENT: A manual adjustment withdrawal transaction - DEPOSIT_ADJUSTMENT: A manual adjustment deposit transaction - KEY_REGISTRATION: An on-chain registration for an address - DELEGATION: An on-chain delegation transaction - UNDELEGATION: An on-chain undelegation transaction - RESTAKE: On-chain restaking transaction - COMPLETE_UNBONDING: On-chain unbonding event transaction - WITHDRAW_UNBONDED: On-chain event indicating unbonding period is over - STAKE_ACCOUNT_CREATE: On-chain transaction to begin staking from an address - CHANGE_VALIDATOR: On-chain transaction alter validator - STAKE: On-chain transaction to begin staking in Cryptocurrency network - UNSTAKE: On-chain transaction to stop staking in Cryptocurrency network - REMOVE_AUTHORIZED_PARTY: On-chain transaction to remove a party from a multi-signature wallet - STAKE_AUTHORIZE_WITH_SEED: On-chain transaction to begin staking from a seed account - SLASH: On-chain transaction indicating a slash event has occurred - COINBASE_DEPOSIT: On-chain transaction deposit for the purpose of transaction operations - CONVERSION: Internal conversion between two assets - CLAIM_REWARDS: On-chain transaction to claim rewards from Vote Account - VOTE_AUTHORIZE: On-chain transaction to transfer the reward claiming permission to other pubkey - WEB3_TRANSACTION: On-chain transaction initiated with Prime Onchain Wallet Deprecated: Use ONCHAIN_TRANSACTION instead - ONCHAIN_TRANSACTION: On-chain transaction initiated with Prime Onchain Wallet - PORTFOLIO_STAKE: Portfolio-level staking operation - PORTFOLIO_UNSTAKE: Portfolio-level unstaking operation
|
|
25
25
|
*/
|
|
26
26
|
var TransactionType;
|
|
27
27
|
(function (TransactionType) {
|
|
@@ -58,4 +58,6 @@ var TransactionType;
|
|
|
58
58
|
TransactionType["VoteAuthorize"] = "VOTE_AUTHORIZE";
|
|
59
59
|
TransactionType["Web3Transaction"] = "WEB3_TRANSACTION";
|
|
60
60
|
TransactionType["OnchainTransaction"] = "ONCHAIN_TRANSACTION";
|
|
61
|
+
TransactionType["PortfolioStake"] = "PORTFOLIO_STAKE";
|
|
62
|
+
TransactionType["PortfolioUnstake"] = "PORTFOLIO_UNSTAKE";
|
|
61
63
|
})(TransactionType || (exports.TransactionType = TransactionType = {}));
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2025-present Coinbase Global, Inc.
|
|
4
|
+
*
|
|
5
|
+
* This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*
|
|
19
|
+
* Do not edit the class manually.
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.TravelRuleStatus = void 0;
|
|
23
|
+
var TravelRuleStatus;
|
|
24
|
+
(function (TravelRuleStatus) {
|
|
25
|
+
TravelRuleStatus["TravelRuleStatusUnspecified"] = "TRAVEL_RULE_STATUS_UNSPECIFIED";
|
|
26
|
+
TravelRuleStatus["TravelRuleStatusPending"] = "TRAVEL_RULE_STATUS_PENDING";
|
|
27
|
+
TravelRuleStatus["TravelRuleStatusSubmitted"] = "TRAVEL_RULE_STATUS_SUBMITTED";
|
|
28
|
+
})(TravelRuleStatus || (exports.TravelRuleStatus = TravelRuleStatus = {}));
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2025-present Coinbase Global, Inc.
|
|
4
|
+
*
|
|
5
|
+
* This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*
|
|
19
|
+
* Do not edit the class manually.
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.TravelRuleWalletType = void 0;
|
|
23
|
+
/**
|
|
24
|
+
* - TRAVEL_RULE_WALLET_TYPE_UNSPECIFIED: Default unspecified wallet type - TRAVEL_RULE_WALLET_TYPE_VASP: Centralized exchange wallet - TRAVEL_RULE_WALLET_TYPE_SELF_CUSTODIED: Self-hosted/custodial wallet
|
|
25
|
+
*/
|
|
26
|
+
var TravelRuleWalletType;
|
|
27
|
+
(function (TravelRuleWalletType) {
|
|
28
|
+
TravelRuleWalletType["TravelRuleWalletTypeUnspecified"] = "TRAVEL_RULE_WALLET_TYPE_UNSPECIFIED";
|
|
29
|
+
TravelRuleWalletType["TravelRuleWalletTypeVasp"] = "TRAVEL_RULE_WALLET_TYPE_VASP";
|
|
30
|
+
TravelRuleWalletType["TravelRuleWalletTypeSelfCustodied"] = "TRAVEL_RULE_WALLET_TYPE_SELF_CUSTODIED";
|
|
31
|
+
})(TravelRuleWalletType || (exports.TravelRuleWalletType = TravelRuleWalletType = {}));
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2025-present Coinbase Global, Inc.
|
|
4
|
+
*
|
|
5
|
+
* This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*
|
|
19
|
+
* Do not edit the class manually.
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.UnstakeType = void 0;
|
|
23
|
+
var UnstakeType;
|
|
24
|
+
(function (UnstakeType) {
|
|
25
|
+
UnstakeType["UnstakeTypeUnspecified"] = "UNSTAKE_TYPE_UNSPECIFIED";
|
|
26
|
+
UnstakeType["UnstakeTypePartial"] = "UNSTAKE_TYPE_PARTIAL";
|
|
27
|
+
UnstakeType["UnstakeTypeFull"] = "UNSTAKE_TYPE_FULL";
|
|
28
|
+
})(UnstakeType || (exports.UnstakeType = UnstakeType = {}));
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.UserRole = void 0;
|
|
23
23
|
/**
|
|
24
|
-
* - USER_ROLE_UNKNOWN: nil value - AUDITOR: An auditor - SIGNATORY: A signatory - ADMIN: An admin - INITIATOR: An initiator - REVIEWER: A reviewer - TRADER: A trader - FULL_TRADER: A trader with full permissions - TEAM_MANAGER: A team manager - APPROVER: An approver
|
|
24
|
+
* - USER_ROLE_UNKNOWN: nil value - AUDITOR: An auditor - SIGNATORY: A signatory - ADMIN: An admin - INITIATOR: An initiator - REVIEWER: A reviewer - TRADER: A trader - FULL_TRADER: A trader with full permissions - TEAM_MANAGER: A team manager - APPROVER: An approver - TAX_MANAGER: A tax manager
|
|
25
25
|
*/
|
|
26
26
|
var UserRole;
|
|
27
27
|
(function (UserRole) {
|
|
@@ -34,4 +34,5 @@ var UserRole;
|
|
|
34
34
|
UserRole["FullTrader"] = "FULL_TRADER";
|
|
35
35
|
UserRole["TeamManager"] = "TEAM_MANAGER";
|
|
36
36
|
UserRole["Approver"] = "APPROVER";
|
|
37
|
+
UserRole["TaxManager"] = "TAX_MANAGER";
|
|
37
38
|
})(UserRole || (exports.UserRole = UserRole = {}));
|
|
@@ -21,11 +21,12 @@
|
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.XMCallType = void 0;
|
|
23
23
|
/**
|
|
24
|
-
* - CALL_TYPE_STANDARD: Evaluated at standard margin call evaluation time - CALL_TYPE_URGENT: Evaluated in realtime
|
|
24
|
+
* - CALL_TYPE_STANDARD: Evaluated at standard margin call evaluation time - CALL_TYPE_URGENT: Evaluated in realtime - CALL_TYPE_DEBIT: Evaluated at debit call evaluation time
|
|
25
25
|
*/
|
|
26
26
|
var XMCallType;
|
|
27
27
|
(function (XMCallType) {
|
|
28
28
|
XMCallType["XmCallTypeUnspecified"] = "XM_CALL_TYPE_UNSPECIFIED";
|
|
29
29
|
XMCallType["CallTypeStandard"] = "CALL_TYPE_STANDARD";
|
|
30
30
|
XMCallType["CallTypeUrgent"] = "CALL_TYPE_URGENT";
|
|
31
|
+
XMCallType["CallTypeDebit"] = "CALL_TYPE_DEBIT";
|
|
31
32
|
})(XMCallType || (exports.XMCallType = XMCallType = {}));
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.XMEntityCallStatus = void 0;
|
|
23
23
|
/**
|
|
24
|
-
* - ENTITY_NO_CALL: There are no margin calls - ENTITY_OPEN_STANDARD_CALL: There is a standard margin call. There
|
|
24
|
+
* XMEntityCallStatus summarizes the state of open margin calls or debit calls. When multiple calls exist, the status reflects the highest priority call type. Priority order (highest to lowest): aged > urgent > standard > debit. - ENTITY_NO_CALL: There are no margin calls or debit calls. - ENTITY_OPEN_STANDARD_CALL: There is a standard margin call. There may also be debit calls, but there are no urgent margin calls or expired calls.. - ENTITY_OPEN_URGENT_CALL: There is an urgent margin call. There may also be standard margin calls or debit calls, but there are no expired calls. - ENTITY_AGED_CALL: At least one open margin call (standard or urgent) or debit call is aged. This will trigger the SESSION_LOCKED control status. - ENTITY_OPEN_DEBIT_CALL: There is a debit call. There are no standard margin calls, urgent margin calls, or expired calls.
|
|
25
25
|
*/
|
|
26
26
|
var XMEntityCallStatus;
|
|
27
27
|
(function (XMEntityCallStatus) {
|
|
@@ -30,4 +30,5 @@ var XMEntityCallStatus;
|
|
|
30
30
|
XMEntityCallStatus["EntityOpenStandardCall"] = "ENTITY_OPEN_STANDARD_CALL";
|
|
31
31
|
XMEntityCallStatus["EntityOpenUrgentCall"] = "ENTITY_OPEN_URGENT_CALL";
|
|
32
32
|
XMEntityCallStatus["EntityAgedCall"] = "ENTITY_AGED_CALL";
|
|
33
|
+
XMEntityCallStatus["EntityOpenDebitCall"] = "ENTITY_OPEN_DEBIT_CALL";
|
|
33
34
|
})(XMEntityCallStatus || (exports.XMEntityCallStatus = XMEntityCallStatus = {}));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.XMParty = void 0;
|
|
3
|
+
exports.WalletType = exports.WalletDepositInstructionType = exports.VisibilityStatus = exports.ValidatorStatus = exports.UserRole = exports.UnstakeType = exports.TravelRuleWalletType = exports.TravelRuleStatus = exports.TransferLocationType = exports.TransactionType = exports.TransactionStatus = exports.TimeInForceType = exports.SortDirection = exports.SigningStatus = exports.RewardSubtype = exports.RateType = exports.ProductPermissions = exports.PositionReferenceType = exports.PortfolioBalanceType = exports.PegOffsetType = exports.PaymentMethodType = exports.OrderType = exports.OrderStatus = exports.OrderSide = exports.NetworkType = exports.NetworkFamily = exports.MarginAddOnType = exports.LoanType = exports.InvoiceType = exports.InvoiceState = exports.HierarchyType = exports.FcmPositionSide = exports.FcmMarginCallType = exports.FcmMarginCallState = exports.FcmFuturesSweepStatus = exports.EstimateType = exports.DestinationType = exports.CandlesGranularity = exports.Benchmark = exports.AssetChangeType = exports.AllocationStatus = exports.AllocationSizeType = exports.PrimeActivityType = exports.ActivityStatus = exports.ActivitySecondaryType = exports.ActivityLevel = exports.ActivityCategory = exports.Action = exports.AddressBookType = exports.CustodyActivityType = void 0;
|
|
4
|
+
exports.XMParty = exports.XMMarginLevel = exports.XMEntityCallStatus = exports.XMControlStatus = exports.XMCallType = exports.XMCallStatus = exports.WalletVisibility = void 0;
|
|
5
5
|
var CustodyActivityType_1 = require("./CustodyActivityType");
|
|
6
6
|
Object.defineProperty(exports, "CustodyActivityType", { enumerable: true, get: function () { return CustodyActivityType_1.ActivityType; } });
|
|
7
7
|
var AddressBookType_1 = require("./AddressBookType");
|
|
@@ -30,6 +30,8 @@ var CandlesGranularity_1 = require("./CandlesGranularity");
|
|
|
30
30
|
Object.defineProperty(exports, "CandlesGranularity", { enumerable: true, get: function () { return CandlesGranularity_1.CandlesGranularity; } });
|
|
31
31
|
var DestinationType_1 = require("./DestinationType");
|
|
32
32
|
Object.defineProperty(exports, "DestinationType", { enumerable: true, get: function () { return DestinationType_1.DestinationType; } });
|
|
33
|
+
var EstimateType_1 = require("./EstimateType");
|
|
34
|
+
Object.defineProperty(exports, "EstimateType", { enumerable: true, get: function () { return EstimateType_1.EstimateType; } });
|
|
33
35
|
var FcmFuturesSweepStatus_1 = require("./FcmFuturesSweepStatus");
|
|
34
36
|
Object.defineProperty(exports, "FcmFuturesSweepStatus", { enumerable: true, get: function () { return FcmFuturesSweepStatus_1.FcmFuturesSweepStatus; } });
|
|
35
37
|
var FcmMarginCallState_1 = require("./FcmMarginCallState");
|
|
@@ -60,6 +62,8 @@ var OrderType_1 = require("./OrderType");
|
|
|
60
62
|
Object.defineProperty(exports, "OrderType", { enumerable: true, get: function () { return OrderType_1.OrderType; } });
|
|
61
63
|
var PaymentMethodType_1 = require("./PaymentMethodType");
|
|
62
64
|
Object.defineProperty(exports, "PaymentMethodType", { enumerable: true, get: function () { return PaymentMethodType_1.PaymentMethodType; } });
|
|
65
|
+
var PegOffsetType_1 = require("./PegOffsetType");
|
|
66
|
+
Object.defineProperty(exports, "PegOffsetType", { enumerable: true, get: function () { return PegOffsetType_1.PegOffsetType; } });
|
|
63
67
|
var PortfolioBalanceType_1 = require("./PortfolioBalanceType");
|
|
64
68
|
Object.defineProperty(exports, "PortfolioBalanceType", { enumerable: true, get: function () { return PortfolioBalanceType_1.PortfolioBalanceType; } });
|
|
65
69
|
var PositionReferenceType_1 = require("./PositionReferenceType");
|
|
@@ -68,6 +72,8 @@ var ProductPermissions_1 = require("./ProductPermissions");
|
|
|
68
72
|
Object.defineProperty(exports, "ProductPermissions", { enumerable: true, get: function () { return ProductPermissions_1.ProductPermissions; } });
|
|
69
73
|
var RateType_1 = require("./RateType");
|
|
70
74
|
Object.defineProperty(exports, "RateType", { enumerable: true, get: function () { return RateType_1.RateType; } });
|
|
75
|
+
var RewardSubtype_1 = require("./RewardSubtype");
|
|
76
|
+
Object.defineProperty(exports, "RewardSubtype", { enumerable: true, get: function () { return RewardSubtype_1.RewardSubtype; } });
|
|
71
77
|
var SigningStatus_1 = require("./SigningStatus");
|
|
72
78
|
Object.defineProperty(exports, "SigningStatus", { enumerable: true, get: function () { return SigningStatus_1.SigningStatus; } });
|
|
73
79
|
var SortDirection_1 = require("./SortDirection");
|
|
@@ -80,6 +86,12 @@ var TransactionType_1 = require("./TransactionType");
|
|
|
80
86
|
Object.defineProperty(exports, "TransactionType", { enumerable: true, get: function () { return TransactionType_1.TransactionType; } });
|
|
81
87
|
var TransferLocationType_1 = require("./TransferLocationType");
|
|
82
88
|
Object.defineProperty(exports, "TransferLocationType", { enumerable: true, get: function () { return TransferLocationType_1.TransferLocationType; } });
|
|
89
|
+
var TravelRuleStatus_1 = require("./TravelRuleStatus");
|
|
90
|
+
Object.defineProperty(exports, "TravelRuleStatus", { enumerable: true, get: function () { return TravelRuleStatus_1.TravelRuleStatus; } });
|
|
91
|
+
var TravelRuleWalletType_1 = require("./TravelRuleWalletType");
|
|
92
|
+
Object.defineProperty(exports, "TravelRuleWalletType", { enumerable: true, get: function () { return TravelRuleWalletType_1.TravelRuleWalletType; } });
|
|
93
|
+
var UnstakeType_1 = require("./UnstakeType");
|
|
94
|
+
Object.defineProperty(exports, "UnstakeType", { enumerable: true, get: function () { return UnstakeType_1.UnstakeType; } });
|
|
83
95
|
var UserRole_1 = require("./UserRole");
|
|
84
96
|
Object.defineProperty(exports, "UserRole", { enumerable: true, get: function () { return UserRole_1.UserRole; } });
|
|
85
97
|
var ValidatorStatus_1 = require("./ValidatorStatus");
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Copyright 2025-present Coinbase Global, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
const validation_1 = require("../validation");
|
|
19
|
+
const errors_1 = require("../../errors");
|
|
20
|
+
describe('validation', () => {
|
|
21
|
+
describe('isValidUUID', () => {
|
|
22
|
+
it('should return true for valid UUIDs', () => {
|
|
23
|
+
expect((0, validation_1.isValidUUID)('123e4567-e89b-12d3-a456-426614174000')).toBe(true);
|
|
24
|
+
expect((0, validation_1.isValidUUID)('550e8400-e29b-41d4-a716-446655440000')).toBe(true);
|
|
25
|
+
expect((0, validation_1.isValidUUID)('ABCDEF12-3456-7890-ABCD-EF1234567890')).toBe(true);
|
|
26
|
+
});
|
|
27
|
+
it('should return false for invalid UUIDs', () => {
|
|
28
|
+
expect((0, validation_1.isValidUUID)('not-a-uuid')).toBe(false);
|
|
29
|
+
expect((0, validation_1.isValidUUID)('123e4567-e89b-12d3-a456')).toBe(false);
|
|
30
|
+
expect((0, validation_1.isValidUUID)('123e4567e89b12d3a456426614174000')).toBe(false);
|
|
31
|
+
expect((0, validation_1.isValidUUID)('')).toBe(false);
|
|
32
|
+
expect((0, validation_1.isValidUUID)('12345678-1234-1234-1234-12345678901g')).toBe(false); // 'g' is not hex
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
describe('ValidationResult', () => {
|
|
36
|
+
let validator;
|
|
37
|
+
beforeEach(() => {
|
|
38
|
+
validator = (0, validation_1.createValidator)();
|
|
39
|
+
});
|
|
40
|
+
it('should start with no errors', () => {
|
|
41
|
+
expect(validator.hasErrors()).toBe(false);
|
|
42
|
+
expect(validator.getErrors()).toEqual([]);
|
|
43
|
+
});
|
|
44
|
+
it('should accumulate errors', () => {
|
|
45
|
+
validator.addError('field1', 'is required');
|
|
46
|
+
validator.addError('field2', 'must be a valid UUID', 'invalid-value');
|
|
47
|
+
expect(validator.hasErrors()).toBe(true);
|
|
48
|
+
expect(validator.getErrors()).toHaveLength(2);
|
|
49
|
+
expect(validator.getErrors()[0]).toEqual({
|
|
50
|
+
paramName: 'field1',
|
|
51
|
+
message: 'is required',
|
|
52
|
+
});
|
|
53
|
+
expect(validator.getErrors()[1]).toEqual({
|
|
54
|
+
paramName: 'field2',
|
|
55
|
+
message: 'must be a valid UUID',
|
|
56
|
+
value: 'invalid-value',
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
it('should throw with formatted error message when there are errors', () => {
|
|
60
|
+
validator.addError('portfolioId', 'must be a valid UUID', 'bad-id');
|
|
61
|
+
validator.addError('orderId', 'is required');
|
|
62
|
+
expect(() => validator.throwIfInvalid()).toThrow(errors_1.CoinbasePrimeClientException);
|
|
63
|
+
expect(() => validator.throwIfInvalid()).toThrow(/Request validation failed:\n - portfolioId: must be a valid UUID \(received: 'bad-id'\)\n - orderId: is required/);
|
|
64
|
+
});
|
|
65
|
+
it('should not throw when there are no errors', () => {
|
|
66
|
+
expect(() => validator.throwIfInvalid()).not.toThrow();
|
|
67
|
+
});
|
|
68
|
+
it('should include custom context message', () => {
|
|
69
|
+
validator.addError('field1', 'is invalid');
|
|
70
|
+
expect(() => validator.throwIfInvalid('Custom operation failed')).toThrow(/Custom operation failed:/);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
describe('validateRequiredUUID', () => {
|
|
74
|
+
let validator;
|
|
75
|
+
beforeEach(() => {
|
|
76
|
+
validator = (0, validation_1.createValidator)();
|
|
77
|
+
});
|
|
78
|
+
it('should not add error for valid UUID', () => {
|
|
79
|
+
(0, validation_1.validateRequiredUUID)(validator, '123e4567-e89b-12d3-a456-426614174000', 'testId');
|
|
80
|
+
expect(validator.hasErrors()).toBe(false);
|
|
81
|
+
});
|
|
82
|
+
it('should add error for undefined', () => {
|
|
83
|
+
(0, validation_1.validateRequiredUUID)(validator, undefined, 'testId');
|
|
84
|
+
expect(validator.hasErrors()).toBe(true);
|
|
85
|
+
expect(validator.getErrors()[0].message).toContain('required');
|
|
86
|
+
});
|
|
87
|
+
it('should add error for null', () => {
|
|
88
|
+
(0, validation_1.validateRequiredUUID)(validator, null, 'testId');
|
|
89
|
+
expect(validator.hasErrors()).toBe(true);
|
|
90
|
+
expect(validator.getErrors()[0].message).toContain('required');
|
|
91
|
+
});
|
|
92
|
+
it('should add error for empty string', () => {
|
|
93
|
+
(0, validation_1.validateRequiredUUID)(validator, '', 'testId');
|
|
94
|
+
expect(validator.hasErrors()).toBe(true);
|
|
95
|
+
expect(validator.getErrors()[0].message).toContain('required');
|
|
96
|
+
});
|
|
97
|
+
it('should add error for whitespace-only string', () => {
|
|
98
|
+
(0, validation_1.validateRequiredUUID)(validator, ' ', 'testId');
|
|
99
|
+
expect(validator.hasErrors()).toBe(true);
|
|
100
|
+
expect(validator.getErrors()[0].message).toContain('whitespace');
|
|
101
|
+
});
|
|
102
|
+
it('should add error for invalid UUID format', () => {
|
|
103
|
+
(0, validation_1.validateRequiredUUID)(validator, 'not-a-uuid', 'testId');
|
|
104
|
+
expect(validator.hasErrors()).toBe(true);
|
|
105
|
+
expect(validator.getErrors()[0].message).toContain('valid UUID');
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
describe('validateOptionalUUID', () => {
|
|
109
|
+
let validator;
|
|
110
|
+
beforeEach(() => {
|
|
111
|
+
validator = (0, validation_1.createValidator)();
|
|
112
|
+
});
|
|
113
|
+
it('should not add error for valid UUID', () => {
|
|
114
|
+
(0, validation_1.validateOptionalUUID)(validator, '123e4567-e89b-12d3-a456-426614174000', 'testId');
|
|
115
|
+
expect(validator.hasErrors()).toBe(false);
|
|
116
|
+
});
|
|
117
|
+
it('should not add error for undefined', () => {
|
|
118
|
+
(0, validation_1.validateOptionalUUID)(validator, undefined, 'testId');
|
|
119
|
+
expect(validator.hasErrors()).toBe(false);
|
|
120
|
+
});
|
|
121
|
+
it('should not add error for null', () => {
|
|
122
|
+
(0, validation_1.validateOptionalUUID)(validator, null, 'testId');
|
|
123
|
+
expect(validator.hasErrors()).toBe(false);
|
|
124
|
+
});
|
|
125
|
+
it('should not add error for empty string', () => {
|
|
126
|
+
(0, validation_1.validateOptionalUUID)(validator, '', 'testId');
|
|
127
|
+
expect(validator.hasErrors()).toBe(false);
|
|
128
|
+
});
|
|
129
|
+
it('should add error for invalid UUID format', () => {
|
|
130
|
+
(0, validation_1.validateOptionalUUID)(validator, 'not-a-uuid', 'testId');
|
|
131
|
+
expect(validator.hasErrors()).toBe(true);
|
|
132
|
+
expect(validator.getErrors()[0].message).toContain('valid UUID');
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
describe('validateRequiredString', () => {
|
|
136
|
+
let validator;
|
|
137
|
+
beforeEach(() => {
|
|
138
|
+
validator = (0, validation_1.createValidator)();
|
|
139
|
+
});
|
|
140
|
+
it('should not add error for valid string', () => {
|
|
141
|
+
(0, validation_1.validateRequiredString)(validator, 'valid-string', 'testField');
|
|
142
|
+
expect(validator.hasErrors()).toBe(false);
|
|
143
|
+
});
|
|
144
|
+
it('should add error for undefined', () => {
|
|
145
|
+
(0, validation_1.validateRequiredString)(validator, undefined, 'testField');
|
|
146
|
+
expect(validator.hasErrors()).toBe(true);
|
|
147
|
+
expect(validator.getErrors()[0].message).toContain('required');
|
|
148
|
+
});
|
|
149
|
+
it('should add error for null', () => {
|
|
150
|
+
(0, validation_1.validateRequiredString)(validator, null, 'testField');
|
|
151
|
+
expect(validator.hasErrors()).toBe(true);
|
|
152
|
+
expect(validator.getErrors()[0].message).toContain('required');
|
|
153
|
+
});
|
|
154
|
+
it('should add error for empty string', () => {
|
|
155
|
+
(0, validation_1.validateRequiredString)(validator, '', 'testField');
|
|
156
|
+
expect(validator.hasErrors()).toBe(true);
|
|
157
|
+
expect(validator.getErrors()[0].message).toContain('required');
|
|
158
|
+
});
|
|
159
|
+
it('should add error for whitespace-only string', () => {
|
|
160
|
+
(0, validation_1.validateRequiredString)(validator, ' ', 'testField');
|
|
161
|
+
expect(validator.hasErrors()).toBe(true);
|
|
162
|
+
expect(validator.getErrors()[0].message).toContain('whitespace');
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
describe('validateOptionalString', () => {
|
|
166
|
+
let validator;
|
|
167
|
+
beforeEach(() => {
|
|
168
|
+
validator = (0, validation_1.createValidator)();
|
|
169
|
+
});
|
|
170
|
+
it('should not add error for valid string', () => {
|
|
171
|
+
(0, validation_1.validateOptionalString)(validator, 'valid-string', 'testField');
|
|
172
|
+
expect(validator.hasErrors()).toBe(false);
|
|
173
|
+
});
|
|
174
|
+
it('should not add error for undefined', () => {
|
|
175
|
+
(0, validation_1.validateOptionalString)(validator, undefined, 'testField');
|
|
176
|
+
expect(validator.hasErrors()).toBe(false);
|
|
177
|
+
});
|
|
178
|
+
it('should not add error for null', () => {
|
|
179
|
+
(0, validation_1.validateOptionalString)(validator, null, 'testField');
|
|
180
|
+
expect(validator.hasErrors()).toBe(false);
|
|
181
|
+
});
|
|
182
|
+
it('should add error for whitespace-only when not empty', () => {
|
|
183
|
+
(0, validation_1.validateOptionalString)(validator, ' ', 'testField');
|
|
184
|
+
expect(validator.hasErrors()).toBe(true);
|
|
185
|
+
expect(validator.getErrors()[0].message).toContain('whitespace');
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
describe('multiple field validation', () => {
|
|
189
|
+
it('should collect all validation errors before throwing', () => {
|
|
190
|
+
const validator = (0, validation_1.createValidator)();
|
|
191
|
+
// Simulate validating multiple fields at once
|
|
192
|
+
(0, validation_1.validateRequiredUUID)(validator, undefined, 'portfolioId');
|
|
193
|
+
(0, validation_1.validateRequiredUUID)(validator, 'invalid-uuid', 'orderId');
|
|
194
|
+
(0, validation_1.validateRequiredString)(validator, '', 'productId');
|
|
195
|
+
expect(validator.hasErrors()).toBe(true);
|
|
196
|
+
expect(validator.getErrors()).toHaveLength(3);
|
|
197
|
+
expect(() => validator.throwIfInvalid('getOrder request validation failed')).toThrow(errors_1.CoinbasePrimeClientException);
|
|
198
|
+
try {
|
|
199
|
+
validator.throwIfInvalid('getOrder request validation failed');
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
if (error instanceof errors_1.CoinbasePrimeClientException) {
|
|
203
|
+
expect(error.message).toContain('portfolioId');
|
|
204
|
+
expect(error.message).toContain('orderId');
|
|
205
|
+
expect(error.message).toContain('productId');
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
});
|