@cityofzion/bs-ethereum 3.0.2 → 3.0.4

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.
@@ -27,7 +27,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
27
27
  exports.MoralisBDSEthereum = void 0;
28
28
  const blockchain_service_1 = require("@cityofzion/blockchain-service");
29
29
  const axios_1 = __importDefault(require("axios"));
30
- const ethers_1 = require("ethers");
31
30
  const BSEthereumHelper_1 = require("../../helpers/BSEthereumHelper");
32
31
  const ERC20_1 = require("../../assets/abis/ERC20");
33
32
  const RpcBDSEthereum_1 = require("./RpcBDSEthereum");
@@ -60,7 +59,9 @@ class MoralisBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
60
59
  const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._service.network);
61
60
  const balances = [
62
61
  {
63
- amount: ethers_1.ethers.utils.formatUnits(nativeBalance, nativeToken.decimals),
62
+ amount: blockchain_service_1.BSBigNumberHelper.format(blockchain_service_1.BSBigNumberHelper.fromDecimals(nativeBalance, nativeToken.decimals), {
63
+ decimals: nativeToken.decimals,
64
+ }),
64
65
  token: nativeToken,
65
66
  },
66
67
  ];
@@ -70,7 +71,9 @@ class MoralisBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
70
71
  if (balance.possible_spam || !balance.decimals || !balance.token_address || !balance.symbol)
71
72
  return;
72
73
  balances.push({
73
- amount: ethers_1.ethers.utils.formatUnits(balance.balance, balance.decimals),
74
+ amount: blockchain_service_1.BSBigNumberHelper.format(blockchain_service_1.BSBigNumberHelper.fromDecimals(balance.balance, balance.decimals), {
75
+ decimals: balance.decimals,
76
+ }),
74
77
  token: this._service.tokenService.normalizeToken({
75
78
  decimals: balance.decimals,
76
79
  hash: balance.token_address,
@@ -133,7 +136,9 @@ class MoralisBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
133
136
  const contractHashUrl = contractTemplateUrl === null || contractTemplateUrl === void 0 ? void 0 : contractTemplateUrl.replace('{hash}', nativeToken.hash);
134
137
  events.push({
135
138
  eventType: 'token',
136
- amount: ethers_1.ethers.utils.formatEther(data.value),
139
+ amount: blockchain_service_1.BSBigNumberHelper.format(blockchain_service_1.BSBigNumberHelper.fromDecimals(data.value, nativeToken.decimals), {
140
+ decimals: nativeToken.decimals,
141
+ }),
137
142
  from: data.from_address,
138
143
  to: data.to_address,
139
144
  token: nativeToken,
@@ -165,7 +170,9 @@ class MoralisBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
165
170
  const token = yield this.getTokenInfo(contractHash);
166
171
  events.push({
167
172
  contractHash,
168
- amount: ethers_1.ethers.utils.formatUnits(amount, token.decimals),
173
+ amount: blockchain_service_1.BSBigNumberHelper.format(blockchain_service_1.BSBigNumberHelper.fromDecimals(amount, token.decimals), {
174
+ decimals: token.decimals,
175
+ }),
169
176
  from,
170
177
  fromUrl,
171
178
  to,
@@ -210,8 +217,9 @@ class MoralisBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
210
217
  date: new Date(data.block_timestamp).toISOString(),
211
218
  invocationCount: 0,
212
219
  notificationCount: 0,
213
- networkFeeAmount: data.transaction_fee,
214
- systemFeeAmount: ethers_1.ethers.utils.formatEther('0'),
220
+ networkFeeAmount: blockchain_service_1.BSBigNumberHelper.format(blockchain_service_1.BSBigNumberHelper.fromNumber(data.transaction_fee), {
221
+ decimals: this._service.feeToken.decimals,
222
+ }),
215
223
  txIdUrl,
216
224
  events,
217
225
  type: 'default',
@@ -245,7 +253,9 @@ class MoralisBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
245
253
  const fromUrl = addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', transfer.from_address);
246
254
  const toUrl = addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', transfer.to_address);
247
255
  events.push({
248
- amount: ethers_1.ethers.utils.formatUnits(transfer.value, nativeAsset.decimals),
256
+ amount: blockchain_service_1.BSBigNumberHelper.format(blockchain_service_1.BSBigNumberHelper.fromDecimals(transfer.value, nativeAsset.decimals), {
257
+ decimals: nativeAsset.decimals,
258
+ }),
249
259
  from: transfer.from_address,
250
260
  fromUrl,
251
261
  to: transfer.to_address,
@@ -265,7 +275,9 @@ class MoralisBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
265
275
  const toUrl = addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', transfer.to_address);
266
276
  const contractHashUrl = contractTemplateUrl === null || contractTemplateUrl === void 0 ? void 0 : contractTemplateUrl.replace('{hash}', transfer.address);
267
277
  events.push({
268
- amount: ethers_1.ethers.utils.formatUnits(transfer.value, transfer.token_decimals),
278
+ amount: blockchain_service_1.BSBigNumberHelper.format(blockchain_service_1.BSBigNumberHelper.fromDecimals(transfer.value, transfer.token_decimals), {
279
+ decimals: transfer.token_decimals,
280
+ }),
269
281
  from: transfer.from_address,
270
282
  fromUrl,
271
283
  to: transfer.to_address,
@@ -316,8 +328,9 @@ class MoralisBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
316
328
  txIdUrl,
317
329
  notificationCount: 0,
318
330
  invocationCount: 0,
319
- networkFeeAmount: item.transaction_fee,
320
- systemFeeAmount: ethers_1.ethers.utils.formatEther('0'),
331
+ networkFeeAmount: blockchain_service_1.BSBigNumberHelper.format(blockchain_service_1.BSBigNumberHelper.fromNumber(item.transaction_fee), {
332
+ decimals: this._service.feeToken.decimals,
333
+ }),
321
334
  date: new Date(item.block_timestamp).toISOString(),
322
335
  events,
323
336
  type: 'default',
@@ -22,6 +22,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
22
22
  var _RpcBDSEthereum_instances, _RpcBDSEthereum_providerInstance, _RpcBDSEthereum_provider_get;
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.RpcBDSEthereum = void 0;
25
+ const blockchain_service_1 = require("@cityofzion/blockchain-service");
25
26
  const ethers_1 = require("ethers");
26
27
  const BSEthereumHelper_1 = require("../../helpers/BSEthereumHelper");
27
28
  const ERC20_1 = require("../../assets/abis/ERC20");
@@ -60,12 +61,15 @@ class RpcBDSEthereum {
60
61
  date: new Date(timestamp).toISOString(),
61
62
  invocationCount: 0,
62
63
  notificationCount: 0,
63
- networkFeeAmount: ethers_1.ethers.utils.formatEther(fee),
64
- systemFeeAmount: ethers_1.ethers.utils.formatEther(0),
64
+ networkFeeAmount: blockchain_service_1.BSBigNumberHelper.format(blockchain_service_1.BSBigNumberHelper.fromDecimals(fee.toString(), this._service.feeToken.decimals), {
65
+ decimals: this._service.feeToken.decimals,
66
+ }),
65
67
  events: [
66
68
  {
67
69
  eventType: 'token',
68
- amount: ethers_1.ethers.utils.formatEther(transaction.value),
70
+ amount: blockchain_service_1.BSBigNumberHelper.format(blockchain_service_1.BSBigNumberHelper.fromDecimals(transaction.value.toString(), token.decimals), {
71
+ decimals: token.decimals,
72
+ }),
69
73
  methodName: 'transfer',
70
74
  from: transaction.from,
71
75
  fromUrl,
@@ -118,7 +122,9 @@ class RpcBDSEthereum {
118
122
  const token = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._service.network);
119
123
  return [
120
124
  {
121
- amount: ethers_1.ethers.utils.formatEther(balance),
125
+ amount: blockchain_service_1.BSBigNumberHelper.format(blockchain_service_1.BSBigNumberHelper.fromDecimals(balance.toString(), token.decimals), {
126
+ decimals: token.decimals,
127
+ }),
122
128
  token,
123
129
  },
124
130
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cityofzion/bs-ethereum",
3
- "version": "3.0.2",
3
+ "version": "3.0.4",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": "https://github.com/CityOfZion/blockchain-services",
@@ -19,7 +19,7 @@
19
19
  "@ledgerhq/hw-app-eth": "~7.3.0",
20
20
  "axios": "~1.13.2",
21
21
  "ethers": "5.8.0",
22
- "@cityofzion/blockchain-service": "3.0.2"
22
+ "@cityofzion/blockchain-service": "3.0.4"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@ledgerhq/hw-transport": "~6.32.0",