@coinbase-sample/prime-sdk-ts 0.4.0 → 0.5.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/README.md +22 -0
- package/dist/activities/index.js +40 -4
- package/dist/addressBooks/index.js +4 -2
- package/dist/allocations/index.js +21 -1
- package/dist/balances/index.js +17 -5
- package/dist/client.js +7 -2
- package/dist/constants.js +4 -1
- package/dist/invoices/index.js +16 -3
- package/dist/model/CreateWalletDepositAddressRequest.js +21 -0
- package/dist/model/ListWalletAddressesResponse.js +21 -0
- package/dist/model/enums/TransactionStatus.js +1 -1
- package/dist/orders/index.js +52 -8
- package/dist/portfolios/types.js +15 -0
- package/dist/positions/index.js +9 -6
- package/dist/products/index.js +5 -1
- package/dist/shared/brand.js +15 -0
- package/dist/shared/paginatedResponse.js +185 -0
- package/dist/shared/pagination.js +15 -0
- package/dist/shared/toCamelCase.js +15 -0
- package/dist/staking/index.js +22 -4
- package/dist/transactions/index.js +17 -2
- package/dist/types/activities/types.d.ts +6 -3
- package/dist/types/addressBooks/types.d.ts +4 -2
- package/dist/types/allocations/types.d.ts +4 -2
- package/dist/types/assets/types.d.ts +1 -1
- package/dist/types/balances/types.d.ts +6 -3
- package/dist/types/client.d.ts +2 -2
- package/dist/types/commission/types.d.ts +1 -1
- package/dist/types/constants.d.ts +3 -0
- package/dist/types/financing/types.d.ts +1 -1
- package/dist/types/futures/types.d.ts +1 -1
- package/dist/types/invoices/index.d.ts +2 -2
- package/dist/types/invoices/types.d.ts +9 -3
- package/dist/types/model/Commission.d.ts +1 -1
- package/dist/types/model/CreateOnchainTransactionRequestEvmParams.d.ts +1 -1
- package/dist/types/model/CreateWalletDepositAddressRequest.d.ts +25 -0
- package/dist/types/model/Fill.d.ts +1 -1
- package/dist/types/model/ListWalletAddressesResponse.d.ts +25 -0
- package/dist/types/model/Order.d.ts +1 -1
- package/dist/types/model/TransferLocation.d.ts +8 -0
- package/dist/types/model/enums/TransactionStatus.d.ts +1 -1
- package/dist/types/model/index.d.ts +2 -0
- package/dist/types/onchainAddressBook/types.d.ts +1 -1
- package/dist/types/orders/types.d.ts +11 -6
- package/dist/types/paymentMethods/types.d.ts +1 -1
- package/dist/types/portfolios/types.d.ts +1 -1
- package/dist/types/positions/types.d.ts +9 -9
- package/dist/types/products/types.d.ts +4 -2
- package/dist/types/shared/brand.d.ts +15 -0
- package/dist/types/shared/paginatedResponse.d.ts +120 -0
- package/dist/types/shared/toCamelCase.d.ts +15 -0
- package/dist/types/staking/types.d.ts +1 -1
- package/dist/types/transactions/types.d.ts +7 -3
- package/dist/types/users/types.d.ts +9 -5
- package/dist/types/wallets/types.d.ts +7 -5
- package/dist/users/index.js +11 -2
- package/dist/wallets/index.js +17 -21
- package/package.json +2 -2
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* Do not edit the class manually.
|
|
19
19
|
*/
|
|
20
20
|
/**
|
|
21
|
-
* - UNKNOWN_TRANSACTION_STATUS: An Unknown Transaction status - TRANSACTION_CREATED: The Transaction has been created and is awaiting Consensus approval This is a non-terminal status - TRANSACTION_REQUESTED: The Transaction has reached User Consensus and is awaiting Coinbase Prime approval This is a non-terminal status - TRANSACTION_APPROVED: The Transaction has been authorized by Coinbase Prime This is a non-terminal status - TRANSACTION_GASSING: The transaction is awaiting blockchain resources for broadcast This is a non-terminal status - TRANSACTION_GASSED: The transaction has received blockchain resources for broadcasting This is a non-terminal status - TRANSACTION_PROVISIONED: The transaction has been provisioned and is awaiting planning This is a non-terminal status - TRANSACTION_PLANNED: The transaction has been constructed.
|
|
21
|
+
* - UNKNOWN_TRANSACTION_STATUS: An Unknown Transaction status - TRANSACTION_CREATED: The Transaction has been created and is awaiting Consensus approval This is a non-terminal status - TRANSACTION_REQUESTED: The Transaction has reached User Consensus and is awaiting Coinbase Prime approval This is a non-terminal status - TRANSACTION_APPROVED: The Transaction has been authorized by Coinbase Prime This is a non-terminal status - TRANSACTION_GASSING: The transaction is awaiting blockchain resources for broadcast This is a non-terminal status - TRANSACTION_GASSED: The transaction has received blockchain resources for broadcasting This is a non-terminal status - TRANSACTION_PROVISIONED: The transaction has been provisioned and is awaiting planning This is a non-terminal status - TRANSACTION_PLANNED: The transaction has been constructed. This is a non-terminal status - TRANSACTION_PROCESSING: The transaction is currently processing and awaiting finalization This is a non-terminal status - TRANSACTION_RESTORED: The transaction has been broadcasted to the network. This is a non-terminal status - TRANSACTION_DONE: The transaction has confirmed on-chain and finished. This is a terminal status - TRANSACTION_IMPORT_PENDING: The transaction deposit has been detected and is awaiting finalization. This is a non-terminal status - TRANSACTION_IMPORTED: The transaction deposit and reward has been detected. This is a terminal status - TRANSACTION_CANCELLED: The transaction has been cancelled This is a terminal status - TRANSACTION_REJECTED: The transaction was rejected before construction and broadcasting. This is a terminal status - TRANSACTION_DELAYED: The transaction s taking longer than expected to confirm on-chain. This is a non-terminal status - TRANSACTION_RETRIED: The transaction has been recreated and retried, this occurs when network congestion results in transfers becoming extremely delayed due to insufficient fees or network resources such as CPU, RAM, or NET This is a terminal status - TRANSACTION_FAILED: The transaction failed on-chain (the fee was spent but the operation failed). This is a terminal status - TRANSACTION_EXPIRED: The transaction has expired. This is a terminal status - TRANSACTION_BROADCASTING: The transaction is currently broadcasting to the cryptocurrency network. This is a non-terminal status - OTHER_TRANSACTION_STATUS: The transaction has reached an OTHER status. This is a non-terminal status - TRANSACTION_CONSTRUCTED: The transaction bctx is constructed but not yet broadcasting on chain This is a non-terminal status
|
|
22
22
|
*/
|
|
23
23
|
export declare enum TransactionStatus {
|
|
24
24
|
UnknownTransactionStatus = "UNKNOWN_TRANSACTION_STATUS",
|
|
@@ -101,6 +101,7 @@ export type { ListAggregateEntityPositionsResponse } from './ListAggregateEntity
|
|
|
101
101
|
export type { ListEntityBalancesResponse } from './ListEntityBalancesResponse';
|
|
102
102
|
export type { ListEntityPositionsResponse } from './ListEntityPositionsResponse';
|
|
103
103
|
export type { ListOnchainAddressGroupsResponse } from './ListOnchainAddressGroupsResponse';
|
|
104
|
+
export type { ListWalletAddressesResponse } from './ListWalletAddressesResponse';
|
|
104
105
|
export type { ListWeb3WalletBalancesResponse } from './ListWeb3WalletBalancesResponse';
|
|
105
106
|
export type { LoanInfo } from './LoanInfo';
|
|
106
107
|
export type { Locate } from './Locate';
|
|
@@ -158,6 +159,7 @@ export type { CreateNewLocatesRequest } from './CreateNewLocatesRequest';
|
|
|
158
159
|
export type { CreateOnchainTransactionRequest } from './CreateOnchainTransactionRequest';
|
|
159
160
|
export type { CreateOrderRequest } from './CreateOrderRequest';
|
|
160
161
|
export type { CreatePortfolioAddressBookEntryRequest } from './CreatePortfolioAddressBookEntryRequest';
|
|
162
|
+
export type { CreateWalletDepositAddressRequest } from './CreateWalletDepositAddressRequest';
|
|
161
163
|
export type { CreateWalletRequest } from './CreateWalletRequest';
|
|
162
164
|
export type { CreateWalletWithdrawalRequest } from './CreateWalletWithdrawalRequest';
|
|
163
165
|
export type { OrderPreviewRequest } from './OrderPreviewRequest';
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Brand } from '
|
|
16
|
+
import { Brand } from '../shared/brand';
|
|
17
17
|
import { ListOnchainAddressGroupsResponse as listInt, AddressGroup, ActivityCreationResponse } from '../model/';
|
|
18
18
|
export type ListOnchainAddressBookRequest = {
|
|
19
19
|
portfolioId: string;
|
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Brand } from '
|
|
16
|
+
import { Brand } from '../shared/brand';
|
|
17
17
|
import { OrderSide, OrderStatus, OrderType } from '../model/enums/';
|
|
18
18
|
import { GetOpenOrdersResponse, GetOrderFillsResponse, GetOrderResponse as internalGet, GetOrdersResponse, GetPortfolioFillsResponse, OrderPreviewRequest, PostOrderPreviewResponse, CancelOrderResponse as internalCancel, CreateOrderResponse as internalCreateResp, CreateOrderRequest as internalCreate, QuoteResponse, AcceptQuoteRequest as internalAcceptQuoteReq, AcceptQuoteResponse as internalAcceptQuoteResp } from '../model/';
|
|
19
19
|
import { Pagination } from '../shared/pagination';
|
|
20
|
+
import { BasePaginatedRequest, PaginatedResponseMethods } from '../shared/paginatedResponse';
|
|
20
21
|
export type GetOrderRequest = {
|
|
21
22
|
portfolioId: string;
|
|
22
23
|
orderId: string;
|
|
@@ -27,22 +28,25 @@ export type ListPortfolioFillsRequest = Pagination & {
|
|
|
27
28
|
startDate?: string;
|
|
28
29
|
endDate?: string;
|
|
29
30
|
};
|
|
30
|
-
export type
|
|
31
|
+
export type BaseListPortfolioFillsResponse = Brand<GetPortfolioFillsResponse, 'ListPortfolioFillsResponse'>;
|
|
32
|
+
export type ListPortfolioFillsResponse = BaseListPortfolioFillsResponse & PaginatedResponseMethods<ListPortfolioFillsRequest & BasePaginatedRequest, BaseListPortfolioFillsResponse, any>;
|
|
31
33
|
export type ListPortfolioOrdersRequest = Pagination & {
|
|
32
34
|
portfolioId: string;
|
|
33
35
|
orderStatuses?: OrderStatus[];
|
|
34
36
|
productIds?: string[];
|
|
35
|
-
|
|
37
|
+
orderType?: OrderType;
|
|
36
38
|
orderSide?: OrderSide;
|
|
37
39
|
startDate?: string;
|
|
38
40
|
endDate?: string;
|
|
39
41
|
};
|
|
40
|
-
export type
|
|
42
|
+
export type BaseListPortfolioOrdersResponse = Brand<GetOrdersResponse, 'ListPortfolioOrdersResponse'>;
|
|
43
|
+
export type ListPortfolioOrdersResponse = BaseListPortfolioOrdersResponse & PaginatedResponseMethods<ListPortfolioOrdersRequest & BasePaginatedRequest, BaseListPortfolioOrdersResponse, any>;
|
|
41
44
|
export type ListOrderFillsRequest = Pagination & {
|
|
42
45
|
portfolioId: string;
|
|
43
46
|
orderId: string;
|
|
44
47
|
};
|
|
45
|
-
export type
|
|
48
|
+
export type BaseListOrderFillsResponse = Brand<GetOrderFillsResponse, 'ListOrderFillsResponse'>;
|
|
49
|
+
export type ListOrderFillsResponse = BaseListOrderFillsResponse & PaginatedResponseMethods<ListOrderFillsRequest & BasePaginatedRequest, BaseListOrderFillsResponse, any>;
|
|
46
50
|
export type ListOpenOrdersRequest = Pagination & {
|
|
47
51
|
portfolioId: string;
|
|
48
52
|
productIds?: string[];
|
|
@@ -51,7 +55,8 @@ export type ListOpenOrdersRequest = Pagination & {
|
|
|
51
55
|
startDate?: string;
|
|
52
56
|
endDate: string;
|
|
53
57
|
};
|
|
54
|
-
export type
|
|
58
|
+
export type BaseListOpenOrdersResponse = Brand<GetOpenOrdersResponse, 'ListOpenOrdersResponse'>;
|
|
59
|
+
export type ListOpenOrdersResponse = BaseListOpenOrdersResponse & PaginatedResponseMethods<ListOpenOrdersRequest & BasePaginatedRequest, BaseListOpenOrdersResponse, any>;
|
|
55
60
|
export type CreateOrderPreviewRequest = OrderPreviewRequest & {
|
|
56
61
|
portfolioId: string;
|
|
57
62
|
};
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Brand } from '
|
|
16
|
+
import { Brand } from '../shared/brand';
|
|
17
17
|
import { GetEntityPaymentMethodsResponse, GetEntityPaymentMethodDetailsResponse } from '../model/';
|
|
18
18
|
export type ListEntityPaymentMethodsRequest = {
|
|
19
19
|
entityId: string;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Brand } from '
|
|
16
|
+
import { Brand } from '../shared/brand';
|
|
17
17
|
import { GetPortfolioResponse as internalGet, GetPortfoliosResponse, GetPostTradeCreditResponse } from '../model/';
|
|
18
18
|
export type GetPortfolioRequest = {
|
|
19
19
|
/**
|
|
@@ -13,17 +13,17 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Brand } from '
|
|
16
|
+
import { Brand } from '../shared/brand';
|
|
17
17
|
import { ListAggregateEntityPositionsResponse as ListAggregateEntityPositionsInt, ListEntityPositionsResponse as ListEntityPositionsInt } from '../model/';
|
|
18
|
-
|
|
18
|
+
import { BasePaginatedRequest, PaginatedResponseMethods } from '../shared/paginatedResponse';
|
|
19
|
+
import { Pagination } from '../shared/pagination';
|
|
20
|
+
export type ListAggregateEntityPositionsRequest = Pagination & {
|
|
19
21
|
entityId: string;
|
|
20
|
-
cursor?: string;
|
|
21
|
-
limit?: number;
|
|
22
22
|
};
|
|
23
|
-
export type
|
|
24
|
-
export type
|
|
23
|
+
export type BaseListAggregateEntityPositionsResponse = Brand<ListAggregateEntityPositionsInt, 'ListAggregateEntityPositionsResponse'>;
|
|
24
|
+
export type ListAggregateEntityPositionsResponse = BaseListAggregateEntityPositionsResponse & PaginatedResponseMethods<ListAggregateEntityPositionsRequest & BasePaginatedRequest, BaseListAggregateEntityPositionsResponse, any>;
|
|
25
|
+
export type ListEntityPositionsRequest = Pagination & {
|
|
25
26
|
entityId: string;
|
|
26
|
-
cursor?: string;
|
|
27
|
-
limit?: number;
|
|
28
27
|
};
|
|
29
|
-
export type
|
|
28
|
+
export type BaseListEntityPositionsResponse = Brand<ListEntityPositionsInt, 'ListEntityPositionsResponse'>;
|
|
29
|
+
export type ListEntityPositionsResponse = BaseListEntityPositionsResponse & PaginatedResponseMethods<ListEntityPositionsRequest & BasePaginatedRequest, BaseListEntityPositionsResponse, any>;
|
|
@@ -13,10 +13,12 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Brand } from '
|
|
16
|
+
import { Brand } from '../shared/brand';
|
|
17
17
|
import { GetPortfolioProductsResponse } from '../model/';
|
|
18
18
|
import { Pagination } from '../shared/pagination';
|
|
19
|
+
import { PaginatedResponseMethods, BasePaginatedRequest } from '../shared/paginatedResponse';
|
|
19
20
|
export type ListProductsRequest = Pagination & {
|
|
20
21
|
portfolioId: string;
|
|
21
22
|
};
|
|
22
|
-
export type
|
|
23
|
+
export type BaseListProductsResponse = Brand<GetPortfolioProductsResponse, 'ListProductsResponse'>;
|
|
24
|
+
export type ListProductsResponse = BaseListProductsResponse & PaginatedResponseMethods<ListProductsRequest & BasePaginatedRequest, BaseListProductsResponse, any>;
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025-present Coinbase Global, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
1
16
|
export type Brand<T, B> = T & {
|
|
2
17
|
__brand: B;
|
|
3
18
|
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025-present Coinbase Global, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { CoinbaseCallOptions } from '@coinbase-sample/core-ts';
|
|
17
|
+
import { CoinbasePrimeClient } from 'src/client';
|
|
18
|
+
/**
|
|
19
|
+
* Base type for paginated requests
|
|
20
|
+
*/
|
|
21
|
+
export type BasePaginatedRequest = {
|
|
22
|
+
cursor?: string;
|
|
23
|
+
limit?: number;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* API call signature for paginated endpoints
|
|
27
|
+
*/
|
|
28
|
+
export type ApiCall<TRequest extends BasePaginatedRequest, TResponse> = (request: TRequest, options?: CoinbaseCallOptions) => Promise<TResponse>;
|
|
29
|
+
/**
|
|
30
|
+
* Configuration for pagination behavior
|
|
31
|
+
*/
|
|
32
|
+
export interface PaginationConfig {
|
|
33
|
+
defaultLimit?: number;
|
|
34
|
+
maxPages?: number;
|
|
35
|
+
maxItems?: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Function to extract data array from response
|
|
39
|
+
*/
|
|
40
|
+
export type DataExtractor<TResponse, TData> = (response: TResponse) => TData[];
|
|
41
|
+
/**
|
|
42
|
+
* Interface for pagination methods that will be added to response objects
|
|
43
|
+
*/
|
|
44
|
+
export interface PaginatedResponseMethods<TRequest extends BasePaginatedRequest, TResponse, TData> {
|
|
45
|
+
__apiCall: ApiCall<TRequest, TResponse & PaginatedResponseMethods<TRequest, TResponse, TData>>;
|
|
46
|
+
__baseRequest: Omit<TRequest, 'cursor'>;
|
|
47
|
+
__dataExtractor: DataExtractor<TResponse, TData>;
|
|
48
|
+
__config: PaginationConfig;
|
|
49
|
+
__currentPage: number;
|
|
50
|
+
__totalItemsFetched: number;
|
|
51
|
+
/**
|
|
52
|
+
* Check if there are more pages available
|
|
53
|
+
*/
|
|
54
|
+
hasNext(): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Get the next cursor
|
|
57
|
+
*/
|
|
58
|
+
getNextCursor(): string | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Fetch the next page
|
|
61
|
+
*/
|
|
62
|
+
next(options?: CoinbaseCallOptions): Promise<(TResponse & PaginatedResponseMethods<TRequest, TResponse, TData>) | null>;
|
|
63
|
+
/**
|
|
64
|
+
* Fetch all remaining pages and return combined data
|
|
65
|
+
*/
|
|
66
|
+
fetchAll(options?: CoinbaseCallOptions, progressCallback?: (page: number, totalItems: number) => void): Promise<TData[]>;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Factory function to create enhanced response objects with pagination methods
|
|
70
|
+
*/
|
|
71
|
+
export declare function createPaginatedResponse<TRequest extends BasePaginatedRequest, TResponse, TData>(responseData: TResponse, apiCall: ApiCall<TRequest, TResponse & PaginatedResponseMethods<TRequest, TResponse, TData>>, baseRequest: Omit<TRequest, 'cursor'>, dataExtractor: DataExtractor<TResponse, TData>, options?: CoinbaseCallOptions): TResponse & PaginatedResponseMethods<TRequest, TResponse, TData>;
|
|
72
|
+
/**
|
|
73
|
+
* Common data extractors for typical API responses
|
|
74
|
+
*/
|
|
75
|
+
export declare const ResponseExtractors: {
|
|
76
|
+
activities: <T>(response: {
|
|
77
|
+
activities?: T[];
|
|
78
|
+
}) => T[];
|
|
79
|
+
addresses: <T>(response: {
|
|
80
|
+
addresses?: T[];
|
|
81
|
+
}) => T[];
|
|
82
|
+
allocations: <T>(response: {
|
|
83
|
+
allocations?: T[];
|
|
84
|
+
}) => T[];
|
|
85
|
+
balances: <T>(response: {
|
|
86
|
+
balances?: T[];
|
|
87
|
+
}) => T[];
|
|
88
|
+
fills: <T>(response: {
|
|
89
|
+
fills?: T[];
|
|
90
|
+
}) => T[];
|
|
91
|
+
invoices: <T>(response: {
|
|
92
|
+
invoices?: T[];
|
|
93
|
+
}) => T[];
|
|
94
|
+
orders: <T>(response: {
|
|
95
|
+
orders?: T[];
|
|
96
|
+
}) => T[];
|
|
97
|
+
positions: <T>(response: {
|
|
98
|
+
positions?: T[];
|
|
99
|
+
}) => T[];
|
|
100
|
+
products: <T>(response: {
|
|
101
|
+
products?: T[];
|
|
102
|
+
}) => T[];
|
|
103
|
+
portfolios: <T>(response: {
|
|
104
|
+
portfolios?: T[];
|
|
105
|
+
}) => T[];
|
|
106
|
+
transactions: <T>(response: {
|
|
107
|
+
transactions?: T[];
|
|
108
|
+
}) => T[];
|
|
109
|
+
users: <T>(response: {
|
|
110
|
+
users?: T[];
|
|
111
|
+
}) => T[];
|
|
112
|
+
wallets: <T>(response: {
|
|
113
|
+
wallets?: T[];
|
|
114
|
+
}) => T[];
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Get the default pagination options for a client
|
|
118
|
+
*/
|
|
119
|
+
export declare function getDefaultPaginationOptions(client: CoinbasePrimeClient, options: CoinbaseCallOptions | undefined): CoinbaseCallOptions;
|
|
120
|
+
export declare function getQueryParams(client: CoinbasePrimeClient, request: BasePaginatedRequest): Record<string, string | number | string[]>;
|
|
@@ -1 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025-present Coinbase Global, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
1
16
|
export declare function toCamelCase<T>(obj: T, seen?: WeakSet<object>): T;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Brand } from '
|
|
16
|
+
import { Brand } from '../shared/brand';
|
|
17
17
|
import { StakingInitiateResponse, StakingInitiateRequest, StakingUnstakeResponse } from 'src/model/';
|
|
18
18
|
export type CreateStakeRequest = StakingInitiateRequest & {
|
|
19
19
|
portfolioId: string;
|
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Brand } from '
|
|
16
|
+
import { Brand } from '../shared/brand';
|
|
17
17
|
import { TransactionType } 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
|
+
import { PaginatedResponseMethods, BasePaginatedRequest } from '../shared/paginatedResponse';
|
|
20
21
|
export type ListPortfolioTransactionsRequest = Pagination & {
|
|
21
22
|
portfolioId: string;
|
|
22
23
|
symbols?: string[];
|
|
@@ -24,7 +25,8 @@ export type ListPortfolioTransactionsRequest = Pagination & {
|
|
|
24
25
|
startTime?: string;
|
|
25
26
|
endTime?: string;
|
|
26
27
|
};
|
|
27
|
-
|
|
28
|
+
type BaseListPortfolioTransactionsResponse = Brand<GetPortfolioTransactionsResponse, 'ListPortfolioTransactionsResponse'>;
|
|
29
|
+
export type ListPortfolioTransactionsResponse = BaseListPortfolioTransactionsResponse & PaginatedResponseMethods<ListPortfolioTransactionsRequest & BasePaginatedRequest, BaseListPortfolioTransactionsResponse, any>;
|
|
28
30
|
export type ListWalletTransactionsRequest = Pagination & {
|
|
29
31
|
portfolioId: string;
|
|
30
32
|
walletId: string;
|
|
@@ -32,7 +34,8 @@ export type ListWalletTransactionsRequest = Pagination & {
|
|
|
32
34
|
startTime?: string;
|
|
33
35
|
endTime?: string;
|
|
34
36
|
};
|
|
35
|
-
export type
|
|
37
|
+
export type BaseListWalletTransactionsResponse = Brand<GetWalletTransactionsResponse, 'ListWalletTransactionsResponse'>;
|
|
38
|
+
export type ListWalletTransactionsResponse = BaseListWalletTransactionsResponse & PaginatedResponseMethods<ListWalletTransactionsRequest & BasePaginatedRequest, BaseListWalletTransactionsResponse, any>;
|
|
36
39
|
export type GetTransactionRequest = {
|
|
37
40
|
portfolioId: string;
|
|
38
41
|
transactionId: string;
|
|
@@ -58,3 +61,4 @@ export type CreateOnchainTransactionRequest = internalCreate & {
|
|
|
58
61
|
walletId: string;
|
|
59
62
|
};
|
|
60
63
|
export type CreateOnchainTransactionResponse = Brand<internalCreateResp, 'CreateOnchainTransactionResponse'>;
|
|
64
|
+
export {};
|
|
@@ -13,13 +13,17 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Brand } from '
|
|
16
|
+
import { Brand } from '../shared/brand';
|
|
17
17
|
import { GetEntityUsersResponse } from '../model/';
|
|
18
|
-
|
|
18
|
+
import { BasePaginatedRequest, PaginatedResponseMethods } from '../shared/paginatedResponse';
|
|
19
|
+
import { Pagination } from '../shared/pagination';
|
|
20
|
+
export type ListUsersRequest = Pagination & {
|
|
19
21
|
entityId: string;
|
|
20
22
|
};
|
|
21
|
-
export type
|
|
22
|
-
export type
|
|
23
|
+
export type BaseListUsersResponse = Brand<GetEntityUsersResponse, 'ListUsersResponse'>;
|
|
24
|
+
export type ListUsersResponse = BaseListUsersResponse & PaginatedResponseMethods<ListUsersRequest & BasePaginatedRequest, BaseListUsersResponse, any>;
|
|
25
|
+
export type ListPortfolioUsersRequest = Pagination & {
|
|
23
26
|
portfolioId: string;
|
|
24
27
|
};
|
|
25
|
-
export type
|
|
28
|
+
export type BaseListPortfolioUsersResponse = Brand<GetEntityUsersResponse, 'ListPortfolioUsersResponse'>;
|
|
29
|
+
export type ListPortfolioUsersResponse = BaseListPortfolioUsersResponse & PaginatedResponseMethods<ListPortfolioUsersRequest & BasePaginatedRequest, BaseListPortfolioUsersResponse, any>;
|
|
@@ -13,16 +13,18 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Brand } from '
|
|
16
|
+
import { Brand } from '../shared/brand';
|
|
17
17
|
import { WalletType, WalletDepositInstructionType } from '../model/enums/';
|
|
18
18
|
import { GetWalletsResponse, GetWalletResponse as internalGet, GetWalletAddressesResponse as internalGetAddresses, GetWalletDepositInstructionsResponse as internalGetInstructs, CreateWalletRequest as internalCreate, CreateWalletResponse as internalCreateResp, BlockchainAddress } from '../model/';
|
|
19
19
|
import { Pagination } from '../shared/pagination';
|
|
20
|
+
import { BasePaginatedRequest, PaginatedResponseMethods } from '../shared/paginatedResponse';
|
|
20
21
|
export type ListWalletsRequest = Pagination & {
|
|
21
22
|
portfolioId: string;
|
|
22
23
|
type: WalletType;
|
|
23
24
|
symbols?: string[];
|
|
24
25
|
};
|
|
25
|
-
export type
|
|
26
|
+
export type BaseListWalletsResponse = Brand<GetWalletsResponse, 'ListWalletsResponse'>;
|
|
27
|
+
export type ListWalletsResponse = BaseListWalletsResponse & PaginatedResponseMethods<ListWalletsRequest & BasePaginatedRequest, BaseListWalletsResponse, any>;
|
|
26
28
|
export type GetWalletRequest = {
|
|
27
29
|
portfolioId: string;
|
|
28
30
|
walletId: string;
|
|
@@ -44,7 +46,8 @@ export type ListWalletAddressesRequest = {
|
|
|
44
46
|
cursor?: string;
|
|
45
47
|
limit?: number;
|
|
46
48
|
};
|
|
47
|
-
export type
|
|
49
|
+
export type BaseListWalletAddressesResponse = Brand<internalGetAddresses, 'ListWalletAddressesResponse'>;
|
|
50
|
+
export type ListWalletAddressesResponse = BaseListWalletAddressesResponse & PaginatedResponseMethods<ListWalletAddressesRequest & BasePaginatedRequest, BaseListWalletAddressesResponse, any>;
|
|
48
51
|
export type CreateWalletRequest = internalCreate & {
|
|
49
52
|
portfolioId: string;
|
|
50
53
|
};
|
|
@@ -52,7 +55,6 @@ export type CreateWalletResponse = Brand<internalCreateResp, 'CreateWalletRespon
|
|
|
52
55
|
export type CreateWalletDepositAddressRequest = {
|
|
53
56
|
portfolioId: string;
|
|
54
57
|
walletId: string;
|
|
55
|
-
networkId
|
|
56
|
-
networkType?: string;
|
|
58
|
+
networkId: string;
|
|
57
59
|
};
|
|
58
60
|
export type CreateWalletDepositAddressResponse = Brand<BlockchainAddress, 'CreateWalletDepositAddressResponse'>;
|
package/dist/users/index.js
CHANGED
|
@@ -10,26 +10,35 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.UsersService = void 0;
|
|
13
|
+
const paginatedResponse_1 = require("../shared/paginatedResponse");
|
|
13
14
|
class UsersService {
|
|
14
15
|
constructor(client) {
|
|
15
16
|
this.client = client;
|
|
16
17
|
}
|
|
17
18
|
listUsers(request, options) {
|
|
18
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const queryParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
19
21
|
const response = yield this.client.request({
|
|
20
22
|
url: `entities/${request.entityId}/users`,
|
|
23
|
+
queryParams,
|
|
21
24
|
callOptions: options,
|
|
22
25
|
});
|
|
23
|
-
|
|
26
|
+
const responseData = response.data;
|
|
27
|
+
const paginationOptions = (0, paginatedResponse_1.getDefaultPaginationOptions)(this.client, options);
|
|
28
|
+
return (0, paginatedResponse_1.createPaginatedResponse)(responseData, this.listUsers.bind(this), request, paginatedResponse_1.ResponseExtractors.users, paginationOptions);
|
|
24
29
|
});
|
|
25
30
|
}
|
|
26
31
|
listPortfolioUsers(request, options) {
|
|
27
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const queryParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
28
34
|
const response = yield this.client.request({
|
|
29
35
|
url: `portfolios/${request.portfolioId}/users`,
|
|
36
|
+
queryParams,
|
|
30
37
|
callOptions: options,
|
|
31
38
|
});
|
|
32
|
-
|
|
39
|
+
const responseData = response.data;
|
|
40
|
+
const paginationOptions = (0, paginatedResponse_1.getDefaultPaginationOptions)(this.client, options);
|
|
41
|
+
return (0, paginatedResponse_1.createPaginatedResponse)(responseData, this.listPortfolioUsers.bind(this), request, paginatedResponse_1.ResponseExtractors.users, paginationOptions);
|
|
33
42
|
});
|
|
34
43
|
}
|
|
35
44
|
}
|
package/dist/wallets/index.js
CHANGED
|
@@ -26,17 +26,23 @@ exports.WalletsService = void 0;
|
|
|
26
26
|
* limitations under the License.
|
|
27
27
|
*/
|
|
28
28
|
const core_ts_1 = require("@coinbase-sample/core-ts");
|
|
29
|
+
const paginatedResponse_1 = require("../shared/paginatedResponse");
|
|
29
30
|
class WalletsService {
|
|
30
31
|
constructor(client) {
|
|
31
32
|
this.client = client;
|
|
32
33
|
}
|
|
33
34
|
listWallets(request, options) {
|
|
34
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
const queryParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
35
37
|
const response = yield this.client.request({
|
|
36
38
|
url: `portfolios/${request.portfolioId}/wallets`,
|
|
39
|
+
queryParams,
|
|
37
40
|
callOptions: options,
|
|
38
41
|
});
|
|
39
|
-
|
|
42
|
+
const responseData = response.data;
|
|
43
|
+
// Merge client defaults with call options
|
|
44
|
+
const paginationOptions = (0, paginatedResponse_1.getDefaultPaginationOptions)(this.client, options);
|
|
45
|
+
return (0, paginatedResponse_1.createPaginatedResponse)(responseData, this.listWallets.bind(this), request, paginatedResponse_1.ResponseExtractors.wallets, paginationOptions);
|
|
40
46
|
});
|
|
41
47
|
}
|
|
42
48
|
getWallet(request, options) {
|
|
@@ -69,25 +75,19 @@ class WalletsService {
|
|
|
69
75
|
}
|
|
70
76
|
listWalletAddresses(request, options) {
|
|
71
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
|
|
78
|
+
const queryParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
73
79
|
if (request.networkId) {
|
|
74
|
-
queryParams
|
|
75
|
-
}
|
|
76
|
-
if (request.networkType) {
|
|
77
|
-
queryParams['network.type'] = request.networkType;
|
|
78
|
-
}
|
|
79
|
-
if (request.cursor) {
|
|
80
|
-
queryParams.cursor = request.cursor;
|
|
81
|
-
}
|
|
82
|
-
if (request.limit) {
|
|
83
|
-
queryParams.limit = request.limit;
|
|
80
|
+
queryParams.networkId = request.networkId;
|
|
84
81
|
}
|
|
85
82
|
const response = yield this.client.request({
|
|
86
83
|
url: `portfolios/${request.portfolioId}/wallets/${request.walletId}/addresses`,
|
|
87
84
|
queryParams,
|
|
88
85
|
callOptions: options,
|
|
89
86
|
});
|
|
90
|
-
|
|
87
|
+
const responseData = response.data;
|
|
88
|
+
// Merge client defaults with call options
|
|
89
|
+
const paginationOptions = (0, paginatedResponse_1.getDefaultPaginationOptions)(this.client, options);
|
|
90
|
+
return (0, paginatedResponse_1.createPaginatedResponse)(responseData, this.listWalletAddresses.bind(this), request, paginatedResponse_1.ResponseExtractors.addresses, paginationOptions);
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
93
|
createWallet(request, options) {
|
|
@@ -104,16 +104,12 @@ class WalletsService {
|
|
|
104
104
|
}
|
|
105
105
|
createWalletDepositAddress(request, options) {
|
|
106
106
|
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
if (request.networkType) {
|
|
112
|
-
queryParams['network.type'] = request.networkType;
|
|
113
|
-
}
|
|
107
|
+
const bodyParams = {
|
|
108
|
+
networkId: request.networkId,
|
|
109
|
+
};
|
|
114
110
|
const response = yield this.client.request({
|
|
115
111
|
url: `portfolios/${request.portfolioId}/wallets/${request.walletId}/addresses`,
|
|
116
|
-
|
|
112
|
+
bodyParams,
|
|
117
113
|
method: core_ts_1.Method.POST,
|
|
118
114
|
callOptions: options,
|
|
119
115
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase-sample/prime-sdk-ts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/types/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -35,6 +35,6 @@
|
|
|
35
35
|
"typescript": "^5.8.3"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@coinbase-sample/core-ts": "^0.
|
|
38
|
+
"@coinbase-sample/core-ts": "^0.2.0"
|
|
39
39
|
}
|
|
40
40
|
}
|