-
Notifications
You must be signed in to change notification settings - Fork 499
Add support for Yul compilation and verification #2521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: staging
Are you sure you want to change the base?
Conversation
kuzdogan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good thank you!
Requested some changes
| language: 'Yul', | ||
| output: outputMetadata, | ||
| settings: { | ||
| ...metadataSettings, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small thing, this should exclude outputSelection, it's not in metadata.settings: https://docs.soliditylang.org/en/latest/metadata.html
Same change needed in Vyper metadata generation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this should be in server instead? It isn't used anywhere in lib-sourcify, and we also don't refer to this in Readme as reference example
|
|
||
| /** | ||
| * Converts libraries from the solc JSON input format to the metadata format. | ||
| * jsonInput format: { "contracts/1_Storage.sol": { Journal: "0x..." } } | ||
| * metadata format: { "contracts/1_Storage.sol:Journal": "0x..." } | ||
| */ | ||
| export function convertLibrariesToMetadataFormat( | ||
| libraries?: Libraries, | ||
| ): MetadataCompilerSettings['libraries'] { | ||
| if (!libraries) { | ||
| return undefined; | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this a duplicate of this code?
sourcify/packages/lib-sourcify/src/Validation/SolidityMetadataContract.ts
Lines 320 to 327 in a1f21e7
| // Convert the libraries from the metadata format to the compiler_settings format | |
| // metadata format: "contracts/1_Storage.sol:Journal": "0x7d53f102f4d4aa014db4e10d6deec2009b3cda6b" | |
| // settings format: "contracts/1_Storage.sol": { Journal: "0x7d53f102f4d4aa014db4e10d6deec2009b3cda6b" } | |
| if (metadataLibraries) { | |
| this.solcJsonInput.settings.libraries = Object.keys( | |
| metadataLibraries, | |
| ).reduce((libraries, libraryKey) => { | |
| // Before Solidity v0.7.5: { "ERC20": "0x..."} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the opposite code, now I created another function so it's more clear. Let me know if it is more understandable now
| if (!abi) { | ||
| throw new Error("No ABI found in compilation output"); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's check if the language is Yul here but still throw otherwise
| args?: any[], | ||
| ): Promise<DeploymentInfo> { | ||
| const contractFactory = new ContractFactory(abi, bytecode, signer); | ||
| const contractFactory = new ContractFactory(abi || [], bytecode, signer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should set abi to be undefined above as a type, if we expect it to be undefined
| * metadata format: { "contracts/1_Storage.sol:Journal": "0x..." } | ||
| * jsonInput format: { "contracts/1_Storage.sol": { Journal: "0x..." } } | ||
| */ | ||
| export function convertLibrariesFromMetadataFormat( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you rename this to convertLibrariesToStdJsonFormat? It's confusing
See #2517
Notice: