Skip to content

Commit

Permalink
✨ Feat: Add back bytecode to evmts compiles (#668)
Browse files Browse the repository at this point in the history
## Description

Add back bytecode to evmts bundler. If a contract ends in .s.sol we
compile it's bytecode.

## Testing

Explain the quality checks that have been done on the code changes

## Additional Information

- [ ] I read the [contributing docs](../docs/contributing.md) (if this
is your first contribution)

Your ENS/address:

Co-authored-by: Will Cory <[email protected]>
  • Loading branch information
roninjin10 and Will Cory authored Nov 17, 2023
1 parent 2f13396 commit 31ed39a
Show file tree
Hide file tree
Showing 52 changed files with 494 additions and 136 deletions.
12 changes: 12 additions & 0 deletions .changeset/happy-rocks-jump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@evmts/ts-plugin": minor
"@evmts/unplugin": minor
"@evmts/runtime": minor
"@evmts/core": minor
"@evmts/base": minor
"@evmts/solc": minor
"@evmts/bun-plugin": minor
"@evmts/bundler": minor
---

Added back bytecode to EVMts bundler. When the compiler encounters a file ending in .s.sol it will compile the bytecode in addition to the abi
2 changes: 1 addition & 1 deletion bundler/base/docs/modules/bundler.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@

#### Defined in

[types.ts:32](https://github.com/evmts/evmts-monorepo/blob/main/bundler/base/src/types.ts#L32)
[types.ts:34](https://github.com/evmts/evmts-monorepo/blob/main/bundler/base/src/types.ts#L34)
65 changes: 49 additions & 16 deletions bundler/base/src/bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const bundler = (config, logger, fao) => {
return {
name: bundler.name,
config,
resolveDts: async (modulePath, basedir, includeAst) => {
resolveDts: async (modulePath, basedir, includeAst, includeBytecode) => {
try {
const { solcInput, solcOutput, artifacts, modules, asts } =
await resolveArtifacts(
Expand All @@ -18,14 +18,15 @@ export const bundler = (config, logger, fao) => {
logger,
config,
includeAst,
includeBytecode,
fao,
)
if (artifacts && Object.keys(artifacts).length > 0) {
return {
solcInput,
solcOutput,
asts,
code: runSync(generateRuntime(artifacts, 'dts')),
code: runSync(generateRuntime(artifacts, 'dts', includeBytecode)),
modules,
}
}
Expand All @@ -36,7 +37,7 @@ export const bundler = (config, logger, fao) => {
throw e
}
},
resolveDtsSync: (modulePath, basedir, includeAst) => {
resolveDtsSync: (modulePath, basedir, includeAst, includeBytecode) => {
try {
const { artifacts, modules, asts, solcInput, solcOutput } =
resolveArtifactsSync(
Expand All @@ -45,6 +46,7 @@ export const bundler = (config, logger, fao) => {
logger,
config,
includeAst,
includeBytecode,
fao,
)
if (artifacts && Object.keys(artifacts).length > 0) {
Expand All @@ -53,7 +55,7 @@ export const bundler = (config, logger, fao) => {
solcOutput,
asts,
modules,
code: runSync(generateRuntime(artifacts, 'dts')),
code: runSync(generateRuntime(artifacts, 'dts', includeBytecode)),
}
}
return { modules, code: '', asts, solcInput, solcOutput }
Expand All @@ -63,7 +65,7 @@ export const bundler = (config, logger, fao) => {
throw e
}
},
resolveTsModuleSync: (modulePath, basedir, includeAst) => {
resolveTsModuleSync: (modulePath, basedir, includeAst, includeBytecode) => {
try {
const { solcInput, solcOutput, asts, artifacts, modules } =
resolveArtifactsSync(
Expand All @@ -72,11 +74,12 @@ export const bundler = (config, logger, fao) => {
logger,
config,
includeAst,
includeBytecode,
fao,
)
let code = ''
if (artifacts && Object.keys(artifacts).length > 0) {
code = runSync(generateRuntime(artifacts, 'ts'))
code = runSync(generateRuntime(artifacts, 'ts', includeBytecode))
}
return { code, modules, solcInput, solcOutput, asts }
} catch (e) {
Expand All @@ -85,7 +88,12 @@ export const bundler = (config, logger, fao) => {
throw e
}
},
resolveTsModule: async (modulePath, basedir, includeAst) => {
resolveTsModule: async (
modulePath,
basedir,
includeAst,
includeBytecode,
) => {
try {
const { solcInput, solcOutput, asts, artifacts, modules } =
await resolveArtifacts(
Expand All @@ -94,11 +102,12 @@ export const bundler = (config, logger, fao) => {
logger,
config,
includeAst,
includeBytecode,
fao,
)
let code = ''
if (artifacts && Object.keys(artifacts).length > 0) {
code = runSync(generateRuntime(artifacts, 'ts'))
code = runSync(generateRuntime(artifacts, 'ts', includeBytecode))
}
return { code, modules, solcInput, solcOutput, asts }
} catch (e) {
Expand All @@ -107,7 +116,12 @@ export const bundler = (config, logger, fao) => {
throw e
}
},
resolveCjsModuleSync: (modulePath, basedir, includeAst) => {
resolveCjsModuleSync: (
modulePath,
basedir,
includeAst,
includeBytecode,
) => {
try {
const { solcInput, solcOutput, asts, artifacts, modules } =
resolveArtifactsSync(
Expand All @@ -116,11 +130,12 @@ export const bundler = (config, logger, fao) => {
logger,
config,
includeAst,
includeBytecode,
fao,
)
let code = ''
if (artifacts && Object.keys(artifacts).length > 0) {
code = runSync(generateRuntime(artifacts, 'cjs'))
code = runSync(generateRuntime(artifacts, 'cjs', includeBytecode))
}
return { code, modules, solcInput, solcOutput, asts }
} catch (e) {
Expand All @@ -129,7 +144,12 @@ export const bundler = (config, logger, fao) => {
throw e
}
},
resolveCjsModule: async (modulePath, basedir, includeAst) => {
resolveCjsModule: async (
modulePath,
basedir,
includeAst,
includeBytecode,
) => {
try {
const { solcInput, solcOutput, asts, artifacts, modules } =
await resolveArtifacts(
Expand All @@ -138,11 +158,12 @@ export const bundler = (config, logger, fao) => {
logger,
config,
includeAst,
includeBytecode,
fao,
)
let code = ''
if (artifacts && Object.keys(artifacts).length > 0) {
code = runSync(generateRuntime(artifacts, 'cjs'))
code = runSync(generateRuntime(artifacts, 'cjs', includeBytecode))
}
return { code, modules, solcInput, solcOutput, asts }
} catch (e) {
Expand All @@ -151,7 +172,12 @@ export const bundler = (config, logger, fao) => {
throw e
}
},
resolveEsmModuleSync: (modulePath, basedir, includeAst) => {
resolveEsmModuleSync: (
modulePath,
basedir,
includeAst,
includeBytecode,
) => {
try {
const { solcInput, solcOutput, asts, artifacts, modules } =
resolveArtifactsSync(
Expand All @@ -160,11 +186,12 @@ export const bundler = (config, logger, fao) => {
logger,
config,
includeAst,
includeBytecode,
fao,
)
let code = ''
if (artifacts && Object.keys(artifacts).length > 0) {
code = runSync(generateRuntime(artifacts, 'mjs'))
code = runSync(generateRuntime(artifacts, 'mjs', includeBytecode))
}
return { code, modules, solcInput, solcOutput, asts }
} catch (e) {
Expand All @@ -173,7 +200,12 @@ export const bundler = (config, logger, fao) => {
throw e
}
},
resolveEsmModule: async (modulePath, basedir, includeAst) => {
resolveEsmModule: async (
modulePath,
basedir,
includeAst,
includeBytecode,
) => {
try {
const { solcInput, solcOutput, asts, artifacts, modules } =
await resolveArtifacts(
Expand All @@ -182,11 +214,12 @@ export const bundler = (config, logger, fao) => {
logger,
config,
includeAst,
includeBytecode,
fao,
)
let code = ''
if (artifacts && Object.keys(artifacts).length > 0) {
code = runSync(generateRuntime(artifacts, 'mjs'))
code = runSync(generateRuntime(artifacts, 'mjs', includeBytecode))
}
return { code, modules, solcInput, solcOutput, asts }
} catch (e) {
Expand Down
Loading

0 comments on commit 31ed39a

Please sign in to comment.