Skip to content

Commit

Permalink
Update add member flow (#26)
Browse files Browse the repository at this point in the history
* don't work async, prepare to remove

* new flow works good

* refactor
  • Loading branch information
seemenkina authored Aug 15, 2024
1 parent d473de2 commit ea08e56
Show file tree
Hide file tree
Showing 31 changed files with 4,622 additions and 7,229 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Expand Down
89 changes: 46 additions & 43 deletions crates/bindings/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"",
);
Expand All @@ -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,
Expand All @@ -48,45 +50,46 @@ 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,
P: alloy_contract::private::Provider<T, N>,
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,
Expand All @@ -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,
Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down
205 changes: 84 additions & 121 deletions crates/bindings/src/deploy.rs

Large diffs are not rendered by default.

Loading

0 comments on commit ea08e56

Please sign in to comment.