From 404d6ed92db75e28394b614b6fa570142c499f17 Mon Sep 17 00:00:00 2001 From: shaorongqiang Date: Fri, 29 Nov 2024 16:16:31 +0800 Subject: [PATCH] fix export web3 rpc --- Cargo.toml | 1 + .../src/api/query_server/query_api/mod.rs | 3 +-- .../contracts/modules/ethereum/src/impls.rs | 5 ++--- .../contracts/modules/evm/src/runtime/stack.rs | 10 +++------- .../primitives/rpc-core/src/types/bytes.rs | 2 +- .../primitives/rpc-core/src/types/index.rs | 2 +- .../contracts/primitives/rpc-server/src/lib.rs | 12 ++++++------ src/components/contracts/rpc/src/eth.rs | 4 ++-- src/components/wallet_mobile/src/rust/account.rs | 2 +- .../wallet_mobile/src/rust/data_model.rs | 16 ++++++++-------- src/ledger/src/data_model/mod.rs | 2 +- src/ledger/src/staking/mod.rs | 6 +++--- src/ledger/src/store/mod.rs | 3 +-- 13 files changed, 31 insertions(+), 37 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6cdcd8239..2943572c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,6 +36,7 @@ members = [ "src/components/contracts/primitives/enterprise-web3", "src/components/contracts/rpc", ] +resolver = "2" [profile.dev] incremental = false diff --git a/src/components/abciapp/src/api/query_server/query_api/mod.rs b/src/components/abciapp/src/api/query_server/query_api/mod.rs index e90d15ae2..248020765 100644 --- a/src/components/abciapp/src/api/query_server/query_api/mod.rs +++ b/src/components/abciapp/src/api/query_server/query_api/mod.rs @@ -423,7 +423,6 @@ pub async fn get_related_xfrs( #[allow(missing_docs)] #[allow(clippy::unnecessary_wraps)] - pub async fn get_circulating_supply( data: web::Data>>, ) -> actix_web::Result>, actix_web::error::Error> { @@ -651,7 +650,7 @@ impl QueryApi { }); for (host, port) in addrs.iter() { - hdr = hdr.bind(&format!("{host}:{port}")).c(d!())? + hdr = hdr.bind(format!("{host}:{port}")).c(d!())? } hdr.run(); diff --git a/src/components/contracts/modules/ethereum/src/impls.rs b/src/components/contracts/modules/ethereum/src/impls.rs index f28cde195..575f17fc2 100644 --- a/src/components/contracts/modules/ethereum/src/impls.rs +++ b/src/components/contracts/modules/ethereum/src/impls.rs @@ -54,9 +54,8 @@ impl App { let mut txn_signers = ctx.eth_cache.current.write(); match txn_signers.get(&transaction_hash) { Some(signer) => *signer, - None => Self::recover_signer(transaction).map(|signer| { - txn_signers.insert(transaction_hash, Some(signer)); - signer + None => Self::recover_signer(transaction).inspect(|signer| { + txn_signers.insert(transaction_hash, Some(*signer)); }), } } diff --git a/src/components/contracts/modules/evm/src/runtime/stack.rs b/src/components/contracts/modules/evm/src/runtime/stack.rs index 70e25dbed..ad1a0ff09 100644 --- a/src/components/contracts/modules/evm/src/runtime/stack.rs +++ b/src/components/contracts/modules/evm/src/runtime/stack.rs @@ -33,7 +33,7 @@ pub struct FindoraStackSubstate<'context, 'config> { pub substate: Option>, } -impl<'context, 'config> FindoraStackSubstate<'context, 'config> { +impl<'config> FindoraStackSubstate<'_, 'config> { pub fn metadata(&self) -> &StackSubstateMetadata<'config> { &self.metadata } @@ -207,9 +207,7 @@ impl<'context, 'vicinity, 'config, C: Config> } } -impl<'context, 'vicinity, 'config, C: Config> Backend - for FindoraStackState<'context, 'vicinity, 'config, C> -{ +impl Backend for FindoraStackState<'_, '_, '_, C> { fn gas_price(&self) -> U256 { self.vicinity.gas_price } @@ -278,9 +276,7 @@ impl<'context, 'vicinity, 'config, C: Config> Backend } } -impl<'context, 'vicinity, 'config, C: Config> StackState<'config> - for FindoraStackState<'context, 'vicinity, 'config, C> -{ +impl<'config, C: Config> StackState<'config> for FindoraStackState<'_, '_, 'config, C> { fn metadata(&self) -> &StackSubstateMetadata<'config> { self.substate.metadata() } diff --git a/src/components/contracts/primitives/rpc-core/src/types/bytes.rs b/src/components/contracts/primitives/rpc-core/src/types/bytes.rs index 11d086f61..8e80d9a6e 100644 --- a/src/components/contracts/primitives/rpc-core/src/types/bytes.rs +++ b/src/components/contracts/primitives/rpc-core/src/types/bytes.rs @@ -72,7 +72,7 @@ impl<'a> Deserialize<'a> for Bytes { struct BytesVisitor; -impl<'a> Visitor<'a> for BytesVisitor { +impl Visitor<'_> for BytesVisitor { type Value = Bytes; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { diff --git a/src/components/contracts/primitives/rpc-core/src/types/index.rs b/src/components/contracts/primitives/rpc-core/src/types/index.rs index 02226c7b1..599a20f4e 100644 --- a/src/components/contracts/primitives/rpc-core/src/types/index.rs +++ b/src/components/contracts/primitives/rpc-core/src/types/index.rs @@ -42,7 +42,7 @@ impl<'a> Deserialize<'a> for Index { struct IndexVisitor; -impl<'a> Visitor<'a> for IndexVisitor { +impl Visitor<'_> for IndexVisitor { type Value = Index; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { diff --git a/src/components/contracts/primitives/rpc-server/src/lib.rs b/src/components/contracts/primitives/rpc-server/src/lib.rs index 69b765d2c..7ba2ee800 100644 --- a/src/components/contracts/primitives/rpc-server/src/lib.rs +++ b/src/components/contracts/primitives/rpc-server/src/lib.rs @@ -119,13 +119,13 @@ mod inner { addr: &str, io: RpcHandler, ) -> io::Result { - let builder = ipc::ServerBuilder::new(io); - #[cfg(target_os = "unix")] - builder.set_security_attributes({ + let mut builder = ipc::ServerBuilder::new(io); + #[cfg(target_family = "unix")] + { let security_attributes = ipc::SecurityAttributes::empty(); - security_attributes.set_mode(0o600)?; - security_attributes - }); + builder = + builder.set_security_attributes(security_attributes.set_mode(0o600)?); + } builder.start(addr) } diff --git a/src/components/contracts/rpc/src/eth.rs b/src/components/contracts/rpc/src/eth.rs index 7a4ffff85..27c93af76 100644 --- a/src/components/contracts/rpc/src/eth.rs +++ b/src/components/contracts/rpc/src/eth.rs @@ -1144,7 +1144,7 @@ impl EthApi for EthApiImpl { cumulative_receipts .truncate((status.transaction_index + 1) as usize); - return Ok(Some(Receipt { + Ok(Some(Receipt { transaction_hash: Some(status.transaction_hash), transaction_index: Some(status.transaction_index.into()), block_hash: Some(block_hash), @@ -1197,7 +1197,7 @@ impl EthApi for EthApiImpl { status_code: Some(U64::from(receipt.state_root.to_low_u64_be())), logs_bloom: receipt.logs_bloom, state_root: None, - })); + })) } _ => Ok(None), } diff --git a/src/components/wallet_mobile/src/rust/account.rs b/src/components/wallet_mobile/src/rust/account.rs index 0c6588a54..e5333569a 100644 --- a/src/components/wallet_mobile/src/rust/account.rs +++ b/src/components/wallet_mobile/src/rust/account.rs @@ -73,7 +73,7 @@ pub enum EVMTransactionKind { } impl EVMTransactionBuilder { - /// transfer to uxto assets from account(ed25519 or ecdsa address) balance. + // transfer to uxto assets from account(ed25519 or ecdsa address) balance. pub fn new_transfer_to_utxo_from_account( recipient: XfrPublicKey, diff --git a/src/components/wallet_mobile/src/rust/data_model.rs b/src/components/wallet_mobile/src/rust/data_model.rs index 12733a3f3..ad8901488 100644 --- a/src/components/wallet_mobile/src/rust/data_model.rs +++ b/src/components/wallet_mobile/src/rust/data_model.rs @@ -749,20 +749,20 @@ impl TracingPolicy { /// When an asset is defined, several options governing the assets must be /// specified: /// 1. **Traceable**: Records and identities of traceable assets can be decrypted by a provided tracing key. By defaults, assets do not have -/// any tracing policies. +/// any tracing policies. /// 2. **Transferable**: Non-transferable assets can only be transferred once from the issuer to another user. By default, assets are transferable. /// 3. **Updatable**: Whether the asset memo can be updated. By default, assets are not updatable. /// 4. **Transfer signature rules**: Signature weights and threshold for a valid transfer. By /// default, there are no special signature requirements. /// 5. **Max units**: Optional limit on the total number of units of this asset that can be issued. /// By default, assets do not have issuance caps. -/// @see {@link module:Findora-Wasm~TracingPolicies|TracingPolicies} for more information about tracing policies. -/// @see {@link module:Findora-Wasm~TransactionBuilder#add_operation_update_memo|add_operation_update_memo} for more information about how to add -/// a memo update operation to a transaction. -/// @see {@link module:Findora-Wasm~SignatureRules|SignatureRules} for more information about co-signatures. -/// @see {@link -/// module:Findora-Wasm~TransactionBuilder#add_operation_create_asset|add_operation_create_asset} -/// for information about how to add asset rules to an asset definition. +/// @see {@link module:Findora-Wasm~TracingPolicies|TracingPolicies} for more information about tracing policies. +/// @see {@link module:Findora-Wasm~TransactionBuilder#add_operation_update_memo|add_operation_update_memo} for more information about how to add +/// a memo update operation to a transaction. +/// @see {@link module:Findora-Wasm~SignatureRules|SignatureRules} for more information about co-signatures. +/// @see {@link +/// module:Findora-Wasm~TransactionBuilder#add_operation_create_asset|add_operation_create_asset} +/// for information about how to add asset rules to an asset definition. pub struct AssetRules { pub(crate) rules: PlatformAssetRules, } diff --git a/src/ledger/src/data_model/mod.rs b/src/ledger/src/data_model/mod.rs index 20b5810b7..1e5096d13 100644 --- a/src/ledger/src/data_model/mod.rs +++ b/src/ledger/src/data_model/mod.rs @@ -356,7 +356,7 @@ impl<'de> Deserialize<'de> for Code { { struct CodeVisitor; - impl<'de> Visitor<'de> for CodeVisitor { + impl Visitor<'_> for CodeVisitor { type Value = Code; #[inline(always)] diff --git a/src/ledger/src/staking/mod.rs b/src/ledger/src/staking/mod.rs index 31979ce47..6415867d3 100644 --- a/src/ledger/src/staking/mod.rs +++ b/src/ledger/src/staking/mod.rs @@ -178,10 +178,10 @@ lazy_static! { }; } -/// The lock time after the delegation expires, about 21 days. -//pub const UNBOND_BLOCK_CNT: u64 = 3600 * 24 * 21 / BLOCK_INTERVAL; +// The lock time after the delegation expires, about 21 days. +// pub const UNBOND_BLOCK_CNT: u64 = 3600 * 24 * 21 / BLOCK_INTERVAL; -// minimal number of validators +/// Minimal number of validators pub const VALIDATORS_MIN: usize = 5; /// The minimum weight threshold required diff --git a/src/ledger/src/store/mod.rs b/src/ledger/src/store/mod.rs index e739c90d9..865b89695 100644 --- a/src/ledger/src/store/mod.rs +++ b/src/ledger/src/store/mod.rs @@ -120,10 +120,9 @@ impl LedgerState { .check_txn_effects(&txe) .c(d!()) .and_then(|_| block.add_txn_effect(txe).c(d!())) - .map(|tmpid| { + .inspect(|_| { // NOTE: set at the last position block.staking_simulator.coinbase_check_and_pay(&tx); - tmpid }) }