Skip to content

Commit a2db050

Browse files
author
Gianmarco Fraccaroli
committed
sdk 0.30.2
1 parent 98c740e commit a2db050

File tree

10 files changed

+34
-23
lines changed

10 files changed

+34
-23
lines changed

Cargo.lock

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ rand = "0.8.5"
3737
rand_chacha = "0.3.1"
3838
dotenvy = "0.15.7"
3939
hex = "0.4.3"
40-
namada_sdk = { git = "https://github.com/anoma/namada", tag = "v0.30.2", default-features = false, features = ["tendermint-rpc", "std", "async-client", "async-send", "download-params"] }
40+
namada_sdk = { git = "https://github.com/anoma/namada", tag = "v0.30.2", default-features = false, features = ["tendermint-rpc", "std", "async-client", "async-send", "download-params", "rand"] }
4141
tendermint-config = "0.34.0"
4242
tendermint-rpc = { version = "0.34.0", features = ["http-client"]}
4343
orion = "0.17.5"

build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ use vergen::EmitBuilder;
44
fn main() -> Result<(), Box<dyn Error>> {
55
EmitBuilder::builder().all_git().emit()?;
66
Ok(())
7-
}
7+
}

src/app.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ use axum::{
1717
use lazy_static::lazy_static;
1818
use namada_sdk::{
1919
args::TxBuilder,
20-
core::types::{address::Address, chain::ChainId, key::RefTo},
2120
io::NullIo,
2221
masp::fs::FsShieldedUtils,
22+
types::{address::Address, chain::ChainId, key::RefTo},
2323
wallet::fs::FsWalletUtils,
2424
NamadaImpl,
2525
};
@@ -75,7 +75,7 @@ impl ApplicationServer {
7575
tracing::info!("Sleeping until: {}", chain_start);
7676
sleep(Duration::from_secs(60)).await;
7777
}
78-
};
78+
}
7979

8080
let url = Url::from_str(&rpc).expect("invalid RPC address");
8181
let http_client = HttpClient::new(url).unwrap();
@@ -116,7 +116,7 @@ impl ApplicationServer {
116116
difficulty,
117117
chain_id,
118118
chain_start,
119-
withdraw_limit
119+
withdraw_limit,
120120
);
121121

122122
Router::new()

src/dto/faucet.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ pub struct FaucetSettingResponse {
5757
pub chain_id: String,
5858
pub start_at: i64,
5959
pub withdraw_limit: u64,
60-
pub tokens_alias_to_address: HashMap<String, String>
60+
pub tokens_alias_to_address: HashMap<String, String>,
6161
}

src/error/faucet.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub enum FaucetError {
2020
#[error("Error while sending transfer: {0}")]
2121
SdkError(String),
2222
#[error("Withdraw limit must be less then {0}")]
23-
InvalidWithdrawLimit(u64)
23+
InvalidWithdrawLimit(u64),
2424
}
2525

2626
impl IntoResponse for FaucetError {

src/handler/faucet.rs

+16-9
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@ use axum::{extract::State, Json};
44
use axum_macros::debug_handler;
55
use namada_sdk::{
66
args::InputAmount,
7-
core::types::{
8-
address::Address,
9-
masp::{TransferSource, TransferTarget},
10-
},
117
rpc,
128
signing::default_sign,
139
tendermint::abci::Code,
10+
tx::data::ResultCode,
11+
types::{
12+
address::Address,
13+
masp::{TransferSource, TransferTarget},
14+
},
1415
Namada,
15-
core::types::transaction::ResultCode
1616
};
1717

1818
use crate::{
19-
dto::faucet::{FaucetRequestDto, FaucetResponseDto, FaucetResponseStatusDto, FaucetSettingResponse},
19+
dto::faucet::{
20+
FaucetRequestDto, FaucetResponseDto, FaucetResponseStatusDto, FaucetSettingResponse,
21+
},
2022
error::{api::ApiError, faucet::FaucetError, validate::ValidatedRequest},
2123
repository::faucet::FaucetRepositoryTrait,
2224
state::faucet::FaucetState,
@@ -32,7 +34,10 @@ pub async fn faucet_settings(
3234
chain_id: state.chain_id,
3335
start_at: state.chain_start,
3436
withdraw_limit: state.withdraw_limit,
35-
tokens_alias_to_address: HashMap::from([("NAM".to_string(), nam_token_address.to_string())])
37+
tokens_alias_to_address: HashMap::from([(
38+
"NAM".to_string(),
39+
nam_token_address.to_string(),
40+
)]),
3641
};
3742

3843
Ok(Json(response))
@@ -58,7 +63,7 @@ pub async fn request_transfer(
5863
let auth_key: String = state.auth_key.clone();
5964

6065
if payload.transfer.amount > state.withdraw_limit {
61-
return Err(FaucetError::InvalidWithdrawLimit(state.withdraw_limit).into())
66+
return Err(FaucetError::InvalidWithdrawLimit(state.withdraw_limit).into());
6267
}
6368

6469
let token_address = Address::decode(payload.transfer.token.clone());
@@ -133,7 +138,9 @@ pub async fn request_transfer(
133138

134139
let (transfer_result, tx_hash) = if let Ok(response) = process_tx_response {
135140
match response {
136-
namada_sdk::tx::ProcessTxResponse::Applied(r) => (r.code.eq(&ResultCode::Ok), Some(r.hash)),
141+
namada_sdk::tx::ProcessTxResponse::Applied(r) => {
142+
(r.code.eq(&ResultCode::Ok), Some(r.hash))
143+
}
137144
namada_sdk::tx::ProcessTxResponse::Broadcast(r) => {
138145
(r.code.eq(&Code::Ok), Some(r.hash.to_string()))
139146
}

src/sdk/namada.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use namada_sdk::{
2-
core::types::key::common::SecretKey,
32
io::NullIo,
43
masp::{fs::FsShieldedUtils, ShieldedContext},
4+
types::key::common::SecretKey,
55
wallet::{fs::FsWalletUtils, Wallet},
66
NamadaImpl,
77
};

src/sdk/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::str::FromStr;
22

3-
use namada_sdk::core::types::{address::Address, key::common::SecretKey};
3+
use namada_sdk::types::{address::Address, key::common::SecretKey};
44

55
pub fn sk_from_str(sk: &str) -> SecretKey {
66
SecretKey::from_str(sk).expect("Should be able to decode secret key.")

src/state/faucet.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use std::sync::Arc;
66
use tokio::sync::RwLock;
77

88
use namada_sdk::{
9-
core::types::address::Address, io::NullIo, masp::fs::FsShieldedUtils,
10-
wallet::fs::FsWalletUtils, NamadaImpl,
9+
io::NullIo, masp::fs::FsShieldedUtils, types::address::Address, wallet::fs::FsWalletUtils,
10+
NamadaImpl,
1111
};
1212
use tendermint_rpc::HttpClient;
1313

@@ -21,7 +21,7 @@ pub struct FaucetState {
2121
pub difficulty: u64,
2222
pub chain_id: String,
2323
pub chain_start: i64,
24-
pub withdraw_limit: u64
24+
pub withdraw_limit: u64,
2525
}
2626

2727
impl FaucetState {
@@ -33,7 +33,7 @@ impl FaucetState {
3333
difficulty: u64,
3434
chain_id: String,
3535
chain_start: i64,
36-
withdraw_limit: u64
36+
withdraw_limit: u64,
3737
) -> Self {
3838
Self {
3939
faucet_service: FaucetService::new(data),
@@ -44,7 +44,7 @@ impl FaucetState {
4444
difficulty,
4545
chain_id,
4646
chain_start,
47-
withdraw_limit: withdraw_limit * 10_u64.pow(6)
47+
withdraw_limit: withdraw_limit * 10_u64.pow(6),
4848
}
4949
}
5050
}

0 commit comments

Comments
 (0)