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. 2
      libs/remix-lib/src/execution/txHelper.ts
  5. 2
      libs/remix-lib/src/execution/txRunnerVM.ts
  6. 12
      libs/remix-lib/src/execution/txRunnerWeb3.ts
  7. 4
      libs/remix-lib/src/init.ts
  8. 2
      libs/remix-lib/src/query-params.ts
  9. 2
      libs/remix-lib/src/util.ts
  10. 1
      libs/remix-lib/test/txFormat.ts
  11. 2
      libs/remix-lib/test/txHelper.ts
  12. 13
      libs/remix-lib/test/util.ts

@ -22,7 +22,7 @@
"outputs": ["{options.outputFile}"], "outputs": ["{options.outputFile}"],
"options": { "options": {
"lintFilePatterns": ["libs/remix-lib/**/*.ts"], "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 * @param {Function} cb - callback
*/ */
parseLogs (tx, contractName, compiledContracts, cb) { 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) => { this.resolveReceipt(tx, (error, receipt) => {
if (error) return cb(error) if (error) return cb(error)
this._decodeLogs(tx, receipt, contractName, compiledContracts, cb) this._decodeLogs(tx, receipt, contractName, compiledContracts, cb)
@ -33,7 +33,7 @@ export class EventsDecoder {
return cb('cannot decode logs - contract or receipt not resolved ') return cb('cannot decode logs - contract or receipt not resolved ')
} }
if (!receipt.logs) { if (!receipt.logs) {
return cb(null, { decoded: [], raw: [] }) return cb(null, { decoded: [], raw: []})
} }
this._decodeEvents(tx, receipt.logs, contract, contracts, cb) this._decodeEvents(tx, receipt.logs, contract, contracts, cb)
} }

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

@ -66,7 +66,7 @@ export function sortAbiFunction (contractabi) {
} }
export function getConstructorInterface (abi) { 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') { if (typeof abi === 'string') {
try { try {
abi = JSON.parse(abi) abi = JSON.parse(abi)

@ -137,7 +137,7 @@ export class TxRunnerVM {
}) })
} else { } else {
this.blockParentHash = block.hash() this.blockParentHash = block.hash()
this.runBlockInVm(tx, block, async (err, result) => { this.runBlockInVm(tx, block, async (err, result) => {
if (!err) { if (!err) {
if (!useCall) { if (!useCall) {
this.getVMObject().vm.blockchain.putBlock(block) this.getVMObject().vm.blockchain.putBlock(block)

@ -2,7 +2,7 @@
import { EventManager } from '../eventManager' import { EventManager } from '../eventManager'
import type { Transaction as InternalTransaction } from './txRunner' import type { Transaction as InternalTransaction } from './txRunner'
import Web3 from 'web3' import Web3 from 'web3'
import {toBigInt, toHex} from 'web3-utils' import { toBigInt, toHex } from 'web3-utils'
export class TxRunnerWeb3 { export class TxRunnerWeb3 {
event event
@ -65,9 +65,9 @@ export class TxRunnerWeb3 {
promptCb( promptCb(
async (value) => { async (value) => {
try { 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) 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. `) 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. // 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. // So we don't consider this to be an error.
@ -81,9 +81,9 @@ export class TxRunnerWeb3 {
) )
} else { } else {
try { 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) 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. `) 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. // 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. // So we don't consider this to be an error.
@ -121,7 +121,7 @@ export class TxRunnerWeb3 {
console.log(errNetWork) console.log(errNetWork)
return 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 && network.lastBlock) {
if (network.lastBlock.baseFeePerGas) { if (network.lastBlock.baseFeePerGas) {
// the sending stack (web3.js / metamask need to have the type defined) // the sending stack (web3.js / metamask need to have the type defined)

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

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

@ -248,7 +248,7 @@ export function getinputParameters (value) {
export function compareByteCode (code1, code2) { export function compareByteCode (code1, code2) {
if (code1 === code2) return true if (code1 === code2) return true
if (code2 === '0x') return false // abstract contract. see comment 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') { if (code2.substr(2, 46) === '7300000000000000000000000000000000000000003014') {
// testing the following signature: PUSH20 00..00 ADDRESS EQ // testing the following signature: PUSH20 00..00 ADDRESS EQ

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

@ -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" }]

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