mirror of
https://github.com/vacp2p/de-mls.git
synced 2026-01-09 15:18:00 -05:00
Update add member flow (#26)
* don't work async, prepare to remove * new flow works good * refactor
This commit is contained in:
committed by
GitHub
parent
d473de2f11
commit
ea08e5633f
@@ -24,6 +24,8 @@ tokio = { version = "=1.38.0", features = [
|
||||
"full",
|
||||
] }
|
||||
tokio-util = "=0.7.11"
|
||||
tokio-tungstenite = "0.15"
|
||||
tungstenite = "0.14"
|
||||
alloy = { git = "https://github.com/alloy-rs/alloy", features = [
|
||||
"providers",
|
||||
"node-bindings",
|
||||
@@ -32,9 +34,11 @@ alloy = { git = "https://github.com/alloy-rs/alloy", features = [
|
||||
"k256",
|
||||
] }
|
||||
fred = { version = "=9.0.3", features = ["subscriber-client"] }
|
||||
console-subscriber = "0.1.5"
|
||||
|
||||
rand = "=0.8.5"
|
||||
serde_json = "=1.0"
|
||||
serde = "=1.0.204"
|
||||
url = "=2.5.2"
|
||||
tls_codec = "=0.3.0"
|
||||
hex = "=0.4.3"
|
||||
|
||||
2
contracts/lib/openzeppelin-contracts
vendored
2
contracts/lib/openzeppelin-contracts
vendored
Submodule contracts/lib/openzeppelin-contracts updated: 659f3063f8...e3786e63e6
@@ -19,6 +19,7 @@ pub mod Context {
|
||||
///0x
|
||||
/// ```
|
||||
#[rustfmt::skip]
|
||||
#[allow(clippy::all)]
|
||||
pub static BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static(
|
||||
b"",
|
||||
);
|
||||
@@ -28,13 +29,14 @@ pub mod Context {
|
||||
///0x
|
||||
/// ```
|
||||
#[rustfmt::skip]
|
||||
#[allow(clippy::all)]
|
||||
pub static DEPLOYED_BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static(
|
||||
b"",
|
||||
);
|
||||
use alloy::contract as alloy_contract;
|
||||
/**Creates a new wrapper around an on-chain [`Context`](self) contract instance.
|
||||
|
||||
See the [wrapper's documentation](`ContextInstance`) for more details.*/
|
||||
See the [wrapper's documentation](`ContextInstance`) for more details.*/
|
||||
#[inline]
|
||||
pub const fn new<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
@@ -48,9 +50,9 @@ See the [wrapper's documentation](`ContextInstance`) for more details.*/
|
||||
}
|
||||
/**Deploys this contract using the given `provider` and constructor arguments, if any.
|
||||
|
||||
Returns a new instance of the contract, if the deployment was successful.
|
||||
Returns a new instance of the contract, if the deployment was successful.
|
||||
|
||||
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
|
||||
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
|
||||
#[inline]
|
||||
pub fn deploy<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
@@ -58,35 +60,36 @@ For more fine-grained control over the deployment process, use [`deploy_builder`
|
||||
N: alloy_contract::private::Network,
|
||||
>(
|
||||
provider: P,
|
||||
) -> impl ::core::future::Future<
|
||||
Output = alloy_contract::Result<ContextInstance<T, P, N>>,
|
||||
> {
|
||||
) -> impl ::core::future::Future<Output = alloy_contract::Result<ContextInstance<T, P, N>>>
|
||||
{
|
||||
ContextInstance::<T, P, N>::deploy(provider)
|
||||
}
|
||||
/**Creates a `RawCallBuilder` for deploying this contract using the given `provider`
|
||||
and constructor arguments, if any.
|
||||
and constructor arguments, if any.
|
||||
|
||||
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
|
||||
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
|
||||
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
#[inline]
|
||||
pub fn deploy_builder<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
>(provider: P) -> alloy_contract::RawCallBuilder<T, P, N> {
|
||||
>(
|
||||
provider: P,
|
||||
) -> alloy_contract::RawCallBuilder<T, P, N> {
|
||||
ContextInstance::<T, P, N>::deploy_builder(provider)
|
||||
}
|
||||
/**A [`Context`](self) instance.
|
||||
|
||||
Contains type-safe methods for interacting with an on-chain instance of the
|
||||
[`Context`](self) contract located at a given `address`, using a given
|
||||
provider `P`.
|
||||
Contains type-safe methods for interacting with an on-chain instance of the
|
||||
[`Context`](self) contract located at a given `address`, using a given
|
||||
provider `P`.
|
||||
|
||||
If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!)
|
||||
documentation on how to provide it), the `deploy` and `deploy_builder` methods can
|
||||
be used to deploy a new instance of the contract.
|
||||
If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!)
|
||||
documentation on how to provide it), the `deploy` and `deploy_builder` methods can
|
||||
be used to deploy a new instance of the contract.
|
||||
|
||||
See the [module-level documentation](self) for all the available methods.*/
|
||||
See the [module-level documentation](self) for all the available methods.*/
|
||||
#[derive(Clone)]
|
||||
pub struct ContextInstance<T, P, N = alloy_contract::private::Ethereum> {
|
||||
address: alloy_sol_types::private::Address,
|
||||
@@ -97,24 +100,24 @@ See the [module-level documentation](self) for all the available methods.*/
|
||||
impl<T, P, N> ::core::fmt::Debug for ContextInstance<T, P, N> {
|
||||
#[inline]
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
|
||||
f.debug_tuple("ContextInstance").field(&self.address).finish()
|
||||
f.debug_tuple("ContextInstance")
|
||||
.field(&self.address)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
/// Instantiation and getters/setters.
|
||||
#[automatically_derived]
|
||||
impl<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> ContextInstance<T, P, N> {
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> ContextInstance<T, P, N>
|
||||
{
|
||||
/**Creates a new wrapper around an on-chain [`Context`](self) contract instance.
|
||||
|
||||
See the [wrapper's documentation](`ContextInstance`) for more details.*/
|
||||
See the [wrapper's documentation](`ContextInstance`) for more details.*/
|
||||
#[inline]
|
||||
pub const fn new(
|
||||
address: alloy_sol_types::private::Address,
|
||||
provider: P,
|
||||
) -> Self {
|
||||
pub const fn new(address: alloy_sol_types::private::Address, provider: P) -> Self {
|
||||
Self {
|
||||
address,
|
||||
provider,
|
||||
@@ -123,22 +126,20 @@ See the [wrapper's documentation](`ContextInstance`) for more details.*/
|
||||
}
|
||||
/**Deploys this contract using the given `provider` and constructor arguments, if any.
|
||||
|
||||
Returns a new instance of the contract, if the deployment was successful.
|
||||
Returns a new instance of the contract, if the deployment was successful.
|
||||
|
||||
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
|
||||
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
|
||||
#[inline]
|
||||
pub async fn deploy(
|
||||
provider: P,
|
||||
) -> alloy_contract::Result<ContextInstance<T, P, N>> {
|
||||
pub async fn deploy(provider: P) -> alloy_contract::Result<ContextInstance<T, P, N>> {
|
||||
let call_builder = Self::deploy_builder(provider);
|
||||
let contract_address = call_builder.deploy().await?;
|
||||
Ok(Self::new(contract_address, call_builder.provider))
|
||||
}
|
||||
/**Creates a `RawCallBuilder` for deploying this contract using the given `provider`
|
||||
and constructor arguments, if any.
|
||||
and constructor arguments, if any.
|
||||
|
||||
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
|
||||
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
|
||||
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
#[inline]
|
||||
pub fn deploy_builder(provider: P) -> alloy_contract::RawCallBuilder<T, P, N> {
|
||||
alloy_contract::RawCallBuilder::new_raw_deploy(
|
||||
@@ -181,10 +182,11 @@ the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
/// Function calls.
|
||||
#[automatically_derived]
|
||||
impl<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> ContextInstance<T, P, N> {
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> ContextInstance<T, P, N>
|
||||
{
|
||||
/// Creates a new call builder using this contract instance's provider and address.
|
||||
///
|
||||
/// Note that the call can be any function call, not just those defined in this
|
||||
@@ -199,10 +201,11 @@ the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
/// Event filters.
|
||||
#[automatically_derived]
|
||||
impl<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> ContextInstance<T, P, N> {
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> ContextInstance<T, P, N>
|
||||
{
|
||||
/// Creates a new event filter using this contract instance's provider and address.
|
||||
///
|
||||
/// Note that the type can be any event, not just those defined in this contract.
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -114,6 +114,7 @@ pub mod DeploymentConfig {
|
||||
///0x6080604052600c805462ff00ff19166201000117905534801561002157600080fd5b50604051610223380380610223833981016040819052610040916100f0565b6001600160a01b0381166100675760405163201616d160e21b815260040160405180910390fd5b600e80546001600160a01b0319166001600160a01b03831617905546617a69036100cb57604080516020808201835260009091528151908101909152600e546001600160a01b031690819052600d80546001600160a01b03191690911790556100ea565b604051630b13dbff60e01b815246600482015260240160405180910390fd5b50610120565b60006020828403121561010257600080fd5b81516001600160a01b038116811461011957600080fd5b9392505050565b60f58061012e6000396000f3fe6080604052348015600f57600080fd5b506004361060465760003560e01c806312900da814604b578063d7b6574514608f578063f8a8fd6d1460d2578063f8ccbf471460d4575b600080fd5b6040805160208082018352600090915281518082018352600e5473ffffffffffffffffffffffffffffffffffffffff16908190529151918252015b60405180910390f35b600d5460ae9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016086565b005b600c5460e69062010000900460ff1681565b6040519015158152602001608656
|
||||
/// ```
|
||||
#[rustfmt::skip]
|
||||
#[allow(clippy::all)]
|
||||
pub static BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static(
|
||||
b"`\x80`@R`\x0C\x80Tb\xFF\0\xFF\x19\x16b\x01\0\x01\x17\x90U4\x80\x15a\0!W`\0\x80\xFD[P`@Qa\x02#8\x03\x80a\x02#\x839\x81\x01`@\x81\x90Ra\0@\x91a\0\xF0V[`\x01`\x01`\xA0\x1B\x03\x81\x16a\0gW`@Qc \x16\x16\xD1`\xE2\x1B\x81R`\x04\x01`@Q\x80\x91\x03\x90\xFD[`\x0E\x80T`\x01`\x01`\xA0\x1B\x03\x19\x16`\x01`\x01`\xA0\x1B\x03\x83\x16\x17\x90UFazi\x03a\0\xCBW`@\x80Q` \x80\x82\x01\x83R`\0\x90\x91R\x81Q\x90\x81\x01\x90\x91R`\x0ET`\x01`\x01`\xA0\x1B\x03\x16\x90\x81\x90R`\r\x80T`\x01`\x01`\xA0\x1B\x03\x19\x16\x90\x91\x17\x90Ua\0\xEAV[`@Qc\x0B\x13\xDB\xFF`\xE0\x1B\x81RF`\x04\x82\x01R`$\x01`@Q\x80\x91\x03\x90\xFD[Pa\x01 V[`\0` \x82\x84\x03\x12\x15a\x01\x02W`\0\x80\xFD[\x81Q`\x01`\x01`\xA0\x1B\x03\x81\x16\x81\x14a\x01\x19W`\0\x80\xFD[\x93\x92PPPV[`\xF5\x80a\x01.`\09`\0\xF3\xFE`\x80`@R4\x80\x15`\x0FW`\0\x80\xFD[P`\x046\x10`FW`\x005`\xE0\x1C\x80c\x12\x90\r\xA8\x14`KW\x80c\xD7\xB6WE\x14`\x8FW\x80c\xF8\xA8\xFDm\x14`\xD2W\x80c\xF8\xCC\xBFG\x14`\xD4W[`\0\x80\xFD[`@\x80Q` \x80\x82\x01\x83R`\0\x90\x91R\x81Q\x80\x82\x01\x83R`\x0ETs\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x16\x90\x81\x90R\x91Q\x91\x82R\x01[`@Q\x80\x91\x03\x90\xF3[`\rT`\xAE\x90s\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x16\x81V[`@Qs\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x90\x91\x16\x81R` \x01`\x86V[\0[`\x0CT`\xE6\x90b\x01\0\0\x90\x04`\xFF\x16\x81V[`@Q\x90\x15\x15\x81R` \x01`\x86V",
|
||||
);
|
||||
@@ -123,12 +124,13 @@ pub mod DeploymentConfig {
|
||||
///0x6080604052348015600f57600080fd5b506004361060465760003560e01c806312900da814604b578063d7b6574514608f578063f8a8fd6d1460d2578063f8ccbf471460d4575b600080fd5b6040805160208082018352600090915281518082018352600e5473ffffffffffffffffffffffffffffffffffffffff16908190529151918252015b60405180910390f35b600d5460ae9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016086565b005b600c5460e69062010000900460ff1681565b6040519015158152602001608656
|
||||
/// ```
|
||||
#[rustfmt::skip]
|
||||
#[allow(clippy::all)]
|
||||
pub static DEPLOYED_BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static(
|
||||
b"`\x80`@R4\x80\x15`\x0FW`\0\x80\xFD[P`\x046\x10`FW`\x005`\xE0\x1C\x80c\x12\x90\r\xA8\x14`KW\x80c\xD7\xB6WE\x14`\x8FW\x80c\xF8\xA8\xFDm\x14`\xD2W\x80c\xF8\xCC\xBFG\x14`\xD4W[`\0\x80\xFD[`@\x80Q` \x80\x82\x01\x83R`\0\x90\x91R\x81Q\x80\x82\x01\x83R`\x0ETs\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x16\x90\x81\x90R\x91Q\x91\x82R\x01[`@Q\x80\x91\x03\x90\xF3[`\rT`\xAE\x90s\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x16\x81V[`@Qs\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x90\x91\x16\x81R` \x01`\x86V[\0[`\x0CT`\xE6\x90b\x01\0\0\x90\x04`\xFF\x16\x81V[`@Q\x90\x15\x15\x81R` \x01`\x86V",
|
||||
);
|
||||
/**```solidity
|
||||
struct NetworkConfig { address deployer; }
|
||||
```*/
|
||||
struct NetworkConfig { address deployer; }
|
||||
```*/
|
||||
#[allow(non_camel_case_types, non_snake_case)]
|
||||
#[derive(Clone)]
|
||||
pub struct NetworkConfig {
|
||||
@@ -143,9 +145,7 @@ struct NetworkConfig { address deployer; }
|
||||
type UnderlyingRustTuple<'a> = (alloy::sol_types::private::Address,);
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -182,49 +182,53 @@ struct NetworkConfig { address deployer; }
|
||||
}
|
||||
#[inline]
|
||||
fn stv_abi_encoded_size(&self) -> usize {
|
||||
let tuple = <UnderlyingRustTuple<
|
||||
'_,
|
||||
> as ::core::convert::From<Self>>::from(self.clone());
|
||||
<UnderlyingSolTuple<
|
||||
'_,
|
||||
> as alloy_sol_types::SolType>::abi_encoded_size(&tuple)
|
||||
if let Some(size) = <Self as alloy_sol_types::SolType>::ENCODED_SIZE {
|
||||
return size;
|
||||
}
|
||||
let tuple =
|
||||
<UnderlyingRustTuple<'_> as ::core::convert::From<Self>>::from(self.clone());
|
||||
<UnderlyingSolTuple<'_> as alloy_sol_types::SolType>::abi_encoded_size(&tuple)
|
||||
}
|
||||
#[inline]
|
||||
fn stv_eip712_data_word(&self) -> alloy_sol_types::Word {
|
||||
<Self as alloy_sol_types::SolStruct>::eip712_hash_struct(self)
|
||||
}
|
||||
#[inline]
|
||||
fn stv_abi_encode_packed_to(
|
||||
&self,
|
||||
out: &mut alloy_sol_types::private::Vec<u8>,
|
||||
) {
|
||||
let tuple = <UnderlyingRustTuple<
|
||||
'_,
|
||||
> as ::core::convert::From<Self>>::from(self.clone());
|
||||
<UnderlyingSolTuple<
|
||||
'_,
|
||||
> as alloy_sol_types::SolType>::abi_encode_packed_to(&tuple, out)
|
||||
fn stv_abi_encode_packed_to(&self, out: &mut alloy_sol_types::private::Vec<u8>) {
|
||||
let tuple =
|
||||
<UnderlyingRustTuple<'_> as ::core::convert::From<Self>>::from(self.clone());
|
||||
<UnderlyingSolTuple<'_> as alloy_sol_types::SolType>::abi_encode_packed_to(
|
||||
&tuple, out,
|
||||
)
|
||||
}
|
||||
#[inline]
|
||||
fn stv_abi_packed_encoded_size(&self) -> usize {
|
||||
if let Some(size) = <Self as alloy_sol_types::SolType>::PACKED_ENCODED_SIZE {
|
||||
return size;
|
||||
}
|
||||
let tuple =
|
||||
<UnderlyingRustTuple<'_> as ::core::convert::From<Self>>::from(self.clone());
|
||||
<UnderlyingSolTuple<'_> as alloy_sol_types::SolType>::abi_packed_encoded_size(
|
||||
&tuple,
|
||||
)
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolType for NetworkConfig {
|
||||
type RustType = Self;
|
||||
type Token<'a> = <UnderlyingSolTuple<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Token<'a> = <UnderlyingSolTuple<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
const SOL_NAME: &'static str = <Self as alloy_sol_types::SolStruct>::NAME;
|
||||
const ENCODED_SIZE: Option<usize> = <UnderlyingSolTuple<
|
||||
'_,
|
||||
> as alloy_sol_types::SolType>::ENCODED_SIZE;
|
||||
const ENCODED_SIZE: Option<usize> =
|
||||
<UnderlyingSolTuple<'_> as alloy_sol_types::SolType>::ENCODED_SIZE;
|
||||
const PACKED_ENCODED_SIZE: Option<usize> =
|
||||
<UnderlyingSolTuple<'_> as alloy_sol_types::SolType>::PACKED_ENCODED_SIZE;
|
||||
#[inline]
|
||||
fn valid_token(token: &Self::Token<'_>) -> bool {
|
||||
<UnderlyingSolTuple<'_> as alloy_sol_types::SolType>::valid_token(token)
|
||||
}
|
||||
#[inline]
|
||||
fn detokenize(token: Self::Token<'_>) -> Self::RustType {
|
||||
let tuple = <UnderlyingSolTuple<
|
||||
'_,
|
||||
> as alloy_sol_types::SolType>::detokenize(token);
|
||||
let tuple = <UnderlyingSolTuple<'_> as alloy_sol_types::SolType>::detokenize(token);
|
||||
<Self as ::core::convert::From<UnderlyingRustTuple<'_>>>::from(tuple)
|
||||
}
|
||||
}
|
||||
@@ -233,14 +237,12 @@ struct NetworkConfig { address deployer; }
|
||||
const NAME: &'static str = "NetworkConfig";
|
||||
#[inline]
|
||||
fn eip712_root_type() -> alloy_sol_types::private::Cow<'static, str> {
|
||||
alloy_sol_types::private::Cow::Borrowed(
|
||||
"NetworkConfig(address deployer)",
|
||||
)
|
||||
alloy_sol_types::private::Cow::Borrowed("NetworkConfig(address deployer)")
|
||||
}
|
||||
#[inline]
|
||||
fn eip712_components() -> alloy_sol_types::private::Vec<
|
||||
alloy_sol_types::private::Cow<'static, str>,
|
||||
> {
|
||||
fn eip712_components(
|
||||
) -> alloy_sol_types::private::Vec<alloy_sol_types::private::Cow<'static, str>>
|
||||
{
|
||||
alloy_sol_types::private::Vec::new()
|
||||
}
|
||||
#[inline]
|
||||
@@ -250,10 +252,10 @@ struct NetworkConfig { address deployer; }
|
||||
#[inline]
|
||||
fn eip712_encode_data(&self) -> alloy_sol_types::private::Vec<u8> {
|
||||
<alloy::sol_types::sol_data::Address as alloy_sol_types::SolType>::eip712_data_word(
|
||||
&self.deployer,
|
||||
)
|
||||
.0
|
||||
.to_vec()
|
||||
&self.deployer,
|
||||
)
|
||||
.0
|
||||
.to_vec()
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
@@ -270,33 +272,24 @@ struct NetworkConfig { address deployer; }
|
||||
rust: &Self::RustType,
|
||||
out: &mut alloy_sol_types::private::Vec<u8>,
|
||||
) {
|
||||
out.reserve(
|
||||
<Self as alloy_sol_types::EventTopic>::topic_preimage_length(rust),
|
||||
);
|
||||
out.reserve(<Self as alloy_sol_types::EventTopic>::topic_preimage_length(rust));
|
||||
<alloy::sol_types::sol_data::Address as alloy_sol_types::EventTopic>::encode_topic_preimage(
|
||||
&rust.deployer,
|
||||
out,
|
||||
);
|
||||
}
|
||||
#[inline]
|
||||
fn encode_topic(
|
||||
rust: &Self::RustType,
|
||||
) -> alloy_sol_types::abi::token::WordToken {
|
||||
fn encode_topic(rust: &Self::RustType) -> alloy_sol_types::abi::token::WordToken {
|
||||
let mut out = alloy_sol_types::private::Vec::new();
|
||||
<Self as alloy_sol_types::EventTopic>::encode_topic_preimage(
|
||||
rust,
|
||||
&mut out,
|
||||
);
|
||||
alloy_sol_types::abi::token::WordToken(
|
||||
alloy_sol_types::private::keccak256(out),
|
||||
)
|
||||
<Self as alloy_sol_types::EventTopic>::encode_topic_preimage(rust, &mut out);
|
||||
alloy_sol_types::abi::token::WordToken(alloy_sol_types::private::keccak256(out))
|
||||
}
|
||||
}
|
||||
};
|
||||
/**Custom error with signature `DeploymentConfig_InvalidDeployerAddress()` and selector `0x80585b44`.
|
||||
```solidity
|
||||
error DeploymentConfig_InvalidDeployerAddress();
|
||||
```*/
|
||||
```solidity
|
||||
error DeploymentConfig_InvalidDeployerAddress();
|
||||
```*/
|
||||
#[allow(non_camel_case_types, non_snake_case)]
|
||||
#[derive(Clone)]
|
||||
pub struct DeploymentConfig_InvalidDeployerAddress {}
|
||||
@@ -309,9 +302,7 @@ error DeploymentConfig_InvalidDeployerAddress();
|
||||
type UnderlyingRustTuple<'a> = ();
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -320,16 +311,14 @@ error DeploymentConfig_InvalidDeployerAddress();
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<DeploymentConfig_InvalidDeployerAddress>
|
||||
for UnderlyingRustTuple<'_> {
|
||||
impl ::core::convert::From<DeploymentConfig_InvalidDeployerAddress> for UnderlyingRustTuple<'_> {
|
||||
fn from(value: DeploymentConfig_InvalidDeployerAddress) -> Self {
|
||||
()
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>>
|
||||
for DeploymentConfig_InvalidDeployerAddress {
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>> for DeploymentConfig_InvalidDeployerAddress {
|
||||
fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
|
||||
Self {}
|
||||
}
|
||||
@@ -337,9 +326,7 @@ error DeploymentConfig_InvalidDeployerAddress();
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolError for DeploymentConfig_InvalidDeployerAddress {
|
||||
type Parameters<'a> = UnderlyingSolTuple<'a>;
|
||||
type Token<'a> = <Self::Parameters<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Token<'a> = <Self::Parameters<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
const SIGNATURE: &'static str = "DeploymentConfig_InvalidDeployerAddress()";
|
||||
const SELECTOR: [u8; 4] = [128u8, 88u8, 91u8, 68u8];
|
||||
#[inline]
|
||||
@@ -355,9 +342,9 @@ error DeploymentConfig_InvalidDeployerAddress();
|
||||
}
|
||||
};
|
||||
/**Custom error with signature `DeploymentConfig_NoConfigForChain(uint256)` and selector `0x0b13dbff`.
|
||||
```solidity
|
||||
error DeploymentConfig_NoConfigForChain(uint256);
|
||||
```*/
|
||||
```solidity
|
||||
error DeploymentConfig_NoConfigForChain(uint256);
|
||||
```*/
|
||||
#[allow(non_camel_case_types, non_snake_case)]
|
||||
#[derive(Clone)]
|
||||
pub struct DeploymentConfig_NoConfigForChain {
|
||||
@@ -372,9 +359,7 @@ error DeploymentConfig_NoConfigForChain(uint256);
|
||||
type UnderlyingRustTuple<'a> = (alloy::sol_types::private::U256,);
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -383,16 +368,14 @@ error DeploymentConfig_NoConfigForChain(uint256);
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<DeploymentConfig_NoConfigForChain>
|
||||
for UnderlyingRustTuple<'_> {
|
||||
impl ::core::convert::From<DeploymentConfig_NoConfigForChain> for UnderlyingRustTuple<'_> {
|
||||
fn from(value: DeploymentConfig_NoConfigForChain) -> Self {
|
||||
(value._0,)
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>>
|
||||
for DeploymentConfig_NoConfigForChain {
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>> for DeploymentConfig_NoConfigForChain {
|
||||
fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
|
||||
Self { _0: tuple.0 }
|
||||
}
|
||||
@@ -400,9 +383,7 @@ error DeploymentConfig_NoConfigForChain(uint256);
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolError for DeploymentConfig_NoConfigForChain {
|
||||
type Parameters<'a> = UnderlyingSolTuple<'a>;
|
||||
type Token<'a> = <Self::Parameters<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Token<'a> = <Self::Parameters<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
const SIGNATURE: &'static str = "DeploymentConfig_NoConfigForChain(uint256)";
|
||||
const SELECTOR: [u8; 4] = [11u8, 19u8, 219u8, 255u8];
|
||||
#[inline]
|
||||
@@ -414,17 +395,17 @@ error DeploymentConfig_NoConfigForChain(uint256);
|
||||
#[inline]
|
||||
fn tokenize(&self) -> Self::Token<'_> {
|
||||
(
|
||||
<alloy::sol_types::sol_data::Uint<
|
||||
256,
|
||||
> as alloy_sol_types::SolType>::tokenize(&self._0),
|
||||
<alloy::sol_types::sol_data::Uint<256> as alloy_sol_types::SolType>::tokenize(
|
||||
&self._0,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
};
|
||||
/**Constructor`.
|
||||
```solidity
|
||||
constructor(address _broadcaster);
|
||||
```*/
|
||||
```solidity
|
||||
constructor(address _broadcaster);
|
||||
```*/
|
||||
#[allow(non_camel_case_types, non_snake_case)]
|
||||
#[derive(Clone)]
|
||||
pub struct constructorCall {
|
||||
@@ -439,9 +420,7 @@ constructor(address _broadcaster);
|
||||
type UnderlyingRustTuple<'a> = (alloy::sol_types::private::Address,);
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -459,16 +438,16 @@ constructor(address _broadcaster);
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>> for constructorCall {
|
||||
fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
|
||||
Self { _broadcaster: tuple.0 }
|
||||
Self {
|
||||
_broadcaster: tuple.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolConstructor for constructorCall {
|
||||
type Parameters<'a> = (alloy::sol_types::sol_data::Address,);
|
||||
type Token<'a> = <Self::Parameters<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Token<'a> = <Self::Parameters<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
#[inline]
|
||||
fn new<'a>(
|
||||
tuple: <Self::Parameters<'a> as alloy_sol_types::SolType>::RustType,
|
||||
@@ -486,9 +465,9 @@ constructor(address _broadcaster);
|
||||
}
|
||||
};
|
||||
/**Function with signature `IS_SCRIPT()` and selector `0xf8ccbf47`.
|
||||
```solidity
|
||||
function IS_SCRIPT() external view returns (bool);
|
||||
```*/
|
||||
```solidity
|
||||
function IS_SCRIPT() external view returns (bool);
|
||||
```*/
|
||||
#[allow(non_camel_case_types, non_snake_case)]
|
||||
#[derive(Clone)]
|
||||
pub struct IS_SCRIPTCall {}
|
||||
@@ -508,9 +487,7 @@ function IS_SCRIPT() external view returns (bool);
|
||||
type UnderlyingRustTuple<'a> = ();
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -539,9 +516,7 @@ function IS_SCRIPT() external view returns (bool);
|
||||
type UnderlyingRustTuple<'a> = (bool,);
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -566,14 +541,10 @@ function IS_SCRIPT() external view returns (bool);
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolCall for IS_SCRIPTCall {
|
||||
type Parameters<'a> = ();
|
||||
type Token<'a> = <Self::Parameters<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Token<'a> = <Self::Parameters<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Return = IS_SCRIPTReturn;
|
||||
type ReturnTuple<'a> = (alloy::sol_types::sol_data::Bool,);
|
||||
type ReturnToken<'a> = <Self::ReturnTuple<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type ReturnToken<'a> = <Self::ReturnTuple<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
const SIGNATURE: &'static str = "IS_SCRIPT()";
|
||||
const SELECTOR: [u8; 4] = [248u8, 204u8, 191u8, 71u8];
|
||||
#[inline]
|
||||
@@ -591,17 +562,17 @@ function IS_SCRIPT() external view returns (bool);
|
||||
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)
|
||||
<Self::ReturnTuple<'_> as alloy_sol_types::SolType>::abi_decode_sequence(
|
||||
data, validate,
|
||||
)
|
||||
.map(Into::into)
|
||||
}
|
||||
}
|
||||
};
|
||||
/**Function with signature `activeNetworkConfig()` and selector `0xd7b65745`.
|
||||
```solidity
|
||||
function activeNetworkConfig() external view returns (address deployer);
|
||||
```*/
|
||||
```solidity
|
||||
function activeNetworkConfig() external view returns (address deployer);
|
||||
```*/
|
||||
#[allow(non_camel_case_types, non_snake_case)]
|
||||
#[derive(Clone)]
|
||||
pub struct activeNetworkConfigCall {}
|
||||
@@ -621,9 +592,7 @@ function activeNetworkConfig() external view returns (address deployer);
|
||||
type UnderlyingRustTuple<'a> = ();
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -632,16 +601,14 @@ function activeNetworkConfig() external view returns (address deployer);
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<activeNetworkConfigCall>
|
||||
for UnderlyingRustTuple<'_> {
|
||||
impl ::core::convert::From<activeNetworkConfigCall> for UnderlyingRustTuple<'_> {
|
||||
fn from(value: activeNetworkConfigCall) -> Self {
|
||||
()
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>>
|
||||
for activeNetworkConfigCall {
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>> for activeNetworkConfigCall {
|
||||
fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
|
||||
Self {}
|
||||
}
|
||||
@@ -654,9 +621,7 @@ function activeNetworkConfig() external view returns (address deployer);
|
||||
type UnderlyingRustTuple<'a> = (alloy::sol_types::private::Address,);
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -665,16 +630,14 @@ function activeNetworkConfig() external view returns (address deployer);
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<activeNetworkConfigReturn>
|
||||
for UnderlyingRustTuple<'_> {
|
||||
impl ::core::convert::From<activeNetworkConfigReturn> for UnderlyingRustTuple<'_> {
|
||||
fn from(value: activeNetworkConfigReturn) -> Self {
|
||||
(value.deployer,)
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>>
|
||||
for activeNetworkConfigReturn {
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>> for activeNetworkConfigReturn {
|
||||
fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
|
||||
Self { deployer: tuple.0 }
|
||||
}
|
||||
@@ -683,14 +646,10 @@ function activeNetworkConfig() external view returns (address deployer);
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolCall for activeNetworkConfigCall {
|
||||
type Parameters<'a> = ();
|
||||
type Token<'a> = <Self::Parameters<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Token<'a> = <Self::Parameters<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Return = activeNetworkConfigReturn;
|
||||
type ReturnTuple<'a> = (alloy::sol_types::sol_data::Address,);
|
||||
type ReturnToken<'a> = <Self::ReturnTuple<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type ReturnToken<'a> = <Self::ReturnTuple<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
const SIGNATURE: &'static str = "activeNetworkConfig()";
|
||||
const SELECTOR: [u8; 4] = [215u8, 182u8, 87u8, 69u8];
|
||||
#[inline]
|
||||
@@ -708,17 +667,17 @@ function activeNetworkConfig() external view returns (address deployer);
|
||||
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)
|
||||
<Self::ReturnTuple<'_> as alloy_sol_types::SolType>::abi_decode_sequence(
|
||||
data, validate,
|
||||
)
|
||||
.map(Into::into)
|
||||
}
|
||||
}
|
||||
};
|
||||
/**Function with signature `getOrCreateAnvilEthConfig()` and selector `0x12900da8`.
|
||||
```solidity
|
||||
function getOrCreateAnvilEthConfig() external view returns (NetworkConfig memory);
|
||||
```*/
|
||||
```solidity
|
||||
function getOrCreateAnvilEthConfig() external view returns (NetworkConfig memory);
|
||||
```*/
|
||||
#[allow(non_camel_case_types, non_snake_case)]
|
||||
#[derive(Clone)]
|
||||
pub struct getOrCreateAnvilEthConfigCall {}
|
||||
@@ -738,9 +697,7 @@ function getOrCreateAnvilEthConfig() external view returns (NetworkConfig memory
|
||||
type UnderlyingRustTuple<'a> = ();
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -749,16 +706,14 @@ function getOrCreateAnvilEthConfig() external view returns (NetworkConfig memory
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<getOrCreateAnvilEthConfigCall>
|
||||
for UnderlyingRustTuple<'_> {
|
||||
impl ::core::convert::From<getOrCreateAnvilEthConfigCall> for UnderlyingRustTuple<'_> {
|
||||
fn from(value: getOrCreateAnvilEthConfigCall) -> Self {
|
||||
()
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>>
|
||||
for getOrCreateAnvilEthConfigCall {
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>> for getOrCreateAnvilEthConfigCall {
|
||||
fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
|
||||
Self {}
|
||||
}
|
||||
@@ -768,14 +723,11 @@ function getOrCreateAnvilEthConfig() external view returns (NetworkConfig memory
|
||||
#[doc(hidden)]
|
||||
type UnderlyingSolTuple<'a> = (NetworkConfig,);
|
||||
#[doc(hidden)]
|
||||
type UnderlyingRustTuple<'a> = (
|
||||
<NetworkConfig as alloy::sol_types::SolType>::RustType,
|
||||
);
|
||||
type UnderlyingRustTuple<'a> =
|
||||
(<NetworkConfig as alloy::sol_types::SolType>::RustType,);
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -784,16 +736,14 @@ function getOrCreateAnvilEthConfig() external view returns (NetworkConfig memory
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<getOrCreateAnvilEthConfigReturn>
|
||||
for UnderlyingRustTuple<'_> {
|
||||
impl ::core::convert::From<getOrCreateAnvilEthConfigReturn> for UnderlyingRustTuple<'_> {
|
||||
fn from(value: getOrCreateAnvilEthConfigReturn) -> Self {
|
||||
(value._0,)
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>>
|
||||
for getOrCreateAnvilEthConfigReturn {
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>> for getOrCreateAnvilEthConfigReturn {
|
||||
fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
|
||||
Self { _0: tuple.0 }
|
||||
}
|
||||
@@ -802,14 +752,10 @@ function getOrCreateAnvilEthConfig() external view returns (NetworkConfig memory
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolCall for getOrCreateAnvilEthConfigCall {
|
||||
type Parameters<'a> = ();
|
||||
type Token<'a> = <Self::Parameters<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Token<'a> = <Self::Parameters<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Return = getOrCreateAnvilEthConfigReturn;
|
||||
type ReturnTuple<'a> = (NetworkConfig,);
|
||||
type ReturnToken<'a> = <Self::ReturnTuple<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type ReturnToken<'a> = <Self::ReturnTuple<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
const SIGNATURE: &'static str = "getOrCreateAnvilEthConfig()";
|
||||
const SELECTOR: [u8; 4] = [18u8, 144u8, 13u8, 168u8];
|
||||
#[inline]
|
||||
@@ -827,17 +773,17 @@ function getOrCreateAnvilEthConfig() external view returns (NetworkConfig memory
|
||||
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)
|
||||
<Self::ReturnTuple<'_> as alloy_sol_types::SolType>::abi_decode_sequence(
|
||||
data, validate,
|
||||
)
|
||||
.map(Into::into)
|
||||
}
|
||||
}
|
||||
};
|
||||
/**Function with signature `test()` and selector `0xf8a8fd6d`.
|
||||
```solidity
|
||||
function test() external;
|
||||
```*/
|
||||
```solidity
|
||||
function test() external;
|
||||
```*/
|
||||
#[allow(non_camel_case_types, non_snake_case)]
|
||||
#[derive(Clone)]
|
||||
pub struct testCall {}
|
||||
@@ -855,9 +801,7 @@ function test() external;
|
||||
type UnderlyingRustTuple<'a> = ();
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -886,9 +830,7 @@ function test() external;
|
||||
type UnderlyingRustTuple<'a> = ();
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -913,14 +855,10 @@ function test() external;
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolCall for testCall {
|
||||
type Parameters<'a> = ();
|
||||
type Token<'a> = <Self::Parameters<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Token<'a> = <Self::Parameters<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Return = testReturn;
|
||||
type ReturnTuple<'a> = ();
|
||||
type ReturnToken<'a> = <Self::ReturnTuple<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type ReturnToken<'a> = <Self::ReturnTuple<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
const SIGNATURE: &'static str = "test()";
|
||||
const SELECTOR: [u8; 4] = [248u8, 168u8, 253u8, 109u8];
|
||||
#[inline]
|
||||
@@ -938,10 +876,10 @@ function test() external;
|
||||
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)
|
||||
<Self::ReturnTuple<'_> as alloy_sol_types::SolType>::abi_decode_sequence(
|
||||
data, validate,
|
||||
)
|
||||
.map(Into::into)
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -975,9 +913,7 @@ function test() external;
|
||||
#[inline]
|
||||
fn selector(&self) -> [u8; 4] {
|
||||
match self {
|
||||
Self::IS_SCRIPT(_) => {
|
||||
<IS_SCRIPTCall as alloy_sol_types::SolCall>::SELECTOR
|
||||
}
|
||||
Self::IS_SCRIPT(_) => <IS_SCRIPTCall as alloy_sol_types::SolCall>::SELECTOR,
|
||||
Self::activeNetworkConfig(_) => {
|
||||
<activeNetworkConfigCall as alloy_sol_types::SolCall>::SELECTOR
|
||||
}
|
||||
@@ -1005,17 +941,17 @@ function test() external;
|
||||
static DECODE_SHIMS: &[fn(
|
||||
&[u8],
|
||||
bool,
|
||||
) -> alloy_sol_types::Result<DeploymentConfigCalls>] = &[
|
||||
)
|
||||
-> alloy_sol_types::Result<DeploymentConfigCalls>] = &[
|
||||
{
|
||||
fn getOrCreateAnvilEthConfig(
|
||||
data: &[u8],
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<DeploymentConfigCalls> {
|
||||
<getOrCreateAnvilEthConfigCall as alloy_sol_types::SolCall>::abi_decode_raw(
|
||||
data,
|
||||
validate,
|
||||
)
|
||||
.map(DeploymentConfigCalls::getOrCreateAnvilEthConfig)
|
||||
data, validate,
|
||||
)
|
||||
.map(DeploymentConfigCalls::getOrCreateAnvilEthConfig)
|
||||
}
|
||||
getOrCreateAnvilEthConfig
|
||||
},
|
||||
@@ -1025,10 +961,9 @@ function test() external;
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<DeploymentConfigCalls> {
|
||||
<activeNetworkConfigCall as alloy_sol_types::SolCall>::abi_decode_raw(
|
||||
data,
|
||||
validate,
|
||||
)
|
||||
.map(DeploymentConfigCalls::activeNetworkConfig)
|
||||
data, validate,
|
||||
)
|
||||
.map(DeploymentConfigCalls::activeNetworkConfig)
|
||||
}
|
||||
activeNetworkConfig
|
||||
},
|
||||
@@ -1037,10 +972,7 @@ function test() external;
|
||||
data: &[u8],
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<DeploymentConfigCalls> {
|
||||
<testCall as alloy_sol_types::SolCall>::abi_decode_raw(
|
||||
data,
|
||||
validate,
|
||||
)
|
||||
<testCall as alloy_sol_types::SolCall>::abi_decode_raw(data, validate)
|
||||
.map(DeploymentConfigCalls::test)
|
||||
}
|
||||
test
|
||||
@@ -1050,22 +982,17 @@ function test() external;
|
||||
data: &[u8],
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<DeploymentConfigCalls> {
|
||||
<IS_SCRIPTCall as alloy_sol_types::SolCall>::abi_decode_raw(
|
||||
data,
|
||||
validate,
|
||||
)
|
||||
<IS_SCRIPTCall as alloy_sol_types::SolCall>::abi_decode_raw(data, validate)
|
||||
.map(DeploymentConfigCalls::IS_SCRIPT)
|
||||
}
|
||||
IS_SCRIPT
|
||||
},
|
||||
];
|
||||
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,
|
||||
),
|
||||
);
|
||||
return Err(alloy_sol_types::Error::unknown_selector(
|
||||
<Self as alloy_sol_types::SolInterface>::NAME,
|
||||
selector,
|
||||
));
|
||||
};
|
||||
(unsafe { DECODE_SHIMS.get_unchecked(idx) })(data, validate)
|
||||
}
|
||||
@@ -1076,9 +1003,7 @@ function test() external;
|
||||
<IS_SCRIPTCall as alloy_sol_types::SolCall>::abi_encoded_size(inner)
|
||||
}
|
||||
Self::activeNetworkConfig(inner) => {
|
||||
<activeNetworkConfigCall as alloy_sol_types::SolCall>::abi_encoded_size(
|
||||
inner,
|
||||
)
|
||||
<activeNetworkConfigCall as alloy_sol_types::SolCall>::abi_encoded_size(inner)
|
||||
}
|
||||
Self::getOrCreateAnvilEthConfig(inner) => {
|
||||
<getOrCreateAnvilEthConfigCall as alloy_sol_types::SolCall>::abi_encoded_size(
|
||||
@@ -1094,21 +1019,16 @@ function test() external;
|
||||
fn abi_encode_raw(&self, out: &mut alloy_sol_types::private::Vec<u8>) {
|
||||
match self {
|
||||
Self::IS_SCRIPT(inner) => {
|
||||
<IS_SCRIPTCall as alloy_sol_types::SolCall>::abi_encode_raw(
|
||||
inner,
|
||||
out,
|
||||
)
|
||||
<IS_SCRIPTCall as alloy_sol_types::SolCall>::abi_encode_raw(inner, out)
|
||||
}
|
||||
Self::activeNetworkConfig(inner) => {
|
||||
<activeNetworkConfigCall as alloy_sol_types::SolCall>::abi_encode_raw(
|
||||
inner,
|
||||
out,
|
||||
inner, out,
|
||||
)
|
||||
}
|
||||
Self::getOrCreateAnvilEthConfig(inner) => {
|
||||
<getOrCreateAnvilEthConfigCall as alloy_sol_types::SolCall>::abi_encode_raw(
|
||||
inner,
|
||||
out,
|
||||
inner, out,
|
||||
)
|
||||
}
|
||||
Self::test(inner) => {
|
||||
@@ -1130,10 +1050,8 @@ function test() external;
|
||||
/// No guarantees are made about the order of the selectors.
|
||||
///
|
||||
/// Prefer using `SolInterface` methods instead.
|
||||
pub const SELECTORS: &'static [[u8; 4usize]] = &[
|
||||
[11u8, 19u8, 219u8, 255u8],
|
||||
[128u8, 88u8, 91u8, 68u8],
|
||||
];
|
||||
pub const SELECTORS: &'static [[u8; 4usize]] =
|
||||
&[[11u8, 19u8, 219u8, 255u8], [128u8, 88u8, 91u8, 68u8]];
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolInterface for DeploymentConfigErrors {
|
||||
@@ -1169,7 +1087,8 @@ function test() external;
|
||||
static DECODE_SHIMS: &[fn(
|
||||
&[u8],
|
||||
bool,
|
||||
) -> alloy_sol_types::Result<DeploymentConfigErrors>] = &[
|
||||
)
|
||||
-> alloy_sol_types::Result<DeploymentConfigErrors>] = &[
|
||||
{
|
||||
fn DeploymentConfig_NoConfigForChain(
|
||||
data: &[u8],
|
||||
@@ -1202,12 +1121,10 @@ function test() external;
|
||||
},
|
||||
];
|
||||
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,
|
||||
),
|
||||
);
|
||||
return Err(alloy_sol_types::Error::unknown_selector(
|
||||
<Self as alloy_sol_types::SolInterface>::NAME,
|
||||
selector,
|
||||
));
|
||||
};
|
||||
(unsafe { DECODE_SHIMS.get_unchecked(idx) })(data, validate)
|
||||
}
|
||||
@@ -1247,7 +1164,7 @@ function test() external;
|
||||
use alloy::contract as alloy_contract;
|
||||
/**Creates a new wrapper around an on-chain [`DeploymentConfig`](self) contract instance.
|
||||
|
||||
See the [wrapper's documentation](`DeploymentConfigInstance`) for more details.*/
|
||||
See the [wrapper's documentation](`DeploymentConfigInstance`) for more details.*/
|
||||
#[inline]
|
||||
pub const fn new<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
@@ -1261,9 +1178,9 @@ See the [wrapper's documentation](`DeploymentConfigInstance`) for more details.*
|
||||
}
|
||||
/**Deploys this contract using the given `provider` and constructor arguments, if any.
|
||||
|
||||
Returns a new instance of the contract, if the deployment was successful.
|
||||
Returns a new instance of the contract, if the deployment was successful.
|
||||
|
||||
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
|
||||
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
|
||||
#[inline]
|
||||
pub fn deploy<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
@@ -1272,16 +1189,15 @@ For more fine-grained control over the deployment process, use [`deploy_builder`
|
||||
>(
|
||||
provider: P,
|
||||
_broadcaster: alloy::sol_types::private::Address,
|
||||
) -> impl ::core::future::Future<
|
||||
Output = alloy_contract::Result<DeploymentConfigInstance<T, P, N>>,
|
||||
> {
|
||||
) -> impl ::core::future::Future<Output = alloy_contract::Result<DeploymentConfigInstance<T, P, N>>>
|
||||
{
|
||||
DeploymentConfigInstance::<T, P, N>::deploy(provider, _broadcaster)
|
||||
}
|
||||
/**Creates a `RawCallBuilder` for deploying this contract using the given `provider`
|
||||
and constructor arguments, if any.
|
||||
and constructor arguments, if any.
|
||||
|
||||
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
|
||||
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
|
||||
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
#[inline]
|
||||
pub fn deploy_builder<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
@@ -1295,15 +1211,15 @@ the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
}
|
||||
/**A [`DeploymentConfig`](self) instance.
|
||||
|
||||
Contains type-safe methods for interacting with an on-chain instance of the
|
||||
[`DeploymentConfig`](self) contract located at a given `address`, using a given
|
||||
provider `P`.
|
||||
Contains type-safe methods for interacting with an on-chain instance of the
|
||||
[`DeploymentConfig`](self) contract located at a given `address`, using a given
|
||||
provider `P`.
|
||||
|
||||
If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!)
|
||||
documentation on how to provide it), the `deploy` and `deploy_builder` methods can
|
||||
be used to deploy a new instance of the contract.
|
||||
If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!)
|
||||
documentation on how to provide it), the `deploy` and `deploy_builder` methods can
|
||||
be used to deploy a new instance of the contract.
|
||||
|
||||
See the [module-level documentation](self) for all the available methods.*/
|
||||
See the [module-level documentation](self) for all the available methods.*/
|
||||
#[derive(Clone)]
|
||||
pub struct DeploymentConfigInstance<T, P, N = alloy_contract::private::Ethereum> {
|
||||
address: alloy_sol_types::private::Address,
|
||||
@@ -1314,24 +1230,24 @@ See the [module-level documentation](self) for all the available methods.*/
|
||||
impl<T, P, N> ::core::fmt::Debug for DeploymentConfigInstance<T, P, N> {
|
||||
#[inline]
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
|
||||
f.debug_tuple("DeploymentConfigInstance").field(&self.address).finish()
|
||||
f.debug_tuple("DeploymentConfigInstance")
|
||||
.field(&self.address)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
/// Instantiation and getters/setters.
|
||||
#[automatically_derived]
|
||||
impl<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> DeploymentConfigInstance<T, P, N> {
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> DeploymentConfigInstance<T, P, N>
|
||||
{
|
||||
/**Creates a new wrapper around an on-chain [`DeploymentConfig`](self) contract instance.
|
||||
|
||||
See the [wrapper's documentation](`DeploymentConfigInstance`) for more details.*/
|
||||
See the [wrapper's documentation](`DeploymentConfigInstance`) for more details.*/
|
||||
#[inline]
|
||||
pub const fn new(
|
||||
address: alloy_sol_types::private::Address,
|
||||
provider: P,
|
||||
) -> Self {
|
||||
pub const fn new(address: alloy_sol_types::private::Address, provider: P) -> Self {
|
||||
Self {
|
||||
address,
|
||||
provider,
|
||||
@@ -1340,9 +1256,9 @@ See the [wrapper's documentation](`DeploymentConfigInstance`) for more details.*
|
||||
}
|
||||
/**Deploys this contract using the given `provider` and constructor arguments, if any.
|
||||
|
||||
Returns a new instance of the contract, if the deployment was successful.
|
||||
Returns a new instance of the contract, if the deployment was successful.
|
||||
|
||||
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
|
||||
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
|
||||
#[inline]
|
||||
pub async fn deploy(
|
||||
provider: P,
|
||||
@@ -1353,10 +1269,10 @@ For more fine-grained control over the deployment process, use [`deploy_builder`
|
||||
Ok(Self::new(contract_address, call_builder.provider))
|
||||
}
|
||||
/**Creates a `RawCallBuilder` for deploying this contract using the given `provider`
|
||||
and constructor arguments, if any.
|
||||
and constructor arguments, if any.
|
||||
|
||||
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
|
||||
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
|
||||
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
#[inline]
|
||||
pub fn deploy_builder(
|
||||
provider: P,
|
||||
@@ -1366,12 +1282,11 @@ the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
provider,
|
||||
[
|
||||
&BYTECODE[..],
|
||||
&alloy_sol_types::SolConstructor::abi_encode(
|
||||
&constructorCall { _broadcaster },
|
||||
)[..],
|
||||
&alloy_sol_types::SolConstructor::abi_encode(&constructorCall { _broadcaster })
|
||||
[..],
|
||||
]
|
||||
.concat()
|
||||
.into(),
|
||||
.concat()
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
/// Returns a reference to the address.
|
||||
@@ -1409,10 +1324,11 @@ the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
/// Function calls.
|
||||
#[automatically_derived]
|
||||
impl<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> DeploymentConfigInstance<T, P, N> {
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> DeploymentConfigInstance<T, P, N>
|
||||
{
|
||||
/// Creates a new call builder using this contract instance's provider and address.
|
||||
///
|
||||
/// Note that the call can be any function call, not just those defined in this
|
||||
@@ -1424,9 +1340,7 @@ the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
alloy_contract::SolCallBuilder::new_sol(&self.provider, &self.address, call)
|
||||
}
|
||||
///Creates a new call builder for the [`IS_SCRIPT`] function.
|
||||
pub fn IS_SCRIPT(
|
||||
&self,
|
||||
) -> alloy_contract::SolCallBuilder<T, &P, IS_SCRIPTCall, N> {
|
||||
pub fn IS_SCRIPT(&self) -> alloy_contract::SolCallBuilder<T, &P, IS_SCRIPTCall, N> {
|
||||
self.call_builder(&IS_SCRIPTCall {})
|
||||
}
|
||||
///Creates a new call builder for the [`activeNetworkConfig`] function.
|
||||
@@ -1449,10 +1363,11 @@ the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
/// Event filters.
|
||||
#[automatically_derived]
|
||||
impl<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> DeploymentConfigInstance<T, P, N> {
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> DeploymentConfigInstance<T, P, N>
|
||||
{
|
||||
/// Creates a new event filter using this contract instance's provider and address.
|
||||
///
|
||||
/// Note that the type can be any event, not just those defined in this contract.
|
||||
|
||||
@@ -1,446 +0,0 @@
|
||||
/**
|
||||
|
||||
Generated by the following Solidity interface...
|
||||
```solidity
|
||||
interface Foo {
|
||||
function id(uint256 value) external pure returns (uint256);
|
||||
}
|
||||
```
|
||||
|
||||
...which was generated by the following JSON ABI:
|
||||
```json
|
||||
[
|
||||
{
|
||||
"type": "function",
|
||||
"name": "id",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "value",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "pure"
|
||||
}
|
||||
]
|
||||
```*/
|
||||
#[allow(non_camel_case_types, non_snake_case, clippy::style)]
|
||||
pub mod Foo {
|
||||
use super::*;
|
||||
use alloy::sol_types as alloy_sol_types;
|
||||
/// The creation / init bytecode of the contract.
|
||||
///
|
||||
/// ```text
|
||||
///0x6080604052348015600f57600080fd5b5060658061001e6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80637d3c40c814602d575b600080fd5b603b6038366004604d565b90565b60405190815260200160405180910390f35b600060208284031215605e57600080fd5b503591905056
|
||||
/// ```
|
||||
#[rustfmt::skip]
|
||||
pub static BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static(
|
||||
b"`\x80`@R4\x80\x15`\x0FW`\0\x80\xFD[P`e\x80a\0\x1E`\09`\0\xF3\xFE`\x80`@R4\x80\x15`\x0FW`\0\x80\xFD[P`\x046\x10`(W`\x005`\xE0\x1C\x80c}<@\xC8\x14`-W[`\0\x80\xFD[`;`86`\x04`MV[\x90V[`@Q\x90\x81R` \x01`@Q\x80\x91\x03\x90\xF3[`\0` \x82\x84\x03\x12\x15`^W`\0\x80\xFD[P5\x91\x90PV",
|
||||
);
|
||||
/// The runtime bytecode of the contract, as deployed on the network.
|
||||
///
|
||||
/// ```text
|
||||
///0x6080604052348015600f57600080fd5b506004361060285760003560e01c80637d3c40c814602d575b600080fd5b603b6038366004604d565b90565b60405190815260200160405180910390f35b600060208284031215605e57600080fd5b503591905056
|
||||
/// ```
|
||||
#[rustfmt::skip]
|
||||
pub static DEPLOYED_BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static(
|
||||
b"`\x80`@R4\x80\x15`\x0FW`\0\x80\xFD[P`\x046\x10`(W`\x005`\xE0\x1C\x80c}<@\xC8\x14`-W[`\0\x80\xFD[`;`86`\x04`MV[\x90V[`@Q\x90\x81R` \x01`@Q\x80\x91\x03\x90\xF3[`\0` \x82\x84\x03\x12\x15`^W`\0\x80\xFD[P5\x91\x90PV",
|
||||
);
|
||||
/**Function with signature `id(uint256)` and selector `0x7d3c40c8`.
|
||||
```solidity
|
||||
function id(uint256 value) external pure returns (uint256);
|
||||
```*/
|
||||
#[allow(non_camel_case_types, non_snake_case)]
|
||||
#[derive(Clone)]
|
||||
pub struct idCall {
|
||||
pub value: alloy::sol_types::private::U256,
|
||||
}
|
||||
///Container type for the return parameters of the [`id(uint256)`](idCall) function.
|
||||
#[allow(non_camel_case_types, non_snake_case)]
|
||||
#[derive(Clone)]
|
||||
pub struct idReturn {
|
||||
pub _0: alloy::sol_types::private::U256,
|
||||
}
|
||||
#[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::Uint<256>,);
|
||||
#[doc(hidden)]
|
||||
type UnderlyingRustTuple<'a> = (alloy::sol_types::private::U256,);
|
||||
#[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<idCall> for UnderlyingRustTuple<'_> {
|
||||
fn from(value: idCall) -> Self {
|
||||
(value.value,)
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>> for idCall {
|
||||
fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
|
||||
Self { value: tuple.0 }
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
#[doc(hidden)]
|
||||
type UnderlyingSolTuple<'a> = (alloy::sol_types::sol_data::Uint<256>,);
|
||||
#[doc(hidden)]
|
||||
type UnderlyingRustTuple<'a> = (alloy::sol_types::private::U256,);
|
||||
#[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<idReturn> for UnderlyingRustTuple<'_> {
|
||||
fn from(value: idReturn) -> Self {
|
||||
(value._0,)
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>> for idReturn {
|
||||
fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
|
||||
Self { _0: tuple.0 }
|
||||
}
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolCall for idCall {
|
||||
type Parameters<'a> = (alloy::sol_types::sol_data::Uint<256>,);
|
||||
type Token<'a> = <Self::Parameters<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Return = idReturn;
|
||||
type ReturnTuple<'a> = (alloy::sol_types::sol_data::Uint<256>,);
|
||||
type ReturnToken<'a> = <Self::ReturnTuple<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
const SIGNATURE: &'static str = "id(uint256)";
|
||||
const SELECTOR: [u8; 4] = [125u8, 60u8, 64u8, 200u8];
|
||||
#[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::Uint<
|
||||
256,
|
||||
> as alloy_sol_types::SolType>::tokenize(&self.value),
|
||||
)
|
||||
}
|
||||
#[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 [`Foo`](self) function calls.
|
||||
pub enum FooCalls {
|
||||
id(idCall),
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl FooCalls {
|
||||
/// 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]] = &[[125u8, 60u8, 64u8, 200u8]];
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolInterface for FooCalls {
|
||||
const NAME: &'static str = "FooCalls";
|
||||
const MIN_DATA_LENGTH: usize = 32usize;
|
||||
const COUNT: usize = 1usize;
|
||||
#[inline]
|
||||
fn selector(&self) -> [u8; 4] {
|
||||
match self {
|
||||
Self::id(_) => <idCall 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<FooCalls>] = &[
|
||||
{
|
||||
fn id(
|
||||
data: &[u8],
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<FooCalls> {
|
||||
<idCall as alloy_sol_types::SolCall>::abi_decode_raw(
|
||||
data,
|
||||
validate,
|
||||
)
|
||||
.map(FooCalls::id)
|
||||
}
|
||||
id
|
||||
},
|
||||
];
|
||||
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::id(inner) => {
|
||||
<idCall 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::id(inner) => {
|
||||
<idCall as alloy_sol_types::SolCall>::abi_encode_raw(inner, out)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
use alloy::contract as alloy_contract;
|
||||
/**Creates a new wrapper around an on-chain [`Foo`](self) contract instance.
|
||||
|
||||
See the [wrapper's documentation](`FooInstance`) for more details.*/
|
||||
#[inline]
|
||||
pub const fn new<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
>(address: alloy_sol_types::private::Address, provider: P) -> FooInstance<T, P, N> {
|
||||
FooInstance::<T, P, N>::new(address, provider)
|
||||
}
|
||||
/**Deploys this contract using the given `provider` and constructor arguments, if any.
|
||||
|
||||
Returns a new instance of the contract, if the deployment was successful.
|
||||
|
||||
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
|
||||
#[inline]
|
||||
pub fn deploy<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
>(
|
||||
provider: P,
|
||||
) -> impl ::core::future::Future<
|
||||
Output = alloy_contract::Result<FooInstance<T, P, N>>,
|
||||
> {
|
||||
FooInstance::<T, P, N>::deploy(provider)
|
||||
}
|
||||
/**Creates a `RawCallBuilder` for deploying this contract using the given `provider`
|
||||
and constructor arguments, if any.
|
||||
|
||||
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
|
||||
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
#[inline]
|
||||
pub fn deploy_builder<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
>(provider: P) -> alloy_contract::RawCallBuilder<T, P, N> {
|
||||
FooInstance::<T, P, N>::deploy_builder(provider)
|
||||
}
|
||||
/**A [`Foo`](self) instance.
|
||||
|
||||
Contains type-safe methods for interacting with an on-chain instance of the
|
||||
[`Foo`](self) contract located at a given `address`, using a given
|
||||
provider `P`.
|
||||
|
||||
If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!)
|
||||
documentation on how to provide it), the `deploy` and `deploy_builder` methods can
|
||||
be used to deploy a new instance of the contract.
|
||||
|
||||
See the [module-level documentation](self) for all the available methods.*/
|
||||
#[derive(Clone)]
|
||||
pub struct FooInstance<T, P, N = alloy_contract::private::Ethereum> {
|
||||
address: alloy_sol_types::private::Address,
|
||||
provider: P,
|
||||
_network_transport: ::core::marker::PhantomData<(N, T)>,
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl<T, P, N> ::core::fmt::Debug for FooInstance<T, P, N> {
|
||||
#[inline]
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
|
||||
f.debug_tuple("FooInstance").field(&self.address).finish()
|
||||
}
|
||||
}
|
||||
/// Instantiation and getters/setters.
|
||||
#[automatically_derived]
|
||||
impl<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> FooInstance<T, P, N> {
|
||||
/**Creates a new wrapper around an on-chain [`Foo`](self) contract instance.
|
||||
|
||||
See the [wrapper's documentation](`FooInstance`) for more details.*/
|
||||
#[inline]
|
||||
pub const fn new(
|
||||
address: alloy_sol_types::private::Address,
|
||||
provider: P,
|
||||
) -> Self {
|
||||
Self {
|
||||
address,
|
||||
provider,
|
||||
_network_transport: ::core::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
/**Deploys this contract using the given `provider` and constructor arguments, if any.
|
||||
|
||||
Returns a new instance of the contract, if the deployment was successful.
|
||||
|
||||
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
|
||||
#[inline]
|
||||
pub async fn deploy(
|
||||
provider: P,
|
||||
) -> alloy_contract::Result<FooInstance<T, P, N>> {
|
||||
let call_builder = Self::deploy_builder(provider);
|
||||
let contract_address = call_builder.deploy().await?;
|
||||
Ok(Self::new(contract_address, call_builder.provider))
|
||||
}
|
||||
/**Creates a `RawCallBuilder` for deploying this contract using the given `provider`
|
||||
and constructor arguments, if any.
|
||||
|
||||
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
|
||||
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
#[inline]
|
||||
pub fn deploy_builder(provider: P) -> alloy_contract::RawCallBuilder<T, P, N> {
|
||||
alloy_contract::RawCallBuilder::new_raw_deploy(
|
||||
provider,
|
||||
::core::clone::Clone::clone(&BYTECODE),
|
||||
)
|
||||
}
|
||||
/// Returns a reference to the address.
|
||||
#[inline]
|
||||
pub const fn address(&self) -> &alloy_sol_types::private::Address {
|
||||
&self.address
|
||||
}
|
||||
/// Sets the address.
|
||||
#[inline]
|
||||
pub fn set_address(&mut self, address: alloy_sol_types::private::Address) {
|
||||
self.address = address;
|
||||
}
|
||||
/// Sets the address and returns `self`.
|
||||
pub fn at(mut self, address: alloy_sol_types::private::Address) -> Self {
|
||||
self.set_address(address);
|
||||
self
|
||||
}
|
||||
/// Returns a reference to the provider.
|
||||
#[inline]
|
||||
pub const fn provider(&self) -> &P {
|
||||
&self.provider
|
||||
}
|
||||
}
|
||||
impl<T, P: ::core::clone::Clone, N> FooInstance<T, &P, N> {
|
||||
/// Clones the provider and returns a new instance with the cloned provider.
|
||||
#[inline]
|
||||
pub fn with_cloned_provider(self) -> FooInstance<T, P, N> {
|
||||
FooInstance {
|
||||
address: self.address,
|
||||
provider: ::core::clone::Clone::clone(&self.provider),
|
||||
_network_transport: ::core::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Function calls.
|
||||
#[automatically_derived]
|
||||
impl<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> FooInstance<T, P, N> {
|
||||
/// Creates a new call builder using this contract instance's provider and address.
|
||||
///
|
||||
/// Note that the call can be any function call, not just those defined in this
|
||||
/// contract. Prefer using the other methods for building type-safe contract calls.
|
||||
pub fn call_builder<C: alloy_sol_types::SolCall>(
|
||||
&self,
|
||||
call: &C,
|
||||
) -> alloy_contract::SolCallBuilder<T, &P, C, N> {
|
||||
alloy_contract::SolCallBuilder::new_sol(&self.provider, &self.address, call)
|
||||
}
|
||||
///Creates a new call builder for the [`id`] function.
|
||||
pub fn id(
|
||||
&self,
|
||||
value: alloy::sol_types::private::U256,
|
||||
) -> alloy_contract::SolCallBuilder<T, &P, idCall, N> {
|
||||
self.call_builder(&idCall { value })
|
||||
}
|
||||
}
|
||||
/// Event filters.
|
||||
#[automatically_derived]
|
||||
impl<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> FooInstance<T, P, N> {
|
||||
/// Creates a new event filter using this contract instance's provider and address.
|
||||
///
|
||||
/// Note that the type can be any event, not just those defined in this contract.
|
||||
/// Prefer using the other methods for building type-safe event filters.
|
||||
pub fn event_filter<E: alloy_sol_types::SolEvent>(
|
||||
&self,
|
||||
) -> alloy_contract::Event<T, &P, E, N> {
|
||||
alloy_contract::Event::new_sol(&self.provider, &self.address)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,7 @@ pub mod IERC165 {
|
||||
///0x
|
||||
/// ```
|
||||
#[rustfmt::skip]
|
||||
#[allow(clippy::all)]
|
||||
pub static BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static(
|
||||
b"",
|
||||
);
|
||||
@@ -50,13 +51,14 @@ pub mod IERC165 {
|
||||
///0x
|
||||
/// ```
|
||||
#[rustfmt::skip]
|
||||
#[allow(clippy::all)]
|
||||
pub static DEPLOYED_BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static(
|
||||
b"",
|
||||
);
|
||||
/**Function with signature `supportsInterface(bytes4)` and selector `0x01ffc9a7`.
|
||||
```solidity
|
||||
function supportsInterface(bytes4 interfaceID) external view returns (bool);
|
||||
```*/
|
||||
```solidity
|
||||
function supportsInterface(bytes4 interfaceID) external view returns (bool);
|
||||
```*/
|
||||
#[allow(non_camel_case_types, non_snake_case)]
|
||||
#[derive(Clone)]
|
||||
pub struct supportsInterfaceCall {
|
||||
@@ -78,9 +80,7 @@ function supportsInterface(bytes4 interfaceID) external view returns (bool);
|
||||
type UnderlyingRustTuple<'a> = (alloy::sol_types::private::FixedBytes<4>,);
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -89,18 +89,18 @@ function supportsInterface(bytes4 interfaceID) external view returns (bool);
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<supportsInterfaceCall>
|
||||
for UnderlyingRustTuple<'_> {
|
||||
impl ::core::convert::From<supportsInterfaceCall> for UnderlyingRustTuple<'_> {
|
||||
fn from(value: supportsInterfaceCall) -> Self {
|
||||
(value.interfaceID,)
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>>
|
||||
for supportsInterfaceCall {
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>> for supportsInterfaceCall {
|
||||
fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
|
||||
Self { interfaceID: tuple.0 }
|
||||
Self {
|
||||
interfaceID: tuple.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,9 +111,7 @@ function supportsInterface(bytes4 interfaceID) external view returns (bool);
|
||||
type UnderlyingRustTuple<'a> = (bool,);
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -122,16 +120,14 @@ function supportsInterface(bytes4 interfaceID) external view returns (bool);
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<supportsInterfaceReturn>
|
||||
for UnderlyingRustTuple<'_> {
|
||||
impl ::core::convert::From<supportsInterfaceReturn> for UnderlyingRustTuple<'_> {
|
||||
fn from(value: supportsInterfaceReturn) -> Self {
|
||||
(value._0,)
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>>
|
||||
for supportsInterfaceReturn {
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>> for supportsInterfaceReturn {
|
||||
fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
|
||||
Self { _0: tuple.0 }
|
||||
}
|
||||
@@ -140,14 +136,10 @@ function supportsInterface(bytes4 interfaceID) external view returns (bool);
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolCall for supportsInterfaceCall {
|
||||
type Parameters<'a> = (alloy::sol_types::sol_data::FixedBytes<4>,);
|
||||
type Token<'a> = <Self::Parameters<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Token<'a> = <Self::Parameters<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Return = supportsInterfaceReturn;
|
||||
type ReturnTuple<'a> = (alloy::sol_types::sol_data::Bool,);
|
||||
type ReturnToken<'a> = <Self::ReturnTuple<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type ReturnToken<'a> = <Self::ReturnTuple<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
const SIGNATURE: &'static str = "supportsInterface(bytes4)";
|
||||
const SELECTOR: [u8; 4] = [1u8, 255u8, 201u8, 167u8];
|
||||
#[inline]
|
||||
@@ -169,10 +161,10 @@ function supportsInterface(bytes4 interfaceID) external view returns (bool);
|
||||
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)
|
||||
<Self::ReturnTuple<'_> as alloy_sol_types::SolType>::abi_decode_sequence(
|
||||
data, validate,
|
||||
)
|
||||
.map(Into::into)
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -218,31 +210,23 @@ function supportsInterface(bytes4 interfaceID) external view returns (bool);
|
||||
data: &[u8],
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<Self> {
|
||||
static DECODE_SHIMS: &[fn(
|
||||
&[u8],
|
||||
bool,
|
||||
) -> alloy_sol_types::Result<IERC165Calls>] = &[
|
||||
{
|
||||
fn supportsInterface(
|
||||
data: &[u8],
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<IERC165Calls> {
|
||||
<supportsInterfaceCall as alloy_sol_types::SolCall>::abi_decode_raw(
|
||||
data,
|
||||
validate,
|
||||
)
|
||||
.map(IERC165Calls::supportsInterface)
|
||||
}
|
||||
supportsInterface
|
||||
},
|
||||
];
|
||||
static DECODE_SHIMS: &[fn(&[u8], bool) -> alloy_sol_types::Result<IERC165Calls>] = &[{
|
||||
fn supportsInterface(
|
||||
data: &[u8],
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<IERC165Calls> {
|
||||
<supportsInterfaceCall as alloy_sol_types::SolCall>::abi_decode_raw(
|
||||
data, validate,
|
||||
)
|
||||
.map(IERC165Calls::supportsInterface)
|
||||
}
|
||||
supportsInterface
|
||||
}];
|
||||
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,
|
||||
),
|
||||
);
|
||||
return Err(alloy_sol_types::Error::unknown_selector(
|
||||
<Self as alloy_sol_types::SolInterface>::NAME,
|
||||
selector,
|
||||
));
|
||||
};
|
||||
(unsafe { DECODE_SHIMS.get_unchecked(idx) })(data, validate)
|
||||
}
|
||||
@@ -250,9 +234,7 @@ function supportsInterface(bytes4 interfaceID) external view returns (bool);
|
||||
fn abi_encoded_size(&self) -> usize {
|
||||
match self {
|
||||
Self::supportsInterface(inner) => {
|
||||
<supportsInterfaceCall as alloy_sol_types::SolCall>::abi_encoded_size(
|
||||
inner,
|
||||
)
|
||||
<supportsInterfaceCall as alloy_sol_types::SolCall>::abi_encoded_size(inner)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -260,10 +242,7 @@ function supportsInterface(bytes4 interfaceID) external view returns (bool);
|
||||
fn abi_encode_raw(&self, out: &mut alloy_sol_types::private::Vec<u8>) {
|
||||
match self {
|
||||
Self::supportsInterface(inner) => {
|
||||
<supportsInterfaceCall as alloy_sol_types::SolCall>::abi_encode_raw(
|
||||
inner,
|
||||
out,
|
||||
)
|
||||
<supportsInterfaceCall as alloy_sol_types::SolCall>::abi_encode_raw(inner, out)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -271,7 +250,7 @@ function supportsInterface(bytes4 interfaceID) external view returns (bool);
|
||||
use alloy::contract as alloy_contract;
|
||||
/**Creates a new wrapper around an on-chain [`IERC165`](self) contract instance.
|
||||
|
||||
See the [wrapper's documentation](`IERC165Instance`) for more details.*/
|
||||
See the [wrapper's documentation](`IERC165Instance`) for more details.*/
|
||||
#[inline]
|
||||
pub const fn new<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
@@ -285,9 +264,9 @@ See the [wrapper's documentation](`IERC165Instance`) for more details.*/
|
||||
}
|
||||
/**Deploys this contract using the given `provider` and constructor arguments, if any.
|
||||
|
||||
Returns a new instance of the contract, if the deployment was successful.
|
||||
Returns a new instance of the contract, if the deployment was successful.
|
||||
|
||||
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
|
||||
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
|
||||
#[inline]
|
||||
pub fn deploy<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
@@ -295,35 +274,36 @@ For more fine-grained control over the deployment process, use [`deploy_builder`
|
||||
N: alloy_contract::private::Network,
|
||||
>(
|
||||
provider: P,
|
||||
) -> impl ::core::future::Future<
|
||||
Output = alloy_contract::Result<IERC165Instance<T, P, N>>,
|
||||
> {
|
||||
) -> impl ::core::future::Future<Output = alloy_contract::Result<IERC165Instance<T, P, N>>>
|
||||
{
|
||||
IERC165Instance::<T, P, N>::deploy(provider)
|
||||
}
|
||||
/**Creates a `RawCallBuilder` for deploying this contract using the given `provider`
|
||||
and constructor arguments, if any.
|
||||
and constructor arguments, if any.
|
||||
|
||||
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
|
||||
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
|
||||
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
#[inline]
|
||||
pub fn deploy_builder<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
>(provider: P) -> alloy_contract::RawCallBuilder<T, P, N> {
|
||||
>(
|
||||
provider: P,
|
||||
) -> alloy_contract::RawCallBuilder<T, P, N> {
|
||||
IERC165Instance::<T, P, N>::deploy_builder(provider)
|
||||
}
|
||||
/**A [`IERC165`](self) instance.
|
||||
|
||||
Contains type-safe methods for interacting with an on-chain instance of the
|
||||
[`IERC165`](self) contract located at a given `address`, using a given
|
||||
provider `P`.
|
||||
Contains type-safe methods for interacting with an on-chain instance of the
|
||||
[`IERC165`](self) contract located at a given `address`, using a given
|
||||
provider `P`.
|
||||
|
||||
If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!)
|
||||
documentation on how to provide it), the `deploy` and `deploy_builder` methods can
|
||||
be used to deploy a new instance of the contract.
|
||||
If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!)
|
||||
documentation on how to provide it), the `deploy` and `deploy_builder` methods can
|
||||
be used to deploy a new instance of the contract.
|
||||
|
||||
See the [module-level documentation](self) for all the available methods.*/
|
||||
See the [module-level documentation](self) for all the available methods.*/
|
||||
#[derive(Clone)]
|
||||
pub struct IERC165Instance<T, P, N = alloy_contract::private::Ethereum> {
|
||||
address: alloy_sol_types::private::Address,
|
||||
@@ -334,24 +314,24 @@ See the [module-level documentation](self) for all the available methods.*/
|
||||
impl<T, P, N> ::core::fmt::Debug for IERC165Instance<T, P, N> {
|
||||
#[inline]
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
|
||||
f.debug_tuple("IERC165Instance").field(&self.address).finish()
|
||||
f.debug_tuple("IERC165Instance")
|
||||
.field(&self.address)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
/// Instantiation and getters/setters.
|
||||
#[automatically_derived]
|
||||
impl<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> IERC165Instance<T, P, N> {
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> IERC165Instance<T, P, N>
|
||||
{
|
||||
/**Creates a new wrapper around an on-chain [`IERC165`](self) contract instance.
|
||||
|
||||
See the [wrapper's documentation](`IERC165Instance`) for more details.*/
|
||||
See the [wrapper's documentation](`IERC165Instance`) for more details.*/
|
||||
#[inline]
|
||||
pub const fn new(
|
||||
address: alloy_sol_types::private::Address,
|
||||
provider: P,
|
||||
) -> Self {
|
||||
pub const fn new(address: alloy_sol_types::private::Address, provider: P) -> Self {
|
||||
Self {
|
||||
address,
|
||||
provider,
|
||||
@@ -360,22 +340,20 @@ See the [wrapper's documentation](`IERC165Instance`) for more details.*/
|
||||
}
|
||||
/**Deploys this contract using the given `provider` and constructor arguments, if any.
|
||||
|
||||
Returns a new instance of the contract, if the deployment was successful.
|
||||
Returns a new instance of the contract, if the deployment was successful.
|
||||
|
||||
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
|
||||
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
|
||||
#[inline]
|
||||
pub async fn deploy(
|
||||
provider: P,
|
||||
) -> alloy_contract::Result<IERC165Instance<T, P, N>> {
|
||||
pub async fn deploy(provider: P) -> alloy_contract::Result<IERC165Instance<T, P, N>> {
|
||||
let call_builder = Self::deploy_builder(provider);
|
||||
let contract_address = call_builder.deploy().await?;
|
||||
Ok(Self::new(contract_address, call_builder.provider))
|
||||
}
|
||||
/**Creates a `RawCallBuilder` for deploying this contract using the given `provider`
|
||||
and constructor arguments, if any.
|
||||
and constructor arguments, if any.
|
||||
|
||||
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
|
||||
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
|
||||
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
#[inline]
|
||||
pub fn deploy_builder(provider: P) -> alloy_contract::RawCallBuilder<T, P, N> {
|
||||
alloy_contract::RawCallBuilder::new_raw_deploy(
|
||||
@@ -418,10 +396,11 @@ the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
/// Function calls.
|
||||
#[automatically_derived]
|
||||
impl<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> IERC165Instance<T, P, N> {
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> IERC165Instance<T, P, N>
|
||||
{
|
||||
/// Creates a new call builder using this contract instance's provider and address.
|
||||
///
|
||||
/// Note that the call can be any function call, not just those defined in this
|
||||
@@ -437,20 +416,17 @@ the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
&self,
|
||||
interfaceID: alloy::sol_types::private::FixedBytes<4>,
|
||||
) -> alloy_contract::SolCallBuilder<T, &P, supportsInterfaceCall, N> {
|
||||
self.call_builder(
|
||||
&supportsInterfaceCall {
|
||||
interfaceID,
|
||||
},
|
||||
)
|
||||
self.call_builder(&supportsInterfaceCall { interfaceID })
|
||||
}
|
||||
}
|
||||
/// Event filters.
|
||||
#[automatically_derived]
|
||||
impl<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> IERC165Instance<T, P, N> {
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> IERC165Instance<T, P, N>
|
||||
{
|
||||
/// Creates a new event filter using this contract instance's provider and address.
|
||||
///
|
||||
/// Note that the type can be any event, not just those defined in this contract.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -56,6 +56,7 @@ pub mod IERC721TokenReceiver {
|
||||
///0x
|
||||
/// ```
|
||||
#[rustfmt::skip]
|
||||
#[allow(clippy::all)]
|
||||
pub static BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static(
|
||||
b"",
|
||||
);
|
||||
@@ -65,13 +66,14 @@ pub mod IERC721TokenReceiver {
|
||||
///0x
|
||||
/// ```
|
||||
#[rustfmt::skip]
|
||||
#[allow(clippy::all)]
|
||||
pub static DEPLOYED_BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static(
|
||||
b"",
|
||||
);
|
||||
/**Function with signature `onERC721Received(address,address,uint256,bytes)` and selector `0x150b7a02`.
|
||||
```solidity
|
||||
function onERC721Received(address _operator, address _from, uint256 _tokenId, bytes memory _data) external returns (bytes4);
|
||||
```*/
|
||||
```solidity
|
||||
function onERC721Received(address _operator, address _from, uint256 _tokenId, bytes memory _data) external returns (bytes4);
|
||||
```*/
|
||||
#[allow(non_camel_case_types, non_snake_case)]
|
||||
#[derive(Clone)]
|
||||
pub struct onERC721ReceivedCall {
|
||||
@@ -106,9 +108,7 @@ function onERC721Received(address _operator, address _from, uint256 _tokenId, by
|
||||
);
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -117,16 +117,14 @@ function onERC721Received(address _operator, address _from, uint256 _tokenId, by
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<onERC721ReceivedCall>
|
||||
for UnderlyingRustTuple<'_> {
|
||||
impl ::core::convert::From<onERC721ReceivedCall> for UnderlyingRustTuple<'_> {
|
||||
fn from(value: onERC721ReceivedCall) -> Self {
|
||||
(value._operator, value._from, value._tokenId, value._data)
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>>
|
||||
for onERC721ReceivedCall {
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>> for onERC721ReceivedCall {
|
||||
fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
|
||||
Self {
|
||||
_operator: tuple.0,
|
||||
@@ -144,9 +142,7 @@ function onERC721Received(address _operator, address _from, uint256 _tokenId, by
|
||||
type UnderlyingRustTuple<'a> = (alloy::sol_types::private::FixedBytes<4>,);
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -155,16 +151,14 @@ function onERC721Received(address _operator, address _from, uint256 _tokenId, by
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<onERC721ReceivedReturn>
|
||||
for UnderlyingRustTuple<'_> {
|
||||
impl ::core::convert::From<onERC721ReceivedReturn> for UnderlyingRustTuple<'_> {
|
||||
fn from(value: onERC721ReceivedReturn) -> Self {
|
||||
(value._0,)
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>>
|
||||
for onERC721ReceivedReturn {
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>> for onERC721ReceivedReturn {
|
||||
fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
|
||||
Self { _0: tuple.0 }
|
||||
}
|
||||
@@ -178,14 +172,10 @@ function onERC721Received(address _operator, address _from, uint256 _tokenId, by
|
||||
alloy::sol_types::sol_data::Uint<256>,
|
||||
alloy::sol_types::sol_data::Bytes,
|
||||
);
|
||||
type Token<'a> = <Self::Parameters<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Token<'a> = <Self::Parameters<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Return = onERC721ReceivedReturn;
|
||||
type ReturnTuple<'a> = (alloy::sol_types::sol_data::FixedBytes<4>,);
|
||||
type ReturnToken<'a> = <Self::ReturnTuple<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type ReturnToken<'a> = <Self::ReturnTuple<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
const SIGNATURE: &'static str = "onERC721Received(address,address,uint256,bytes)";
|
||||
const SELECTOR: [u8; 4] = [21u8, 11u8, 122u8, 2u8];
|
||||
#[inline]
|
||||
@@ -203,9 +193,9 @@ function onERC721Received(address _operator, address _from, uint256 _tokenId, by
|
||||
<alloy::sol_types::sol_data::Address as alloy_sol_types::SolType>::tokenize(
|
||||
&self._from,
|
||||
),
|
||||
<alloy::sol_types::sol_data::Uint<
|
||||
256,
|
||||
> as alloy_sol_types::SolType>::tokenize(&self._tokenId),
|
||||
<alloy::sol_types::sol_data::Uint<256> as alloy_sol_types::SolType>::tokenize(
|
||||
&self._tokenId,
|
||||
),
|
||||
<alloy::sol_types::sol_data::Bytes as alloy_sol_types::SolType>::tokenize(
|
||||
&self._data,
|
||||
),
|
||||
@@ -216,10 +206,10 @@ function onERC721Received(address _operator, address _from, uint256 _tokenId, by
|
||||
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)
|
||||
<Self::ReturnTuple<'_> as alloy_sol_types::SolType>::abi_decode_sequence(
|
||||
data, validate,
|
||||
)
|
||||
.map(Into::into)
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -268,28 +258,24 @@ function onERC721Received(address _operator, address _from, uint256 _tokenId, by
|
||||
static DECODE_SHIMS: &[fn(
|
||||
&[u8],
|
||||
bool,
|
||||
) -> alloy_sol_types::Result<IERC721TokenReceiverCalls>] = &[
|
||||
{
|
||||
fn onERC721Received(
|
||||
data: &[u8],
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<IERC721TokenReceiverCalls> {
|
||||
<onERC721ReceivedCall as alloy_sol_types::SolCall>::abi_decode_raw(
|
||||
data,
|
||||
validate,
|
||||
)
|
||||
.map(IERC721TokenReceiverCalls::onERC721Received)
|
||||
}
|
||||
onERC721Received
|
||||
},
|
||||
];
|
||||
)
|
||||
-> alloy_sol_types::Result<IERC721TokenReceiverCalls>] = &[{
|
||||
fn onERC721Received(
|
||||
data: &[u8],
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<IERC721TokenReceiverCalls> {
|
||||
<onERC721ReceivedCall as alloy_sol_types::SolCall>::abi_decode_raw(
|
||||
data, validate,
|
||||
)
|
||||
.map(IERC721TokenReceiverCalls::onERC721Received)
|
||||
}
|
||||
onERC721Received
|
||||
}];
|
||||
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,
|
||||
),
|
||||
);
|
||||
return Err(alloy_sol_types::Error::unknown_selector(
|
||||
<Self as alloy_sol_types::SolInterface>::NAME,
|
||||
selector,
|
||||
));
|
||||
};
|
||||
(unsafe { DECODE_SHIMS.get_unchecked(idx) })(data, validate)
|
||||
}
|
||||
@@ -297,9 +283,7 @@ function onERC721Received(address _operator, address _from, uint256 _tokenId, by
|
||||
fn abi_encoded_size(&self) -> usize {
|
||||
match self {
|
||||
Self::onERC721Received(inner) => {
|
||||
<onERC721ReceivedCall as alloy_sol_types::SolCall>::abi_encoded_size(
|
||||
inner,
|
||||
)
|
||||
<onERC721ReceivedCall as alloy_sol_types::SolCall>::abi_encoded_size(inner)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -307,10 +291,7 @@ function onERC721Received(address _operator, address _from, uint256 _tokenId, by
|
||||
fn abi_encode_raw(&self, out: &mut alloy_sol_types::private::Vec<u8>) {
|
||||
match self {
|
||||
Self::onERC721Received(inner) => {
|
||||
<onERC721ReceivedCall as alloy_sol_types::SolCall>::abi_encode_raw(
|
||||
inner,
|
||||
out,
|
||||
)
|
||||
<onERC721ReceivedCall as alloy_sol_types::SolCall>::abi_encode_raw(inner, out)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -318,7 +299,7 @@ function onERC721Received(address _operator, address _from, uint256 _tokenId, by
|
||||
use alloy::contract as alloy_contract;
|
||||
/**Creates a new wrapper around an on-chain [`IERC721TokenReceiver`](self) contract instance.
|
||||
|
||||
See the [wrapper's documentation](`IERC721TokenReceiverInstance`) for more details.*/
|
||||
See the [wrapper's documentation](`IERC721TokenReceiverInstance`) for more details.*/
|
||||
#[inline]
|
||||
pub const fn new<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
@@ -332,9 +313,9 @@ See the [wrapper's documentation](`IERC721TokenReceiverInstance`) for more detai
|
||||
}
|
||||
/**Deploys this contract using the given `provider` and constructor arguments, if any.
|
||||
|
||||
Returns a new instance of the contract, if the deployment was successful.
|
||||
Returns a new instance of the contract, if the deployment was successful.
|
||||
|
||||
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
|
||||
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
|
||||
#[inline]
|
||||
pub fn deploy<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
@@ -348,35 +329,33 @@ For more fine-grained control over the deployment process, use [`deploy_builder`
|
||||
IERC721TokenReceiverInstance::<T, P, N>::deploy(provider)
|
||||
}
|
||||
/**Creates a `RawCallBuilder` for deploying this contract using the given `provider`
|
||||
and constructor arguments, if any.
|
||||
and constructor arguments, if any.
|
||||
|
||||
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
|
||||
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
|
||||
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
#[inline]
|
||||
pub fn deploy_builder<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
>(provider: P) -> alloy_contract::RawCallBuilder<T, P, N> {
|
||||
>(
|
||||
provider: P,
|
||||
) -> alloy_contract::RawCallBuilder<T, P, N> {
|
||||
IERC721TokenReceiverInstance::<T, P, N>::deploy_builder(provider)
|
||||
}
|
||||
/**A [`IERC721TokenReceiver`](self) instance.
|
||||
|
||||
Contains type-safe methods for interacting with an on-chain instance of the
|
||||
[`IERC721TokenReceiver`](self) contract located at a given `address`, using a given
|
||||
provider `P`.
|
||||
Contains type-safe methods for interacting with an on-chain instance of the
|
||||
[`IERC721TokenReceiver`](self) contract located at a given `address`, using a given
|
||||
provider `P`.
|
||||
|
||||
If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!)
|
||||
documentation on how to provide it), the `deploy` and `deploy_builder` methods can
|
||||
be used to deploy a new instance of the contract.
|
||||
If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!)
|
||||
documentation on how to provide it), the `deploy` and `deploy_builder` methods can
|
||||
be used to deploy a new instance of the contract.
|
||||
|
||||
See the [module-level documentation](self) for all the available methods.*/
|
||||
See the [module-level documentation](self) for all the available methods.*/
|
||||
#[derive(Clone)]
|
||||
pub struct IERC721TokenReceiverInstance<
|
||||
T,
|
||||
P,
|
||||
N = alloy_contract::private::Ethereum,
|
||||
> {
|
||||
pub struct IERC721TokenReceiverInstance<T, P, N = alloy_contract::private::Ethereum> {
|
||||
address: alloy_sol_types::private::Address,
|
||||
provider: P,
|
||||
_network_transport: ::core::marker::PhantomData<(N, T)>,
|
||||
@@ -385,24 +364,24 @@ See the [module-level documentation](self) for all the available methods.*/
|
||||
impl<T, P, N> ::core::fmt::Debug for IERC721TokenReceiverInstance<T, P, N> {
|
||||
#[inline]
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
|
||||
f.debug_tuple("IERC721TokenReceiverInstance").field(&self.address).finish()
|
||||
f.debug_tuple("IERC721TokenReceiverInstance")
|
||||
.field(&self.address)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
/// Instantiation and getters/setters.
|
||||
#[automatically_derived]
|
||||
impl<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> IERC721TokenReceiverInstance<T, P, N> {
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> IERC721TokenReceiverInstance<T, P, N>
|
||||
{
|
||||
/**Creates a new wrapper around an on-chain [`IERC721TokenReceiver`](self) contract instance.
|
||||
|
||||
See the [wrapper's documentation](`IERC721TokenReceiverInstance`) for more details.*/
|
||||
See the [wrapper's documentation](`IERC721TokenReceiverInstance`) for more details.*/
|
||||
#[inline]
|
||||
pub const fn new(
|
||||
address: alloy_sol_types::private::Address,
|
||||
provider: P,
|
||||
) -> Self {
|
||||
pub const fn new(address: alloy_sol_types::private::Address, provider: P) -> Self {
|
||||
Self {
|
||||
address,
|
||||
provider,
|
||||
@@ -411,9 +390,9 @@ See the [wrapper's documentation](`IERC721TokenReceiverInstance`) for more detai
|
||||
}
|
||||
/**Deploys this contract using the given `provider` and constructor arguments, if any.
|
||||
|
||||
Returns a new instance of the contract, if the deployment was successful.
|
||||
Returns a new instance of the contract, if the deployment was successful.
|
||||
|
||||
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
|
||||
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
|
||||
#[inline]
|
||||
pub async fn deploy(
|
||||
provider: P,
|
||||
@@ -423,10 +402,10 @@ For more fine-grained control over the deployment process, use [`deploy_builder`
|
||||
Ok(Self::new(contract_address, call_builder.provider))
|
||||
}
|
||||
/**Creates a `RawCallBuilder` for deploying this contract using the given `provider`
|
||||
and constructor arguments, if any.
|
||||
and constructor arguments, if any.
|
||||
|
||||
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
|
||||
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
|
||||
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
#[inline]
|
||||
pub fn deploy_builder(provider: P) -> alloy_contract::RawCallBuilder<T, P, N> {
|
||||
alloy_contract::RawCallBuilder::new_raw_deploy(
|
||||
@@ -469,10 +448,11 @@ the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
/// Function calls.
|
||||
#[automatically_derived]
|
||||
impl<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> IERC721TokenReceiverInstance<T, P, N> {
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> IERC721TokenReceiverInstance<T, P, N>
|
||||
{
|
||||
/// Creates a new call builder using this contract instance's provider and address.
|
||||
///
|
||||
/// Note that the call can be any function call, not just those defined in this
|
||||
@@ -491,23 +471,22 @@ the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
_tokenId: alloy::sol_types::private::U256,
|
||||
_data: alloy::sol_types::private::Bytes,
|
||||
) -> alloy_contract::SolCallBuilder<T, &P, onERC721ReceivedCall, N> {
|
||||
self.call_builder(
|
||||
&onERC721ReceivedCall {
|
||||
_operator,
|
||||
_from,
|
||||
_tokenId,
|
||||
_data,
|
||||
},
|
||||
)
|
||||
self.call_builder(&onERC721ReceivedCall {
|
||||
_operator,
|
||||
_from,
|
||||
_tokenId,
|
||||
_data,
|
||||
})
|
||||
}
|
||||
}
|
||||
/// Event filters.
|
||||
#[automatically_derived]
|
||||
impl<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> IERC721TokenReceiverInstance<T, P, N> {
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> IERC721TokenReceiverInstance<T, P, N>
|
||||
{
|
||||
/// Creates a new event filter using this contract instance's provider and address.
|
||||
///
|
||||
/// Note that the type can be any event, not just those defined in this contract.
|
||||
|
||||
@@ -69,6 +69,7 @@ pub mod IScKeystore {
|
||||
///0x
|
||||
/// ```
|
||||
#[rustfmt::skip]
|
||||
#[allow(clippy::all)]
|
||||
pub static BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static(
|
||||
b"",
|
||||
);
|
||||
@@ -78,13 +79,14 @@ pub mod IScKeystore {
|
||||
///0x
|
||||
/// ```
|
||||
#[rustfmt::skip]
|
||||
#[allow(clippy::all)]
|
||||
pub static DEPLOYED_BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static(
|
||||
b"",
|
||||
);
|
||||
/**Function with signature `addUser(address)` and selector `0x421b2d8b`.
|
||||
```solidity
|
||||
function addUser(address user) external;
|
||||
```*/
|
||||
```solidity
|
||||
function addUser(address user) external;
|
||||
```*/
|
||||
#[allow(non_camel_case_types, non_snake_case)]
|
||||
#[derive(Clone)]
|
||||
pub struct addUserCall {
|
||||
@@ -104,9 +106,7 @@ function addUser(address user) external;
|
||||
type UnderlyingRustTuple<'a> = (alloy::sol_types::private::Address,);
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -135,9 +135,7 @@ function addUser(address user) external;
|
||||
type UnderlyingRustTuple<'a> = ();
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -162,14 +160,10 @@ function addUser(address user) external;
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolCall for addUserCall {
|
||||
type Parameters<'a> = (alloy::sol_types::sol_data::Address,);
|
||||
type Token<'a> = <Self::Parameters<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Token<'a> = <Self::Parameters<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Return = addUserReturn;
|
||||
type ReturnTuple<'a> = ();
|
||||
type ReturnToken<'a> = <Self::ReturnTuple<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type ReturnToken<'a> = <Self::ReturnTuple<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
const SIGNATURE: &'static str = "addUser(address)";
|
||||
const SELECTOR: [u8; 4] = [66u8, 27u8, 45u8, 139u8];
|
||||
#[inline]
|
||||
@@ -191,17 +185,17 @@ function addUser(address user) external;
|
||||
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)
|
||||
<Self::ReturnTuple<'_> as alloy_sol_types::SolType>::abi_decode_sequence(
|
||||
data, validate,
|
||||
)
|
||||
.map(Into::into)
|
||||
}
|
||||
}
|
||||
};
|
||||
/**Function with signature `removeUser(address)` and selector `0x98575188`.
|
||||
```solidity
|
||||
function removeUser(address user) external;
|
||||
```*/
|
||||
```solidity
|
||||
function removeUser(address user) external;
|
||||
```*/
|
||||
#[allow(non_camel_case_types, non_snake_case)]
|
||||
#[derive(Clone)]
|
||||
pub struct removeUserCall {
|
||||
@@ -221,9 +215,7 @@ function removeUser(address user) external;
|
||||
type UnderlyingRustTuple<'a> = (alloy::sol_types::private::Address,);
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -252,9 +244,7 @@ function removeUser(address user) external;
|
||||
type UnderlyingRustTuple<'a> = ();
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -279,14 +269,10 @@ function removeUser(address user) external;
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolCall for removeUserCall {
|
||||
type Parameters<'a> = (alloy::sol_types::sol_data::Address,);
|
||||
type Token<'a> = <Self::Parameters<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Token<'a> = <Self::Parameters<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Return = removeUserReturn;
|
||||
type ReturnTuple<'a> = ();
|
||||
type ReturnToken<'a> = <Self::ReturnTuple<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type ReturnToken<'a> = <Self::ReturnTuple<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
const SIGNATURE: &'static str = "removeUser(address)";
|
||||
const SELECTOR: [u8; 4] = [152u8, 87u8, 81u8, 136u8];
|
||||
#[inline]
|
||||
@@ -308,17 +294,17 @@ function removeUser(address user) external;
|
||||
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)
|
||||
<Self::ReturnTuple<'_> as alloy_sol_types::SolType>::abi_decode_sequence(
|
||||
data, validate,
|
||||
)
|
||||
.map(Into::into)
|
||||
}
|
||||
}
|
||||
};
|
||||
/**Function with signature `userExists(address)` and selector `0x0e666e49`.
|
||||
```solidity
|
||||
function userExists(address user) external view returns (bool);
|
||||
```*/
|
||||
```solidity
|
||||
function userExists(address user) external view returns (bool);
|
||||
```*/
|
||||
#[allow(non_camel_case_types, non_snake_case)]
|
||||
#[derive(Clone)]
|
||||
pub struct userExistsCall {
|
||||
@@ -340,9 +326,7 @@ function userExists(address user) external view returns (bool);
|
||||
type UnderlyingRustTuple<'a> = (alloy::sol_types::private::Address,);
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -371,9 +355,7 @@ function userExists(address user) external view returns (bool);
|
||||
type UnderlyingRustTuple<'a> = (bool,);
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -398,14 +380,10 @@ function userExists(address user) external view returns (bool);
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolCall for userExistsCall {
|
||||
type Parameters<'a> = (alloy::sol_types::sol_data::Address,);
|
||||
type Token<'a> = <Self::Parameters<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Token<'a> = <Self::Parameters<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Return = userExistsReturn;
|
||||
type ReturnTuple<'a> = (alloy::sol_types::sol_data::Bool,);
|
||||
type ReturnToken<'a> = <Self::ReturnTuple<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type ReturnToken<'a> = <Self::ReturnTuple<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
const SIGNATURE: &'static str = "userExists(address)";
|
||||
const SELECTOR: [u8; 4] = [14u8, 102u8, 110u8, 73u8];
|
||||
#[inline]
|
||||
@@ -427,10 +405,10 @@ function userExists(address user) external view returns (bool);
|
||||
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)
|
||||
<Self::ReturnTuple<'_> as alloy_sol_types::SolType>::abi_decode_sequence(
|
||||
data, validate,
|
||||
)
|
||||
.map(Into::into)
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -463,12 +441,8 @@ function userExists(address user) external view returns (bool);
|
||||
fn selector(&self) -> [u8; 4] {
|
||||
match self {
|
||||
Self::addUser(_) => <addUserCall as alloy_sol_types::SolCall>::SELECTOR,
|
||||
Self::removeUser(_) => {
|
||||
<removeUserCall as alloy_sol_types::SolCall>::SELECTOR
|
||||
}
|
||||
Self::userExists(_) => {
|
||||
<userExistsCall as alloy_sol_types::SolCall>::SELECTOR
|
||||
}
|
||||
Self::removeUser(_) => <removeUserCall as alloy_sol_types::SolCall>::SELECTOR,
|
||||
Self::userExists(_) => <userExistsCall as alloy_sol_types::SolCall>::SELECTOR,
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
@@ -486,57 +460,50 @@ function userExists(address user) external view returns (bool);
|
||||
data: &[u8],
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<Self> {
|
||||
static DECODE_SHIMS: &[fn(
|
||||
&[u8],
|
||||
bool,
|
||||
) -> alloy_sol_types::Result<IScKeystoreCalls>] = &[
|
||||
{
|
||||
fn userExists(
|
||||
data: &[u8],
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<IScKeystoreCalls> {
|
||||
<userExistsCall as alloy_sol_types::SolCall>::abi_decode_raw(
|
||||
data,
|
||||
validate,
|
||||
static DECODE_SHIMS: &[fn(&[u8], bool) -> alloy_sol_types::Result<IScKeystoreCalls>] =
|
||||
&[
|
||||
{
|
||||
fn userExists(
|
||||
data: &[u8],
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<IScKeystoreCalls> {
|
||||
<userExistsCall as alloy_sol_types::SolCall>::abi_decode_raw(
|
||||
data, validate,
|
||||
)
|
||||
.map(IScKeystoreCalls::userExists)
|
||||
}
|
||||
userExists
|
||||
},
|
||||
{
|
||||
fn addUser(
|
||||
data: &[u8],
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<IScKeystoreCalls> {
|
||||
<addUserCall as alloy_sol_types::SolCall>::abi_decode_raw(
|
||||
data,
|
||||
validate,
|
||||
}
|
||||
userExists
|
||||
},
|
||||
{
|
||||
fn addUser(
|
||||
data: &[u8],
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<IScKeystoreCalls> {
|
||||
<addUserCall as alloy_sol_types::SolCall>::abi_decode_raw(
|
||||
data, validate,
|
||||
)
|
||||
.map(IScKeystoreCalls::addUser)
|
||||
}
|
||||
addUser
|
||||
},
|
||||
{
|
||||
fn removeUser(
|
||||
data: &[u8],
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<IScKeystoreCalls> {
|
||||
<removeUserCall as alloy_sol_types::SolCall>::abi_decode_raw(
|
||||
data,
|
||||
validate,
|
||||
}
|
||||
addUser
|
||||
},
|
||||
{
|
||||
fn removeUser(
|
||||
data: &[u8],
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<IScKeystoreCalls> {
|
||||
<removeUserCall as alloy_sol_types::SolCall>::abi_decode_raw(
|
||||
data, validate,
|
||||
)
|
||||
.map(IScKeystoreCalls::removeUser)
|
||||
}
|
||||
removeUser
|
||||
},
|
||||
];
|
||||
}
|
||||
removeUser
|
||||
},
|
||||
];
|
||||
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,
|
||||
),
|
||||
);
|
||||
return Err(alloy_sol_types::Error::unknown_selector(
|
||||
<Self as alloy_sol_types::SolInterface>::NAME,
|
||||
selector,
|
||||
));
|
||||
};
|
||||
(unsafe { DECODE_SHIMS.get_unchecked(idx) })(data, validate)
|
||||
}
|
||||
@@ -561,16 +528,10 @@ function userExists(address user) external view returns (bool);
|
||||
<addUserCall as alloy_sol_types::SolCall>::abi_encode_raw(inner, out)
|
||||
}
|
||||
Self::removeUser(inner) => {
|
||||
<removeUserCall as alloy_sol_types::SolCall>::abi_encode_raw(
|
||||
inner,
|
||||
out,
|
||||
)
|
||||
<removeUserCall as alloy_sol_types::SolCall>::abi_encode_raw(inner, out)
|
||||
}
|
||||
Self::userExists(inner) => {
|
||||
<userExistsCall as alloy_sol_types::SolCall>::abi_encode_raw(
|
||||
inner,
|
||||
out,
|
||||
)
|
||||
<userExistsCall as alloy_sol_types::SolCall>::abi_encode_raw(inner, out)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -578,7 +539,7 @@ function userExists(address user) external view returns (bool);
|
||||
use alloy::contract as alloy_contract;
|
||||
/**Creates a new wrapper around an on-chain [`IScKeystore`](self) contract instance.
|
||||
|
||||
See the [wrapper's documentation](`IScKeystoreInstance`) for more details.*/
|
||||
See the [wrapper's documentation](`IScKeystoreInstance`) for more details.*/
|
||||
#[inline]
|
||||
pub const fn new<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
@@ -592,9 +553,9 @@ See the [wrapper's documentation](`IScKeystoreInstance`) for more details.*/
|
||||
}
|
||||
/**Deploys this contract using the given `provider` and constructor arguments, if any.
|
||||
|
||||
Returns a new instance of the contract, if the deployment was successful.
|
||||
Returns a new instance of the contract, if the deployment was successful.
|
||||
|
||||
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
|
||||
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
|
||||
#[inline]
|
||||
pub fn deploy<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
@@ -602,35 +563,36 @@ For more fine-grained control over the deployment process, use [`deploy_builder`
|
||||
N: alloy_contract::private::Network,
|
||||
>(
|
||||
provider: P,
|
||||
) -> impl ::core::future::Future<
|
||||
Output = alloy_contract::Result<IScKeystoreInstance<T, P, N>>,
|
||||
> {
|
||||
) -> impl ::core::future::Future<Output = alloy_contract::Result<IScKeystoreInstance<T, P, N>>>
|
||||
{
|
||||
IScKeystoreInstance::<T, P, N>::deploy(provider)
|
||||
}
|
||||
/**Creates a `RawCallBuilder` for deploying this contract using the given `provider`
|
||||
and constructor arguments, if any.
|
||||
and constructor arguments, if any.
|
||||
|
||||
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
|
||||
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
|
||||
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
#[inline]
|
||||
pub fn deploy_builder<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
>(provider: P) -> alloy_contract::RawCallBuilder<T, P, N> {
|
||||
>(
|
||||
provider: P,
|
||||
) -> alloy_contract::RawCallBuilder<T, P, N> {
|
||||
IScKeystoreInstance::<T, P, N>::deploy_builder(provider)
|
||||
}
|
||||
/**A [`IScKeystore`](self) instance.
|
||||
|
||||
Contains type-safe methods for interacting with an on-chain instance of the
|
||||
[`IScKeystore`](self) contract located at a given `address`, using a given
|
||||
provider `P`.
|
||||
Contains type-safe methods for interacting with an on-chain instance of the
|
||||
[`IScKeystore`](self) contract located at a given `address`, using a given
|
||||
provider `P`.
|
||||
|
||||
If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!)
|
||||
documentation on how to provide it), the `deploy` and `deploy_builder` methods can
|
||||
be used to deploy a new instance of the contract.
|
||||
If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!)
|
||||
documentation on how to provide it), the `deploy` and `deploy_builder` methods can
|
||||
be used to deploy a new instance of the contract.
|
||||
|
||||
See the [module-level documentation](self) for all the available methods.*/
|
||||
See the [module-level documentation](self) for all the available methods.*/
|
||||
#[derive(Clone)]
|
||||
pub struct IScKeystoreInstance<T, P, N = alloy_contract::private::Ethereum> {
|
||||
address: alloy_sol_types::private::Address,
|
||||
@@ -641,24 +603,24 @@ See the [module-level documentation](self) for all the available methods.*/
|
||||
impl<T, P, N> ::core::fmt::Debug for IScKeystoreInstance<T, P, N> {
|
||||
#[inline]
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
|
||||
f.debug_tuple("IScKeystoreInstance").field(&self.address).finish()
|
||||
f.debug_tuple("IScKeystoreInstance")
|
||||
.field(&self.address)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
/// Instantiation and getters/setters.
|
||||
#[automatically_derived]
|
||||
impl<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> IScKeystoreInstance<T, P, N> {
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> IScKeystoreInstance<T, P, N>
|
||||
{
|
||||
/**Creates a new wrapper around an on-chain [`IScKeystore`](self) contract instance.
|
||||
|
||||
See the [wrapper's documentation](`IScKeystoreInstance`) for more details.*/
|
||||
See the [wrapper's documentation](`IScKeystoreInstance`) for more details.*/
|
||||
#[inline]
|
||||
pub const fn new(
|
||||
address: alloy_sol_types::private::Address,
|
||||
provider: P,
|
||||
) -> Self {
|
||||
pub const fn new(address: alloy_sol_types::private::Address, provider: P) -> Self {
|
||||
Self {
|
||||
address,
|
||||
provider,
|
||||
@@ -667,22 +629,20 @@ See the [wrapper's documentation](`IScKeystoreInstance`) for more details.*/
|
||||
}
|
||||
/**Deploys this contract using the given `provider` and constructor arguments, if any.
|
||||
|
||||
Returns a new instance of the contract, if the deployment was successful.
|
||||
Returns a new instance of the contract, if the deployment was successful.
|
||||
|
||||
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
|
||||
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
|
||||
#[inline]
|
||||
pub async fn deploy(
|
||||
provider: P,
|
||||
) -> alloy_contract::Result<IScKeystoreInstance<T, P, N>> {
|
||||
pub async fn deploy(provider: P) -> alloy_contract::Result<IScKeystoreInstance<T, P, N>> {
|
||||
let call_builder = Self::deploy_builder(provider);
|
||||
let contract_address = call_builder.deploy().await?;
|
||||
Ok(Self::new(contract_address, call_builder.provider))
|
||||
}
|
||||
/**Creates a `RawCallBuilder` for deploying this contract using the given `provider`
|
||||
and constructor arguments, if any.
|
||||
and constructor arguments, if any.
|
||||
|
||||
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
|
||||
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
|
||||
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
#[inline]
|
||||
pub fn deploy_builder(provider: P) -> alloy_contract::RawCallBuilder<T, P, N> {
|
||||
alloy_contract::RawCallBuilder::new_raw_deploy(
|
||||
@@ -725,10 +685,11 @@ the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
/// Function calls.
|
||||
#[automatically_derived]
|
||||
impl<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> IScKeystoreInstance<T, P, N> {
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> IScKeystoreInstance<T, P, N>
|
||||
{
|
||||
/// Creates a new call builder using this contract instance's provider and address.
|
||||
///
|
||||
/// Note that the call can be any function call, not just those defined in this
|
||||
@@ -764,10 +725,11 @@ the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
/// Event filters.
|
||||
#[automatically_derived]
|
||||
impl<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> IScKeystoreInstance<T, P, N> {
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> IScKeystoreInstance<T, P, N>
|
||||
{
|
||||
/// Creates a new event filter using this contract instance's provider and address.
|
||||
///
|
||||
/// Note that the type can be any event, not just those defined in this contract.
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
pub mod context;
|
||||
pub mod deploy;
|
||||
pub mod deploymentconfig;
|
||||
pub mod foo;
|
||||
pub mod ierc165;
|
||||
pub mod ierc20;
|
||||
pub mod ierc721;
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -103,6 +103,7 @@ pub mod Ownable {
|
||||
///0x
|
||||
/// ```
|
||||
#[rustfmt::skip]
|
||||
#[allow(clippy::all)]
|
||||
pub static BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static(
|
||||
b"",
|
||||
);
|
||||
@@ -112,13 +113,14 @@ pub mod Ownable {
|
||||
///0x
|
||||
/// ```
|
||||
#[rustfmt::skip]
|
||||
#[allow(clippy::all)]
|
||||
pub static DEPLOYED_BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static(
|
||||
b"",
|
||||
);
|
||||
/**Custom error with signature `OwnableInvalidOwner(address)` and selector `0x1e4fbdf7`.
|
||||
```solidity
|
||||
error OwnableInvalidOwner(address owner);
|
||||
```*/
|
||||
```solidity
|
||||
error OwnableInvalidOwner(address owner);
|
||||
```*/
|
||||
#[allow(non_camel_case_types, non_snake_case)]
|
||||
#[derive(Clone)]
|
||||
pub struct OwnableInvalidOwner {
|
||||
@@ -133,9 +135,7 @@ error OwnableInvalidOwner(address owner);
|
||||
type UnderlyingRustTuple<'a> = (alloy::sol_types::private::Address,);
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -159,9 +159,7 @@ error OwnableInvalidOwner(address owner);
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolError for OwnableInvalidOwner {
|
||||
type Parameters<'a> = UnderlyingSolTuple<'a>;
|
||||
type Token<'a> = <Self::Parameters<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Token<'a> = <Self::Parameters<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
const SIGNATURE: &'static str = "OwnableInvalidOwner(address)";
|
||||
const SELECTOR: [u8; 4] = [30u8, 79u8, 189u8, 247u8];
|
||||
#[inline]
|
||||
@@ -181,9 +179,9 @@ error OwnableInvalidOwner(address owner);
|
||||
}
|
||||
};
|
||||
/**Custom error with signature `OwnableUnauthorizedAccount(address)` and selector `0x118cdaa7`.
|
||||
```solidity
|
||||
error OwnableUnauthorizedAccount(address account);
|
||||
```*/
|
||||
```solidity
|
||||
error OwnableUnauthorizedAccount(address account);
|
||||
```*/
|
||||
#[allow(non_camel_case_types, non_snake_case)]
|
||||
#[derive(Clone)]
|
||||
pub struct OwnableUnauthorizedAccount {
|
||||
@@ -198,9 +196,7 @@ error OwnableUnauthorizedAccount(address account);
|
||||
type UnderlyingRustTuple<'a> = (alloy::sol_types::private::Address,);
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -209,16 +205,14 @@ error OwnableUnauthorizedAccount(address account);
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<OwnableUnauthorizedAccount>
|
||||
for UnderlyingRustTuple<'_> {
|
||||
impl ::core::convert::From<OwnableUnauthorizedAccount> for UnderlyingRustTuple<'_> {
|
||||
fn from(value: OwnableUnauthorizedAccount) -> Self {
|
||||
(value.account,)
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>>
|
||||
for OwnableUnauthorizedAccount {
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>> for OwnableUnauthorizedAccount {
|
||||
fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
|
||||
Self { account: tuple.0 }
|
||||
}
|
||||
@@ -226,9 +220,7 @@ error OwnableUnauthorizedAccount(address account);
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolError for OwnableUnauthorizedAccount {
|
||||
type Parameters<'a> = UnderlyingSolTuple<'a>;
|
||||
type Token<'a> = <Self::Parameters<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Token<'a> = <Self::Parameters<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
const SIGNATURE: &'static str = "OwnableUnauthorizedAccount(address)";
|
||||
const SELECTOR: [u8; 4] = [17u8, 140u8, 218u8, 167u8];
|
||||
#[inline]
|
||||
@@ -248,9 +240,9 @@ error OwnableUnauthorizedAccount(address account);
|
||||
}
|
||||
};
|
||||
/**Event with signature `OwnershipTransferred(address,address)` and selector `0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0`.
|
||||
```solidity
|
||||
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
||||
```*/
|
||||
```solidity
|
||||
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
||||
```*/
|
||||
#[allow(non_camel_case_types, non_snake_case, clippy::style)]
|
||||
#[derive(Clone)]
|
||||
pub struct OwnershipTransferred {
|
||||
@@ -265,49 +257,19 @@ event OwnershipTransferred(address indexed previousOwner, address indexed newOwn
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolEvent for OwnershipTransferred {
|
||||
type DataTuple<'a> = ();
|
||||
type DataToken<'a> = <Self::DataTuple<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
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::Address,
|
||||
alloy::sol_types::sol_data::Address,
|
||||
);
|
||||
const SIGNATURE: &'static str = "OwnershipTransferred(address,address)";
|
||||
const SIGNATURE_HASH: alloy_sol_types::private::B256 = alloy_sol_types::private::B256::new([
|
||||
139u8,
|
||||
224u8,
|
||||
7u8,
|
||||
156u8,
|
||||
83u8,
|
||||
22u8,
|
||||
89u8,
|
||||
20u8,
|
||||
19u8,
|
||||
68u8,
|
||||
205u8,
|
||||
31u8,
|
||||
208u8,
|
||||
164u8,
|
||||
242u8,
|
||||
132u8,
|
||||
25u8,
|
||||
73u8,
|
||||
127u8,
|
||||
151u8,
|
||||
34u8,
|
||||
163u8,
|
||||
218u8,
|
||||
175u8,
|
||||
227u8,
|
||||
180u8,
|
||||
24u8,
|
||||
111u8,
|
||||
107u8,
|
||||
100u8,
|
||||
87u8,
|
||||
224u8,
|
||||
]);
|
||||
const SIGNATURE_HASH: alloy_sol_types::private::B256 =
|
||||
alloy_sol_types::private::B256::new([
|
||||
139u8, 224u8, 7u8, 156u8, 83u8, 22u8, 89u8, 20u8, 19u8, 68u8, 205u8, 31u8,
|
||||
208u8, 164u8, 242u8, 132u8, 25u8, 73u8, 127u8, 151u8, 34u8, 163u8, 218u8,
|
||||
175u8, 227u8, 180u8, 24u8, 111u8, 107u8, 100u8, 87u8, 224u8,
|
||||
]);
|
||||
const ANONYMOUS: bool = false;
|
||||
#[allow(unused_variables)]
|
||||
#[inline]
|
||||
@@ -340,9 +302,7 @@ event OwnershipTransferred(address indexed previousOwner, address indexed newOwn
|
||||
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[0usize] = alloy_sol_types::abi::token::WordToken(Self::SIGNATURE_HASH);
|
||||
out[1usize] = <alloy::sol_types::sol_data::Address as alloy_sol_types::EventTopic>::encode_topic(
|
||||
&self.previousOwner,
|
||||
);
|
||||
@@ -352,22 +312,27 @@ event OwnershipTransferred(address indexed previousOwner, address indexed newOwn
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::private::IntoLogData for OwnershipTransferred {
|
||||
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<&OwnershipTransferred> for alloy_sol_types::private::LogData {
|
||||
#[inline]
|
||||
fn from(this: &OwnershipTransferred) -> alloy_sol_types::private::LogData {
|
||||
let topics = alloy_sol_types::SolEvent::encode_topics(this)
|
||||
.into_iter()
|
||||
.map(|t| t.into())
|
||||
.collect();
|
||||
let data = alloy_sol_types::SolEvent::encode_data(this).into();
|
||||
alloy_sol_types::private::LogData::new_unchecked(topics, data)
|
||||
alloy_sol_types::SolEvent::encode_log_data(this)
|
||||
}
|
||||
}
|
||||
};
|
||||
/**Function with signature `owner()` and selector `0x8da5cb5b`.
|
||||
```solidity
|
||||
function owner() external view returns (address);
|
||||
```*/
|
||||
```solidity
|
||||
function owner() external view returns (address);
|
||||
```*/
|
||||
#[allow(non_camel_case_types, non_snake_case)]
|
||||
#[derive(Clone)]
|
||||
pub struct ownerCall {}
|
||||
@@ -387,9 +352,7 @@ function owner() external view returns (address);
|
||||
type UnderlyingRustTuple<'a> = ();
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -418,9 +381,7 @@ function owner() external view returns (address);
|
||||
type UnderlyingRustTuple<'a> = (alloy::sol_types::private::Address,);
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -445,14 +406,10 @@ function owner() external view returns (address);
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolCall for ownerCall {
|
||||
type Parameters<'a> = ();
|
||||
type Token<'a> = <Self::Parameters<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Token<'a> = <Self::Parameters<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Return = ownerReturn;
|
||||
type ReturnTuple<'a> = (alloy::sol_types::sol_data::Address,);
|
||||
type ReturnToken<'a> = <Self::ReturnTuple<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type ReturnToken<'a> = <Self::ReturnTuple<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
const SIGNATURE: &'static str = "owner()";
|
||||
const SELECTOR: [u8; 4] = [141u8, 165u8, 203u8, 91u8];
|
||||
#[inline]
|
||||
@@ -470,17 +427,17 @@ function owner() external view returns (address);
|
||||
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)
|
||||
<Self::ReturnTuple<'_> as alloy_sol_types::SolType>::abi_decode_sequence(
|
||||
data, validate,
|
||||
)
|
||||
.map(Into::into)
|
||||
}
|
||||
}
|
||||
};
|
||||
/**Function with signature `renounceOwnership()` and selector `0x715018a6`.
|
||||
```solidity
|
||||
function renounceOwnership() external;
|
||||
```*/
|
||||
```solidity
|
||||
function renounceOwnership() external;
|
||||
```*/
|
||||
#[allow(non_camel_case_types, non_snake_case)]
|
||||
#[derive(Clone)]
|
||||
pub struct renounceOwnershipCall {}
|
||||
@@ -498,9 +455,7 @@ function renounceOwnership() external;
|
||||
type UnderlyingRustTuple<'a> = ();
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -509,16 +464,14 @@ function renounceOwnership() external;
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<renounceOwnershipCall>
|
||||
for UnderlyingRustTuple<'_> {
|
||||
impl ::core::convert::From<renounceOwnershipCall> for UnderlyingRustTuple<'_> {
|
||||
fn from(value: renounceOwnershipCall) -> Self {
|
||||
()
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>>
|
||||
for renounceOwnershipCall {
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>> for renounceOwnershipCall {
|
||||
fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
|
||||
Self {}
|
||||
}
|
||||
@@ -531,9 +484,7 @@ function renounceOwnership() external;
|
||||
type UnderlyingRustTuple<'a> = ();
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -542,16 +493,14 @@ function renounceOwnership() external;
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<renounceOwnershipReturn>
|
||||
for UnderlyingRustTuple<'_> {
|
||||
impl ::core::convert::From<renounceOwnershipReturn> for UnderlyingRustTuple<'_> {
|
||||
fn from(value: renounceOwnershipReturn) -> Self {
|
||||
()
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>>
|
||||
for renounceOwnershipReturn {
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>> for renounceOwnershipReturn {
|
||||
fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
|
||||
Self {}
|
||||
}
|
||||
@@ -560,14 +509,10 @@ function renounceOwnership() external;
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolCall for renounceOwnershipCall {
|
||||
type Parameters<'a> = ();
|
||||
type Token<'a> = <Self::Parameters<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Token<'a> = <Self::Parameters<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Return = renounceOwnershipReturn;
|
||||
type ReturnTuple<'a> = ();
|
||||
type ReturnToken<'a> = <Self::ReturnTuple<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type ReturnToken<'a> = <Self::ReturnTuple<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
const SIGNATURE: &'static str = "renounceOwnership()";
|
||||
const SELECTOR: [u8; 4] = [113u8, 80u8, 24u8, 166u8];
|
||||
#[inline]
|
||||
@@ -585,17 +530,17 @@ function renounceOwnership() external;
|
||||
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)
|
||||
<Self::ReturnTuple<'_> as alloy_sol_types::SolType>::abi_decode_sequence(
|
||||
data, validate,
|
||||
)
|
||||
.map(Into::into)
|
||||
}
|
||||
}
|
||||
};
|
||||
/**Function with signature `transferOwnership(address)` and selector `0xf2fde38b`.
|
||||
```solidity
|
||||
function transferOwnership(address newOwner) external;
|
||||
```*/
|
||||
```solidity
|
||||
function transferOwnership(address newOwner) external;
|
||||
```*/
|
||||
#[allow(non_camel_case_types, non_snake_case)]
|
||||
#[derive(Clone)]
|
||||
pub struct transferOwnershipCall {
|
||||
@@ -615,9 +560,7 @@ function transferOwnership(address newOwner) external;
|
||||
type UnderlyingRustTuple<'a> = (alloy::sol_types::private::Address,);
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -626,16 +569,14 @@ function transferOwnership(address newOwner) external;
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<transferOwnershipCall>
|
||||
for UnderlyingRustTuple<'_> {
|
||||
impl ::core::convert::From<transferOwnershipCall> for UnderlyingRustTuple<'_> {
|
||||
fn from(value: transferOwnershipCall) -> Self {
|
||||
(value.newOwner,)
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>>
|
||||
for transferOwnershipCall {
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>> for transferOwnershipCall {
|
||||
fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
|
||||
Self { newOwner: tuple.0 }
|
||||
}
|
||||
@@ -648,9 +589,7 @@ function transferOwnership(address newOwner) external;
|
||||
type UnderlyingRustTuple<'a> = ();
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code, unreachable_patterns)]
|
||||
fn _type_assertion(
|
||||
_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>,
|
||||
) {
|
||||
fn _type_assertion(_t: alloy_sol_types::private::AssertTypeEq<UnderlyingRustTuple>) {
|
||||
match _t {
|
||||
alloy_sol_types::private::AssertTypeEq::<
|
||||
<UnderlyingSolTuple as alloy_sol_types::SolType>::RustType,
|
||||
@@ -659,16 +598,14 @@ function transferOwnership(address newOwner) external;
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<transferOwnershipReturn>
|
||||
for UnderlyingRustTuple<'_> {
|
||||
impl ::core::convert::From<transferOwnershipReturn> for UnderlyingRustTuple<'_> {
|
||||
fn from(value: transferOwnershipReturn) -> Self {
|
||||
()
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
#[doc(hidden)]
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>>
|
||||
for transferOwnershipReturn {
|
||||
impl ::core::convert::From<UnderlyingRustTuple<'_>> for transferOwnershipReturn {
|
||||
fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
|
||||
Self {}
|
||||
}
|
||||
@@ -677,14 +614,10 @@ function transferOwnership(address newOwner) external;
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolCall for transferOwnershipCall {
|
||||
type Parameters<'a> = (alloy::sol_types::sol_data::Address,);
|
||||
type Token<'a> = <Self::Parameters<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Token<'a> = <Self::Parameters<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type Return = transferOwnershipReturn;
|
||||
type ReturnTuple<'a> = ();
|
||||
type ReturnToken<'a> = <Self::ReturnTuple<
|
||||
'a,
|
||||
> as alloy_sol_types::SolType>::Token<'a>;
|
||||
type ReturnToken<'a> = <Self::ReturnTuple<'a> as alloy_sol_types::SolType>::Token<'a>;
|
||||
const SIGNATURE: &'static str = "transferOwnership(address)";
|
||||
const SELECTOR: [u8; 4] = [242u8, 253u8, 227u8, 139u8];
|
||||
#[inline]
|
||||
@@ -706,10 +639,10 @@ function transferOwnership(address newOwner) external;
|
||||
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)
|
||||
<Self::ReturnTuple<'_> as alloy_sol_types::SolType>::abi_decode_sequence(
|
||||
data, validate,
|
||||
)
|
||||
.map(Into::into)
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -765,32 +698,22 @@ function transferOwnership(address newOwner) external;
|
||||
data: &[u8],
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<Self> {
|
||||
static DECODE_SHIMS: &[fn(
|
||||
&[u8],
|
||||
bool,
|
||||
) -> alloy_sol_types::Result<OwnableCalls>] = &[
|
||||
static DECODE_SHIMS: &[fn(&[u8], bool) -> alloy_sol_types::Result<OwnableCalls>] = &[
|
||||
{
|
||||
fn renounceOwnership(
|
||||
data: &[u8],
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<OwnableCalls> {
|
||||
<renounceOwnershipCall as alloy_sol_types::SolCall>::abi_decode_raw(
|
||||
data,
|
||||
validate,
|
||||
)
|
||||
.map(OwnableCalls::renounceOwnership)
|
||||
data, validate,
|
||||
)
|
||||
.map(OwnableCalls::renounceOwnership)
|
||||
}
|
||||
renounceOwnership
|
||||
},
|
||||
{
|
||||
fn owner(
|
||||
data: &[u8],
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<OwnableCalls> {
|
||||
<ownerCall as alloy_sol_types::SolCall>::abi_decode_raw(
|
||||
data,
|
||||
validate,
|
||||
)
|
||||
fn owner(data: &[u8], validate: bool) -> alloy_sol_types::Result<OwnableCalls> {
|
||||
<ownerCall as alloy_sol_types::SolCall>::abi_decode_raw(data, validate)
|
||||
.map(OwnableCalls::owner)
|
||||
}
|
||||
owner
|
||||
@@ -801,21 +724,18 @@ function transferOwnership(address newOwner) external;
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<OwnableCalls> {
|
||||
<transferOwnershipCall as alloy_sol_types::SolCall>::abi_decode_raw(
|
||||
data,
|
||||
validate,
|
||||
)
|
||||
.map(OwnableCalls::transferOwnership)
|
||||
data, validate,
|
||||
)
|
||||
.map(OwnableCalls::transferOwnership)
|
||||
}
|
||||
transferOwnership
|
||||
},
|
||||
];
|
||||
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,
|
||||
),
|
||||
);
|
||||
return Err(alloy_sol_types::Error::unknown_selector(
|
||||
<Self as alloy_sol_types::SolInterface>::NAME,
|
||||
selector,
|
||||
));
|
||||
};
|
||||
(unsafe { DECODE_SHIMS.get_unchecked(idx) })(data, validate)
|
||||
}
|
||||
@@ -826,14 +746,10 @@ function transferOwnership(address newOwner) external;
|
||||
<ownerCall as alloy_sol_types::SolCall>::abi_encoded_size(inner)
|
||||
}
|
||||
Self::renounceOwnership(inner) => {
|
||||
<renounceOwnershipCall as alloy_sol_types::SolCall>::abi_encoded_size(
|
||||
inner,
|
||||
)
|
||||
<renounceOwnershipCall as alloy_sol_types::SolCall>::abi_encoded_size(inner)
|
||||
}
|
||||
Self::transferOwnership(inner) => {
|
||||
<transferOwnershipCall as alloy_sol_types::SolCall>::abi_encoded_size(
|
||||
inner,
|
||||
)
|
||||
<transferOwnershipCall as alloy_sol_types::SolCall>::abi_encoded_size(inner)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -844,16 +760,10 @@ function transferOwnership(address newOwner) external;
|
||||
<ownerCall as alloy_sol_types::SolCall>::abi_encode_raw(inner, out)
|
||||
}
|
||||
Self::renounceOwnership(inner) => {
|
||||
<renounceOwnershipCall as alloy_sol_types::SolCall>::abi_encode_raw(
|
||||
inner,
|
||||
out,
|
||||
)
|
||||
<renounceOwnershipCall as alloy_sol_types::SolCall>::abi_encode_raw(inner, out)
|
||||
}
|
||||
Self::transferOwnership(inner) => {
|
||||
<transferOwnershipCall as alloy_sol_types::SolCall>::abi_encode_raw(
|
||||
inner,
|
||||
out,
|
||||
)
|
||||
<transferOwnershipCall as alloy_sol_types::SolCall>::abi_encode_raw(inner, out)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -871,10 +781,8 @@ function transferOwnership(address newOwner) external;
|
||||
/// No guarantees are made about the order of the selectors.
|
||||
///
|
||||
/// Prefer using `SolInterface` methods instead.
|
||||
pub const SELECTORS: &'static [[u8; 4usize]] = &[
|
||||
[17u8, 140u8, 218u8, 167u8],
|
||||
[30u8, 79u8, 189u8, 247u8],
|
||||
];
|
||||
pub const SELECTORS: &'static [[u8; 4usize]] =
|
||||
&[[17u8, 140u8, 218u8, 167u8], [30u8, 79u8, 189u8, 247u8]];
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolInterface for OwnableErrors {
|
||||
@@ -907,20 +815,16 @@ function transferOwnership(address newOwner) external;
|
||||
data: &[u8],
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<Self> {
|
||||
static DECODE_SHIMS: &[fn(
|
||||
&[u8],
|
||||
bool,
|
||||
) -> alloy_sol_types::Result<OwnableErrors>] = &[
|
||||
static DECODE_SHIMS: &[fn(&[u8], bool) -> alloy_sol_types::Result<OwnableErrors>] = &[
|
||||
{
|
||||
fn OwnableUnauthorizedAccount(
|
||||
data: &[u8],
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<OwnableErrors> {
|
||||
<OwnableUnauthorizedAccount as alloy_sol_types::SolError>::abi_decode_raw(
|
||||
data,
|
||||
validate,
|
||||
)
|
||||
.map(OwnableErrors::OwnableUnauthorizedAccount)
|
||||
data, validate,
|
||||
)
|
||||
.map(OwnableErrors::OwnableUnauthorizedAccount)
|
||||
}
|
||||
OwnableUnauthorizedAccount
|
||||
},
|
||||
@@ -930,21 +834,18 @@ function transferOwnership(address newOwner) external;
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<OwnableErrors> {
|
||||
<OwnableInvalidOwner as alloy_sol_types::SolError>::abi_decode_raw(
|
||||
data,
|
||||
validate,
|
||||
)
|
||||
.map(OwnableErrors::OwnableInvalidOwner)
|
||||
data, validate,
|
||||
)
|
||||
.map(OwnableErrors::OwnableInvalidOwner)
|
||||
}
|
||||
OwnableInvalidOwner
|
||||
},
|
||||
];
|
||||
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,
|
||||
),
|
||||
);
|
||||
return Err(alloy_sol_types::Error::unknown_selector(
|
||||
<Self as alloy_sol_types::SolInterface>::NAME,
|
||||
selector,
|
||||
));
|
||||
};
|
||||
(unsafe { DECODE_SHIMS.get_unchecked(idx) })(data, validate)
|
||||
}
|
||||
@@ -952,9 +853,7 @@ function transferOwnership(address newOwner) external;
|
||||
fn abi_encoded_size(&self) -> usize {
|
||||
match self {
|
||||
Self::OwnableInvalidOwner(inner) => {
|
||||
<OwnableInvalidOwner as alloy_sol_types::SolError>::abi_encoded_size(
|
||||
inner,
|
||||
)
|
||||
<OwnableInvalidOwner as alloy_sol_types::SolError>::abi_encoded_size(inner)
|
||||
}
|
||||
Self::OwnableUnauthorizedAccount(inner) => {
|
||||
<OwnableUnauthorizedAccount as alloy_sol_types::SolError>::abi_encoded_size(
|
||||
@@ -967,15 +866,11 @@ function transferOwnership(address newOwner) external;
|
||||
fn abi_encode_raw(&self, out: &mut alloy_sol_types::private::Vec<u8>) {
|
||||
match self {
|
||||
Self::OwnableInvalidOwner(inner) => {
|
||||
<OwnableInvalidOwner as alloy_sol_types::SolError>::abi_encode_raw(
|
||||
inner,
|
||||
out,
|
||||
)
|
||||
<OwnableInvalidOwner as alloy_sol_types::SolError>::abi_encode_raw(inner, out)
|
||||
}
|
||||
Self::OwnableUnauthorizedAccount(inner) => {
|
||||
<OwnableUnauthorizedAccount as alloy_sol_types::SolError>::abi_encode_raw(
|
||||
inner,
|
||||
out,
|
||||
inner, out,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -993,42 +888,11 @@ function transferOwnership(address newOwner) external;
|
||||
/// No guarantees are made about the order of the selectors.
|
||||
///
|
||||
/// Prefer using `SolInterface` methods instead.
|
||||
pub const SELECTORS: &'static [[u8; 32usize]] = &[
|
||||
[
|
||||
139u8,
|
||||
224u8,
|
||||
7u8,
|
||||
156u8,
|
||||
83u8,
|
||||
22u8,
|
||||
89u8,
|
||||
20u8,
|
||||
19u8,
|
||||
68u8,
|
||||
205u8,
|
||||
31u8,
|
||||
208u8,
|
||||
164u8,
|
||||
242u8,
|
||||
132u8,
|
||||
25u8,
|
||||
73u8,
|
||||
127u8,
|
||||
151u8,
|
||||
34u8,
|
||||
163u8,
|
||||
218u8,
|
||||
175u8,
|
||||
227u8,
|
||||
180u8,
|
||||
24u8,
|
||||
111u8,
|
||||
107u8,
|
||||
100u8,
|
||||
87u8,
|
||||
224u8,
|
||||
],
|
||||
];
|
||||
pub const SELECTORS: &'static [[u8; 32usize]] = &[[
|
||||
139u8, 224u8, 7u8, 156u8, 83u8, 22u8, 89u8, 20u8, 19u8, 68u8, 205u8, 31u8, 208u8,
|
||||
164u8, 242u8, 132u8, 25u8, 73u8, 127u8, 151u8, 34u8, 163u8, 218u8, 175u8, 227u8, 180u8,
|
||||
24u8, 111u8, 107u8, 100u8, 87u8, 224u8,
|
||||
]];
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl alloy_sol_types::SolEventInterface for OwnableEvents {
|
||||
@@ -1040,26 +904,37 @@ function transferOwnership(address newOwner) external;
|
||||
validate: bool,
|
||||
) -> alloy_sol_types::Result<Self> {
|
||||
match topics.first().copied() {
|
||||
Some(
|
||||
<OwnershipTransferred as alloy_sol_types::SolEvent>::SIGNATURE_HASH,
|
||||
) => {
|
||||
Some(<OwnershipTransferred as alloy_sol_types::SolEvent>::SIGNATURE_HASH) => {
|
||||
<OwnershipTransferred as alloy_sol_types::SolEvent>::decode_raw_log(
|
||||
topics,
|
||||
data,
|
||||
validate,
|
||||
)
|
||||
.map(Self::OwnershipTransferred)
|
||||
topics, data, validate,
|
||||
)
|
||||
.map(Self::OwnershipTransferred)
|
||||
}
|
||||
_ => {
|
||||
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(),
|
||||
),
|
||||
_ => 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 OwnableEvents {
|
||||
fn to_log_data(&self) -> alloy_sol_types::private::LogData {
|
||||
match self {
|
||||
Self::OwnershipTransferred(inner) => {
|
||||
alloy_sol_types::private::IntoLogData::to_log_data(inner)
|
||||
}
|
||||
}
|
||||
}
|
||||
fn into_log_data(self) -> alloy_sol_types::private::LogData {
|
||||
match self {
|
||||
Self::OwnershipTransferred(inner) => {
|
||||
alloy_sol_types::private::IntoLogData::into_log_data(inner)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1067,7 +942,7 @@ function transferOwnership(address newOwner) external;
|
||||
use alloy::contract as alloy_contract;
|
||||
/**Creates a new wrapper around an on-chain [`Ownable`](self) contract instance.
|
||||
|
||||
See the [wrapper's documentation](`OwnableInstance`) for more details.*/
|
||||
See the [wrapper's documentation](`OwnableInstance`) for more details.*/
|
||||
#[inline]
|
||||
pub const fn new<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
@@ -1081,9 +956,9 @@ See the [wrapper's documentation](`OwnableInstance`) for more details.*/
|
||||
}
|
||||
/**Deploys this contract using the given `provider` and constructor arguments, if any.
|
||||
|
||||
Returns a new instance of the contract, if the deployment was successful.
|
||||
Returns a new instance of the contract, if the deployment was successful.
|
||||
|
||||
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
|
||||
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
|
||||
#[inline]
|
||||
pub fn deploy<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
@@ -1091,35 +966,36 @@ For more fine-grained control over the deployment process, use [`deploy_builder`
|
||||
N: alloy_contract::private::Network,
|
||||
>(
|
||||
provider: P,
|
||||
) -> impl ::core::future::Future<
|
||||
Output = alloy_contract::Result<OwnableInstance<T, P, N>>,
|
||||
> {
|
||||
) -> impl ::core::future::Future<Output = alloy_contract::Result<OwnableInstance<T, P, N>>>
|
||||
{
|
||||
OwnableInstance::<T, P, N>::deploy(provider)
|
||||
}
|
||||
/**Creates a `RawCallBuilder` for deploying this contract using the given `provider`
|
||||
and constructor arguments, if any.
|
||||
and constructor arguments, if any.
|
||||
|
||||
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
|
||||
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
|
||||
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
#[inline]
|
||||
pub fn deploy_builder<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
>(provider: P) -> alloy_contract::RawCallBuilder<T, P, N> {
|
||||
>(
|
||||
provider: P,
|
||||
) -> alloy_contract::RawCallBuilder<T, P, N> {
|
||||
OwnableInstance::<T, P, N>::deploy_builder(provider)
|
||||
}
|
||||
/**A [`Ownable`](self) instance.
|
||||
|
||||
Contains type-safe methods for interacting with an on-chain instance of the
|
||||
[`Ownable`](self) contract located at a given `address`, using a given
|
||||
provider `P`.
|
||||
Contains type-safe methods for interacting with an on-chain instance of the
|
||||
[`Ownable`](self) contract located at a given `address`, using a given
|
||||
provider `P`.
|
||||
|
||||
If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!)
|
||||
documentation on how to provide it), the `deploy` and `deploy_builder` methods can
|
||||
be used to deploy a new instance of the contract.
|
||||
If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!)
|
||||
documentation on how to provide it), the `deploy` and `deploy_builder` methods can
|
||||
be used to deploy a new instance of the contract.
|
||||
|
||||
See the [module-level documentation](self) for all the available methods.*/
|
||||
See the [module-level documentation](self) for all the available methods.*/
|
||||
#[derive(Clone)]
|
||||
pub struct OwnableInstance<T, P, N = alloy_contract::private::Ethereum> {
|
||||
address: alloy_sol_types::private::Address,
|
||||
@@ -1130,24 +1006,24 @@ See the [module-level documentation](self) for all the available methods.*/
|
||||
impl<T, P, N> ::core::fmt::Debug for OwnableInstance<T, P, N> {
|
||||
#[inline]
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
|
||||
f.debug_tuple("OwnableInstance").field(&self.address).finish()
|
||||
f.debug_tuple("OwnableInstance")
|
||||
.field(&self.address)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
/// Instantiation and getters/setters.
|
||||
#[automatically_derived]
|
||||
impl<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> OwnableInstance<T, P, N> {
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> OwnableInstance<T, P, N>
|
||||
{
|
||||
/**Creates a new wrapper around an on-chain [`Ownable`](self) contract instance.
|
||||
|
||||
See the [wrapper's documentation](`OwnableInstance`) for more details.*/
|
||||
See the [wrapper's documentation](`OwnableInstance`) for more details.*/
|
||||
#[inline]
|
||||
pub const fn new(
|
||||
address: alloy_sol_types::private::Address,
|
||||
provider: P,
|
||||
) -> Self {
|
||||
pub const fn new(address: alloy_sol_types::private::Address, provider: P) -> Self {
|
||||
Self {
|
||||
address,
|
||||
provider,
|
||||
@@ -1156,22 +1032,20 @@ See the [wrapper's documentation](`OwnableInstance`) for more details.*/
|
||||
}
|
||||
/**Deploys this contract using the given `provider` and constructor arguments, if any.
|
||||
|
||||
Returns a new instance of the contract, if the deployment was successful.
|
||||
Returns a new instance of the contract, if the deployment was successful.
|
||||
|
||||
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
|
||||
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
|
||||
#[inline]
|
||||
pub async fn deploy(
|
||||
provider: P,
|
||||
) -> alloy_contract::Result<OwnableInstance<T, P, N>> {
|
||||
pub async fn deploy(provider: P) -> alloy_contract::Result<OwnableInstance<T, P, N>> {
|
||||
let call_builder = Self::deploy_builder(provider);
|
||||
let contract_address = call_builder.deploy().await?;
|
||||
Ok(Self::new(contract_address, call_builder.provider))
|
||||
}
|
||||
/**Creates a `RawCallBuilder` for deploying this contract using the given `provider`
|
||||
and constructor arguments, if any.
|
||||
and constructor arguments, if any.
|
||||
|
||||
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
|
||||
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
|
||||
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
#[inline]
|
||||
pub fn deploy_builder(provider: P) -> alloy_contract::RawCallBuilder<T, P, N> {
|
||||
alloy_contract::RawCallBuilder::new_raw_deploy(
|
||||
@@ -1214,10 +1088,11 @@ the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
/// Function calls.
|
||||
#[automatically_derived]
|
||||
impl<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> OwnableInstance<T, P, N> {
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> OwnableInstance<T, P, N>
|
||||
{
|
||||
/// Creates a new call builder using this contract instance's provider and address.
|
||||
///
|
||||
/// Note that the call can be any function call, not just those defined in this
|
||||
@@ -1249,10 +1124,11 @@ the bytecode concatenated with the constructor's ABI-encoded arguments.*/
|
||||
/// Event filters.
|
||||
#[automatically_derived]
|
||||
impl<
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> OwnableInstance<T, P, N> {
|
||||
T: alloy_contract::private::Transport + ::core::clone::Clone,
|
||||
P: alloy_contract::private::Provider<T, N>,
|
||||
N: alloy_contract::private::Network,
|
||||
> OwnableInstance<T, P, N>
|
||||
{
|
||||
/// Creates a new event filter using this contract instance's provider and address.
|
||||
///
|
||||
/// Note that the type can be any event, not just those defined in this contract.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -10,7 +10,20 @@ edition = "2021"
|
||||
# waku-bindings = "=0.6.0"
|
||||
bus = "=2.4.1"
|
||||
fred = { version = "=9.0.3", features = ["subscriber-client"] }
|
||||
tokio = "=1.38.0"
|
||||
tokio = { version = "=1.38.0", features = ["full"] }
|
||||
tokio-tungstenite = "0.15"
|
||||
tungstenite = "0.14"
|
||||
futures-util = "0.3"
|
||||
tokio-stream = "0.1"
|
||||
alloy = { git = "https://github.com/alloy-rs/alloy", features = [
|
||||
"providers",
|
||||
"node-bindings",
|
||||
"network",
|
||||
"transports",
|
||||
"k256",
|
||||
"rlp",
|
||||
] }
|
||||
tokio-util = "=0.7.11"
|
||||
|
||||
openmls = { version = "=0.5.0", features = ["test-utils"] }
|
||||
rand = { version = "^0.8" }
|
||||
@@ -23,3 +36,4 @@ serde_json = "=1.0"
|
||||
serde = "=1.0.204"
|
||||
|
||||
sc_key_store = { path = "../sc_key_store" }
|
||||
url = "2.5.2"
|
||||
|
||||
206
ds/src/chat_client.rs
Normal file
206
ds/src/chat_client.rs
Normal file
@@ -0,0 +1,206 @@
|
||||
use alloy::primitives::Address;
|
||||
use alloy::signers::Signature;
|
||||
use futures_util::{SinkExt, StreamExt};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::{mpsc, Mutex};
|
||||
use tokio_tungstenite::tungstenite::protocol::Message;
|
||||
|
||||
use crate::chat_server::ServerMessage;
|
||||
use crate::DeliveryServiceError;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
||||
pub enum ChatMessages {
|
||||
Request(RequestMLSPayload),
|
||||
Response(ResponseMLSPayload),
|
||||
Welcome(String),
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
||||
pub enum ReqMessageType {
|
||||
InviteToGroup,
|
||||
RemoveFromGroup,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
||||
pub struct RequestMLSPayload {
|
||||
sc_address: String,
|
||||
group_name: String,
|
||||
pub msg_type: ReqMessageType,
|
||||
}
|
||||
|
||||
impl RequestMLSPayload {
|
||||
pub fn new(sc_address: String, group_name: String, msg_type: ReqMessageType) -> Self {
|
||||
RequestMLSPayload {
|
||||
sc_address,
|
||||
group_name,
|
||||
msg_type,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn msg_to_sign(&self) -> String {
|
||||
self.sc_address.to_owned() + &self.group_name
|
||||
}
|
||||
|
||||
pub fn group_name(&self) -> String {
|
||||
self.group_name.clone()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
||||
pub struct ResponseMLSPayload {
|
||||
signature: String,
|
||||
user_address: String,
|
||||
pub group_name: String,
|
||||
key_package: Vec<u8>,
|
||||
}
|
||||
|
||||
impl ResponseMLSPayload {
|
||||
pub fn new(
|
||||
signature: String,
|
||||
user_address: String,
|
||||
group_name: String,
|
||||
key_package: Vec<u8>,
|
||||
) -> Self {
|
||||
Self {
|
||||
signature,
|
||||
user_address,
|
||||
group_name,
|
||||
key_package,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn validate(
|
||||
&self,
|
||||
sc_address: String,
|
||||
group_name: String,
|
||||
) -> Result<(String, Vec<u8>), DeliveryServiceError> {
|
||||
let recover_sig: Signature = serde_json::from_str(&self.signature)?;
|
||||
let addr = Address::from_str(&self.user_address)?;
|
||||
// Recover the signer from the message.
|
||||
let recovered =
|
||||
recover_sig.recover_address_from_msg(sc_address.to_owned() + &group_name)?;
|
||||
|
||||
if recovered.ne(&addr) {
|
||||
return Err(DeliveryServiceError::ValidationError(recovered.to_string()));
|
||||
}
|
||||
Ok((self.user_address.clone(), self.key_package.clone()))
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ChatClient {
|
||||
sender: mpsc::UnboundedSender<Message>,
|
||||
}
|
||||
|
||||
impl ChatClient {
|
||||
pub async fn connect(
|
||||
server_addr: &str,
|
||||
username: String,
|
||||
) -> Result<(Self, mpsc::UnboundedReceiver<Message>), DeliveryServiceError> {
|
||||
let (ws_stream, _) = tokio_tungstenite::connect_async(server_addr).await?;
|
||||
let (mut write, read) = ws_stream.split();
|
||||
let (sender, receiver) = mpsc::unbounded_channel();
|
||||
let (msg_sender, msg_receiver) = mpsc::unbounded_channel();
|
||||
|
||||
let receiver = Arc::new(Mutex::new(receiver));
|
||||
|
||||
// Spawn a task to handle outgoing messages
|
||||
tokio::spawn(async move {
|
||||
while let Some(message) = receiver.lock().await.recv().await {
|
||||
if let Err(err) = write.send(message).await {
|
||||
return Err(DeliveryServiceError::SenderError(err.to_string()));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
});
|
||||
|
||||
// Spawn a task to handle incoming messages
|
||||
tokio::spawn(async move {
|
||||
let mut read = read;
|
||||
while let Some(Ok(message)) = read.next().await {
|
||||
if let Err(err) = msg_sender.send(message) {
|
||||
return Err(DeliveryServiceError::SenderError(err.to_string()));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
});
|
||||
|
||||
// Send a SystemJoin message when registering
|
||||
let join_msg = ServerMessage::SystemJoin {
|
||||
username: username.to_string(),
|
||||
};
|
||||
let join_json = serde_json::to_string(&join_msg).unwrap();
|
||||
sender
|
||||
.send(Message::Text(join_json))
|
||||
.map_err(|err| DeliveryServiceError::SenderError(err.to_string()))?;
|
||||
|
||||
Ok((ChatClient { sender }, msg_receiver))
|
||||
}
|
||||
|
||||
pub fn send_message(&self, msg: ServerMessage) -> Result<(), DeliveryServiceError> {
|
||||
let msg_json = serde_json::to_string(&msg).unwrap();
|
||||
self.sender
|
||||
.send(Message::Text(msg_json))
|
||||
.map_err(|err| DeliveryServiceError::SenderError(err.to_string()))?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_sign() {
|
||||
use alloy::signers::SignerSync;
|
||||
let signer = alloy::signers::local::PrivateKeySigner::from_str(
|
||||
"0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d",
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// Sign a message.
|
||||
let message = "You are joining the group with smart contract: ".to_owned()
|
||||
+ "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512";
|
||||
let signature = signer.sign_message_sync(message.as_bytes()).unwrap();
|
||||
|
||||
let json = serde_json::to_string(&signature).unwrap();
|
||||
let recover_sig: Signature = serde_json::from_str(&json).unwrap();
|
||||
|
||||
// Recover the signer from the message.
|
||||
let recovered = recover_sig.recover_address_from_msg(message).unwrap();
|
||||
assert_eq!(recovered, signer.address());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn json_test() {
|
||||
let inner_msg = ChatMessages::Request(RequestMLSPayload::new(
|
||||
"sc_address".to_string(),
|
||||
"group_name".to_string(),
|
||||
ReqMessageType::InviteToGroup,
|
||||
));
|
||||
|
||||
let res = serde_json::to_string(&inner_msg);
|
||||
assert!(res.is_ok());
|
||||
let json_inner_msg = res.unwrap();
|
||||
|
||||
let server_msg = ServerMessage::InMessage {
|
||||
from: "alice".to_string(),
|
||||
to: vec!["bob".to_string()],
|
||||
msg: json_inner_msg,
|
||||
};
|
||||
|
||||
let res = serde_json::to_string(&server_msg);
|
||||
assert!(res.is_ok());
|
||||
let json_server_msg = res.unwrap();
|
||||
|
||||
////
|
||||
|
||||
if let Ok(chat_message) = serde_json::from_str::<ServerMessage>(&json_server_msg) {
|
||||
assert_eq!(chat_message, server_msg);
|
||||
match chat_message {
|
||||
ServerMessage::InMessage { from, to, msg } => {
|
||||
if let Ok(chat_msg) = serde_json::from_str::<ChatMessages>(&msg) {
|
||||
assert_eq!(chat_msg, inner_msg);
|
||||
}
|
||||
}
|
||||
ServerMessage::SystemJoin { username } => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
114
ds/src/chat_server.rs
Normal file
114
ds/src/chat_server.rs
Normal file
@@ -0,0 +1,114 @@
|
||||
use futures_util::{SinkExt, StreamExt};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use tokio::{
|
||||
net::TcpListener,
|
||||
sync::{mpsc, Mutex},
|
||||
};
|
||||
use tokio_tungstenite::{accept_async, tungstenite::protocol::Message};
|
||||
|
||||
use crate::DeliveryServiceError;
|
||||
|
||||
type Tx = mpsc::UnboundedSender<Message>;
|
||||
type PeerMap = Arc<Mutex<HashMap<String, Tx>>>;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
||||
#[serde(tag = "type")]
|
||||
pub enum ServerMessage {
|
||||
InMessage {
|
||||
from: String,
|
||||
to: Vec<String>,
|
||||
msg: String,
|
||||
},
|
||||
SystemJoin {
|
||||
username: String,
|
||||
},
|
||||
}
|
||||
|
||||
pub async fn start_server(addr: &str) -> Result<(), DeliveryServiceError> {
|
||||
let listener = TcpListener::bind(addr).await?;
|
||||
let peers = PeerMap::new(Mutex::new(HashMap::new()));
|
||||
|
||||
while let Ok((stream, _)) = listener.accept().await {
|
||||
let peers = peers.clone();
|
||||
|
||||
tokio::spawn(async move {
|
||||
if let Err(e) = handle_connection(peers, stream).await {
|
||||
eprintln!("Error in connection handling: {:?}", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn handle_connection(
|
||||
peers: PeerMap,
|
||||
stream: tokio::net::TcpStream,
|
||||
) -> Result<(), DeliveryServiceError> {
|
||||
let ws_stream = accept_async(stream).await?;
|
||||
let (mut write, mut read) = ws_stream.split();
|
||||
let (sender, receiver) = mpsc::unbounded_channel();
|
||||
let receiver = Arc::new(Mutex::new(receiver));
|
||||
|
||||
let mut username = String::new();
|
||||
|
||||
// Spawn a task to handle outgoing messages
|
||||
tokio::spawn(async move {
|
||||
while let Some(message) = receiver.lock().await.recv().await {
|
||||
if let Err(err) = write.send(message).await {
|
||||
return Err(DeliveryServiceError::SenderError(err.to_string()));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
});
|
||||
|
||||
// Handle incoming messages
|
||||
while let Some(Ok(Message::Text(text))) = read.next().await {
|
||||
if let Ok(chat_message) = serde_json::from_str::<ServerMessage>(&text) {
|
||||
match chat_message {
|
||||
ServerMessage::SystemJoin {
|
||||
username: join_username,
|
||||
} => {
|
||||
username = join_username.clone();
|
||||
peers
|
||||
.lock()
|
||||
.await
|
||||
.insert(join_username.clone(), sender.clone());
|
||||
println!("{} joined the chat", join_username);
|
||||
}
|
||||
ServerMessage::InMessage { from, to, msg } => {
|
||||
println!("Received message from {} to {:?}: {}", from, to, msg);
|
||||
for recipient in to {
|
||||
if let Some(recipient_sender) = peers.lock().await.get(&recipient) {
|
||||
let message = ServerMessage::InMessage {
|
||||
from: from.clone(),
|
||||
to: vec![recipient.clone()],
|
||||
msg: msg.clone(),
|
||||
};
|
||||
let message_json = serde_json::to_string(&message).unwrap();
|
||||
recipient_sender
|
||||
.send(Message::Text(message_json))
|
||||
.map_err(|err| {
|
||||
DeliveryServiceError::SenderError(err.to_string())
|
||||
})?;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the user from the map when they disconnect
|
||||
if !username.is_empty() {
|
||||
peers.lock().await.remove(&username);
|
||||
println!("{} left the chat", username);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn start_test() {
|
||||
start_server("127.0.0.1:8080").await.unwrap()
|
||||
}
|
||||
41
ds/src/ds.rs
41
ds/src/ds.rs
@@ -1,17 +1,15 @@
|
||||
use fred::{
|
||||
clients::{RedisClient, SubscriberClient},
|
||||
error::RedisError,
|
||||
prelude::*,
|
||||
types::Message,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio::sync::broadcast::{error::RecvError, Receiver};
|
||||
use tokio::sync::broadcast::Receiver;
|
||||
|
||||
use openmls::{framing::MlsMessageOut, prelude::TlsSerializeTrait};
|
||||
use crate::DeliveryServiceError;
|
||||
// use waku_bindings::*;
|
||||
|
||||
pub struct RClient {
|
||||
group_id: String,
|
||||
client: RedisClient,
|
||||
sub_client: SubscriberClient,
|
||||
// broadcaster: Receiver<Message>,
|
||||
@@ -24,7 +22,7 @@ pub struct SenderStruct {
|
||||
}
|
||||
|
||||
impl RClient {
|
||||
pub async fn new_for_group(
|
||||
pub async fn new_with_group(
|
||||
group_id: String,
|
||||
) -> Result<(Self, Receiver<Message>), DeliveryServiceError> {
|
||||
let redis_client = RedisClient::default();
|
||||
@@ -35,49 +33,28 @@ impl RClient {
|
||||
subscriber.subscribe(group_id.clone()).await?;
|
||||
Ok((
|
||||
RClient {
|
||||
group_id,
|
||||
client: redis_client,
|
||||
sub_client: subscriber.clone(),
|
||||
// broadcaster: subscriber.message_rx(),
|
||||
},
|
||||
subscriber.message_rx(),
|
||||
))
|
||||
}
|
||||
|
||||
pub async fn remove_from_group(&mut self) -> Result<(), DeliveryServiceError> {
|
||||
self.sub_client.unsubscribe(self.group_id.clone()).await?;
|
||||
self.sub_client.quit().await?;
|
||||
self.client.quit().await?;
|
||||
pub async fn remove_group(&mut self, group_id: String) -> Result<(), DeliveryServiceError> {
|
||||
self.sub_client.unsubscribe(group_id).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn msg_send(
|
||||
&mut self,
|
||||
msg: MlsMessageOut,
|
||||
msg: Vec<u8>,
|
||||
sender: String,
|
||||
group_id: String,
|
||||
) -> Result<(), DeliveryServiceError> {
|
||||
let buf = msg.tls_serialize_detached()?;
|
||||
|
||||
let json_value = SenderStruct { sender, msg: buf };
|
||||
let json_value = SenderStruct { sender, msg };
|
||||
let bytes = serde_json::to_vec(&json_value)?;
|
||||
self.client
|
||||
.publish(self.group_id.clone(), bytes.as_slice())
|
||||
.await?;
|
||||
self.client.publish(group_id, bytes.as_slice()).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum DeliveryServiceError {
|
||||
#[error("Json error: {0}")]
|
||||
JsonError(#[from] serde_json::Error),
|
||||
#[error("Redis error: {0}")]
|
||||
RedisError(#[from] RedisError),
|
||||
#[error("Tokio error: {0}")]
|
||||
TokioReceiveError(#[from] RecvError),
|
||||
#[error("Serialization problem: {0}")]
|
||||
TlsError(#[from] tls_codec::Error),
|
||||
#[error("Unknown error: {0}")]
|
||||
Other(anyhow::Error),
|
||||
}
|
||||
|
||||
@@ -1 +1,34 @@
|
||||
use alloy::{hex::FromHexError, primitives::SignatureError};
|
||||
use fred::error::RedisError;
|
||||
|
||||
pub mod chat_client;
|
||||
pub mod chat_server;
|
||||
pub mod ds;
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum DeliveryServiceError {
|
||||
#[error("Validation failed: {0}")]
|
||||
ValidationError(String),
|
||||
|
||||
#[error("Redis operation failed: {0}")]
|
||||
RedisError(#[from] RedisError),
|
||||
#[error("Failed to send message to channel: {0}")]
|
||||
SenderError(String),
|
||||
#[error("WebSocket handshake failed.")]
|
||||
HandshakeError(#[from] tokio_tungstenite::tungstenite::Error),
|
||||
|
||||
#[error("Serialization error: {0}")]
|
||||
TlsError(#[from] tls_codec::Error),
|
||||
#[error("JSON processing error: {0}")]
|
||||
JsonError(#[from] serde_json::Error),
|
||||
#[error("Failed to bind to the address.")]
|
||||
BindError(#[from] std::io::Error),
|
||||
|
||||
#[error("Failed to parse address: {0}")]
|
||||
AlloyFromHexError(#[from] FromHexError),
|
||||
#[error("Failed to recover signature: {0}")]
|
||||
AlloySignatureError(#[from] SignatureError),
|
||||
|
||||
#[error("An unknown error occurred: {0}")]
|
||||
Other(anyhow::Error),
|
||||
}
|
||||
|
||||
@@ -1,78 +1,36 @@
|
||||
pub mod sc_ks;
|
||||
|
||||
use mls_crypto::openmls_provider::MlsCryptoProvider;
|
||||
use openmls::prelude::*;
|
||||
use std::collections::HashSet;
|
||||
|
||||
/// The DS returns a list of key packages for a user as `UserKeyPackages`.
|
||||
/// This is a tuple struct holding a vector of `(Vec<u8>, KeyPackage)` tuples,
|
||||
/// where the first value is the key package hash (output of `KeyPackage::hash`)
|
||||
/// and the second value is the corresponding key package.
|
||||
#[derive(Debug, Default, Clone, PartialEq)]
|
||||
pub struct UserKeyPackages(pub Vec<(Vec<u8>, KeyPackage)>);
|
||||
|
||||
impl UserKeyPackages {
|
||||
fn get_id_from_kp(&self) -> Vec<u8> {
|
||||
let key_package: KeyPackage = self.0[0].1.clone();
|
||||
key_package.leaf_node().credential().identity().to_vec()
|
||||
}
|
||||
}
|
||||
|
||||
/// Information about a user.
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct UserInfo {
|
||||
pub id: Vec<u8>,
|
||||
pub key_packages: UserKeyPackages,
|
||||
pub key_packages_hash: HashSet<Vec<u8>>,
|
||||
pub sign_pk: Vec<u8>,
|
||||
}
|
||||
use alloy::hex::FromHexError;
|
||||
|
||||
pub trait SCKeyStoreService {
|
||||
fn does_user_exist(
|
||||
&self,
|
||||
id: &[u8],
|
||||
address: &str,
|
||||
) -> impl std::future::Future<Output = Result<bool, KeyStoreError>>;
|
||||
fn add_user(
|
||||
&mut self,
|
||||
ukp: UserKeyPackages,
|
||||
sign_pk: &[u8],
|
||||
address: &str,
|
||||
) -> impl std::future::Future<Output = Result<(), KeyStoreError>>;
|
||||
fn get_user(
|
||||
fn remove_user(
|
||||
&self,
|
||||
id: &[u8],
|
||||
crypto: &MlsCryptoProvider,
|
||||
) -> impl std::future::Future<Output = Result<UserInfo, KeyStoreError>>;
|
||||
fn add_user_kp(
|
||||
&mut self,
|
||||
id: &[u8],
|
||||
ukp: UserKeyPackages,
|
||||
address: &str,
|
||||
) -> impl std::future::Future<Output = Result<(), KeyStoreError>>;
|
||||
// we need get key package of other user for inviting them to group
|
||||
fn get_avaliable_user_kp(
|
||||
&mut self,
|
||||
id: &[u8],
|
||||
crypto: &MlsCryptoProvider,
|
||||
) -> impl std::future::Future<Output = Result<KeyPackage, KeyStoreError>>;
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum KeyStoreError {
|
||||
#[error("User doesn't exist")]
|
||||
UnknownUserError,
|
||||
#[error("Invalid data for User: {0}")]
|
||||
InvalidUserDataError(String),
|
||||
#[error("Unauthorized User")]
|
||||
UnauthorizedUserError,
|
||||
#[error("User already exist")]
|
||||
AlreadyExistedUserError,
|
||||
#[error("Alloy contract error: {0}")]
|
||||
AlloyError(#[from] alloy::contract::Error),
|
||||
#[error("Serialization problem: {0}")]
|
||||
TlsError(#[from] tls_codec::Error),
|
||||
#[error("Key package doesn't valid: {0}")]
|
||||
MlsKeyPackageVerifyError(#[from] openmls::prelude::KeyPackageVerifyError),
|
||||
#[error(transparent)]
|
||||
MlsLibraryError(#[from] LibraryError),
|
||||
#[error("Unknown error: {0}")]
|
||||
Other(anyhow::Error),
|
||||
#[error("User already exists.")]
|
||||
UserAlreadyExistsError,
|
||||
|
||||
#[error("User not found.")]
|
||||
UserNotFoundError,
|
||||
|
||||
#[error("Alloy contract operation failed: {0}")]
|
||||
AlloyContractError(#[from] alloy::contract::Error),
|
||||
|
||||
#[error("Failed to parse address: {0}")]
|
||||
AddressParseError(#[from] FromHexError),
|
||||
|
||||
#[error("An unexpected error occurred: {0}")]
|
||||
UnexpectedError(anyhow::Error),
|
||||
}
|
||||
|
||||
@@ -1,26 +1,12 @@
|
||||
use alloy::{
|
||||
network::{EthereumWallet, Network},
|
||||
primitives::{Address, Bytes},
|
||||
providers::Provider,
|
||||
signers::local::PrivateKeySigner,
|
||||
transports::Transport,
|
||||
};
|
||||
use foundry_contracts::sckeystore::ScKeystore::{self, KeyPackage, ScKeystoreInstance};
|
||||
use mls_crypto::openmls_provider::MlsCryptoProvider;
|
||||
use openmls::test_utils::OpenMlsCryptoProvider;
|
||||
use openmls::{
|
||||
key_packages::KeyPackageIn,
|
||||
prelude::{KeyPackage as mlsKeyPackage, TlsDeserializeTrait, TlsSerializeTrait},
|
||||
versions::ProtocolVersion,
|
||||
};
|
||||
use std::{collections::HashSet, str::FromStr};
|
||||
use alloy::{network::Network, primitives::Address, providers::Provider, transports::Transport};
|
||||
use foundry_contracts::sckeystore::ScKeystore::{self, ScKeystoreInstance};
|
||||
use std::str::FromStr;
|
||||
|
||||
use crate::UserInfo;
|
||||
use crate::UserKeyPackages;
|
||||
use crate::{KeyStoreError, SCKeyStoreService};
|
||||
|
||||
pub struct ScKeyStorage<T, P, N> {
|
||||
instance: ScKeystoreInstance<T, P, N>,
|
||||
address: String,
|
||||
}
|
||||
|
||||
impl<T, P, N> ScKeyStorage<T, P, N>
|
||||
@@ -32,263 +18,50 @@ where
|
||||
pub fn new(provider: P, address: Address) -> Self {
|
||||
Self {
|
||||
instance: ScKeystore::new(address, provider),
|
||||
address: address.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<UserKeyPackages> for Vec<KeyPackage> {
|
||||
fn from(ukp: UserKeyPackages) -> Self {
|
||||
let mut res: Vec<KeyPackage> = Vec::with_capacity(ukp.0.len());
|
||||
for kp in ukp.0 {
|
||||
let bytes = kp.1.tls_serialize_detached().unwrap();
|
||||
let kp_bytes = Bytes::copy_from_slice(bytes.as_slice());
|
||||
let kp_sc: KeyPackage = KeyPackage::from((vec![kp_bytes],));
|
||||
res.push(kp_sc)
|
||||
}
|
||||
res
|
||||
pub fn sc_adsress(&self) -> String {
|
||||
self.address.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Transport + Clone, P: Provider<T, N>, N: Network> SCKeyStoreService
|
||||
for &mut ScKeyStorage<T, P, N>
|
||||
for ScKeyStorage<T, P, N>
|
||||
{
|
||||
async fn does_user_exist(&self, id: &[u8]) -> Result<bool, KeyStoreError> {
|
||||
let address = Address::from_slice(id);
|
||||
let res = self.instance.userExists(address).call().await?;
|
||||
Ok(res._0)
|
||||
async fn does_user_exist(&self, address: &str) -> Result<bool, KeyStoreError> {
|
||||
let address = Address::from_str(address)?;
|
||||
let res = self.instance.userExists(address).call().await;
|
||||
match res {
|
||||
Ok(is_exist) => Ok(is_exist._0),
|
||||
Err(err) => Err(KeyStoreError::AlloyContractError(err)),
|
||||
}
|
||||
}
|
||||
|
||||
async fn add_user(
|
||||
&mut self,
|
||||
ukp: UserKeyPackages,
|
||||
sign_pk: &[u8],
|
||||
) -> Result<(), KeyStoreError> {
|
||||
if ukp.0.is_empty() {
|
||||
return Err(KeyStoreError::InvalidUserDataError(
|
||||
"no key packages".to_string(),
|
||||
));
|
||||
}
|
||||
let user_id = ukp.get_id_from_kp();
|
||||
if self.does_user_exist(user_id.as_slice()).await? {
|
||||
return Err(KeyStoreError::AlreadyExistedUserError);
|
||||
async fn add_user(&mut self, address: &str) -> Result<(), KeyStoreError> {
|
||||
if self.does_user_exist(address).await? {
|
||||
return Err(KeyStoreError::UserAlreadyExistsError);
|
||||
}
|
||||
|
||||
let ukp_sc: Vec<KeyPackage> = ukp.into();
|
||||
for (i, kp_sc) in ukp_sc.iter().enumerate() {
|
||||
if i == 0 {
|
||||
let add_user_binding = self.instance.addUser(
|
||||
Address::from_slice(user_id.as_slice()),
|
||||
Bytes::copy_from_slice(sign_pk),
|
||||
kp_sc.to_owned(),
|
||||
);
|
||||
let res = add_user_binding.send().await;
|
||||
match res {
|
||||
Ok(_) => continue,
|
||||
Err(err) => return Err(KeyStoreError::AlloyError(err)),
|
||||
}
|
||||
}
|
||||
let add_kp_binding = self.instance.addKeyPackage(kp_sc.to_owned());
|
||||
let res = add_kp_binding.send().await;
|
||||
match res {
|
||||
Ok(_) => continue,
|
||||
Err(err) => return Err(KeyStoreError::AlloyError(err)),
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn get_user(
|
||||
&self,
|
||||
id: &[u8],
|
||||
crypto: &MlsCryptoProvider,
|
||||
) -> Result<UserInfo, KeyStoreError> {
|
||||
let address = Address::from_slice(id);
|
||||
let res = self.instance.getUser(address).call().await;
|
||||
|
||||
let user = match res {
|
||||
Ok(user) => user,
|
||||
Err(err) => return Err(KeyStoreError::AlloyError(err)),
|
||||
};
|
||||
|
||||
let mut user = UserInfo {
|
||||
id: id.to_vec(),
|
||||
key_packages: UserKeyPackages::default(),
|
||||
key_packages_hash: HashSet::default(),
|
||||
sign_pk: user._0.signaturePubKey.to_vec(),
|
||||
};
|
||||
|
||||
let res = self.instance.getAllKeyPackagesForUser(address).call().await;
|
||||
|
||||
let kps = match res {
|
||||
Ok(kp) => kp,
|
||||
Err(err) => return Err(KeyStoreError::AlloyError(err)),
|
||||
};
|
||||
|
||||
for kp in kps._0 {
|
||||
let key_package_in = KeyPackageIn::tls_deserialize_bytes(&kp.data[0])?;
|
||||
let key_package = key_package_in.validate(crypto.crypto(), ProtocolVersion::Mls10)?;
|
||||
let kp = key_package.hash_ref(crypto.crypto())?.as_slice().to_vec();
|
||||
user.key_packages.0.push((kp, key_package));
|
||||
}
|
||||
|
||||
Ok(user)
|
||||
}
|
||||
|
||||
async fn add_user_kp(&mut self, id: &[u8], ukp: UserKeyPackages) -> Result<(), KeyStoreError> {
|
||||
if !self.does_user_exist(id).await? {
|
||||
return Err(KeyStoreError::UnknownUserError);
|
||||
}
|
||||
|
||||
let mut kp_bytes: Vec<Bytes> = Vec::with_capacity(ukp.0.len());
|
||||
for kp in ukp.0 {
|
||||
let bytes = kp.1.tls_serialize_detached()?;
|
||||
kp_bytes.push(Bytes::copy_from_slice(bytes.as_slice()))
|
||||
}
|
||||
|
||||
let kp: KeyPackage = KeyPackage::from((kp_bytes,));
|
||||
|
||||
let add_kp_binding = self.instance.addKeyPackage(kp);
|
||||
let res = add_kp_binding.send().await;
|
||||
|
||||
let add_to_acl_binding = self.instance.addUser(Address::from_str(address)?);
|
||||
let res = add_to_acl_binding.send().await;
|
||||
match res {
|
||||
Ok(_) => Ok(()),
|
||||
Err(err) => Err(KeyStoreError::AlloyError(err)),
|
||||
Err(err) => Err(KeyStoreError::AlloyContractError(err)),
|
||||
}
|
||||
}
|
||||
|
||||
async fn get_avaliable_user_kp(
|
||||
&mut self,
|
||||
id: &[u8],
|
||||
crypto: &MlsCryptoProvider,
|
||||
) -> Result<mlsKeyPackage, KeyStoreError> {
|
||||
if !self.does_user_exist(id).await? {
|
||||
return Err(KeyStoreError::UnknownUserError);
|
||||
async fn remove_user(&self, address: &str) -> Result<(), KeyStoreError> {
|
||||
if !self.does_user_exist(address).await? {
|
||||
return Err(KeyStoreError::UserNotFoundError);
|
||||
}
|
||||
let address = Address::from_slice(id);
|
||||
let add_kp_binding = self.instance.getAvailableKeyPackage(address);
|
||||
let res = add_kp_binding.call().await?;
|
||||
let key_package_in = KeyPackageIn::tls_deserialize_bytes(&res._0.data[0])?;
|
||||
let key_package = key_package_in.validate(crypto.crypto(), ProtocolVersion::Mls10)?;
|
||||
|
||||
Ok(key_package)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn alice_addr_test() -> (Address, EthereumWallet) {
|
||||
let alice_address = Address::from_str("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266").unwrap(); // anvil default key 0
|
||||
let signer = PrivateKeySigner::from_str(
|
||||
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
|
||||
)
|
||||
.unwrap();
|
||||
let wallet = EthereumWallet::from(signer);
|
||||
(alice_address, wallet)
|
||||
}
|
||||
|
||||
pub fn bob_addr_test() -> (Address, EthereumWallet) {
|
||||
let bob_address = Address::from_str("0x70997970C51812dc3A010C7d01b50e0d17dc79C8").unwrap(); // anvil default key 0
|
||||
let signer = PrivateKeySigner::from_str(
|
||||
"0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d",
|
||||
)
|
||||
.unwrap();
|
||||
let wallet = EthereumWallet::from(signer);
|
||||
(bob_address, wallet)
|
||||
}
|
||||
|
||||
pub fn carla_addr_test() -> (Address, EthereumWallet) {
|
||||
let carla_address = Address::from_str("0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC").unwrap(); // anvil default key 0
|
||||
let signer = PrivateKeySigner::from_str(
|
||||
"0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a",
|
||||
)
|
||||
.unwrap();
|
||||
let wallet = EthereumWallet::from(signer);
|
||||
(carla_address, wallet)
|
||||
}
|
||||
|
||||
mod test {
|
||||
use alloy::{primitives::Address, providers::ProviderBuilder};
|
||||
use std::{borrow::BorrowMut, collections::HashMap};
|
||||
|
||||
use openmls::prelude::*;
|
||||
use openmls_basic_credential::SignatureKeyPair;
|
||||
|
||||
use mls_crypto::openmls_provider::{MlsCryptoProvider, CIPHERSUITE};
|
||||
|
||||
use crate::{sc_ks::*, UserKeyPackages};
|
||||
|
||||
pub(crate) fn test_identity(
|
||||
address: Address,
|
||||
crypto: &MlsCryptoProvider,
|
||||
) -> (UserKeyPackages, SignatureKeyPair) {
|
||||
let ciphersuite = CIPHERSUITE;
|
||||
let signature_keys = SignatureKeyPair::new(ciphersuite.signature_algorithm()).unwrap();
|
||||
let credential = Credential::new(address.to_vec(), CredentialType::Basic).unwrap();
|
||||
|
||||
let credential_with_key = CredentialWithKey {
|
||||
credential,
|
||||
signature_key: signature_keys.to_public_vec().into(),
|
||||
};
|
||||
signature_keys.store(crypto.key_store()).unwrap();
|
||||
|
||||
let mut kps = HashMap::new();
|
||||
for _ in 0..3 {
|
||||
let key_package = mlsKeyPackage::builder()
|
||||
.build(
|
||||
CryptoConfig {
|
||||
ciphersuite,
|
||||
version: ProtocolVersion::default(),
|
||||
},
|
||||
crypto,
|
||||
&signature_keys,
|
||||
credential_with_key.clone(),
|
||||
)
|
||||
.unwrap();
|
||||
let kp = key_package.hash_ref(crypto.crypto()).unwrap();
|
||||
kps.insert(kp.as_slice().to_vec(), key_package);
|
||||
let remove_user_binding = self.instance.removeUser(Address::from_str(address)?);
|
||||
let res = remove_user_binding.send().await;
|
||||
match res {
|
||||
Ok(_) => Ok(()),
|
||||
Err(err) => Err(KeyStoreError::AlloyContractError(err)),
|
||||
}
|
||||
let ukp = UserKeyPackages(kps.drain().collect::<Vec<(Vec<u8>, mlsKeyPackage)>>());
|
||||
|
||||
(ukp, signature_keys)
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_sc_storage() {
|
||||
let crypto = MlsCryptoProvider::default();
|
||||
let storage_address =
|
||||
Address::from_str("0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512").unwrap();
|
||||
let (alice_address, wallet) = alice_addr_test();
|
||||
let provider = ProviderBuilder::new()
|
||||
.with_recommended_fillers()
|
||||
.wallet(wallet)
|
||||
.on_http(url::Url::from_str("http://localhost:8545").unwrap());
|
||||
|
||||
let alice = test_identity(alice_address, &crypto);
|
||||
let mut binding = ScKeyStorage::new(provider, storage_address);
|
||||
let mut storage = binding.borrow_mut();
|
||||
|
||||
let res = storage.add_user(alice.0, alice.1.public()).await;
|
||||
println!("Add user res: {:#?}", res);
|
||||
assert!(res.is_ok());
|
||||
|
||||
let res = storage.get_user(alice_address.as_slice(), &crypto).await;
|
||||
println!("Get user res: {:#?}", res);
|
||||
assert!(res.is_ok());
|
||||
|
||||
let res = storage.does_user_exist(alice_address.as_slice()).await;
|
||||
println!("User exist res: {:#?}", res);
|
||||
|
||||
let res = storage
|
||||
.get_avaliable_user_kp(alice_address.as_slice(), &crypto)
|
||||
.await;
|
||||
// println!("Get user kp: {:#?}", res);
|
||||
assert!(res.is_ok());
|
||||
|
||||
let res2 = storage
|
||||
.get_avaliable_user_kp(alice_address.as_slice(), &crypto)
|
||||
.await;
|
||||
// println!("Get user kp: {:#?}", res);
|
||||
assert!(res.is_ok());
|
||||
|
||||
// HERE SHOULD BE NOT EQUAL
|
||||
assert_ne!(res.unwrap(), res2.unwrap());
|
||||
}
|
||||
}
|
||||
|
||||
111
src/cli.rs
111
src/cli.rs
@@ -1,17 +1,9 @@
|
||||
use alloy::{
|
||||
hex::FromHexError,
|
||||
network::EthereumWallet,
|
||||
primitives::Address,
|
||||
signers::local::{LocalSignerError, PrivateKeySigner},
|
||||
};
|
||||
use clap::{arg, command, Parser, Subcommand};
|
||||
use crossterm::{
|
||||
event::{self, Event, KeyCode},
|
||||
execute,
|
||||
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
|
||||
};
|
||||
|
||||
use fred::error::RedisError;
|
||||
use ratatui::{
|
||||
backend::CrosstermBackend,
|
||||
layout::{Constraint, Direction, Layout},
|
||||
@@ -21,39 +13,32 @@ use ratatui::{
|
||||
Frame, Terminal,
|
||||
};
|
||||
use std::{
|
||||
io,
|
||||
io::{Read, Write},
|
||||
str::FromStr,
|
||||
string::FromUtf8Error,
|
||||
io::{stdout, Read, Write},
|
||||
sync::Arc,
|
||||
};
|
||||
use tokio::{
|
||||
sync::mpsc::error::SendError,
|
||||
sync::mpsc::{Receiver, Sender},
|
||||
sync::Mutex,
|
||||
task::JoinError,
|
||||
};
|
||||
use tokio_util::sync::CancellationToken;
|
||||
use url::Url;
|
||||
|
||||
use crate::user::UserError;
|
||||
use ds::ds::DeliveryServiceError;
|
||||
use crate::CliError;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
pub struct Args {
|
||||
/// User private key that correspond to Ethereum wallet
|
||||
#[arg(short = 'K', long)]
|
||||
user_priv_key: String,
|
||||
pub user_priv_key: String,
|
||||
// /// Rpc url
|
||||
// #[arg(short = 'U', long,
|
||||
// default_value_t = Url::from_str("http://localhost:8545").unwrap())]
|
||||
// pub storage_url: Url,
|
||||
|
||||
/// Rpc url
|
||||
#[arg(short = 'U', long,
|
||||
default_value_t = Url::from_str("http://localhost:8545").unwrap())]
|
||||
pub storage_url: Url,
|
||||
|
||||
/// Storage contract address
|
||||
#[arg(short = 'S', long)]
|
||||
pub storage_addr: String,
|
||||
// /// Storage contract address
|
||||
// #[arg(short = 'S', long)]
|
||||
// pub storage_addr: String,
|
||||
}
|
||||
|
||||
pub enum Msg {
|
||||
@@ -70,14 +55,6 @@ pub enum Message {
|
||||
Error(String),
|
||||
}
|
||||
|
||||
pub fn get_user_data(args: &Args) -> Result<(Address, EthereumWallet, Address), CliError> {
|
||||
let signer = PrivateKeySigner::from_str(&args.user_priv_key)?;
|
||||
let user_address = signer.address();
|
||||
let wallet = EthereumWallet::from(signer);
|
||||
let storage_address = Address::from_str(&args.storage_addr)?;
|
||||
Ok((user_address, wallet, storage_address))
|
||||
}
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
#[command(multicall = true)]
|
||||
pub struct Cli {
|
||||
@@ -89,13 +66,12 @@ pub struct Cli {
|
||||
pub enum Commands {
|
||||
CreateGroup {
|
||||
group_name: String,
|
||||
storage_address: String,
|
||||
storage_url: Url,
|
||||
},
|
||||
Invite {
|
||||
group_name: String,
|
||||
user_wallet: String,
|
||||
},
|
||||
JoinGroup {
|
||||
group_name: String,
|
||||
users_wallet_addrs: Vec<String>,
|
||||
},
|
||||
SendMessage {
|
||||
group_name: String,
|
||||
@@ -135,19 +111,29 @@ pub async fn event_handler(
|
||||
if cli.is_err() {
|
||||
messages_tx
|
||||
.send(Msg::Input(Message::System("Unknown command".to_string())))
|
||||
.await?;
|
||||
.await
|
||||
.map_err(|err| CliError::SenderError(err.to_string()))?;
|
||||
continue;
|
||||
}
|
||||
cli_tx.send(cli.unwrap().command).await?;
|
||||
cli_tx
|
||||
.send(cli.unwrap().command)
|
||||
.await
|
||||
.map_err(|err| CliError::SenderError(err.to_string()))?;
|
||||
}
|
||||
KeyCode::Esc => {
|
||||
messages_tx.send(Msg::Exit).await?;
|
||||
messages_tx
|
||||
.send(Msg::Exit)
|
||||
.await
|
||||
.map_err(|err| CliError::SenderError(err.to_string()))?;
|
||||
token.cancel();
|
||||
break;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
messages_tx.send(Msg::Refresh(input.clone())).await?;
|
||||
messages_tx
|
||||
.send(Msg::Refresh(input.clone()))
|
||||
.await
|
||||
.map_err(|err| CliError::SenderError(err.to_string()))?;
|
||||
}
|
||||
}
|
||||
Ok::<_, CliError>(())
|
||||
@@ -204,7 +190,7 @@ pub async fn terminal_handler(
|
||||
token: CancellationToken,
|
||||
) -> Result<(), CliError> {
|
||||
enable_raw_mode()?;
|
||||
let mut stdout = io::stdout();
|
||||
let mut stdout = stdout();
|
||||
execute!(stdout, EnterAlternateScreen)?;
|
||||
let backend = CrosstermBackend::new(stdout);
|
||||
let terminal = Arc::new(Mutex::new(Terminal::new(backend)?));
|
||||
@@ -254,44 +240,3 @@ pub async fn terminal_handler(
|
||||
terminal_lock.show_cursor()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum CliError {
|
||||
#[error("Can't split the line")]
|
||||
SplitLineError,
|
||||
#[error("Unknown message type")]
|
||||
UnknownMsgError,
|
||||
|
||||
#[error(transparent)]
|
||||
UserError(#[from] UserError),
|
||||
#[error(transparent)]
|
||||
DeliveryServiceError(#[from] DeliveryServiceError),
|
||||
|
||||
#[error("Unable to parce the address: {0}")]
|
||||
AlloyFromHexError(#[from] FromHexError),
|
||||
#[error("Unable to parce the signer: {0}")]
|
||||
AlloyParceSignerError(#[from] LocalSignerError),
|
||||
#[error("Problem from std::io library: {0}")]
|
||||
IoError(#[from] std::io::Error),
|
||||
#[error("Parse String UTF8 error: {0}")]
|
||||
ParseUTF8Error(#[from] FromUtf8Error),
|
||||
#[error("Parse String error: {0}")]
|
||||
StringError(#[from] core::convert::Infallible),
|
||||
|
||||
#[error("Can't send control message into channel: {0}")]
|
||||
SendMsgError(#[from] SendError<Msg>),
|
||||
#[error("Can't send bytes into channel: {0}")]
|
||||
SendVecError(#[from] SendError<Vec<u8>>),
|
||||
#[error("Can't send command into channel: {0}")]
|
||||
SendCommandError(#[from] SendError<Commands>),
|
||||
|
||||
#[error(transparent)]
|
||||
ClapError(#[from] clap::error::Error),
|
||||
#[error("Redis error: {0}")]
|
||||
RedisError(#[from] RedisError),
|
||||
#[error("Failed from tokio join: {0}")]
|
||||
TokioJoinError(#[from] JoinError),
|
||||
|
||||
#[error("Unknown error: {0}")]
|
||||
AnyHowError(anyhow::Error),
|
||||
}
|
||||
|
||||
213
src/contact.rs
Normal file
213
src/contact.rs
Normal file
@@ -0,0 +1,213 @@
|
||||
use alloy::hex::ToHexExt;
|
||||
use ds::{
|
||||
chat_client::{
|
||||
ChatClient, ChatMessages, ReqMessageType, RequestMLSPayload, ResponseMLSPayload,
|
||||
},
|
||||
chat_server::ServerMessage,
|
||||
};
|
||||
// use waku_bindings::*;
|
||||
|
||||
use openmls::prelude::MlsMessageOut;
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
use tls_codec::Serialize;
|
||||
use tokio::sync::Mutex;
|
||||
use tokio_util::sync::CancellationToken;
|
||||
|
||||
use crate::ContactError;
|
||||
|
||||
pub const CHAT_SERVER_ADDR: &str = "ws://127.0.0.1:8080";
|
||||
|
||||
pub struct ContactsList {
|
||||
contacts: Arc<Mutex<HashMap<String, Contact>>>,
|
||||
group_id2sc: HashMap<String, String>,
|
||||
pub future_req: HashMap<String, CancellationToken>,
|
||||
pub chat_client: ChatClient,
|
||||
}
|
||||
|
||||
pub struct Contact {
|
||||
// map group_name to key_package bytes
|
||||
group_id2user_kp: HashMap<String, Vec<u8>>,
|
||||
// user_p2p_addr: WakuPeers,
|
||||
}
|
||||
|
||||
impl Contact {
|
||||
pub fn get_relevant_kp(&mut self, group_name: String) -> Result<Vec<u8>, ContactError> {
|
||||
match self.group_id2user_kp.remove(&group_name) {
|
||||
Some(kp) => Ok(kp.clone()),
|
||||
None => Err(ContactError::MissingKeyPackageForGroup),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_key_package(
|
||||
&mut self,
|
||||
key_package: Vec<u8>,
|
||||
group_name: String,
|
||||
) -> Result<(), ContactError> {
|
||||
match self.group_id2user_kp.insert(group_name, key_package) {
|
||||
Some(_) => Err(ContactError::DuplicateUserError),
|
||||
None => Ok(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ContactsList {
|
||||
pub async fn new(chat_client: ChatClient) -> Result<Self, ContactError> {
|
||||
Ok(ContactsList {
|
||||
contacts: Arc::new(Mutex::new(HashMap::new())),
|
||||
group_id2sc: HashMap::new(),
|
||||
future_req: HashMap::new(),
|
||||
chat_client,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn send_welcome_msg_to_users(
|
||||
&mut self,
|
||||
self_address: String,
|
||||
users_address: Vec<String>,
|
||||
welcome: MlsMessageOut,
|
||||
) -> Result<(), ContactError> {
|
||||
let bytes = welcome.tls_serialize_detached()?;
|
||||
let welcome_str: String = bytes.encode_hex();
|
||||
|
||||
let msg = ChatMessages::Welcome(welcome_str);
|
||||
self.chat_client.send_message(ServerMessage::InMessage {
|
||||
from: self_address,
|
||||
to: users_address,
|
||||
msg: serde_json::to_string(&msg)?,
|
||||
})?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn send_msg_req(
|
||||
&mut self,
|
||||
self_address: String,
|
||||
user_address: String,
|
||||
group_name: String,
|
||||
msg_type: ReqMessageType,
|
||||
) -> Result<(), ContactError> {
|
||||
self.future_req
|
||||
.insert(user_address.clone(), CancellationToken::new());
|
||||
|
||||
let sc_address = match self.group_id2sc.get(&group_name).cloned() {
|
||||
Some(sc) => sc,
|
||||
None => return Err(ContactError::MissingSmartContractForGroup),
|
||||
};
|
||||
|
||||
let req = ChatMessages::Request(RequestMLSPayload::new(sc_address, group_name, msg_type));
|
||||
self.chat_client.send_message(ServerMessage::InMessage {
|
||||
from: self_address,
|
||||
to: vec![user_address],
|
||||
msg: serde_json::to_string(&req)?,
|
||||
})?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn send_resp_msg_to_user(
|
||||
&mut self,
|
||||
self_address: String,
|
||||
user_address: &str,
|
||||
resp: ResponseMLSPayload,
|
||||
) -> Result<(), ContactError> {
|
||||
let resp_j = ChatMessages::Response(resp);
|
||||
self.chat_client.send_message(ServerMessage::InMessage {
|
||||
from: self_address,
|
||||
to: vec![user_address.to_string()],
|
||||
msg: serde_json::to_string(&resp_j)?,
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn add_new_contact(&mut self, user_address: &str) -> Result<(), ContactError> {
|
||||
let mut contacts = self.contacts.lock().await;
|
||||
if contacts.contains_key(user_address) {
|
||||
return Err(ContactError::DuplicateUserError);
|
||||
}
|
||||
|
||||
match contacts.insert(
|
||||
user_address.to_string(),
|
||||
Contact {
|
||||
group_id2user_kp: HashMap::new(),
|
||||
},
|
||||
) {
|
||||
Some(_) => Err(ContactError::DuplicateUserError),
|
||||
None => Ok(()),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn add_key_package_to_contact(
|
||||
&mut self,
|
||||
user_wallet: &str,
|
||||
key_package: Vec<u8>,
|
||||
group_name: String,
|
||||
) -> Result<(), ContactError> {
|
||||
let mut contacts = self.contacts.lock().await;
|
||||
match contacts.get_mut(user_wallet) {
|
||||
Some(user) => user.add_key_package(key_package, group_name)?,
|
||||
None => return Err(ContactError::UserNotFoundError),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn does_user_in_contacts(&self, user_wallet: &str) -> bool {
|
||||
let contacts = self.contacts.lock().await;
|
||||
contacts.get(user_wallet).is_some()
|
||||
}
|
||||
|
||||
pub async fn prepare_joiners(
|
||||
&mut self,
|
||||
user_wallets: Vec<String>,
|
||||
group_name: String,
|
||||
) -> Result<HashMap<String, Vec<u8>>, ContactError> {
|
||||
let mut joiners_kp = HashMap::with_capacity(user_wallets.len());
|
||||
|
||||
for user_wallet in user_wallets {
|
||||
if joiners_kp.contains_key(&user_wallet) {
|
||||
return Err(ContactError::DuplicateUserError);
|
||||
}
|
||||
|
||||
let mut contacts = self.contacts.lock().await;
|
||||
match contacts.get_mut(&user_wallet) {
|
||||
Some(contact) => match contact.get_relevant_kp(group_name.clone()) {
|
||||
Ok(kp) => match joiners_kp.insert(user_wallet, kp) {
|
||||
Some(_) => return Err(ContactError::DuplicateUserError),
|
||||
None => continue,
|
||||
},
|
||||
Err(err) => return Err(err),
|
||||
},
|
||||
None => return Err(ContactError::UserNotFoundError),
|
||||
}
|
||||
}
|
||||
|
||||
Ok(joiners_kp)
|
||||
}
|
||||
|
||||
pub fn handle_response(&mut self, user_address: &str) -> Result<(), ContactError> {
|
||||
match self.future_req.get(user_address) {
|
||||
Some(token) => {
|
||||
token.cancel();
|
||||
Ok(())
|
||||
}
|
||||
None => Err(ContactError::UserNotFoundError),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn insert_group2sc(
|
||||
&mut self,
|
||||
group_name: String,
|
||||
sc_address: String,
|
||||
) -> Result<(), ContactError> {
|
||||
match self.group_id2sc.insert(group_name, sc_address) {
|
||||
Some(_) => Err(ContactError::GroupAlreadyExistsError),
|
||||
None => Ok(()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn group2sc(&self, group_name: String) -> Result<String, ContactError> {
|
||||
match self.group_id2sc.get(&group_name).cloned() {
|
||||
Some(addr) => Ok(addr),
|
||||
None => Err(ContactError::GroupNotFoundError(group_name)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,14 @@
|
||||
use hex;
|
||||
use alloy::primitives::Address;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use openmls::{credentials::CredentialWithKey, key_packages::*, prelude::*};
|
||||
use openmls_basic_credential::SignatureKeyPair;
|
||||
use openmls_rust_crypto::MemoryKeyStoreError;
|
||||
use openmls_traits::types::Ciphersuite;
|
||||
|
||||
use mls_crypto::openmls_provider::MlsCryptoProvider;
|
||||
|
||||
use crate::IdentityError;
|
||||
|
||||
pub struct Identity {
|
||||
pub(crate) kp: HashMap<Vec<u8>, KeyPackage>,
|
||||
pub(crate) credential_with_key: CredentialWithKey,
|
||||
@@ -19,7 +20,6 @@ impl Identity {
|
||||
ciphersuite: Ciphersuite,
|
||||
crypto: &MlsCryptoProvider,
|
||||
user_wallet_address: &[u8],
|
||||
number_of_kp: usize,
|
||||
) -> Result<Identity, IdentityError> {
|
||||
let credential = Credential::new(user_wallet_address.to_vec(), CredentialType::Basic)?;
|
||||
let signature_keys = SignatureKeyPair::new(ciphersuite.signature_algorithm())?;
|
||||
@@ -30,19 +30,17 @@ impl Identity {
|
||||
signature_keys.store(crypto.key_store())?;
|
||||
|
||||
let mut kps = HashMap::new();
|
||||
for _ in 0..number_of_kp {
|
||||
let key_package = KeyPackage::builder().build(
|
||||
CryptoConfig {
|
||||
ciphersuite,
|
||||
version: ProtocolVersion::default(),
|
||||
},
|
||||
crypto,
|
||||
&signature_keys,
|
||||
credential_with_key.clone(),
|
||||
)?;
|
||||
let kp = key_package.hash_ref(crypto.crypto())?;
|
||||
kps.insert(kp.as_slice().to_vec(), key_package);
|
||||
}
|
||||
let key_package = KeyPackage::builder().build(
|
||||
CryptoConfig {
|
||||
ciphersuite,
|
||||
version: ProtocolVersion::default(),
|
||||
},
|
||||
crypto,
|
||||
&signature_keys,
|
||||
credential_with_key.clone(),
|
||||
)?;
|
||||
let kp = key_package.hash_ref(crypto.crypto())?;
|
||||
kps.insert(kp.as_slice().to_vec(), key_package);
|
||||
|
||||
Ok(Identity {
|
||||
kp: kps,
|
||||
@@ -52,7 +50,7 @@ impl Identity {
|
||||
}
|
||||
|
||||
/// Create an additional key package using the credential_with_key/signer bound to this identity
|
||||
pub fn add_key_package(
|
||||
pub fn generate_key_package(
|
||||
&mut self,
|
||||
ciphersuite: Ciphersuite,
|
||||
crypto: &MlsCryptoProvider,
|
||||
@@ -81,22 +79,6 @@ impl Identity {
|
||||
|
||||
impl ToString for Identity {
|
||||
fn to_string(&self) -> String {
|
||||
hex::encode(self.credential_with_key.credential.identity())
|
||||
Address::from_slice(self.credential_with_key.credential.identity()).to_string()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum IdentityError {
|
||||
#[error("Something wrong while creating new key package: {0}")]
|
||||
MlsKeyPackageNewError(#[from] KeyPackageNewError<MemoryKeyStoreError>),
|
||||
#[error(transparent)]
|
||||
MlsLibraryError(#[from] LibraryError),
|
||||
#[error("Something wrong with signature: {0}")]
|
||||
MlsCryptoError(#[from] CryptoError),
|
||||
#[error("Can't save signature key")]
|
||||
MlsKeyStoreError(#[from] MemoryKeyStoreError),
|
||||
#[error("Something wrong with credential: {0}")]
|
||||
MlsCredentialError(#[from] CredentialError),
|
||||
#[error("Unknown error: {0}")]
|
||||
Other(anyhow::Error),
|
||||
}
|
||||
|
||||
172
src/lib.rs
172
src/lib.rs
@@ -1,47 +1,153 @@
|
||||
use alloy::{hex::FromHexError, primitives::SignatureError, signers::local::LocalSignerError};
|
||||
use ds::DeliveryServiceError;
|
||||
use fred::error::RedisError;
|
||||
use openmls::{error::LibraryError, prelude::*};
|
||||
use openmls_rust_crypto::MemoryKeyStoreError;
|
||||
use sc_key_store::KeyStoreError;
|
||||
use std::{str::Utf8Error, string::FromUtf8Error};
|
||||
use tokio::task::JoinError;
|
||||
|
||||
pub mod cli;
|
||||
pub mod contact;
|
||||
pub mod conversation;
|
||||
pub mod identity;
|
||||
pub mod user;
|
||||
|
||||
use std::{fs::File, io};
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum CliError {
|
||||
#[error("Can't split the line")]
|
||||
SplitLineError,
|
||||
#[error("Failed to cancel token")]
|
||||
TokenCancellingError,
|
||||
|
||||
const SC_ADDRESS: &str = "contracts/broadcast/Deploy.s.sol/31337/run-latest.json";
|
||||
#[error("Problem from std::io library: {0}")]
|
||||
IoError(#[from] std::io::Error),
|
||||
|
||||
pub fn get_contract_address() -> Result<String, HelperError> {
|
||||
let file = File::open(SC_ADDRESS)?;
|
||||
let json: serde_json::Value = serde_json::from_reader(file)?;
|
||||
#[error("Failed to send message to channel: {0}")]
|
||||
SenderError(String),
|
||||
|
||||
let returns = match json.get("returns") {
|
||||
Some(v) => v,
|
||||
None => return Err(HelperError::UnknownJsonFieldError),
|
||||
};
|
||||
#[error("Redis error: {0}")]
|
||||
RedisError(#[from] RedisError),
|
||||
#[error("Failed from tokio join: {0}")]
|
||||
TokioJoinError(#[from] JoinError),
|
||||
|
||||
let sc_keystore = match returns.get("scKeystore") {
|
||||
Some(v) => v,
|
||||
None => return Err(HelperError::UnknownJsonFieldError),
|
||||
};
|
||||
|
||||
let address = match sc_keystore.get("value") {
|
||||
Some(v) => v,
|
||||
None => return Err(HelperError::UnknownJsonFieldError),
|
||||
};
|
||||
|
||||
match address.as_str() {
|
||||
Some(res) => Ok(res.to_string()),
|
||||
None => Err(HelperError::ParserError),
|
||||
}
|
||||
#[error("Unknown error: {0}")]
|
||||
AnyHowError(anyhow::Error),
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum HelperError {
|
||||
#[error("Field doesn't exist")]
|
||||
UnknownJsonFieldError,
|
||||
#[error("Parser Error")]
|
||||
ParserError,
|
||||
#[error("Can't read file: {0}")]
|
||||
IoError(#[from] io::Error),
|
||||
#[error("Json Error: {0}")]
|
||||
JsonError(#[from] serde_json::Error),
|
||||
#[error("Unknown error: {0}")]
|
||||
pub enum ContactError {
|
||||
#[error("Key package for the specified group does not exist.")]
|
||||
MissingKeyPackageForGroup,
|
||||
#[error("SmartContract address for the specified group does not exist.")]
|
||||
MissingSmartContractForGroup,
|
||||
#[error("User not found.")]
|
||||
UserNotFoundError,
|
||||
#[error("Group not found: {0}")]
|
||||
GroupNotFoundError(String),
|
||||
#[error("Duplicate user found in joiners list.")]
|
||||
DuplicateUserError,
|
||||
#[error("Group already exists")]
|
||||
GroupAlreadyExistsError,
|
||||
#[error("Invalid user address in signature.")]
|
||||
InvalidUserSignatureError,
|
||||
|
||||
#[error(transparent)]
|
||||
DeliveryServiceError(#[from] DeliveryServiceError),
|
||||
|
||||
#[error("Failed to parse signature: {0}")]
|
||||
AlloySignatureParsingError(#[from] SignatureError),
|
||||
#[error("JSON processing error: {0}")]
|
||||
JsonProcessingError(#[from] serde_json::Error),
|
||||
#[error("Serialization error: {0}")]
|
||||
SerializationError(#[from] tls_codec::Error),
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum IdentityError {
|
||||
#[error("Failed to create new key package: {0}")]
|
||||
MlsKeyPackageCreationError(#[from] KeyPackageNewError<MemoryKeyStoreError>),
|
||||
#[error(transparent)]
|
||||
MlsLibraryError(#[from] LibraryError),
|
||||
#[error("Failed to create signature: {0}")]
|
||||
MlsCryptoError(#[from] CryptoError),
|
||||
#[error("Failed to save signature key: {0}")]
|
||||
MlsKeyStoreError(#[from] MemoryKeyStoreError),
|
||||
#[error("Failed to create credential: {0}")]
|
||||
MlsCredentialError(#[from] CredentialError),
|
||||
#[error("An unknown error occurred: {0}")]
|
||||
Other(anyhow::Error),
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum UserError {
|
||||
#[error("User lacks connection to the smart contract.")]
|
||||
MissingSmartContractConnection,
|
||||
#[error("Group not found: {0}")]
|
||||
GroupNotFoundError(String),
|
||||
#[error("Group already exists: {0}")]
|
||||
GroupAlreadyExistsError(String),
|
||||
#[error("Unsupported message type.")]
|
||||
UnsupportedMessageType,
|
||||
#[error("User already exists: {0}")]
|
||||
UserAlreadyExistsError(String),
|
||||
#[error("Welcome message cannot be empty.")]
|
||||
EmptyWelcomeMessageError,
|
||||
#[error("Message from user is invalid")]
|
||||
InvalidChatMessageError,
|
||||
#[error("Message from server is invalid")]
|
||||
InvalidServerMessageError,
|
||||
#[error("User not found.")]
|
||||
UserNotFoundError,
|
||||
|
||||
#[error(transparent)]
|
||||
DeliveryServiceError(#[from] DeliveryServiceError),
|
||||
#[error(transparent)]
|
||||
KeyStoreError(#[from] KeyStoreError),
|
||||
#[error(transparent)]
|
||||
IdentityError(#[from] IdentityError),
|
||||
#[error(transparent)]
|
||||
ContactError(#[from] ContactError),
|
||||
|
||||
#[error("Error while creating MLS group: {0}")]
|
||||
MlsGroupCreationError(#[from] NewGroupError<MemoryKeyStoreError>),
|
||||
#[error("Error while adding member to MLS group: {0}")]
|
||||
MlsAddMemberError(#[from] AddMembersError<MemoryKeyStoreError>),
|
||||
#[error("Error while merging pending commit in MLS group: {0}")]
|
||||
MlsMergePendingCommitError(#[from] MergePendingCommitError<MemoryKeyStoreError>),
|
||||
#[error("Error while merging commit in MLS group: {0}")]
|
||||
MlsMergeCommitError(#[from] MergeCommitError<MemoryKeyStoreError>),
|
||||
#[error("Error processing unverified message: {0}")]
|
||||
MlsProcessMessageError(#[from] ProcessMessageError),
|
||||
#[error("Error while creating message: {0}")]
|
||||
MlsCreateMessageError(#[from] CreateMessageError),
|
||||
#[error("Failed to create staged join: {0}")]
|
||||
MlsWelcomeError(#[from] WelcomeError<MemoryKeyStoreError>),
|
||||
#[error("Failed to remove member from MLS group: {0}")]
|
||||
MlsRemoveMemberError(#[from] RemoveMembersError<MemoryKeyStoreError>),
|
||||
#[error("Failed to validate user key package: {0}")]
|
||||
MlsKeyPackageVerificationError(#[from] KeyPackageVerifyError),
|
||||
|
||||
#[error("UTF-8 parsing error: {0}")]
|
||||
Utf8ParsingError(#[from] FromUtf8Error),
|
||||
#[error("UTF-8 string parsing error: {0}")]
|
||||
Utf8StringParsingError(#[from] Utf8Error),
|
||||
|
||||
#[error("JSON processing error: {0}")]
|
||||
JsonError(#[from] serde_json::Error),
|
||||
#[error("Serialization error: {0}")]
|
||||
SerializationError(#[from] tls_codec::Error),
|
||||
|
||||
#[error("Failed to parse address: {0}")]
|
||||
AddressParsingError(#[from] FromHexError),
|
||||
#[error("Failed to parse signer: {0}")]
|
||||
SignerParsingError(#[from] LocalSignerError),
|
||||
|
||||
#[error("Signing error: {0}")]
|
||||
SigningError(#[from] alloy::signers::Error),
|
||||
#[error("I/O error: {0}")]
|
||||
IoError(#[from] std::io::Error),
|
||||
|
||||
#[error("An unknown error occurred: {0}")]
|
||||
UnknownError(anyhow::Error),
|
||||
}
|
||||
|
||||
235
src/main.rs
235
src/main.rs
@@ -1,14 +1,14 @@
|
||||
use alloy::providers::ProviderBuilder;
|
||||
use alloy::{providers::ProviderBuilder, signers::local::PrivateKeySigner};
|
||||
use clap::Parser;
|
||||
use openmls::framing::MlsMessageIn;
|
||||
use std::{error::Error, fs::File, io::Read};
|
||||
use tls_codec::Deserialize;
|
||||
use tokio::sync::mpsc;
|
||||
use std::{error::Error, str::FromStr, sync::Arc};
|
||||
use tokio::sync::{mpsc, Mutex};
|
||||
use tokio_tungstenite::tungstenite::protocol::Message as TokioMessage;
|
||||
use tokio_util::sync::CancellationToken;
|
||||
|
||||
use de_mls::{
|
||||
cli::*,
|
||||
user::{User, UserError},
|
||||
use de_mls::{cli::*, user::User, CliError, UserError};
|
||||
use ds::{
|
||||
chat_client::{ChatClient, ChatMessages},
|
||||
chat_server::ServerMessage,
|
||||
};
|
||||
|
||||
#[tokio::main]
|
||||
@@ -18,26 +18,19 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||
let (cli_tx, mut cli_gr_rx) = mpsc::channel::<Commands>(100);
|
||||
|
||||
let args = Args::parse();
|
||||
let (user_address, wallet, storage_address) = get_user_data(&args)?;
|
||||
|
||||
let client_provider = ProviderBuilder::new()
|
||||
.with_recommended_fillers()
|
||||
.wallet(wallet)
|
||||
.on_http(args.storage_url);
|
||||
|
||||
let signer = PrivateKeySigner::from_str(&args.user_priv_key)?;
|
||||
let user_address = signer.address().to_string();
|
||||
let (client, mut client_recv) =
|
||||
ChatClient::connect("ws://127.0.0.1:8080", user_address.clone()).await?;
|
||||
//// Create user
|
||||
let mut user = User::new(
|
||||
user_address.as_slice(),
|
||||
client_provider.clone(),
|
||||
storage_address,
|
||||
)
|
||||
.await?;
|
||||
let user_n = User::new(&args.user_priv_key, client).await?;
|
||||
let user_arc = Arc::new(Mutex::new(user_n));
|
||||
|
||||
let (messages_tx, messages_rx) = mpsc::channel::<Msg>(100);
|
||||
messages_tx
|
||||
.send(Msg::Input(Message::System(format!(
|
||||
"Hello, {:}",
|
||||
user_address
|
||||
user_address.clone()
|
||||
))))
|
||||
.await?;
|
||||
|
||||
@@ -47,41 +40,118 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||
|
||||
let res_msg_tx = messages_tx.clone();
|
||||
let main_token = token.clone();
|
||||
let user = user_arc.clone();
|
||||
let h2 = tokio::spawn(async move {
|
||||
let (redis_tx, mut redis_rx) = mpsc::channel::<Vec<u8>>(100);
|
||||
loop {
|
||||
tokio::select! {
|
||||
Some(msg) = client_recv.recv() => {
|
||||
if let TokioMessage::Text(text) = msg {
|
||||
if let Ok(chat_message) = serde_json::from_str::<ServerMessage>(&text) {
|
||||
if let ServerMessage::InMessage { from, to, msg } = chat_message {
|
||||
if let Ok(chat_msg) = serde_json::from_str::<ChatMessages>(&msg) {
|
||||
match chat_msg {
|
||||
ChatMessages::Request(req) => {
|
||||
let res = user.as_ref().lock().await.send_responce_on_request(req, &from);
|
||||
if let Err(err) = res {
|
||||
res_msg_tx
|
||||
.send(Msg::Input(Message::Error(err.to_string())))
|
||||
.await.map_err(|err| CliError::SenderError(err.to_string()))?;
|
||||
}
|
||||
},
|
||||
ChatMessages::Response(resp) => {
|
||||
let res = user.as_ref().lock().await.parce_responce(resp).await;
|
||||
if let Err(err) = res {
|
||||
res_msg_tx
|
||||
.send(Msg::Input(Message::Error(err.to_string())))
|
||||
.await.map_err(|err| CliError::SenderError(err.to_string()))?;
|
||||
}
|
||||
},
|
||||
ChatMessages::Welcome(welcome) => {
|
||||
let res = user.as_ref().lock().await.join_group(welcome).await;
|
||||
match res {
|
||||
Ok(mut buf) => {
|
||||
let msg = format!("Succesfully join to the group: {:#?}", buf.1);
|
||||
res_msg_tx.send(Msg::Input(Message::System(msg))).await.map_err(|err| CliError::SenderError(err.to_string()))?;
|
||||
|
||||
let redis_tx = redis_tx.clone();
|
||||
tokio::spawn(async move {
|
||||
while let Ok(msg) = buf.0.recv().await {
|
||||
let bytes: Vec<u8> = msg.value.convert()?;
|
||||
redis_tx.send(bytes).await.map_err(|err| CliError::SenderError(err.to_string()))?;
|
||||
}
|
||||
Ok::<_, CliError>(())
|
||||
});
|
||||
},
|
||||
Err(err) => {
|
||||
res_msg_tx
|
||||
.send(Msg::Input(Message::Error(err.to_string())))
|
||||
.await.map_err(|err| CliError::SenderError(err.to_string()))?;
|
||||
},
|
||||
};
|
||||
},
|
||||
}
|
||||
} else {
|
||||
res_msg_tx
|
||||
.send(Msg::Input(Message::Error(UserError::InvalidChatMessageError.to_string())))
|
||||
.await.map_err(|err| CliError::SenderError(err.to_string()))?;
|
||||
}
|
||||
};
|
||||
} else {
|
||||
res_msg_tx
|
||||
.send(Msg::Input(Message::Error(UserError::InvalidServerMessageError.to_string())))
|
||||
.await.map_err(|err| CliError::SenderError(err.to_string()))?;
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(val) = redis_rx.recv() =>{
|
||||
let res = user.receive_msg(val).await;
|
||||
let res = user.as_ref().lock().await.receive_msg(val).await;
|
||||
match res {
|
||||
Ok(msg) => {
|
||||
match msg {
|
||||
Some(m) => res_msg_tx.send(Msg::Input(Message::Incoming(m.group, m.author, m.message))).await?,
|
||||
Some(m) => res_msg_tx.send(Msg::Input(Message::Incoming(m.group, m.author, m.message))).await.map_err(|err| CliError::SenderError(err.to_string()))?,
|
||||
None => continue
|
||||
}
|
||||
},
|
||||
Err(err) => {
|
||||
res_msg_tx
|
||||
.send(Msg::Input(Message::Error(err.to_string())))
|
||||
.await?;
|
||||
.await.map_err(|err| CliError::SenderError(err.to_string()))?;
|
||||
},
|
||||
};
|
||||
}
|
||||
Some(command) = cli_gr_rx.recv() => {
|
||||
// res_msg_tx.send(Msg::Input(Message::System(format!("Get command: {:?}", command)))).await?;
|
||||
match command {
|
||||
Commands::CreateGroup { group_name } => {
|
||||
let res = user.create_group(group_name.clone()).await;
|
||||
Commands::CreateGroup { group_name, storage_address, storage_url } => {
|
||||
let client_provider = ProviderBuilder::new()
|
||||
.with_recommended_fillers()
|
||||
.wallet(user.as_ref().lock().await.wallet())
|
||||
.on_http(storage_url);
|
||||
let res = user.as_ref().lock().await.connect_to_smart_contract(&storage_address, client_provider).await;
|
||||
match res {
|
||||
Ok(_) => {
|
||||
let msg = format!("Successfully connect to Smart Contract on address {:}\n", storage_address);
|
||||
res_msg_tx.send(Msg::Input(Message::System(msg))).await.map_err(|err| CliError::SenderError(err.to_string()))?;
|
||||
},
|
||||
Err(err) => {
|
||||
res_msg_tx
|
||||
.send(Msg::Input(Message::Error(err.to_string())))
|
||||
.await.map_err(|err| CliError::SenderError(err.to_string()))?;
|
||||
},
|
||||
};
|
||||
|
||||
let res = user.as_ref().lock().await.create_group(group_name.clone()).await;
|
||||
match res {
|
||||
Ok(mut br) => {
|
||||
let msg = format!("Successfully create group: {:?}", group_name.clone());
|
||||
res_msg_tx.send(Msg::Input(Message::System(msg))).await?;
|
||||
res_msg_tx.send(Msg::Input(Message::System(msg))).await.map_err(|err| CliError::SenderError(err.to_string()))?;
|
||||
|
||||
let redis_tx = redis_tx.clone();
|
||||
tokio::spawn(async move {
|
||||
while let Ok(msg) = br.recv().await {
|
||||
let bytes: Vec<u8> = msg.value.convert()?;
|
||||
redis_tx.send(bytes).await?;
|
||||
redis_tx.send(bytes).await.map_err(|err| CliError::SenderError(err.to_string()))?;
|
||||
}
|
||||
Ok::<_, CliError>(())
|
||||
});
|
||||
@@ -89,79 +159,84 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||
Err(err) => {
|
||||
res_msg_tx
|
||||
.send(Msg::Input(Message::Error(err.to_string())))
|
||||
.await?;
|
||||
.await.map_err(|err| CliError::SenderError(err.to_string()))?;
|
||||
},
|
||||
};
|
||||
},
|
||||
Commands::Invite { group_name, user_wallet } => {
|
||||
let res = user.invite(user_wallet, group_name.clone()).await;
|
||||
match res {
|
||||
Ok(_) => {
|
||||
let msg = format!("Invite {:} to the group {:}\n",
|
||||
user_address, group_name
|
||||
);
|
||||
res_msg_tx.send(Msg::Input(Message::System(msg))).await?;
|
||||
},
|
||||
Err(err) => {
|
||||
res_msg_tx
|
||||
.send(Msg::Input(Message::Error(err.to_string())))
|
||||
.await?;
|
||||
},
|
||||
};
|
||||
},
|
||||
Commands::JoinGroup { group_name } => {
|
||||
let mut file = File::open(format!("invite_{group_name}.txt"))?;
|
||||
let mut welcome = String::new();
|
||||
file.read_to_string(&mut welcome).unwrap();
|
||||
Commands::Invite { group_name, users_wallet_addrs } => {
|
||||
let user_clone = user.clone();
|
||||
let res_msg_tx_c = messages_tx.clone();
|
||||
tokio::spawn(async move {
|
||||
for user_wallet in users_wallet_addrs.iter() {
|
||||
let user_clone_ref = user_clone.as_ref();
|
||||
let opt_token =
|
||||
{
|
||||
let mut user_clone_ref_lock = user_clone_ref.lock().await;
|
||||
let res = user_clone_ref_lock.handle_send_req(user_wallet, group_name.clone()).await;
|
||||
match res {
|
||||
Ok(token) => {
|
||||
token
|
||||
},
|
||||
Err(err) => {
|
||||
res_msg_tx_c
|
||||
.send(Msg::Input(Message::Error(err.to_string())))
|
||||
.await.map_err(|err| CliError::SenderError(err.to_string()))?;
|
||||
None
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
let wbytes = hex::decode(welcome).unwrap();
|
||||
let welc = MlsMessageIn::tls_deserialize_bytes(wbytes).unwrap();
|
||||
let welcome = welc.into_welcome();
|
||||
if welcome.is_some() {
|
||||
let res = user.join_group(welcome.unwrap()).await;
|
||||
match opt_token {
|
||||
Some(token) => token.cancelled().await,
|
||||
None => return Err(CliError::TokenCancellingError),
|
||||
};
|
||||
|
||||
{
|
||||
let mut user_clone_ref_lock = user_clone.as_ref().lock().await;
|
||||
user_clone_ref_lock.contacts.future_req.remove(user_wallet);
|
||||
let res = user_clone_ref_lock.add_user_to_acl(user_wallet).await;
|
||||
if let Err(err) = res {
|
||||
res_msg_tx_c
|
||||
.send(Msg::Input(Message::Error(err.to_string())))
|
||||
.await.map_err(|err| CliError::SenderError(err.to_string()))?;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let res = user_clone.as_ref().lock().await.invite(users_wallet_addrs.clone(), group_name.clone()).await;
|
||||
match res {
|
||||
Ok(mut buf) => {
|
||||
let msg = format!("Succesfully join to the group: {:#?}", buf.1);
|
||||
res_msg_tx.send(Msg::Input(Message::System(msg))).await?;
|
||||
|
||||
let redis_tx = redis_tx.clone();
|
||||
tokio::spawn(async move {
|
||||
while let Ok(msg) = buf.0.recv().await {
|
||||
let bytes: Vec<u8> = msg.value.convert()?;
|
||||
redis_tx.send(bytes).await?;
|
||||
}
|
||||
Ok::<_, CliError>(())
|
||||
});
|
||||
Ok(_) => {
|
||||
let msg = format!("Invite {:?} to the group {:}\n",
|
||||
users_wallet_addrs, group_name
|
||||
);
|
||||
res_msg_tx_c.send(Msg::Input(Message::System(msg))).await.map_err(|err| CliError::SenderError(err.to_string()))?;
|
||||
},
|
||||
Err(err) => {
|
||||
res_msg_tx
|
||||
res_msg_tx_c
|
||||
.send(Msg::Input(Message::Error(err.to_string())))
|
||||
.await?;
|
||||
.await.map_err(|err| CliError::SenderError(err.to_string()))?;
|
||||
},
|
||||
};
|
||||
} else {
|
||||
res_msg_tx
|
||||
.send(Msg::Input(Message::Error(UserError::EmptyWelcomeMessageError.to_string())))
|
||||
.await?;
|
||||
}
|
||||
|
||||
Ok::<_, CliError>(())
|
||||
});
|
||||
},
|
||||
Commands::SendMessage { group_name, msg } => {
|
||||
let message = msg.join(" ");
|
||||
let res = user.send_msg(&message, group_name.clone(), user.identity.to_string()).await;
|
||||
let res = user.as_ref().lock().await.send_msg(&message, group_name.clone(), user_address.clone()).await;
|
||||
match res {
|
||||
Ok(_) => {
|
||||
res_msg_tx.send(Msg::Input(Message::Mine(group_name, user.identity.to_string(), message ))).await?;
|
||||
res_msg_tx.send(Msg::Input(Message::Mine(group_name, user_address.clone(), message ))).await.map_err(|err| CliError::SenderError(err.to_string()))?;
|
||||
},
|
||||
Err(err) => {
|
||||
res_msg_tx
|
||||
.send(Msg::Input(Message::Error(err.to_string())))
|
||||
.await?;
|
||||
.await.map_err(|err| CliError::SenderError(err.to_string()))?;
|
||||
},
|
||||
};
|
||||
},
|
||||
Commands::Exit => {
|
||||
res_msg_tx.send(Msg::Input(Message::System("Bye!".to_string()))).await?;
|
||||
res_msg_tx.send(Msg::Input(Message::System("Bye!".to_string()))).await.map_err(|err| CliError::SenderError(err.to_string()))?;
|
||||
break
|
||||
},
|
||||
}
|
||||
@@ -170,7 +245,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||
break;
|
||||
}
|
||||
else => {
|
||||
res_msg_tx.send(Msg::Input(Message::System("Something went wrong".to_string()))).await?;
|
||||
res_msg_tx.send(Msg::Input(Message::System("Something went wrong".to_string()))).await.map_err(|err| CliError::SenderError(err.to_string()))?;
|
||||
break
|
||||
}
|
||||
};
|
||||
|
||||
317
src/user.rs
317
src/user.rs
@@ -1,35 +1,31 @@
|
||||
use alloy::{
|
||||
hex::{self, FromHexError, ToHexExt},
|
||||
network::Network,
|
||||
hex::{self},
|
||||
network::{EthereumWallet, Network},
|
||||
primitives::Address,
|
||||
providers::Provider,
|
||||
signers::{local::PrivateKeySigner, SignerSync},
|
||||
transports::Transport,
|
||||
};
|
||||
use fred::types::Message;
|
||||
use openmls::{group::*, prelude::*};
|
||||
use openmls_rust_crypto::MemoryKeyStoreError;
|
||||
use std::{
|
||||
borrow::BorrowMut,
|
||||
cell::RefCell,
|
||||
collections::HashMap,
|
||||
fmt::Display,
|
||||
fs::File,
|
||||
io::Write,
|
||||
str::{from_utf8, FromStr, Utf8Error},
|
||||
string::FromUtf8Error,
|
||||
str::{from_utf8, FromStr},
|
||||
};
|
||||
use tokio::sync::broadcast::Receiver;
|
||||
use tokio_util::sync::CancellationToken;
|
||||
|
||||
use ds::ds::*;
|
||||
use ds::{
|
||||
chat_client::{ChatClient, ReqMessageType, RequestMLSPayload, ResponseMLSPayload},
|
||||
ds::*,
|
||||
};
|
||||
use mls_crypto::openmls_provider::*;
|
||||
use sc_key_store::{sc_ks::ScKeyStorage, *};
|
||||
// use waku_bindings::*;
|
||||
//
|
||||
|
||||
use crate::conversation::*;
|
||||
use crate::identity::{Identity, IdentityError};
|
||||
|
||||
const NUMBER_OF_KP: usize = 2;
|
||||
use crate::{contact::ContactsList, conversation::*};
|
||||
use crate::{identity::Identity, UserError};
|
||||
|
||||
pub struct Group {
|
||||
group_name: String,
|
||||
@@ -49,8 +45,10 @@ pub struct User<T, P, N> {
|
||||
pub identity: Identity,
|
||||
pub groups: HashMap<String, Group>,
|
||||
provider: MlsCryptoProvider,
|
||||
sc_ks: ScKeyStorage<T, P, N>,
|
||||
// pub(crate) contacts: HashMap<Vec<u8>, WakuPeers>,
|
||||
eth_signer: PrivateKeySigner,
|
||||
// we don't need on-chain connection if we don't create a group
|
||||
sc_ks: Option<ScKeyStorage<T, P, N>>,
|
||||
pub contacts: ContactsList,
|
||||
}
|
||||
|
||||
impl<T, P, N> User<T, P, N>
|
||||
@@ -60,24 +58,38 @@ where
|
||||
N: Network,
|
||||
{
|
||||
/// Create a new user with the given name and a fresh set of credentials.
|
||||
pub async fn new(
|
||||
user_wallet_address: &[u8],
|
||||
provider: P,
|
||||
sc_storage_address: Address,
|
||||
) -> Result<Self, UserError> {
|
||||
pub async fn new(user_eth_priv_key: &str, chat_client: ChatClient) -> Result<Self, UserError> {
|
||||
let signer = PrivateKeySigner::from_str(user_eth_priv_key)?;
|
||||
let user_address = signer.address();
|
||||
|
||||
let crypto = MlsCryptoProvider::default();
|
||||
let id = Identity::new(CIPHERSUITE, &crypto, user_wallet_address, NUMBER_OF_KP)?;
|
||||
let mut user = User {
|
||||
let id = Identity::new(CIPHERSUITE, &crypto, user_address.as_slice())?;
|
||||
let user = User {
|
||||
groups: HashMap::new(),
|
||||
identity: id,
|
||||
eth_signer: signer,
|
||||
provider: crypto,
|
||||
sc_ks: ScKeyStorage::new(provider, sc_storage_address),
|
||||
// contacts: HashMap::new(),
|
||||
sc_ks: None,
|
||||
contacts: ContactsList::new(chat_client).await?,
|
||||
};
|
||||
user.register().await?;
|
||||
Ok(user)
|
||||
}
|
||||
|
||||
pub async fn connect_to_smart_contract(
|
||||
&mut self,
|
||||
sc_storage_address: &str,
|
||||
provider: P,
|
||||
) -> Result<(), UserError> {
|
||||
let storage_address = Address::from_str(sc_storage_address)?;
|
||||
self.sc_ks = Some(ScKeyStorage::new(provider, storage_address));
|
||||
self.sc_ks
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.add_user(&self.identity.to_string())
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn create_group(
|
||||
&mut self,
|
||||
group_name: String,
|
||||
@@ -85,7 +97,7 @@ where
|
||||
let group_id = group_name.as_bytes();
|
||||
|
||||
if self.groups.contains_key(&group_name) {
|
||||
return Err(UserError::AlreadyExistedGroupError(group_name));
|
||||
return Err(UserError::GroupAlreadyExistsError(group_name));
|
||||
}
|
||||
|
||||
let group_config = MlsGroupConfig::builder()
|
||||
@@ -100,7 +112,7 @@ where
|
||||
self.identity.credential_with_key.clone(),
|
||||
)?;
|
||||
|
||||
let (rc, broadcaster) = RClient::new_for_group(group_name.clone()).await?;
|
||||
let (rc, broadcaster) = RClient::new_with_group(group_name.clone()).await?;
|
||||
let group = Group {
|
||||
group_name: group_name.clone(),
|
||||
conversation: Conversation::default(),
|
||||
@@ -110,76 +122,84 @@ where
|
||||
// content_topics: Vec::new(),
|
||||
};
|
||||
|
||||
self.groups.insert(group_name, group);
|
||||
self.groups.insert(group_name.clone(), group);
|
||||
self.contacts
|
||||
.insert_group2sc(group_name, self.sc_address()?)?;
|
||||
Ok(broadcaster)
|
||||
}
|
||||
|
||||
async fn register(&mut self) -> Result<(), UserError> {
|
||||
let ukp = self.key_packages();
|
||||
self.sc_ks
|
||||
.borrow_mut()
|
||||
.add_user(ukp.clone(), self.identity.signature_pub_key().as_slice())
|
||||
.await?;
|
||||
pub async fn add_user_to_acl(&mut self, user_address: &str) -> Result<(), UserError> {
|
||||
if self.sc_ks.is_none() {
|
||||
return Err(UserError::MissingSmartContractConnection);
|
||||
}
|
||||
self.sc_ks.as_mut().unwrap().add_user(user_address).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Get the key packages fo this user.
|
||||
pub fn key_packages(&self) -> UserKeyPackages {
|
||||
let mut kpgs = self.identity.kp.clone();
|
||||
UserKeyPackages(kpgs.drain().collect::<Vec<(Vec<u8>, KeyPackage)>>())
|
||||
pub async fn restore_key_package(
|
||||
&mut self,
|
||||
mut signed_kp: &[u8],
|
||||
) -> Result<KeyPackage, UserError> {
|
||||
if self.sc_ks.is_none() {
|
||||
return Err(UserError::MissingSmartContractConnection);
|
||||
}
|
||||
|
||||
let key_package_in = KeyPackageIn::tls_deserialize(&mut signed_kp)?;
|
||||
let key_package =
|
||||
key_package_in.validate(self.provider.crypto(), ProtocolVersion::Mls10)?;
|
||||
|
||||
Ok(key_package)
|
||||
}
|
||||
|
||||
pub async fn invite(
|
||||
&mut self,
|
||||
user_wallet: String,
|
||||
users: Vec<String>,
|
||||
group_name: String,
|
||||
) -> Result<(), UserError> {
|
||||
let user_address = Address::from_str(&user_wallet)?;
|
||||
let user_wallet_address = user_address.as_slice();
|
||||
// First we need to get the key package for {id} from the DS.
|
||||
if !self
|
||||
.sc_ks
|
||||
.borrow_mut()
|
||||
.does_user_exist(user_wallet_address)
|
||||
.await?
|
||||
{
|
||||
return Err(UserError::UnknownUserError);
|
||||
if self.sc_ks.is_none() {
|
||||
return Err(UserError::MissingSmartContractConnection);
|
||||
}
|
||||
|
||||
// Reclaim a key package from the server
|
||||
let joiner_key_package = self
|
||||
.sc_ks
|
||||
.borrow_mut()
|
||||
.get_avaliable_user_kp(user_wallet_address, &self.provider)
|
||||
let users_for_invite = self
|
||||
.contacts
|
||||
.prepare_joiners(users.clone(), group_name.clone())
|
||||
.await?;
|
||||
|
||||
let mut joiners_key_package: Vec<KeyPackage> = Vec::with_capacity(users_for_invite.len());
|
||||
let mut user_addrs = Vec::with_capacity(users_for_invite.len());
|
||||
for (user_addr, user_kp) in users_for_invite {
|
||||
joiners_key_package.push(self.restore_key_package(&user_kp).await?);
|
||||
user_addrs.push(user_addr);
|
||||
}
|
||||
|
||||
// Build a proposal with this key package and do the MLS bits.
|
||||
let group = match self.groups.get_mut(&group_name) {
|
||||
Some(g) => g,
|
||||
None => return Err(UserError::UnknownGroupError(group_name)),
|
||||
None => return Err(UserError::GroupNotFoundError(group_name)),
|
||||
};
|
||||
|
||||
let (out_messages, welcome, _group_info) = group.mls_group.borrow_mut().add_members(
|
||||
&self.provider,
|
||||
&self.identity.signer,
|
||||
&[joiner_key_package],
|
||||
&joiners_key_package,
|
||||
)?;
|
||||
|
||||
group
|
||||
.rc_client
|
||||
.msg_send(out_messages, self.identity.to_string())
|
||||
.msg_send(
|
||||
out_messages.tls_serialize_detached()?,
|
||||
self.identity.to_string(),
|
||||
group_name,
|
||||
)
|
||||
.await?;
|
||||
// Second, process the invitation on our end.
|
||||
group
|
||||
.mls_group
|
||||
.borrow_mut()
|
||||
.merge_pending_commit(&self.provider)?;
|
||||
// Put sending welcome by p2p here
|
||||
let bytes = welcome.tls_serialize_detached()?;
|
||||
let string = bytes.encode_hex();
|
||||
|
||||
let mut file = File::create(format!("invite_{group_name}.txt"))?;
|
||||
file.write_all(string.as_bytes())?;
|
||||
// Send welcome by p2p
|
||||
self.contacts
|
||||
.send_welcome_msg_to_users(self.identity.to_string(), user_addrs, welcome)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -200,7 +220,7 @@ where
|
||||
MlsMessageInBody::PublicMessage(message) => {
|
||||
self.process_protocol_msg(message.into())?
|
||||
}
|
||||
_ => return Err(UserError::MessageTypeError),
|
||||
_ => return Err(UserError::UnsupportedMessageType),
|
||||
};
|
||||
Ok(msg)
|
||||
}
|
||||
@@ -212,7 +232,7 @@ where
|
||||
let group_name = from_utf8(message.group_id().as_slice())?.to_string();
|
||||
let group = match self.groups.get_mut(&group_name) {
|
||||
Some(g) => g,
|
||||
None => return Err(UserError::UnknownGroupError(group_name)),
|
||||
None => return Err(UserError::GroupNotFoundError(group_name)),
|
||||
};
|
||||
let mut mls_group = group.mls_group.borrow_mut();
|
||||
|
||||
@@ -269,7 +289,7 @@ where
|
||||
) -> Result<(), UserError> {
|
||||
let group = match self.groups.get_mut(&group_name) {
|
||||
Some(g) => g,
|
||||
None => return Err(UserError::UnknownGroupError(group_name)),
|
||||
None => return Err(UserError::GroupNotFoundError(group_name)),
|
||||
};
|
||||
|
||||
let message_out = group.mls_group.borrow_mut().create_message(
|
||||
@@ -278,25 +298,36 @@ where
|
||||
msg.as_bytes(),
|
||||
)?;
|
||||
|
||||
group.rc_client.msg_send(message_out, sender).await?;
|
||||
group
|
||||
.rc_client
|
||||
.msg_send(message_out.tls_serialize_detached()?, sender, group_name)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn join_group(
|
||||
&mut self,
|
||||
welcome: Welcome,
|
||||
welcome: String,
|
||||
) -> Result<(Receiver<Message>, String), UserError> {
|
||||
let wbytes = hex::decode(welcome).unwrap();
|
||||
let welc = MlsMessageIn::tls_deserialize_bytes(wbytes).unwrap();
|
||||
let welcome = welc.into_welcome();
|
||||
if welcome.is_none() {
|
||||
return Err(UserError::EmptyWelcomeMessageError);
|
||||
}
|
||||
|
||||
let group_config = MlsGroupConfig::builder()
|
||||
.use_ratchet_tree_extension(true)
|
||||
.build();
|
||||
|
||||
// TODO: After we move from openmls, we will have to delete the used key package here ourselves.
|
||||
let mls_group = MlsGroup::new_from_welcome(&self.provider, &group_config, welcome, None)?;
|
||||
let mls_group =
|
||||
MlsGroup::new_from_welcome(&self.provider, &group_config, welcome.unwrap(), None)?;
|
||||
|
||||
let group_id = mls_group.group_id().to_vec();
|
||||
let group_name = String::from_utf8(group_id)?;
|
||||
|
||||
let (rc, br) = RClient::new_for_group(group_name.clone()).await?;
|
||||
let (rc, br) = RClient::new_with_group(group_name.clone()).await?;
|
||||
let group = Group {
|
||||
group_name: group_name.clone(),
|
||||
conversation: Conversation::default(),
|
||||
@@ -305,7 +336,7 @@ where
|
||||
};
|
||||
|
||||
match self.groups.insert(group_name.clone(), group) {
|
||||
Some(old) => Err(UserError::AlreadyExistedGroupError(old.group_name)),
|
||||
Some(old) => Err(UserError::GroupAlreadyExistsError(old.group_name)),
|
||||
None => Ok((br, group_name)),
|
||||
}
|
||||
}
|
||||
@@ -344,7 +375,7 @@ where
|
||||
group_name: String,
|
||||
) -> Result<Option<Vec<ConversationMessage>>, UserError> {
|
||||
self.groups.get(&group_name).map_or_else(
|
||||
|| Err(UserError::UnknownGroupError(group_name)),
|
||||
|| Err(UserError::GroupNotFoundError(group_name)),
|
||||
|g| {
|
||||
Ok(g.conversation
|
||||
.get(100)
|
||||
@@ -356,7 +387,7 @@ where
|
||||
pub fn group_members(&self, group_name: String) -> Result<Vec<String>, UserError> {
|
||||
let group = match self.groups.get(&group_name) {
|
||||
Some(g) => g,
|
||||
None => return Err(UserError::UnknownGroupError(group_name)),
|
||||
None => return Err(UserError::GroupNotFoundError(group_name)),
|
||||
};
|
||||
Ok(group.group_members(self.identity.signature_pub_key().as_slice()))
|
||||
}
|
||||
@@ -367,6 +398,86 @@ where
|
||||
}
|
||||
Ok(self.groups.keys().map(|k| k.to_owned()).collect())
|
||||
}
|
||||
|
||||
pub fn wallet(&self) -> EthereumWallet {
|
||||
EthereumWallet::from(self.eth_signer.clone())
|
||||
}
|
||||
|
||||
fn sign(&self, msg: String) -> Result<String, UserError> {
|
||||
let signature = self.eth_signer.sign_message_sync(msg.as_bytes())?;
|
||||
let res = serde_json::to_string(&signature)?;
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
pub fn send_responce_on_request(
|
||||
&mut self,
|
||||
req: RequestMLSPayload,
|
||||
user_address: &str,
|
||||
) -> Result<(), UserError> {
|
||||
let self_address = self.identity.to_string();
|
||||
match req.msg_type {
|
||||
ReqMessageType::InviteToGroup => {
|
||||
let signature = self.sign(req.msg_to_sign())?;
|
||||
let key_package = self
|
||||
.identity
|
||||
.generate_key_package(CIPHERSUITE, &self.provider)?;
|
||||
let resp = ResponseMLSPayload::new(
|
||||
signature,
|
||||
self_address.clone(),
|
||||
req.group_name(),
|
||||
key_package.tls_serialize_detached()?,
|
||||
);
|
||||
self.contacts
|
||||
.send_resp_msg_to_user(self_address, user_address, resp)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
ReqMessageType::RemoveFromGroup => Ok(()),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn parce_responce(&mut self, resp: ResponseMLSPayload) -> Result<(), UserError> {
|
||||
if self.sc_ks.is_none() {
|
||||
return Err(UserError::MissingSmartContractConnection);
|
||||
}
|
||||
let group_name = resp.group_name.clone();
|
||||
let sc_address = self.contacts.group2sc(group_name.clone())?;
|
||||
let (user_wallet, kp) = resp.validate(sc_address, group_name.clone())?;
|
||||
|
||||
self.contacts
|
||||
.add_key_package_to_contact(&user_wallet, kp, group_name.clone())
|
||||
.await?;
|
||||
|
||||
self.contacts.handle_response(&user_wallet)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn sc_address(&self) -> Result<String, UserError> {
|
||||
if self.sc_ks.is_none() {
|
||||
return Err(UserError::MissingSmartContractConnection);
|
||||
}
|
||||
Ok(self.sc_ks.as_ref().unwrap().sc_adsress())
|
||||
}
|
||||
|
||||
pub async fn handle_send_req(
|
||||
&mut self,
|
||||
user_wallet: &str,
|
||||
group_name: String,
|
||||
) -> Result<Option<CancellationToken>, UserError> {
|
||||
if !self.contacts.does_user_in_contacts(user_wallet).await {
|
||||
self.contacts.add_new_contact(user_wallet).await?;
|
||||
}
|
||||
self.contacts
|
||||
.send_msg_req(
|
||||
self.identity.to_string(),
|
||||
user_wallet.to_owned(),
|
||||
group_name,
|
||||
ReqMessageType::InviteToGroup,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
Ok(self.contacts.future_req.get(user_wallet).cloned())
|
||||
}
|
||||
}
|
||||
|
||||
impl Group {
|
||||
@@ -399,59 +510,3 @@ pub enum GroupError {
|
||||
#[error("Unknown group member : {0}")]
|
||||
UnknownGroupMemberError(String),
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum UserError {
|
||||
#[error("Unknown group: {0}")]
|
||||
UnknownGroupError(String),
|
||||
#[error("Group already exist: {0}")]
|
||||
AlreadyExistedGroupError(String),
|
||||
#[error("Unsupported message type")]
|
||||
MessageTypeError,
|
||||
#[error("Unknown user")]
|
||||
UnknownUserError,
|
||||
#[error("Empty welcome message")]
|
||||
EmptyWelcomeMessageError,
|
||||
|
||||
#[error("Delivery Service error: {0}")]
|
||||
DeliveryServiceError(#[from] DeliveryServiceError),
|
||||
#[error(transparent)]
|
||||
GroupError(#[from] GroupError),
|
||||
#[error("Key Store error: {0}")]
|
||||
KeyStoreError(#[from] KeyStoreError),
|
||||
#[error("Identity error: {0}")]
|
||||
IdentityError(#[from] IdentityError),
|
||||
|
||||
#[error("Something wrong while creating Mls group: {0}")]
|
||||
MlsGroupCreationError(#[from] NewGroupError<MemoryKeyStoreError>),
|
||||
#[error("Something wrong while adding member to Mls group: {0}")]
|
||||
MlsAddMemberError(#[from] AddMembersError<MemoryKeyStoreError>),
|
||||
#[error("Something wrong while merging pending commit: {0}")]
|
||||
MlsMergePendingCommitError(#[from] MergePendingCommitError<MemoryKeyStoreError>),
|
||||
#[error("Something wrong while merging commit: {0}")]
|
||||
MlsMergeCommitError(#[from] MergeCommitError<MemoryKeyStoreError>),
|
||||
#[error("Error processing unverified message: {0}")]
|
||||
MlsProcessMessageError(#[from] ProcessMessageError),
|
||||
#[error("Something wrong while creating message: {0}")]
|
||||
MlsCreateMessageError(#[from] CreateMessageError),
|
||||
#[error("Failed to create staged join: {0}")]
|
||||
MlsWelcomeError(#[from] WelcomeError<MemoryKeyStoreError>),
|
||||
#[error("Failed to remove member from group: {0}")]
|
||||
MlsRemoveMembersError(#[from] RemoveMembersError<MemoryKeyStoreError>),
|
||||
|
||||
#[error("Parse String UTF8 error: {0}")]
|
||||
ParseUTF8Error(#[from] FromUtf8Error),
|
||||
#[error("Parse str UTF8 error: {0}")]
|
||||
ParseStrUTF8Error(#[from] Utf8Error),
|
||||
#[error("Json error: {0}")]
|
||||
JsonError(#[from] serde_json::Error),
|
||||
#[error("Serialization problem: {0}")]
|
||||
TlsError(#[from] tls_codec::Error),
|
||||
#[error("Unable to parce the address: {0}")]
|
||||
AlloyFromHexError(#[from] FromHexError),
|
||||
#[error("Write to stdout error")]
|
||||
IoError(#[from] std::io::Error),
|
||||
|
||||
#[error("Unknown error: {0}")]
|
||||
Other(anyhow::Error),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user