-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
315 additions
and
123 deletions.
There are no files selected for viewing
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,14 @@ | ||
[package] | ||
name = "ixc-codec-solidity-abi" | ||
version = "0.0.1" | ||
edition = "2021" | ||
repository.workspace = true | ||
license.workspace = true | ||
publish = false | ||
|
||
[dependencies] | ||
ixc_schema = { path = "../../schema" } | ||
alloy-sol-types = "0.8.5" | ||
|
||
[lints] | ||
workspace = true |
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 @@ | ||
struct Decoder {} |
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,31 @@ | ||
use alloy_sol_types::abi::encode; | ||
use alloy_sol_types::SolValue; | ||
use ixc_schema::encoder::EncodeError; | ||
use ixc_schema::structs::StructEncodeVisitor; | ||
use ixc_schema::value::Value; | ||
|
||
struct Encoder {} | ||
|
||
impl ixc_schema::encoder::Encoder for Encoder { | ||
fn encode_u32(&mut self, x: u32) -> Result<(), EncodeError> { | ||
let bz = <u32 as SolValue>::abi_encode(&x); | ||
todo!() | ||
} | ||
|
||
fn encode_u128(&mut self, x: u128) -> Result<(), EncodeError> { | ||
let bz = <u128 as SolValue>::abi_encode(&x); | ||
todo!() | ||
} | ||
|
||
fn encode_str(&mut self, x: &str) -> Result<(), EncodeError> { | ||
todo!() | ||
} | ||
|
||
fn encode_list_slice<'a, V: Value<'a>>(&mut self, xs: &[V]) -> Result<(), EncodeError> { | ||
todo!() | ||
} | ||
|
||
fn encode_struct<V: StructEncodeVisitor>(&mut self, visitor: &V) -> Result<(), EncodeError> { | ||
todo!() | ||
} | ||
} |
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,20 @@ | ||
mod encoder; | ||
mod decoder; | ||
|
||
use ixc_schema::buffer::WriterFactory; | ||
use ixc_schema::codec::Codec; | ||
use ixc_schema::encoder::EncodeError; | ||
use ixc_schema::mem::MemoryManager; | ||
use ixc_schema::value::Value; | ||
|
||
pub struct SolidityABICodec; | ||
|
||
impl Codec for SolidityABICodec { | ||
fn encode_value<'a, V: Value<'a>, F: WriterFactory>(value: &V, writer_factory: &F) -> Result<F::Output, EncodeError> { | ||
todo!() | ||
} | ||
|
||
fn decode_value<'b, 'a: 'b, V: Value<'a>>(input: &'a [u8], memory_manager: &'b MemoryManager<'a, 'a>) -> Result<V, DecodeError> { | ||
todo!() | ||
} | ||
} |
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,13 @@ | ||
[package] | ||
name = "ixc-codec-proto" | ||
version = "0.0.1" | ||
edition = "2021" | ||
repository.workspace = true | ||
license.workspace = true | ||
publish = false | ||
|
||
[dependencies] | ||
ixc_schema = { path = "../../schema" } | ||
|
||
[lints] | ||
workspace = true |
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 @@ | ||
struct Decoder {} |
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 @@ | ||
struct Encoder {} |
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,21 @@ | ||
mod encoder; | ||
mod decoder; | ||
|
||
use ixc_schema::buffer::WriterFactory; | ||
use ixc_schema::codec::Codec; | ||
use ixc_schema::decoder::DecodeError; | ||
use ixc_schema::encoder::EncodeError; | ||
use ixc_schema::mem::MemoryManager; | ||
use ixc_schema::value::Value; | ||
|
||
pub struct ProtobufCodec; | ||
|
||
impl Codec for ProtobufCodec { | ||
fn encode_value<'a, V: Value<'a>, F: WriterFactory>(value: &V, writer_factory: &F) -> Result<F::Output, EncodeError> { | ||
todo!() | ||
} | ||
|
||
fn decode_value<'b, 'a: 'b, V: Value<'a>>(input: &'a [u8], memory_manager: &'b MemoryManager<'a, 'a>) -> Result<V, DecodeError> { | ||
todo!() | ||
} | ||
} |
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 |
---|---|---|
@@ -1,22 +1,37 @@ | ||
//! The raw handler and host backend interfaces. | ||
use core::alloc::Layout; | ||
use crate::code::Code; | ||
use crate::packet::MessagePacket; | ||
|
||
/// A handler for an account. | ||
pub trait Handler { | ||
/// Handle a message packet. | ||
fn handle(&self, message_packet: &mut MessagePacket, callbacks: &dyn HostBackend) -> HandlerCode; | ||
} | ||
|
||
#[non_exhaustive] | ||
/// A host backend for the handler. | ||
pub trait HostBackend { | ||
/// Invoke a message packet. | ||
fn invoke(&self, message_packet: &mut MessagePacket) -> Code; | ||
/// Allocate memory for a message response. | ||
/// The memory management expectation of handlers is that the caller | ||
/// deallocates both the memory it allocated and any memory allocated | ||
/// for the response by the callee. | ||
/// The alloc function in the host backend should return a pointer to | ||
/// memory that the caller knows how to free and such allocated | ||
/// memory should be referenced in the message packet's out pointers. | ||
unsafe fn alloc(&self, layout: Layout) -> Result<*mut u8, AllocError>; | ||
} | ||
|
||
/// An allocation error. | ||
#[derive(Debug)] | ||
pub struct AllocError; | ||
|
||
/// A code that a handler can return. | ||
#[derive(Clone, Copy, PartialEq, Eq, Debug)] | ||
pub enum HandlerCode { | ||
/// The handler completed successfully. | ||
Ok, | ||
/// The handler encountered an error. | ||
HandlerError(u32), | ||
} |
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
Oops, something went wrong.