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

✨ Feat: Add back bytecode to evmts compiles #668

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading