Skip to content
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

"packagizing" the useCompiler #1348

Open
4 tasks
manuelwedler opened this issue Apr 15, 2024 · 1 comment
Open
4 tasks

"packagizing" the useCompiler #1348

manuelwedler opened this issue Apr 15, 2024 · 1 comment

Comments

@manuelwedler
Copy link
Collaborator

manuelwedler commented Apr 15, 2024

We use a function useCompiler in various places to compile contracts. This function provides a small wrapper around the solc compiler in order to download it and invoke the compilation.

The code was duplicated across multiple places, namely in the tests of lib-sourcify, in serverless/compiler-lambda and in the server code. In order to minimize the effort for maintenance and synchronization of these code parts, they should be moved into a public package. Basically the content of services/server/src/server/services/compiler/local/solidityCompiler.ts should be the content of the new package.

Tasks

@manuelwedler manuelwedler changed the title "packagizing" the userCompiler "packagizing" the useCompiler Apr 15, 2024
@marcocastignoli
Copy link
Member

marcocastignoli commented Apr 16, 2024

My proposal is to build this package with the idea of shipping multiple compilers in mind. For example doing something like this: https://github.com/lodash/lodash/tree/4.5.0-npm-packages. (We can actually do the same thing just by having multiple compilers under packages/)

The final objective should be being able to do something like this in nodejs

import { CheckedContract } from "@ethereum-sourcify/lib-sourcify"
import {initCompiler} from "@ethereum-sourcify/compilers/solidity/nodejs"

const compiler = initCompiler(...)
const contract = new CheckedContract(compiler, metadata, sources);

And something like this in the browser

import { CheckedContract } from "@ethereum-sourcify/lib-sourcify"
import {initCompiler} from "@ethereum-sourcify/compilers/solidity/browser"

const compiler = initCompiler(...)

const contract = new CheckedContract(compiler, metadata, sources);

And something like this in the lambda function

import {useCompiler} from "@ethereum-sourcify/compilers/solidity/nodejs"

exports.handler = async (event) => {
    return {
      success: true,
      body: await useCompiler(
        event.version,
        event.solcJsonInput,
        event.forceEmscripten
      ),
    }
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

No branches or pull requests

2 participants