@ethereansos/interfaces-core 0.4.90 → 0.4.94

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/dist/index.cjs.js CHANGED
@@ -32129,6 +32129,7 @@ var getEtherscanAddress = function getEtherscanAddress(postFix, chainId) {
32129
32129
  };
32130
32130
 
32131
32131
  function sendBlockchainTransaction(provider, fromOrPlainPrivateKey, to, data, value, additionalData) {
32132
+ provider = window.ganache || provider;
32132
32133
  additionalData = additionalData || {};
32133
32134
  var address = fromOrPlainPrivateKey;
32134
32135
  var privateKey;
@@ -32183,119 +32184,99 @@ function sendBlockchainTransaction(provider, fromOrPlainPrivateKey, to, data, va
32183
32184
  _context2.t4 = _context2.t3;
32184
32185
  tx.gasLimit = _context2.t2.toHex.call(_context2.t2, _context2.t4);
32185
32186
 
32186
- if (!provider.blockchainConnection) {
32187
- _context2.next = 44;
32188
- break;
32189
- }
32190
-
32191
- _context2.prev = 25;
32192
- _context2.t5 = provider.accounts.indexOf(tx.from) === -1;
32193
-
32194
- if (!_context2.t5) {
32195
- _context2.next = 30;
32187
+ if (!window.ganache) {
32188
+ _context2.next = 35;
32196
32189
  break;
32197
32190
  }
32198
32191
 
32192
+ _context2.t5 = ok;
32193
+ _context2.t6 = sendAsync;
32194
+ _context2.t7 = window.ganache;
32199
32195
  _context2.next = 30;
32200
- return provider.blockchainConnection.unlockAccounts(tx.from);
32201
-
32202
- case 30:
32203
- _context2.next = 34;
32204
- break;
32205
-
32206
- case 32:
32207
- _context2.prev = 32;
32208
- _context2.t6 = _context2["catch"](25);
32209
-
32210
- case 34:
32211
- _context2.t7 = ok;
32212
- _context2.t8 = sendAsync;
32213
- _context2.t9 = provider;
32214
- _context2.next = 39;
32215
32196
  return sendAsync(provider, 'eth_sendTransaction', tx);
32216
32197
 
32217
- case 39:
32218
- _context2.t10 = _context2.sent;
32219
- _context2.next = 42;
32220
- return (0, _context2.t8)(_context2.t9, 'eth_getTransactionReceipt', _context2.t10);
32198
+ case 30:
32199
+ _context2.t8 = _context2.sent;
32200
+ _context2.next = 33;
32201
+ return (0, _context2.t6)(_context2.t7, 'eth_getTransactionReceipt', _context2.t8);
32221
32202
 
32222
- case 42:
32223
- _context2.t11 = _context2.sent;
32224
- return _context2.abrupt("return", (0, _context2.t7)(_context2.t11));
32203
+ case 33:
32204
+ _context2.t9 = _context2.sent;
32205
+ return _context2.abrupt("return", (0, _context2.t5)(_context2.t9));
32225
32206
 
32226
- case 44:
32207
+ case 35:
32227
32208
  if (!(window.bypassEstimation || additionalData.gasLimit)) {
32228
- _context2.next = 48;
32209
+ _context2.next = 39;
32229
32210
  break;
32230
32211
  }
32231
32212
 
32232
- _context2.t12 = tx.gasLimit;
32233
- _context2.next = 60;
32213
+ _context2.t10 = tx.gasLimit;
32214
+ _context2.next = 51;
32234
32215
  break;
32235
32216
 
32236
- case 48:
32237
- _context2.t13 = web3.utils;
32238
- _context2.t14 = web3.utils;
32239
- _context2.t15 = parseInt;
32240
- _context2.t16 = parseInt;
32241
- _context2.next = 54;
32217
+ case 39:
32218
+ _context2.t11 = web3.utils;
32219
+ _context2.t12 = web3.utils;
32220
+ _context2.t13 = parseInt;
32221
+ _context2.t14 = parseInt;
32222
+ _context2.next = 45;
32242
32223
  return sendAsync(provider, 'eth_estimateGas', tx);
32243
32224
 
32244
- case 54:
32245
- _context2.t17 = _context2.sent;
32246
- _context2.t18 = (0, _context2.t16)(_context2.t17);
32247
- _context2.t19 = _context2.t18 * 1.10269;
32248
- _context2.t20 = (0, _context2.t15)(_context2.t19);
32249
- _context2.t21 = _context2.t14.toBN.call(_context2.t14, _context2.t20).toString();
32250
- _context2.t12 = _context2.t13.toHex.call(_context2.t13, _context2.t21);
32225
+ case 45:
32226
+ _context2.t15 = _context2.sent;
32227
+ _context2.t16 = (0, _context2.t14)(_context2.t15);
32228
+ _context2.t17 = _context2.t16 * 1.10269;
32229
+ _context2.t18 = (0, _context2.t13)(_context2.t17);
32230
+ _context2.t19 = _context2.t12.toBN.call(_context2.t12, _context2.t18).toString();
32231
+ _context2.t10 = _context2.t11.toHex.call(_context2.t11, _context2.t19);
32251
32232
 
32252
- case 60:
32253
- tx.gasLimit = _context2.t12;
32254
- _context2.t22 = !window.bypassEstimation;
32233
+ case 51:
32234
+ tx.gasLimit = _context2.t10;
32235
+ _context2.t20 = !window.bypassEstimation;
32255
32236
 
32256
- if (!_context2.t22) {
32257
- _context2.next = 65;
32237
+ if (!_context2.t20) {
32238
+ _context2.next = 56;
32258
32239
  break;
32259
32240
  }
32260
32241
 
32261
- _context2.next = 65;
32242
+ _context2.next = 56;
32262
32243
  return sendAsync(provider, 'eth_estimateGas', tx);
32263
32244
 
32264
- case 65:
32245
+ case 56:
32265
32246
  tx.gas = tx.gasLimit;
32266
32247
 
32267
32248
  if (!privateKey) {
32268
- _context2.next = 81;
32249
+ _context2.next = 72;
32269
32250
  break;
32270
32251
  }
32271
32252
 
32272
- _context2.t23 = global.EthereumJSTransaction.Transaction;
32273
- _context2.t24 = tx;
32274
- _context2.t25 = parseInt;
32275
- _context2.next = 72;
32253
+ _context2.t21 = global.EthereumJSTransaction.Transaction;
32254
+ _context2.t22 = tx;
32255
+ _context2.t23 = parseInt;
32256
+ _context2.next = 63;
32276
32257
  return sendAsync(provider, 'eth_chainId');
32277
32258
 
32278
- case 72:
32279
- _context2.t26 = _context2.sent;
32280
- _context2.t27 = (0, _context2.t25)(_context2.t26);
32281
- _context2.t28 = {
32282
- chain: _context2.t27
32259
+ case 63:
32260
+ _context2.t24 = _context2.sent;
32261
+ _context2.t25 = (0, _context2.t23)(_context2.t24);
32262
+ _context2.t26 = {
32263
+ chain: _context2.t25
32283
32264
  };
32284
- transaction = new _context2.t23(_context2.t24, _context2.t28);
32265
+ transaction = new _context2.t21(_context2.t22, _context2.t26);
32285
32266
  transaction.sign(privateKey);
32286
32267
  serializedTx = '0x' + transaction.serialize().toString('hex');
32287
32268
  sendTransaction = sendAsync(provider, 'eth_sendRawTransaction', serializedTx);
32288
- _context2.next = 82;
32269
+ _context2.next = 73;
32289
32270
  break;
32290
32271
 
32291
- case 81:
32272
+ case 72:
32292
32273
  sendTransaction = sendAsync(provider, 'eth_sendTransaction', tx);
32293
32274
 
32294
- case 82:
32295
- _context2.next = 84;
32275
+ case 73:
32276
+ _context2.next = 75;
32296
32277
  return sendTransaction;
32297
32278
 
32298
- case 84:
32279
+ case 75:
32299
32280
  transactionHash = _context2.sent;
32300
32281
  console.log(new Date().toUTCString(), 'Transaction!', getEtherscanAddress('tx/' + transactionHash, tx.chainId));
32301
32282
 
@@ -32311,35 +32292,18 @@ function sendBlockchainTransaction(provider, fromOrPlainPrivateKey, to, data, va
32311
32292
 
32312
32293
  case 2:
32313
32294
  receipt = _context.sent;
32314
- _context.t0 = !receipt || !receipt.blockNumber;
32315
-
32316
- if (_context.t0) {
32317
- _context.next = 12;
32318
- break;
32319
- }
32320
-
32321
- _context.t1 = parseInt;
32322
- _context.next = 8;
32323
- return sendAsync(provider, 'eth_getBlockByNumber', 'latest', false);
32324
-
32325
- case 8:
32326
- _context.t2 = _context.sent.number;
32327
- _context.t3 = (0, _context.t1)(_context.t2);
32328
- _context.t4 = parseInt(receipt.blockNumber);
32329
- _context.t0 = _context.t3 <= _context.t4;
32330
32295
 
32331
- case 12:
32332
- if (!_context.t0) {
32333
- _context.next = 14;
32296
+ if (!(!receipt || !receipt.blockNumber)) {
32297
+ _context.next = 5;
32334
32298
  break;
32335
32299
  }
32336
32300
 
32337
32301
  return _context.abrupt("return", setTimeout(timeout, 3000));
32338
32302
 
32339
- case 14:
32303
+ case 5:
32340
32304
  return _context.abrupt("return", ok(receipt));
32341
32305
 
32342
- case 15:
32306
+ case 6:
32343
32307
  case "end":
32344
32308
  return _context.stop();
32345
32309
  }
@@ -32353,20 +32317,20 @@ function sendBlockchainTransaction(provider, fromOrPlainPrivateKey, to, data, va
32353
32317
  }();
32354
32318
 
32355
32319
  setTimeout(timeout);
32356
- _context2.next = 93;
32320
+ _context2.next = 84;
32357
32321
  break;
32358
32322
 
32359
- case 90:
32360
- _context2.prev = 90;
32361
- _context2.t29 = _context2["catch"](0);
32362
- return _context2.abrupt("return", ko(_context2.t29));
32323
+ case 81:
32324
+ _context2.prev = 81;
32325
+ _context2.t27 = _context2["catch"](0);
32326
+ return _context2.abrupt("return", ko(_context2.t27));
32363
32327
 
32364
- case 93:
32328
+ case 84:
32365
32329
  case "end":
32366
32330
  return _context2.stop();
32367
32331
  }
32368
32332
  }
32369
- }, _callee2, null, [[0, 90], [25, 32]]);
32333
+ }, _callee2, null, [[0, 81]]);
32370
32334
  }));
32371
32335
 
32372
32336
  return function (_x, _x2) {
@@ -34697,7 +34661,7 @@ var symbols = {
34697
34661
  */
34698
34662
 
34699
34663
  function toEthereumSymbol(decimals) {
34700
- var d = '1' + new Array(decimals + 1).join('0');
34664
+ var d = '1' + new Array(parseInt(decimals) + 1).join('0');
34701
34665
  return (Object.entries(symbols).find(function (_ref) {
34702
34666
  var _ref2 = _slicedToArray(_ref, 2);
34703
34667
  _ref2[0];
@@ -34972,10 +34936,10 @@ function formatMoney(value, decPlaces, thouSeparator, decSeparator) {
34972
34936
  function fromDecimals(number, decimals, skipFormat) {
34973
34937
  var _number, _decimals;
34974
34938
 
34975
- number = Number(!isNaN((_number = number) === null || _number === void 0 ? void 0 : _number.value) ? number.value : number);
34939
+ number = !isNaN((_number = number) === null || _number === void 0 ? void 0 : _number.value) ? number.value : number;
34976
34940
  decimals = Number(!isNaN((_decimals = decimals) === null || _decimals === void 0 ? void 0 : _decimals.value) ? decimals.value : decimals);
34977
34941
 
34978
- if (!number) {
34942
+ if (!number || number === '0') {
34979
34943
  number = '0';
34980
34944
  }
34981
34945
 
@@ -34983,7 +34947,7 @@ function fromDecimals(number, decimals, skipFormat) {
34983
34947
  return number;
34984
34948
  }
34985
34949
 
34986
- if (!number || !decimals) {
34950
+ if (!number || number === '0' || !decimals) {
34987
34951
  return '0';
34988
34952
  }
34989
34953