@cobo/cobo-waas2 1.6.0 → 1.7.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.
Files changed (97) hide show
  1. package/README.md +17 -2
  2. package/dist/ApiClient.js +56 -6
  3. package/dist/api/DevelopersWebhooksApi.js +2 -2
  4. package/dist/api/StakingsApi.js +91 -7
  5. package/dist/api/TransactionsApi.js +4 -4
  6. package/dist/crypto/Ed25519Signer.js +36 -0
  7. package/dist/crypto/Secp256k1Signer.js +36 -0
  8. package/dist/index.js +70 -7
  9. package/dist/model/Activity.js +4 -8
  10. package/dist/model/ActivityAction.js +20 -0
  11. package/dist/model/ActivityType.js +5 -0
  12. package/dist/model/AutoFuelType.js +61 -0
  13. package/dist/model/BabylonValidator.js +4 -12
  14. package/dist/model/ContractCallParams.js +9 -0
  15. package/dist/model/CoreStakeExtra.js +170 -0
  16. package/dist/model/CoreStakingExtra.js +187 -0
  17. package/dist/model/CreateClaimActivity.js +139 -0
  18. package/dist/model/CreateClaimActivityRequest.js +182 -0
  19. package/dist/model/CreateStakeActivity.js +4 -8
  20. package/dist/model/CreateStakeActivityExtra.js +60 -8
  21. package/dist/model/CreateStakeActivityRequest.js +5 -10
  22. package/dist/model/CreateWithdrawActivity.js +0 -13
  23. package/dist/model/CreateWithdrawActivityRequest.js +0 -18
  24. package/dist/model/EstimateClaimFee.js +145 -0
  25. package/dist/model/EstimateContractCallFeeParams.js +2 -2
  26. package/dist/model/EstimateFeeParams.js +1 -1
  27. package/dist/model/EstimateStakeFee.js +5 -10
  28. package/dist/model/EstimateWithdrawFee.js +0 -18
  29. package/dist/model/EstimatedFee.js +1 -1
  30. package/dist/model/EstimatedFixedFee.js +4 -4
  31. package/dist/model/EstimatedUtxoFeeSlow.js +3 -3
  32. package/dist/model/EthStakingExtra.js +31 -0
  33. package/dist/model/EthStakingExtraAllOfBeaconValidators.js +140 -0
  34. package/dist/model/FeeAmount.js +1 -1
  35. package/dist/model/FeeRate.js +1 -1
  36. package/dist/model/FixedFeeRate.js +2 -2
  37. package/dist/model/GetStakingEstimationFeeRequest.js +39 -17
  38. package/dist/model/MPCProject.js +4 -4
  39. package/dist/model/MpcTransferSource.js +1 -1
  40. package/dist/model/Pagination.js +2 -2
  41. package/dist/model/StakingPoolId.js +81 -0
  42. package/dist/model/StakingPoolType.js +5 -0
  43. package/dist/model/Stakings.js +10 -14
  44. package/dist/model/StakingsExtra.js +67 -8
  45. package/dist/model/TransactionRbf.js +9 -0
  46. package/dist/model/TransactionRbfSource.js +1 -1
  47. package/dist/model/TransactionRequestEvmEip1559Fee.js +1 -1
  48. package/dist/model/TransactionRequestEvmLegacyFee.js +1 -1
  49. package/dist/model/TransactionRequestFixedFee.js +1 -1
  50. package/dist/model/TransactionRequestUtxoFee.js +1 -1
  51. package/dist/model/TransferParams.js +9 -0
  52. package/docs/Activity.md +1 -1
  53. package/docs/ActivityAction.md +8 -0
  54. package/docs/ActivityType.md +2 -0
  55. package/docs/AutoFuelType.md +12 -0
  56. package/docs/BabylonValidator.md +4 -4
  57. package/docs/ContractCallParams.md +1 -0
  58. package/docs/CoreStakeExtra.md +13 -0
  59. package/docs/CoreStakingExtra.md +14 -0
  60. package/docs/CreateClaimActivity.md +11 -0
  61. package/docs/CreateClaimActivityRequest.md +12 -0
  62. package/docs/CreateStakeActivity.md +1 -1
  63. package/docs/CreateStakeActivityExtra.md +4 -0
  64. package/docs/CreateStakeActivityRequest.md +1 -1
  65. package/docs/CreateWithdrawActivity.md +0 -1
  66. package/docs/CreateWithdrawActivityRequest.md +0 -1
  67. package/docs/DevelopersWebhooksApi.md +1 -1
  68. package/docs/EstimateClaimFee.md +11 -0
  69. package/docs/EstimateContractCallFeeParams.md +1 -1
  70. package/docs/EstimateFeeParams.md +1 -1
  71. package/docs/EstimateStakeFee.md +1 -1
  72. package/docs/EstimateWithdrawFee.md +0 -1
  73. package/docs/EstimatedFee.md +1 -1
  74. package/docs/EstimatedFixedFee.md +1 -1
  75. package/docs/EstimatedUtxoFeeSlow.md +1 -1
  76. package/docs/EthStakingExtra.md +1 -0
  77. package/docs/EthStakingExtraAllOfBeaconValidators.md +14 -0
  78. package/docs/FeeAmount.md +1 -1
  79. package/docs/FeeRate.md +1 -1
  80. package/docs/FixedFeeRate.md +1 -1
  81. package/docs/GetStakingEstimationFeeRequest.md +2 -3
  82. package/docs/MPCProject.md +1 -1
  83. package/docs/MpcTransferSource.md +1 -1
  84. package/docs/Pagination.md +1 -1
  85. package/docs/PoolDetailsAllOfValidatorsInfo.md +4 -4
  86. package/docs/StakingPoolId.md +20 -0
  87. package/docs/StakingPoolType.md +2 -0
  88. package/docs/Stakings.md +2 -2
  89. package/docs/StakingsApi.md +108 -2
  90. package/docs/StakingsExtra.md +5 -0
  91. package/docs/TransactionRbf.md +1 -0
  92. package/docs/TransactionRbfSource.md +1 -1
  93. package/docs/TransactionsApi.md +2 -2
  94. package/docs/TransferParams.md +1 -0
  95. package/package.json +3 -2
  96. package/dist/model/StakingsValidatorInfo.js +0 -140
  97. package/docs/StakingsValidatorInfo.md +0 -13
package/README.md CHANGED
@@ -15,7 +15,7 @@ For more information about the WaaS 2.0 API, see [Introduction to WaaS 2.0](/v2/
15
15
  This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
16
16
 
17
17
  - API version: v2
18
- - Package version: 1.6.0
18
+ - Package version: 1.7.0
19
19
  - Generator version: 7.6.0
20
20
  - Build package: org.openapitools.codegen.languages.JavascriptClientCodegen
21
21
  For more information, please visit [https://www.cobo.com/waas](https://www.cobo.com/waas)
@@ -36,7 +36,13 @@ const CoboWaas2 = require('@cobo/cobo-waas2');
36
36
  const apiClient = CoboWaas2.ApiClient.instance
37
37
  // for dev env
38
38
  // apiClient.setEnv(CoboWaas2.Env.DEV);
39
+
40
+ // by default, ed25519 is used
39
41
  apiClient.setPrivateKey("<YOUR_API_PRIVATE_KEY_IN_HEX>");
42
+
43
+ // or secp256k1
44
+ // apiClient.setPrivateKey("<YOUR_API_PRIVATE_KEY_IN_HEX>", "SECP256K1");
45
+
40
46
  // call api
41
47
  const apiInstance = new CoboWaas2.WalletsApi();
42
48
  const opts = {
@@ -75,12 +81,14 @@ Class | Method | HTTP request | Description
75
81
  *CoboWaas2.DevelopersWebhooksApi* | [**updateWebhookEndpointById**](docs/DevelopersWebhooksApi.md#updateWebhookEndpointById) | **PUT** /webhooks/endpoints/{endpoint_id} | Update webhook endpoint
76
82
  *CoboWaas2.OAuthApi* | [**getToken**](docs/OAuthApi.md#getToken) | **GET** /oauth/token | Get Org Access Token
77
83
  *CoboWaas2.OAuthApi* | [**refreshToken**](docs/OAuthApi.md#refreshToken) | **POST** /oauth/token | Refresh Org Access Token
84
+ *CoboWaas2.StakingsApi* | [**createClaimActivity**](docs/StakingsApi.md#createClaimActivity) | **POST** /stakings/activities/claim | Create claim activity
78
85
  *CoboWaas2.StakingsApi* | [**createStakeActivity**](docs/StakingsApi.md#createStakeActivity) | **POST** /stakings/activities/stake | Create stake activity
79
86
  *CoboWaas2.StakingsApi* | [**createUnstakeActivity**](docs/StakingsApi.md#createUnstakeActivity) | **POST** /stakings/activities/unstake | Create unstake activity
80
87
  *CoboWaas2.StakingsApi* | [**createWithdrawActivity**](docs/StakingsApi.md#createWithdrawActivity) | **POST** /stakings/activities/withdraw | Create withdraw activity
81
88
  *CoboWaas2.StakingsApi* | [**getStakingActivityById**](docs/StakingsApi.md#getStakingActivityById) | **GET** /stakings/activities/{activity_id} | Get staking activity details
82
89
  *CoboWaas2.StakingsApi* | [**getStakingById**](docs/StakingsApi.md#getStakingById) | **GET** /stakings/{staking_id} | Get staking position details
83
90
  *CoboWaas2.StakingsApi* | [**getStakingEstimationFee**](docs/StakingsApi.md#getStakingEstimationFee) | **POST** /stakings/estimate_fee | Estimate staking fees
91
+ *CoboWaas2.StakingsApi* | [**getStakingEstimationFeeV2**](docs/StakingsApi.md#getStakingEstimationFeeV2) | **POST** /stakings/estimate_fee_v2 | Estimate staking fees
84
92
  *CoboWaas2.StakingsApi* | [**getStakingPoolById**](docs/StakingsApi.md#getStakingPoolById) | **GET** /stakings/pools/{pool_id} | Get staking pool details
85
93
  *CoboWaas2.StakingsApi* | [**listStakingActivities**](docs/StakingsApi.md#listStakingActivities) | **GET** /stakings/activities | List staking activities
86
94
  *CoboWaas2.StakingsApi* | [**listStakingPools**](docs/StakingsApi.md#listStakingPools) | **GET** /stakings/pools | List staking pools
@@ -164,6 +172,7 @@ Class | Method | HTTP request | Description
164
172
  - [CoboWaas2.ApiLogSummary](docs/ApiLogSummary.md)
165
173
  - [CoboWaas2.AssetBalance](docs/AssetBalance.md)
166
174
  - [CoboWaas2.AssetInfo](docs/AssetInfo.md)
175
+ - [CoboWaas2.AutoFuelType](docs/AutoFuelType.md)
167
176
  - [CoboWaas2.BabylonStakeEstimatedFee](docs/BabylonStakeEstimatedFee.md)
168
177
  - [CoboWaas2.BabylonStakeExtra](docs/BabylonStakeExtra.md)
169
178
  - [CoboWaas2.BabylonStakingExtra](docs/BabylonStakingExtra.md)
@@ -186,7 +195,11 @@ Class | Method | HTTP request | Description
186
195
  - [CoboWaas2.ContractCallParams](docs/ContractCallParams.md)
187
196
  - [CoboWaas2.ContractCallSource](docs/ContractCallSource.md)
188
197
  - [CoboWaas2.ContractCallSourceType](docs/ContractCallSourceType.md)
198
+ - [CoboWaas2.CoreStakeExtra](docs/CoreStakeExtra.md)
199
+ - [CoboWaas2.CoreStakingExtra](docs/CoreStakingExtra.md)
189
200
  - [CoboWaas2.CreateAddressRequest](docs/CreateAddressRequest.md)
201
+ - [CoboWaas2.CreateClaimActivity](docs/CreateClaimActivity.md)
202
+ - [CoboWaas2.CreateClaimActivityRequest](docs/CreateClaimActivityRequest.md)
190
203
  - [CoboWaas2.CreateCustodialWalletParams](docs/CreateCustodialWalletParams.md)
191
204
  - [CoboWaas2.CreateExchangeWalletParams](docs/CreateExchangeWalletParams.md)
192
205
  - [CoboWaas2.CreateKeyShareHolder](docs/CreateKeyShareHolder.md)
@@ -219,6 +232,7 @@ Class | Method | HTTP request | Description
219
232
  - [CoboWaas2.EigenLayerNativeStakeExtra](docs/EigenLayerNativeStakeExtra.md)
220
233
  - [CoboWaas2.EigenlayerValidator](docs/EigenlayerValidator.md)
221
234
  - [CoboWaas2.ErrorResponse](docs/ErrorResponse.md)
235
+ - [CoboWaas2.EstimateClaimFee](docs/EstimateClaimFee.md)
222
236
  - [CoboWaas2.EstimateContractCallFeeParams](docs/EstimateContractCallFeeParams.md)
223
237
  - [CoboWaas2.EstimateFeeParams](docs/EstimateFeeParams.md)
224
238
  - [CoboWaas2.EstimateFeeRequestType](docs/EstimateFeeRequestType.md)
@@ -237,6 +251,7 @@ Class | Method | HTTP request | Description
237
251
  - [CoboWaas2.EthStakeEstimatedFee](docs/EthStakeEstimatedFee.md)
238
252
  - [CoboWaas2.EthStakeExtra](docs/EthStakeExtra.md)
239
253
  - [CoboWaas2.EthStakingExtra](docs/EthStakingExtra.md)
254
+ - [CoboWaas2.EthStakingExtraAllOfBeaconValidators](docs/EthStakingExtraAllOfBeaconValidators.md)
240
255
  - [CoboWaas2.EthUnstakeExtra](docs/EthUnstakeExtra.md)
241
256
  - [CoboWaas2.EvmContractCallDestination](docs/EvmContractCallDestination.md)
242
257
  - [CoboWaas2.EvmEIP191MessageSignDestination](docs/EvmEIP191MessageSignDestination.md)
@@ -332,11 +347,11 @@ Class | Method | HTTP request | Description
332
347
  - [CoboWaas2.SmartContractWalletType](docs/SmartContractWalletType.md)
333
348
  - [CoboWaas2.SourceGroup](docs/SourceGroup.md)
334
349
  - [CoboWaas2.StakeSourceType](docs/StakeSourceType.md)
350
+ - [CoboWaas2.StakingPoolId](docs/StakingPoolId.md)
335
351
  - [CoboWaas2.StakingPoolType](docs/StakingPoolType.md)
336
352
  - [CoboWaas2.StakingSource](docs/StakingSource.md)
337
353
  - [CoboWaas2.Stakings](docs/Stakings.md)
338
354
  - [CoboWaas2.StakingsExtra](docs/StakingsExtra.md)
339
- - [CoboWaas2.StakingsValidatorInfo](docs/StakingsValidatorInfo.md)
340
355
  - [CoboWaas2.SubWalletAssetBalance](docs/SubWalletAssetBalance.md)
341
356
  - [CoboWaas2.TSSGroups](docs/TSSGroups.md)
342
357
  - [CoboWaas2.TSSRequest](docs/TSSRequest.md)
package/dist/ApiClient.js CHANGED
@@ -6,8 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports["default"] = void 0;
7
7
  var _superagent = _interopRequireDefault(require("superagent"));
8
8
  var _querystring = _interopRequireDefault(require("querystring"));
9
- var _ApiSigner = _interopRequireDefault(require("./crypto/ApiSigner"));
10
9
  var _Env = _interopRequireDefault(require("./Env"));
10
+ var _Ed25519Signer = _interopRequireDefault(require("./crypto/Ed25519Signer"));
11
+ var _Secp256k1Signer = _interopRequireDefault(require("./crypto/Secp256k1Signer"));
12
+ var CryptoJS = _interopRequireWildcard(require("crypto-js"));
13
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
14
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
11
15
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
12
16
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
13
17
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -47,6 +51,8 @@ var ApiClient = /*#__PURE__*/function () {
47
51
  function ApiClient() {
48
52
  var env = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _Env["default"].PROD;
49
53
  var privateKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
54
+ var curve_type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
55
+ var signer = arguments.length > 3 ? arguments[3] : undefined;
50
56
  _classCallCheck(this, ApiClient);
51
57
  /**
52
58
  * The base URL against which to resolve every API call's (relative) path.
@@ -54,7 +60,16 @@ var ApiClient = /*#__PURE__*/function () {
54
60
  * @default https://api.dev.cobo.com/v2
55
61
  */
56
62
  this.basePath = env.basePath;
57
- this.privateKey = privateKey;
63
+ if (privateKey) {
64
+ curve_type = curve_type || "ED25519";
65
+ if (curve_type === "ED25519") {
66
+ this.signer = new _Ed25519Signer["default"](privateKey);
67
+ } else if (curve_type === "SECP256k1") {
68
+ this.signer = new _Secp256k1Signer["default"](privateKey);
69
+ }
70
+ } else if (signer) {
71
+ this.signer = signer;
72
+ }
58
73
 
59
74
  /**
60
75
  * The authentication methods to be included for all API calls.
@@ -77,7 +92,7 @@ var ApiClient = /*#__PURE__*/function () {
77
92
  * @default {}
78
93
  */
79
94
  this.defaultHeaders = {
80
- 'User-Agent': 'cobo-waas2-js-sdk/1.6.0'
95
+ 'User-Agent': 'cobo-waas2-js-sdk/1.7.0'
81
96
  };
82
97
 
83
98
  /**
@@ -120,15 +135,42 @@ var ApiClient = /*#__PURE__*/function () {
120
135
  */
121
136
  this.plugins = null;
122
137
  }
138
+
139
+ /***
140
+ *
141
+ * @param env
142
+ */
123
143
  return _createClass(ApiClient, [{
124
144
  key: "setEnv",
125
145
  value: function setEnv(env) {
126
146
  this.basePath = env.basePath;
127
147
  }
148
+
149
+ /***
150
+ *
151
+ * @param privateKey
152
+ */
128
153
  }, {
129
154
  key: "setPrivateKey",
130
155
  value: function setPrivateKey(privateKey) {
131
- this.privateKey = privateKey;
156
+ var curveType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "ED25519";
157
+ if (curveType === "ED25519") {
158
+ this.signer = new _Ed25519Signer["default"](privateKey);
159
+ } else if (curveType === "SECP256K1") {
160
+ this.signer = new _Secp256k1Signer["default"](privateKey);
161
+ } else {
162
+ throw new Error('Invalid curve type' + curveType);
163
+ }
164
+ }
165
+
166
+ /***
167
+ *
168
+ * @param signer
169
+ */
170
+ }, {
171
+ key: "setSigner",
172
+ value: function setSigner(signer) {
173
+ this.signer = signer;
132
174
  }
133
175
 
134
176
  /**
@@ -441,8 +483,16 @@ var ApiClient = /*#__PURE__*/function () {
441
483
  }).map(function (k) {
442
484
  return k + '=' + encodeURIComponent(queryParams[k]).replace(/%20/g, "+");
443
485
  }).join('&');
444
- var signer = new _ApiSigner["default"](this.privateKey);
445
- request.set(signer.generateHeaders(new URL(url).pathname, httpMethod, bodyParam, queryStr));
486
+ var nonce = String(new Date().getTime());
487
+ var strToSign = [httpMethod, new URL(url).pathname, nonce, queryStr, bodyParam ? JSON.stringify(bodyParam) : ''].join('|');
488
+ console.log("strToSign:", strToSign);
489
+ var hash2String = CryptoJS.SHA256(CryptoJS.SHA256(strToSign)).toString(CryptoJS.enc.Hex);
490
+ var headers = {
491
+ 'BIZ-API-KEY': this.signer.getPublicKey(),
492
+ "BIZ-API-NONCE": nonce,
493
+ "BIZ-API-SIGNATURE": this.signer.sign(hash2String)
494
+ };
495
+ request.set(headers);
446
496
  if (this.plugins !== null) {
447
497
  for (var index in this.plugins) {
448
498
  if (this.plugins.hasOwnProperty(index)) {
@@ -460,7 +460,7 @@ var DevelopersWebhooksApi = exports["default"] = /*#__PURE__*/function () {
460
460
 
461
461
  /**
462
462
  * Trigger test event
463
- * This operation tests the functionality of your webhook endpoint by triggering a test webhook event. You only need to provide the event type. By default, the payload contains dummy data with no impact on your real business transactions or activities. You can optionally provide the `override_data` property to customize the payload.
463
+ * This operation tests the functionality of your webhook endpoint by triggering a test webhook event. The test event will be sent to all the endpoints you have registered on Cobo Portal. You only need to provide the event type. By default, the payload contains dummy data with no impact on your real business transactions or activities. You can optionally provide the `override_data` property to customize the payload.
464
464
  * @param {Object} opts Optional parameters
465
465
  * @param {module:model/TriggerTestWebhookEventRequest} [TriggerTestWebhookEventRequest] The request body used to trigger a test webhook event.
466
466
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/TriggerTestWebhookEvent201Response} and HTTP response
@@ -486,7 +486,7 @@ var DevelopersWebhooksApi = exports["default"] = /*#__PURE__*/function () {
486
486
 
487
487
  /**
488
488
  * Trigger test event
489
- * This operation tests the functionality of your webhook endpoint by triggering a test webhook event. You only need to provide the event type. By default, the payload contains dummy data with no impact on your real business transactions or activities. You can optionally provide the `override_data` property to customize the payload.
489
+ * This operation tests the functionality of your webhook endpoint by triggering a test webhook event. The test event will be sent to all the endpoints you have registered on Cobo Portal. You only need to provide the event type. By default, the payload contains dummy data with no impact on your real business transactions or activities. You can optionally provide the `override_data` property to customize the payload.
490
490
  * @param {Object} opts Optional parameters
491
491
  * @param {module:model/TriggerTestWebhookEventRequest} opts.TriggerTestWebhookEventRequest The request body used to trigger a test webhook event.
492
492
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/TriggerTestWebhookEvent201Response}
@@ -8,11 +8,13 @@ var _ApiClient = _interopRequireDefault(require("../ApiClient"));
8
8
  var _Activity = _interopRequireDefault(require("../model/Activity"));
9
9
  var _ActivityStatus = _interopRequireDefault(require("../model/ActivityStatus"));
10
10
  var _ActivityType = _interopRequireDefault(require("../model/ActivityType"));
11
+ var _CreateClaimActivityRequest = _interopRequireDefault(require("../model/CreateClaimActivityRequest"));
11
12
  var _CreateStakeActivity201Response = _interopRequireDefault(require("../model/CreateStakeActivity201Response"));
12
13
  var _CreateStakeActivityRequest = _interopRequireDefault(require("../model/CreateStakeActivityRequest"));
13
14
  var _CreateUnstakeActivityRequest = _interopRequireDefault(require("../model/CreateUnstakeActivityRequest"));
14
15
  var _CreateWithdrawActivityRequest = _interopRequireDefault(require("../model/CreateWithdrawActivityRequest"));
15
16
  var _ErrorResponse = _interopRequireDefault(require("../model/ErrorResponse"));
17
+ var _EthStakeEstimatedFee = _interopRequireDefault(require("../model/EthStakeEstimatedFee"));
16
18
  var _GetStakingEstimationFee201Response = _interopRequireDefault(require("../model/GetStakingEstimationFee201Response"));
17
19
  var _GetStakingEstimationFeeRequest = _interopRequireDefault(require("../model/GetStakingEstimationFeeRequest"));
18
20
  var _ListStakingActivities200Response = _interopRequireDefault(require("../model/ListStakingActivities200Response"));
@@ -54,13 +56,54 @@ var StakingsApi = exports["default"] = /*#__PURE__*/function () {
54
56
  }
55
57
 
56
58
  /**
57
- * Create stake activity
58
- * This operation creates a staking request. For some protocols, you can use the `fee` property in the request body to specify the maximum fee you are willing to pay. The transaction will fail if the actual fee exceeds the specified maximum fee. <Note>For the Babylon protocol, you can only select UTXO as the fee model.</Note>
59
+ * Create claim activity
60
+ * This operation creates a claim request. <Note>Currently, only the Ethereum Beacon protocol supports this operation.</Note> For some protocols, you can use the `fee` property in the request body to specify the maximum fee you are willing to pay. The transaction will fail if the actual fee exceeds the specified maximum fee.
59
61
  * @param {Object} opts Optional parameters
60
- * @param {module:model/CreateStakeActivityRequest} [CreateStakeActivityRequest] The request body to create a staking request.
62
+ * @param {module:model/CreateClaimActivityRequest} [CreateClaimActivityRequest] The request body to create a staking request.
61
63
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/CreateStakeActivity201Response} and HTTP response
62
64
  */
63
65
  return _createClass(StakingsApi, [{
66
+ key: "createClaimActivityWithHttpInfo",
67
+ value: function createClaimActivityWithHttpInfo(opts) {
68
+ opts = opts || {};
69
+ var postBody = opts['CreateClaimActivityRequest'];
70
+ if (postBody && postBody.toJSON) {
71
+ postBody = postBody.toJSON();
72
+ }
73
+ var pathParams = {};
74
+ var queryParams = {};
75
+ var headerParams = {};
76
+ var formParams = {};
77
+ var authNames = ['CoboAuth'];
78
+ var contentTypes = ['application/json'];
79
+ var accepts = ['application/json'];
80
+ var returnType = _CreateStakeActivity201Response["default"];
81
+ return this.apiClient.callApi('/stakings/activities/claim', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
82
+ }
83
+
84
+ /**
85
+ * Create claim activity
86
+ * This operation creates a claim request. <Note>Currently, only the Ethereum Beacon protocol supports this operation.</Note> For some protocols, you can use the `fee` property in the request body to specify the maximum fee you are willing to pay. The transaction will fail if the actual fee exceeds the specified maximum fee.
87
+ * @param {Object} opts Optional parameters
88
+ * @param {module:model/CreateClaimActivityRequest} opts.CreateClaimActivityRequest The request body to create a staking request.
89
+ * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/CreateStakeActivity201Response}
90
+ */
91
+ }, {
92
+ key: "createClaimActivity",
93
+ value: function createClaimActivity(opts) {
94
+ return this.createClaimActivityWithHttpInfo(opts).then(function (response_and_data) {
95
+ return response_and_data.data;
96
+ });
97
+ }
98
+
99
+ /**
100
+ * Create stake activity
101
+ * This operation creates a staking request. For some protocols, you can use the `fee` property in the request body to specify the maximum fee you are willing to pay. The transaction will fail if the actual fee exceeds the specified maximum fee. <Note>For the Babylon protocol, you can only select UTXO as the fee model.</Note>
102
+ * @param {Object} opts Optional parameters
103
+ * @param {module:model/CreateStakeActivityRequest} [CreateStakeActivityRequest] The request body to create a staking request.
104
+ * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/CreateStakeActivity201Response} and HTTP response
105
+ */
106
+ }, {
64
107
  key: "createStakeActivityWithHttpInfo",
65
108
  value: function createStakeActivityWithHttpInfo(opts) {
66
109
  opts = opts || {};
@@ -223,7 +266,7 @@ var StakingsApi = exports["default"] = /*#__PURE__*/function () {
223
266
  /**
224
267
  * Get staking position details
225
268
  * This operation retrieves the detailed information about a specified staking position.
226
- * @param {String} staking_id The ID of the staking position. You can retrieve a list of staking positions by calling [List staking positions](/v2/api-references/stakings/list-all-stakings).
269
+ * @param {String} staking_id The ID of the staking position. You can retrieve a list of staking positions by calling [List staking positions](/v2/api-references/stakings/list-staking-positions).
227
270
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/Stakings} and HTTP response
228
271
  */
229
272
  }, {
@@ -253,7 +296,7 @@ var StakingsApi = exports["default"] = /*#__PURE__*/function () {
253
296
  /**
254
297
  * Get staking position details
255
298
  * This operation retrieves the detailed information about a specified staking position.
256
- * @param {String} staking_id The ID of the staking position. You can retrieve a list of staking positions by calling [List staking positions](/v2/api-references/stakings/list-all-stakings).
299
+ * @param {String} staking_id The ID of the staking position. You can retrieve a list of staking positions by calling [List staking positions](/v2/api-references/stakings/list-staking-positions).
257
300
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/Stakings}
258
301
  */
259
302
  }, {
@@ -266,7 +309,7 @@ var StakingsApi = exports["default"] = /*#__PURE__*/function () {
266
309
 
267
310
  /**
268
311
  * Estimate staking fees
269
- * This operation calculates the fee required for a staking activity based on factors such as network congestion and transaction complexity. For some protocols, you can use the `fee.fee_rate` property in the request body to specify the fee rate you are willing to pay. The `fee.max_fee_amount` property in the request body will be ignored. <Note>For the Babylon protocol, you can only select UTXO as the fee model.</Note>
312
+ * <Note>This operation is deprecated. Please use the [updated version](/v2/api-references/stakings/estimate-staking-fees-1) instead.</Note> This operation calculates the fee required for a staking activity based on factors such as network congestion and transaction complexity. For some protocols, you can use the `fee.fee_rate` property in the request body to specify the fee rate you are willing to pay. The `fee.max_fee_amount` property in the request body will be ignored. <Note>For the Babylon protocol, you can only select UTXO as the fee model.</Note>
270
313
  * @param {Object} opts Optional parameters
271
314
  * @param {module:model/GetStakingEstimationFeeRequest} [GetStakingEstimationFeeRequest] The request body to get the estimated fee of a staking activity.
272
315
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/GetStakingEstimationFee201Response} and HTTP response
@@ -292,7 +335,7 @@ var StakingsApi = exports["default"] = /*#__PURE__*/function () {
292
335
 
293
336
  /**
294
337
  * Estimate staking fees
295
- * This operation calculates the fee required for a staking activity based on factors such as network congestion and transaction complexity. For some protocols, you can use the `fee.fee_rate` property in the request body to specify the fee rate you are willing to pay. The `fee.max_fee_amount` property in the request body will be ignored. <Note>For the Babylon protocol, you can only select UTXO as the fee model.</Note>
338
+ * <Note>This operation is deprecated. Please use the [updated version](/v2/api-references/stakings/estimate-staking-fees-1) instead.</Note> This operation calculates the fee required for a staking activity based on factors such as network congestion and transaction complexity. For some protocols, you can use the `fee.fee_rate` property in the request body to specify the fee rate you are willing to pay. The `fee.max_fee_amount` property in the request body will be ignored. <Note>For the Babylon protocol, you can only select UTXO as the fee model.</Note>
296
339
  * @param {Object} opts Optional parameters
297
340
  * @param {module:model/GetStakingEstimationFeeRequest} opts.GetStakingEstimationFeeRequest The request body to get the estimated fee of a staking activity.
298
341
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/GetStakingEstimationFee201Response}
@@ -305,6 +348,47 @@ var StakingsApi = exports["default"] = /*#__PURE__*/function () {
305
348
  });
306
349
  }
307
350
 
351
+ /**
352
+ * Estimate staking fees
353
+ * This operation calculates the fee required for a staking activity based on factors such as network congestion and transaction complexity. <Note>For the Babylon protocol, you can only select UTXO as the fee model.</Note>
354
+ * @param {Object} opts Optional parameters
355
+ * @param {module:model/GetStakingEstimationFeeRequest} [GetStakingEstimationFeeRequest] The request body to get the estimated fee of a staking activity.
356
+ * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/EthStakeEstimatedFee} and HTTP response
357
+ */
358
+ }, {
359
+ key: "getStakingEstimationFeeV2WithHttpInfo",
360
+ value: function getStakingEstimationFeeV2WithHttpInfo(opts) {
361
+ opts = opts || {};
362
+ var postBody = opts['GetStakingEstimationFeeRequest'];
363
+ if (postBody && postBody.toJSON) {
364
+ postBody = postBody.toJSON();
365
+ }
366
+ var pathParams = {};
367
+ var queryParams = {};
368
+ var headerParams = {};
369
+ var formParams = {};
370
+ var authNames = ['CoboAuth'];
371
+ var contentTypes = ['application/json'];
372
+ var accepts = ['application/json'];
373
+ var returnType = _EthStakeEstimatedFee["default"];
374
+ return this.apiClient.callApi('/stakings/estimate_fee_v2', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
375
+ }
376
+
377
+ /**
378
+ * Estimate staking fees
379
+ * This operation calculates the fee required for a staking activity based on factors such as network congestion and transaction complexity. <Note>For the Babylon protocol, you can only select UTXO as the fee model.</Note>
380
+ * @param {Object} opts Optional parameters
381
+ * @param {module:model/GetStakingEstimationFeeRequest} opts.GetStakingEstimationFeeRequest The request body to get the estimated fee of a staking activity.
382
+ * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/EthStakeEstimatedFee}
383
+ */
384
+ }, {
385
+ key: "getStakingEstimationFeeV2",
386
+ value: function getStakingEstimationFeeV2(opts) {
387
+ return this.getStakingEstimationFeeV2WithHttpInfo(opts).then(function (response_and_data) {
388
+ return response_and_data.data;
389
+ });
390
+ }
391
+
308
392
  /**
309
393
  * Get staking pool details
310
394
  * This operation retrieves the detailed information about a specified staking pool.
@@ -279,7 +279,7 @@ var TransactionsApi = exports["default"] = /*#__PURE__*/function () {
279
279
 
280
280
  /**
281
281
  * Transfer token
282
- * The operation transfers your assets from a wallet created on Cobo Protal to another address. You need to specify details such as the sender address and recipient address, token ID, and the amount to transfer. You can specify the fee-related properties to limit the transaction fee. A transaction request for tracking is returned upon successful operation. <Note>If you make transfers from Custodial Wallets, do not set the fee-related properties. Otherwise, the transaction will fail.</Note> <Note>You can transfer tokens to multiple addresses only if you use MPC Wallets as the transaction source. You should use the <code>utxo_outputs</code> property to specify the destination addresses.</Note> <Info>If you initiate a transaction from a Smart Contract Wallet, a relevant transaction will be triggered from the Delegate to the Cobo Safe's address of the Smart Contract Wallet, with a transfer amount of <code>0</code>.</Info>
282
+ * The operation transfers your assets from a wallet created on Cobo Portal to another address. You need to specify details such as the sender address and recipient address, token ID, and the amount to transfer. You can specify the fee-related properties to limit the transaction fee. A transaction request for tracking is returned upon successful operation. <Note>If you make transfers from Custodial Wallets, do not set the fee-related properties. Otherwise, the transaction will fail.</Note> <Note>You can transfer tokens to multiple addresses only if you use MPC Wallets as the transaction source. You should use the <code>utxo_outputs</code> property to specify the destination addresses.</Note> <Info>If you initiate a transaction from a Smart Contract Wallet, a relevant transaction will be triggered from the Delegate to the Cobo Safe's address of the Smart Contract Wallet, with a transfer amount of <code>0</code>.</Info>
283
283
  * @param {Object} opts Optional parameters
284
284
  * @param {module:model/TransferParams} [TransferParams] The request body to create a transfer transaction
285
285
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/CreateTransferTransaction201Response} and HTTP response
@@ -305,7 +305,7 @@ var TransactionsApi = exports["default"] = /*#__PURE__*/function () {
305
305
 
306
306
  /**
307
307
  * Transfer token
308
- * The operation transfers your assets from a wallet created on Cobo Protal to another address. You need to specify details such as the sender address and recipient address, token ID, and the amount to transfer. You can specify the fee-related properties to limit the transaction fee. A transaction request for tracking is returned upon successful operation. <Note>If you make transfers from Custodial Wallets, do not set the fee-related properties. Otherwise, the transaction will fail.</Note> <Note>You can transfer tokens to multiple addresses only if you use MPC Wallets as the transaction source. You should use the <code>utxo_outputs</code> property to specify the destination addresses.</Note> <Info>If you initiate a transaction from a Smart Contract Wallet, a relevant transaction will be triggered from the Delegate to the Cobo Safe's address of the Smart Contract Wallet, with a transfer amount of <code>0</code>.</Info>
308
+ * The operation transfers your assets from a wallet created on Cobo Portal to another address. You need to specify details such as the sender address and recipient address, token ID, and the amount to transfer. You can specify the fee-related properties to limit the transaction fee. A transaction request for tracking is returned upon successful operation. <Note>If you make transfers from Custodial Wallets, do not set the fee-related properties. Otherwise, the transaction will fail.</Note> <Note>You can transfer tokens to multiple addresses only if you use MPC Wallets as the transaction source. You should use the <code>utxo_outputs</code> property to specify the destination addresses.</Note> <Info>If you initiate a transaction from a Smart Contract Wallet, a relevant transaction will be triggered from the Delegate to the Cobo Safe's address of the Smart Contract Wallet, with a transfer amount of <code>0</code>.</Info>
309
309
  * @param {Object} opts Optional parameters
310
310
  * @param {module:model/TransferParams} opts.TransferParams The request body to create a transfer transaction
311
311
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/CreateTransferTransaction201Response}
@@ -369,7 +369,7 @@ var TransactionsApi = exports["default"] = /*#__PURE__*/function () {
369
369
 
370
370
  /**
371
371
  * Estimate transaction fee
372
- * This operation estimates the transaction fee rates of a token transfer or a contract call based on three different transaction speeds (slow, recommended, and fast), considering factors such as network congestion and transaction complexity. You need to specify the transaction information, including the request ID, request type, source address, destination address, and token ID of the transaction fee. The response can contain different properties based on the transaction fee model used by the chain, including EIP-1559 fee model, legacy fee model, UTXO fee model, and fixed fee model.
372
+ * This operation estimates the transaction fee of a token transfer or a contract call based on the fee model that the chain uses, considering factors such as network congestion and transaction complexity. You need to specify the transaction information, including the request ID, request type, source address, destination address, token ID (only applicable to token transfers), and chain ID (only applicable to contract calls). The response can contain different properties based on the transaction fee model used by the chain. For the legacy, EIP-1559, and UTXO fee models, Cobo also supports three different transaction speed levels: slow, recommended, and fast. For more information about estimating transaction fees, refer to [Estimate transaction fee](/v2/guides/transactions/estimate-fees).
373
373
  * @param {Object} opts Optional parameters
374
374
  * @param {module:model/EstimateFeeParams} [EstimateFeeParams] The request body to estimate the transaction fee of a token transfer or a contract call.
375
375
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/EstimatedFee} and HTTP response
@@ -395,7 +395,7 @@ var TransactionsApi = exports["default"] = /*#__PURE__*/function () {
395
395
 
396
396
  /**
397
397
  * Estimate transaction fee
398
- * This operation estimates the transaction fee rates of a token transfer or a contract call based on three different transaction speeds (slow, recommended, and fast), considering factors such as network congestion and transaction complexity. You need to specify the transaction information, including the request ID, request type, source address, destination address, and token ID of the transaction fee. The response can contain different properties based on the transaction fee model used by the chain, including EIP-1559 fee model, legacy fee model, UTXO fee model, and fixed fee model.
398
+ * This operation estimates the transaction fee of a token transfer or a contract call based on the fee model that the chain uses, considering factors such as network congestion and transaction complexity. You need to specify the transaction information, including the request ID, request type, source address, destination address, token ID (only applicable to token transfers), and chain ID (only applicable to contract calls). The response can contain different properties based on the transaction fee model used by the chain. For the legacy, EIP-1559, and UTXO fee models, Cobo also supports three different transaction speed levels: slow, recommended, and fast. For more information about estimating transaction fees, refer to [Estimate transaction fee](/v2/guides/transactions/estimate-fees).
399
399
  * @param {Object} opts Optional parameters
400
400
  * @param {module:model/EstimateFeeParams} opts.EstimateFeeParams The request body to estimate the transaction fee of a token transfer or a contract call.
401
401
  * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/EstimatedFee}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _tweetnacl = require("tweetnacl");
8
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
9
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
10
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
11
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
12
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
13
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
14
+ var Ed25519Signer = exports["default"] = /*#__PURE__*/function () {
15
+ function Ed25519Signer(privateKey) {
16
+ _classCallCheck(this, Ed25519Signer);
17
+ this.privateKey = privateKey;
18
+ }
19
+ return _createClass(Ed25519Signer, [{
20
+ key: "sign",
21
+ value: function sign(message_hash) {
22
+ var pk = this.getPublicKey(this.privateKey);
23
+ var skBytes = new Uint8Array(Buffer.from(this.privateKey + pk, 'hex'));
24
+ var messageBytes = new Uint8Array(Buffer.from(message_hash, 'hex'));
25
+ var signature = _tweetnacl.sign.detached(messageBytes, skBytes);
26
+ return Buffer.from(signature).toString('hex');
27
+ }
28
+ }, {
29
+ key: "getPublicKey",
30
+ value: function getPublicKey() {
31
+ var skBytes = new Uint8Array(Buffer.from(this.privateKey, 'hex'));
32
+ var pk = _tweetnacl.sign.keyPair.fromSeed(skBytes).publicKey;
33
+ return Buffer.from(pk).toString('hex');
34
+ }
35
+ }]);
36
+ }();
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _elliptic = require("elliptic");
8
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
9
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
10
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
11
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
12
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
13
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
14
+ var ec = new _elliptic.ec('secp256k1');
15
+ var Secp256k1Signer = exports["default"] = /*#__PURE__*/function () {
16
+ function Secp256k1Signer(privateKey) {
17
+ _classCallCheck(this, Secp256k1Signer);
18
+ this.privateKey = privateKey;
19
+ this.keyPair = ec.keyFromPrivate(privateKey, 'hex');
20
+ }
21
+ return _createClass(Secp256k1Signer, [{
22
+ key: "sign",
23
+ value: function sign(message) {
24
+ var messageHash = Buffer.from(message, 'hex');
25
+ var signature = this.keyPair.sign(messageHash, {
26
+ canonical: true
27
+ });
28
+ return Buffer.from(signature.toDER()).toString('hex');
29
+ }
30
+ }, {
31
+ key: "getPublicKey",
32
+ value: function getPublicKey() {
33
+ return this.keyPair.getPublic(true, 'hex');
34
+ }
35
+ }]);
36
+ }();