Giter VIP home page Giter VIP logo

Comments (3)

jtakalai avatar jtakalai commented on August 29, 2024

web3 has those log decoding things exposed in web3.eth.abi without importing stuff.

Our current (pre-1.0) code has

const SolidityEvent = require("web3/lib/web3/event.js")
const SolidityCoder = require("web3/lib/solidity/coder.js")

and then does lots of log parsing from ABI, core lines being

        // TODO: probably should handle somehow "If arrays (including string and bytes) are used as indexed arguments, the Keccak-256 hash of it is stored as topic instead." (http://solidity.readthedocs.io/en/develop/contracts.html#events)
        const paramTypes = event.inputs.filter(i => !i.indexed).map(i => i.type)
        const paramBytes = log.data.replace("0x", "")   // unindexed params go into data
        const paramValues = SolidityCoder.decodeParams(paramTypes, paramBytes)

but also noticing in comments

        /* web3.js 1.0 (remove direct SolidityCoder/SolidityEvent refs)
        // for anonymous events, const paramValues = web3.eth.abi.decodeLog(event.inputs, log.data, log.topics)
        const paramValues = web3.eth.abi.decodeLog(event.inputs, log.data, log.topics.slice(1))
        */

So yeah, I think web3.js 1.0 will greatly simplify log parsing, and that's really one of the big features I've been waiting to have from it. It's not so great to have to import stuff from the "internals".

from truffle-core.

cgewecke avatar cgewecke commented on August 29, 2024

@jtakalai Thanks for highlighting this. Cross-referencing to truffle-contract 95 where Web3 1.0 work is currently focused.

from truffle-core.

cgewecke avatar cgewecke commented on August 29, 2024

Closing, this is done on the web3-one branch

from truffle-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.