Skip to content

Conversation

@marcocastignoli
Copy link
Member

See #2517

  • Implement YulCompilation class for handling Yul contracts.
  • Extend compilation utilities to support Yul alongside Solidity and Vyper.
  • Update VerificationService to handle Yul contracts.
  • Add tests for Yul compilation and verification (including a new alliance test)

Notice:

  • Yul doesn't support metadata so we are generating one like we do for Vyper
  • Yul doesn't support ABI so I had to update signatures and tests functions to support this case

@marcocastignoli marcocastignoli self-assigned this Nov 26, 2025
@marcocastignoli marcocastignoli moved this from Triage to Sprint - Needs Review in Sourcify Public Nov 26, 2025
@marcocastignoli marcocastignoli marked this pull request as ready for review November 26, 2025 08:54
Copy link
Member

@kuzdogan kuzdogan left a 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,
Copy link
Member

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

Copy link
Member

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

Comment on lines +29 to +41

/**
* 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;
}

Copy link
Member

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?

// 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..."}

Copy link
Member Author

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

Comment on lines 916 to 918
if (!abi) {
throw new Error("No ABI found in compilation output");
return;
}
Copy link
Member

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);
Copy link
Member

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(
Copy link
Member

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

@kuzdogan kuzdogan self-requested a review December 16, 2025 09:46
@kuzdogan kuzdogan self-assigned this Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Sprint - Needs Review

Development

Successfully merging this pull request may close these issues.

3 participants