@cityofzion/bs-multichain 3.1.13 → 3.1.15

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.
@@ -50,7 +50,7 @@ class SimpleSwapApi {
50
50
  }
51
51
  catch (error) {
52
52
  if (axios_1.default.isAxiosError(error) && error.response?.data.message) {
53
- throw new Error(error.response.data.message);
53
+ throw new Error(error.response.data.message, { cause: error });
54
54
  }
55
55
  throw error;
56
56
  }
@@ -69,7 +69,7 @@ class SimpleSwapApi {
69
69
  }
70
70
  catch (error) {
71
71
  if (axios_1.default.isAxiosError(error) && error.response?.data.message) {
72
- throw new Error(error.response.data.message);
72
+ throw new Error(error.response.data.message, { cause: error });
73
73
  }
74
74
  throw error;
75
75
  }
@@ -88,7 +88,7 @@ class SimpleSwapApi {
88
88
  }
89
89
  catch (error) {
90
90
  if (axios_1.default.isAxiosError(error) && error.response?.data.message) {
91
- throw new Error(error.response.data.message);
91
+ throw new Error(error.response.data.message, { cause: error });
92
92
  }
93
93
  throw error;
94
94
  }
@@ -108,7 +108,7 @@ class SimpleSwapApi {
108
108
  }
109
109
  catch (error) {
110
110
  if (axios_1.default.isAxiosError(error) && error.response?.data.message) {
111
- throw new Error(error.response.data.message);
111
+ throw new Error(error.response.data.message, { cause: error });
112
112
  }
113
113
  throw error;
114
114
  }
@@ -123,7 +123,7 @@ class SimpleSwapApi {
123
123
  amount,
124
124
  userRefundAddress: refundAddress,
125
125
  addressTo: address,
126
- extraIdTo: extraIdToReceive?.trim() ?? null,
126
+ extraIdTo: extraIdToReceive?.trim() || null,
127
127
  });
128
128
  return {
129
129
  id: result.id,
@@ -133,7 +133,7 @@ class SimpleSwapApi {
133
133
  }
134
134
  catch (error) {
135
135
  if (axios_1.default.isAxiosError(error) && error.response?.data.message) {
136
- throw new Error(error.response.data.message);
136
+ throw new Error(error.response.data.message, { cause: error });
137
137
  }
138
138
  throw error;
139
139
  }
@@ -150,7 +150,7 @@ class SimpleSwapApi {
150
150
  }
151
151
  catch (error) {
152
152
  if (axios_1.default.isAxiosError(error) && error.response?.data.message) {
153
- throw new Error(error.response.data.message);
153
+ throw new Error(error.response.data.message, { cause: error });
154
154
  }
155
155
  throw error;
156
156
  }
@@ -143,9 +143,8 @@ class SimpleSwapOrchestrator {
143
143
  !__classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_tokenToUse_get).value.hash ||
144
144
  __classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_tokenToUse_get).value.decimals === undefined ||
145
145
  isNaN(__classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_tokenToUse_get).value.decimals) ||
146
- (__classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_tokenToReceive_get).value.hasExtraId &&
147
- (!__classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_extraIdToReceive_get).valid || !__classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_extraIdToReceive_get).value?.trim()))) {
148
- throw new blockchain_service_1.BSError('Not all required fields are set', 'MISSING_REQUIRED_FIELDS');
146
+ (__classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_tokenToReceive_get).value.hasExtraId && __classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_extraIdToReceive_get).valid === false)) {
147
+ throw new blockchain_service_1.BSError('Invalid fields', 'INVALID_FIELDS');
149
148
  }
150
149
  const response = {
151
150
  id: '',
@@ -391,10 +390,12 @@ _SimpleSwapOrchestrator_api = new WeakMap(), _SimpleSwapOrchestrator_blockchainS
391
390
  }
392
391
  if (shouldRecalculateAmountToReceive && __classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_tokenToReceive_get).value && __classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_amountToUse_get).value) {
393
392
  try {
394
- const estimate = await __classPrivateFieldGet(this, _SimpleSwapOrchestrator_api, "f").getEstimate(__classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_tokenToUse_get).value, __classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_tokenToReceive_get).value, __classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_amountToUse_get).value);
395
- __classPrivateFieldSet(this, _SimpleSwapOrchestrator_instances, {
396
- value: estimate,
397
- }, "a", _SimpleSwapOrchestrator_amountToReceive_set);
393
+ const estimatedValue = await __classPrivateFieldGet(this, _SimpleSwapOrchestrator_api, "f").getEstimate(__classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_tokenToUse_get).value, __classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_tokenToReceive_get).value, __classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_amountToUse_get).value);
394
+ const decimals = __classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_tokenToReceive_get).value.decimals;
395
+ const value = typeof decimals === 'number' && !isNaN(decimals)
396
+ ? new blockchain_service_1.BSBigHumanAmount(estimatedValue, decimals).toFormatted()
397
+ : estimatedValue;
398
+ __classPrivateFieldSet(this, _SimpleSwapOrchestrator_instances, { value }, "a", _SimpleSwapOrchestrator_amountToReceive_set);
398
399
  }
399
400
  catch (error) {
400
401
  this.eventEmitter.emit('error', error.message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cityofzion/bs-multichain",
3
- "version": "3.1.13",
3
+ "version": "3.1.15",
4
4
  "repository": "https://github.com/CityOfZion/blockchain-services",
5
5
  "license": "GPL-3.0-only",
6
6
  "author": "Coz",
@@ -13,7 +13,7 @@
13
13
  "@walletconnect/utils": "~2.21.9",
14
14
  "@walletconnect/jsonrpc-utils": "~1.0.8",
15
15
  "axios": "~1.15.0",
16
- "@cityofzion/blockchain-service": "3.1.13"
16
+ "@cityofzion/blockchain-service": "3.1.15"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@types/node": "~24.5.2",
@@ -23,13 +23,13 @@
23
23
  "typed-emitter": "~2.1.0",
24
24
  "typescript": "~5.9.2",
25
25
  "vitest": "~4.0.18",
26
- "@cityofzion/bs-bitcoin": "3.1.13",
27
- "@cityofzion/bs-ethereum": "3.1.13",
28
- "@cityofzion/bs-neo3": "3.1.13",
29
- "@cityofzion/bs-neox": "3.1.13",
30
- "@cityofzion/bs-stellar": "3.1.13",
31
- "@cityofzion/bs-solana": "3.1.13",
32
- "@cityofzion/bs-neo-legacy": "3.1.13"
26
+ "@cityofzion/bs-neo3": "3.1.15",
27
+ "@cityofzion/bs-neox": "3.1.15",
28
+ "@cityofzion/bs-bitcoin": "3.1.15",
29
+ "@cityofzion/bs-ethereum": "3.1.15",
30
+ "@cityofzion/bs-neo-legacy": "3.1.15",
31
+ "@cityofzion/bs-solana": "3.1.15",
32
+ "@cityofzion/bs-stellar": "3.1.15"
33
33
  },
34
34
  "scripts": {
35
35
  "build": "rm -rf ./dist && rm -f *.tgz && npm run typecheck && tsc --project tsconfig.build.json",