projectsophon / hardhat-diamond-abi Goto Github PK
View Code? Open in Web Editor NEWHardhat plugin to combine multiple ABIs into a Diamond ABI artifact.
License: GNU General Public License v3.0
Hardhat plugin to combine multiple ABIs into a Diamond ABI artifact.
License: GNU General Public License v3.0
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.
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.
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';
Discussion in diamond discord, it seems that you can add the diamond ABI to itself with the wrong configuration.
Consider that
FacetA
and FacetB
.MyLib
.FacetA
and FacetB
need to emit SomeEvent
.At this point, there are different ways of doing things:
MyLib
- it is valid Solidity - and from FacetA
(or FacetB
) one could call emit MyLib.SomeEvent(...)
.FacetA
and FacetB
- it is valid Solidity - and both facets can emit.IFacetEvents
, inherited from both FacetA
and FacetB
- it is valid in solidity. Both facets can now call emit IFacetEvents.SomeEvent(...)
.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.
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.
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.
The steps to reproduce the error are:
- clone the repo -> https://github.com/mudgen/diamond-1-hardhat.git
- cd into the dir
- open a terminal and run -> hh run scripts/deploy.js (works)
- install -> https://www.npmjs.com/package/hardhat-diamond-abi/v/3.0.0
- open a terminal and run -> hh run scripts/deploy.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
/**
~~
I currently have a couple of different diamonds in my contracts directory. Some Facets are shared between them. Some are unique to the individual Diamonds. Is there a way to use this plugin with a structure like that? From what I can tell, it's built for one diamond per hardhat project. Is that correct?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.