Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to polkadot-v1.0.0 #149

Merged
merged 8 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions proposals/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ homepage = { workspace = true }
[dependencies]
scale-codec = { package = 'parity-scale-codec', version = '3.0.0', default-features = false, optional = true, features = ["derive", "max-encoded-len"] }
scale-info = { version = "2.1.1", default-features = false, optional = true }
frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43", optional = true }
frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0", optional = true }
num-traits = { version = "0.2.15", default-features = false }
typed-builder = { version = "0.14.0", default-features = false, optional = true }
tiny-keccak = { version = "2.0.2", features = ["keccak"] }
Expand All @@ -32,5 +32,5 @@ default = ["std", "evm", "substrate", "scale", "ink"]
std = ["scale-codec/std", "scale-info/std", "num-traits/std", "serde", "hex/std", "frame-support/std"]
scale = ["scale-codec", "scale-info/derive"]
evm = []
substrate = ["scale", "typed-builder", "frame-support"]
substrate = ["scale", "typed-builder", "frame-support", "serde"]
ink = ["scale", "typed-builder"]
21 changes: 14 additions & 7 deletions proposals/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,23 @@ pub struct FunctionSignature(pub [u8; 4]);
scale_codec::MaxEncodedLen
)
)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
#[derive(serde::Serialize, serde::Deserialize)]
pub struct ResourceId(pub [u8; 32]);

/// Proposal Target Chain and its type (6 bytes).
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)]
#[derive(
Default,
Debug,
Clone,
Copy,
PartialEq,
Eq,
Hash,
Ord,
PartialOrd,
serde::Serialize,
serde::Deserialize,
)]
#[cfg_attr(
feature = "scale",
derive(
Expand All @@ -47,11 +59,6 @@ pub struct ResourceId(pub [u8; 32]);
scale_codec::MaxEncodedLen
)
)]
#[cfg_attr(
feature = "std",
derive(Serialize, Deserialize),
serde(tag = "type", content = "id")
)]
1xstj marked this conversation as resolved.
Show resolved Hide resolved
#[non_exhaustive]
pub enum TypedChainId {
/// None chain type.
Expand Down
138 changes: 88 additions & 50 deletions src/evm/contract/protocol_solidity/anchor_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub use anchor_handler_contract::*;
clippy::upper_case_acronyms,
clippy::type_complexity,
dead_code,
non_camel_case_types,
non_camel_case_types
)]
pub mod anchor_handler_contract {
#[rustfmt::skip]
Expand Down Expand Up @@ -3490,9 +3490,8 @@ pub mod anchor_handler_contract {
51,
];
///The bytecode of the contract.
pub static ANCHORHANDLERCONTRACT_BYTECODE: ::ethers::core::types::Bytes = ::ethers::core::types::Bytes::from_static(
__BYTECODE,
);
pub static ANCHORHANDLERCONTRACT_BYTECODE: ::ethers::core::types::Bytes =
::ethers::core::types::Bytes::from_static(__BYTECODE);
#[rustfmt::skip]
const __DEPLOYED_BYTECODE: &[u8] = &[
96,
Expand Down Expand Up @@ -5879,9 +5878,9 @@ pub mod anchor_handler_contract {
51,
];
///The deployed bytecode of the contract.
pub static ANCHORHANDLERCONTRACT_DEPLOYED_BYTECODE: ::ethers::core::types::Bytes = ::ethers::core::types::Bytes::from_static(
__DEPLOYED_BYTECODE,
);
pub static ANCHORHANDLERCONTRACT_DEPLOYED_BYTECODE:
::ethers::core::types::Bytes =
::ethers::core::types::Bytes::from_static(__DEPLOYED_BYTECODE);
pub struct AnchorHandlerContract<M>(::ethers::contract::Contract<M>);
impl<M> ::core::clone::Clone for AnchorHandlerContract<M> {
fn clone(&self) -> Self {
Expand All @@ -5900,7 +5899,10 @@ pub mod anchor_handler_contract {
}
}
impl<M> ::core::fmt::Debug for AnchorHandlerContract<M> {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fn fmt(
&self,
f: &mut ::core::fmt::Formatter<'_>,
) -> ::core::fmt::Result {
f.debug_tuple(stringify!(AnchorHandlerContract))
.field(&self.address())
.finish()
Expand All @@ -5913,13 +5915,11 @@ pub mod anchor_handler_contract {
address: T,
client: ::std::sync::Arc<M>,
) -> Self {
Self(
::ethers::contract::Contract::new(
address.into(),
ANCHORHANDLERCONTRACT_ABI.clone(),
client,
),
)
Self(::ethers::contract::Contract::new(
address.into(),
ANCHORHANDLERCONTRACT_ABI.clone(),
client,
))
}
/// Constructs the general purpose `Deployer` instance based on the provided constructor arguments and sends it.
/// Returns a new instance of a deployer that returns an instance of this contract after sending the transaction
Expand Down Expand Up @@ -6027,12 +6027,16 @@ pub mod anchor_handler_contract {
contract_address: ::ethers::core::types::Address,
) -> ::ethers::contract::builders::ContractCall<M, ()> {
self.0
.method_hash([184, 250, 55, 54], (resource_id, contract_address))
.method_hash(
[184, 250, 55, 54],
(resource_id, contract_address),
)
.expect("method not found (this should never happen)")
}
}
impl<M: ::ethers::providers::Middleware> From<::ethers::contract::Contract<M>>
for AnchorHandlerContract<M> {
impl<M: ::ethers::providers::Middleware>
From<::ethers::contract::Contract<M>> for AnchorHandlerContract<M>
{
fn from(contract: ::ethers::contract::Contract<M>) -> Self {
Self::new(contract.address(), contract.client())
}
Expand All @@ -6048,7 +6052,7 @@ pub mod anchor_handler_contract {
Debug,
PartialEq,
Eq,
Hash
Hash,
)]
#[ethcall(name = "_bridgeAddress", abi = "_bridgeAddress()")]
pub struct BridgeAddressCall;
Expand All @@ -6063,13 +6067,15 @@ pub mod anchor_handler_contract {
Debug,
PartialEq,
Eq,
Hash
Hash,
)]
#[ethcall(
name = "_contractAddressToResourceID",
abi = "_contractAddressToResourceID(address)"
)]
pub struct ContractAddressToResourceIDCall(pub ::ethers::core::types::Address);
pub struct ContractAddressToResourceIDCall(
pub ::ethers::core::types::Address,
);
///Container type for all input parameters for the `_contractWhitelist` function with signature `_contractWhitelist(address)` and selector `0x7f79bea8`
#[derive(
Clone,
Expand All @@ -6081,7 +6087,7 @@ pub mod anchor_handler_contract {
Debug,
PartialEq,
Eq,
Hash
Hash,
)]
#[ethcall(name = "_contractWhitelist", abi = "_contractWhitelist(address)")]
pub struct ContractWhitelistCall(pub ::ethers::core::types::Address);
Expand All @@ -6096,7 +6102,7 @@ pub mod anchor_handler_contract {
Debug,
PartialEq,
Eq,
Hash
Hash,
)]
#[ethcall(
name = "_resourceIDToContractAddress",
Expand All @@ -6114,7 +6120,7 @@ pub mod anchor_handler_contract {
Debug,
PartialEq,
Eq,
Hash
Hash,
)]
#[ethcall(name = "executeProposal", abi = "executeProposal(bytes32,bytes)")]
pub struct ExecuteProposalCall {
Expand All @@ -6132,7 +6138,7 @@ pub mod anchor_handler_contract {
Debug,
PartialEq,
Eq,
Hash
Hash,
)]
#[ethcall(name = "migrateBridge", abi = "migrateBridge(address)")]
pub struct MigrateBridgeCall {
Expand All @@ -6149,7 +6155,7 @@ pub mod anchor_handler_contract {
Debug,
PartialEq,
Eq,
Hash
Hash,
)]
#[ethcall(name = "setResource", abi = "setResource(bytes32,address)")]
pub struct SetResourceCall {
Expand All @@ -6165,7 +6171,7 @@ pub mod anchor_handler_contract {
Debug,
PartialEq,
Eq,
Hash
Hash,
)]
pub enum AnchorHandlerContractCalls {
BridgeAddress(BridgeAddressCall),
Expand All @@ -6179,10 +6185,14 @@ pub mod anchor_handler_contract {
impl ::ethers::core::abi::AbiDecode for AnchorHandlerContractCalls {
fn decode(
data: impl AsRef<[u8]>,
) -> ::core::result::Result<Self, ::ethers::core::abi::AbiError> {
) -> ::core::result::Result<Self, ::ethers::core::abi::AbiError>
{
let data = data.as_ref();
if let Ok(decoded)
= <BridgeAddressCall as ::ethers::core::abi::AbiDecode>::decode(data) {
if let Ok(decoded) =
<BridgeAddressCall as ::ethers::core::abi::AbiDecode>::decode(
data,
)
{
return Ok(Self::BridgeAddress(decoded));
}
if let Ok(decoded)
Expand All @@ -6203,16 +6213,25 @@ pub mod anchor_handler_contract {
) {
return Ok(Self::ResourceIDToContractAddress(decoded));
}
if let Ok(decoded)
= <ExecuteProposalCall as ::ethers::core::abi::AbiDecode>::decode(data) {
if let Ok(decoded) =
<ExecuteProposalCall as ::ethers::core::abi::AbiDecode>::decode(
data,
)
{
return Ok(Self::ExecuteProposal(decoded));
}
if let Ok(decoded)
= <MigrateBridgeCall as ::ethers::core::abi::AbiDecode>::decode(data) {
if let Ok(decoded) =
<MigrateBridgeCall as ::ethers::core::abi::AbiDecode>::decode(
data,
)
{
return Ok(Self::MigrateBridge(decoded));
}
if let Ok(decoded)
= <SetResourceCall as ::ethers::core::abi::AbiDecode>::decode(data) {
if let Ok(decoded) =
<SetResourceCall as ::ethers::core::abi::AbiDecode>::decode(
data,
)
{
return Ok(Self::SetResource(decoded));
}
Err(::ethers::core::abi::Error::InvalidData.into())
Expand Down Expand Up @@ -6246,19 +6265,32 @@ pub mod anchor_handler_contract {
}
}
impl ::core::fmt::Display for AnchorHandlerContractCalls {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fn fmt(
&self,
f: &mut ::core::fmt::Formatter<'_>,
) -> ::core::fmt::Result {
match self {
Self::BridgeAddress(element) => ::core::fmt::Display::fmt(element, f),
Self::BridgeAddress(element) => {
::core::fmt::Display::fmt(element, f)
}
Self::ContractAddressToResourceID(element) => {
::core::fmt::Display::fmt(element, f)
}
Self::ContractWhitelist(element) => ::core::fmt::Display::fmt(element, f),
Self::ContractWhitelist(element) => {
::core::fmt::Display::fmt(element, f)
}
Self::ResourceIDToContractAddress(element) => {
::core::fmt::Display::fmt(element, f)
}
Self::ExecuteProposal(element) => ::core::fmt::Display::fmt(element, f),
Self::MigrateBridge(element) => ::core::fmt::Display::fmt(element, f),
Self::SetResource(element) => ::core::fmt::Display::fmt(element, f),
Self::ExecuteProposal(element) => {
::core::fmt::Display::fmt(element, f)
}
Self::MigrateBridge(element) => {
::core::fmt::Display::fmt(element, f)
}
Self::SetResource(element) => {
::core::fmt::Display::fmt(element, f)
}
}
}
}
Expand All @@ -6268,18 +6300,22 @@ pub mod anchor_handler_contract {
}
}
impl ::core::convert::From<ContractAddressToResourceIDCall>
for AnchorHandlerContractCalls {
for AnchorHandlerContractCalls
{
fn from(value: ContractAddressToResourceIDCall) -> Self {
Self::ContractAddressToResourceID(value)
}
}
impl ::core::convert::From<ContractWhitelistCall> for AnchorHandlerContractCalls {
impl ::core::convert::From<ContractWhitelistCall>
for AnchorHandlerContractCalls
{
fn from(value: ContractWhitelistCall) -> Self {
Self::ContractWhitelist(value)
}
}
impl ::core::convert::From<ResourceIDToContractAddressCall>
for AnchorHandlerContractCalls {
for AnchorHandlerContractCalls
{
fn from(value: ResourceIDToContractAddressCall) -> Self {
Self::ResourceIDToContractAddress(value)
}
Expand Down Expand Up @@ -6310,7 +6346,7 @@ pub mod anchor_handler_contract {
Debug,
PartialEq,
Eq,
Hash
Hash,
)]
pub struct BridgeAddressReturn(pub ::ethers::core::types::Address);
///Container type for all return fields from the `_contractAddressToResourceID` function with signature `_contractAddressToResourceID(address)` and selector `0xec97d3b4`
Expand All @@ -6324,7 +6360,7 @@ pub mod anchor_handler_contract {
Debug,
PartialEq,
Eq,
Hash
Hash,
)]
pub struct ContractAddressToResourceIDReturn(pub [u8; 32]);
///Container type for all return fields from the `_contractWhitelist` function with signature `_contractWhitelist(address)` and selector `0x7f79bea8`
Expand All @@ -6338,7 +6374,7 @@ pub mod anchor_handler_contract {
Debug,
PartialEq,
Eq,
Hash
Hash,
)]
pub struct ContractWhitelistReturn(pub bool);
///Container type for all return fields from the `_resourceIDToContractAddress` function with signature `_resourceIDToContractAddress(bytes32)` and selector `0xc54c2a11`
Expand All @@ -6352,7 +6388,9 @@ pub mod anchor_handler_contract {
Debug,
PartialEq,
Eq,
Hash
Hash,
)]
pub struct ResourceIDToContractAddressReturn(pub ::ethers::core::types::Address);
pub struct ResourceIDToContractAddressReturn(
pub ::ethers::core::types::Address,
);
}
Loading
Loading