remix-lib lint

git4refactor
filip mertens 7 months ago
parent c3db5384c9
commit c03bb35533
  1. 4
      libs/remix-lib/src/execution/eventsDecoder.ts
  2. 6
      libs/remix-lib/src/execution/logsManager.ts
  3. 2
      libs/remix-lib/src/execution/txHelper.ts
  4. 6
      libs/remix-lib/src/execution/txRunnerWeb3.ts
  5. 4
      libs/remix-lib/src/init.ts
  6. 1
      libs/remix-lib/test/txFormat.ts
  7. 2
      libs/remix-lib/test/txHelper.ts
  8. 13
      libs/remix-lib/test/util.ts

@ -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)

@ -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,7 +65,7 @@ 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. `)
@ -81,7 +81,7 @@ 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. `)

@ -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())
} }
} }

@ -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