@coinbase-sample/prime-sdk-ts 0.6.1 → 0.6.3
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 +207 -67
- package/dist/activities/index.js +21 -39
- package/dist/addressBooks/index.js +18 -5
- package/dist/allocations/index.js +19 -18
- package/dist/balances/index.js +23 -17
- package/dist/client-manual.js +84 -0
- package/dist/client-modular.js +57 -0
- package/dist/client-only.js +31 -0
- package/dist/{client.js → clients/client.js} +12 -2
- package/dist/clients/clientWithServices.js +323 -0
- package/dist/{types/client.d.ts → clients/clientWithServicesTypes.js} +3 -6
- package/dist/clients/index.js +28 -0
- package/dist/clients/types.js +2 -0
- package/dist/constants.js +1 -1
- package/dist/financing/index.js +16 -3
- package/dist/futures/index.js +4 -4
- package/dist/index.js +27 -18
- package/dist/invoices/index.js +16 -12
- package/dist/onchainAddressBook/index.js +4 -4
- package/dist/orders/index.js +38 -58
- package/dist/positions/index.js +21 -6
- package/dist/products/index.js +16 -3
- package/dist/services.js +75 -0
- package/dist/shared/envUtils.js +66 -0
- package/dist/shared/paginatedResponse.js +3 -0
- package/dist/staking/index.js +5 -5
- package/dist/transactions/index.js +26 -17
- package/dist/types/activities/index.d.ts +2 -3
- package/dist/types/addressBooks/index.d.ts +2 -3
- package/dist/types/allocations/index.d.ts +2 -3
- package/dist/types/assets/index.d.ts +2 -3
- package/dist/types/balances/index.d.ts +2 -3
- package/dist/types/client-manual.d.ts +58 -0
- package/dist/types/client-modular.d.ts +39 -0
- package/dist/types/client-only.d.ts +18 -0
- package/dist/types/clients/client.d.ts +27 -0
- package/dist/types/clients/clientWithServices.d.ts +229 -0
- package/dist/types/clients/clientWithServicesTypes.d.ts +115 -0
- package/dist/types/clients/index.d.ts +19 -0
- package/dist/types/clients/types.d.ts +48 -0
- package/dist/types/commission/index.d.ts +2 -3
- package/dist/types/constants.d.ts +1 -1
- package/dist/types/financing/index.d.ts +2 -3
- package/dist/types/futures/index.d.ts +2 -3
- package/dist/types/index.d.ts +2 -1
- package/dist/types/invoices/index.d.ts +2 -3
- package/dist/types/onchainAddressBook/index.d.ts +2 -3
- package/dist/types/orders/index.d.ts +2 -3
- package/dist/types/paymentMethods/index.d.ts +2 -3
- package/dist/types/portfolios/index.d.ts +2 -3
- package/dist/types/positions/index.d.ts +2 -3
- package/dist/types/products/index.d.ts +2 -3
- package/dist/types/services.d.ts +39 -0
- package/dist/types/shared/envUtils.d.ts +36 -0
- package/dist/types/shared/paginatedResponse.d.ts +5 -4
- package/dist/types/staking/index.d.ts +2 -3
- package/dist/types/transactions/index.d.ts +2 -3
- package/dist/types/types.d.ts +37 -0
- package/dist/types/users/index.d.ts +2 -3
- package/dist/types/wallets/index.d.ts +2 -3
- package/dist/types.js +39 -0
- package/dist/users/index.js +21 -6
- package/dist/wallets/index.js +24 -12
- package/package.json +32 -1
package/dist/index.js
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.WalletsService = exports.UsersService = exports.TransactionsService = exports.StakingService = exports.ProductsService = exports.PositionsService = exports.PortfoliosService = exports.PaymentMethodsService = exports.OrdersService = exports.OnchainAddressBookService = exports.InvoicesService = exports.FuturesService = exports.FinancingService = exports.CommissionService = exports.BalancesService = exports.AssetsService = exports.AllocationService = exports.AddressBooksService = exports.ActivitiesService = exports.CoinbasePrimeCredentials = exports.CoinbasePrimeClient = void 0;
|
|
18
2
|
/**
|
|
19
3
|
* Copyright 2024-present Coinbase Global, Inc.
|
|
20
4
|
*
|
|
@@ -30,10 +14,35 @@ exports.WalletsService = exports.UsersService = exports.TransactionsService = ex
|
|
|
30
14
|
* See the License for the specific language governing permissions and
|
|
31
15
|
* limitations under the License.
|
|
32
16
|
*/
|
|
33
|
-
var
|
|
34
|
-
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
24
|
+
}) : (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
o[k2] = m[k];
|
|
27
|
+
}));
|
|
28
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
29
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.WalletsService = exports.UsersService = exports.TransactionsService = exports.StakingService = exports.ProductsService = exports.PositionsService = exports.PortfoliosService = exports.PaymentMethodsService = exports.OrdersService = exports.OnchainAddressBookService = exports.InvoicesService = exports.FuturesService = exports.FinancingService = exports.CommissionService = exports.BalancesService = exports.AssetsService = exports.AllocationService = exports.AddressBooksService = exports.ActivitiesService = exports.createCredentialsFromEnv = exports.CoinbasePrimeCredentials = exports.CoinbasePrimeClient = exports.CoinbasePrimeClientWithServices = exports.CoinbaseError = exports.CoinbaseClientException = exports.Method = exports.CoinbaseClient = void 0;
|
|
33
|
+
// Re-export commonly used core-ts objects for convenience
|
|
34
|
+
// This allows users to import everything from a single package
|
|
35
|
+
var clients_1 = require("./clients");
|
|
36
|
+
Object.defineProperty(exports, "CoinbaseClient", { enumerable: true, get: function () { return clients_1.CoinbaseClient; } });
|
|
37
|
+
Object.defineProperty(exports, "Method", { enumerable: true, get: function () { return clients_1.Method; } });
|
|
38
|
+
Object.defineProperty(exports, "CoinbaseClientException", { enumerable: true, get: function () { return clients_1.CoinbaseClientException; } });
|
|
39
|
+
Object.defineProperty(exports, "CoinbaseError", { enumerable: true, get: function () { return clients_1.CoinbaseError; } });
|
|
40
|
+
Object.defineProperty(exports, "CoinbasePrimeClientWithServices", { enumerable: true, get: function () { return clients_1.CoinbasePrimeClientWithServices; } });
|
|
41
|
+
Object.defineProperty(exports, "CoinbasePrimeClient", { enumerable: true, get: function () { return clients_1.CoinbasePrimeClient; } });
|
|
35
42
|
var credentials_1 = require("./credentials");
|
|
36
43
|
Object.defineProperty(exports, "CoinbasePrimeCredentials", { enumerable: true, get: function () { return credentials_1.CoinbasePrimeCredentials; } });
|
|
44
|
+
var envUtils_1 = require("./shared/envUtils");
|
|
45
|
+
Object.defineProperty(exports, "createCredentialsFromEnv", { enumerable: true, get: function () { return envUtils_1.createCredentialsFromEnv; } });
|
|
37
46
|
var activities_1 = require("./activities");
|
|
38
47
|
Object.defineProperty(exports, "ActivitiesService", { enumerable: true, get: function () { return activities_1.ActivitiesService; } });
|
|
39
48
|
var addressBooks_1 = require("./addressBooks");
|
package/dist/invoices/index.js
CHANGED
|
@@ -8,6 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
11
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
23
|
exports.InvoicesService = void 0;
|
|
13
24
|
const paginatedResponse_1 = require("../shared/paginatedResponse");
|
|
@@ -17,19 +28,12 @@ class InvoicesService {
|
|
|
17
28
|
}
|
|
18
29
|
listInvoices(request, options) {
|
|
19
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
if (request.billingYear) {
|
|
25
|
-
queryParams.billingYear = request.billingYear;
|
|
26
|
-
}
|
|
27
|
-
if (request.billingMonth) {
|
|
28
|
-
queryParams.billingMonth = request.billingMonth;
|
|
29
|
-
}
|
|
31
|
+
const paginationParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
32
|
+
const { limit, cursor, sortDirection, entityId } = request, queryParams = __rest(request, ["limit", "cursor", "sortDirection", "entityId"]);
|
|
33
|
+
const finalQueryParams = Object.assign(Object.assign({}, paginationParams), queryParams);
|
|
30
34
|
const response = yield this.client.request({
|
|
31
|
-
url: `entities/${
|
|
32
|
-
queryParams,
|
|
35
|
+
url: `entities/${entityId}/invoices`,
|
|
36
|
+
queryParams: finalQueryParams,
|
|
33
37
|
callOptions: options,
|
|
34
38
|
});
|
|
35
39
|
const paginationOptions = (0, paginatedResponse_1.getDefaultPaginationOptions)(this.client, options);
|
|
@@ -25,7 +25,7 @@ exports.OnchainAddressBookService = void 0;
|
|
|
25
25
|
* See the License for the specific language governing permissions and
|
|
26
26
|
* limitations under the License.
|
|
27
27
|
*/
|
|
28
|
-
const
|
|
28
|
+
const clients_1 = require("../clients");
|
|
29
29
|
class OnchainAddressBookService {
|
|
30
30
|
constructor(client) {
|
|
31
31
|
this.client = client;
|
|
@@ -44,7 +44,7 @@ class OnchainAddressBookService {
|
|
|
44
44
|
const response = yield this.client.request({
|
|
45
45
|
url: `portfolios/${request.portfolioId}/onchain_address_group`,
|
|
46
46
|
bodyParams: Object.assign(Object.assign({}, request), { portfolioId: undefined }),
|
|
47
|
-
method:
|
|
47
|
+
method: clients_1.Method.POST,
|
|
48
48
|
callOptions: options,
|
|
49
49
|
});
|
|
50
50
|
return response.data;
|
|
@@ -55,7 +55,7 @@ class OnchainAddressBookService {
|
|
|
55
55
|
const response = yield this.client.request({
|
|
56
56
|
url: `portfolios/${request.portfolioId}/onchain_address_group`,
|
|
57
57
|
bodyParams: Object.assign(Object.assign({}, request), { portfolioId: undefined }),
|
|
58
|
-
method:
|
|
58
|
+
method: clients_1.Method.PUT,
|
|
59
59
|
callOptions: options,
|
|
60
60
|
});
|
|
61
61
|
return response.data;
|
|
@@ -65,7 +65,7 @@ class OnchainAddressBookService {
|
|
|
65
65
|
return __awaiter(this, void 0, void 0, function* () {
|
|
66
66
|
const response = yield this.client.request({
|
|
67
67
|
url: `portfolios/${request.portfolioId}/onchain_address_group/${request.addressGroupId}`,
|
|
68
|
-
method:
|
|
68
|
+
method: clients_1.Method.DELETE,
|
|
69
69
|
callOptions: options,
|
|
70
70
|
});
|
|
71
71
|
return response.data;
|
package/dist/orders/index.js
CHANGED
|
@@ -8,6 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
11
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
23
|
exports.OrdersService = void 0;
|
|
13
24
|
/**
|
|
@@ -25,7 +36,7 @@ exports.OrdersService = void 0;
|
|
|
25
36
|
* See the License for the specific language governing permissions and
|
|
26
37
|
* limitations under the License.
|
|
27
38
|
*/
|
|
28
|
-
const
|
|
39
|
+
const clients_1 = require("../clients");
|
|
29
40
|
const paginatedResponse_1 = require("../shared/paginatedResponse");
|
|
30
41
|
class OrdersService {
|
|
31
42
|
constructor(client) {
|
|
@@ -53,16 +64,12 @@ class OrdersService {
|
|
|
53
64
|
}
|
|
54
65
|
listPortfolioFills(request, options) {
|
|
55
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
if (request.endDate) {
|
|
61
|
-
queryParams.endDate = new Date(request.endDate).toISOString();
|
|
62
|
-
}
|
|
67
|
+
const paginationParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
68
|
+
const { limit, cursor, sortDirection, portfolioId } = request, queryParams = __rest(request, ["limit", "cursor", "sortDirection", "portfolioId"]);
|
|
69
|
+
const finalQueryParams = Object.assign(Object.assign({}, paginationParams), queryParams);
|
|
63
70
|
const response = yield this.client.request({
|
|
64
|
-
url: `portfolios/${
|
|
65
|
-
queryParams,
|
|
71
|
+
url: `portfolios/${portfolioId}/fills`,
|
|
72
|
+
queryParams: finalQueryParams,
|
|
66
73
|
callOptions: options,
|
|
67
74
|
});
|
|
68
75
|
const paginationOptions = (0, paginatedResponse_1.getDefaultPaginationOptions)(this.client, options);
|
|
@@ -71,28 +78,12 @@ class OrdersService {
|
|
|
71
78
|
}
|
|
72
79
|
listPortfolioOrders(request, options) {
|
|
73
80
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
if (request.productIds) {
|
|
79
|
-
queryParams.productIds = request.productIds;
|
|
80
|
-
}
|
|
81
|
-
if (request.orderType) {
|
|
82
|
-
queryParams.orderType = request.orderType;
|
|
83
|
-
}
|
|
84
|
-
if (request.orderSide) {
|
|
85
|
-
queryParams.orderSide = request.orderSide;
|
|
86
|
-
}
|
|
87
|
-
if (request.startDate) {
|
|
88
|
-
queryParams.startDate = new Date(request.startDate).toISOString();
|
|
89
|
-
}
|
|
90
|
-
if (request.endDate) {
|
|
91
|
-
queryParams.endDate = new Date(request.endDate).toISOString();
|
|
92
|
-
}
|
|
81
|
+
const paginationParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
82
|
+
const { limit, cursor, sortDirection, portfolioId } = request, queryParams = __rest(request, ["limit", "cursor", "sortDirection", "portfolioId"]);
|
|
83
|
+
const finalQueryParams = Object.assign(Object.assign({}, paginationParams), queryParams);
|
|
93
84
|
const response = yield this.client.request({
|
|
94
|
-
url: `portfolios/${
|
|
95
|
-
queryParams,
|
|
85
|
+
url: `portfolios/${portfolioId}/orders`,
|
|
86
|
+
queryParams: finalQueryParams,
|
|
96
87
|
callOptions: options,
|
|
97
88
|
});
|
|
98
89
|
const paginationOptions = (0, paginatedResponse_1.getDefaultPaginationOptions)(this.client, options);
|
|
@@ -101,10 +92,12 @@ class OrdersService {
|
|
|
101
92
|
}
|
|
102
93
|
listOrderFills(request, options) {
|
|
103
94
|
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
-
const
|
|
95
|
+
const paginationParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
96
|
+
const { limit, cursor, sortDirection, portfolioId, orderId } = request, queryParams = __rest(request, ["limit", "cursor", "sortDirection", "portfolioId", "orderId"]);
|
|
97
|
+
const finalQueryParams = Object.assign(Object.assign({}, paginationParams), queryParams);
|
|
105
98
|
const response = yield this.client.request({
|
|
106
|
-
url: `portfolios/${
|
|
107
|
-
queryParams,
|
|
99
|
+
url: `portfolios/${portfolioId}/orders/${orderId}/fills`,
|
|
100
|
+
queryParams: finalQueryParams,
|
|
108
101
|
callOptions: options,
|
|
109
102
|
});
|
|
110
103
|
const paginationOptions = (0, paginatedResponse_1.getDefaultPaginationOptions)(this.client, options);
|
|
@@ -113,25 +106,12 @@ class OrdersService {
|
|
|
113
106
|
}
|
|
114
107
|
listOpenOrders(request, options) {
|
|
115
108
|
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
if (request.orderType) {
|
|
121
|
-
queryParams.orderType = request.orderType;
|
|
122
|
-
}
|
|
123
|
-
if (request.orderSide) {
|
|
124
|
-
queryParams.orderSide = request.orderSide;
|
|
125
|
-
}
|
|
126
|
-
if (request.startDate) {
|
|
127
|
-
queryParams.startDate = new Date(request.startDate).toISOString();
|
|
128
|
-
}
|
|
129
|
-
if (request.endDate) {
|
|
130
|
-
queryParams.endDate = new Date(request.endDate).toISOString();
|
|
131
|
-
}
|
|
109
|
+
const paginationParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
110
|
+
const { limit, cursor, sortDirection, portfolioId } = request, queryParams = __rest(request, ["limit", "cursor", "sortDirection", "portfolioId"]);
|
|
111
|
+
const finalQueryParams = Object.assign(Object.assign({}, paginationParams), queryParams);
|
|
132
112
|
const response = yield this.client.request({
|
|
133
|
-
url: `portfolios/${
|
|
134
|
-
queryParams,
|
|
113
|
+
url: `portfolios/${portfolioId}/open_orders`,
|
|
114
|
+
queryParams: finalQueryParams,
|
|
135
115
|
callOptions: options,
|
|
136
116
|
});
|
|
137
117
|
const paginationOptions = (0, paginatedResponse_1.getDefaultPaginationOptions)(this.client, options);
|
|
@@ -141,8 +121,8 @@ class OrdersService {
|
|
|
141
121
|
createOrderPreview(request, options) {
|
|
142
122
|
return __awaiter(this, void 0, void 0, function* () {
|
|
143
123
|
const response = yield this.client.request({
|
|
144
|
-
url: `portfolios/${request.portfolioId}/
|
|
145
|
-
method:
|
|
124
|
+
url: `portfolios/${request.portfolioId}/order_preview`,
|
|
125
|
+
method: clients_1.Method.POST,
|
|
146
126
|
bodyParams: request,
|
|
147
127
|
callOptions: options,
|
|
148
128
|
});
|
|
@@ -153,7 +133,7 @@ class OrdersService {
|
|
|
153
133
|
return __awaiter(this, void 0, void 0, function* () {
|
|
154
134
|
const response = yield this.client.request({
|
|
155
135
|
url: `portfolios/${request.portfolioId}/orders/${request.orderId}/cancel`,
|
|
156
|
-
method:
|
|
136
|
+
method: clients_1.Method.POST,
|
|
157
137
|
callOptions: options,
|
|
158
138
|
});
|
|
159
139
|
return response.data;
|
|
@@ -163,7 +143,7 @@ class OrdersService {
|
|
|
163
143
|
return __awaiter(this, void 0, void 0, function* () {
|
|
164
144
|
const response = yield this.client.request({
|
|
165
145
|
url: `portfolios/${request.portfolioId}/order`,
|
|
166
|
-
method:
|
|
146
|
+
method: clients_1.Method.POST,
|
|
167
147
|
bodyParams: request,
|
|
168
148
|
callOptions: options,
|
|
169
149
|
});
|
|
@@ -174,7 +154,7 @@ class OrdersService {
|
|
|
174
154
|
return __awaiter(this, void 0, void 0, function* () {
|
|
175
155
|
const response = yield this.client.request({
|
|
176
156
|
url: `portfolios/${request.portfolioId}/rfq`,
|
|
177
|
-
method:
|
|
157
|
+
method: clients_1.Method.POST,
|
|
178
158
|
bodyParams: request,
|
|
179
159
|
callOptions: options,
|
|
180
160
|
});
|
|
@@ -185,7 +165,7 @@ class OrdersService {
|
|
|
185
165
|
return __awaiter(this, void 0, void 0, function* () {
|
|
186
166
|
const response = yield this.client.request({
|
|
187
167
|
url: `portfolios/${request.portfolioId}/accept_quote`,
|
|
188
|
-
method:
|
|
168
|
+
method: clients_1.Method.POST,
|
|
189
169
|
bodyParams: request,
|
|
190
170
|
callOptions: options,
|
|
191
171
|
});
|
package/dist/positions/index.js
CHANGED
|
@@ -8,6 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
11
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
23
|
exports.PositionsService = void 0;
|
|
13
24
|
const paginatedResponse_1 = require("../shared/paginatedResponse");
|
|
@@ -17,11 +28,13 @@ class PositionsService {
|
|
|
17
28
|
}
|
|
18
29
|
listAggregateEntityPositions(request, options) {
|
|
19
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const
|
|
31
|
+
const paginationParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
32
|
+
const { limit, cursor, sortDirection, entityId } = request, queryParams = __rest(request, ["limit", "cursor", "sortDirection", "entityId"]);
|
|
33
|
+
const finalQueryParams = Object.assign(Object.assign({}, paginationParams), queryParams);
|
|
21
34
|
const response = yield this.client.request({
|
|
22
|
-
url: `entities/${
|
|
35
|
+
url: `entities/${entityId}/aggregate_positions`,
|
|
23
36
|
callOptions: options,
|
|
24
|
-
queryParams,
|
|
37
|
+
queryParams: finalQueryParams,
|
|
25
38
|
});
|
|
26
39
|
const paginationOptions = (0, paginatedResponse_1.getDefaultPaginationOptions)(this.client, options);
|
|
27
40
|
return (0, paginatedResponse_1.createPaginatedResponse)(response.data, this.listAggregateEntityPositions.bind(this), request, paginatedResponse_1.ResponseExtractors.positions, paginationOptions);
|
|
@@ -29,11 +42,13 @@ class PositionsService {
|
|
|
29
42
|
}
|
|
30
43
|
listEntityPositions(request, options) {
|
|
31
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
const
|
|
45
|
+
const paginationParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
46
|
+
const { limit, cursor, sortDirection, entityId } = request, queryParams = __rest(request, ["limit", "cursor", "sortDirection", "entityId"]);
|
|
47
|
+
const finalQueryParams = Object.assign(Object.assign({}, paginationParams), queryParams);
|
|
33
48
|
const response = yield this.client.request({
|
|
34
|
-
url: `entities/${
|
|
49
|
+
url: `entities/${entityId}/positions`,
|
|
35
50
|
callOptions: options,
|
|
36
|
-
queryParams,
|
|
51
|
+
queryParams: finalQueryParams,
|
|
37
52
|
});
|
|
38
53
|
const paginationOptions = (0, paginatedResponse_1.getDefaultPaginationOptions)(this.client, options);
|
|
39
54
|
return (0, paginatedResponse_1.createPaginatedResponse)(response.data, this.listEntityPositions.bind(this), request, paginatedResponse_1.ResponseExtractors.positions, paginationOptions);
|
package/dist/products/index.js
CHANGED
|
@@ -8,6 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
11
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
23
|
exports.ProductsService = void 0;
|
|
13
24
|
const paginatedResponse_1 = require("../shared/paginatedResponse");
|
|
@@ -17,10 +28,12 @@ class ProductsService {
|
|
|
17
28
|
}
|
|
18
29
|
listProducts(request, options) {
|
|
19
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const
|
|
31
|
+
const paginationParams = (0, paginatedResponse_1.getQueryParams)(this.client, request);
|
|
32
|
+
const { limit, cursor, sortDirection, portfolioId } = request, queryParams = __rest(request, ["limit", "cursor", "sortDirection", "portfolioId"]);
|
|
33
|
+
const finalQueryParams = Object.assign(Object.assign({}, paginationParams), queryParams);
|
|
21
34
|
const response = yield this.client.request({
|
|
22
|
-
url: `portfolios/${
|
|
23
|
-
queryParams,
|
|
35
|
+
url: `portfolios/${portfolioId}/products`,
|
|
36
|
+
queryParams: finalQueryParams,
|
|
24
37
|
callOptions: options,
|
|
25
38
|
});
|
|
26
39
|
const paginationOptions = (0, paginatedResponse_1.getDefaultPaginationOptions)(this.client, options);
|
package/dist/services.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
*/
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
24
|
+
}) : (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
o[k2] = m[k];
|
|
27
|
+
}));
|
|
28
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
29
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.WalletsService = exports.UsersService = exports.TransactionsService = exports.StakingService = exports.ProductsService = exports.PositionsService = exports.PortfoliosService = exports.PaymentMethodsService = exports.OrdersService = exports.OnchainAddressBookService = exports.InvoicesService = exports.FuturesService = exports.FinancingService = exports.CommissionService = exports.BalancesService = exports.AssetsService = exports.AllocationService = exports.AddressBooksService = exports.ActivitiesService = void 0;
|
|
33
|
+
// Services-only entry point - for users who want to import specific services
|
|
34
|
+
// without pulling in client classes. Ideal for custom client implementations
|
|
35
|
+
// or when using dependency injection frameworks.
|
|
36
|
+
// Export all service classes and interfaces
|
|
37
|
+
var activities_1 = require("./activities");
|
|
38
|
+
Object.defineProperty(exports, "ActivitiesService", { enumerable: true, get: function () { return activities_1.ActivitiesService; } });
|
|
39
|
+
var addressBooks_1 = require("./addressBooks");
|
|
40
|
+
Object.defineProperty(exports, "AddressBooksService", { enumerable: true, get: function () { return addressBooks_1.AddressBooksService; } });
|
|
41
|
+
var allocations_1 = require("./allocations");
|
|
42
|
+
Object.defineProperty(exports, "AllocationService", { enumerable: true, get: function () { return allocations_1.AllocationService; } });
|
|
43
|
+
var assets_1 = require("./assets");
|
|
44
|
+
Object.defineProperty(exports, "AssetsService", { enumerable: true, get: function () { return assets_1.AssetsService; } });
|
|
45
|
+
var balances_1 = require("./balances");
|
|
46
|
+
Object.defineProperty(exports, "BalancesService", { enumerable: true, get: function () { return balances_1.BalancesService; } });
|
|
47
|
+
var commission_1 = require("./commission");
|
|
48
|
+
Object.defineProperty(exports, "CommissionService", { enumerable: true, get: function () { return commission_1.CommissionService; } });
|
|
49
|
+
var financing_1 = require("./financing");
|
|
50
|
+
Object.defineProperty(exports, "FinancingService", { enumerable: true, get: function () { return financing_1.FinancingService; } });
|
|
51
|
+
var futures_1 = require("./futures");
|
|
52
|
+
Object.defineProperty(exports, "FuturesService", { enumerable: true, get: function () { return futures_1.FuturesService; } });
|
|
53
|
+
var invoices_1 = require("./invoices");
|
|
54
|
+
Object.defineProperty(exports, "InvoicesService", { enumerable: true, get: function () { return invoices_1.InvoicesService; } });
|
|
55
|
+
var onchainAddressBook_1 = require("./onchainAddressBook");
|
|
56
|
+
Object.defineProperty(exports, "OnchainAddressBookService", { enumerable: true, get: function () { return onchainAddressBook_1.OnchainAddressBookService; } });
|
|
57
|
+
var orders_1 = require("./orders");
|
|
58
|
+
Object.defineProperty(exports, "OrdersService", { enumerable: true, get: function () { return orders_1.OrdersService; } });
|
|
59
|
+
var paymentMethods_1 = require("./paymentMethods");
|
|
60
|
+
Object.defineProperty(exports, "PaymentMethodsService", { enumerable: true, get: function () { return paymentMethods_1.PaymentMethodsService; } });
|
|
61
|
+
var portfolios_1 = require("./portfolios");
|
|
62
|
+
Object.defineProperty(exports, "PortfoliosService", { enumerable: true, get: function () { return portfolios_1.PortfoliosService; } });
|
|
63
|
+
var positions_1 = require("./positions");
|
|
64
|
+
Object.defineProperty(exports, "PositionsService", { enumerable: true, get: function () { return positions_1.PositionsService; } });
|
|
65
|
+
var products_1 = require("./products");
|
|
66
|
+
Object.defineProperty(exports, "ProductsService", { enumerable: true, get: function () { return products_1.ProductsService; } });
|
|
67
|
+
var staking_1 = require("./staking");
|
|
68
|
+
Object.defineProperty(exports, "StakingService", { enumerable: true, get: function () { return staking_1.StakingService; } });
|
|
69
|
+
var transactions_1 = require("./transactions");
|
|
70
|
+
Object.defineProperty(exports, "TransactionsService", { enumerable: true, get: function () { return transactions_1.TransactionsService; } });
|
|
71
|
+
var users_1 = require("./users");
|
|
72
|
+
Object.defineProperty(exports, "UsersService", { enumerable: true, get: function () { return users_1.UsersService; } });
|
|
73
|
+
var wallets_1 = require("./wallets");
|
|
74
|
+
Object.defineProperty(exports, "WalletsService", { enumerable: true, get: function () { return wallets_1.WalletsService; } });
|
|
75
|
+
__exportStar(require("./model/enums/"), exports);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCredentialsFromEnv = createCredentialsFromEnv;
|
|
4
|
+
/**
|
|
5
|
+
* Copyright 2025-present Coinbase Global, Inc.
|
|
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
|
+
const credentials_1 = require("../credentials");
|
|
20
|
+
/**
|
|
21
|
+
* Shared utility function to create credentials from environment variables
|
|
22
|
+
* Used by both CoinbasePrimeClient and CoinbasePrimeClientWithServices
|
|
23
|
+
*
|
|
24
|
+
* Automatically attempts to load .env file if dotenv is available.
|
|
25
|
+
* If dotenv is not installed or .env file doesn't exist, falls back to
|
|
26
|
+
* using environment variables set directly.
|
|
27
|
+
*
|
|
28
|
+
* @advanced For custom scenarios. Most users should use Client.fromEnv() instead.
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* // Basic usage (recommended)
|
|
32
|
+
* const client = CoinbasePrimeClient.fromEnv();
|
|
33
|
+
*
|
|
34
|
+
* // Advanced usage (custom scenarios)
|
|
35
|
+
* const credentials = createCredentialsFromEnv();
|
|
36
|
+
* const client = new CoinbasePrimeClient(credentials, 'custom-url');
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
function createCredentialsFromEnv() {
|
|
40
|
+
// Try to load .env file if dotenv is available (optional)
|
|
41
|
+
try {
|
|
42
|
+
require('dotenv').config();
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
// dotenv not installed or .env file doesn't exist - that's fine
|
|
46
|
+
// Environment variables might be set directly via shell, Docker, CI/CD, etc.
|
|
47
|
+
}
|
|
48
|
+
const credsJson = process.env.PRIME_CREDENTIALS;
|
|
49
|
+
if (!credsJson) {
|
|
50
|
+
throw new Error('PRIME_CREDENTIALS environment variable is required. ' +
|
|
51
|
+
'Set it to a JSON string with AccessKey, SecretKey, and Passphrase. ' +
|
|
52
|
+
'You can set it directly (export PRIME_CREDENTIALS=\'{"AccessKey":"...","SecretKey":"...","Passphrase":"..."}\') ' +
|
|
53
|
+
'or create a .env file with PRIME_CREDENTIALS={"AccessKey":"...","SecretKey":"...","Passphrase":"..."}.');
|
|
54
|
+
}
|
|
55
|
+
let creds;
|
|
56
|
+
try {
|
|
57
|
+
creds = JSON.parse(credsJson);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
throw new Error('PRIME_CREDENTIALS must be valid JSON with AccessKey, SecretKey, and Passphrase fields.');
|
|
61
|
+
}
|
|
62
|
+
if (!creds.AccessKey || !creds.SecretKey || !creds.Passphrase) {
|
|
63
|
+
throw new Error('PRIME_CREDENTIALS must contain AccessKey, SecretKey, and Passphrase fields.');
|
|
64
|
+
}
|
|
65
|
+
return new credentials_1.CoinbasePrimeCredentials(creds.AccessKey, creds.SecretKey, creds.Passphrase);
|
|
66
|
+
}
|
|
@@ -178,6 +178,9 @@ function getQueryParams(client, request) {
|
|
|
178
178
|
if (request.cursor) {
|
|
179
179
|
queryParams.cursor = request.cursor;
|
|
180
180
|
}
|
|
181
|
+
if (request.sortDirection) {
|
|
182
|
+
queryParams.sortDirection = request.sortDirection;
|
|
183
|
+
}
|
|
181
184
|
if (!queryParams.limit) {
|
|
182
185
|
queryParams.limit = client.getDefaultPaginationLimit();
|
|
183
186
|
}
|
package/dist/staking/index.js
CHANGED
|
@@ -25,7 +25,7 @@ exports.StakingService = void 0;
|
|
|
25
25
|
* See the License for the specific language governing permissions and
|
|
26
26
|
* limitations under the License.
|
|
27
27
|
*/
|
|
28
|
-
const
|
|
28
|
+
const clients_1 = require("../clients");
|
|
29
29
|
class StakingService {
|
|
30
30
|
constructor(client) {
|
|
31
31
|
this.client = client;
|
|
@@ -35,7 +35,7 @@ class StakingService {
|
|
|
35
35
|
const bodyParams = Object.assign(Object.assign({}, request), { portfolioId: undefined, walletId: undefined });
|
|
36
36
|
const response = yield this.client.request({
|
|
37
37
|
url: `portfolios/${request.portfolioId}/wallets/${request.walletId}/staking/initiate`,
|
|
38
|
-
method:
|
|
38
|
+
method: clients_1.Method.POST,
|
|
39
39
|
bodyParams,
|
|
40
40
|
callOptions: options,
|
|
41
41
|
});
|
|
@@ -47,7 +47,7 @@ class StakingService {
|
|
|
47
47
|
const bodyParams = Object.assign(Object.assign({}, request), { portfolioId: undefined, walletId: undefined });
|
|
48
48
|
const response = yield this.client.request({
|
|
49
49
|
url: `portfolios/${request.portfolioId}/wallets/${request.walletId}/staking/unstake`,
|
|
50
|
-
method:
|
|
50
|
+
method: clients_1.Method.POST,
|
|
51
51
|
bodyParams,
|
|
52
52
|
callOptions: options,
|
|
53
53
|
});
|
|
@@ -59,7 +59,7 @@ class StakingService {
|
|
|
59
59
|
const bodyParams = Object.assign(Object.assign({}, request), { portfolioId: undefined });
|
|
60
60
|
const response = yield this.client.request({
|
|
61
61
|
url: `portfolios/${request.portfolioId}/staking/initiate`,
|
|
62
|
-
method:
|
|
62
|
+
method: clients_1.Method.POST,
|
|
63
63
|
bodyParams,
|
|
64
64
|
callOptions: options,
|
|
65
65
|
});
|
|
@@ -71,7 +71,7 @@ class StakingService {
|
|
|
71
71
|
const bodyParams = Object.assign(Object.assign({}, request), { portfolioId: undefined });
|
|
72
72
|
const response = yield this.client.request({
|
|
73
73
|
url: `portfolios/${request.portfolioId}/staking/unstake`,
|
|
74
|
-
method:
|
|
74
|
+
method: clients_1.Method.POST,
|
|
75
75
|
bodyParams,
|
|
76
76
|
callOptions: options,
|
|
77
77
|
});
|