-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(zinkc): introduce artifact as compiler output (#210)
* feat(compiler): introduce instance artifact as compiler output * refactor(compiler): remove config constructor * refactor(zint): use pure instead of without_dispatcher * feat(zint): introduce module lookup * feat(codegen): remove lifetime for dispatcher * chore(abi): use tiny-keccak instead of sha3 * docs(RELEASES): append release note for v0.1.10 * chore(deps): update dependencies
- Loading branch information
Showing
31 changed files
with
341 additions
and
361 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
//! Zink compiler artifact | ||
|
||
use crate::{Compiler, Config}; | ||
use wasmparser::FuncType; | ||
use zabi::Abi; | ||
use zingen::Constructor; | ||
|
||
/// Zink compiler artifact | ||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] | ||
#[derive(Default, Debug)] | ||
pub struct Artifact { | ||
/// Contract ABIs | ||
pub abi: Vec<Abi>, | ||
/// Bytecode of the contract. | ||
pub bytecode: Vec<u8>, | ||
/// Compiler configuration. | ||
pub config: Config, | ||
/// Runtime bytecode of the contract. | ||
pub runtime_bytecode: Vec<u8>, | ||
} | ||
|
||
impl TryFrom<(Compiler, Option<FuncType>)> for Artifact { | ||
type Error = anyhow::Error; | ||
|
||
fn try_from( | ||
(compiler, constructor): (Compiler, Option<FuncType>), | ||
) -> Result<Self, Self::Error> { | ||
let Compiler { | ||
abi, | ||
buffer, | ||
config, | ||
.. | ||
} = compiler; | ||
|
||
let bytecode = Constructor::new(constructor, buffer.clone())? | ||
.finish()? | ||
.to_vec(); | ||
|
||
Ok(Self { | ||
abi, | ||
bytecode, | ||
config, | ||
runtime_bytecode: buffer.to_vec(), | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.