@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.esm.js CHANGED
@@ -32118,6 +32118,7 @@ var getEtherscanAddress = function getEtherscanAddress(postFix, chainId) {
32118
32118
  };
32119
32119
 
32120
32120
  function sendBlockchainTransaction(provider, fromOrPlainPrivateKey, to, data, value, additionalData) {
32121
+ provider = window.ganache || provider;
32121
32122
  additionalData = additionalData || {};
32122
32123
  var address = fromOrPlainPrivateKey;
32123
32124
  var privateKey;
@@ -32172,119 +32173,99 @@ function sendBlockchainTransaction(provider, fromOrPlainPrivateKey, to, data, va
32172
32173
  _context2.t4 = _context2.t3;
32173
32174
  tx.gasLimit = _context2.t2.toHex.call(_context2.t2, _context2.t4);
32174
32175
 
32175
- if (!provider.blockchainConnection) {
32176
- _context2.next = 44;
32177
- break;
32178
- }
32179
-
32180
- _context2.prev = 25;
32181
- _context2.t5 = provider.accounts.indexOf(tx.from) === -1;
32182
-
32183
- if (!_context2.t5) {
32184
- _context2.next = 30;
32176
+ if (!window.ganache) {
32177
+ _context2.next = 35;
32185
32178
  break;
32186
32179
  }
32187
32180
 
32181
+ _context2.t5 = ok;
32182
+ _context2.t6 = sendAsync;
32183
+ _context2.t7 = window.ganache;
32188
32184
  _context2.next = 30;
32189
- return provider.blockchainConnection.unlockAccounts(tx.from);
32190
-
32191
- case 30:
32192
- _context2.next = 34;
32193
- break;
32194
-
32195
- case 32:
32196
- _context2.prev = 32;
32197
- _context2.t6 = _context2["catch"](25);
32198
-
32199
- case 34:
32200
- _context2.t7 = ok;
32201
- _context2.t8 = sendAsync;
32202
- _context2.t9 = provider;
32203
- _context2.next = 39;
32204
32185
  return sendAsync(provider, 'eth_sendTransaction', tx);
32205
32186
 
32206
- case 39:
32207
- _context2.t10 = _context2.sent;
32208
- _context2.next = 42;
32209
- return (0, _context2.t8)(_context2.t9, 'eth_getTransactionReceipt', _context2.t10);
32187
+ case 30:
32188
+ _context2.t8 = _context2.sent;
32189
+ _context2.next = 33;
32190
+ return (0, _context2.t6)(_context2.t7, 'eth_getTransactionReceipt', _context2.t8);
32210
32191
 
32211
- case 42:
32212
- _context2.t11 = _context2.sent;
32213
- return _context2.abrupt("return", (0, _context2.t7)(_context2.t11));
32192
+ case 33:
32193
+ _context2.t9 = _context2.sent;
32194
+ return _context2.abrupt("return", (0, _context2.t5)(_context2.t9));
32214
32195
 
32215
- case 44:
32196
+ case 35:
32216
32197
  if (!(window.bypassEstimation || additionalData.gasLimit)) {
32217
- _context2.next = 48;
32198
+ _context2.next = 39;
32218
32199
  break;
32219
32200
  }
32220
32201
 
32221
- _context2.t12 = tx.gasLimit;
32222
- _context2.next = 60;
32202
+ _context2.t10 = tx.gasLimit;
32203
+ _context2.next = 51;
32223
32204
  break;
32224
32205
 
32225
- case 48:
32226
- _context2.t13 = web3.utils;
32227
- _context2.t14 = web3.utils;
32228
- _context2.t15 = parseInt;
32229
- _context2.t16 = parseInt;
32230
- _context2.next = 54;
32206
+ case 39:
32207
+ _context2.t11 = web3.utils;
32208
+ _context2.t12 = web3.utils;
32209
+ _context2.t13 = parseInt;
32210
+ _context2.t14 = parseInt;
32211
+ _context2.next = 45;
32231
32212
  return sendAsync(provider, 'eth_estimateGas', tx);
32232
32213
 
32233
- case 54:
32234
- _context2.t17 = _context2.sent;
32235
- _context2.t18 = (0, _context2.t16)(_context2.t17);
32236
- _context2.t19 = _context2.t18 * 1.10269;
32237
- _context2.t20 = (0, _context2.t15)(_context2.t19);
32238
- _context2.t21 = _context2.t14.toBN.call(_context2.t14, _context2.t20).toString();
32239
- _context2.t12 = _context2.t13.toHex.call(_context2.t13, _context2.t21);
32214
+ case 45:
32215
+ _context2.t15 = _context2.sent;
32216
+ _context2.t16 = (0, _context2.t14)(_context2.t15);
32217
+ _context2.t17 = _context2.t16 * 1.10269;
32218
+ _context2.t18 = (0, _context2.t13)(_context2.t17);
32219
+ _context2.t19 = _context2.t12.toBN.call(_context2.t12, _context2.t18).toString();
32220
+ _context2.t10 = _context2.t11.toHex.call(_context2.t11, _context2.t19);
32240
32221
 
32241
- case 60:
32242
- tx.gasLimit = _context2.t12;
32243
- _context2.t22 = !window.bypassEstimation;
32222
+ case 51:
32223
+ tx.gasLimit = _context2.t10;
32224
+ _context2.t20 = !window.bypassEstimation;
32244
32225
 
32245
- if (!_context2.t22) {
32246
- _context2.next = 65;
32226
+ if (!_context2.t20) {
32227
+ _context2.next = 56;
32247
32228
  break;
32248
32229
  }
32249
32230
 
32250
- _context2.next = 65;
32231
+ _context2.next = 56;
32251
32232
  return sendAsync(provider, 'eth_estimateGas', tx);
32252
32233
 
32253
- case 65:
32234
+ case 56:
32254
32235
  tx.gas = tx.gasLimit;
32255
32236
 
32256
32237
  if (!privateKey) {
32257
- _context2.next = 81;
32238
+ _context2.next = 72;
32258
32239
  break;
32259
32240
  }
32260
32241
 
32261
- _context2.t23 = global.EthereumJSTransaction.Transaction;
32262
- _context2.t24 = tx;
32263
- _context2.t25 = parseInt;
32264
- _context2.next = 72;
32242
+ _context2.t21 = global.EthereumJSTransaction.Transaction;
32243
+ _context2.t22 = tx;
32244
+ _context2.t23 = parseInt;
32245
+ _context2.next = 63;
32265
32246
  return sendAsync(provider, 'eth_chainId');
32266
32247
 
32267
- case 72:
32268
- _context2.t26 = _context2.sent;
32269
- _context2.t27 = (0, _context2.t25)(_context2.t26);
32270
- _context2.t28 = {
32271
- chain: _context2.t27
32248
+ case 63:
32249
+ _context2.t24 = _context2.sent;
32250
+ _context2.t25 = (0, _context2.t23)(_context2.t24);
32251
+ _context2.t26 = {
32252
+ chain: _context2.t25
32272
32253
  };
32273
- transaction = new _context2.t23(_context2.t24, _context2.t28);
32254
+ transaction = new _context2.t21(_context2.t22, _context2.t26);
32274
32255
  transaction.sign(privateKey);
32275
32256
  serializedTx = '0x' + transaction.serialize().toString('hex');
32276
32257
  sendTransaction = sendAsync(provider, 'eth_sendRawTransaction', serializedTx);
32277
- _context2.next = 82;
32258
+ _context2.next = 73;
32278
32259
  break;
32279
32260
 
32280
- case 81:
32261
+ case 72:
32281
32262
  sendTransaction = sendAsync(provider, 'eth_sendTransaction', tx);
32282
32263
 
32283
- case 82:
32284
- _context2.next = 84;
32264
+ case 73:
32265
+ _context2.next = 75;
32285
32266
  return sendTransaction;
32286
32267
 
32287
- case 84:
32268
+ case 75:
32288
32269
  transactionHash = _context2.sent;
32289
32270
  console.log(new Date().toUTCString(), 'Transaction!', getEtherscanAddress('tx/' + transactionHash, tx.chainId));
32290
32271
 
@@ -32300,35 +32281,18 @@ function sendBlockchainTransaction(provider, fromOrPlainPrivateKey, to, data, va
32300
32281
 
32301
32282
  case 2:
32302
32283
  receipt = _context.sent;
32303
- _context.t0 = !receipt || !receipt.blockNumber;
32304
-
32305
- if (_context.t0) {
32306
- _context.next = 12;
32307
- break;
32308
- }
32309
-
32310
- _context.t1 = parseInt;
32311
- _context.next = 8;
32312
- return sendAsync(provider, 'eth_getBlockByNumber', 'latest', false);
32313
-
32314
- case 8:
32315
- _context.t2 = _context.sent.number;
32316
- _context.t3 = (0, _context.t1)(_context.t2);
32317
- _context.t4 = parseInt(receipt.blockNumber);
32318
- _context.t0 = _context.t3 <= _context.t4;
32319
32284
 
32320
- case 12:
32321
- if (!_context.t0) {
32322
- _context.next = 14;
32285
+ if (!(!receipt || !receipt.blockNumber)) {
32286
+ _context.next = 5;
32323
32287
  break;
32324
32288
  }
32325
32289
 
32326
32290
  return _context.abrupt("return", setTimeout(timeout, 3000));
32327
32291
 
32328
- case 14:
32292
+ case 5:
32329
32293
  return _context.abrupt("return", ok(receipt));
32330
32294
 
32331
- case 15:
32295
+ case 6:
32332
32296
  case "end":
32333
32297
  return _context.stop();
32334
32298
  }
@@ -32342,20 +32306,20 @@ function sendBlockchainTransaction(provider, fromOrPlainPrivateKey, to, data, va
32342
32306
  }();
32343
32307
 
32344
32308
  setTimeout(timeout);
32345
- _context2.next = 93;
32309
+ _context2.next = 84;
32346
32310
  break;
32347
32311
 
32348
- case 90:
32349
- _context2.prev = 90;
32350
- _context2.t29 = _context2["catch"](0);
32351
- return _context2.abrupt("return", ko(_context2.t29));
32312
+ case 81:
32313
+ _context2.prev = 81;
32314
+ _context2.t27 = _context2["catch"](0);
32315
+ return _context2.abrupt("return", ko(_context2.t27));
32352
32316
 
32353
- case 93:
32317
+ case 84:
32354
32318
  case "end":
32355
32319
  return _context2.stop();
32356
32320
  }
32357
32321
  }
32358
- }, _callee2, null, [[0, 90], [25, 32]]);
32322
+ }, _callee2, null, [[0, 81]]);
32359
32323
  }));
32360
32324
 
32361
32325
  return function (_x, _x2) {
@@ -34686,7 +34650,7 @@ var symbols = {
34686
34650
  */
34687
34651
 
34688
34652
  function toEthereumSymbol(decimals) {
34689
- var d = '1' + new Array(decimals + 1).join('0');
34653
+ var d = '1' + new Array(parseInt(decimals) + 1).join('0');
34690
34654
  return (Object.entries(symbols).find(function (_ref) {
34691
34655
  var _ref2 = _slicedToArray(_ref, 2);
34692
34656
  _ref2[0];
@@ -34961,10 +34925,10 @@ function formatMoney(value, decPlaces, thouSeparator, decSeparator) {
34961
34925
  function fromDecimals(number, decimals, skipFormat) {
34962
34926
  var _number, _decimals;
34963
34927
 
34964
- number = Number(!isNaN((_number = number) === null || _number === void 0 ? void 0 : _number.value) ? number.value : number);
34928
+ number = !isNaN((_number = number) === null || _number === void 0 ? void 0 : _number.value) ? number.value : number;
34965
34929
  decimals = Number(!isNaN((_decimals = decimals) === null || _decimals === void 0 ? void 0 : _decimals.value) ? decimals.value : decimals);
34966
34930
 
34967
- if (!number) {
34931
+ if (!number || number === '0') {
34968
34932
  number = '0';
34969
34933
  }
34970
34934
 
@@ -34972,7 +34936,7 @@ function fromDecimals(number, decimals, skipFormat) {
34972
34936
  return number;
34973
34937
  }
34974
34938
 
34975
- if (!number || !decimals) {
34939
+ if (!number || number === '0' || !decimals) {
34976
34940
  return '0';
34977
34941
  }
34978
34942