mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 04:01:02 +00:00
Use CallRequest type from rust-web3 crate (#101)
* Use `CallRequest` type from rust-web3 crate * Change CallRequest's `to` field to be optional Required due to changes in upstream `rust-web3` crate.
This commit is contained in:
committed by
Bastian Köcher
parent
e16dd14e20
commit
792226c9fd
@@ -28,7 +28,7 @@ serde = { version = "1.0.110", features = ["derive"] }
|
|||||||
serde_json = "1.0.53"
|
serde_json = "1.0.53"
|
||||||
sp-bridge-eth-poa = { path = "../../primitives/ethereum-poa" }
|
sp-bridge-eth-poa = { path = "../../primitives/ethereum-poa" }
|
||||||
time = "0.2"
|
time = "0.2"
|
||||||
web3 = "0.11"
|
web3 = { git = "https://github.com/tomusdrw/rust-web3" }
|
||||||
|
|
||||||
# Substrate Based Dependencies
|
# Substrate Based Dependencies
|
||||||
[dependencies.frame-system]
|
[dependencies.frame-system]
|
||||||
|
|||||||
@@ -14,7 +14,9 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use crate::ethereum_types::{Address, Bytes, EthereumHeaderId, Header, Receipt, TransactionHash, H256, U256, U64};
|
use crate::ethereum_types::{
|
||||||
|
Address, Bytes, CallRequest, EthereumHeaderId, Header, Receipt, TransactionHash, H256, U256, U64,
|
||||||
|
};
|
||||||
use crate::substrate_types::{GrandpaJustification, Hash as SubstrateHash, QueuedSubstrateHeader, SubstrateHeaderId};
|
use crate::substrate_types::{GrandpaJustification, Hash as SubstrateHash, QueuedSubstrateHeader, SubstrateHeaderId};
|
||||||
use crate::sync_types::{HeaderId, MaybeConnectionError};
|
use crate::sync_types::{HeaderId, MaybeConnectionError};
|
||||||
use crate::{bail_on_arg_error, bail_on_error};
|
use crate::{bail_on_arg_error, bail_on_error};
|
||||||
@@ -24,7 +26,7 @@ use jsonrpsee::common::Params;
|
|||||||
use jsonrpsee::raw::{RawClient, RawClientError};
|
use jsonrpsee::raw::{RawClient, RawClientError};
|
||||||
use jsonrpsee::transport::http::{HttpTransportClient, RequestError};
|
use jsonrpsee::transport::http::{HttpTransportClient, RequestError};
|
||||||
use parity_crypto::publickey::KeyPair;
|
use parity_crypto::publickey::KeyPair;
|
||||||
use serde::{de::DeserializeOwned, Serialize};
|
use serde::de::DeserializeOwned;
|
||||||
use serde_json::{from_value, to_value};
|
use serde_json::{from_value, to_value};
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
@@ -87,15 +89,6 @@ impl Default for EthereumSigningParams {
|
|||||||
/// Ethereum client type.
|
/// Ethereum client type.
|
||||||
pub type Client = RawClient<HttpTransportClient>;
|
pub type Client = RawClient<HttpTransportClient>;
|
||||||
|
|
||||||
/// Ethereum contract call request.
|
|
||||||
#[derive(Debug, Default, PartialEq, Serialize)]
|
|
||||||
pub struct CallRequest {
|
|
||||||
/// Contract address.
|
|
||||||
pub to: Option<Address>,
|
|
||||||
/// Call data.
|
|
||||||
pub data: Option<Bytes>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// All possible errors that can occur during interacting with Ethereum node.
|
/// All possible errors that can occur during interacting with Ethereum node.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
@@ -225,6 +218,7 @@ pub async fn best_substrate_block(
|
|||||||
to_value(CallRequest {
|
to_value(CallRequest {
|
||||||
to: Some(contract_address),
|
to: Some(contract_address),
|
||||||
data: Some(encoded_call.into()),
|
data: Some(encoded_call.into()),
|
||||||
|
..Default::default()
|
||||||
})
|
})
|
||||||
.map_err(|e| Error::RequestSerialization(e)),
|
.map_err(|e| Error::RequestSerialization(e)),
|
||||||
client
|
client
|
||||||
@@ -258,6 +252,7 @@ pub async fn substrate_header_known(
|
|||||||
to_value(CallRequest {
|
to_value(CallRequest {
|
||||||
to: Some(contract_address),
|
to: Some(contract_address),
|
||||||
data: Some(encoded_call.into()),
|
data: Some(encoded_call.into()),
|
||||||
|
..Default::default()
|
||||||
})
|
})
|
||||||
.map_err(|e| Error::RequestSerialization(e)),
|
.map_err(|e| Error::RequestSerialization(e)),
|
||||||
client
|
client
|
||||||
@@ -311,6 +306,7 @@ pub async fn incomplete_substrate_headers(
|
|||||||
to_value(CallRequest {
|
to_value(CallRequest {
|
||||||
to: Some(contract_address),
|
to: Some(contract_address),
|
||||||
data: Some(encoded_call.into()),
|
data: Some(encoded_call.into()),
|
||||||
|
..Default::default()
|
||||||
})
|
})
|
||||||
.map_err(|e| Error::RequestSerialization(e)),
|
.map_err(|e| Error::RequestSerialization(e)),
|
||||||
client
|
client
|
||||||
@@ -398,6 +394,7 @@ async fn submit_ethereum_transaction(
|
|||||||
CallRequest {
|
CallRequest {
|
||||||
to: contract_address,
|
to: contract_address,
|
||||||
data: Some(encoded_call.clone().into()),
|
data: Some(encoded_call.clone().into()),
|
||||||
|
..Default::default()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ use crate::substrate_types::{into_substrate_ethereum_header, into_substrate_ethe
|
|||||||
use crate::sync_types::{HeaderId, HeadersSyncPipeline, QueuedHeader, SourceHeader};
|
use crate::sync_types::{HeaderId, HeadersSyncPipeline, QueuedHeader, SourceHeader};
|
||||||
use codec::Encode;
|
use codec::Encode;
|
||||||
|
|
||||||
pub use web3::types::{Address, Bytes, H256, U128, U256, U64};
|
pub use web3::types::{Address, Bytes, CallRequest, H256, U128, U256, U64};
|
||||||
|
|
||||||
/// When header is just received from the Ethereum node, we check that it has
|
/// When header is just received from the Ethereum node, we check that it has
|
||||||
/// both number and hash fields filled.
|
/// both number and hash fields filled.
|
||||||
|
|||||||
Reference in New Issue
Block a user