fixing linting for remix-lib

pull/5370/head
lianahus 7 months ago
parent e5aeb0104c
commit c79a55a06c
  1. 2
      libs/remix-lib/project.json
  2. 4
      libs/remix-lib/src/execution/eventsDecoder.ts
  3. 6
      libs/remix-lib/src/execution/logsManager.ts
  4. 12
      libs/remix-lib/src/execution/txFormat.ts
  5. 6
      libs/remix-lib/src/execution/txHelper.ts
  6. 4
      libs/remix-lib/src/execution/txRunnerVM.ts
  7. 20
      libs/remix-lib/src/execution/txRunnerWeb3.ts
  8. 8
      libs/remix-lib/src/helpers/txResultHelper.ts
  9. 4
      libs/remix-lib/src/init.ts
  10. 2
      libs/remix-lib/src/query-params.ts
  11. 6
      libs/remix-lib/src/util.ts
  12. 1
      libs/remix-lib/test/txFormat.ts
  13. 4
      libs/remix-lib/test/txHelper.ts
  14. 2
      libs/remix-lib/test/txResultHelper.ts
  15. 17
      libs/remix-lib/test/util.ts

@ -22,7 +22,7 @@
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["libs/remix-lib/**/*.ts"],
"eslintConfig": "libs/remix-lib/.eslinrc"
"eslintConfig": "libs/remix-lib/.eslintrc"
}
}
},

@ -21,7 +21,7 @@ export class EventsDecoder {
* @param {Function} cb - callback
*/
parseLogs (tx, contractName, compiledContracts, cb) {
if (tx.isCall) return cb(null, { decoded: [], raw: [] })
if (tx.isCall) return cb(null, { decoded: [], raw: []})
this.resolveReceipt(tx, (error, receipt) => {
if (error) return cb(error)
this._decodeLogs(tx, receipt, contractName, compiledContracts, cb)
@ -33,7 +33,7 @@ export class EventsDecoder {
return cb('cannot decode logs - contract or receipt not resolved ')
}
if (!receipt.logs) {
return cb(null, { decoded: [], raw: [] })
return cb(null, { decoded: [], raw: []})
}
this._decodeEvents(tx, receipt.logs, contract, contracts, cb)
}

@ -24,7 +24,7 @@ export class LogsManager {
if (!receipt) return next()
for (const log of receipt.logs) {
this.oldLogs.push({ type: 'block', blockNumber, block, tx, log, txNumber: i, receipt })
const subscriptions = this.getSubscriptionsFor({ type: 'block', blockNumber, block, tx, log, receipt})
const subscriptions = this.getSubscriptionsFor({ type: 'block', blockNumber, block, tx, log, receipt })
for (const subscriptionId of subscriptions) {
const result = {
logIndex: '0x1', // 1
@ -76,7 +76,7 @@ export class LogsManager {
const subscriptionParams = this.subscriptions[subscriptionId]
const [queryType, queryFilter] = subscriptionParams
if (this.eventMatchesFilter(changeEvent, queryType, queryFilter || { topics: [] })) {
if (this.eventMatchesFilter(changeEvent, queryType, queryFilter || { topics: []})) {
matchedSubscriptions.push(subscriptionId)
}
}
@ -135,7 +135,7 @@ export class LogsManager {
const tracking = this.filterTracking[filterId]
if (logsOnly || filterType === 'filter') {
return this.getLogsFor(params || { topics: [] })
return this.getLogsFor(params || { topics: []})
}
if (filterType === 'block') {
const blocks = this.oldLogs.filter(x => x.type === 'block').filter(x => tracking.block === undefined || x.blockNumber >= tracking.block)

@ -88,7 +88,7 @@ export function encodeParams (params, funAbi, callback?) {
const result = { data: data, dataHex: dataHex, funArgs: funArgs }
callback && callback(null, result)
resolve(result)
})
})
}
/**
@ -409,7 +409,7 @@ export function decodeResponse (response, fnabi) {
const name = fnabi.outputs[i].name
json[i] = outputTypes[i] + ': ' + (name ? name + ' ' + decodedObj[i] : decodedObj[i])
}
return json
} catch (e) {
return { error: 'Failed to decode output: ' + e }
@ -485,16 +485,16 @@ export const normalizeParam = (param) => {
try {
let paramTrimmed = param.replace(/^'/g, '').replace(/'$/g, '')
paramTrimmed = paramTrimmed.replace(/^"/g, '').replace(/"$/g, '')
param = fromExponential(paramTrimmed)
param = fromExponential(paramTrimmed)
} catch (e) {
console.log(e)
}
}
}
}
if (typeof param === 'string') {
if (typeof param === 'string') {
if (param === 'true') param = true
if (param === 'false') param = false
if (param === 'false') param = false
}
return param
}

@ -16,8 +16,8 @@ export function encodeParams (funABI, args) {
const type = funABI.inputs[i].type
if (type === 'bool') {
if (args[i] === false || args[i] === 'false' || args[i] === '0' || args[i] === 0) args[i] = false
else if (args[i] === true || args[i] === 'true' || args[i] === '1' || args[i] === 1) args[i] = true
else throw new Error(`provided value for boolean is invalid: ${args[i]}`)
else if (args[i] === true || args[i] === 'true' || args[i] === '1' || args[i] === 1) args[i] = true
else throw new Error(`provided value for boolean is invalid: ${args[i]}`)
}
types.push(type.indexOf('tuple') === 0 ? makeFullTypeDefinition(funABI.inputs[i]) : type)
if (args.length < types.length) {
@ -66,7 +66,7 @@ export function sortAbiFunction (contractabi) {
}
export function getConstructorInterface (abi) {
const funABI = { name: '', inputs: [], type: 'constructor', payable: false, outputs: [] }
const funABI = { name: '', inputs: [], type: 'constructor', payable: false, outputs: []}
if (typeof abi === 'string') {
try {
abi = JSON.parse(abi)

@ -38,7 +38,7 @@ export class TxRunnerVM {
this.logsManager = new LogsManager()
// has a default for now for backwards compatibility
this.getVMObject = getVMObject
this.commonContext = this.getVMObject().common
this.commonContext = this.getVMObject().common
this.pendingTxs = {}
this.vmaccounts = vmaccounts
this.queusTxs = []
@ -137,7 +137,7 @@ export class TxRunnerVM {
})
} else {
this.blockParentHash = block.hash()
this.runBlockInVm(tx, block, async (err, result) => {
this.runBlockInVm(tx, block, async (err, result) => {
if (!err) {
if (!useCall) {
this.getVMObject().vm.blockchain.putBlock(block)

@ -2,7 +2,7 @@
import { EventManager } from '../eventManager'
import type { Transaction as InternalTransaction } from './txRunner'
import Web3 from 'web3'
import {toBigInt, toHex} from 'web3-utils'
import { toBigInt, toHex } from 'web3-utils'
export class TxRunnerWeb3 {
event
@ -65,9 +65,9 @@ export class TxRunnerWeb3 {
promptCb(
async (value) => {
try {
const res = await (this.getWeb3() as any).eth.personal.sendTransaction({...tx, value}, { checkRevertBeforeSending: false, ignoreGasPricing: true })
const res = await (this.getWeb3() as any).eth.personal.sendTransaction({ ...tx, value }, { checkRevertBeforeSending: false, ignoreGasPricing: true })
cb(null, res.transactionHash)
} catch (e) {
} catch (e) {
console.log(`Send transaction failed: ${e.message} . if you use an injected provider, please check it is properly unlocked. `)
// in case the receipt is available, we consider that only the execution failed but the transaction went through.
// So we don't consider this to be an error.
@ -81,9 +81,9 @@ export class TxRunnerWeb3 {
)
} else {
try {
const res = await this.getWeb3().eth.sendTransaction(tx, null, { checkRevertBeforeSending: false, ignoreGasPricing: true})
const res = await this.getWeb3().eth.sendTransaction(tx, null, { checkRevertBeforeSending: false, ignoreGasPricing: true })
cb(null, res.transactionHash)
} catch (e) {
} catch (e) {
console.log(`Send transaction failed: ${e.message} . if you use an injected provider, please check it is properly unlocked. `)
// in case the receipt is available, we consider that only the execution failed but the transaction went through.
// So we don't consider this to be an error.
@ -121,7 +121,7 @@ export class TxRunnerWeb3 {
console.log(errNetWork)
return
}
const txCopy = { ...tx, type: undefined, maxFeePerGas: undefined, gasPrice: undefined }
const txCopy = { ...tx, type: undefined, maxFeePerGas: undefined, gasPrice: undefined }
if (network && network.lastBlock) {
if (network.lastBlock.baseFeePerGas) {
// the sending stack (web3.js / metamask need to have the type defined)
@ -138,17 +138,17 @@ export class TxRunnerWeb3 {
gasEstimationForceSend(null, () => {
/*
* gasLimit is a value that can be set in the UI to hardcap value that can be put in a tx.
* e.g if the gasestimate
* e.g if the gasestimate
*/
if (gasLimit !== '0x0' && gasEstimation > gasLimit) {
return callback(`estimated gas for this transaction (${gasEstimation}) is higher than gasLimit set in the configuration (${gasLimit}). Please raise the gas limit.`)
}
}
if (gasLimit === '0x0') {
tx['gas'] = gasEstimation
} else {
tx['gas'] = gasLimit
}
}
if (this._api.config.getUnpersistedProperty('doNotShowTransactionConfirmationAgain')) {
return this._executeTx(tx, network, null, this._api, promptCb, callback)

@ -8,13 +8,13 @@ function convertToPrefixedHex (input) {
if (input === undefined || input === null || isHexString(input)) {
return input
}
if ((input.constructor && input.constructor.name === 'BigNumber')
|| BN.isBN(input)
if ((input.constructor && input.constructor.name === 'BigNumber')
|| BN.isBN(input)
|| isBigInt(input)
|| typeof input === 'number') {
return '0x' + input.toString(16)
}
try {
return bytesToHex(input)
} catch (e) {
@ -26,7 +26,7 @@ function convertToPrefixedHex (input) {
return '0x' + input.toString(16)
} catch (e) {
console.log(e)
}
}
return input
}

@ -1,9 +1,9 @@
'use strict'
import Web3, { Web3PluginBase } from 'web3'
import {toNumber} from 'web3-utils'
import { toNumber } from 'web3-utils'
export function extendWeb3 (web3) {
if(!web3.debug){
if (!web3.debug){
web3.registerPlugin(new Web3DebugPlugin())
}
}

@ -1,6 +1,6 @@
'use strict'
export class QueryParams {
export class QueryParams {
update (params) {
const currentParams = this.get()

@ -248,7 +248,7 @@ export function getinputParameters (value) {
export function compareByteCode (code1, code2) {
if (code1 === code2) return true
if (code2 === '0x') return false // abstract contract. see comment
if (code1 === '0x00' || code2 === '0x00' && code1 !== code2) return false // // This can be removed some time once YUL returns correct bytecode
if (code1 === '0x00' || code2 === '0x00' && code1 !== code2) return false // // This can be removed some time once YUL returns correct bytecode
if (code2.substr(2, 46) === '7300000000000000000000000000000000000000003014') {
// testing the following signature: PUSH20 00..00 ADDRESS EQ
@ -263,7 +263,7 @@ export function compareByteCode (code1, code2) {
}
code1 = removeImmutableReference(code1, code2)
code1 = extractinputParameters(code1)
code1 = extractinputParameters(code1)
code1 = extractSwarmHash(code1)
code1 = extractcborMetadata(code1)
code2 = extractinputParameters(code2)
@ -275,7 +275,7 @@ export function compareByteCode (code1, code2) {
// if the length isn't the same, we have an issue with extracting the metadata hash.
const minLength = code1.length > code2.length ? code2.length: code1.length
code1 = code1.substr(0, minLength - 10)
code2 = code2.substr(0, minLength - 10)
code2 = code2.substr(0, minLength - 10)
}
const compare = stringSimilarity.compareTwoStrings(code1, code2)
return compare == 1

@ -45,7 +45,6 @@ function testWithInput (st, params, expected) {
}, () => {}, () => {})
}
tape('ContractStringParameters - (TxFormat.buildData) - format string input parameters', function (t) {
let output = compiler.compile(compilerInput(stringContract))
output = JSON.parse(output)

@ -29,7 +29,7 @@ tape('getFunction', function (st) {
fn = txHelper.getFunctionLiner(testTupleAbi[0], true)
st.equal(fn, 'setUser((string,uint256))')
fn = txHelper.getFunctionLiner(testTupleAbi[0], false)
st.equal(fn, 'setUser(tuple)')
})
@ -165,4 +165,4 @@ const abi = `[
}
]`
const testTupleAbi = [{"inputs":[{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"uint256","name":"age","type":"uint256"}],"internalType":"struct Example.User","name":"user","type":"tuple"}],"name":"setUser","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userByAddress","outputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"uint256","name":"age","type":"uint256"}],"stateMutability":"view","type":"function"}]
const testTupleAbi = [{ "inputs":[{ "components":[{ "internalType":"string","name":"name","type":"string" },{ "internalType":"uint256","name":"age","type":"uint256" }],"internalType":"struct Example.User","name":"user","type":"tuple" }],"name":"setUser","outputs":[],"stateMutability":"nonpayable","type":"function" },{ "inputs":[{ "internalType":"address","name":"","type":"address" }],"name":"userByAddress","outputs":[{ "internalType":"string","name":"name","type":"string" },{ "internalType":"uint256","name":"age","type":"uint256" }],"stateMutability":"view","type":"function" }]

@ -59,7 +59,7 @@ const EXEC_RESULT = {
}
const EXEC_RESULT_ERROR = {
exceptionError: 'this is an error'
exceptionError: 'this is an error'
}
tape('converts node transaction result to RemixTx', function (t) {

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save