mirror of
https://github.com/serai-dex/serai.git
synced 2025-03-12 09:26:51 +00:00
Remove artifacts for serai-processor-ethereum-contracts
This commit is contained in:
parent
3f0f4d520d
commit
39be23d807
15 changed files with 5501 additions and 69 deletions
19
Cargo.lock
generated
19
Cargo.lock
generated
|
@ -2516,6 +2516,7 @@ dependencies = [
|
|||
"alloy-rpc-types-eth",
|
||||
"alloy-simple-request-transport",
|
||||
"alloy-sol-types",
|
||||
"ethereum-schnorr-contract",
|
||||
"flexible-transcript",
|
||||
"group",
|
||||
"k256",
|
||||
|
@ -6126,6 +6127,16 @@ dependencies = [
|
|||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prettyplease"
|
||||
version = "0.2.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"syn 2.0.77",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "primeorder"
|
||||
version = "0.13.6"
|
||||
|
@ -6291,7 +6302,7 @@ dependencies = [
|
|||
"log",
|
||||
"multimap",
|
||||
"petgraph",
|
||||
"prettyplease",
|
||||
"prettyplease 0.1.25",
|
||||
"prost",
|
||||
"prost-types",
|
||||
"regex",
|
||||
|
@ -8700,8 +8711,14 @@ dependencies = [
|
|||
name = "serai-processor-ethereum-contracts"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"alloy-sol-macro-expander",
|
||||
"alloy-sol-macro-input",
|
||||
"alloy-sol-types",
|
||||
"build-solidity-contracts",
|
||||
"prettyplease 0.2.22",
|
||||
"serde_json",
|
||||
"syn 2.0.77",
|
||||
"syn-solidity",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
@ -12,6 +12,13 @@ pub fn build(
|
|||
contracts_path: &str,
|
||||
artifacts_path: &str,
|
||||
) -> Result<(), String> {
|
||||
if !fs::exists(artifacts_path)
|
||||
.map_err(|e| format!("couldn't check if artifacts directory already exists: {e:?}"))?
|
||||
{
|
||||
fs::create_dir(artifacts_path)
|
||||
.map_err(|e| format!("couldn't create the non-existent artifacts directory: {e:?}"))?;
|
||||
}
|
||||
|
||||
println!("cargo:rerun-if-changed={contracts_path}/*");
|
||||
println!("cargo:rerun-if-changed={artifacts_path}/*");
|
||||
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
use std::{env, fs};
|
||||
|
||||
fn main() {
|
||||
let artifacts_path = env::var("OUT_DIR").unwrap().to_string() + "/ethereum-schnorr-contract";
|
||||
if !fs::exists(&artifacts_path).unwrap() {
|
||||
fs::create_dir(&artifacts_path).unwrap();
|
||||
}
|
||||
let artifacts_path = std::env::var("OUT_DIR").unwrap().to_string() + "/ethereum-schnorr-contract";
|
||||
build_solidity_contracts::build(&[], "contracts", &artifacts_path).unwrap();
|
||||
}
|
||||
|
|
1
processor/ethereum/contracts/.gitignore
vendored
1
processor/ethereum/contracts/.gitignore
vendored
|
@ -1 +0,0 @@
|
|||
artifacts
|
|
@ -21,3 +21,12 @@ alloy-sol-types = { version = "0.8", default-features = false, features = ["json
|
|||
|
||||
[build-dependencies]
|
||||
build-solidity-contracts = { path = "../../../networks/ethereum/build-contracts" }
|
||||
|
||||
syn = { version = "2", default-features = false, features = ["proc-macro"] }
|
||||
|
||||
serde_json = { version = "1", default-features = false, features = ["std"] }
|
||||
|
||||
syn-solidity = { version = "0.8", default-features = false }
|
||||
alloy-sol-macro-input = { version = "0.8", default-features = false }
|
||||
alloy-sol-macro-expander = { version = "0.8", default-features = false }
|
||||
prettyplease = { version = "0.2", default-features = false }
|
||||
|
|
|
@ -1,8 +1,69 @@
|
|||
fn main() {
|
||||
build_solidity_contracts::build(
|
||||
&["../../../networks/ethereum/schnorr/contracts"],
|
||||
"contracts",
|
||||
"artifacts",
|
||||
use std::{env, fs};
|
||||
|
||||
use alloy_sol_macro_input::{SolInputKind, SolInput};
|
||||
|
||||
fn write(sol: syn_solidity::File, file: &str) {
|
||||
let sol = alloy_sol_macro_expander::expand::expand(sol).unwrap();
|
||||
fs::write(
|
||||
file,
|
||||
// TODO: Replace `prettyplease::unparse` with `to_string`
|
||||
prettyplease::unparse(&syn::File {
|
||||
attrs: vec![],
|
||||
items: vec![syn::parse2(sol).unwrap()],
|
||||
shebang: None,
|
||||
})
|
||||
.as_bytes(),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
fn sol(sol: &str, file: &str) {
|
||||
let alloy_sol_macro_input::SolInputKind::Sol(sol) =
|
||||
syn::parse_str(&std::fs::read_to_string(sol).unwrap()).unwrap()
|
||||
else {
|
||||
panic!("parsed .sol file wasn't SolInputKind::Sol");
|
||||
};
|
||||
write(sol, file);
|
||||
}
|
||||
|
||||
fn abi(ident: &str, abi: &str, file: &str) {
|
||||
let SolInputKind::Sol(sol) = (SolInput {
|
||||
attrs: vec![],
|
||||
path: None,
|
||||
kind: SolInputKind::Json(
|
||||
syn::parse_str(ident).unwrap(),
|
||||
serde_json::from_str(&fs::read_to_string(abi).unwrap()).unwrap(),
|
||||
),
|
||||
})
|
||||
.normalize_json()
|
||||
.unwrap()
|
||||
.kind
|
||||
else {
|
||||
panic!("normalized JSON wasn't SolInputKind::Sol");
|
||||
};
|
||||
write(sol, file);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let artifacts_path =
|
||||
env::var("OUT_DIR").unwrap().to_string() + "/serai-processor-ethereum-contracts";
|
||||
build_solidity_contracts::build(
|
||||
&["../../../networks/ethereum/schnorr/contracts"],
|
||||
"contracts",
|
||||
&artifacts_path,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// TODO: Use OUT_DIR for the generated code
|
||||
if !fs::exists("src/abigen").unwrap() {
|
||||
fs::create_dir("src/abigen").unwrap();
|
||||
}
|
||||
|
||||
// These can be handled with the sol! macro
|
||||
sol("contracts/IERC20.sol", "src/abigen/erc20.rs");
|
||||
sol("contracts/Deployer.sol", "src/abigen/deployer.rs");
|
||||
// This cannot be handled with the sol! macro. The Solidity requires an import, the ABI is built
|
||||
// to OUT_DIR and the macro doesn't support non-static paths:
|
||||
// https://github.com/alloy-rs/core/issues/738
|
||||
abi("Router", &(artifacts_path.clone() + "/Router.abi"), "src/abigen/router.rs");
|
||||
}
|
||||
|
|
584
processor/ethereum/contracts/src/abigen/deployer.rs
Normal file
584
processor/ethereum/contracts/src/abigen/deployer.rs
Normal file
|
@ -0,0 +1,584 @@
|
|||
///Module containing a contract's types and functions.
|
||||
/**
|
||||
|
||||
```solidity
|
||||
contract Deployer {
|
||||
event Deployment(bytes32 indexed init_code_hash, address created);
|
||||
error DeploymentFailed();
|
||||
function deploy(bytes memory init_code) external { <stmts> }
|
||||
}
|
||||
```*/
|
||||
#[allow(non_camel_case_types, non_snake_case, clippy::style)]
|
||||
pub mod Deployer {
|
||||
use super::*;
|
||||
use ::alloy_sol_types as alloy_sol_types;
|
||||
/**Event with signature `Deployment(bytes32,address)` and selector `0x60b877a3bae7bf0f0bd5e1c40ebf44ea158201397f6b72d7c05360157b1ec0fc`.
|
||||
```solidity
|
||||
event Deployment(bytes32 indexed init_code_hash, address created);
|
||||
```*/
|
||||
#[allow(non_camel_case_types, non_snake_case, clippy::style)]
|
||||
#[derive(Clone)]
|
||||
pub struct Deployment {
|
||||
#[allow(missing_docs)]
|
||||
pub init_code_hash: ::alloy_sol_types::private::FixedBytes<32>,
|
||||
#[allow(missing_docs)]
|
||||
pub created: ::alloy_sol_types::private::Address,
|
||||
}
|
||||
#[allow(non_camel_case_types, non_snake_case, clippy::style)]
|
||||
const _: () = {
|
||||
use ::alloy_sol_types as alloy_sol_types;
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolEvent for Deployment {
|
||||
type DataTuple<'a> = (::alloy_sol_types::sol_data::Address,);
|
||||
type DataToken<'a> = <Self::DataTuple<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type TopicList = (
|
||||
alloy_sol_types::sol_data::FixedBytes<32>,
|
||||
::alloy_sol_types::sol_data::FixedBytes<32>,
|
||||
);
|
||||
const SIGNATURE: &'static str = "Deployment(bytes32,address)";
|
||||
const SIGNATURE_HASH: alloy_sol_types::private::B256 = alloy_sol_types::private::B256::new([
|
||||
96u8,
|
||||
184u8,
|
||||
119u8,
|
||||
163u8,
|
||||
186u8,
|
||||
231u8,
|
||||
191u8,
|
||||
15u8,
|
||||
11u8,
|
||||
213u8,
|
||||
225u8,
|
||||
196u8,
|
||||
14u8,
|
||||
191u8,
|
||||
68u8,
|
||||
234u8,
|
||||
21u8,
|
||||
130u8,
|
||||
1u8,
|
||||
57u8,
|
||||
127u8,
|
||||
107u8,
|
||||
114u8,
|
||||
215u8,
|
||||
192u8,
|
||||
83u8,
|
||||
96u8,
|
||||
21u8,
|
||||
123u8,
|
||||
30u8,
|
||||
192u8,
|
||||
252u8,
|
||||
]);
|
||||
const ANONYMOUS: bool = false;
|
||||
#[allow(unused_variables)]
|
||||
#[inline]
|
||||
fn new(
|
||||
topics: <Self::TopicList as alloy_sol_types::SolType>::RustType,
|
||||
data: <Self::DataTuple<'_> as alloy_sol_types::SolType>::RustType,
|
||||
) -> Self {
|
||||
Self {
|
||||
init_code_hash: topics.1,
|
||||
created: data.0,
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
fn tokenize_body(&self) -> Self::DataToken<'_> {
|
||||
(
|
||||
<::alloy_sol_types::sol_data::Address as alloy_sol_types::SolType>::tokenize(
|
||||
&self.created,
|
||||
),
|
||||
)
|
||||
}
|
||||
#[inline]
|
||||
fn topics(&self) -> <Self::TopicList as alloy_sol_types::SolType>::RustType {
|
||||
(Self::SIGNATURE_HASH.into(), self.init_code_hash.clone())
|
||||
}
|
||||
#[inline]
|
||||
fn encode_topics_raw(
|
||||
&self,
|
||||
out: &mut [alloy_sol_types::abi::token::WordToken],
|
||||
) -> alloy_sol_types::Result<()> {
|
||||
if out.len() < <Self::TopicList as alloy_sol_types::TopicList>::COUNT {
|
||||
return Err(alloy_sol_types::Error::Overrun);
|
||||
}
|
||||
out[0usize] = alloy_sol_types::abi::token::WordToken(
|
||||
Self::SIGNATURE_HASH,
|
||||
);
|
||||
out[1usize] = <::alloy_sol_types::sol_data::FixedBytes<
|
||||
32,
|
||||
> as alloy_sol_types::EventTopic>::encode_topic(&self.init_code_hash);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::private::IntoLogData for Deployment {
|
||||
fn to_log_data(&self) -> alloy_sol_types::private::LogData {
|
||||
From::from(self)
|
||||
}
|
||||
fn into_log_data(self) -> alloy_sol_types::private::LogData {
|
||||
From::from(&self)
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl From<&Deployment> for alloy_sol_types::private::LogData {
|
||||
#[inline]
|
||||
fn from(this: &Deployment) -> alloy_sol_types::private::LogData {
|
||||
alloy_sol_types::SolEvent::encode_log_data(this)
|
||||
}
|
||||
}
|
||||
};
|
||||
/**Custom error with signature `DeploymentFailed()` and selector `0x30116425`.
|
||||
```solidity
|
||||
error DeploymentFailed();
|
||||
```*/
|
||||
#[allow(non_camel_case_types, non_snake_case)]
|
||||
#[derive(Clone)]
|
||||
pub struct DeploymentFailed {}
|
||||
#[allow(non_camel_case_types, non_snake_case, clippy::style)]
|
||||
const _: () = {
|
||||
use ::alloy_sol_types as alloy_sol_types;
|
||||
#[doc(hidden)]
|
||||
type UnderlyingSolTuple<'a> = ();
|
||||
#[doc(hidden)]
|
||||
type UnderlyingRustTuple<'a> = ();
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
>(_) => {}
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<DeploymentFailed> for UnderlyingRustTuple<'_> {
|
||||
fn from(value: DeploymentFailed) -> Self {
|
||||
()
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>> for DeploymentFailed {
|
||||
fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolError for DeploymentFailed {
|
||||
type Parameters<'a> = UnderlyingSolTuple<'a>;
|
||||
type Token<'a> = <Self::Parameters<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
const SIGNATURE: &'static str = "DeploymentFailed()";
|
||||
const SELECTOR: [u8; 4] = [48u8, 17u8, 100u8, 37u8];
|
||||
#[inline]
|
||||
fn new<'a>(
|
||||
tuple: <Self::Parameters<'a> as alloy_sol_types::SolType>::RustType,
|
||||
) -> Self {
|
||||
tuple.into()
|
||||
}
|
||||
#[inline]
|
||||
fn tokenize(&self) -> Self::Token<'_> {
|
||||
()
|
||||
}
|
||||
}
|
||||
};
|
||||
/**Function with signature `deploy(bytes)` and selector `0x00774360`.
|
||||
```solidity
|
||||
function deploy(bytes memory init_code) external { <stmts> }
|
||||
```*/
|
||||
#[allow(non_camel_case_types, non_snake_case)]
|
||||
#[derive(Clone)]
|
||||
pub struct deployCall {
|
||||
pub init_code: ::alloy_sol_types::private::Bytes,
|
||||
}
|
||||
///Container type for the return parameters of the [`deploy(bytes)`](deployCall) function.
|
||||
#[allow(non_camel_case_types, non_snake_case)]
|
||||
#[derive(Clone)]
|
||||
pub struct deployReturn {}
|
||||
#[allow(non_camel_case_types, non_snake_case, clippy::style)]
|
||||
const _: () = {
|
||||
use ::alloy_sol_types as alloy_sol_types;
|
||||
{
|
||||
#[doc(hidden)]
|
||||
type UnderlyingSolTuple<'a> = (::alloy_sol_types::sol_data::Bytes,);
|
||||
#[doc(hidden)]
|
||||
type UnderlyingRustTuple<'a> = (::alloy_sol_types::private::Bytes,);
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
>(_) => {}
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<deployCall> for UnderlyingRustTuple<'_> {
|
||||
fn from(value: deployCall) -> Self {
|
||||
(value.init_code,)
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>> for deployCall {
|
||||
fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
|
||||
Self { init_code: tuple.0 }
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
#[doc(hidden)]
|
||||
type UnderlyingSolTuple<'a> = ();
|
||||
#[doc(hidden)]
|
||||
type UnderlyingRustTuple<'a> = ();
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
>(_) => {}
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<deployReturn> for UnderlyingRustTuple<'_> {
|
||||
fn from(value: deployReturn) -> Self {
|
||||
()
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>> for deployReturn {
|
||||
fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolCall for deployCall {
|
||||
type Parameters<'a> = (::alloy_sol_types::sol_data::Bytes,);
|
||||
type Token<'a> = <Self::Parameters<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Return = deployReturn;
|
||||
type ReturnTuple<'a> = ();
|
||||
type ReturnToken<'a> = <Self::ReturnTuple<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
const SIGNATURE: &'static str = "deploy(bytes)";
|
||||
const SELECTOR: [u8; 4] = [0u8, 119u8, 67u8, 96u8];
|
||||
#[inline]
|
||||
fn new<'a>(
|
||||
tuple: <Self::Parameters<'a> as alloy_sol_types::SolType>::RustType,
|
||||
) -> Self {
|
||||
tuple.into()
|
||||
}
|
||||
#[inline]
|
||||
fn tokenize(&self) -> Self::Token<'_> {
|
||||
(
|
||||
<::alloy_sol_types::sol_data::Bytes as alloy_sol_types::SolType>::tokenize(
|
||||
&self.init_code,
|
||||
),
|
||||
)
|
||||
}
|
||||
#[inline]
|
||||
fn abi_decode_returns(
|
||||
data: &[u8],
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<Self::Return> {
|
||||
<Self::ReturnTuple<
|
||||
'_,
|
||||
> as alloy_sol_types::SolType>::abi_decode_sequence(data, validate)
|
||||
.map(Into::into)
|
||||
}
|
||||
}
|
||||
};
|
||||
///Container for all the [`Deployer`](self) function calls.
|
||||
pub enum DeployerCalls {
|
||||
deploy(deployCall),
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl DeployerCalls {
|
||||
/// All the selectors of this enum.
|
||||
///
|
||||
/// Note that the selectors might not be in the same order as the variants.
|
||||
/// No guarantees are made about the order of the selectors.
|
||||
///
|
||||
/// Prefer using `SolInterface` methods instead.
|
||||
pub const SELECTORS: &'static [[u8; 4usize]] = &[[0u8, 119u8, 67u8, 96u8]];
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolInterface for DeployerCalls {
|
||||
const NAME: &'static str = "DeployerCalls";
|
||||
const MIN_DATA_LENGTH: usize = 64usize;
|
||||
const COUNT: usize = 1usize;
|
||||
#[inline]
|
||||
fn selector(&self) -> [u8; 4] {
|
||||
match self {
|
||||
Self::deploy(_) => <deployCall as alloy_sol_types::SolCall>::SELECTOR,
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
fn selector_at(i: usize) -> ::core::option::Option<[u8; 4]> {
|
||||
Self::SELECTORS.get(i).copied()
|
||||
}
|
||||
#[inline]
|
||||
fn valid_selector(selector: [u8; 4]) -> bool {
|
||||
Self::SELECTORS.binary_search(&selector).is_ok()
|
||||
}
|
||||
#[inline]
|
||||
#[allow(unsafe_code, non_snake_case)]
|
||||
fn abi_decode_raw(
|
||||
selector: [u8; 4],
|
||||
data: &[u8],
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<Self> {
|
||||
static DECODE_SHIMS: &[fn(
|
||||
&[u8],
|
||||
bool,
|
||||
) -> alloy_sol_types::Result<DeployerCalls>] = &[
|
||||
{
|
||||
fn deploy(
|
||||
data: &[u8],
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<DeployerCalls> {
|
||||
<deployCall as alloy_sol_types::SolCall>::abi_decode_raw(
|
||||
data,
|
||||
validate,
|
||||
)
|
||||
.map(DeployerCalls::deploy)
|
||||
}
|
||||
deploy
|
||||
},
|
||||
];
|
||||
let Ok(idx) = Self::SELECTORS.binary_search(&selector) else {
|
||||
return Err(
|
||||
alloy_sol_types::Error::unknown_selector(
|
||||
<Self as alloy_sol_types::SolInterface>::NAME,
|
||||
selector,
|
||||
),
|
||||
);
|
||||
};
|
||||
(unsafe { DECODE_SHIMS.get_unchecked(idx) })(data, validate)
|
||||
}
|
||||
#[inline]
|
||||
fn abi_encoded_size(&self) -> usize {
|
||||
match self {
|
||||
Self::deploy(inner) => {
|
||||
<deployCall as alloy_sol_types::SolCall>::abi_encoded_size(inner)
|
||||
}
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
fn abi_encode_raw(&self, out: &mut alloy_sol_types::private::Vec<u8>) {
|
||||
match self {
|
||||
Self::deploy(inner) => {
|
||||
<deployCall as alloy_sol_types::SolCall>::abi_encode_raw(inner, out)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
///Container for all the [`Deployer`](self) custom errors.
|
||||
pub enum DeployerErrors {
|
||||
DeploymentFailed(DeploymentFailed),
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl DeployerErrors {
|
||||
/// All the selectors of this enum.
|
||||
///
|
||||
/// Note that the selectors might not be in the same order as the variants.
|
||||
/// No guarantees are made about the order of the selectors.
|
||||
///
|
||||
/// Prefer using `SolInterface` methods instead.
|
||||
pub const SELECTORS: &'static [[u8; 4usize]] = &[[48u8, 17u8, 100u8, 37u8]];
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolInterface for DeployerErrors {
|
||||
const NAME: &'static str = "DeployerErrors";
|
||||
const MIN_DATA_LENGTH: usize = 0usize;
|
||||
const COUNT: usize = 1usize;
|
||||
#[inline]
|
||||
fn selector(&self) -> [u8; 4] {
|
||||
match self {
|
||||
Self::DeploymentFailed(_) => {
|
||||
<DeploymentFailed as alloy_sol_types::SolError>::SELECTOR
|
||||
}
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
fn selector_at(i: usize) -> ::core::option::Option<[u8; 4]> {
|
||||
Self::SELECTORS.get(i).copied()
|
||||
}
|
||||
#[inline]
|
||||
fn valid_selector(selector: [u8; 4]) -> bool {
|
||||
Self::SELECTORS.binary_search(&selector).is_ok()
|
||||
}
|
||||
#[inline]
|
||||
#[allow(unsafe_code, non_snake_case)]
|
||||
fn abi_decode_raw(
|
||||
selector: [u8; 4],
|
||||
data: &[u8],
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<Self> {
|
||||
static DECODE_SHIMS: &[fn(
|
||||
&[u8],
|
||||
bool,
|
||||
) -> alloy_sol_types::Result<DeployerErrors>] = &[
|
||||
{
|
||||
fn DeploymentFailed(
|
||||
data: &[u8],
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<DeployerErrors> {
|
||||
<DeploymentFailed as alloy_sol_types::SolError>::abi_decode_raw(
|
||||
data,
|
||||
validate,
|
||||
)
|
||||
.map(DeployerErrors::DeploymentFailed)
|
||||
}
|
||||
DeploymentFailed
|
||||
},
|
||||
];
|
||||
let Ok(idx) = Self::SELECTORS.binary_search(&selector) else {
|
||||
return Err(
|
||||
alloy_sol_types::Error::unknown_selector(
|
||||
<Self as alloy_sol_types::SolInterface>::NAME,
|
||||
selector,
|
||||
),
|
||||
);
|
||||
};
|
||||
(unsafe { DECODE_SHIMS.get_unchecked(idx) })(data, validate)
|
||||
}
|
||||
#[inline]
|
||||
fn abi_encoded_size(&self) -> usize {
|
||||
match self {
|
||||
Self::DeploymentFailed(inner) => {
|
||||
<DeploymentFailed as alloy_sol_types::SolError>::abi_encoded_size(
|
||||
inner,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
fn abi_encode_raw(&self, out: &mut alloy_sol_types::private::Vec<u8>) {
|
||||
match self {
|
||||
Self::DeploymentFailed(inner) => {
|
||||
<DeploymentFailed as alloy_sol_types::SolError>::abi_encode_raw(
|
||||
inner,
|
||||
out,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
///Container for all the [`Deployer`](self) events.
|
||||
pub enum DeployerEvents {
|
||||
Deployment(Deployment),
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl DeployerEvents {
|
||||
/// All the selectors of this enum.
|
||||
///
|
||||
/// Note that the selectors might not be in the same order as the variants.
|
||||
/// No guarantees are made about the order of the selectors.
|
||||
///
|
||||
/// Prefer using `SolInterface` methods instead.
|
||||
pub const SELECTORS: &'static [[u8; 32usize]] = &[
|
||||
[
|
||||
96u8,
|
||||
184u8,
|
||||
119u8,
|
||||
163u8,
|
||||
186u8,
|
||||
231u8,
|
||||
191u8,
|
||||
15u8,
|
||||
11u8,
|
||||
213u8,
|
||||
225u8,
|
||||
196u8,
|
||||
14u8,
|
||||
191u8,
|
||||
68u8,
|
||||
234u8,
|
||||
21u8,
|
||||
130u8,
|
||||
1u8,
|
||||
57u8,
|
||||
127u8,
|
||||
107u8,
|
||||
114u8,
|
||||
215u8,
|
||||
192u8,
|
||||
83u8,
|
||||
96u8,
|
||||
21u8,
|
||||
123u8,
|
||||
30u8,
|
||||
192u8,
|
||||
252u8,
|
||||
],
|
||||
];
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolEventInterface for DeployerEvents {
|
||||
const NAME: &'static str = "DeployerEvents";
|
||||
const COUNT: usize = 1usize;
|
||||
fn decode_raw_log(
|
||||
topics: &[alloy_sol_types::Word],
|
||||
data: &[u8],
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<Self> {
|
||||
match topics.first().copied() {
|
||||
Some(<Deployment as alloy_sol_types::SolEvent>::SIGNATURE_HASH) => {
|
||||
<Deployment as alloy_sol_types::SolEvent>::decode_raw_log(
|
||||
topics,
|
||||
data,
|
||||
validate,
|
||||
)
|
||||
.map(Self::Deployment)
|
||||
}
|
||||
_ => {
|
||||
alloy_sol_types::private::Err(alloy_sol_types::Error::InvalidLog {
|
||||
name: <Self as alloy_sol_types::SolEventInterface>::NAME,
|
||||
log: alloy_sol_types::private::Box::new(
|
||||
alloy_sol_types::private::LogData::new_unchecked(
|
||||
topics.to_vec(),
|
||||
data.to_vec().into(),
|
||||
),
|
||||
),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::private::IntoLogData for DeployerEvents {
|
||||
fn to_log_data(&self) -> alloy_sol_types::private::LogData {
|
||||
match self {
|
||||
Self::Deployment(inner) => {
|
||||
alloy_sol_types::private::IntoLogData::to_log_data(inner)
|
||||
}
|
||||
}
|
||||
}
|
||||
fn into_log_data(self) -> alloy_sol_types::private::LogData {
|
||||
match self {
|
||||
Self::Deployment(inner) => {
|
||||
alloy_sol_types::private::IntoLogData::into_log_data(inner)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
1838
processor/ethereum/contracts/src/abigen/erc20.rs
Normal file
1838
processor/ethereum/contracts/src/abigen/erc20.rs
Normal file
File diff suppressed because it is too large
Load diff
3
processor/ethereum/contracts/src/abigen/mod.rs
Normal file
3
processor/ethereum/contracts/src/abigen/mod.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
pub mod erc20;
|
||||
pub mod deployer;
|
||||
pub mod router;
|
2958
processor/ethereum/contracts/src/abigen/router.rs
Normal file
2958
processor/ethereum/contracts/src/abigen/router.rs
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,46 +1,21 @@
|
|||
use alloy_sol_types::sol;
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[expect(warnings)]
|
||||
#[expect(needless_pass_by_value)]
|
||||
#[expect(clippy::all)]
|
||||
#[expect(clippy::ignored_unit_patterns)]
|
||||
#[expect(clippy::redundant_closure_for_method_calls)]
|
||||
mod erc20_container {
|
||||
use super::*;
|
||||
sol!("contracts/IERC20.sol");
|
||||
}
|
||||
mod abigen;
|
||||
|
||||
pub mod erc20 {
|
||||
pub const BYTECODE: &str = include_str!("../artifacts/Deployer.bin");
|
||||
pub use super::erc20_container::IERC20::*;
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[expect(warnings)]
|
||||
#[expect(needless_pass_by_value)]
|
||||
#[expect(clippy::all)]
|
||||
#[expect(clippy::ignored_unit_patterns)]
|
||||
#[expect(clippy::redundant_closure_for_method_calls)]
|
||||
mod deployer_container {
|
||||
use super::*;
|
||||
sol!("contracts/Deployer.sol");
|
||||
pub use super::abigen::erc20::IERC20::*;
|
||||
}
|
||||
pub mod deployer {
|
||||
pub const BYTECODE: &str = include_str!("../artifacts/Deployer.bin");
|
||||
pub use super::deployer_container::Deployer::*;
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[expect(warnings)]
|
||||
#[expect(needless_pass_by_value)]
|
||||
#[expect(clippy::all)]
|
||||
#[expect(clippy::ignored_unit_patterns)]
|
||||
#[expect(clippy::redundant_closure_for_method_calls)]
|
||||
mod router_container {
|
||||
use super::*;
|
||||
sol!(Router, "artifacts/Router.abi");
|
||||
pub const BYTECODE: &str =
|
||||
include_str!(concat!(env!("OUT_DIR"), "/serai-processor-ethereum-contracts/Deployer.bin"));
|
||||
pub use super::abigen::deployer::Deployer::*;
|
||||
}
|
||||
pub mod router {
|
||||
pub const BYTECODE: &str = include_str!("../artifacts/Router.bin");
|
||||
pub use super::router_container::Router::*;
|
||||
pub const BYTECODE: &str =
|
||||
include_str!(concat!(env!("OUT_DIR"), "/serai-processor-ethereum-contracts/Router.bin"));
|
||||
pub use super::abigen::router::Router::*;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ alloy-provider = { version = "0.3", default-features = false }
|
|||
|
||||
alloy-node-bindings = { version = "0.3", default-features = false, optional = true }
|
||||
|
||||
ethereum-schnorr-contract = { path = "../../../networks/ethereum/schnorr", default-features = false }
|
||||
contracts = { package = "serai-processor-ethereum-contracts", path = "../contracts" }
|
||||
|
||||
[dev-dependencies]
|
||||
|
|
|
@ -13,6 +13,8 @@ use frost::{
|
|||
curve::{Ciphersuite, Secp256k1},
|
||||
};
|
||||
|
||||
pub use ethereum_schnorr_contract::*;
|
||||
|
||||
use alloy_core::primitives::{Parity, Signature as AlloySignature};
|
||||
use alloy_consensus::{SignableTransaction, Signed, TxLegacy};
|
||||
|
||||
|
@ -77,11 +79,3 @@ impl Hram<Secp256k1> for EthereumHram {
|
|||
<Scalar as Reduce<KU256>>::reduce_bytes(&keccak256(&data).into())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&Signature> for AbiSignature {
|
||||
fn from(sig: &Signature) -> AbiSignature {
|
||||
let c: [u8; 32] = sig.c.to_repr().into();
|
||||
let s: [u8; 32] = sig.s.to_repr().into();
|
||||
AbiSignature { c: c.into(), s: s.into() }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -236,7 +236,7 @@ impl RouterCommand {
|
|||
writer.write_all(&[0])?;
|
||||
writer.write_all(&chain_id.as_le_bytes())?;
|
||||
writer.write_all(&nonce.as_le_bytes())?;
|
||||
writer.write_all(&key.A.to_bytes())
|
||||
writer.write_all(&key.point().to_bytes())
|
||||
}
|
||||
RouterCommand::Execute { chain_id, nonce, outs } => {
|
||||
writer.write_all(&[1])?;
|
||||
|
@ -406,9 +406,9 @@ impl SignatureMachine<SignedRouterCommand> for RouterCommandSignatureMachine {
|
|||
self,
|
||||
shares: HashMap<Participant, Self::SignatureShare>,
|
||||
) -> Result<SignedRouterCommand, FrostError> {
|
||||
let sig = self.machine.complete(shares)?;
|
||||
let signature = Signature::new(&self.key, &self.command.msg(), sig)
|
||||
.expect("machine produced an invalid signature");
|
||||
let signature = self.machine.complete(shares)?;
|
||||
let signature = Signature::new(signature).expect("machine produced an invalid signature");
|
||||
assert!(signature.verify(&self.key, &self.command.msg()));
|
||||
Ok(SignedRouterCommand { command: self.command, signature })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,7 +127,6 @@ impl InInstruction {
|
|||
pub struct Executed {
|
||||
pub tx_id: [u8; 32],
|
||||
pub nonce: u64,
|
||||
pub signature: [u8; 64],
|
||||
}
|
||||
|
||||
/// The contract Serai uses to manage its state.
|
||||
|
@ -142,7 +141,7 @@ impl Router {
|
|||
pub(crate) fn init_code(key: &PublicKey) -> Vec<u8> {
|
||||
let mut bytecode = Self::code();
|
||||
// Append the constructor arguments
|
||||
bytecode.extend((abi::constructorCall { _seraiKey: key.eth_repr().into() }).abi_encode());
|
||||
bytecode.extend((abi::constructorCall { initialSeraiKey: key.eth_repr().into() }).abi_encode());
|
||||
bytecode
|
||||
}
|
||||
|
||||
|
@ -392,13 +391,9 @@ impl Router {
|
|||
let log =
|
||||
log.log_decode::<SeraiKeyUpdated>().map_err(|_| Error::ConnectionError)?.inner.data;
|
||||
|
||||
let mut signature = [0; 64];
|
||||
signature[.. 32].copy_from_slice(log.signature.c.as_ref());
|
||||
signature[32 ..].copy_from_slice(log.signature.s.as_ref());
|
||||
res.push(Executed {
|
||||
tx_id,
|
||||
nonce: log.nonce.try_into().map_err(|_| Error::ConnectionError)?,
|
||||
signature,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -418,13 +413,9 @@ impl Router {
|
|||
|
||||
let log = log.log_decode::<ExecutedEvent>().map_err(|_| Error::ConnectionError)?.inner.data;
|
||||
|
||||
let mut signature = [0; 64];
|
||||
signature[.. 32].copy_from_slice(log.signature.c.as_ref());
|
||||
signature[32 ..].copy_from_slice(log.signature.s.as_ref());
|
||||
res.push(Executed {
|
||||
tx_id,
|
||||
nonce: log.nonce.try_into().map_err(|_| Error::ConnectionError)?,
|
||||
signature,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue