Coder Social home page Coder Social logo

projectsophon / hardhat-diamond-abi Goto Github PK

View Code? Open in Web Editor NEW
50.0 50.0 11.0 126 KB

Hardhat plugin to combine multiple ABIs into a Diamond ABI artifact.

License: GNU General Public License v3.0

TypeScript 83.24% Solidity 13.13% JavaScript 3.63%

hardhat-diamond-abi's People

Contributors

friskyfoxdk avatar github-actions[bot] avatar phated avatar ubinatus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

hardhat-diamond-abi's Issues

Allow generation of multiple diamond ABIs for a project

Because generateDiamondAbi expects a literal called diamondAbi within the Hardhat runtime environment (line 181 of index.ts), if one has multiple diamonds within a project, there is no way for one to combine the facets of each diamond into separate ABIs.

Plugin operates on cached ABIs even when contract is removed

If a contract gets moved, renamed, deleted, or refactored, the hardhat cache can still contain the ABI information and then the plugin starts to see duplicate identifiers.

Need to investigate if there's a way to see if an ABI is stale.

Ran into this during 0xPARC hack week.

Failed to create Diamond ABI - `InitializationFunctionReverted(address,bytes)` appears twice.

Hi
I am trying to compile but I get this error:
Error in plugin hardhat-diamond-abi: Failed to create Diamond ABI - `InitializationFunctionReverted(address,bytes)` appears twice.
But I searched for that and it is defined only once in the whole project.
I am using diamond-3-hardhat
and this is how I imported modules in hardhat.config.ts:

import 'dotenv/config';
import { HardhatUserConfig } from 'hardhat/config';
import 'hardhat-diamond-abi'; // must be imported before typechain

import '@nomicfoundation/hardhat-ethers';
import 'hardhat-deploy';
import 'hardhat-deploy-ethers';
import '@nomicfoundation/hardhat-chai-matchers';

import '@typechain/hardhat';
import 'hardhat-gas-reporter';
//import 'solidity-coverage';
import 'hardhat-contract-sizer';

Incorrect consolidation of ABI for events.

Consider that

  • A diamond has two facets - FacetA and FacetB.
  • Both rely on a library for storage and other things - eg MyLib.
  • Both FacetA and FacetB need to emit SomeEvent.

At this point, there are different ways of doing things:

  1. Declare the events in MyLib - it is valid Solidity - and from FacetA (or FacetB) one could call emit MyLib.SomeEvent(...).
  2. Declare the events in FacetA and FacetB - it is valid Solidity - and both facets can emit.
  3. Declare the events in an interface such as IFacetEvents, inherited from both FacetA and FacetB - it is valid in solidity. Both facets can now call emit IFacetEvents.SomeEvent(...).

Problem with 1:

Most hardhat typescript tooling won't allow to unit test this - because neither FacetA or FacetB explicitely declare SomeEvent, and so no types are consolidated knowing about that event.

Problem with 2:

Using hardhat-diamond-abi, the project won't compile because SomeEvent is found as a duplicate between FacetA and FacetB when trying to build the ABI of their union for the diamond - although it's valid Solidity code.

Problem with 3:

Although both facets inherit from the common interface IFacetEvents, there are no function signature overlap - so it should be fine. Yet, the project won't compile for the same reason as case 2 - hardhat-diamond-abi will complain that IFacetEvents is duplicated.

TypeError: Cannot read property 'format' of null

The steps to reproduce the error are:

  1. clone the repo -> https://github.com/mudgen/diamond-1-hardhat.git
  2. cd into the dir
  3. open a terminal and run -> hh run scripts/deploy.js (works)
  4. install -> https://www.npmjs.com/package/hardhat-diamond-abi/v/3.0.0
  5. open a terminal and run -> hh run scripts/deploy.js

hardhat.config.js

/* global ethers task */
require('@nomiclabs/hardhat-waffle')
require("hardhat-diamond-abi");

// This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html
task('accounts', 'Prints the list of accounts', async () => {
const accounts = await ethers.getSigners()

for (const account of accounts) {
console.log(account.address)
}
})

// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more

/**

  • @type import('hardhat/config').HardhatUserConfig
    */
    module.exports = {
    solidity: '0.8.6',
    settings: {
    optimizer: {
    enabled: true,
    runs: 200
    }
    },
    diamondAbi: {
    // (required) The name of your Diamond ABI
    name: "BestDappEver",
    },
    }

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.