From d917c485f885448e38371497a53fc4dbd85e4c0a Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Mon, 30 Nov 2020 16:30:58 +0530 Subject: [PATCH] srcinTs --- .../src/{eventManager.js => eventManager.ts} | 0 .../{eventsDecoder.js => eventsDecoder.ts} | 4 +++- ...cution-context.js => execution-context.ts} | 6 ++--- .../{logsManager.js => logsManager.ts} | 0 .../{txExecution.js => txExecution.ts} | 2 +- .../execution/{txFormat.js => txFormat.ts} | 0 .../execution/{txHelper.js => txHelper.ts} | 4 ++-- .../{txListener.js => txListener.ts} | 15 ++++++++++-- .../execution/{txRunner.js => txRunner.ts} | 24 +++++++++++++------ .../{typeConversion.js => typeConversion.ts} | 0 .../{compilerHelper.js => compilerHelper.ts} | 0 .../{txResultHelper.js => txResultHelper.ts} | 0 .../src/helpers/{uiHelper.js => uiHelper.ts} | 0 libs/remix-lib/src/{init.js => init.ts} | 0 libs/remix-lib/src/{storage.js => storage.ts} | 0 .../{universalDapp.js => universalDapp.ts} | 0 libs/remix-lib/src/{util.js => util.ts} | 12 +++++----- .../{dummyProvider.js => dummyProvider.ts} | 0 .../{web3Providers.js => web3Providers.ts} | 0 .../{web3VmProvider.js => web3VmProvider.ts} | 0 20 files changed, 45 insertions(+), 22 deletions(-) rename libs/remix-lib/src/{eventManager.js => eventManager.ts} (100%) rename libs/remix-lib/src/execution/{eventsDecoder.js => eventsDecoder.ts} (98%) rename libs/remix-lib/src/execution/{execution-context.js => execution-context.ts} (98%) rename libs/remix-lib/src/execution/{logsManager.js => logsManager.ts} (100%) rename libs/remix-lib/src/execution/{txExecution.js => txExecution.ts} (99%) rename libs/remix-lib/src/execution/{txFormat.js => txFormat.ts} (100%) rename libs/remix-lib/src/execution/{txHelper.js => txHelper.ts} (98%) rename libs/remix-lib/src/execution/{txListener.js => txListener.ts} (98%) rename libs/remix-lib/src/execution/{txRunner.js => txRunner.ts} (96%) rename libs/remix-lib/src/execution/{typeConversion.js => typeConversion.ts} (100%) rename libs/remix-lib/src/helpers/{compilerHelper.js => compilerHelper.ts} (100%) rename libs/remix-lib/src/helpers/{txResultHelper.js => txResultHelper.ts} (100%) rename libs/remix-lib/src/helpers/{uiHelper.js => uiHelper.ts} (100%) rename libs/remix-lib/src/{init.js => init.ts} (100%) rename libs/remix-lib/src/{storage.js => storage.ts} (100%) rename libs/remix-lib/src/{universalDapp.js => universalDapp.ts} (100%) rename libs/remix-lib/src/{util.js => util.ts} (95%) rename libs/remix-lib/src/web3Provider/{dummyProvider.js => dummyProvider.ts} (100%) rename libs/remix-lib/src/web3Provider/{web3Providers.js => web3Providers.ts} (100%) rename libs/remix-lib/src/web3Provider/{web3VmProvider.js => web3VmProvider.ts} (100%) diff --git a/libs/remix-lib/src/eventManager.js b/libs/remix-lib/src/eventManager.ts similarity index 100% rename from libs/remix-lib/src/eventManager.js rename to libs/remix-lib/src/eventManager.ts diff --git a/libs/remix-lib/src/execution/eventsDecoder.js b/libs/remix-lib/src/execution/eventsDecoder.ts similarity index 98% rename from libs/remix-lib/src/execution/eventsDecoder.js rename to libs/remix-lib/src/execution/eventsDecoder.ts index b524f8e5c2..694b965d2b 100644 --- a/libs/remix-lib/src/execution/eventsDecoder.js +++ b/libs/remix-lib/src/execution/eventsDecoder.ts @@ -1,5 +1,5 @@ 'use strict' -const ethers = require('ethers') +import { ethers } from 'ethers' const txHelper = require('./txHelper') /** @@ -7,6 +7,8 @@ const txHelper = require('./txHelper') * */ class EventsDecoder { + resolveReceipt + constructor ({resolveReceipt}) { this.resolveReceipt = resolveReceipt } diff --git a/libs/remix-lib/src/execution/execution-context.js b/libs/remix-lib/src/execution/execution-context.ts similarity index 98% rename from libs/remix-lib/src/execution/execution-context.js rename to libs/remix-lib/src/execution/execution-context.ts index d77bca07b9..a026a1d0a5 100644 --- a/libs/remix-lib/src/execution/execution-context.js +++ b/libs/remix-lib/src/execution/execution-context.ts @@ -1,6 +1,6 @@ /* global ethereum */ 'use strict' -const Web3 = require('web3') +import Web3 from 'web3' const EventManager = require('../eventManager') const EthJSVM = require('ethereumjs-vm').default const ethUtil = require('ethereumjs-util') @@ -12,8 +12,8 @@ const LogsManager = require('./logsManager.js') const rlp = ethUtil.rlp let web3 -if (typeof window !== 'undefined' && typeof window.ethereum !== 'undefined') { - var injectedProvider = window.ethereum +if (typeof window !== 'undefined' && typeof window['ethereum'] !== 'undefined') { + var injectedProvider = window['ethereum'] web3 = new Web3(injectedProvider) } else { web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545')) diff --git a/libs/remix-lib/src/execution/logsManager.js b/libs/remix-lib/src/execution/logsManager.ts similarity index 100% rename from libs/remix-lib/src/execution/logsManager.js rename to libs/remix-lib/src/execution/logsManager.ts diff --git a/libs/remix-lib/src/execution/txExecution.js b/libs/remix-lib/src/execution/txExecution.ts similarity index 99% rename from libs/remix-lib/src/execution/txExecution.js rename to libs/remix-lib/src/execution/txExecution.ts index bb89eff5cb..0e4bdb942f 100644 --- a/libs/remix-lib/src/execution/txExecution.js +++ b/libs/remix-lib/src/execution/txExecution.ts @@ -1,5 +1,5 @@ 'use strict' -const ethers = require('ethers') +import { ethers } from 'ethers' module.exports = { /** diff --git a/libs/remix-lib/src/execution/txFormat.js b/libs/remix-lib/src/execution/txFormat.ts similarity index 100% rename from libs/remix-lib/src/execution/txFormat.js rename to libs/remix-lib/src/execution/txFormat.ts diff --git a/libs/remix-lib/src/execution/txHelper.js b/libs/remix-lib/src/execution/txHelper.ts similarity index 98% rename from libs/remix-lib/src/execution/txHelper.js rename to libs/remix-lib/src/execution/txHelper.ts index fb50c80f50..879377de95 100644 --- a/libs/remix-lib/src/execution/txHelper.js +++ b/libs/remix-lib/src/execution/txHelper.ts @@ -1,5 +1,5 @@ 'use strict' -const ethers = require('ethers') +import { ethers } from 'ethers' module.exports = { makeFullTypeDefinition: function (typeDef) { @@ -76,7 +76,7 @@ module.exports = { if (abi[i].type === 'constructor') { funABI.inputs = abi[i].inputs || [] funABI.payable = abi[i].payable - funABI.stateMutability = abi[i].stateMutability + funABI['stateMutability'] = abi[i].stateMutability break } } diff --git a/libs/remix-lib/src/execution/txListener.js b/libs/remix-lib/src/execution/txListener.ts similarity index 98% rename from libs/remix-lib/src/execution/txListener.js rename to libs/remix-lib/src/execution/txListener.ts index 06e9b9962a..590fbfe4f8 100644 --- a/libs/remix-lib/src/execution/txListener.js +++ b/libs/remix-lib/src/execution/txListener.ts @@ -1,6 +1,6 @@ 'use strict' -const async = require('async') -const ethers = require('ethers') +import async from 'async' +import { ethers } from 'ethers' const ethJSUtil = require('ethereumjs-util') const EventManager = require('../eventManager') const codeUtil = require('../util') @@ -28,6 +28,17 @@ function addExecutionCosts(txResult, tx) { */ class TxListener { + event + executionContext + _resolvedTransactions + _api + _resolvedContracts + _isListening: boolean + _listenOnNetwork:boolean + _loopId + blocks + lastBlock + constructor (opt, executionContext) { this.event = new EventManager() // has a default for now for backwards compatability diff --git a/libs/remix-lib/src/execution/txRunner.js b/libs/remix-lib/src/execution/txRunner.ts similarity index 96% rename from libs/remix-lib/src/execution/txRunner.js rename to libs/remix-lib/src/execution/txRunner.ts index 2ad6fb737e..a4e3e3f588 100644 --- a/libs/remix-lib/src/execution/txRunner.js +++ b/libs/remix-lib/src/execution/txRunner.ts @@ -1,12 +1,22 @@ 'use strict' const EthJSTX = require('ethereumjs-tx').Transaction const EthJSBlock = require('ethereumjs-block') -const ethJSUtil = require('ethereumjs-util') -const BN = ethJSUtil.BN +import { BN } from 'ethereumjs-util' const defaultExecutionContext = require('./execution-context') const EventManager = require('../eventManager') class TxRunner { + + event + executionContext + _api + blockNumber + runAsync + pendingTxs + vmaccounts + queusTxs + blocks + constructor (vmaccounts, api, executionContext) { this.event = new EventManager() // has a default for now for backwards compatability @@ -63,7 +73,7 @@ class TxRunner { resolve({ result, tx, - transactionHash: result ? result.transactionHash : null + transactionHash: result ? result['transactionHash'] : null }) }) } @@ -167,7 +177,7 @@ class TxRunner { const tx = { from: from, to: to, data: data, value: value } if (useCall) { - tx.gas = gasLimit + tx['gas'] = gasLimit return this.executionContext.web3().eth.call(tx, function (error, result) { callback(error, { result: result, @@ -182,7 +192,7 @@ class TxRunner { } gasEstimationForceSend(err, () => { // callback is called whenever no error - tx.gas = !gasEstimation ? gasLimit : gasEstimation + tx['gas'] = !gasEstimation ? gasLimit : gasEstimation if (this._api.config.getUnpersistedProperty('doNotShowTransactionConfirmationAgain')) { return this._executeTx(tx, null, this._api, promptCb, callback) @@ -194,7 +204,7 @@ class TxRunner { return } - confirmCb(network, tx, tx.gas, (gasPrice) => { + confirmCb(network, tx, tx['gas'], (gasPrice) => { return this._executeTx(tx, gasPrice, this._api, promptCb, callback) }, (error) => { callback(error) @@ -248,7 +258,7 @@ async function tryTillTxAvailable (txhash, executionContext) { async function pause () { return new Promise((resolve, reject) => { setTimeout(resolve, 500) }) } -function run(self, tx, stamp, confirmationCb, gasEstimationForceSend, promptCb, callback) { +function run(self, tx, stamp, confirmationCb, gasEstimationForceSend = null, promptCb = null, callback = null) { if (!self.runAsync && Object.keys(self.pendingTxs).length) { return self.queusTxs.push({ tx, stamp, callback }) } diff --git a/libs/remix-lib/src/execution/typeConversion.js b/libs/remix-lib/src/execution/typeConversion.ts similarity index 100% rename from libs/remix-lib/src/execution/typeConversion.js rename to libs/remix-lib/src/execution/typeConversion.ts diff --git a/libs/remix-lib/src/helpers/compilerHelper.js b/libs/remix-lib/src/helpers/compilerHelper.ts similarity index 100% rename from libs/remix-lib/src/helpers/compilerHelper.js rename to libs/remix-lib/src/helpers/compilerHelper.ts diff --git a/libs/remix-lib/src/helpers/txResultHelper.js b/libs/remix-lib/src/helpers/txResultHelper.ts similarity index 100% rename from libs/remix-lib/src/helpers/txResultHelper.js rename to libs/remix-lib/src/helpers/txResultHelper.ts diff --git a/libs/remix-lib/src/helpers/uiHelper.js b/libs/remix-lib/src/helpers/uiHelper.ts similarity index 100% rename from libs/remix-lib/src/helpers/uiHelper.js rename to libs/remix-lib/src/helpers/uiHelper.ts diff --git a/libs/remix-lib/src/init.js b/libs/remix-lib/src/init.ts similarity index 100% rename from libs/remix-lib/src/init.js rename to libs/remix-lib/src/init.ts diff --git a/libs/remix-lib/src/storage.js b/libs/remix-lib/src/storage.ts similarity index 100% rename from libs/remix-lib/src/storage.js rename to libs/remix-lib/src/storage.ts diff --git a/libs/remix-lib/src/universalDapp.js b/libs/remix-lib/src/universalDapp.ts similarity index 100% rename from libs/remix-lib/src/universalDapp.js rename to libs/remix-lib/src/universalDapp.ts diff --git a/libs/remix-lib/src/util.js b/libs/remix-lib/src/util.ts similarity index 95% rename from libs/remix-lib/src/util.js rename to libs/remix-lib/src/util.ts index 8fcf7a32c7..97b792d147 100644 --- a/libs/remix-lib/src/util.js +++ b/libs/remix-lib/src/util.ts @@ -1,5 +1,5 @@ 'use strict' -const ethutil = require('ethereumjs-util') +import { BN, bufferToHex, keccak, setLengthLeft } from 'ethereumjs-util' /* contains misc util: @TODO should be splitted @@ -48,10 +48,10 @@ module.exports = { const ret = [] for (let k in bnList) { const v = bnList[k] - if (ethutil.BN.isBN(v)) { + if (BN.isBN(v)) { ret.push('0x' + v.toString('hex', 64)) } else { - ret.push('0x' + (new ethutil.BN(v)).toString('hex', 64)) // TEMP FIX TO REMOVE ONCE https://github.com/ethereumjs/ethereumjs-vm/pull/293 is released + ret.push('0x' + (new BN(v)).toString('hex', 64)) // TEMP FIX TO REMOVE ONCE https://github.com/ethereumjs/ethereumjs-vm/pull/293 is released } } return ret @@ -161,9 +161,9 @@ module.exports = { if (typeof value === 'string' && value.indexOf('0x') !== 0) { value = '0x' + value } - let ret = ethutil.bufferToHex(ethutil.setLengthLeft(value, 32)) - ret = ethutil.keccak(ret) - return ethutil.bufferToHex(ret) + let ret: any = bufferToHex(setLengthLeft(value, 32)) + ret = keccak(ret) + return bufferToHex(ret) }, /** diff --git a/libs/remix-lib/src/web3Provider/dummyProvider.js b/libs/remix-lib/src/web3Provider/dummyProvider.ts similarity index 100% rename from libs/remix-lib/src/web3Provider/dummyProvider.js rename to libs/remix-lib/src/web3Provider/dummyProvider.ts diff --git a/libs/remix-lib/src/web3Provider/web3Providers.js b/libs/remix-lib/src/web3Provider/web3Providers.ts similarity index 100% rename from libs/remix-lib/src/web3Provider/web3Providers.js rename to libs/remix-lib/src/web3Provider/web3Providers.ts diff --git a/libs/remix-lib/src/web3Provider/web3VmProvider.js b/libs/remix-lib/src/web3Provider/web3VmProvider.ts similarity index 100% rename from libs/remix-lib/src/web3Provider/web3VmProvider.js rename to libs/remix-lib/src/web3Provider/web3VmProvider.ts