Skip to content

Commit 96acf31

Browse files
committed
fmt
1 parent 3c80943 commit 96acf31

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+14323
-32450
lines changed

components/eth-trigger-weather/src/lib.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
11
mod trigger;
22
use layer_wasi::{
33
bindings::world::{Guest, TriggerAction},
4-
export_layer_trigger_world, wasi::{Request, WasiPollable},
4+
export_layer_trigger_world,
5+
wasi::{Request, WasiPollable},
56
};
6-
use wstd::runtime::{block_on, Reactor};
7-
use trigger::{decode_trigger_event, encode_trigger_output};
87
use serde::{Deserialize, Serialize};
8+
use trigger::{decode_trigger_event, encode_trigger_output};
9+
use wstd::runtime::{block_on, Reactor};
910

1011
struct Component;
1112

1213
impl Guest for Component {
1314
fn run(trigger_action: TriggerAction) -> std::result::Result<Vec<u8>, String> {
14-
let (trigger_id, req) = decode_trigger_event(trigger_action.data).map_err(|e| e.to_string())?;
15+
let (trigger_id, req) =
16+
decode_trigger_event(trigger_action.data).map_err(|e| e.to_string())?;
1517

1618
if !req.contains(&b',') {
1719
return Err("Input must be in the format of City,State".to_string());
1820
}
1921
let input = std::str::from_utf8(&req).unwrap(); // TODO:
2022

2123
// open weather API, not wavs specific
22-
let api_key = std::env::var("WAVS_ENV_OPEN_WEATHER_API_KEY").or(Err("missing env var `WAVS_ENV_OPEN_WEATHER_API_KEY`".to_string()))?;
24+
let api_key = std::env::var("WAVS_ENV_OPEN_WEATHER_API_KEY")
25+
.or(Err("missing env var `WAVS_ENV_OPEN_WEATHER_API_KEY`".to_string()))?;
2326

2427
let res = block_on(move |reactor| async move {
25-
let loc: Result<LocDataNested, String> = get_location(&reactor, api_key.clone(), input).await;
28+
let loc: Result<LocDataNested, String> =
29+
get_location(&reactor, api_key.clone(), input).await;
2630

2731
let location = match loc {
2832
Ok(data) => data,
@@ -47,18 +51,14 @@ impl Guest for Component {
4751
}
4852
}
4953

50-
5154
async fn get_location(
5255
reactor: &Reactor,
5356
app_key: String,
5457
loc_input: &str,
5558
) -> Result<LocDataNested, String> {
5659
let url: &str = "http://api.openweathermap.org/geo/1.0/direct";
5760
let loc_input_formatted = format!("{},US", loc_input);
58-
let params = [
59-
("q", loc_input_formatted.as_str()),
60-
("appid", app_key.as_str()),
61-
];
61+
let params = [("q", loc_input_formatted.as_str()), ("appid", app_key.as_str())];
6262

6363
let url_with_params = reqwest::Url::parse_with_params(url, &params).unwrap();
6464
let mut req = Request::get(url_with_params.as_str())?;

components/eth-trigger-weather/src/trigger.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// Helpers to work with "trigger id" flows - which our example components do
22
use alloy_sol_types::SolValue;
33
use anyhow::Result;
4+
use example_submit::ISimpleSubmit::DataWithId;
5+
use example_trigger::{NewTrigger, TriggerInfo};
46
use layer_wasi::{
57
bindings::compat::{TriggerData, TriggerDataEthContractEvent},
68
ethereum::WasiProvider,
79
};
8-
use example_submit::ISimpleSubmit::DataWithId;
9-
use example_trigger::{NewTrigger, TriggerInfo};
1010

1111
pub fn decode_trigger_event(trigger_data: TriggerData) -> Result<(u64, Vec<u8>)> {
1212
match trigger_data {
@@ -24,14 +24,9 @@ pub fn decode_trigger_event(trigger_data: TriggerData) -> Result<(u64, Vec<u8>)>
2424
}
2525

2626
pub fn encode_trigger_output(trigger_id: u64, output: impl AsRef<[u8]>) -> Vec<u8> {
27-
DataWithId {
28-
triggerId: trigger_id,
29-
data: output.as_ref().to_vec().into(),
30-
}
31-
.abi_encode()
27+
DataWithId { triggerId: trigger_id, data: output.as_ref().to_vec().into() }.abi_encode()
3228
}
3329

34-
3530
mod example_trigger {
3631
use alloy_sol_macro::sol;
3732
pub use ISimpleTrigger::TriggerInfo;

crates/bindings/src/addressupgradeable.rs

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub mod AddressUpgradeable {
4242
use alloy::contract as alloy_contract;
4343
/**Creates a new wrapper around an on-chain [`AddressUpgradeable`](self) contract instance.
4444
45-
See the [wrapper's documentation](`AddressUpgradeableInstance`) for more details.*/
45+
See the [wrapper's documentation](`AddressUpgradeableInstance`) for more details.*/
4646
#[inline]
4747
pub const fn new<
4848
T: alloy_contract::private::Transport + ::core::clone::Clone,
@@ -56,45 +56,46 @@ See the [wrapper's documentation](`AddressUpgradeableInstance`) for more details
5656
}
5757
/**Deploys this contract using the given `provider` and constructor arguments, if any.
5858
59-
Returns a new instance of the contract, if the deployment was successful.
59+
Returns a new instance of the contract, if the deployment was successful.
6060
61-
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
61+
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
6262
#[inline]
6363
pub fn deploy<
6464
T: alloy_contract::private::Transport + ::core::clone::Clone,
6565
P: alloy_contract::private::Provider<T, N>,
6666
N: alloy_contract::private::Network,
6767
>(
6868
provider: P,
69-
) -> impl ::core::future::Future<
70-
Output = alloy_contract::Result<AddressUpgradeableInstance<T, P, N>>,
71-
> {
69+
) -> impl ::core::future::Future<Output = alloy_contract::Result<AddressUpgradeableInstance<T, P, N>>>
70+
{
7271
AddressUpgradeableInstance::<T, P, N>::deploy(provider)
7372
}
7473
/**Creates a `RawCallBuilder` for deploying this contract using the given `provider`
75-
and constructor arguments, if any.
74+
and constructor arguments, if any.
7675
77-
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
78-
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
76+
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
77+
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
7978
#[inline]
8079
pub fn deploy_builder<
8180
T: alloy_contract::private::Transport + ::core::clone::Clone,
8281
P: alloy_contract::private::Provider<T, N>,
8382
N: alloy_contract::private::Network,
84-
>(provider: P) -> alloy_contract::RawCallBuilder<T, P, N> {
83+
>(
84+
provider: P,
85+
) -> alloy_contract::RawCallBuilder<T, P, N> {
8586
AddressUpgradeableInstance::<T, P, N>::deploy_builder(provider)
8687
}
8788
/**A [`AddressUpgradeable`](self) instance.
8889
89-
Contains type-safe methods for interacting with an on-chain instance of the
90-
[`AddressUpgradeable`](self) contract located at a given `address`, using a given
91-
provider `P`.
90+
Contains type-safe methods for interacting with an on-chain instance of the
91+
[`AddressUpgradeable`](self) contract located at a given `address`, using a given
92+
provider `P`.
9293
93-
If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!)
94-
documentation on how to provide it), the `deploy` and `deploy_builder` methods can
95-
be used to deploy a new instance of the contract.
94+
If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!)
95+
documentation on how to provide it), the `deploy` and `deploy_builder` methods can
96+
be used to deploy a new instance of the contract.
9697
97-
See the [module-level documentation](self) for all the available methods.*/
98+
See the [module-level documentation](self) for all the available methods.*/
9899
#[derive(Clone)]
99100
pub struct AddressUpgradeableInstance<T, P, N = alloy_contract::private::Ethereum> {
100101
address: alloy_sol_types::private::Address,
@@ -111,29 +112,23 @@ See the [module-level documentation](self) for all the available methods.*/
111112
/// Instantiation and getters/setters.
112113
#[automatically_derived]
113114
impl<
114-
T: alloy_contract::private::Transport + ::core::clone::Clone,
115-
P: alloy_contract::private::Provider<T, N>,
116-
N: alloy_contract::private::Network,
117-
> AddressUpgradeableInstance<T, P, N> {
115+
T: alloy_contract::private::Transport + ::core::clone::Clone,
116+
P: alloy_contract::private::Provider<T, N>,
117+
N: alloy_contract::private::Network,
118+
> AddressUpgradeableInstance<T, P, N>
119+
{
118120
/**Creates a new wrapper around an on-chain [`AddressUpgradeable`](self) contract instance.
119121
120-
See the [wrapper's documentation](`AddressUpgradeableInstance`) for more details.*/
122+
See the [wrapper's documentation](`AddressUpgradeableInstance`) for more details.*/
121123
#[inline]
122-
pub const fn new(
123-
address: alloy_sol_types::private::Address,
124-
provider: P,
125-
) -> Self {
126-
Self {
127-
address,
128-
provider,
129-
_network_transport: ::core::marker::PhantomData,
130-
}
124+
pub const fn new(address: alloy_sol_types::private::Address, provider: P) -> Self {
125+
Self { address, provider, _network_transport: ::core::marker::PhantomData }
131126
}
132127
/**Deploys this contract using the given `provider` and constructor arguments, if any.
133128
134-
Returns a new instance of the contract, if the deployment was successful.
129+
Returns a new instance of the contract, if the deployment was successful.
135130
136-
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
131+
For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
137132
#[inline]
138133
pub async fn deploy(
139134
provider: P,
@@ -143,10 +138,10 @@ For more fine-grained control over the deployment process, use [`deploy_builder`
143138
Ok(Self::new(contract_address, call_builder.provider))
144139
}
145140
/**Creates a `RawCallBuilder` for deploying this contract using the given `provider`
146-
and constructor arguments, if any.
141+
and constructor arguments, if any.
147142
148-
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
149-
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
143+
This is a simple wrapper around creating a `RawCallBuilder` with the data set to
144+
the bytecode concatenated with the constructor's ABI-encoded arguments.*/
150145
#[inline]
151146
pub fn deploy_builder(provider: P) -> alloy_contract::RawCallBuilder<T, P, N> {
152147
alloy_contract::RawCallBuilder::new_raw_deploy(
@@ -189,10 +184,11 @@ the bytecode concatenated with the constructor's ABI-encoded arguments.*/
189184
/// Function calls.
190185
#[automatically_derived]
191186
impl<
192-
T: alloy_contract::private::Transport + ::core::clone::Clone,
193-
P: alloy_contract::private::Provider<T, N>,
194-
N: alloy_contract::private::Network,
195-
> AddressUpgradeableInstance<T, P, N> {
187+
T: alloy_contract::private::Transport + ::core::clone::Clone,
188+
P: alloy_contract::private::Provider<T, N>,
189+
N: alloy_contract::private::Network,
190+
> AddressUpgradeableInstance<T, P, N>
191+
{
196192
/// Creates a new call builder using this contract instance's provider and address.
197193
///
198194
/// Note that the call can be any function call, not just those defined in this
@@ -207,10 +203,11 @@ the bytecode concatenated with the constructor's ABI-encoded arguments.*/
207203
/// Event filters.
208204
#[automatically_derived]
209205
impl<
210-
T: alloy_contract::private::Transport + ::core::clone::Clone,
211-
P: alloy_contract::private::Provider<T, N>,
212-
N: alloy_contract::private::Network,
213-
> AddressUpgradeableInstance<T, P, N> {
206+
T: alloy_contract::private::Transport + ::core::clone::Clone,
207+
P: alloy_contract::private::Provider<T, N>,
208+
N: alloy_contract::private::Network,
209+
> AddressUpgradeableInstance<T, P, N>
210+
{
214211
/// Creates a new event filter using this contract instance's provider and address.
215212
///
216213
/// Note that the type can be any event, not just those defined in this contract.

0 commit comments

Comments
 (0)