@coinbase-sample/prime-sdk-ts 0.4.1 → 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 +19 -3
- 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 +4 -2
- 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/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
package/README.md
CHANGED
|
@@ -12,6 +12,28 @@ The _Prime Typescript SDK_ sample library is free and open source and released u
|
|
|
12
12
|
|
|
13
13
|
The application and code are only available for demonstration purposes.
|
|
14
14
|
|
|
15
|
+
## Pagination
|
|
16
|
+
|
|
17
|
+
When creating the client, you can now specify a maxItems and maxPages to help manage paginated responses.
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
const client = new CoinbasePrimeClient(credentials, undefined, { maxPages: 5, maxItems: 1000 });
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
These values can also be added on a per paginated request, such as:
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
const client = new CoinbasePrimeClient(credentials);
|
|
27
|
+
|
|
28
|
+
const service = new TransactionsService(client);
|
|
29
|
+
|
|
30
|
+
service
|
|
31
|
+
.listPortfolioTransactions(
|
|
32
|
+
{ portfolioId, limit: 100 },
|
|
33
|
+
{ maxPages: 20, maxItems: 1000 }
|
|
34
|
+
)
|
|
35
|
+
```
|
|
36
|
+
|
|
15
37
|
## Usage
|
|
16
38
|
|
|
17
39
|
Here are a few examples requests:
|
package/dist/activities/index.js
CHANGED
|
@@ -25,6 +25,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
25
25
|
};
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.ActivitiesService = void 0;
|
|
28
|
+
const paginatedResponse_1 = require("../shared/paginatedResponse");
|
|
28
29
|
class ActivitiesService {
|
|
29
30
|
constructor(client) {
|
|
30
31
|
this.client = client;
|
|
@@ -49,24 +50,59 @@ class ActivitiesService {
|
|
|
49
50
|
}
|
|
50
51
|
listEntityActivities(request, options) {
|
|
51
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
|
|
53
|
+
let queryParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
54
|
+
if (request.startTime) {
|
|
55
|
+
queryParams.startTime = new Date(request.startTime).toISOString();
|
|
56
|
+
}
|
|
57
|
+
if (request.endTime) {
|
|
58
|
+
queryParams.endTime = new Date(request.endTime).toISOString();
|
|
59
|
+
}
|
|
60
|
+
if (request.statuses) {
|
|
61
|
+
queryParams.statuses = request.statuses;
|
|
62
|
+
}
|
|
63
|
+
if (request.categories) {
|
|
64
|
+
queryParams.categories = request.categories;
|
|
65
|
+
}
|
|
66
|
+
if (request.symbols) {
|
|
67
|
+
queryParams.symbols = request.symbols;
|
|
68
|
+
}
|
|
69
|
+
if (request.activityLevel) {
|
|
70
|
+
queryParams.activityLevel = request.activityLevel;
|
|
71
|
+
}
|
|
53
72
|
const response = yield this.client.request({
|
|
54
73
|
url: `entities/${request.entityId}/activities`,
|
|
55
74
|
queryParams,
|
|
56
75
|
callOptions: options,
|
|
57
76
|
});
|
|
58
|
-
|
|
77
|
+
const paginationOptions = (0, paginatedResponse_1.getDefaultPaginationOptions)(this.client, options);
|
|
78
|
+
return (0, paginatedResponse_1.createPaginatedResponse)(response.data, this.listEntityActivities.bind(this), request, paginatedResponse_1.ResponseExtractors.activities, paginationOptions);
|
|
59
79
|
});
|
|
60
80
|
}
|
|
61
81
|
listPortfolioActivities(request, options) {
|
|
62
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
const queryParams =
|
|
83
|
+
const queryParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
84
|
+
if (request.startTime) {
|
|
85
|
+
queryParams.startTime = new Date(request.startTime).toISOString();
|
|
86
|
+
}
|
|
87
|
+
if (request.endTime) {
|
|
88
|
+
queryParams.endTime = new Date(request.endTime).toISOString();
|
|
89
|
+
}
|
|
90
|
+
if (request.statuses) {
|
|
91
|
+
queryParams.statuses = request.statuses;
|
|
92
|
+
}
|
|
93
|
+
if (request.categories) {
|
|
94
|
+
queryParams.categories = request.categories;
|
|
95
|
+
}
|
|
96
|
+
if (request.symbols) {
|
|
97
|
+
queryParams.symbols = request.symbols;
|
|
98
|
+
}
|
|
64
99
|
const response = yield this.client.request({
|
|
65
100
|
url: `portfolios/${request.portfolioId}/activities`,
|
|
66
101
|
queryParams,
|
|
67
102
|
callOptions: options,
|
|
68
103
|
});
|
|
69
|
-
|
|
104
|
+
const paginationOptions = (0, paginatedResponse_1.getDefaultPaginationOptions)(this.client, options);
|
|
105
|
+
return (0, paginatedResponse_1.createPaginatedResponse)(response.data, this.listPortfolioActivities.bind(this), request, paginatedResponse_1.ResponseExtractors.activities, paginationOptions);
|
|
70
106
|
});
|
|
71
107
|
}
|
|
72
108
|
}
|
|
@@ -26,19 +26,21 @@ exports.AddressBooksService = 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 AddressBooksService {
|
|
30
31
|
constructor(client) {
|
|
31
32
|
this.client = client;
|
|
32
33
|
}
|
|
33
34
|
listAddressBooks(request, options) {
|
|
34
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
const queryParams =
|
|
36
|
+
const queryParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
36
37
|
const response = yield this.client.request({
|
|
37
38
|
url: `portfolios/${request.portfolioId}/address_book`,
|
|
38
39
|
queryParams,
|
|
39
40
|
callOptions: options,
|
|
40
41
|
});
|
|
41
|
-
|
|
42
|
+
const paginationOptions = (0, paginatedResponse_1.getDefaultPaginationOptions)(this.client, options);
|
|
43
|
+
return (0, paginatedResponse_1.createPaginatedResponse)(response.data, this.listAddressBooks.bind(this), request, paginatedResponse_1.ResponseExtractors.addresses, paginationOptions);
|
|
42
44
|
});
|
|
43
45
|
}
|
|
44
46
|
createAddressBook(request, options) {
|
|
@@ -26,6 +26,7 @@ exports.AllocationService = 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 AllocationService {
|
|
30
31
|
constructor(client) {
|
|
31
32
|
this.client = client;
|
|
@@ -54,18 +55,33 @@ class AllocationService {
|
|
|
54
55
|
}
|
|
55
56
|
listPortfolioAllocations(request, options) {
|
|
56
57
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
|
|
58
|
+
let queryParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
59
|
+
if (request.startDate) {
|
|
60
|
+
queryParams.startDate = new Date(request.startDate).toISOString();
|
|
61
|
+
}
|
|
62
|
+
if (request.endDate) {
|
|
63
|
+
queryParams.endDate = new Date(request.endDate).toISOString();
|
|
64
|
+
}
|
|
65
|
+
if (request.productIds) {
|
|
66
|
+
queryParams.productIds = request.productIds;
|
|
67
|
+
}
|
|
68
|
+
if (request.orderSide) {
|
|
69
|
+
queryParams.orderSide = request.orderSide;
|
|
70
|
+
}
|
|
58
71
|
const response = yield this.client.request({
|
|
59
72
|
url: `portfolios/${request.portfolioId}/allocations`,
|
|
60
73
|
queryParams,
|
|
61
74
|
callOptions: options,
|
|
62
75
|
});
|
|
63
|
-
|
|
76
|
+
const paginationOptions = (0, paginatedResponse_1.getDefaultPaginationOptions)(this.client, options);
|
|
77
|
+
return (0, paginatedResponse_1.createPaginatedResponse)(response.data, this.listPortfolioAllocations.bind(this), request, paginatedResponse_1.ResponseExtractors.allocations, paginationOptions);
|
|
64
78
|
});
|
|
65
79
|
}
|
|
66
80
|
listNetAllocations(request, options) {
|
|
67
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
const queryParams =
|
|
82
|
+
const queryParams = {
|
|
83
|
+
allocationId: request.allocationId,
|
|
84
|
+
};
|
|
69
85
|
const response = yield this.client.request({
|
|
70
86
|
url: `portfolios/${request.portfolioId}/allocations/net/${request.nettingId}`,
|
|
71
87
|
queryParams,
|
package/dist/balances/index.js
CHANGED
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.BalancesService = void 0;
|
|
13
|
+
const paginatedResponse_1 = require("../shared/paginatedResponse");
|
|
13
14
|
class BalancesService {
|
|
14
15
|
constructor(client) {
|
|
15
16
|
this.client = client;
|
|
@@ -28,7 +29,7 @@ class BalancesService {
|
|
|
28
29
|
getWalletBalance(request, options) {
|
|
29
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30
31
|
const response = yield this.client.request({
|
|
31
|
-
url: `portfolios/${request.portfolioId}/wallets/${request.walletId}
|
|
32
|
+
url: `portfolios/${request.portfolioId}/wallets/${request.walletId}/balance`,
|
|
32
33
|
callOptions: options,
|
|
33
34
|
});
|
|
34
35
|
return response.data;
|
|
@@ -36,24 +37,35 @@ class BalancesService {
|
|
|
36
37
|
}
|
|
37
38
|
listOnchainWalletBalances(request, options) {
|
|
38
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
|
|
40
|
+
let queryParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
41
|
+
if (request.visibilityStatuses) {
|
|
42
|
+
queryParams.visibilityStatuses = request.visibilityStatuses;
|
|
43
|
+
}
|
|
40
44
|
const response = yield this.client.request({
|
|
41
45
|
url: `portfolios/${request.portfolioId}/wallets/${request.walletId}/web3_balances`,
|
|
42
46
|
queryParams,
|
|
43
47
|
callOptions: options,
|
|
44
48
|
});
|
|
45
|
-
|
|
49
|
+
const paginationOptions = (0, paginatedResponse_1.getDefaultPaginationOptions)(this.client, options);
|
|
50
|
+
return (0, paginatedResponse_1.createPaginatedResponse)(response.data, this.listOnchainWalletBalances.bind(this), request, paginatedResponse_1.ResponseExtractors.balances, paginationOptions);
|
|
46
51
|
});
|
|
47
52
|
}
|
|
48
53
|
listEntityBalances(request, options) {
|
|
49
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
|
|
55
|
+
let queryParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
56
|
+
if (request.symbols) {
|
|
57
|
+
queryParams.symbols = request.symbols;
|
|
58
|
+
}
|
|
59
|
+
if (request.aggregationType) {
|
|
60
|
+
queryParams.aggregationType = request.aggregationType;
|
|
61
|
+
}
|
|
51
62
|
const response = yield this.client.request({
|
|
52
63
|
url: `entities/${request.entityId}/balances`,
|
|
53
64
|
queryParams,
|
|
54
65
|
callOptions: options,
|
|
55
66
|
});
|
|
56
|
-
|
|
67
|
+
const paginationOptions = (0, paginatedResponse_1.getDefaultPaginationOptions)(this.client, options);
|
|
68
|
+
return (0, paginatedResponse_1.createPaginatedResponse)(response.data, this.listEntityBalances.bind(this), request, paginatedResponse_1.ResponseExtractors.balances, paginationOptions);
|
|
57
69
|
});
|
|
58
70
|
}
|
|
59
71
|
}
|
package/dist/client.js
CHANGED
|
@@ -20,8 +20,13 @@ const core_ts_1 = require("@coinbase-sample/core-ts");
|
|
|
20
20
|
const constants_1 = require("./constants");
|
|
21
21
|
const toCamelCase_1 = require("./shared/toCamelCase");
|
|
22
22
|
class CoinbasePrimeClient extends core_ts_1.CoinbaseClient {
|
|
23
|
-
constructor(credentials, apiBasePath) {
|
|
24
|
-
|
|
23
|
+
constructor(credentials, apiBasePath, options) {
|
|
24
|
+
const defaultClientOptions = Object.assign({ defaultLimit: constants_1.DEFAULT_PAGINATION_LIMIT, maxPages: constants_1.DEFAULT_MAX_PAGES, maxItems: constants_1.DEFAULT_MAX_ITEMS }, options);
|
|
25
|
+
let basePath = constants_1.API_BASE_PATH;
|
|
26
|
+
if (apiBasePath && apiBasePath.length > 0) {
|
|
27
|
+
basePath = apiBasePath;
|
|
28
|
+
}
|
|
29
|
+
super(basePath, credentials, constants_1.USER_AGENT, defaultClientOptions);
|
|
25
30
|
// transform the response data to camelCase
|
|
26
31
|
this.addTransformResponse((response) => {
|
|
27
32
|
return Object.assign(Object.assign({}, response), { data: (0, toCamelCase_1.toCamelCase)(response.data) });
|
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CB_ACCESS_TIMESTAMP_HEADER = exports.CB_ACCESS_SIGNATURE_HEADER = exports.CB_ACCESS_PHRASE_HEADER = exports.CB_ACCESS_KEY_HEADER = exports.USER_AGENT = exports.API_BASE_PATH = exports.VERSION = void 0;
|
|
3
|
+
exports.DEFAULT_MAX_ITEMS = exports.DEFAULT_MAX_PAGES = exports.DEFAULT_PAGINATION_LIMIT = exports.CB_ACCESS_TIMESTAMP_HEADER = exports.CB_ACCESS_SIGNATURE_HEADER = exports.CB_ACCESS_PHRASE_HEADER = exports.CB_ACCESS_KEY_HEADER = exports.USER_AGENT = exports.API_BASE_PATH = exports.VERSION = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Copyright 2024-present Coinbase Global, Inc.
|
|
6
6
|
*
|
|
@@ -23,3 +23,6 @@ exports.CB_ACCESS_KEY_HEADER = 'X-CB-ACCESS-KEY';
|
|
|
23
23
|
exports.CB_ACCESS_PHRASE_HEADER = 'X-CB-ACCESS-PASSPHRASE';
|
|
24
24
|
exports.CB_ACCESS_SIGNATURE_HEADER = 'X-CB-ACCESS-SIGNATURE';
|
|
25
25
|
exports.CB_ACCESS_TIMESTAMP_HEADER = 'X-CB-ACCESS-TIMESTAMP';
|
|
26
|
+
exports.DEFAULT_PAGINATION_LIMIT = 25;
|
|
27
|
+
exports.DEFAULT_MAX_PAGES = 100;
|
|
28
|
+
exports.DEFAULT_MAX_ITEMS = 10000;
|
package/dist/invoices/index.js
CHANGED
|
@@ -10,17 +10,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.InvoicesService = void 0;
|
|
13
|
+
const paginatedResponse_1 = require("../shared/paginatedResponse");
|
|
13
14
|
class InvoicesService {
|
|
14
15
|
constructor(client) {
|
|
15
16
|
this.client = client;
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
+
listInvoices(request, options) {
|
|
18
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
let queryParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
21
|
+
if (request.states) {
|
|
22
|
+
queryParams.states = request.states;
|
|
23
|
+
}
|
|
24
|
+
if (request.billingYear) {
|
|
25
|
+
queryParams.billingYear = request.billingYear;
|
|
26
|
+
}
|
|
27
|
+
if (request.billingMonth) {
|
|
28
|
+
queryParams.billingMonth = request.billingMonth;
|
|
29
|
+
}
|
|
19
30
|
const response = yield this.client.request({
|
|
20
|
-
url: `entities/${request.entityId}/
|
|
31
|
+
url: `entities/${request.entityId}/invoices`,
|
|
32
|
+
queryParams,
|
|
21
33
|
callOptions: options,
|
|
22
34
|
});
|
|
23
|
-
|
|
35
|
+
const paginationOptions = (0, paginatedResponse_1.getDefaultPaginationOptions)(this.client, options);
|
|
36
|
+
return (0, paginatedResponse_1.createPaginatedResponse)(response.data, this.listInvoices.bind(this), request, paginatedResponse_1.ResponseExtractors.invoices, paginationOptions);
|
|
24
37
|
});
|
|
25
38
|
}
|
|
26
39
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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 });
|
|
@@ -0,0 +1,21 @@
|
|
|
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 });
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.TransactionStatus = void 0;
|
|
23
23
|
/**
|
|
24
|
-
* - 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.
|
|
24
|
+
* - 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
|
|
25
25
|
*/
|
|
26
26
|
var TransactionStatus;
|
|
27
27
|
(function (TransactionStatus) {
|
package/dist/orders/index.js
CHANGED
|
@@ -26,6 +26,7 @@ exports.OrdersService = 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 OrdersService {
|
|
30
31
|
constructor(client) {
|
|
31
32
|
this.client = client;
|
|
@@ -41,46 +42,89 @@ class OrdersService {
|
|
|
41
42
|
}
|
|
42
43
|
listPortfolioFills(request, options) {
|
|
43
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
|
|
45
|
+
let queryParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
46
|
+
if (request.startDate) {
|
|
47
|
+
queryParams.startDate = new Date(request.startDate).toISOString();
|
|
48
|
+
}
|
|
49
|
+
if (request.endDate) {
|
|
50
|
+
queryParams.endDate = new Date(request.endDate).toISOString();
|
|
51
|
+
}
|
|
45
52
|
const response = yield this.client.request({
|
|
46
53
|
url: `portfolios/${request.portfolioId}/fills`,
|
|
47
54
|
queryParams,
|
|
48
55
|
callOptions: options,
|
|
49
56
|
});
|
|
50
|
-
|
|
57
|
+
const paginationOptions = (0, paginatedResponse_1.getDefaultPaginationOptions)(this.client, options);
|
|
58
|
+
return (0, paginatedResponse_1.createPaginatedResponse)(response.data, this.listPortfolioFills.bind(this), request, paginatedResponse_1.ResponseExtractors.fills, paginationOptions);
|
|
51
59
|
});
|
|
52
60
|
}
|
|
53
61
|
listPortfolioOrders(request, options) {
|
|
54
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
|
|
63
|
+
let queryParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
64
|
+
if (request.orderStatuses) {
|
|
65
|
+
queryParams.orderStatuses = request.orderStatuses;
|
|
66
|
+
}
|
|
67
|
+
if (request.productIds) {
|
|
68
|
+
queryParams.productIds = request.productIds;
|
|
69
|
+
}
|
|
70
|
+
if (request.orderType) {
|
|
71
|
+
queryParams.orderType = request.orderType;
|
|
72
|
+
}
|
|
73
|
+
if (request.orderSide) {
|
|
74
|
+
queryParams.orderSide = request.orderSide;
|
|
75
|
+
}
|
|
76
|
+
if (request.startDate) {
|
|
77
|
+
queryParams.startDate = new Date(request.startDate).toISOString();
|
|
78
|
+
}
|
|
79
|
+
if (request.endDate) {
|
|
80
|
+
queryParams.endDate = new Date(request.endDate).toISOString();
|
|
81
|
+
}
|
|
56
82
|
const response = yield this.client.request({
|
|
57
83
|
url: `portfolios/${request.portfolioId}/orders`,
|
|
58
84
|
queryParams,
|
|
59
85
|
callOptions: options,
|
|
60
86
|
});
|
|
61
|
-
|
|
87
|
+
const paginationOptions = (0, paginatedResponse_1.getDefaultPaginationOptions)(this.client, options);
|
|
88
|
+
return (0, paginatedResponse_1.createPaginatedResponse)(response.data, this.listPortfolioOrders.bind(this), request, paginatedResponse_1.ResponseExtractors.orders, paginationOptions);
|
|
62
89
|
});
|
|
63
90
|
}
|
|
64
91
|
listOrderFills(request, options) {
|
|
65
92
|
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
const queryParams =
|
|
93
|
+
const queryParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
67
94
|
const response = yield this.client.request({
|
|
68
95
|
url: `portfolios/${request.portfolioId}/orders/${request.orderId}/fills`,
|
|
69
96
|
queryParams,
|
|
70
97
|
callOptions: options,
|
|
71
98
|
});
|
|
72
|
-
|
|
99
|
+
const paginationOptions = (0, paginatedResponse_1.getDefaultPaginationOptions)(this.client, options);
|
|
100
|
+
return (0, paginatedResponse_1.createPaginatedResponse)(response.data, this.listOrderFills.bind(this), request, paginatedResponse_1.ResponseExtractors.fills, paginationOptions);
|
|
73
101
|
});
|
|
74
102
|
}
|
|
75
103
|
listOpenOrders(request, options) {
|
|
76
104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
|
|
105
|
+
let queryParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
106
|
+
if (request.productIds) {
|
|
107
|
+
queryParams.productIds = request.productIds;
|
|
108
|
+
}
|
|
109
|
+
if (request.orderType) {
|
|
110
|
+
queryParams.orderType = request.orderType;
|
|
111
|
+
}
|
|
112
|
+
if (request.orderSide) {
|
|
113
|
+
queryParams.orderSide = request.orderSide;
|
|
114
|
+
}
|
|
115
|
+
if (request.startDate) {
|
|
116
|
+
queryParams.startDate = new Date(request.startDate).toISOString();
|
|
117
|
+
}
|
|
118
|
+
if (request.endDate) {
|
|
119
|
+
queryParams.endDate = new Date(request.endDate).toISOString();
|
|
120
|
+
}
|
|
78
121
|
const response = yield this.client.request({
|
|
79
122
|
url: `portfolios/${request.portfolioId}/open_orders`,
|
|
80
123
|
queryParams,
|
|
81
124
|
callOptions: options,
|
|
82
125
|
});
|
|
83
|
-
|
|
126
|
+
const paginationOptions = (0, paginatedResponse_1.getDefaultPaginationOptions)(this.client, options);
|
|
127
|
+
return (0, paginatedResponse_1.createPaginatedResponse)(response.data, this.listOpenOrders.bind(this), request, paginatedResponse_1.ResponseExtractors.orders, paginationOptions);
|
|
84
128
|
});
|
|
85
129
|
}
|
|
86
130
|
createOrderPreview(request, options) {
|
package/dist/portfolios/types.js
CHANGED
|
@@ -1,2 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2024-present Coinbase Global, Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
2
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
package/dist/positions/index.js
CHANGED
|
@@ -10,30 +10,33 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.PositionsService = void 0;
|
|
13
|
+
const paginatedResponse_1 = require("../shared/paginatedResponse");
|
|
13
14
|
class PositionsService {
|
|
14
15
|
constructor(client) {
|
|
15
16
|
this.client = client;
|
|
16
17
|
}
|
|
17
18
|
listAggregateEntityPositions(request, options) {
|
|
18
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
const queryParams =
|
|
20
|
+
const queryParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
20
21
|
const response = yield this.client.request({
|
|
21
|
-
url: `
|
|
22
|
+
url: `entities/${request.entityId}/aggregate_positions`,
|
|
22
23
|
callOptions: options,
|
|
23
24
|
queryParams,
|
|
24
25
|
});
|
|
25
|
-
|
|
26
|
+
const paginationOptions = (0, paginatedResponse_1.getDefaultPaginationOptions)(this.client, options);
|
|
27
|
+
return (0, paginatedResponse_1.createPaginatedResponse)(response.data, this.listAggregateEntityPositions.bind(this), request, paginatedResponse_1.ResponseExtractors.positions, paginationOptions);
|
|
26
28
|
});
|
|
27
29
|
}
|
|
28
30
|
listEntityPositions(request, options) {
|
|
29
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
const queryParams =
|
|
32
|
+
const queryParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
31
33
|
const response = yield this.client.request({
|
|
32
|
-
url: `
|
|
34
|
+
url: `entities/${request.entityId}/positions`,
|
|
33
35
|
callOptions: options,
|
|
34
36
|
queryParams,
|
|
35
37
|
});
|
|
36
|
-
|
|
38
|
+
const paginationOptions = (0, paginatedResponse_1.getDefaultPaginationOptions)(this.client, options);
|
|
39
|
+
return (0, paginatedResponse_1.createPaginatedResponse)(response.data, this.listEntityPositions.bind(this), request, paginatedResponse_1.ResponseExtractors.positions, paginationOptions);
|
|
37
40
|
});
|
|
38
41
|
}
|
|
39
42
|
}
|
package/dist/products/index.js
CHANGED
|
@@ -10,19 +10,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.ProductsService = void 0;
|
|
13
|
+
const paginatedResponse_1 = require("../shared/paginatedResponse");
|
|
13
14
|
class ProductsService {
|
|
14
15
|
constructor(client) {
|
|
15
16
|
this.client = client;
|
|
16
17
|
}
|
|
17
18
|
listProducts(request, options) {
|
|
18
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
const queryParams =
|
|
20
|
+
const queryParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
20
21
|
const response = yield this.client.request({
|
|
21
22
|
url: `portfolios/${request.portfolioId}/products`,
|
|
22
23
|
queryParams,
|
|
23
24
|
callOptions: options,
|
|
24
25
|
});
|
|
25
|
-
|
|
26
|
+
const paginationOptions = (0, paginatedResponse_1.getDefaultPaginationOptions)(this.client, options);
|
|
27
|
+
return (0, paginatedResponse_1.createPaginatedResponse)(response.data, this.listProducts.bind(this), request, paginatedResponse_1.ResponseExtractors.products, paginationOptions);
|
|
26
28
|
});
|
|
27
29
|
}
|
|
28
30
|
}
|
package/dist/shared/brand.js
CHANGED
|
@@ -1,2 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2025-present Coinbase Global, Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
2
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|