From 5b2ad2b2849b64b1db3d6def2cc66de68b2d2f9c Mon Sep 17 00:00:00 2001 From: Gabriel de Quadros Ligneul Date: Wed, 10 Apr 2024 17:28:20 -0300 Subject: [PATCH] feat: bump contracts to 2.0-rc.2 --- .github/license-check/config.json | 6 +- CHANGELOG.md | 4 + build/Dockerfile | 13 +- build/compose-devnet.yaml | 10 +- build/compose-sepolia.yaml | 4 +- cmd/authority-claimer/Cargo.lock | 1 - cmd/authority-claimer/Cargo.toml | 1 - cmd/authority-claimer/build.rs | 22 +- cmd/authority-claimer/src/checker.rs | 119 +- cmd/authority-claimer/src/claimer.rs | 9 +- .../src/{config/cli.rs => config.rs} | 151 ++- cmd/authority-claimer/src/config/contracts.rs | 108 -- cmd/authority-claimer/src/config/error.rs | 40 - cmd/authority-claimer/src/config/mod.rs | 63 - cmd/authority-claimer/src/contracts.rs | 3 +- cmd/authority-claimer/src/http_server.rs | 47 +- cmd/authority-claimer/src/lib.rs | 38 +- cmd/authority-claimer/src/main.rs | 2 +- cmd/authority-claimer/src/metrics.rs | 6 +- .../src/rollups_events/broker.rs | 16 +- .../src/rollups_events/common.rs | 3 +- .../src/rollups_events/rollups_claims.rs | 3 +- cmd/authority-claimer/src/sender.rs | 101 +- .../src/signer/aws_signer.rs | 3 +- cmd/authority-claimer/src/signer/signer.rs | 3 +- cmd/authority-claimer/src/test_fixtures.rs | 11 +- .../root/execute/execute.go | 5 +- cmd/cartesi-rollups-cli/root/send/send.go | 2 +- .../root/validate/validate.go | 4 +- cmd/gen-devnet/deployer.go | 28 +- cmd/gen-devnet/main.go | 4 +- cmd/gen-devnet/rollups.go | 6 +- cmd/gen-devnet/types.go | 1 - docs/config.md | 16 +- internal/node/config/config.go | 53 +- internal/node/config/generate/Config.toml | 14 +- internal/node/config/generated.go | 32 +- internal/node/machinehash.go | 4 +- internal/node/machinehash_test.go | 4 +- internal/node/services.go | 5 +- pkg/addresses/addresses.go | 46 +- pkg/contracts/application/application.go | 1036 +++++++++++++++++ pkg/contracts/authority.go | 844 -------------- pkg/contracts/cartesi_dapp.go | 995 ---------------- pkg/contracts/cartesi_dapp_factory.go | 401 ------- pkg/contracts/generate/main.go | 57 +- pkg/contracts/history.go | 634 ---------- pkg/contracts/iconsensus/iconsensus.go | 540 +++++++++ .../{input_box.go => inputbox/inputbox.go} | 111 +- pkg/contracts/inputs/inputs.go | 202 ++++ pkg/contracts/outputs/outputs.go | 223 ++++ pkg/ethutil/ethutil.go | 46 +- pkg/ethutil/ethutil_test.go | 17 +- pkg/readerclient/proof.go | 35 +- rollups-contracts | 2 +- setup_env.sh | 10 +- test/config.go | 21 +- 57 files changed, 2496 insertions(+), 3689 deletions(-) rename cmd/authority-claimer/src/{config/cli.rs => config.rs} (61%) delete mode 100644 cmd/authority-claimer/src/config/contracts.rs delete mode 100644 cmd/authority-claimer/src/config/error.rs delete mode 100644 cmd/authority-claimer/src/config/mod.rs create mode 100644 pkg/contracts/application/application.go delete mode 100644 pkg/contracts/authority.go delete mode 100644 pkg/contracts/cartesi_dapp.go delete mode 100644 pkg/contracts/cartesi_dapp_factory.go delete mode 100644 pkg/contracts/history.go create mode 100644 pkg/contracts/iconsensus/iconsensus.go rename pkg/contracts/{input_box.go => inputbox/inputbox.go} (71%) create mode 100644 pkg/contracts/inputs/inputs.go create mode 100644 pkg/contracts/outputs/outputs.go diff --git a/.github/license-check/config.json b/.github/license-check/config.json index 92a3bf073..741739a79 100644 --- a/.github/license-check/config.json +++ b/.github/license-check/config.json @@ -2,10 +2,8 @@ { "include": ["**/*.go", "**/*.rs"], "exclude": [ - "offchain/grpc-interfaces/**", - "offchain/target/**", - "offchain/data/src/schema.rs", - "pkg/contracts/*.go", + "cmd/authority-claimer/target/**", + "pkg/contracts/**", "pkg/readerclient/generated.go", "pkg/inspectclient/generated.go", "rollups-contracts/**" diff --git a/CHANGELOG.md b/CHANGELOG.md index 58eec0cce..dd7ffd17c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added Rollups end-to-end test using Echo Dapp +### Changed + +- Bumped Rollups Contracts to 2.0 + ### Removed - Removed `advance-runner`, `dispatcher`, `graphql-server`, `host-runner`, `indexer`, `inspect-server`, and `state-server` Rust services diff --git a/build/Dockerfile b/build/Dockerfile index f59bce8ba..0c33b1b31 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -153,18 +153,17 @@ apt-get install -y --no-install-recommends \ gnupg EOF -# Install yarn +# Install nodejs ARG DEBIAN_FRONTEND=noninteractive RUN < Result<(), Box> { let tempdir = tempfile::tempdir()?; @@ -19,10 +20,7 @@ fn main() -> Result<(), Box> { download_contracts(&tarball)?; unzip_contracts(&tarball, tempdir.path())?; - let contracts = vec![ - ("consensus/authority", "Authority", "authority.rs"), - ("history", "History", "history.rs"), - ]; + let contracts = vec![("consensus", "IConsensus", "iconsensus.rs")]; for (contract_path, contract_name, bindings_file_name) in contracts { let source_path = path(tempdir.path(), contract_path, contract_name); let output_path: PathBuf = diff --git a/cmd/authority-claimer/src/checker.rs b/cmd/authority-claimer/src/checker.rs index a005e766e..6c4f16106 100644 --- a/cmd/authority-claimer/src/checker.rs +++ b/cmd/authority-claimer/src/checker.rs @@ -1,8 +1,10 @@ // (c) Cartesi and individual authors (see AUTHORS) // SPDX-License-Identifier: Apache-2.0 (see LICENSE) -use crate::contracts::history::{Claim, History}; -use crate::rollups_events::{Address, RollupsClaim}; +use crate::{ + contracts::iconsensus::IConsensus, + rollups_events::{Address, Hash, RollupsClaim}, +}; use async_trait::async_trait; use ethers::{ self, @@ -10,11 +12,10 @@ use ethers::{ providers::{ Http, HttpRateLimitRetryPolicy, Middleware, Provider, RetryClient, }, - types::H160, + types::{Address as EthersAddress, H160}, }; use snafu::{ensure, ResultExt, Snafu}; -use std::sync::Arc; -use std::{collections::HashMap, fmt::Debug}; +use std::{collections::HashSet, fmt::Debug, sync::Arc}; use tracing::trace; use url::{ParseError, Url}; @@ -36,11 +37,20 @@ pub trait DuplicateChecker: Debug { // DefaultDuplicateChecker // ------------------------------------------------------------------------------------------------ +#[derive(Debug, Clone, Hash, Eq, PartialEq)] +struct Claim { + application: Address, + first_index: u64, + last_index: u64, + epoch_hash: Hash, +} + #[derive(Debug)] pub struct DefaultDuplicateChecker { provider: Arc>>, - history: History>>, - claims: HashMap>, + iconsensus: IConsensus>>, + from: EthersAddress, + claims: HashSet, confirmations: usize, next_block_to_read: u64, } @@ -66,24 +76,13 @@ pub enum DuplicateCheckerError { latest ))] DepthTooHigh { depth: u64, latest: u64 }, - - #[snafu(display( - "Claim mismatch; blockchain expects [{}, ?], but got claim with [{}, {}]", - expected_first_index, - claim_first_index, - claim_last_index - ))] - ClaimMismatch { - expected_first_index: u128, - claim_first_index: u128, - claim_last_index: u128, - }, } impl DefaultDuplicateChecker { pub async fn new( http_endpoint: String, - history_address: Address, + iconsensus: Address, + from: EthersAddress, confirmations: usize, genesis_block: u64, ) -> Result { @@ -95,14 +94,15 @@ impl DefaultDuplicateChecker { INITIAL_BACKOFF, ); let provider = Arc::new(Provider::new(retry_client)); - let history = History::new( - H160(history_address.inner().to_owned()), + let iconsensus = IConsensus::new( + H160(iconsensus.inner().to_owned()), provider.clone(), ); let mut checker = Self { provider, - history, - claims: HashMap::new(), + iconsensus, + from, + claims: HashSet::new(), confirmations, next_block_to_read: genesis_block, }; @@ -120,27 +120,13 @@ impl DuplicateChecker for DefaultDuplicateChecker { rollups_claim: &RollupsClaim, ) -> Result { self.update_claims().await?; - let expected_first_index = self - .claims // HashMap => DappAddress to Vec - .get(&rollups_claim.dapp_address) // Gets a Option> - .and_then(|claims| claims.last()) // Back to only one Option - .map(|claim| claim.last_index + 1) // Maps to a number - .unwrap_or(0); // If None, unwrap to 0 - if rollups_claim.first_index == expected_first_index { - // This claim is the one the blockchain expects, so it is not considered duplicate. - Ok(false) - } else if rollups_claim.last_index < expected_first_index { - // This claim is already on the blockchain. - Ok(true) - } else { - // This claim is not on blockchain, but it isn't the one blockchain expects. - // If this happens, there is a bug on the dispatcher. - Err(DuplicateCheckerError::ClaimMismatch { - expected_first_index, - claim_first_index: rollups_claim.first_index, - claim_last_index: rollups_claim.last_index, - }) - } + let claim = Claim { + application: rollups_claim.dapp_address.clone(), + first_index: rollups_claim.first_index as u64, + last_index: rollups_claim.last_index as u64, + epoch_hash: rollups_claim.epoch_hash.clone(), + }; + Ok(self.claims.contains(&claim)) } } @@ -167,44 +153,33 @@ impl DefaultDuplicateChecker { return Ok(()); } - let new_claims: Vec<(Address, Claim)> = self - .history - .new_claim_to_history_filter() + let claims = self + .iconsensus + .claim_submission_filter() .from_block(self.next_block_to_read) .to_block(latest) + .topic1(self.from) .query() .await - .context(ContractSnafu)? - .into_iter() - .map(|e| (Address::new(e.dapp.into()), e.claim)) - .collect(); + .context(ContractSnafu)?; + trace!( "read new claims {:?} from block {} to {}", - new_claims, + claims, self.next_block_to_read, latest ); - self.append_claims(new_claims); + for claim_submission in claims.into_iter() { + let claim = Claim { + application: Address::new(claim_submission.app_contract.into()), + first_index: claim_submission.input_range.first_index, + last_index: claim_submission.input_range.last_index, + epoch_hash: Hash::new(claim_submission.epoch_hash), + }; + self.claims.insert(claim); + } self.next_block_to_read = latest + 1; - Ok(()) } - - // Appends new claims to the [Address => Vec] hashmap cache. - fn append_claims(&mut self, new_claims: Vec<(Address, Claim)>) { - if new_claims.is_empty() { - return; - } - for (dapp_address, new_claim) in new_claims { - match self.claims.get_mut(&dapp_address) { - Some(old_claims) => { - old_claims.push(new_claim); - } - None => { - self.claims.insert(dapp_address, vec![new_claim]); - } - } - } - } } diff --git a/cmd/authority-claimer/src/claimer.rs b/cmd/authority-claimer/src/claimer.rs index 8e3bbc033..c0dd8e80e 100644 --- a/cmd/authority-claimer/src/claimer.rs +++ b/cmd/authority-claimer/src/claimer.rs @@ -1,15 +1,14 @@ // (c) Cartesi and individual authors (see AUTHORS) // SPDX-License-Identifier: Apache-2.0 (see LICENSE) -use async_trait::async_trait; -use snafu::ResultExt; -use std::fmt::Debug; -use tracing::{info, trace}; - use crate::{ checker::DuplicateChecker, listener::BrokerListener, sender::TransactionSender, }; +use async_trait::async_trait; +use snafu::ResultExt; +use std::fmt::Debug; +use tracing::{info, trace}; /// The `Claimer` starts an event loop that waits for claim messages /// from the broker, and then sends the claims to the blockchain. It checks to diff --git a/cmd/authority-claimer/src/config/cli.rs b/cmd/authority-claimer/src/config.rs similarity index 61% rename from cmd/authority-claimer/src/config/cli.rs rename to cmd/authority-claimer/src/config.rs index d22e754de..3b0586c57 100644 --- a/cmd/authority-claimer/src/config/cli.rs +++ b/cmd/authority-claimer/src/config.rs @@ -1,94 +1,141 @@ // (c) Cartesi and individual authors (see AUTHORS) // SPDX-License-Identifier: Apache-2.0 (see LICENSE) -use super::contracts::ContractsCLIConfig; -use crate::config::{ - error::{ - AuthorityClaimerConfigError, ContractsSnafu, InvalidRegionSnafu, - MnemonicFileSnafu, TxManagerSnafu, TxSigningConfigError, - TxSigningSnafu, - }, - AuthorityClaimerConfig, ContractsConfig, TxSigningConfig, +use crate::{ + log::{LogConfig, LogEnvCliConfig}, + redacted::Redacted, + rollups_events::{Address, BrokerCLIConfig, BrokerConfig}, }; -use crate::log::{LogConfig, LogEnvCliConfig}; -use crate::redacted::Redacted; -use crate::rollups_events::{BrokerCLIConfig, BrokerConfig}; use clap::{command, Parser}; use eth_tx_manager::{ - config::{TxEnvCLIConfig as TxManagerCLIConfig, TxManagerConfig}, + config::{ + Error as TxManagerConfigError, TxEnvCLIConfig as TxManagerCLIConfig, + TxManagerConfig, + }, Priority, }; -use rusoto_core::Region; -use snafu::ResultExt; +use rusoto_core::{region::ParseRegionError, Region}; +use snafu::{ResultExt, Snafu}; use std::{fs, str::FromStr}; -// ------------------------------------------------------------------------------------------------ -// AuthorityClaimerCLI -// ------------------------------------------------------------------------------------------------ +#[derive(Debug, Snafu)] +#[snafu(visibility(pub(crate)))] +pub enum AuthorityClaimerConfigError { + #[snafu(display("TxManager configuration error"))] + TxManager { source: TxManagerConfigError }, -#[derive(Parser)] -#[command(name = "authority_claimer_config")] -#[command(about = "Configuration for authority-claimer")] -pub(crate) struct AuthorityClaimerCLI { - #[command(flatten)] - pub tx_manager_config: TxManagerCLIConfig, + #[snafu(display("parse IConsensus address error"))] + ParseIConsensusAddress { source: serde_json::Error }, - #[command(flatten)] - pub tx_signing_config: TxSigningCLIConfig, + #[snafu(display("Missing auth configuration"))] + AuthConfigMissing, - #[command(flatten)] - pub broker_config: BrokerCLIConfig, + #[snafu(display("Could not read mnemonic file at path `{}`", path,))] + MnemonicFileError { + path: String, + source: std::io::Error, + }, - #[command(flatten)] - pub log_config: LogEnvCliConfig, + #[snafu(display("Missing AWS region"))] + MissingRegion, - #[command(flatten)] - pub contracts_config: ContractsCLIConfig, + #[snafu(display("Invalid AWS region"))] + InvalidRegion { source: ParseRegionError }, +} - /// Genesis block for reading blockchain events - #[arg(long, env, default_value_t = 1)] +#[derive(Debug, Clone)] +pub struct Config { + pub tx_manager_config: TxManagerConfig, + pub tx_signing_config: TxSigningConfig, + pub tx_manager_priority: Priority, + pub broker_config: BrokerConfig, + pub log_config: LogConfig, + pub iconsensus_address: Address, pub genesis_block: u64, + pub http_server_port: u16, } -impl TryFrom for AuthorityClaimerConfig { - type Error = AuthorityClaimerConfigError; +#[derive(Debug, Clone)] +pub enum TxSigningConfig { + PrivateKey { + private_key: Redacted, + }, + + Mnemonic { + mnemonic: Redacted, + account_index: Option, + }, + + Aws { + key_id: String, + region: Region, + }, +} + +impl Config { + pub fn new() -> Result { + let cli_config = AuthorityClaimerCLI::parse(); - fn try_from(cli_config: AuthorityClaimerCLI) -> Result { let tx_manager_config = TxManagerConfig::initialize(cli_config.tx_manager_config) .context(TxManagerSnafu)?; let tx_signing_config = - TxSigningConfig::try_from(cli_config.tx_signing_config) - .context(TxSigningSnafu)?; + TxSigningConfig::try_from(cli_config.tx_signing_config)?; let broker_config = BrokerConfig::from(cli_config.broker_config); let log_config = LogConfig::initialize(cli_config.log_config); - let contracts_config = - ContractsConfig::try_from(cli_config.contracts_config) - .context(ContractsSnafu)?; + let iconsensus_address = + serde_json::from_str(&cli_config.iconsensus_address) + .context(ParseIConsensusAddressSnafu)?; - Ok(AuthorityClaimerConfig { + Ok(Config { tx_manager_config, tx_signing_config, tx_manager_priority: Priority::Normal, broker_config, log_config, - contracts_config, + iconsensus_address, genesis_block: cli_config.genesis_block, + http_server_port: cli_config.http_server_port, }) } } -// ------------------------------------------------------------------------------------------------ -// TxSigningCLIConfig -// ------------------------------------------------------------------------------------------------ +#[derive(Parser)] +#[command(name = "authority_claimer_config")] +#[command(about = "Configuration for authority-claimer")] +struct AuthorityClaimerCLI { + #[command(flatten)] + pub tx_manager_config: TxManagerCLIConfig, + + #[command(flatten)] + pub tx_signing_config: TxSigningCLIConfig, + + #[command(flatten)] + pub broker_config: BrokerCLIConfig, + + #[command(flatten)] + pub log_config: LogEnvCliConfig, + + /// Address of the IConsensus contract + #[arg(long, env)] + pub iconsensus_address: String, + + /// Genesis block for reading blockchain events + #[arg(long, env, default_value_t = 1)] + pub genesis_block: u64, + + /// Port of the authority-claimer HTTP server + #[arg(long, env, default_value_t = 8080)] + pub http_server_port: u16, +} #[derive(Debug, Parser)] #[command(name = "tx_signing_config")] -pub(crate) struct TxSigningCLIConfig { +struct TxSigningCLIConfig { /// Signer private key, overrides `tx_signing_private_key_file`, `tx_signing_mnemonic` , `tx_signing_mnemonic_file` and `tx_signing_aws_kms_*` #[arg(long, env)] tx_signing_private_key: Option, @@ -119,7 +166,7 @@ pub(crate) struct TxSigningCLIConfig { } impl TryFrom for TxSigningConfig { - type Error = TxSigningConfigError; + type Error = AuthorityClaimerConfigError; fn try_from(cli: TxSigningCLIConfig) -> Result { let account_index = cli.tx_signing_mnemonic_account_index; @@ -152,8 +199,12 @@ impl TryFrom for TxSigningConfig { } else { match (cli.tx_signing_aws_kms_key_id, cli.tx_signing_aws_kms_region) { - (None, _) => Err(TxSigningConfigError::AuthConfigMissing), - (Some(_), None) => Err(TxSigningConfigError::MissingRegion), + (None, _) => { + Err(AuthorityClaimerConfigError::AuthConfigMissing) + } + (Some(_), None) => { + Err(AuthorityClaimerConfigError::MissingRegion) + } (Some(key_id), Some(region)) => { let region = Region::from_str(®ion) .context(InvalidRegionSnafu)?; diff --git a/cmd/authority-claimer/src/config/contracts.rs b/cmd/authority-claimer/src/config/contracts.rs deleted file mode 100644 index 16506f9b9..000000000 --- a/cmd/authority-claimer/src/config/contracts.rs +++ /dev/null @@ -1,108 +0,0 @@ -// (c) Cartesi and individual authors (see AUTHORS) -// SPDX-License-Identifier: Apache-2.0 (see LICENSE) - -use crate::rollups_events::Address; -use crate::types::blockchain_config::RollupsDeployment; -use clap::Parser; -use serde::de::DeserializeOwned; -use snafu::{ResultExt, Snafu}; -use std::{fs::File, io::BufReader, path::PathBuf}; - -#[derive(Clone, Debug)] -pub struct ContractsConfig { - pub history_address: Address, - pub authority_address: Address, -} - -#[derive(Debug, Parser)] -#[command(name = "blockchain_config")] -pub struct ContractsCLIConfig { - /// History contract address - #[arg(long, env)] - pub history_address: Option, - - /// Authority contract address - #[arg(long, env)] - pub authority_address: Option, - - /// Path to file with deployment json of the rollups - #[arg(long, env)] - pub rollups_deployment_file: Option, -} - -impl TryFrom for ContractsConfig { - type Error = ContractsConfigError; - - fn try_from(cli: ContractsCLIConfig) -> Result { - // try to get the values from the environment values - let mut history_address = cli - .history_address - .map(deserialize::
) - .transpose()?; - let mut authority_address = cli - .authority_address - .map(deserialize::
) - .transpose()?; - - // read file and replace values if they are not set - if let Some(file) = cli - .rollups_deployment_file - .map(read::) - .transpose()? - { - history_address = history_address - .or(file.contracts.history.and_then(|c| c.address)); - authority_address = authority_address - .or(file.contracts.authority.and_then(|c| c.address)); - } - - Ok(ContractsConfig { - history_address: history_address - .ok_or(ContractsConfigError::MissingHistoryContractConfig)?, - authority_address: authority_address - .ok_or(ContractsConfigError::MissingAuthorityContractConfig)?, - }) - } -} - -#[derive(Debug, Snafu)] -pub enum ContractsConfigError { - #[snafu(display("Json deserialize error"))] - JsonDeserializeError { source: serde_json::Error }, - - #[snafu(display("Json read error ({})", path.display()))] - JsonReadError { - path: PathBuf, - source: serde_json::Error, - }, - - #[snafu(display("Read file error ({})", path.display()))] - ReadFileError { - path: PathBuf, - source: std::io::Error, - }, - - #[snafu(display("Missing History contract configuration"))] - MissingHistoryContractConfig, - - #[snafu(display("Missing Authority contract configuration"))] - MissingAuthorityContractConfig, -} - -// ------------------------------------------------------------------------------------------------ -// Auxiliary -// ------------------------------------------------------------------------------------------------ - -fn read(path: PathBuf) -> Result { - let file = - File::open(&path).context(ReadFileSnafu { path: path.clone() })?; - let reader = BufReader::new(file); - serde_json::from_reader(reader).context(JsonReadSnafu { path }) -} - -fn deserialize( - s: String, -) -> Result { - serde_json::from_value(serde_json::Value::String(s)) - .context(JsonDeserializeSnafu) -} diff --git a/cmd/authority-claimer/src/config/error.rs b/cmd/authority-claimer/src/config/error.rs deleted file mode 100644 index fa961980e..000000000 --- a/cmd/authority-claimer/src/config/error.rs +++ /dev/null @@ -1,40 +0,0 @@ -// (c) Cartesi and individual authors (see AUTHORS) -// SPDX-License-Identifier: Apache-2.0 (see LICENSE) - -use eth_tx_manager::config::Error as TxManagerConfigError; -use rusoto_core::region::ParseRegionError; -use snafu::Snafu; - -use super::ContractsConfigError; - -#[derive(Debug, Snafu)] -#[snafu(visibility(pub(crate)))] -pub enum AuthorityClaimerConfigError { - #[snafu(display("TxManager configuration error"))] - TxManager { source: TxManagerConfigError }, - - #[snafu(display("TxSigning configuration error"))] - TxSigning { source: TxSigningConfigError }, - - #[snafu(display("Contracts configuration error"))] - Contracts { source: ContractsConfigError }, -} - -#[derive(Debug, Snafu)] -#[snafu(visibility(pub(crate)))] -pub enum TxSigningConfigError { - #[snafu(display("Missing auth configuration"))] - AuthConfigMissing, - - #[snafu(display("Could not read mnemonic file at path `{}`", path,))] - MnemonicFileError { - path: String, - source: std::io::Error, - }, - - #[snafu(display("Missing AWS region"))] - MissingRegion, - - #[snafu(display("Invalid AWS region"))] - InvalidRegion { source: ParseRegionError }, -} diff --git a/cmd/authority-claimer/src/config/mod.rs b/cmd/authority-claimer/src/config/mod.rs deleted file mode 100644 index 9fffb4fac..000000000 --- a/cmd/authority-claimer/src/config/mod.rs +++ /dev/null @@ -1,63 +0,0 @@ -// (c) Cartesi and individual authors (see AUTHORS) -// SPDX-License-Identifier: Apache-2.0 (see LICENSE) - -mod cli; -mod contracts; -mod error; - -pub use contracts::{ContractsConfig, ContractsConfigError}; -pub use error::AuthorityClaimerConfigError; - -use crate::http_server::HttpServerConfig; -use crate::log::LogConfig; -use crate::redacted::Redacted; -use crate::rollups_events::BrokerConfig; -use cli::AuthorityClaimerCLI; -use eth_tx_manager::{config::TxManagerConfig, Priority}; -use rusoto_core::Region; - -#[derive(Debug, Clone)] -pub struct Config { - pub authority_claimer_config: AuthorityClaimerConfig, - pub http_server_config: HttpServerConfig, -} - -#[derive(Debug, Clone)] -pub struct AuthorityClaimerConfig { - pub tx_manager_config: TxManagerConfig, - pub tx_signing_config: TxSigningConfig, - pub tx_manager_priority: Priority, - pub broker_config: BrokerConfig, - pub log_config: LogConfig, - pub contracts_config: ContractsConfig, - pub genesis_block: u64, -} - -#[derive(Debug, Clone)] -pub enum TxSigningConfig { - PrivateKey { - private_key: Redacted, - }, - - Mnemonic { - mnemonic: Redacted, - account_index: Option, - }, - - Aws { - key_id: String, - region: Region, - }, -} - -impl Config { - pub fn new() -> Result { - let (http_server_config, authority_claimer_cli) = - HttpServerConfig::parse::("authority_claimer"); - let authority_claimer_config = authority_claimer_cli.try_into()?; - Ok(Self { - authority_claimer_config, - http_server_config, - }) - } -} diff --git a/cmd/authority-claimer/src/contracts.rs b/cmd/authority-claimer/src/contracts.rs index bdc43df33..9869dbcb9 100644 --- a/cmd/authority-claimer/src/contracts.rs +++ b/cmd/authority-claimer/src/contracts.rs @@ -15,5 +15,4 @@ macro_rules! contract { }; } -contract!(authority); -contract!(history); +contract!(iconsensus); diff --git a/cmd/authority-claimer/src/http_server.rs b/cmd/authority-claimer/src/http_server.rs index 1c8fb97d6..727ee948e 100644 --- a/cmd/authority-claimer/src/http_server.rs +++ b/cmd/authority-claimer/src/http_server.rs @@ -10,49 +10,6 @@ pub use prometheus_client::metrics::counter::Counter as CounterRef; pub use prometheus_client::metrics::family::Family as FamilyRef; // End of metrics to re-export. -use clap::{ - value_parser, Arg, Command, CommandFactory, FromArgMatches, Parser, -}; - -#[derive(Debug, Clone, Parser)] -pub struct HttpServerConfig { - pub(crate) port: u16, -} - -impl HttpServerConfig { - /// Returns the HTTP server config and the app's config after parsing - /// it from the command line and/or environment variables. - /// - /// The parameter `service` must be a lowercase string that - /// uses underlines as spaces. - /// - /// The parametric type `C` must be a struct that derives `Parser`. - pub fn parse( - service: &'static str, - ) -> (HttpServerConfig, C) { - let command = ::command(); - let command = add_port_arg(command, service); - - let matches = command.get_matches(); - let http_server_config: HttpServerConfig = - FromArgMatches::from_arg_matches(&matches).unwrap(); - let inner_config: C = - FromArgMatches::from_arg_matches(&matches).unwrap(); - (http_server_config, inner_config) - } -} - -fn add_port_arg(command: Command, service: S) -> Command { - let service = service.to_string().to_uppercase(); - command.arg( - Arg::new("port") - .long("http-server-port") - .env(format!("{}_HTTP_SERVER_PORT", service)) - .value_parser(value_parser!(u16)) - .default_value("8080"), - ) -} - use axum::{routing::get, Router}; use prometheus_client::encoding::text::encode; use std::{ @@ -64,11 +21,11 @@ use std::{ /// /// The `Registry` parameter is a `prometheus` type used for metric tracking. pub async fn start( - config: HttpServerConfig, + port: u16, registry: Registry, ) -> Result<(), std::io::Error> { let ip = "0.0.0.0".parse().expect("could not parse host address"); - let addr = SocketAddr::new(ip, config.port); + let addr = SocketAddr::new(ip, port); tracing::info!("Starting HTTP server at {}", addr); let registry = Arc::new(Mutex::new(registry)); diff --git a/cmd/authority-claimer/src/lib.rs b/cmd/authority-claimer/src/lib.rs index 7120f5629..9132f0f7d 100644 --- a/cmd/authority-claimer/src/lib.rs +++ b/cmd/authority-claimer/src/lib.rs @@ -18,14 +18,14 @@ mod types; #[cfg(test)] mod test_fixtures; -use crate::{ - checker::DefaultDuplicateChecker, - claimer::{Claimer, DefaultClaimer}, - listener::DefaultBrokerListener, - metrics::AuthorityClaimerMetrics, - sender::DefaultTransactionSender, -}; +use checker::DefaultDuplicateChecker; +use claimer::{Claimer, DefaultClaimer}; pub use config::Config; +use ethers::signers::Signer; +use listener::DefaultBrokerListener; +use metrics::AuthorityClaimerMetrics; +use sender::DefaultTransactionSender; +use signer::ConditionalSigner; use snafu::Error; use tracing::trace; @@ -33,9 +33,8 @@ pub async fn run(config: Config) -> Result<(), Box> { // Creating the metrics and health server. let metrics = AuthorityClaimerMetrics::new(); let http_server_handle = - http_server::start(config.http_server_config, metrics.clone().into()); + http_server::start(config.http_server_port, metrics.clone().into()); - let config = config.authority_claimer_config; let chain_id = config.tx_manager_config.chain_id; // Creating the broker listener. @@ -44,11 +43,17 @@ pub async fn run(config: Config) -> Result<(), Box> { DefaultBrokerListener::new(config.broker_config.clone(), chain_id) .await?; + // Creating the conditional signer. + let conditional_signer = + ConditionalSigner::new(chain_id, &config.tx_signing_config).await?; + let from = conditional_signer.address(); + // Creating the duplicate checker. trace!("Creating the duplicate checker"); let duplicate_checker = DefaultDuplicateChecker::new( config.tx_manager_config.provider_http_endpoint.clone(), - config.contracts_config.history_address.clone(), + config.iconsensus_address.clone(), + from, config.tx_manager_config.default_confirmations, config.genesis_block, ) @@ -56,9 +61,16 @@ pub async fn run(config: Config) -> Result<(), Box> { // Creating the transaction sender. trace!("Creating the transaction sender"); - let transaction_sender = - DefaultTransactionSender::new(config.clone(), chain_id, metrics) - .await?; + let transaction_sender = DefaultTransactionSender::new( + config.tx_manager_config, + config.tx_manager_priority, + conditional_signer, + config.iconsensus_address, + from, + chain_id, + metrics, + ) + .await?; // Creating the claimer loop. let claimer = DefaultClaimer::new( diff --git a/cmd/authority-claimer/src/main.rs b/cmd/authority-claimer/src/main.rs index 145e8551e..c628a776c 100644 --- a/cmd/authority-claimer/src/main.rs +++ b/cmd/authority-claimer/src/main.rs @@ -10,7 +10,7 @@ async fn main() -> Result<(), Box> { let config: Config = Config::new().map_err(Box::new)?; // Setting up the logging environment. - log::configure(&config.authority_claimer_config.log_config); + log::configure(&config.log_config); //Log Service info log::log_service_start(&config, "Authority Claimer"); diff --git a/cmd/authority-claimer/src/metrics.rs b/cmd/authority-claimer/src/metrics.rs index 7108c88e5..1167b894f 100644 --- a/cmd/authority-claimer/src/metrics.rs +++ b/cmd/authority-claimer/src/metrics.rs @@ -1,8 +1,10 @@ // (c) Cartesi and individual authors (see AUTHORS) // SPDX-License-Identifier: Apache-2.0 (see LICENSE) -use crate::http_server::{CounterRef, FamilyRef, Registry}; -use crate::rollups_events::DAppMetadata; +use crate::{ + http_server::{CounterRef, FamilyRef, Registry}, + rollups_events::DAppMetadata, +}; const METRICS_PREFIX: &str = "cartesi_rollups_authority_claimer"; diff --git a/cmd/authority-claimer/src/rollups_events/broker.rs b/cmd/authority-claimer/src/rollups_events/broker.rs index 9df69c5ed..51f31bd17 100644 --- a/cmd/authority-claimer/src/rollups_events/broker.rs +++ b/cmd/authority-claimer/src/rollups_events/broker.rs @@ -1,23 +1,19 @@ // (c) Cartesi and individual authors (see AUTHORS) // SPDX-License-Identifier: Apache-2.0 (see LICENSE) +use crate::redacted::{RedactedUrl, Url}; use backoff::{future::retry, ExponentialBackoff, ExponentialBackoffBuilder}; use clap::Parser; -use redis::aio::{ConnectionLike, ConnectionManager}; -use redis::cluster::ClusterClient; -use redis::cluster_async::ClusterConnection; -use redis::streams::{ - StreamId, StreamRangeReply, StreamReadOptions, StreamReadReply, -}; use redis::{ + aio::{ConnectionLike, ConnectionManager}, + cluster::ClusterClient, + cluster_async::ClusterConnection, + streams::{StreamId, StreamRangeReply, StreamReadOptions, StreamReadReply}, AsyncCommands, Client, Cmd, Pipeline, RedisError, RedisFuture, Value, }; use serde::{de::DeserializeOwned, Serialize}; use snafu::{ResultExt, Snafu}; -use std::fmt; -use std::time::Duration; - -use crate::redacted::{RedactedUrl, Url}; +use std::{fmt, time::Duration}; pub const INITIAL_ID: &str = "0"; diff --git a/cmd/authority-claimer/src/rollups_events/common.rs b/cmd/authority-claimer/src/rollups_events/common.rs index 5fbb73fa0..33c9e8fa4 100644 --- a/cmd/authority-claimer/src/rollups_events/common.rs +++ b/cmd/authority-claimer/src/rollups_events/common.rs @@ -2,8 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 (see LICENSE) use base64::{engine::general_purpose::STANDARD as base64_engine, Engine as _}; -use prometheus_client::encoding::EncodeLabelValue; -use prometheus_client::encoding::LabelValueEncoder; +use prometheus_client::encoding::{EncodeLabelValue, LabelValueEncoder}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::fmt::Write; diff --git a/cmd/authority-claimer/src/rollups_events/rollups_claims.rs b/cmd/authority-claimer/src/rollups_events/rollups_claims.rs index 7c5abc6ae..2d216ed61 100644 --- a/cmd/authority-claimer/src/rollups_events/rollups_claims.rs +++ b/cmd/authority-claimer/src/rollups_events/rollups_claims.rs @@ -1,9 +1,8 @@ // (c) Cartesi and individual authors (see AUTHORS) // SPDX-License-Identifier: Apache-2.0 (see LICENSE) -use serde::{Deserialize, Serialize}; - use super::{Address, BrokerStream, Hash}; +use serde::{Deserialize, Serialize}; #[derive(Debug)] pub struct RollupsClaimsStream { diff --git a/cmd/authority-claimer/src/sender.rs b/cmd/authority-claimer/src/sender.rs index 634ecb0bf..0edc16f42 100644 --- a/cmd/authority-claimer/src/sender.rs +++ b/cmd/authority-claimer/src/sender.rs @@ -1,10 +1,15 @@ // (c) Cartesi and individual authors (see AUTHORS) // SPDX-License-Identifier: Apache-2.0 (see LICENSE) -use crate::contracts::{authority::Authority, history::Claim}; -use crate::rollups_events::{DAppMetadata, RollupsClaim}; +use crate::{ + contracts::iconsensus::{IConsensus, InputRange}, + metrics::AuthorityClaimerMetrics, + rollups_events::{Address, DAppMetadata, RollupsClaim}, + signer::{ConditionalSigner, ConditionalSignerError}, +}; use async_trait::async_trait; use eth_tx_manager::{ + config::TxManagerConfig, database::FileSystemDatabase as Database, gas_oracle::DefaultGasOracle as GasOracle, manager::Configuration, @@ -12,29 +17,19 @@ use eth_tx_manager::{ transaction::{Priority, Transaction, Value}, Chain, }; -use ethabi::Token; use ethers::{ self, - abi::AbiEncode, middleware::SignerMiddleware, providers::{ Http, HttpRateLimitRetryPolicy, MockProvider, Provider, RetryClient, }, - signers::Signer, - types::{Bytes, NameOrAddress, H160}, + types::{NameOrAddress, H160}, }; use snafu::{OptionExt, ResultExt, Snafu}; -use std::fmt::Debug; -use std::sync::Arc; +use std::{fmt::Debug, sync::Arc}; use tracing::{info, trace}; use url::{ParseError, Url}; -use crate::{ - config::AuthorityClaimerConfig, - metrics::AuthorityClaimerMetrics, - signer::{ConditionalSigner, ConditionalSignerError}, -}; - /// The `TransactionSender` sends claims to the blockchain. /// /// It should wait for N blockchain confirmations. @@ -78,31 +73,13 @@ macro_rules! tx_manager { }; } -struct SubmittableClaim(ethers::types::Address, RollupsClaim); - -impl From for Bytes { - fn from(submittable_claim: SubmittableClaim) -> Self { - let SubmittableClaim(dapp_address, claim) = submittable_claim; - let claim = Claim { - epoch_hash: claim.epoch_hash.into_inner(), - first_index: claim.first_index, - last_index: claim.last_index, - }; - ethers::abi::encode(&[ - Token::Address(dapp_address), - Token::FixedBytes(claim.encode()), - ]) - .into() - } -} - #[derive(Debug)] pub struct DefaultTransactionSender { tx_manager: TransactionManager, confirmations: usize, priority: Priority, from: ethers::types::Address, - authority: Authority>, + iconsensus: IConsensus>, chain_id: u64, metrics: AuthorityClaimerMetrics, } @@ -149,13 +126,12 @@ fn create_middleware( /// Creates the tx-manager instance. /// NOTE: tries to re-instantiate the tx-manager only once. async fn create_tx_manager( - conditional_signer: &ConditionalSigner, + conditional_signer: ConditionalSigner, provider_url: String, database_path: String, chain: Chain, ) -> Result { - let middleware = - create_middleware(conditional_signer.clone(), provider_url)?; + let middleware = create_middleware(conditional_signer, provider_url)?; let result = tx_manager!(new, middleware, database_path, chain); let tx_manager = if let Err(TrasactionManagerError::NonceTooLow { .. }) = result { @@ -173,42 +149,37 @@ async fn create_tx_manager( impl DefaultTransactionSender { pub async fn new( - config: AuthorityClaimerConfig, + tx_manager_config: TxManagerConfig, + tx_manager_priority: Priority, + conditional_signer: ConditionalSigner, + iconsensus: Address, + from: ethers::types::Address, chain_id: u64, metrics: AuthorityClaimerMetrics, ) -> Result { - let chain: Chain = (&config.tx_manager_config).into(); - - let conditional_signer = - ConditionalSigner::new(chain.id, &config.tx_signing_config) - .await - .context(SignerSnafu)?; + let chain: Chain = (&tx_manager_config).into(); let tx_manager = create_tx_manager( - &conditional_signer, - config.tx_manager_config.provider_http_endpoint.clone(), - config.tx_manager_config.database_path.clone(), + conditional_signer, + tx_manager_config.provider_http_endpoint.clone(), + tx_manager_config.database_path.clone(), chain, ) .await?; - let authority = { + let iconsensus = { let (provider, _mock) = Provider::mocked(); let provider = Arc::new(provider); - let address: H160 = config - .contracts_config - .authority_address - .into_inner() - .into(); - Authority::new(address, provider) + let address: H160 = iconsensus.into_inner().into(); + IConsensus::new(address, provider) }; Ok(Self { tx_manager, - confirmations: config.tx_manager_config.default_confirmations, - priority: config.tx_manager_priority, - from: conditional_signer.address(), - authority, + confirmations: tx_manager_config.default_confirmations, + priority: tx_manager_priority, + iconsensus, + from, chain_id, metrics, }) @@ -226,13 +197,17 @@ impl TransactionSender for DefaultTransactionSender { let dapp_address = rollups_claim.dapp_address.clone(); let transaction = { - let submittable_claim = SubmittableClaim( - H160(dapp_address.inner().to_owned()), - rollups_claim, - ); + let input_range = InputRange { + first_index: rollups_claim.first_index as u64, + last_index: rollups_claim.last_index as u64, + }; let call = self - .authority - .submit_claim(submittable_claim.into()) + .iconsensus + .submit_claim( + H160(dapp_address.inner().to_owned()), + input_range, + rollups_claim.epoch_hash.into_inner(), + ) .from(self.from); let to = match call.tx.to().context(InternalEthersSnafu)? { NameOrAddress::Address(a) => *a, diff --git a/cmd/authority-claimer/src/signer/aws_signer.rs b/cmd/authority-claimer/src/signer/aws_signer.rs index 29476ee45..49982a538 100644 --- a/cmd/authority-claimer/src/signer/aws_signer.rs +++ b/cmd/authority-claimer/src/signer/aws_signer.rs @@ -1,6 +1,7 @@ // (c) Cartesi and individual authors (see AUTHORS) // SPDX-License-Identifier: Apache-2.0 (see LICENSE) +use super::aws_credentials::AwsCredentialsProvider; use async_trait::async_trait; use ethers::{ signers::{AwsSigner as InnerAwsSigner, AwsSignerError, Signer}, @@ -12,8 +13,6 @@ use ethers::{ use rusoto_core::{HttpClient, Region}; use rusoto_kms::KmsClient; -use super::aws_credentials::AwsCredentialsProvider; - /// The `AwsSigner` (re)implements the `Signer` trait for the `InnerAwsSigner`. /// /// We do not use an `InnerAwsSigner` directly because of lifetime and diff --git a/cmd/authority-claimer/src/signer/signer.rs b/cmd/authority-claimer/src/signer/signer.rs index 14fd25ce1..9a1cb5587 100644 --- a/cmd/authority-claimer/src/signer/signer.rs +++ b/cmd/authority-claimer/src/signer/signer.rs @@ -1,6 +1,7 @@ // (c) Cartesi and individual authors (see AUTHORS) // SPDX-License-Identifier: Apache-2.0 (see LICENSE) +use crate::{config::TxSigningConfig, signer::aws_signer::AwsSigner}; use async_trait::async_trait; use ethers::{ signers::{ @@ -14,8 +15,6 @@ use ethers::{ }; use snafu::{ResultExt, Snafu}; -use crate::{config::TxSigningConfig, signer::aws_signer::AwsSigner}; - /// The `ConditionalSigner` is implementing conditional dispatch (instead of /// dynamic dispatch) by hand for objects that implement the `Sender` trait. /// diff --git a/cmd/authority-claimer/src/test_fixtures.rs b/cmd/authority-claimer/src/test_fixtures.rs index 38662cc54..2e7dc0f69 100644 --- a/cmd/authority-claimer/src/test_fixtures.rs +++ b/cmd/authority-claimer/src/test_fixtures.rs @@ -1,10 +1,13 @@ // (c) Cartesi and individual authors (see AUTHORS) // SPDX-License-Identifier: Apache-2.0 (see LICENSE) -use crate::redacted::{RedactedUrl, Url}; -use crate::rollups_events::{ - broker::BrokerEndpoint, common::ADDRESS_SIZE, Address, Broker, - BrokerConfig, DAppMetadata, RollupsClaim, RollupsClaimsStream, INITIAL_ID, +use crate::{ + redacted::{RedactedUrl, Url}, + rollups_events::{ + broker::BrokerEndpoint, common::ADDRESS_SIZE, Address, Broker, + BrokerConfig, DAppMetadata, RollupsClaim, RollupsClaimsStream, + INITIAL_ID, + }, }; use backoff::ExponentialBackoff; use testcontainers::{ diff --git a/cmd/cartesi-rollups-cli/root/execute/execute.go b/cmd/cartesi-rollups-cli/root/execute/execute.go index c5505ec61..8e4d816c0 100644 --- a/cmd/cartesi-rollups-cli/root/execute/execute.go +++ b/cmd/cartesi-rollups-cli/root/execute/execute.go @@ -94,15 +94,14 @@ func run(cmd *cobra.Command, args []string) { slog.Info("Executing voucher", "voucher-index", voucherIndex, "input-index", inputIndex, - "application-address", book.CartesiDApp, + "application-address", book.Application, ) - txHash, err := ethutil.ExecuteVoucher( + txHash, err := ethutil.ExecuteOutput( ctx, client, book, signer, resp.Payload, - &resp.Destination, proof, ) cobra.CheckErr(err) diff --git a/cmd/cartesi-rollups-cli/root/send/send.go b/cmd/cartesi-rollups-cli/root/send/send.go index d44554eb2..da62b3c87 100644 --- a/cmd/cartesi-rollups-cli/root/send/send.go +++ b/cmd/cartesi-rollups-cli/root/send/send.go @@ -70,7 +70,7 @@ func run(cmd *cobra.Command, args []string) { book = addresses.GetTestBook() } - slog.Info("Sending input", "application-address", book.CartesiDApp) + slog.Info("Sending input", "application-address", book.Application) inputIndex, err := ethutil.AddInput(ctx, client, book, signer, payload) cobra.CheckErr(err) diff --git a/cmd/cartesi-rollups-cli/root/validate/validate.go b/cmd/cartesi-rollups-cli/root/validate/validate.go index fcca2fc79..03684d9ef 100644 --- a/cmd/cartesi-rollups-cli/root/validate/validate.go +++ b/cmd/cartesi-rollups-cli/root/validate/validate.go @@ -83,9 +83,9 @@ func run(cmd *cobra.Command, args []string) { slog.Info("Validating notice", "notice-index", noticeIndex, "input-index", inputIndex, - "application-address", book.CartesiDApp, + "application-address", book.Application, ) - err = ethutil.ValidateNotice(ctx, client, book, resp.Payload, proof) + err = ethutil.ValidateOutput(ctx, client, book, resp.Payload, proof) cobra.CheckErr(err) slog.Info("Notice validated") diff --git a/cmd/gen-devnet/deployer.go b/cmd/gen-devnet/deployer.go index 9fcc4a578..06701a0d3 100644 --- a/cmd/gen-devnet/deployer.go +++ b/cmd/gen-devnet/deployer.go @@ -12,7 +12,6 @@ import ( "github.com/cartesi/rollups-node/pkg/addresses" "github.com/cartesi/rollups-node/pkg/ethutil" - "github.com/ethereum/go-ethereum/common" ) const ( @@ -42,32 +41,41 @@ func deploy(ctx context.Context, // Create a Rollups Application by calling the necessary factories func createApplication(ctx context.Context, hash string) (DeploymentInfo, error) { var depInfo DeploymentInfo + addressBook := addresses.GetTestBook() - // Create the Authority/History pair + // Create the Authority contract contractAddresses, _, err := createContracts(ctx, - common.Address.Hex(addresses.GetTestBook().AuthorityHistoryPairFactory), - "newAuthorityHistoryPair(address,bytes32)(address,address)", + addressBook.AuthorityFactory.Hex(), + "newAuthority(address,bytes32)(address)", CONTRACT_OWNER_ADDRESS, SALT) if err != nil { - return DeploymentInfo{}, fmt.Errorf("could not create authority/history pair: %v", err) + return DeploymentInfo{}, fmt.Errorf("could not create authority: %v", err) } - depInfo.AuthorityAddress = contractAddresses[0] - depInfo.HistoryAddress = contractAddresses[1] + + portalAddresses := []string{ + addressBook.ERC1155BatchPortal.Hex(), + addressBook.ERC1155SinglePortal.Hex(), + addressBook.ERC20Portal.Hex(), + addressBook.ERC721Portal.Hex(), + addressBook.EtherPortal.Hex(), + } + supportedPortals := "[" + strings.Join(portalAddresses, ",") + "]" // Create the Application, passing the address of the newly created Authority contractAddresses, blockNumber, err := createContracts(ctx, - common.Address.Hex(addresses.GetTestBook().CartesiDAppFactory), - "newApplication(address,address,bytes32,bytes32)(address)", + addressBook.ApplicationFactory.Hex(), + "newApplication(address,address,address[],address,bytes32,bytes32)(address)", depInfo.AuthorityAddress, + addressBook.InputBox.Hex(), + supportedPortals, CONTRACT_OWNER_ADDRESS, hash, SALT) if err != nil { return DeploymentInfo{}, fmt.Errorf("could not create application: %v", err) } - depInfo.ApplicationAddress = contractAddresses[0] depInfo.BlockNumber = blockNumber diff --git a/cmd/gen-devnet/main.go b/cmd/gen-devnet/main.go index 936a03bef..8c80bbb90 100644 --- a/cmd/gen-devnet/main.go +++ b/cmd/gen-devnet/main.go @@ -43,11 +43,11 @@ var ( ) func init() { - // Default path based on submodule location for rollups-contracts 1.2 + // Default path based on submodule location for rollups-contracts 2.0 Cmd.Flags().StringVarP(&rollupsContractsPath, "rollups-contracts-hardhat-path", "r", - "rollups-contracts/onchain/rollups", + "rollups-contracts", "path for the hardhat project used to deploy rollups-contracts") Cmd.Flags().StringVarP(&hashFile, diff --git a/cmd/gen-devnet/rollups.go b/cmd/gen-devnet/rollups.go index 889bbd915..aa34298f6 100644 --- a/cmd/gen-devnet/rollups.go +++ b/cmd/gen-devnet/rollups.go @@ -53,15 +53,15 @@ func copyContracts(ctx context.Context, srcDir string, destDir string) error { // Deploy rollups-contracts by using its own deployment script func deployContracts(ctx context.Context, execDir string) error { - cmdDir := execDir + "/rollups" + cmdDir := execDir + "/rollups-contracts" - cmd := exec.CommandContext(ctx, "yarn", "install") + cmd := exec.CommandContext(ctx, "pnpm", "install") cmd.Dir = cmdDir if err := cmd.Run(); err != nil { return fmt.Errorf("command '%v' failed with %v", cmd.String(), err) } - cmd = exec.CommandContext(ctx, "yarn", "deploy:development") + cmd = exec.CommandContext(ctx, "pnpm", "deploy:development") cmd.Env = os.Environ() cmd.Env = append(cmd.Env, "RPC_URL="+RPC_URL) cmd.Dir = cmdDir diff --git a/cmd/gen-devnet/types.go b/cmd/gen-devnet/types.go index c55181bb3..93d53bc4d 100644 --- a/cmd/gen-devnet/types.go +++ b/cmd/gen-devnet/types.go @@ -5,7 +5,6 @@ package main type DeploymentInfo struct { AuthorityAddress string `json:"CARTESI_CONTRACTS_AUTHORITY_ADDRESS"` - HistoryAddress string `json:"CARTESI_CONTRACTS_HISTORY_ADDRESS"` ApplicationAddress string `json:"CARTESI_CONTRACTS_APPLICATION_ADDRESS"` BlockNumber string `json:"CARTESI_CONTRACTS_APPLICATION_DEPLOYMENT_BLOCK_NUMBER"` } diff --git a/docs/config.md b/docs/config.md index 9cad6ebb9..9a1c48293 100644 --- a/docs/config.md +++ b/docs/config.md @@ -116,21 +116,9 @@ Address of the DApp's contract. * **Type:** `string` -## `CARTESI_CONTRACTS_APPLICATION_DEPLOYMENT_BLOCK_NUMBER` +## `CARTESI_CONTRACTS_ICONSENSUS_ADDRESS` -Block in which the DApp's contract was deployed. - -* **Type:** `int64` - -## `CARTESI_CONTRACTS_AUTHORITY_ADDRESS` - -Address of the Authority contract. - -* **Type:** `string` - -## `CARTESI_CONTRACTS_HISTORY_ADDRESS` - -Address of the History contract. +Address of the IConsensus contract. * **Type:** `string` diff --git a/internal/node/config/config.go b/internal/node/config/config.go index 3d12402c8..00d8cba4e 100644 --- a/internal/node/config/config.go +++ b/internal/node/config/config.go @@ -13,31 +13,29 @@ import ( // NodeConfig contains all the Node variables. // See the corresponding environment variable for the variable documentation. type NodeConfig struct { - LogLevel LogLevel - LogPretty bool - RollupsEpochDuration Duration - BlockchainID uint64 - BlockchainHttpEndpoint Redacted[string] - BlockchainWsEndpoint Redacted[string] - BlockchainIsLegacy bool - BlockchainFinalityOffset int - BlockchainBlockTimeout int - ContractsApplicationAddress string - ContractsApplicationDeploymentBlockNumber int64 - ContractsHistoryAddress string - ContractsAuthorityAddress string - ContractsInputBoxAddress string - ContractsInputBoxDeploymentBlockNumber int64 - SnapshotDir string - PostgresEndpoint Redacted[string] - HttpAddress string - HttpPort int - FeatureDisableClaimer bool - FeatureDisableMachineHashCheck bool - ExperimentalServerManagerBypassLog bool - ExperimentalSunodoValidatorEnabled bool - ExperimentalSunodoValidatorRedisEndpoint string - Auth Auth + LogLevel LogLevel + LogPretty bool + RollupsEpochDuration Duration + BlockchainID uint64 + BlockchainHttpEndpoint Redacted[string] + BlockchainWsEndpoint Redacted[string] + BlockchainIsLegacy bool + BlockchainFinalityOffset int + BlockchainBlockTimeout int + ContractsApplicationAddress string + ContractsIConsensusAddress string + ContractsInputBoxAddress string + ContractsInputBoxDeploymentBlockNumber int64 + SnapshotDir string + PostgresEndpoint Redacted[string] + HttpAddress string + HttpPort int + FeatureDisableClaimer bool + FeatureDisableMachineHashCheck bool + ExperimentalServerManagerBypassLog bool + ExperimentalSunodoValidatorEnabled bool + ExperimentalSunodoValidatorRedisEndpoint string + Auth Auth } // Auth is used to sign transactions. @@ -82,10 +80,7 @@ func FromEnv() NodeConfig { config.BlockchainFinalityOffset = getBlockchainFinalityOffset() config.BlockchainBlockTimeout = getBlockchainBlockTimeout() config.ContractsApplicationAddress = getContractsApplicationAddress() - config.ContractsApplicationDeploymentBlockNumber = - getContractsApplicationDeploymentBlockNumber() - config.ContractsHistoryAddress = getContractsHistoryAddress() - config.ContractsAuthorityAddress = getContractsAuthorityAddress() + config.ContractsIConsensusAddress = getContractsIconsensusAddress() config.ContractsInputBoxAddress = getContractsInputBoxAddress() config.ContractsInputBoxDeploymentBlockNumber = getContractsInputBoxDeploymentBlockNumber() config.SnapshotDir = getSnapshotDir() diff --git a/internal/node/config/generate/Config.toml b/internal/node/config/generate/Config.toml index 781184430..e055e4985 100644 --- a/internal/node/config/generate/Config.toml +++ b/internal/node/config/generate/Config.toml @@ -92,20 +92,10 @@ go-type = "string" description = """ Address of the DApp's contract.""" -[contracts.CARTESI_CONTRACTS_APPLICATION_DEPLOYMENT_BLOCK_NUMBER] -go-type = "int64" -description = """ -Block in which the DApp's contract was deployed.""" - -[contracts.CARTESI_CONTRACTS_HISTORY_ADDRESS] -go-type = "string" -description = """ -Address of the History contract.""" - -[contracts.CARTESI_CONTRACTS_AUTHORITY_ADDRESS] +[contracts.CARTESI_CONTRACTS_ICONSENSUS_ADDRESS] go-type = "string" description = """ -Address of the Authority contract.""" +Address of the IConsensus contract.""" [contracts.CARTESI_CONTRACTS_INPUT_BOX_ADDRESS] go-type = "string" diff --git a/internal/node/config/generated.go b/internal/node/config/generated.go index fd2671340..798999d0c 100644 --- a/internal/node/config/generated.go +++ b/internal/node/config/generated.go @@ -281,38 +281,14 @@ func getContractsApplicationAddress() string { return val } -func getContractsApplicationDeploymentBlockNumber() int64 { - s, ok := os.LookupEnv("CARTESI_CONTRACTS_APPLICATION_DEPLOYMENT_BLOCK_NUMBER") +func getContractsIconsensusAddress() string { + s, ok := os.LookupEnv("CARTESI_CONTRACTS_ICONSENSUS_ADDRESS") if !ok { - panic("missing env var CARTESI_CONTRACTS_APPLICATION_DEPLOYMENT_BLOCK_NUMBER") - } - val, err := toInt64(s) - if err != nil { - panic(fmt.Sprintf("failed to parse CARTESI_CONTRACTS_APPLICATION_DEPLOYMENT_BLOCK_NUMBER: %v", err)) - } - return val -} - -func getContractsAuthorityAddress() string { - s, ok := os.LookupEnv("CARTESI_CONTRACTS_AUTHORITY_ADDRESS") - if !ok { - panic("missing env var CARTESI_CONTRACTS_AUTHORITY_ADDRESS") - } - val, err := toString(s) - if err != nil { - panic(fmt.Sprintf("failed to parse CARTESI_CONTRACTS_AUTHORITY_ADDRESS: %v", err)) - } - return val -} - -func getContractsHistoryAddress() string { - s, ok := os.LookupEnv("CARTESI_CONTRACTS_HISTORY_ADDRESS") - if !ok { - panic("missing env var CARTESI_CONTRACTS_HISTORY_ADDRESS") + panic("missing env var CARTESI_CONTRACTS_ICONSENSUS_ADDRESS") } val, err := toString(s) if err != nil { - panic(fmt.Sprintf("failed to parse CARTESI_CONTRACTS_HISTORY_ADDRESS: %v", err)) + panic(fmt.Sprintf("failed to parse CARTESI_CONTRACTS_ICONSENSUS_ADDRESS: %v", err)) } return val } diff --git a/internal/node/machinehash.go b/internal/node/machinehash.go index 3d7d05418..3f487ddc3 100644 --- a/internal/node/machinehash.go +++ b/internal/node/machinehash.go @@ -9,7 +9,7 @@ import ( "os" "path" - "github.com/cartesi/rollups-node/pkg/contracts" + "github.com/cartesi/rollups-node/pkg/contracts/application" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" @@ -69,7 +69,7 @@ func getTemplateHash( if err != nil { return "", fmt.Errorf("get template hash: %w", err) } - cartesiApplication, err := contracts.NewCartesiDAppCaller( + cartesiApplication, err := application.NewApplicationCaller( common.HexToAddress(applicationAddress), client, ) diff --git a/internal/node/machinehash_test.go b/internal/node/machinehash_test.go index 2c690deb9..ff2d13cf3 100644 --- a/internal/node/machinehash_test.go +++ b/internal/node/machinehash_test.go @@ -64,7 +64,7 @@ func (s *ValidateMachineHashSuite) TestItFailsWhenContextIsCanceled() { err = validateMachineHash( ctx, machineDir, - addresses.GetTestBook().CartesiDApp.String(), + addresses.GetTestBook().Application.String(), blockchainHttpEndpoint, ) s.NotNil(err) @@ -91,7 +91,7 @@ func (s *ValidateMachineHashSuite) TestItSucceedsWhenHashesAreEqual() { err = validateMachineHash( ctx, machineDir, - addresses.GetTestBook().CartesiDApp.String(), + addresses.GetTestBook().Application.String(), blockchainHttpEndpoint, ) s.Nil(err) diff --git a/internal/node/services.go b/internal/node/services.go index dcf0a9793..b769f508a 100644 --- a/internal/node/services.go +++ b/internal/node/services.go @@ -69,12 +69,11 @@ func newAuthorityClaimer(c config.NodeConfig, workDir string) services.CommandSe s.Env = append(s.Env, fmt.Sprintf("TX_DEFAULT_CONFIRMATIONS=%v", c.BlockchainFinalityOffset)) s.Env = append(s.Env, fmt.Sprintf("REDIS_ENDPOINT=%v", getRedisEndpoint(c))) - s.Env = append(s.Env, fmt.Sprintf("HISTORY_ADDRESS=%v", c.ContractsHistoryAddress)) - s.Env = append(s.Env, fmt.Sprintf("AUTHORITY_ADDRESS=%v", c.ContractsAuthorityAddress)) + s.Env = append(s.Env, fmt.Sprintf("ICONSENSUS_ADDRESS=%v", c.ContractsIConsensusAddress)) s.Env = append(s.Env, fmt.Sprintf("INPUT_BOX_ADDRESS=%v", c.ContractsInputBoxAddress)) s.Env = append(s.Env, fmt.Sprintf("GENESIS_BLOCK=%v", c.ContractsInputBoxDeploymentBlockNumber)) - s.Env = append(s.Env, fmt.Sprintf("AUTHORITY_CLAIMER_HTTP_SERVER_PORT=%v", + s.Env = append(s.Env, fmt.Sprintf("HTTP_SERVER_PORT=%v", getPort(c, portOffsetAuthorityClaimer))) switch auth := c.Auth.(type) { case config.AuthPrivateKey: diff --git a/pkg/addresses/addresses.go b/pkg/addresses/addresses.go index 8989e65b6..8a4b710a2 100644 --- a/pkg/addresses/addresses.go +++ b/pkg/addresses/addresses.go @@ -19,36 +19,32 @@ import ( // List of contract addresses. type Book struct { - AuthorityHistoryPairFactory common.Address - CartesiDAppFactory common.Address - DAppAddressRelay common.Address - ERC1155BatchPortal common.Address - ERC1155SinglePortal common.Address - ERC20Portal common.Address - ERC721Portal common.Address - EtherPortal common.Address - InputBox common.Address - CartesiDApp common.Address - HistoryAddress common.Address - AuthorityAddress common.Address + Application common.Address + ApplicationFactory common.Address + Authority common.Address + AuthorityFactory common.Address + DAppAddressRelay common.Address + ERC1155BatchPortal common.Address + ERC1155SinglePortal common.Address + ERC20Portal common.Address + ERC721Portal common.Address + EtherPortal common.Address + InputBox common.Address } // Get the addresses for the test environment. func GetTestBook() *Book { return &Book{ - AuthorityHistoryPairFactory: common. - HexToAddress("0x3890A047Cf9Af60731E80B2105362BbDCD70142D"), - CartesiDAppFactory: common.HexToAddress("0x7122cd1221C20892234186facfE8615e6743Ab02"), - DAppAddressRelay: common.HexToAddress("0xF5DE34d6BbC0446E2a45719E718efEbaaE179daE"), - ERC1155BatchPortal: common.HexToAddress("0xedB53860A6B52bbb7561Ad596416ee9965B055Aa"), - ERC1155SinglePortal: common.HexToAddress("0x7CFB0193Ca87eB6e48056885E026552c3A941FC4"), - ERC20Portal: common.HexToAddress("0x9C21AEb2093C32DDbC53eEF24B873BDCd1aDa1DB"), - ERC721Portal: common.HexToAddress("0x237F8DD094C0e47f4236f12b4Fa01d6Dae89fb87"), - EtherPortal: common.HexToAddress("0xFfdbe43d4c855BF7e0f105c400A50857f53AB044"), - InputBox: common.HexToAddress("0x59b22D57D4f067708AB0c00552767405926dc768"), - CartesiDApp: common.HexToAddress("0x7C54E3f7A8070a54223469965A871fB8f6f88c22"), - HistoryAddress: common.HexToAddress("0x325272217ae6815b494bF38cED004c5Eb8a7CdA7"), - AuthorityAddress: common.HexToAddress("0x58c93F83fb3304730C95aad2E360cdb88b782010"), + Application: common.HexToAddress("0xb72c832dDeA10326143831F1E5F1646920C9c990"), + ApplicationFactory: common.HexToAddress("0x39cc8d1faB70F713784032f166aB7Fe3B4801144"), + Authority: common.HexToAddress("0x77e5a5fb18F72b5106621f66C704c006c6dB4578"), + AuthorityFactory: common.HexToAddress("0x5EF4260c72a7A8df752AFF49aC46Ba741754E04a"), + ERC1155BatchPortal: common.HexToAddress("0x83D7fc8A2A2535A17b037598bad23562215a752A"), + ERC1155SinglePortal: common.HexToAddress("0x77b5b758f43E789E0858a766934bE08B2CD65feA"), + ERC20Portal: common.HexToAddress("0x8f4b3F53699EDd5374c3374b4Ee1CcA3d23E95Ab"), + ERC721Portal: common.HexToAddress("0xDF9d6F65E9a053FbaFF9eAaf0b522f1b35Dfd05B"), + EtherPortal: common.HexToAddress("0xF03FB966604bF02073b87b4586b3edBC201f73A6"), + InputBox: common.HexToAddress("0xA1b8EB1F13d8D5Db976a653BbDF8972cfD14691C"), } } diff --git a/pkg/contracts/application/application.go b/pkg/contracts/application/application.go new file mode 100644 index 000000000..709538064 --- /dev/null +++ b/pkg/contracts/application/application.go @@ -0,0 +1,1036 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package application + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// InputRange is an auto generated low-level Go binding around an user-defined struct. +type InputRange struct { + FirstIndex uint64 + LastIndex uint64 +} + +// OutputValidityProof is an auto generated low-level Go binding around an user-defined struct. +type OutputValidityProof struct { + InputRange InputRange + InputIndexWithinEpoch uint64 + OutputIndexWithinInput uint64 + OutputHashesRootHash [32]byte + OutputsEpochRootHash [32]byte + MachineStateHash [32]byte + OutputHashInOutputHashesSiblings [][32]byte + OutputHashesInEpochSiblings [][32]byte +} + +// ApplicationMetaData contains all meta data concerning the Application contract. +var ApplicationMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[{\"internalType\":\"contractIConsensus\",\"name\":\"consensus\",\"type\":\"address\"},{\"internalType\":\"contractIInputBox\",\"name\":\"inputBox\",\"type\":\"address\"},{\"internalType\":\"contractIPortal[]\",\"name\":\"portals\",\"type\":\"address[]\"},{\"internalType\":\"address\",\"name\":\"initialOwner\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"templateHash\",\"type\":\"bytes32\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"IncorrectEpochHash\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"IncorrectOutputHashesRootHash\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"IncorrectOutputsEpochRootHash\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"inputIndex\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint64\",\"name\":\"firstIndex\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"lastIndex\",\"type\":\"uint64\"}],\"internalType\":\"structInputRange\",\"name\":\"inputRange\",\"type\":\"tuple\"}],\"name\":\"InputIndexOutOfRange\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"output\",\"type\":\"bytes\"}],\"name\":\"OutputNotExecutable\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"output\",\"type\":\"bytes\"}],\"name\":\"OutputNotReexecutable\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"OwnableInvalidOwner\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"OwnableUnauthorizedAccount\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ReentrancyGuardReentrantCall\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contractIConsensus\",\"name\":\"newConsensus\",\"type\":\"address\"}],\"name\":\"NewConsensus\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"inputIndex\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"outputIndexWithinInput\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"output\",\"type\":\"bytes\"}],\"name\":\"OutputExecuted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"output\",\"type\":\"bytes\"},{\"components\":[{\"components\":[{\"internalType\":\"uint64\",\"name\":\"firstIndex\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"lastIndex\",\"type\":\"uint64\"}],\"internalType\":\"structInputRange\",\"name\":\"inputRange\",\"type\":\"tuple\"},{\"internalType\":\"uint64\",\"name\":\"inputIndexWithinEpoch\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"outputIndexWithinInput\",\"type\":\"uint64\"},{\"internalType\":\"bytes32\",\"name\":\"outputHashesRootHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"outputsEpochRootHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"machineStateHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32[]\",\"name\":\"outputHashInOutputHashesSiblings\",\"type\":\"bytes32[]\"},{\"internalType\":\"bytes32[]\",\"name\":\"outputHashesInEpochSiblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structOutputValidityProof\",\"name\":\"proof\",\"type\":\"tuple\"}],\"name\":\"executeOutput\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getConsensus\",\"outputs\":[{\"internalType\":\"contractIConsensus\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getInputBox\",\"outputs\":[{\"internalType\":\"contractIInputBox\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getPortals\",\"outputs\":[{\"internalType\":\"contractIPortal[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getTemplateHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contractIConsensus\",\"name\":\"newConsensus\",\"type\":\"address\"}],\"name\":\"migrateToConsensus\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"onERC1155BatchReceived\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"onERC1155Received\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"onERC721Received\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"output\",\"type\":\"bytes\"},{\"components\":[{\"components\":[{\"internalType\":\"uint64\",\"name\":\"firstIndex\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"lastIndex\",\"type\":\"uint64\"}],\"internalType\":\"structInputRange\",\"name\":\"inputRange\",\"type\":\"tuple\"},{\"internalType\":\"uint64\",\"name\":\"inputIndexWithinEpoch\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"outputIndexWithinInput\",\"type\":\"uint64\"},{\"internalType\":\"bytes32\",\"name\":\"outputHashesRootHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"outputsEpochRootHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"machineStateHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32[]\",\"name\":\"outputHashInOutputHashesSiblings\",\"type\":\"bytes32[]\"},{\"internalType\":\"bytes32[]\",\"name\":\"outputHashesInEpochSiblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structOutputValidityProof\",\"name\":\"proof\",\"type\":\"tuple\"}],\"name\":\"validateOutput\",\"outputs\":[],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"inputIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"outputIndexWithinInput\",\"type\":\"uint256\"}],\"name\":\"wasOutputExecuted\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", +} + +// ApplicationABI is the input ABI used to generate the binding from. +// Deprecated: Use ApplicationMetaData.ABI instead. +var ApplicationABI = ApplicationMetaData.ABI + +// Application is an auto generated Go binding around an Ethereum contract. +type Application struct { + ApplicationCaller // Read-only binding to the contract + ApplicationTransactor // Write-only binding to the contract + ApplicationFilterer // Log filterer for contract events +} + +// ApplicationCaller is an auto generated read-only Go binding around an Ethereum contract. +type ApplicationCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ApplicationTransactor is an auto generated write-only Go binding around an Ethereum contract. +type ApplicationTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ApplicationFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type ApplicationFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ApplicationSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type ApplicationSession struct { + Contract *Application // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// ApplicationCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type ApplicationCallerSession struct { + Contract *ApplicationCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// ApplicationTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type ApplicationTransactorSession struct { + Contract *ApplicationTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// ApplicationRaw is an auto generated low-level Go binding around an Ethereum contract. +type ApplicationRaw struct { + Contract *Application // Generic contract binding to access the raw methods on +} + +// ApplicationCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type ApplicationCallerRaw struct { + Contract *ApplicationCaller // Generic read-only contract binding to access the raw methods on +} + +// ApplicationTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type ApplicationTransactorRaw struct { + Contract *ApplicationTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewApplication creates a new instance of Application, bound to a specific deployed contract. +func NewApplication(address common.Address, backend bind.ContractBackend) (*Application, error) { + contract, err := bindApplication(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &Application{ApplicationCaller: ApplicationCaller{contract: contract}, ApplicationTransactor: ApplicationTransactor{contract: contract}, ApplicationFilterer: ApplicationFilterer{contract: contract}}, nil +} + +// NewApplicationCaller creates a new read-only instance of Application, bound to a specific deployed contract. +func NewApplicationCaller(address common.Address, caller bind.ContractCaller) (*ApplicationCaller, error) { + contract, err := bindApplication(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &ApplicationCaller{contract: contract}, nil +} + +// NewApplicationTransactor creates a new write-only instance of Application, bound to a specific deployed contract. +func NewApplicationTransactor(address common.Address, transactor bind.ContractTransactor) (*ApplicationTransactor, error) { + contract, err := bindApplication(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &ApplicationTransactor{contract: contract}, nil +} + +// NewApplicationFilterer creates a new log filterer instance of Application, bound to a specific deployed contract. +func NewApplicationFilterer(address common.Address, filterer bind.ContractFilterer) (*ApplicationFilterer, error) { + contract, err := bindApplication(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &ApplicationFilterer{contract: contract}, nil +} + +// bindApplication binds a generic wrapper to an already deployed contract. +func bindApplication(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := ApplicationMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Application *ApplicationRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Application.Contract.ApplicationCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Application *ApplicationRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Application.Contract.ApplicationTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Application *ApplicationRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Application.Contract.ApplicationTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Application *ApplicationCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Application.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Application *ApplicationTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Application.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Application *ApplicationTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Application.Contract.contract.Transact(opts, method, params...) +} + +// GetConsensus is a free data retrieval call binding the contract method 0x179e740b. +// +// Solidity: function getConsensus() view returns(address) +func (_Application *ApplicationCaller) GetConsensus(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Application.contract.Call(opts, &out, "getConsensus") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// GetConsensus is a free data retrieval call binding the contract method 0x179e740b. +// +// Solidity: function getConsensus() view returns(address) +func (_Application *ApplicationSession) GetConsensus() (common.Address, error) { + return _Application.Contract.GetConsensus(&_Application.CallOpts) +} + +// GetConsensus is a free data retrieval call binding the contract method 0x179e740b. +// +// Solidity: function getConsensus() view returns(address) +func (_Application *ApplicationCallerSession) GetConsensus() (common.Address, error) { + return _Application.Contract.GetConsensus(&_Application.CallOpts) +} + +// GetInputBox is a free data retrieval call binding the contract method 0x00aace9a. +// +// Solidity: function getInputBox() view returns(address) +func (_Application *ApplicationCaller) GetInputBox(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Application.contract.Call(opts, &out, "getInputBox") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// GetInputBox is a free data retrieval call binding the contract method 0x00aace9a. +// +// Solidity: function getInputBox() view returns(address) +func (_Application *ApplicationSession) GetInputBox() (common.Address, error) { + return _Application.Contract.GetInputBox(&_Application.CallOpts) +} + +// GetInputBox is a free data retrieval call binding the contract method 0x00aace9a. +// +// Solidity: function getInputBox() view returns(address) +func (_Application *ApplicationCallerSession) GetInputBox() (common.Address, error) { + return _Application.Contract.GetInputBox(&_Application.CallOpts) +} + +// GetPortals is a free data retrieval call binding the contract method 0x108e8c1d. +// +// Solidity: function getPortals() view returns(address[]) +func (_Application *ApplicationCaller) GetPortals(opts *bind.CallOpts) ([]common.Address, error) { + var out []interface{} + err := _Application.contract.Call(opts, &out, "getPortals") + + if err != nil { + return *new([]common.Address), err + } + + out0 := *abi.ConvertType(out[0], new([]common.Address)).(*[]common.Address) + + return out0, err + +} + +// GetPortals is a free data retrieval call binding the contract method 0x108e8c1d. +// +// Solidity: function getPortals() view returns(address[]) +func (_Application *ApplicationSession) GetPortals() ([]common.Address, error) { + return _Application.Contract.GetPortals(&_Application.CallOpts) +} + +// GetPortals is a free data retrieval call binding the contract method 0x108e8c1d. +// +// Solidity: function getPortals() view returns(address[]) +func (_Application *ApplicationCallerSession) GetPortals() ([]common.Address, error) { + return _Application.Contract.GetPortals(&_Application.CallOpts) +} + +// GetTemplateHash is a free data retrieval call binding the contract method 0x61b12c66. +// +// Solidity: function getTemplateHash() view returns(bytes32) +func (_Application *ApplicationCaller) GetTemplateHash(opts *bind.CallOpts) ([32]byte, error) { + var out []interface{} + err := _Application.contract.Call(opts, &out, "getTemplateHash") + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// GetTemplateHash is a free data retrieval call binding the contract method 0x61b12c66. +// +// Solidity: function getTemplateHash() view returns(bytes32) +func (_Application *ApplicationSession) GetTemplateHash() ([32]byte, error) { + return _Application.Contract.GetTemplateHash(&_Application.CallOpts) +} + +// GetTemplateHash is a free data retrieval call binding the contract method 0x61b12c66. +// +// Solidity: function getTemplateHash() view returns(bytes32) +func (_Application *ApplicationCallerSession) GetTemplateHash() ([32]byte, error) { + return _Application.Contract.GetTemplateHash(&_Application.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_Application *ApplicationCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Application.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_Application *ApplicationSession) Owner() (common.Address, error) { + return _Application.Contract.Owner(&_Application.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_Application *ApplicationCallerSession) Owner() (common.Address, error) { + return _Application.Contract.Owner(&_Application.CallOpts) +} + +// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7. +// +// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool) +func (_Application *ApplicationCaller) SupportsInterface(opts *bind.CallOpts, interfaceId [4]byte) (bool, error) { + var out []interface{} + err := _Application.contract.Call(opts, &out, "supportsInterface", interfaceId) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7. +// +// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool) +func (_Application *ApplicationSession) SupportsInterface(interfaceId [4]byte) (bool, error) { + return _Application.Contract.SupportsInterface(&_Application.CallOpts, interfaceId) +} + +// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7. +// +// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool) +func (_Application *ApplicationCallerSession) SupportsInterface(interfaceId [4]byte) (bool, error) { + return _Application.Contract.SupportsInterface(&_Application.CallOpts, interfaceId) +} + +// ValidateOutput is a free data retrieval call binding the contract method 0x4dcea155. +// +// Solidity: function validateOutput(bytes output, ((uint64,uint64),uint64,uint64,bytes32,bytes32,bytes32,bytes32[],bytes32[]) proof) view returns() +func (_Application *ApplicationCaller) ValidateOutput(opts *bind.CallOpts, output []byte, proof OutputValidityProof) error { + var out []interface{} + err := _Application.contract.Call(opts, &out, "validateOutput", output, proof) + + if err != nil { + return err + } + + return err + +} + +// ValidateOutput is a free data retrieval call binding the contract method 0x4dcea155. +// +// Solidity: function validateOutput(bytes output, ((uint64,uint64),uint64,uint64,bytes32,bytes32,bytes32,bytes32[],bytes32[]) proof) view returns() +func (_Application *ApplicationSession) ValidateOutput(output []byte, proof OutputValidityProof) error { + return _Application.Contract.ValidateOutput(&_Application.CallOpts, output, proof) +} + +// ValidateOutput is a free data retrieval call binding the contract method 0x4dcea155. +// +// Solidity: function validateOutput(bytes output, ((uint64,uint64),uint64,uint64,bytes32,bytes32,bytes32,bytes32[],bytes32[]) proof) view returns() +func (_Application *ApplicationCallerSession) ValidateOutput(output []byte, proof OutputValidityProof) error { + return _Application.Contract.ValidateOutput(&_Application.CallOpts, output, proof) +} + +// WasOutputExecuted is a free data retrieval call binding the contract method 0x24523192. +// +// Solidity: function wasOutputExecuted(uint256 inputIndex, uint256 outputIndexWithinInput) view returns(bool) +func (_Application *ApplicationCaller) WasOutputExecuted(opts *bind.CallOpts, inputIndex *big.Int, outputIndexWithinInput *big.Int) (bool, error) { + var out []interface{} + err := _Application.contract.Call(opts, &out, "wasOutputExecuted", inputIndex, outputIndexWithinInput) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// WasOutputExecuted is a free data retrieval call binding the contract method 0x24523192. +// +// Solidity: function wasOutputExecuted(uint256 inputIndex, uint256 outputIndexWithinInput) view returns(bool) +func (_Application *ApplicationSession) WasOutputExecuted(inputIndex *big.Int, outputIndexWithinInput *big.Int) (bool, error) { + return _Application.Contract.WasOutputExecuted(&_Application.CallOpts, inputIndex, outputIndexWithinInput) +} + +// WasOutputExecuted is a free data retrieval call binding the contract method 0x24523192. +// +// Solidity: function wasOutputExecuted(uint256 inputIndex, uint256 outputIndexWithinInput) view returns(bool) +func (_Application *ApplicationCallerSession) WasOutputExecuted(inputIndex *big.Int, outputIndexWithinInput *big.Int) (bool, error) { + return _Application.Contract.WasOutputExecuted(&_Application.CallOpts, inputIndex, outputIndexWithinInput) +} + +// ExecuteOutput is a paid mutator transaction binding the contract method 0xdbe1a6eb. +// +// Solidity: function executeOutput(bytes output, ((uint64,uint64),uint64,uint64,bytes32,bytes32,bytes32,bytes32[],bytes32[]) proof) returns() +func (_Application *ApplicationTransactor) ExecuteOutput(opts *bind.TransactOpts, output []byte, proof OutputValidityProof) (*types.Transaction, error) { + return _Application.contract.Transact(opts, "executeOutput", output, proof) +} + +// ExecuteOutput is a paid mutator transaction binding the contract method 0xdbe1a6eb. +// +// Solidity: function executeOutput(bytes output, ((uint64,uint64),uint64,uint64,bytes32,bytes32,bytes32,bytes32[],bytes32[]) proof) returns() +func (_Application *ApplicationSession) ExecuteOutput(output []byte, proof OutputValidityProof) (*types.Transaction, error) { + return _Application.Contract.ExecuteOutput(&_Application.TransactOpts, output, proof) +} + +// ExecuteOutput is a paid mutator transaction binding the contract method 0xdbe1a6eb. +// +// Solidity: function executeOutput(bytes output, ((uint64,uint64),uint64,uint64,bytes32,bytes32,bytes32,bytes32[],bytes32[]) proof) returns() +func (_Application *ApplicationTransactorSession) ExecuteOutput(output []byte, proof OutputValidityProof) (*types.Transaction, error) { + return _Application.Contract.ExecuteOutput(&_Application.TransactOpts, output, proof) +} + +// MigrateToConsensus is a paid mutator transaction binding the contract method 0xfc411683. +// +// Solidity: function migrateToConsensus(address newConsensus) returns() +func (_Application *ApplicationTransactor) MigrateToConsensus(opts *bind.TransactOpts, newConsensus common.Address) (*types.Transaction, error) { + return _Application.contract.Transact(opts, "migrateToConsensus", newConsensus) +} + +// MigrateToConsensus is a paid mutator transaction binding the contract method 0xfc411683. +// +// Solidity: function migrateToConsensus(address newConsensus) returns() +func (_Application *ApplicationSession) MigrateToConsensus(newConsensus common.Address) (*types.Transaction, error) { + return _Application.Contract.MigrateToConsensus(&_Application.TransactOpts, newConsensus) +} + +// MigrateToConsensus is a paid mutator transaction binding the contract method 0xfc411683. +// +// Solidity: function migrateToConsensus(address newConsensus) returns() +func (_Application *ApplicationTransactorSession) MigrateToConsensus(newConsensus common.Address) (*types.Transaction, error) { + return _Application.Contract.MigrateToConsensus(&_Application.TransactOpts, newConsensus) +} + +// OnERC1155BatchReceived is a paid mutator transaction binding the contract method 0xbc197c81. +// +// Solidity: function onERC1155BatchReceived(address , address , uint256[] , uint256[] , bytes ) returns(bytes4) +func (_Application *ApplicationTransactor) OnERC1155BatchReceived(opts *bind.TransactOpts, arg0 common.Address, arg1 common.Address, arg2 []*big.Int, arg3 []*big.Int, arg4 []byte) (*types.Transaction, error) { + return _Application.contract.Transact(opts, "onERC1155BatchReceived", arg0, arg1, arg2, arg3, arg4) +} + +// OnERC1155BatchReceived is a paid mutator transaction binding the contract method 0xbc197c81. +// +// Solidity: function onERC1155BatchReceived(address , address , uint256[] , uint256[] , bytes ) returns(bytes4) +func (_Application *ApplicationSession) OnERC1155BatchReceived(arg0 common.Address, arg1 common.Address, arg2 []*big.Int, arg3 []*big.Int, arg4 []byte) (*types.Transaction, error) { + return _Application.Contract.OnERC1155BatchReceived(&_Application.TransactOpts, arg0, arg1, arg2, arg3, arg4) +} + +// OnERC1155BatchReceived is a paid mutator transaction binding the contract method 0xbc197c81. +// +// Solidity: function onERC1155BatchReceived(address , address , uint256[] , uint256[] , bytes ) returns(bytes4) +func (_Application *ApplicationTransactorSession) OnERC1155BatchReceived(arg0 common.Address, arg1 common.Address, arg2 []*big.Int, arg3 []*big.Int, arg4 []byte) (*types.Transaction, error) { + return _Application.Contract.OnERC1155BatchReceived(&_Application.TransactOpts, arg0, arg1, arg2, arg3, arg4) +} + +// OnERC1155Received is a paid mutator transaction binding the contract method 0xf23a6e61. +// +// Solidity: function onERC1155Received(address , address , uint256 , uint256 , bytes ) returns(bytes4) +func (_Application *ApplicationTransactor) OnERC1155Received(opts *bind.TransactOpts, arg0 common.Address, arg1 common.Address, arg2 *big.Int, arg3 *big.Int, arg4 []byte) (*types.Transaction, error) { + return _Application.contract.Transact(opts, "onERC1155Received", arg0, arg1, arg2, arg3, arg4) +} + +// OnERC1155Received is a paid mutator transaction binding the contract method 0xf23a6e61. +// +// Solidity: function onERC1155Received(address , address , uint256 , uint256 , bytes ) returns(bytes4) +func (_Application *ApplicationSession) OnERC1155Received(arg0 common.Address, arg1 common.Address, arg2 *big.Int, arg3 *big.Int, arg4 []byte) (*types.Transaction, error) { + return _Application.Contract.OnERC1155Received(&_Application.TransactOpts, arg0, arg1, arg2, arg3, arg4) +} + +// OnERC1155Received is a paid mutator transaction binding the contract method 0xf23a6e61. +// +// Solidity: function onERC1155Received(address , address , uint256 , uint256 , bytes ) returns(bytes4) +func (_Application *ApplicationTransactorSession) OnERC1155Received(arg0 common.Address, arg1 common.Address, arg2 *big.Int, arg3 *big.Int, arg4 []byte) (*types.Transaction, error) { + return _Application.Contract.OnERC1155Received(&_Application.TransactOpts, arg0, arg1, arg2, arg3, arg4) +} + +// OnERC721Received is a paid mutator transaction binding the contract method 0x150b7a02. +// +// Solidity: function onERC721Received(address , address , uint256 , bytes ) returns(bytes4) +func (_Application *ApplicationTransactor) OnERC721Received(opts *bind.TransactOpts, arg0 common.Address, arg1 common.Address, arg2 *big.Int, arg3 []byte) (*types.Transaction, error) { + return _Application.contract.Transact(opts, "onERC721Received", arg0, arg1, arg2, arg3) +} + +// OnERC721Received is a paid mutator transaction binding the contract method 0x150b7a02. +// +// Solidity: function onERC721Received(address , address , uint256 , bytes ) returns(bytes4) +func (_Application *ApplicationSession) OnERC721Received(arg0 common.Address, arg1 common.Address, arg2 *big.Int, arg3 []byte) (*types.Transaction, error) { + return _Application.Contract.OnERC721Received(&_Application.TransactOpts, arg0, arg1, arg2, arg3) +} + +// OnERC721Received is a paid mutator transaction binding the contract method 0x150b7a02. +// +// Solidity: function onERC721Received(address , address , uint256 , bytes ) returns(bytes4) +func (_Application *ApplicationTransactorSession) OnERC721Received(arg0 common.Address, arg1 common.Address, arg2 *big.Int, arg3 []byte) (*types.Transaction, error) { + return _Application.Contract.OnERC721Received(&_Application.TransactOpts, arg0, arg1, arg2, arg3) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_Application *ApplicationTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Application.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_Application *ApplicationSession) RenounceOwnership() (*types.Transaction, error) { + return _Application.Contract.RenounceOwnership(&_Application.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_Application *ApplicationTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _Application.Contract.RenounceOwnership(&_Application.TransactOpts) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_Application *ApplicationTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _Application.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_Application *ApplicationSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _Application.Contract.TransferOwnership(&_Application.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_Application *ApplicationTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _Application.Contract.TransferOwnership(&_Application.TransactOpts, newOwner) +} + +// Receive is a paid mutator transaction binding the contract receive function. +// +// Solidity: receive() payable returns() +func (_Application *ApplicationTransactor) Receive(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Application.contract.RawTransact(opts, nil) // calldata is disallowed for receive function +} + +// Receive is a paid mutator transaction binding the contract receive function. +// +// Solidity: receive() payable returns() +func (_Application *ApplicationSession) Receive() (*types.Transaction, error) { + return _Application.Contract.Receive(&_Application.TransactOpts) +} + +// Receive is a paid mutator transaction binding the contract receive function. +// +// Solidity: receive() payable returns() +func (_Application *ApplicationTransactorSession) Receive() (*types.Transaction, error) { + return _Application.Contract.Receive(&_Application.TransactOpts) +} + +// ApplicationNewConsensusIterator is returned from FilterNewConsensus and is used to iterate over the raw logs and unpacked data for NewConsensus events raised by the Application contract. +type ApplicationNewConsensusIterator struct { + Event *ApplicationNewConsensus // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ApplicationNewConsensusIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ApplicationNewConsensus) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ApplicationNewConsensus) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ApplicationNewConsensusIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ApplicationNewConsensusIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ApplicationNewConsensus represents a NewConsensus event raised by the Application contract. +type ApplicationNewConsensus struct { + NewConsensus common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterNewConsensus is a free log retrieval operation binding the contract event 0x4991c6f37185659e276ff918a96f3e20e6c5abcd8c9aab450dc19c2f7ad35cb5. +// +// Solidity: event NewConsensus(address newConsensus) +func (_Application *ApplicationFilterer) FilterNewConsensus(opts *bind.FilterOpts) (*ApplicationNewConsensusIterator, error) { + + logs, sub, err := _Application.contract.FilterLogs(opts, "NewConsensus") + if err != nil { + return nil, err + } + return &ApplicationNewConsensusIterator{contract: _Application.contract, event: "NewConsensus", logs: logs, sub: sub}, nil +} + +// WatchNewConsensus is a free log subscription operation binding the contract event 0x4991c6f37185659e276ff918a96f3e20e6c5abcd8c9aab450dc19c2f7ad35cb5. +// +// Solidity: event NewConsensus(address newConsensus) +func (_Application *ApplicationFilterer) WatchNewConsensus(opts *bind.WatchOpts, sink chan<- *ApplicationNewConsensus) (event.Subscription, error) { + + logs, sub, err := _Application.contract.WatchLogs(opts, "NewConsensus") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ApplicationNewConsensus) + if err := _Application.contract.UnpackLog(event, "NewConsensus", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseNewConsensus is a log parse operation binding the contract event 0x4991c6f37185659e276ff918a96f3e20e6c5abcd8c9aab450dc19c2f7ad35cb5. +// +// Solidity: event NewConsensus(address newConsensus) +func (_Application *ApplicationFilterer) ParseNewConsensus(log types.Log) (*ApplicationNewConsensus, error) { + event := new(ApplicationNewConsensus) + if err := _Application.contract.UnpackLog(event, "NewConsensus", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ApplicationOutputExecutedIterator is returned from FilterOutputExecuted and is used to iterate over the raw logs and unpacked data for OutputExecuted events raised by the Application contract. +type ApplicationOutputExecutedIterator struct { + Event *ApplicationOutputExecuted // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ApplicationOutputExecutedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ApplicationOutputExecuted) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ApplicationOutputExecuted) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ApplicationOutputExecutedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ApplicationOutputExecutedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ApplicationOutputExecuted represents a OutputExecuted event raised by the Application contract. +type ApplicationOutputExecuted struct { + InputIndex uint64 + OutputIndexWithinInput uint64 + Output []byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOutputExecuted is a free log retrieval operation binding the contract event 0xd39d8e3e610251d36b5464d9cabbd8fa8319fe6cff76941ce041ecf04669726f. +// +// Solidity: event OutputExecuted(uint64 inputIndex, uint64 outputIndexWithinInput, bytes output) +func (_Application *ApplicationFilterer) FilterOutputExecuted(opts *bind.FilterOpts) (*ApplicationOutputExecutedIterator, error) { + + logs, sub, err := _Application.contract.FilterLogs(opts, "OutputExecuted") + if err != nil { + return nil, err + } + return &ApplicationOutputExecutedIterator{contract: _Application.contract, event: "OutputExecuted", logs: logs, sub: sub}, nil +} + +// WatchOutputExecuted is a free log subscription operation binding the contract event 0xd39d8e3e610251d36b5464d9cabbd8fa8319fe6cff76941ce041ecf04669726f. +// +// Solidity: event OutputExecuted(uint64 inputIndex, uint64 outputIndexWithinInput, bytes output) +func (_Application *ApplicationFilterer) WatchOutputExecuted(opts *bind.WatchOpts, sink chan<- *ApplicationOutputExecuted) (event.Subscription, error) { + + logs, sub, err := _Application.contract.WatchLogs(opts, "OutputExecuted") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ApplicationOutputExecuted) + if err := _Application.contract.UnpackLog(event, "OutputExecuted", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseOutputExecuted is a log parse operation binding the contract event 0xd39d8e3e610251d36b5464d9cabbd8fa8319fe6cff76941ce041ecf04669726f. +// +// Solidity: event OutputExecuted(uint64 inputIndex, uint64 outputIndexWithinInput, bytes output) +func (_Application *ApplicationFilterer) ParseOutputExecuted(log types.Log) (*ApplicationOutputExecuted, error) { + event := new(ApplicationOutputExecuted) + if err := _Application.contract.UnpackLog(event, "OutputExecuted", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ApplicationOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the Application contract. +type ApplicationOwnershipTransferredIterator struct { + Event *ApplicationOwnershipTransferred // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ApplicationOwnershipTransferredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ApplicationOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ApplicationOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ApplicationOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ApplicationOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ApplicationOwnershipTransferred represents a OwnershipTransferred event raised by the Application contract. +type ApplicationOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_Application *ApplicationFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*ApplicationOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _Application.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &ApplicationOwnershipTransferredIterator{contract: _Application.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_Application *ApplicationFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *ApplicationOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _Application.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ApplicationOwnershipTransferred) + if err := _Application.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_Application *ApplicationFilterer) ParseOwnershipTransferred(log types.Log) (*ApplicationOwnershipTransferred, error) { + event := new(ApplicationOwnershipTransferred) + if err := _Application.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/pkg/contracts/authority.go b/pkg/contracts/authority.go deleted file mode 100644 index e584ecce6..000000000 --- a/pkg/contracts/authority.go +++ /dev/null @@ -1,844 +0,0 @@ -// Code generated - DO NOT EDIT. -// This file is a generated binding and any manual changes will be lost. - -package contracts - -import ( - "errors" - "math/big" - "strings" - - ethereum "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/event" -) - -// Reference imports to suppress errors if they are not otherwise used. -var ( - _ = errors.New - _ = big.NewInt - _ = strings.NewReader - _ = ethereum.NotFound - _ = bind.Bind - _ = common.Big1 - _ = types.BloomLookup - _ = event.NewSubscription - _ = abi.ConvertType -) - -// AuthorityMetaData contains all meta data concerning the Authority contract. -var AuthorityMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AuthorityWithdrawalFailed\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"}],\"name\":\"ApplicationJoined\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contractIHistory\",\"name\":\"history\",\"type\":\"address\"}],\"name\":\"NewHistory\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_dapp\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_proofContext\",\"type\":\"bytes\"}],\"name\":\"getClaim\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getHistory\",\"outputs\":[{\"internalType\":\"contractIHistory\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"join\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensus\",\"type\":\"address\"}],\"name\":\"migrateHistoryToConsensus\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contractIHistory\",\"name\":\"_history\",\"type\":\"address\"}],\"name\":\"setHistory\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"_claimData\",\"type\":\"bytes\"}],\"name\":\"submitClaim\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contractIERC20\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"withdrawERC20Tokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", -} - -// AuthorityABI is the input ABI used to generate the binding from. -// Deprecated: Use AuthorityMetaData.ABI instead. -var AuthorityABI = AuthorityMetaData.ABI - -// Authority is an auto generated Go binding around an Ethereum contract. -type Authority struct { - AuthorityCaller // Read-only binding to the contract - AuthorityTransactor // Write-only binding to the contract - AuthorityFilterer // Log filterer for contract events -} - -// AuthorityCaller is an auto generated read-only Go binding around an Ethereum contract. -type AuthorityCaller struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// AuthorityTransactor is an auto generated write-only Go binding around an Ethereum contract. -type AuthorityTransactor struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// AuthorityFilterer is an auto generated log filtering Go binding around an Ethereum contract events. -type AuthorityFilterer struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// AuthoritySession is an auto generated Go binding around an Ethereum contract, -// with pre-set call and transact options. -type AuthoritySession struct { - Contract *Authority // Generic contract binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// AuthorityCallerSession is an auto generated read-only Go binding around an Ethereum contract, -// with pre-set call options. -type AuthorityCallerSession struct { - Contract *AuthorityCaller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session -} - -// AuthorityTransactorSession is an auto generated write-only Go binding around an Ethereum contract, -// with pre-set transact options. -type AuthorityTransactorSession struct { - Contract *AuthorityTransactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// AuthorityRaw is an auto generated low-level Go binding around an Ethereum contract. -type AuthorityRaw struct { - Contract *Authority // Generic contract binding to access the raw methods on -} - -// AuthorityCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type AuthorityCallerRaw struct { - Contract *AuthorityCaller // Generic read-only contract binding to access the raw methods on -} - -// AuthorityTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type AuthorityTransactorRaw struct { - Contract *AuthorityTransactor // Generic write-only contract binding to access the raw methods on -} - -// NewAuthority creates a new instance of Authority, bound to a specific deployed contract. -func NewAuthority(address common.Address, backend bind.ContractBackend) (*Authority, error) { - contract, err := bindAuthority(address, backend, backend, backend) - if err != nil { - return nil, err - } - return &Authority{AuthorityCaller: AuthorityCaller{contract: contract}, AuthorityTransactor: AuthorityTransactor{contract: contract}, AuthorityFilterer: AuthorityFilterer{contract: contract}}, nil -} - -// NewAuthorityCaller creates a new read-only instance of Authority, bound to a specific deployed contract. -func NewAuthorityCaller(address common.Address, caller bind.ContractCaller) (*AuthorityCaller, error) { - contract, err := bindAuthority(address, caller, nil, nil) - if err != nil { - return nil, err - } - return &AuthorityCaller{contract: contract}, nil -} - -// NewAuthorityTransactor creates a new write-only instance of Authority, bound to a specific deployed contract. -func NewAuthorityTransactor(address common.Address, transactor bind.ContractTransactor) (*AuthorityTransactor, error) { - contract, err := bindAuthority(address, nil, transactor, nil) - if err != nil { - return nil, err - } - return &AuthorityTransactor{contract: contract}, nil -} - -// NewAuthorityFilterer creates a new log filterer instance of Authority, bound to a specific deployed contract. -func NewAuthorityFilterer(address common.Address, filterer bind.ContractFilterer) (*AuthorityFilterer, error) { - contract, err := bindAuthority(address, nil, nil, filterer) - if err != nil { - return nil, err - } - return &AuthorityFilterer{contract: contract}, nil -} - -// bindAuthority binds a generic wrapper to an already deployed contract. -func bindAuthority(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := AuthorityMetaData.GetAbi() - if err != nil { - return nil, err - } - return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_Authority *AuthorityRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _Authority.Contract.AuthorityCaller.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_Authority *AuthorityRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _Authority.Contract.AuthorityTransactor.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_Authority *AuthorityRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _Authority.Contract.AuthorityTransactor.contract.Transact(opts, method, params...) -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_Authority *AuthorityCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _Authority.Contract.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_Authority *AuthorityTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _Authority.Contract.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_Authority *AuthorityTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _Authority.Contract.contract.Transact(opts, method, params...) -} - -// GetClaim is a free data retrieval call binding the contract method 0xd79a8240. -// -// Solidity: function getClaim(address _dapp, bytes _proofContext) view returns(bytes32, uint256, uint256) -func (_Authority *AuthorityCaller) GetClaim(opts *bind.CallOpts, _dapp common.Address, _proofContext []byte) ([32]byte, *big.Int, *big.Int, error) { - var out []interface{} - err := _Authority.contract.Call(opts, &out, "getClaim", _dapp, _proofContext) - - if err != nil { - return *new([32]byte), *new(*big.Int), *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) - out1 := *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) - out2 := *abi.ConvertType(out[2], new(*big.Int)).(**big.Int) - - return out0, out1, out2, err - -} - -// GetClaim is a free data retrieval call binding the contract method 0xd79a8240. -// -// Solidity: function getClaim(address _dapp, bytes _proofContext) view returns(bytes32, uint256, uint256) -func (_Authority *AuthoritySession) GetClaim(_dapp common.Address, _proofContext []byte) ([32]byte, *big.Int, *big.Int, error) { - return _Authority.Contract.GetClaim(&_Authority.CallOpts, _dapp, _proofContext) -} - -// GetClaim is a free data retrieval call binding the contract method 0xd79a8240. -// -// Solidity: function getClaim(address _dapp, bytes _proofContext) view returns(bytes32, uint256, uint256) -func (_Authority *AuthorityCallerSession) GetClaim(_dapp common.Address, _proofContext []byte) ([32]byte, *big.Int, *big.Int, error) { - return _Authority.Contract.GetClaim(&_Authority.CallOpts, _dapp, _proofContext) -} - -// GetHistory is a free data retrieval call binding the contract method 0xaa15efc8. -// -// Solidity: function getHistory() view returns(address) -func (_Authority *AuthorityCaller) GetHistory(opts *bind.CallOpts) (common.Address, error) { - var out []interface{} - err := _Authority.contract.Call(opts, &out, "getHistory") - - if err != nil { - return *new(common.Address), err - } - - out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - - return out0, err - -} - -// GetHistory is a free data retrieval call binding the contract method 0xaa15efc8. -// -// Solidity: function getHistory() view returns(address) -func (_Authority *AuthoritySession) GetHistory() (common.Address, error) { - return _Authority.Contract.GetHistory(&_Authority.CallOpts) -} - -// GetHistory is a free data retrieval call binding the contract method 0xaa15efc8. -// -// Solidity: function getHistory() view returns(address) -func (_Authority *AuthorityCallerSession) GetHistory() (common.Address, error) { - return _Authority.Contract.GetHistory(&_Authority.CallOpts) -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_Authority *AuthorityCaller) Owner(opts *bind.CallOpts) (common.Address, error) { - var out []interface{} - err := _Authority.contract.Call(opts, &out, "owner") - - if err != nil { - return *new(common.Address), err - } - - out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - - return out0, err - -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_Authority *AuthoritySession) Owner() (common.Address, error) { - return _Authority.Contract.Owner(&_Authority.CallOpts) -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_Authority *AuthorityCallerSession) Owner() (common.Address, error) { - return _Authority.Contract.Owner(&_Authority.CallOpts) -} - -// Join is a paid mutator transaction binding the contract method 0xb688a363. -// -// Solidity: function join() returns() -func (_Authority *AuthorityTransactor) Join(opts *bind.TransactOpts) (*types.Transaction, error) { - return _Authority.contract.Transact(opts, "join") -} - -// Join is a paid mutator transaction binding the contract method 0xb688a363. -// -// Solidity: function join() returns() -func (_Authority *AuthoritySession) Join() (*types.Transaction, error) { - return _Authority.Contract.Join(&_Authority.TransactOpts) -} - -// Join is a paid mutator transaction binding the contract method 0xb688a363. -// -// Solidity: function join() returns() -func (_Authority *AuthorityTransactorSession) Join() (*types.Transaction, error) { - return _Authority.Contract.Join(&_Authority.TransactOpts) -} - -// MigrateHistoryToConsensus is a paid mutator transaction binding the contract method 0x9368a3d3. -// -// Solidity: function migrateHistoryToConsensus(address _consensus) returns() -func (_Authority *AuthorityTransactor) MigrateHistoryToConsensus(opts *bind.TransactOpts, _consensus common.Address) (*types.Transaction, error) { - return _Authority.contract.Transact(opts, "migrateHistoryToConsensus", _consensus) -} - -// MigrateHistoryToConsensus is a paid mutator transaction binding the contract method 0x9368a3d3. -// -// Solidity: function migrateHistoryToConsensus(address _consensus) returns() -func (_Authority *AuthoritySession) MigrateHistoryToConsensus(_consensus common.Address) (*types.Transaction, error) { - return _Authority.Contract.MigrateHistoryToConsensus(&_Authority.TransactOpts, _consensus) -} - -// MigrateHistoryToConsensus is a paid mutator transaction binding the contract method 0x9368a3d3. -// -// Solidity: function migrateHistoryToConsensus(address _consensus) returns() -func (_Authority *AuthorityTransactorSession) MigrateHistoryToConsensus(_consensus common.Address) (*types.Transaction, error) { - return _Authority.Contract.MigrateHistoryToConsensus(&_Authority.TransactOpts, _consensus) -} - -// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. -// -// Solidity: function renounceOwnership() returns() -func (_Authority *AuthorityTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { - return _Authority.contract.Transact(opts, "renounceOwnership") -} - -// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. -// -// Solidity: function renounceOwnership() returns() -func (_Authority *AuthoritySession) RenounceOwnership() (*types.Transaction, error) { - return _Authority.Contract.RenounceOwnership(&_Authority.TransactOpts) -} - -// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. -// -// Solidity: function renounceOwnership() returns() -func (_Authority *AuthorityTransactorSession) RenounceOwnership() (*types.Transaction, error) { - return _Authority.Contract.RenounceOwnership(&_Authority.TransactOpts) -} - -// SetHistory is a paid mutator transaction binding the contract method 0x159c5ea1. -// -// Solidity: function setHistory(address _history) returns() -func (_Authority *AuthorityTransactor) SetHistory(opts *bind.TransactOpts, _history common.Address) (*types.Transaction, error) { - return _Authority.contract.Transact(opts, "setHistory", _history) -} - -// SetHistory is a paid mutator transaction binding the contract method 0x159c5ea1. -// -// Solidity: function setHistory(address _history) returns() -func (_Authority *AuthoritySession) SetHistory(_history common.Address) (*types.Transaction, error) { - return _Authority.Contract.SetHistory(&_Authority.TransactOpts, _history) -} - -// SetHistory is a paid mutator transaction binding the contract method 0x159c5ea1. -// -// Solidity: function setHistory(address _history) returns() -func (_Authority *AuthorityTransactorSession) SetHistory(_history common.Address) (*types.Transaction, error) { - return _Authority.Contract.SetHistory(&_Authority.TransactOpts, _history) -} - -// SubmitClaim is a paid mutator transaction binding the contract method 0xddfdfbb0. -// -// Solidity: function submitClaim(bytes _claimData) returns() -func (_Authority *AuthorityTransactor) SubmitClaim(opts *bind.TransactOpts, _claimData []byte) (*types.Transaction, error) { - return _Authority.contract.Transact(opts, "submitClaim", _claimData) -} - -// SubmitClaim is a paid mutator transaction binding the contract method 0xddfdfbb0. -// -// Solidity: function submitClaim(bytes _claimData) returns() -func (_Authority *AuthoritySession) SubmitClaim(_claimData []byte) (*types.Transaction, error) { - return _Authority.Contract.SubmitClaim(&_Authority.TransactOpts, _claimData) -} - -// SubmitClaim is a paid mutator transaction binding the contract method 0xddfdfbb0. -// -// Solidity: function submitClaim(bytes _claimData) returns() -func (_Authority *AuthorityTransactorSession) SubmitClaim(_claimData []byte) (*types.Transaction, error) { - return _Authority.Contract.SubmitClaim(&_Authority.TransactOpts, _claimData) -} - -// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. -// -// Solidity: function transferOwnership(address newOwner) returns() -func (_Authority *AuthorityTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { - return _Authority.contract.Transact(opts, "transferOwnership", newOwner) -} - -// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. -// -// Solidity: function transferOwnership(address newOwner) returns() -func (_Authority *AuthoritySession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { - return _Authority.Contract.TransferOwnership(&_Authority.TransactOpts, newOwner) -} - -// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. -// -// Solidity: function transferOwnership(address newOwner) returns() -func (_Authority *AuthorityTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { - return _Authority.Contract.TransferOwnership(&_Authority.TransactOpts, newOwner) -} - -// WithdrawERC20Tokens is a paid mutator transaction binding the contract method 0xbcdd1e13. -// -// Solidity: function withdrawERC20Tokens(address _token, address _recipient, uint256 _amount) returns() -func (_Authority *AuthorityTransactor) WithdrawERC20Tokens(opts *bind.TransactOpts, _token common.Address, _recipient common.Address, _amount *big.Int) (*types.Transaction, error) { - return _Authority.contract.Transact(opts, "withdrawERC20Tokens", _token, _recipient, _amount) -} - -// WithdrawERC20Tokens is a paid mutator transaction binding the contract method 0xbcdd1e13. -// -// Solidity: function withdrawERC20Tokens(address _token, address _recipient, uint256 _amount) returns() -func (_Authority *AuthoritySession) WithdrawERC20Tokens(_token common.Address, _recipient common.Address, _amount *big.Int) (*types.Transaction, error) { - return _Authority.Contract.WithdrawERC20Tokens(&_Authority.TransactOpts, _token, _recipient, _amount) -} - -// WithdrawERC20Tokens is a paid mutator transaction binding the contract method 0xbcdd1e13. -// -// Solidity: function withdrawERC20Tokens(address _token, address _recipient, uint256 _amount) returns() -func (_Authority *AuthorityTransactorSession) WithdrawERC20Tokens(_token common.Address, _recipient common.Address, _amount *big.Int) (*types.Transaction, error) { - return _Authority.Contract.WithdrawERC20Tokens(&_Authority.TransactOpts, _token, _recipient, _amount) -} - -// AuthorityApplicationJoinedIterator is returned from FilterApplicationJoined and is used to iterate over the raw logs and unpacked data for ApplicationJoined events raised by the Authority contract. -type AuthorityApplicationJoinedIterator struct { - Event *AuthorityApplicationJoined // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *AuthorityApplicationJoinedIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(AuthorityApplicationJoined) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(AuthorityApplicationJoined) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *AuthorityApplicationJoinedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *AuthorityApplicationJoinedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// AuthorityApplicationJoined represents a ApplicationJoined event raised by the Authority contract. -type AuthorityApplicationJoined struct { - Application common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterApplicationJoined is a free log retrieval operation binding the contract event 0x27c2b702d3bff195a18baca2daf00b20a986177c5f1449af4e2d46a3c3e02ce5. -// -// Solidity: event ApplicationJoined(address application) -func (_Authority *AuthorityFilterer) FilterApplicationJoined(opts *bind.FilterOpts) (*AuthorityApplicationJoinedIterator, error) { - - logs, sub, err := _Authority.contract.FilterLogs(opts, "ApplicationJoined") - if err != nil { - return nil, err - } - return &AuthorityApplicationJoinedIterator{contract: _Authority.contract, event: "ApplicationJoined", logs: logs, sub: sub}, nil -} - -// WatchApplicationJoined is a free log subscription operation binding the contract event 0x27c2b702d3bff195a18baca2daf00b20a986177c5f1449af4e2d46a3c3e02ce5. -// -// Solidity: event ApplicationJoined(address application) -func (_Authority *AuthorityFilterer) WatchApplicationJoined(opts *bind.WatchOpts, sink chan<- *AuthorityApplicationJoined) (event.Subscription, error) { - - logs, sub, err := _Authority.contract.WatchLogs(opts, "ApplicationJoined") - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(AuthorityApplicationJoined) - if err := _Authority.contract.UnpackLog(event, "ApplicationJoined", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseApplicationJoined is a log parse operation binding the contract event 0x27c2b702d3bff195a18baca2daf00b20a986177c5f1449af4e2d46a3c3e02ce5. -// -// Solidity: event ApplicationJoined(address application) -func (_Authority *AuthorityFilterer) ParseApplicationJoined(log types.Log) (*AuthorityApplicationJoined, error) { - event := new(AuthorityApplicationJoined) - if err := _Authority.contract.UnpackLog(event, "ApplicationJoined", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// AuthorityNewHistoryIterator is returned from FilterNewHistory and is used to iterate over the raw logs and unpacked data for NewHistory events raised by the Authority contract. -type AuthorityNewHistoryIterator struct { - Event *AuthorityNewHistory // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *AuthorityNewHistoryIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(AuthorityNewHistory) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(AuthorityNewHistory) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *AuthorityNewHistoryIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *AuthorityNewHistoryIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// AuthorityNewHistory represents a NewHistory event raised by the Authority contract. -type AuthorityNewHistory struct { - History common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterNewHistory is a free log retrieval operation binding the contract event 0x2bcd43869347a1d42f97ac6042f3d129817abd05a6125f9750fe3724e321d23e. -// -// Solidity: event NewHistory(address history) -func (_Authority *AuthorityFilterer) FilterNewHistory(opts *bind.FilterOpts) (*AuthorityNewHistoryIterator, error) { - - logs, sub, err := _Authority.contract.FilterLogs(opts, "NewHistory") - if err != nil { - return nil, err - } - return &AuthorityNewHistoryIterator{contract: _Authority.contract, event: "NewHistory", logs: logs, sub: sub}, nil -} - -// WatchNewHistory is a free log subscription operation binding the contract event 0x2bcd43869347a1d42f97ac6042f3d129817abd05a6125f9750fe3724e321d23e. -// -// Solidity: event NewHistory(address history) -func (_Authority *AuthorityFilterer) WatchNewHistory(opts *bind.WatchOpts, sink chan<- *AuthorityNewHistory) (event.Subscription, error) { - - logs, sub, err := _Authority.contract.WatchLogs(opts, "NewHistory") - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(AuthorityNewHistory) - if err := _Authority.contract.UnpackLog(event, "NewHistory", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseNewHistory is a log parse operation binding the contract event 0x2bcd43869347a1d42f97ac6042f3d129817abd05a6125f9750fe3724e321d23e. -// -// Solidity: event NewHistory(address history) -func (_Authority *AuthorityFilterer) ParseNewHistory(log types.Log) (*AuthorityNewHistory, error) { - event := new(AuthorityNewHistory) - if err := _Authority.contract.UnpackLog(event, "NewHistory", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// AuthorityOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the Authority contract. -type AuthorityOwnershipTransferredIterator struct { - Event *AuthorityOwnershipTransferred // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *AuthorityOwnershipTransferredIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(AuthorityOwnershipTransferred) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(AuthorityOwnershipTransferred) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *AuthorityOwnershipTransferredIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *AuthorityOwnershipTransferredIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// AuthorityOwnershipTransferred represents a OwnershipTransferred event raised by the Authority contract. -type AuthorityOwnershipTransferred struct { - PreviousOwner common.Address - NewOwner common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. -// -// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) -func (_Authority *AuthorityFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*AuthorityOwnershipTransferredIterator, error) { - - var previousOwnerRule []interface{} - for _, previousOwnerItem := range previousOwner { - previousOwnerRule = append(previousOwnerRule, previousOwnerItem) - } - var newOwnerRule []interface{} - for _, newOwnerItem := range newOwner { - newOwnerRule = append(newOwnerRule, newOwnerItem) - } - - logs, sub, err := _Authority.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) - if err != nil { - return nil, err - } - return &AuthorityOwnershipTransferredIterator{contract: _Authority.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil -} - -// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. -// -// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) -func (_Authority *AuthorityFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *AuthorityOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { - - var previousOwnerRule []interface{} - for _, previousOwnerItem := range previousOwner { - previousOwnerRule = append(previousOwnerRule, previousOwnerItem) - } - var newOwnerRule []interface{} - for _, newOwnerItem := range newOwner { - newOwnerRule = append(newOwnerRule, newOwnerItem) - } - - logs, sub, err := _Authority.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(AuthorityOwnershipTransferred) - if err := _Authority.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. -// -// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) -func (_Authority *AuthorityFilterer) ParseOwnershipTransferred(log types.Log) (*AuthorityOwnershipTransferred, error) { - event := new(AuthorityOwnershipTransferred) - if err := _Authority.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} diff --git a/pkg/contracts/cartesi_dapp.go b/pkg/contracts/cartesi_dapp.go deleted file mode 100644 index cb9c0cfe6..000000000 --- a/pkg/contracts/cartesi_dapp.go +++ /dev/null @@ -1,995 +0,0 @@ -// Code generated - DO NOT EDIT. -// This file is a generated binding and any manual changes will be lost. - -package contracts - -import ( - "errors" - "math/big" - "strings" - - ethereum "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/event" -) - -// Reference imports to suppress errors if they are not otherwise used. -var ( - _ = errors.New - _ = big.NewInt - _ = strings.NewReader - _ = ethereum.NotFound - _ = bind.Bind - _ = common.Big1 - _ = types.BloomLookup - _ = event.NewSubscription - _ = abi.ConvertType -) - -// OutputValidityProof is an auto generated low-level Go binding around an user-defined struct. -type OutputValidityProof struct { - InputIndexWithinEpoch uint64 - OutputIndexWithinInput uint64 - OutputHashesRootHash [32]byte - VouchersEpochRootHash [32]byte - NoticesEpochRootHash [32]byte - MachineStateHash [32]byte - OutputHashInOutputHashesSiblings [][32]byte - OutputHashesInEpochSiblings [][32]byte -} - -// Proof is an auto generated low-level Go binding around an user-defined struct. -type Proof struct { - Validity OutputValidityProof - Context []byte -} - -// CartesiDAppMetaData contains all meta data concerning the CartesiDApp contract. -var CartesiDAppMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"contractIConsensus\",\"name\":\"_consensus\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"_templateHash\",\"type\":\"bytes32\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"EtherTransferFailed\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"IncorrectEpochHash\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"IncorrectOutputHashesRootHash\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"IncorrectOutputsEpochRootHash\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InputIndexOutOfClaimBounds\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"OnlyDApp\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"VoucherReexecutionNotAllowed\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contractIConsensus\",\"name\":\"newConsensus\",\"type\":\"address\"}],\"name\":\"NewConsensus\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"voucherId\",\"type\":\"uint256\"}],\"name\":\"VoucherExecuted\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_destination\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_payload\",\"type\":\"bytes\"},{\"components\":[{\"components\":[{\"internalType\":\"uint64\",\"name\":\"inputIndexWithinEpoch\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"outputIndexWithinInput\",\"type\":\"uint64\"},{\"internalType\":\"bytes32\",\"name\":\"outputHashesRootHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"vouchersEpochRootHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"noticesEpochRootHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"machineStateHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32[]\",\"name\":\"outputHashInOutputHashesSiblings\",\"type\":\"bytes32[]\"},{\"internalType\":\"bytes32[]\",\"name\":\"outputHashesInEpochSiblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structOutputValidityProof\",\"name\":\"validity\",\"type\":\"tuple\"},{\"internalType\":\"bytes\",\"name\":\"context\",\"type\":\"bytes\"}],\"internalType\":\"structProof\",\"name\":\"_proof\",\"type\":\"tuple\"}],\"name\":\"executeVoucher\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getConsensus\",\"outputs\":[{\"internalType\":\"contractIConsensus\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getTemplateHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contractIConsensus\",\"name\":\"_newConsensus\",\"type\":\"address\"}],\"name\":\"migrateToConsensus\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"onERC1155BatchReceived\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"onERC1155Received\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"onERC721Received\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"_notice\",\"type\":\"bytes\"},{\"components\":[{\"components\":[{\"internalType\":\"uint64\",\"name\":\"inputIndexWithinEpoch\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"outputIndexWithinInput\",\"type\":\"uint64\"},{\"internalType\":\"bytes32\",\"name\":\"outputHashesRootHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"vouchersEpochRootHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"noticesEpochRootHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"machineStateHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32[]\",\"name\":\"outputHashInOutputHashesSiblings\",\"type\":\"bytes32[]\"},{\"internalType\":\"bytes32[]\",\"name\":\"outputHashesInEpochSiblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structOutputValidityProof\",\"name\":\"validity\",\"type\":\"tuple\"},{\"internalType\":\"bytes\",\"name\":\"context\",\"type\":\"bytes\"}],\"internalType\":\"structProof\",\"name\":\"_proof\",\"type\":\"tuple\"}],\"name\":\"validateNotice\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_inputIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_outputIndexWithinInput\",\"type\":\"uint256\"}],\"name\":\"wasVoucherExecuted\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_receiver\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"withdrawEther\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", -} - -// CartesiDAppABI is the input ABI used to generate the binding from. -// Deprecated: Use CartesiDAppMetaData.ABI instead. -var CartesiDAppABI = CartesiDAppMetaData.ABI - -// CartesiDApp is an auto generated Go binding around an Ethereum contract. -type CartesiDApp struct { - CartesiDAppCaller // Read-only binding to the contract - CartesiDAppTransactor // Write-only binding to the contract - CartesiDAppFilterer // Log filterer for contract events -} - -// CartesiDAppCaller is an auto generated read-only Go binding around an Ethereum contract. -type CartesiDAppCaller struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// CartesiDAppTransactor is an auto generated write-only Go binding around an Ethereum contract. -type CartesiDAppTransactor struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// CartesiDAppFilterer is an auto generated log filtering Go binding around an Ethereum contract events. -type CartesiDAppFilterer struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// CartesiDAppSession is an auto generated Go binding around an Ethereum contract, -// with pre-set call and transact options. -type CartesiDAppSession struct { - Contract *CartesiDApp // Generic contract binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// CartesiDAppCallerSession is an auto generated read-only Go binding around an Ethereum contract, -// with pre-set call options. -type CartesiDAppCallerSession struct { - Contract *CartesiDAppCaller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session -} - -// CartesiDAppTransactorSession is an auto generated write-only Go binding around an Ethereum contract, -// with pre-set transact options. -type CartesiDAppTransactorSession struct { - Contract *CartesiDAppTransactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// CartesiDAppRaw is an auto generated low-level Go binding around an Ethereum contract. -type CartesiDAppRaw struct { - Contract *CartesiDApp // Generic contract binding to access the raw methods on -} - -// CartesiDAppCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type CartesiDAppCallerRaw struct { - Contract *CartesiDAppCaller // Generic read-only contract binding to access the raw methods on -} - -// CartesiDAppTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type CartesiDAppTransactorRaw struct { - Contract *CartesiDAppTransactor // Generic write-only contract binding to access the raw methods on -} - -// NewCartesiDApp creates a new instance of CartesiDApp, bound to a specific deployed contract. -func NewCartesiDApp(address common.Address, backend bind.ContractBackend) (*CartesiDApp, error) { - contract, err := bindCartesiDApp(address, backend, backend, backend) - if err != nil { - return nil, err - } - return &CartesiDApp{CartesiDAppCaller: CartesiDAppCaller{contract: contract}, CartesiDAppTransactor: CartesiDAppTransactor{contract: contract}, CartesiDAppFilterer: CartesiDAppFilterer{contract: contract}}, nil -} - -// NewCartesiDAppCaller creates a new read-only instance of CartesiDApp, bound to a specific deployed contract. -func NewCartesiDAppCaller(address common.Address, caller bind.ContractCaller) (*CartesiDAppCaller, error) { - contract, err := bindCartesiDApp(address, caller, nil, nil) - if err != nil { - return nil, err - } - return &CartesiDAppCaller{contract: contract}, nil -} - -// NewCartesiDAppTransactor creates a new write-only instance of CartesiDApp, bound to a specific deployed contract. -func NewCartesiDAppTransactor(address common.Address, transactor bind.ContractTransactor) (*CartesiDAppTransactor, error) { - contract, err := bindCartesiDApp(address, nil, transactor, nil) - if err != nil { - return nil, err - } - return &CartesiDAppTransactor{contract: contract}, nil -} - -// NewCartesiDAppFilterer creates a new log filterer instance of CartesiDApp, bound to a specific deployed contract. -func NewCartesiDAppFilterer(address common.Address, filterer bind.ContractFilterer) (*CartesiDAppFilterer, error) { - contract, err := bindCartesiDApp(address, nil, nil, filterer) - if err != nil { - return nil, err - } - return &CartesiDAppFilterer{contract: contract}, nil -} - -// bindCartesiDApp binds a generic wrapper to an already deployed contract. -func bindCartesiDApp(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := CartesiDAppMetaData.GetAbi() - if err != nil { - return nil, err - } - return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_CartesiDApp *CartesiDAppRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _CartesiDApp.Contract.CartesiDAppCaller.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_CartesiDApp *CartesiDAppRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _CartesiDApp.Contract.CartesiDAppTransactor.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_CartesiDApp *CartesiDAppRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _CartesiDApp.Contract.CartesiDAppTransactor.contract.Transact(opts, method, params...) -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_CartesiDApp *CartesiDAppCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _CartesiDApp.Contract.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_CartesiDApp *CartesiDAppTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _CartesiDApp.Contract.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_CartesiDApp *CartesiDAppTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _CartesiDApp.Contract.contract.Transact(opts, method, params...) -} - -// GetConsensus is a free data retrieval call binding the contract method 0x179e740b. -// -// Solidity: function getConsensus() view returns(address) -func (_CartesiDApp *CartesiDAppCaller) GetConsensus(opts *bind.CallOpts) (common.Address, error) { - var out []interface{} - err := _CartesiDApp.contract.Call(opts, &out, "getConsensus") - - if err != nil { - return *new(common.Address), err - } - - out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - - return out0, err - -} - -// GetConsensus is a free data retrieval call binding the contract method 0x179e740b. -// -// Solidity: function getConsensus() view returns(address) -func (_CartesiDApp *CartesiDAppSession) GetConsensus() (common.Address, error) { - return _CartesiDApp.Contract.GetConsensus(&_CartesiDApp.CallOpts) -} - -// GetConsensus is a free data retrieval call binding the contract method 0x179e740b. -// -// Solidity: function getConsensus() view returns(address) -func (_CartesiDApp *CartesiDAppCallerSession) GetConsensus() (common.Address, error) { - return _CartesiDApp.Contract.GetConsensus(&_CartesiDApp.CallOpts) -} - -// GetTemplateHash is a free data retrieval call binding the contract method 0x61b12c66. -// -// Solidity: function getTemplateHash() view returns(bytes32) -func (_CartesiDApp *CartesiDAppCaller) GetTemplateHash(opts *bind.CallOpts) ([32]byte, error) { - var out []interface{} - err := _CartesiDApp.contract.Call(opts, &out, "getTemplateHash") - - if err != nil { - return *new([32]byte), err - } - - out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) - - return out0, err - -} - -// GetTemplateHash is a free data retrieval call binding the contract method 0x61b12c66. -// -// Solidity: function getTemplateHash() view returns(bytes32) -func (_CartesiDApp *CartesiDAppSession) GetTemplateHash() ([32]byte, error) { - return _CartesiDApp.Contract.GetTemplateHash(&_CartesiDApp.CallOpts) -} - -// GetTemplateHash is a free data retrieval call binding the contract method 0x61b12c66. -// -// Solidity: function getTemplateHash() view returns(bytes32) -func (_CartesiDApp *CartesiDAppCallerSession) GetTemplateHash() ([32]byte, error) { - return _CartesiDApp.Contract.GetTemplateHash(&_CartesiDApp.CallOpts) -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_CartesiDApp *CartesiDAppCaller) Owner(opts *bind.CallOpts) (common.Address, error) { - var out []interface{} - err := _CartesiDApp.contract.Call(opts, &out, "owner") - - if err != nil { - return *new(common.Address), err - } - - out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - - return out0, err - -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_CartesiDApp *CartesiDAppSession) Owner() (common.Address, error) { - return _CartesiDApp.Contract.Owner(&_CartesiDApp.CallOpts) -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_CartesiDApp *CartesiDAppCallerSession) Owner() (common.Address, error) { - return _CartesiDApp.Contract.Owner(&_CartesiDApp.CallOpts) -} - -// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7. -// -// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool) -func (_CartesiDApp *CartesiDAppCaller) SupportsInterface(opts *bind.CallOpts, interfaceId [4]byte) (bool, error) { - var out []interface{} - err := _CartesiDApp.contract.Call(opts, &out, "supportsInterface", interfaceId) - - if err != nil { - return *new(bool), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - - return out0, err - -} - -// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7. -// -// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool) -func (_CartesiDApp *CartesiDAppSession) SupportsInterface(interfaceId [4]byte) (bool, error) { - return _CartesiDApp.Contract.SupportsInterface(&_CartesiDApp.CallOpts, interfaceId) -} - -// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7. -// -// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool) -func (_CartesiDApp *CartesiDAppCallerSession) SupportsInterface(interfaceId [4]byte) (bool, error) { - return _CartesiDApp.Contract.SupportsInterface(&_CartesiDApp.CallOpts, interfaceId) -} - -// ValidateNotice is a free data retrieval call binding the contract method 0x96487d46. -// -// Solidity: function validateNotice(bytes _notice, ((uint64,uint64,bytes32,bytes32,bytes32,bytes32,bytes32[],bytes32[]),bytes) _proof) view returns(bool) -func (_CartesiDApp *CartesiDAppCaller) ValidateNotice(opts *bind.CallOpts, _notice []byte, _proof Proof) (bool, error) { - var out []interface{} - err := _CartesiDApp.contract.Call(opts, &out, "validateNotice", _notice, _proof) - - if err != nil { - return *new(bool), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - - return out0, err - -} - -// ValidateNotice is a free data retrieval call binding the contract method 0x96487d46. -// -// Solidity: function validateNotice(bytes _notice, ((uint64,uint64,bytes32,bytes32,bytes32,bytes32,bytes32[],bytes32[]),bytes) _proof) view returns(bool) -func (_CartesiDApp *CartesiDAppSession) ValidateNotice(_notice []byte, _proof Proof) (bool, error) { - return _CartesiDApp.Contract.ValidateNotice(&_CartesiDApp.CallOpts, _notice, _proof) -} - -// ValidateNotice is a free data retrieval call binding the contract method 0x96487d46. -// -// Solidity: function validateNotice(bytes _notice, ((uint64,uint64,bytes32,bytes32,bytes32,bytes32,bytes32[],bytes32[]),bytes) _proof) view returns(bool) -func (_CartesiDApp *CartesiDAppCallerSession) ValidateNotice(_notice []byte, _proof Proof) (bool, error) { - return _CartesiDApp.Contract.ValidateNotice(&_CartesiDApp.CallOpts, _notice, _proof) -} - -// WasVoucherExecuted is a free data retrieval call binding the contract method 0x9d9b1145. -// -// Solidity: function wasVoucherExecuted(uint256 _inputIndex, uint256 _outputIndexWithinInput) view returns(bool) -func (_CartesiDApp *CartesiDAppCaller) WasVoucherExecuted(opts *bind.CallOpts, _inputIndex *big.Int, _outputIndexWithinInput *big.Int) (bool, error) { - var out []interface{} - err := _CartesiDApp.contract.Call(opts, &out, "wasVoucherExecuted", _inputIndex, _outputIndexWithinInput) - - if err != nil { - return *new(bool), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - - return out0, err - -} - -// WasVoucherExecuted is a free data retrieval call binding the contract method 0x9d9b1145. -// -// Solidity: function wasVoucherExecuted(uint256 _inputIndex, uint256 _outputIndexWithinInput) view returns(bool) -func (_CartesiDApp *CartesiDAppSession) WasVoucherExecuted(_inputIndex *big.Int, _outputIndexWithinInput *big.Int) (bool, error) { - return _CartesiDApp.Contract.WasVoucherExecuted(&_CartesiDApp.CallOpts, _inputIndex, _outputIndexWithinInput) -} - -// WasVoucherExecuted is a free data retrieval call binding the contract method 0x9d9b1145. -// -// Solidity: function wasVoucherExecuted(uint256 _inputIndex, uint256 _outputIndexWithinInput) view returns(bool) -func (_CartesiDApp *CartesiDAppCallerSession) WasVoucherExecuted(_inputIndex *big.Int, _outputIndexWithinInput *big.Int) (bool, error) { - return _CartesiDApp.Contract.WasVoucherExecuted(&_CartesiDApp.CallOpts, _inputIndex, _outputIndexWithinInput) -} - -// ExecuteVoucher is a paid mutator transaction binding the contract method 0x1250482f. -// -// Solidity: function executeVoucher(address _destination, bytes _payload, ((uint64,uint64,bytes32,bytes32,bytes32,bytes32,bytes32[],bytes32[]),bytes) _proof) returns(bool) -func (_CartesiDApp *CartesiDAppTransactor) ExecuteVoucher(opts *bind.TransactOpts, _destination common.Address, _payload []byte, _proof Proof) (*types.Transaction, error) { - return _CartesiDApp.contract.Transact(opts, "executeVoucher", _destination, _payload, _proof) -} - -// ExecuteVoucher is a paid mutator transaction binding the contract method 0x1250482f. -// -// Solidity: function executeVoucher(address _destination, bytes _payload, ((uint64,uint64,bytes32,bytes32,bytes32,bytes32,bytes32[],bytes32[]),bytes) _proof) returns(bool) -func (_CartesiDApp *CartesiDAppSession) ExecuteVoucher(_destination common.Address, _payload []byte, _proof Proof) (*types.Transaction, error) { - return _CartesiDApp.Contract.ExecuteVoucher(&_CartesiDApp.TransactOpts, _destination, _payload, _proof) -} - -// ExecuteVoucher is a paid mutator transaction binding the contract method 0x1250482f. -// -// Solidity: function executeVoucher(address _destination, bytes _payload, ((uint64,uint64,bytes32,bytes32,bytes32,bytes32,bytes32[],bytes32[]),bytes) _proof) returns(bool) -func (_CartesiDApp *CartesiDAppTransactorSession) ExecuteVoucher(_destination common.Address, _payload []byte, _proof Proof) (*types.Transaction, error) { - return _CartesiDApp.Contract.ExecuteVoucher(&_CartesiDApp.TransactOpts, _destination, _payload, _proof) -} - -// MigrateToConsensus is a paid mutator transaction binding the contract method 0xfc411683. -// -// Solidity: function migrateToConsensus(address _newConsensus) returns() -func (_CartesiDApp *CartesiDAppTransactor) MigrateToConsensus(opts *bind.TransactOpts, _newConsensus common.Address) (*types.Transaction, error) { - return _CartesiDApp.contract.Transact(opts, "migrateToConsensus", _newConsensus) -} - -// MigrateToConsensus is a paid mutator transaction binding the contract method 0xfc411683. -// -// Solidity: function migrateToConsensus(address _newConsensus) returns() -func (_CartesiDApp *CartesiDAppSession) MigrateToConsensus(_newConsensus common.Address) (*types.Transaction, error) { - return _CartesiDApp.Contract.MigrateToConsensus(&_CartesiDApp.TransactOpts, _newConsensus) -} - -// MigrateToConsensus is a paid mutator transaction binding the contract method 0xfc411683. -// -// Solidity: function migrateToConsensus(address _newConsensus) returns() -func (_CartesiDApp *CartesiDAppTransactorSession) MigrateToConsensus(_newConsensus common.Address) (*types.Transaction, error) { - return _CartesiDApp.Contract.MigrateToConsensus(&_CartesiDApp.TransactOpts, _newConsensus) -} - -// OnERC1155BatchReceived is a paid mutator transaction binding the contract method 0xbc197c81. -// -// Solidity: function onERC1155BatchReceived(address , address , uint256[] , uint256[] , bytes ) returns(bytes4) -func (_CartesiDApp *CartesiDAppTransactor) OnERC1155BatchReceived(opts *bind.TransactOpts, arg0 common.Address, arg1 common.Address, arg2 []*big.Int, arg3 []*big.Int, arg4 []byte) (*types.Transaction, error) { - return _CartesiDApp.contract.Transact(opts, "onERC1155BatchReceived", arg0, arg1, arg2, arg3, arg4) -} - -// OnERC1155BatchReceived is a paid mutator transaction binding the contract method 0xbc197c81. -// -// Solidity: function onERC1155BatchReceived(address , address , uint256[] , uint256[] , bytes ) returns(bytes4) -func (_CartesiDApp *CartesiDAppSession) OnERC1155BatchReceived(arg0 common.Address, arg1 common.Address, arg2 []*big.Int, arg3 []*big.Int, arg4 []byte) (*types.Transaction, error) { - return _CartesiDApp.Contract.OnERC1155BatchReceived(&_CartesiDApp.TransactOpts, arg0, arg1, arg2, arg3, arg4) -} - -// OnERC1155BatchReceived is a paid mutator transaction binding the contract method 0xbc197c81. -// -// Solidity: function onERC1155BatchReceived(address , address , uint256[] , uint256[] , bytes ) returns(bytes4) -func (_CartesiDApp *CartesiDAppTransactorSession) OnERC1155BatchReceived(arg0 common.Address, arg1 common.Address, arg2 []*big.Int, arg3 []*big.Int, arg4 []byte) (*types.Transaction, error) { - return _CartesiDApp.Contract.OnERC1155BatchReceived(&_CartesiDApp.TransactOpts, arg0, arg1, arg2, arg3, arg4) -} - -// OnERC1155Received is a paid mutator transaction binding the contract method 0xf23a6e61. -// -// Solidity: function onERC1155Received(address , address , uint256 , uint256 , bytes ) returns(bytes4) -func (_CartesiDApp *CartesiDAppTransactor) OnERC1155Received(opts *bind.TransactOpts, arg0 common.Address, arg1 common.Address, arg2 *big.Int, arg3 *big.Int, arg4 []byte) (*types.Transaction, error) { - return _CartesiDApp.contract.Transact(opts, "onERC1155Received", arg0, arg1, arg2, arg3, arg4) -} - -// OnERC1155Received is a paid mutator transaction binding the contract method 0xf23a6e61. -// -// Solidity: function onERC1155Received(address , address , uint256 , uint256 , bytes ) returns(bytes4) -func (_CartesiDApp *CartesiDAppSession) OnERC1155Received(arg0 common.Address, arg1 common.Address, arg2 *big.Int, arg3 *big.Int, arg4 []byte) (*types.Transaction, error) { - return _CartesiDApp.Contract.OnERC1155Received(&_CartesiDApp.TransactOpts, arg0, arg1, arg2, arg3, arg4) -} - -// OnERC1155Received is a paid mutator transaction binding the contract method 0xf23a6e61. -// -// Solidity: function onERC1155Received(address , address , uint256 , uint256 , bytes ) returns(bytes4) -func (_CartesiDApp *CartesiDAppTransactorSession) OnERC1155Received(arg0 common.Address, arg1 common.Address, arg2 *big.Int, arg3 *big.Int, arg4 []byte) (*types.Transaction, error) { - return _CartesiDApp.Contract.OnERC1155Received(&_CartesiDApp.TransactOpts, arg0, arg1, arg2, arg3, arg4) -} - -// OnERC721Received is a paid mutator transaction binding the contract method 0x150b7a02. -// -// Solidity: function onERC721Received(address , address , uint256 , bytes ) returns(bytes4) -func (_CartesiDApp *CartesiDAppTransactor) OnERC721Received(opts *bind.TransactOpts, arg0 common.Address, arg1 common.Address, arg2 *big.Int, arg3 []byte) (*types.Transaction, error) { - return _CartesiDApp.contract.Transact(opts, "onERC721Received", arg0, arg1, arg2, arg3) -} - -// OnERC721Received is a paid mutator transaction binding the contract method 0x150b7a02. -// -// Solidity: function onERC721Received(address , address , uint256 , bytes ) returns(bytes4) -func (_CartesiDApp *CartesiDAppSession) OnERC721Received(arg0 common.Address, arg1 common.Address, arg2 *big.Int, arg3 []byte) (*types.Transaction, error) { - return _CartesiDApp.Contract.OnERC721Received(&_CartesiDApp.TransactOpts, arg0, arg1, arg2, arg3) -} - -// OnERC721Received is a paid mutator transaction binding the contract method 0x150b7a02. -// -// Solidity: function onERC721Received(address , address , uint256 , bytes ) returns(bytes4) -func (_CartesiDApp *CartesiDAppTransactorSession) OnERC721Received(arg0 common.Address, arg1 common.Address, arg2 *big.Int, arg3 []byte) (*types.Transaction, error) { - return _CartesiDApp.Contract.OnERC721Received(&_CartesiDApp.TransactOpts, arg0, arg1, arg2, arg3) -} - -// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. -// -// Solidity: function renounceOwnership() returns() -func (_CartesiDApp *CartesiDAppTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { - return _CartesiDApp.contract.Transact(opts, "renounceOwnership") -} - -// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. -// -// Solidity: function renounceOwnership() returns() -func (_CartesiDApp *CartesiDAppSession) RenounceOwnership() (*types.Transaction, error) { - return _CartesiDApp.Contract.RenounceOwnership(&_CartesiDApp.TransactOpts) -} - -// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. -// -// Solidity: function renounceOwnership() returns() -func (_CartesiDApp *CartesiDAppTransactorSession) RenounceOwnership() (*types.Transaction, error) { - return _CartesiDApp.Contract.RenounceOwnership(&_CartesiDApp.TransactOpts) -} - -// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. -// -// Solidity: function transferOwnership(address newOwner) returns() -func (_CartesiDApp *CartesiDAppTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { - return _CartesiDApp.contract.Transact(opts, "transferOwnership", newOwner) -} - -// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. -// -// Solidity: function transferOwnership(address newOwner) returns() -func (_CartesiDApp *CartesiDAppSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { - return _CartesiDApp.Contract.TransferOwnership(&_CartesiDApp.TransactOpts, newOwner) -} - -// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. -// -// Solidity: function transferOwnership(address newOwner) returns() -func (_CartesiDApp *CartesiDAppTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { - return _CartesiDApp.Contract.TransferOwnership(&_CartesiDApp.TransactOpts, newOwner) -} - -// WithdrawEther is a paid mutator transaction binding the contract method 0x522f6815. -// -// Solidity: function withdrawEther(address _receiver, uint256 _value) returns() -func (_CartesiDApp *CartesiDAppTransactor) WithdrawEther(opts *bind.TransactOpts, _receiver common.Address, _value *big.Int) (*types.Transaction, error) { - return _CartesiDApp.contract.Transact(opts, "withdrawEther", _receiver, _value) -} - -// WithdrawEther is a paid mutator transaction binding the contract method 0x522f6815. -// -// Solidity: function withdrawEther(address _receiver, uint256 _value) returns() -func (_CartesiDApp *CartesiDAppSession) WithdrawEther(_receiver common.Address, _value *big.Int) (*types.Transaction, error) { - return _CartesiDApp.Contract.WithdrawEther(&_CartesiDApp.TransactOpts, _receiver, _value) -} - -// WithdrawEther is a paid mutator transaction binding the contract method 0x522f6815. -// -// Solidity: function withdrawEther(address _receiver, uint256 _value) returns() -func (_CartesiDApp *CartesiDAppTransactorSession) WithdrawEther(_receiver common.Address, _value *big.Int) (*types.Transaction, error) { - return _CartesiDApp.Contract.WithdrawEther(&_CartesiDApp.TransactOpts, _receiver, _value) -} - -// Receive is a paid mutator transaction binding the contract receive function. -// -// Solidity: receive() payable returns() -func (_CartesiDApp *CartesiDAppTransactor) Receive(opts *bind.TransactOpts) (*types.Transaction, error) { - return _CartesiDApp.contract.RawTransact(opts, nil) // calldata is disallowed for receive function -} - -// Receive is a paid mutator transaction binding the contract receive function. -// -// Solidity: receive() payable returns() -func (_CartesiDApp *CartesiDAppSession) Receive() (*types.Transaction, error) { - return _CartesiDApp.Contract.Receive(&_CartesiDApp.TransactOpts) -} - -// Receive is a paid mutator transaction binding the contract receive function. -// -// Solidity: receive() payable returns() -func (_CartesiDApp *CartesiDAppTransactorSession) Receive() (*types.Transaction, error) { - return _CartesiDApp.Contract.Receive(&_CartesiDApp.TransactOpts) -} - -// CartesiDAppNewConsensusIterator is returned from FilterNewConsensus and is used to iterate over the raw logs and unpacked data for NewConsensus events raised by the CartesiDApp contract. -type CartesiDAppNewConsensusIterator struct { - Event *CartesiDAppNewConsensus // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *CartesiDAppNewConsensusIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(CartesiDAppNewConsensus) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(CartesiDAppNewConsensus) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *CartesiDAppNewConsensusIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *CartesiDAppNewConsensusIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// CartesiDAppNewConsensus represents a NewConsensus event raised by the CartesiDApp contract. -type CartesiDAppNewConsensus struct { - NewConsensus common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterNewConsensus is a free log retrieval operation binding the contract event 0x4991c6f37185659e276ff918a96f3e20e6c5abcd8c9aab450dc19c2f7ad35cb5. -// -// Solidity: event NewConsensus(address newConsensus) -func (_CartesiDApp *CartesiDAppFilterer) FilterNewConsensus(opts *bind.FilterOpts) (*CartesiDAppNewConsensusIterator, error) { - - logs, sub, err := _CartesiDApp.contract.FilterLogs(opts, "NewConsensus") - if err != nil { - return nil, err - } - return &CartesiDAppNewConsensusIterator{contract: _CartesiDApp.contract, event: "NewConsensus", logs: logs, sub: sub}, nil -} - -// WatchNewConsensus is a free log subscription operation binding the contract event 0x4991c6f37185659e276ff918a96f3e20e6c5abcd8c9aab450dc19c2f7ad35cb5. -// -// Solidity: event NewConsensus(address newConsensus) -func (_CartesiDApp *CartesiDAppFilterer) WatchNewConsensus(opts *bind.WatchOpts, sink chan<- *CartesiDAppNewConsensus) (event.Subscription, error) { - - logs, sub, err := _CartesiDApp.contract.WatchLogs(opts, "NewConsensus") - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(CartesiDAppNewConsensus) - if err := _CartesiDApp.contract.UnpackLog(event, "NewConsensus", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseNewConsensus is a log parse operation binding the contract event 0x4991c6f37185659e276ff918a96f3e20e6c5abcd8c9aab450dc19c2f7ad35cb5. -// -// Solidity: event NewConsensus(address newConsensus) -func (_CartesiDApp *CartesiDAppFilterer) ParseNewConsensus(log types.Log) (*CartesiDAppNewConsensus, error) { - event := new(CartesiDAppNewConsensus) - if err := _CartesiDApp.contract.UnpackLog(event, "NewConsensus", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// CartesiDAppOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the CartesiDApp contract. -type CartesiDAppOwnershipTransferredIterator struct { - Event *CartesiDAppOwnershipTransferred // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *CartesiDAppOwnershipTransferredIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(CartesiDAppOwnershipTransferred) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(CartesiDAppOwnershipTransferred) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *CartesiDAppOwnershipTransferredIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *CartesiDAppOwnershipTransferredIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// CartesiDAppOwnershipTransferred represents a OwnershipTransferred event raised by the CartesiDApp contract. -type CartesiDAppOwnershipTransferred struct { - PreviousOwner common.Address - NewOwner common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. -// -// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) -func (_CartesiDApp *CartesiDAppFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*CartesiDAppOwnershipTransferredIterator, error) { - - var previousOwnerRule []interface{} - for _, previousOwnerItem := range previousOwner { - previousOwnerRule = append(previousOwnerRule, previousOwnerItem) - } - var newOwnerRule []interface{} - for _, newOwnerItem := range newOwner { - newOwnerRule = append(newOwnerRule, newOwnerItem) - } - - logs, sub, err := _CartesiDApp.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) - if err != nil { - return nil, err - } - return &CartesiDAppOwnershipTransferredIterator{contract: _CartesiDApp.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil -} - -// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. -// -// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) -func (_CartesiDApp *CartesiDAppFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *CartesiDAppOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { - - var previousOwnerRule []interface{} - for _, previousOwnerItem := range previousOwner { - previousOwnerRule = append(previousOwnerRule, previousOwnerItem) - } - var newOwnerRule []interface{} - for _, newOwnerItem := range newOwner { - newOwnerRule = append(newOwnerRule, newOwnerItem) - } - - logs, sub, err := _CartesiDApp.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(CartesiDAppOwnershipTransferred) - if err := _CartesiDApp.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. -// -// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) -func (_CartesiDApp *CartesiDAppFilterer) ParseOwnershipTransferred(log types.Log) (*CartesiDAppOwnershipTransferred, error) { - event := new(CartesiDAppOwnershipTransferred) - if err := _CartesiDApp.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// CartesiDAppVoucherExecutedIterator is returned from FilterVoucherExecuted and is used to iterate over the raw logs and unpacked data for VoucherExecuted events raised by the CartesiDApp contract. -type CartesiDAppVoucherExecutedIterator struct { - Event *CartesiDAppVoucherExecuted // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *CartesiDAppVoucherExecutedIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(CartesiDAppVoucherExecuted) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(CartesiDAppVoucherExecuted) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *CartesiDAppVoucherExecutedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *CartesiDAppVoucherExecutedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// CartesiDAppVoucherExecuted represents a VoucherExecuted event raised by the CartesiDApp contract. -type CartesiDAppVoucherExecuted struct { - VoucherId *big.Int - Raw types.Log // Blockchain specific contextual infos -} - -// FilterVoucherExecuted is a free log retrieval operation binding the contract event 0x0eb7ee080f865f1cadc4f54daf58cc3b8879e888832867d13351edcec0fbdc54. -// -// Solidity: event VoucherExecuted(uint256 voucherId) -func (_CartesiDApp *CartesiDAppFilterer) FilterVoucherExecuted(opts *bind.FilterOpts) (*CartesiDAppVoucherExecutedIterator, error) { - - logs, sub, err := _CartesiDApp.contract.FilterLogs(opts, "VoucherExecuted") - if err != nil { - return nil, err - } - return &CartesiDAppVoucherExecutedIterator{contract: _CartesiDApp.contract, event: "VoucherExecuted", logs: logs, sub: sub}, nil -} - -// WatchVoucherExecuted is a free log subscription operation binding the contract event 0x0eb7ee080f865f1cadc4f54daf58cc3b8879e888832867d13351edcec0fbdc54. -// -// Solidity: event VoucherExecuted(uint256 voucherId) -func (_CartesiDApp *CartesiDAppFilterer) WatchVoucherExecuted(opts *bind.WatchOpts, sink chan<- *CartesiDAppVoucherExecuted) (event.Subscription, error) { - - logs, sub, err := _CartesiDApp.contract.WatchLogs(opts, "VoucherExecuted") - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(CartesiDAppVoucherExecuted) - if err := _CartesiDApp.contract.UnpackLog(event, "VoucherExecuted", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseVoucherExecuted is a log parse operation binding the contract event 0x0eb7ee080f865f1cadc4f54daf58cc3b8879e888832867d13351edcec0fbdc54. -// -// Solidity: event VoucherExecuted(uint256 voucherId) -func (_CartesiDApp *CartesiDAppFilterer) ParseVoucherExecuted(log types.Log) (*CartesiDAppVoucherExecuted, error) { - event := new(CartesiDAppVoucherExecuted) - if err := _CartesiDApp.contract.UnpackLog(event, "VoucherExecuted", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} diff --git a/pkg/contracts/cartesi_dapp_factory.go b/pkg/contracts/cartesi_dapp_factory.go deleted file mode 100644 index fb6b2be18..000000000 --- a/pkg/contracts/cartesi_dapp_factory.go +++ /dev/null @@ -1,401 +0,0 @@ -// Code generated - DO NOT EDIT. -// This file is a generated binding and any manual changes will be lost. - -package contracts - -import ( - "errors" - "math/big" - "strings" - - ethereum "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/event" -) - -// Reference imports to suppress errors if they are not otherwise used. -var ( - _ = errors.New - _ = big.NewInt - _ = strings.NewReader - _ = ethereum.NotFound - _ = bind.Bind - _ = common.Big1 - _ = types.BloomLookup - _ = event.NewSubscription - _ = abi.ConvertType -) - -// CartesiDAppFactoryMetaData contains all meta data concerning the CartesiDAppFactory contract. -var CartesiDAppFactoryMetaData = &bind.MetaData{ - ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"contractIConsensus\",\"name\":\"consensus\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"dappOwner\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"templateHash\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"contractCartesiDApp\",\"name\":\"application\",\"type\":\"address\"}],\"name\":\"ApplicationCreated\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"contractIConsensus\",\"name\":\"_consensus\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_dappOwner\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"_templateHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_salt\",\"type\":\"bytes32\"}],\"name\":\"calculateApplicationAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contractIConsensus\",\"name\":\"_consensus\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_dappOwner\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"_templateHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_salt\",\"type\":\"bytes32\"}],\"name\":\"newApplication\",\"outputs\":[{\"internalType\":\"contractCartesiDApp\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contractIConsensus\",\"name\":\"_consensus\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_dappOwner\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"_templateHash\",\"type\":\"bytes32\"}],\"name\":\"newApplication\",\"outputs\":[{\"internalType\":\"contractCartesiDApp\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", -} - -// CartesiDAppFactoryABI is the input ABI used to generate the binding from. -// Deprecated: Use CartesiDAppFactoryMetaData.ABI instead. -var CartesiDAppFactoryABI = CartesiDAppFactoryMetaData.ABI - -// CartesiDAppFactory is an auto generated Go binding around an Ethereum contract. -type CartesiDAppFactory struct { - CartesiDAppFactoryCaller // Read-only binding to the contract - CartesiDAppFactoryTransactor // Write-only binding to the contract - CartesiDAppFactoryFilterer // Log filterer for contract events -} - -// CartesiDAppFactoryCaller is an auto generated read-only Go binding around an Ethereum contract. -type CartesiDAppFactoryCaller struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// CartesiDAppFactoryTransactor is an auto generated write-only Go binding around an Ethereum contract. -type CartesiDAppFactoryTransactor struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// CartesiDAppFactoryFilterer is an auto generated log filtering Go binding around an Ethereum contract events. -type CartesiDAppFactoryFilterer struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// CartesiDAppFactorySession is an auto generated Go binding around an Ethereum contract, -// with pre-set call and transact options. -type CartesiDAppFactorySession struct { - Contract *CartesiDAppFactory // Generic contract binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// CartesiDAppFactoryCallerSession is an auto generated read-only Go binding around an Ethereum contract, -// with pre-set call options. -type CartesiDAppFactoryCallerSession struct { - Contract *CartesiDAppFactoryCaller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session -} - -// CartesiDAppFactoryTransactorSession is an auto generated write-only Go binding around an Ethereum contract, -// with pre-set transact options. -type CartesiDAppFactoryTransactorSession struct { - Contract *CartesiDAppFactoryTransactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// CartesiDAppFactoryRaw is an auto generated low-level Go binding around an Ethereum contract. -type CartesiDAppFactoryRaw struct { - Contract *CartesiDAppFactory // Generic contract binding to access the raw methods on -} - -// CartesiDAppFactoryCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type CartesiDAppFactoryCallerRaw struct { - Contract *CartesiDAppFactoryCaller // Generic read-only contract binding to access the raw methods on -} - -// CartesiDAppFactoryTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type CartesiDAppFactoryTransactorRaw struct { - Contract *CartesiDAppFactoryTransactor // Generic write-only contract binding to access the raw methods on -} - -// NewCartesiDAppFactory creates a new instance of CartesiDAppFactory, bound to a specific deployed contract. -func NewCartesiDAppFactory(address common.Address, backend bind.ContractBackend) (*CartesiDAppFactory, error) { - contract, err := bindCartesiDAppFactory(address, backend, backend, backend) - if err != nil { - return nil, err - } - return &CartesiDAppFactory{CartesiDAppFactoryCaller: CartesiDAppFactoryCaller{contract: contract}, CartesiDAppFactoryTransactor: CartesiDAppFactoryTransactor{contract: contract}, CartesiDAppFactoryFilterer: CartesiDAppFactoryFilterer{contract: contract}}, nil -} - -// NewCartesiDAppFactoryCaller creates a new read-only instance of CartesiDAppFactory, bound to a specific deployed contract. -func NewCartesiDAppFactoryCaller(address common.Address, caller bind.ContractCaller) (*CartesiDAppFactoryCaller, error) { - contract, err := bindCartesiDAppFactory(address, caller, nil, nil) - if err != nil { - return nil, err - } - return &CartesiDAppFactoryCaller{contract: contract}, nil -} - -// NewCartesiDAppFactoryTransactor creates a new write-only instance of CartesiDAppFactory, bound to a specific deployed contract. -func NewCartesiDAppFactoryTransactor(address common.Address, transactor bind.ContractTransactor) (*CartesiDAppFactoryTransactor, error) { - contract, err := bindCartesiDAppFactory(address, nil, transactor, nil) - if err != nil { - return nil, err - } - return &CartesiDAppFactoryTransactor{contract: contract}, nil -} - -// NewCartesiDAppFactoryFilterer creates a new log filterer instance of CartesiDAppFactory, bound to a specific deployed contract. -func NewCartesiDAppFactoryFilterer(address common.Address, filterer bind.ContractFilterer) (*CartesiDAppFactoryFilterer, error) { - contract, err := bindCartesiDAppFactory(address, nil, nil, filterer) - if err != nil { - return nil, err - } - return &CartesiDAppFactoryFilterer{contract: contract}, nil -} - -// bindCartesiDAppFactory binds a generic wrapper to an already deployed contract. -func bindCartesiDAppFactory(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := CartesiDAppFactoryMetaData.GetAbi() - if err != nil { - return nil, err - } - return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_CartesiDAppFactory *CartesiDAppFactoryRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _CartesiDAppFactory.Contract.CartesiDAppFactoryCaller.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_CartesiDAppFactory *CartesiDAppFactoryRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _CartesiDAppFactory.Contract.CartesiDAppFactoryTransactor.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_CartesiDAppFactory *CartesiDAppFactoryRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _CartesiDAppFactory.Contract.CartesiDAppFactoryTransactor.contract.Transact(opts, method, params...) -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_CartesiDAppFactory *CartesiDAppFactoryCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _CartesiDAppFactory.Contract.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_CartesiDAppFactory *CartesiDAppFactoryTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _CartesiDAppFactory.Contract.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_CartesiDAppFactory *CartesiDAppFactoryTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _CartesiDAppFactory.Contract.contract.Transact(opts, method, params...) -} - -// CalculateApplicationAddress is a free data retrieval call binding the contract method 0xbd4f1219. -// -// Solidity: function calculateApplicationAddress(address _consensus, address _dappOwner, bytes32 _templateHash, bytes32 _salt) view returns(address) -func (_CartesiDAppFactory *CartesiDAppFactoryCaller) CalculateApplicationAddress(opts *bind.CallOpts, _consensus common.Address, _dappOwner common.Address, _templateHash [32]byte, _salt [32]byte) (common.Address, error) { - var out []interface{} - err := _CartesiDAppFactory.contract.Call(opts, &out, "calculateApplicationAddress", _consensus, _dappOwner, _templateHash, _salt) - - if err != nil { - return *new(common.Address), err - } - - out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - - return out0, err - -} - -// CalculateApplicationAddress is a free data retrieval call binding the contract method 0xbd4f1219. -// -// Solidity: function calculateApplicationAddress(address _consensus, address _dappOwner, bytes32 _templateHash, bytes32 _salt) view returns(address) -func (_CartesiDAppFactory *CartesiDAppFactorySession) CalculateApplicationAddress(_consensus common.Address, _dappOwner common.Address, _templateHash [32]byte, _salt [32]byte) (common.Address, error) { - return _CartesiDAppFactory.Contract.CalculateApplicationAddress(&_CartesiDAppFactory.CallOpts, _consensus, _dappOwner, _templateHash, _salt) -} - -// CalculateApplicationAddress is a free data retrieval call binding the contract method 0xbd4f1219. -// -// Solidity: function calculateApplicationAddress(address _consensus, address _dappOwner, bytes32 _templateHash, bytes32 _salt) view returns(address) -func (_CartesiDAppFactory *CartesiDAppFactoryCallerSession) CalculateApplicationAddress(_consensus common.Address, _dappOwner common.Address, _templateHash [32]byte, _salt [32]byte) (common.Address, error) { - return _CartesiDAppFactory.Contract.CalculateApplicationAddress(&_CartesiDAppFactory.CallOpts, _consensus, _dappOwner, _templateHash, _salt) -} - -// NewApplication is a paid mutator transaction binding the contract method 0x0e1a07f5. -// -// Solidity: function newApplication(address _consensus, address _dappOwner, bytes32 _templateHash, bytes32 _salt) returns(address) -func (_CartesiDAppFactory *CartesiDAppFactoryTransactor) NewApplication(opts *bind.TransactOpts, _consensus common.Address, _dappOwner common.Address, _templateHash [32]byte, _salt [32]byte) (*types.Transaction, error) { - return _CartesiDAppFactory.contract.Transact(opts, "newApplication", _consensus, _dappOwner, _templateHash, _salt) -} - -// NewApplication is a paid mutator transaction binding the contract method 0x0e1a07f5. -// -// Solidity: function newApplication(address _consensus, address _dappOwner, bytes32 _templateHash, bytes32 _salt) returns(address) -func (_CartesiDAppFactory *CartesiDAppFactorySession) NewApplication(_consensus common.Address, _dappOwner common.Address, _templateHash [32]byte, _salt [32]byte) (*types.Transaction, error) { - return _CartesiDAppFactory.Contract.NewApplication(&_CartesiDAppFactory.TransactOpts, _consensus, _dappOwner, _templateHash, _salt) -} - -// NewApplication is a paid mutator transaction binding the contract method 0x0e1a07f5. -// -// Solidity: function newApplication(address _consensus, address _dappOwner, bytes32 _templateHash, bytes32 _salt) returns(address) -func (_CartesiDAppFactory *CartesiDAppFactoryTransactorSession) NewApplication(_consensus common.Address, _dappOwner common.Address, _templateHash [32]byte, _salt [32]byte) (*types.Transaction, error) { - return _CartesiDAppFactory.Contract.NewApplication(&_CartesiDAppFactory.TransactOpts, _consensus, _dappOwner, _templateHash, _salt) -} - -// NewApplication0 is a paid mutator transaction binding the contract method 0x3648bfb5. -// -// Solidity: function newApplication(address _consensus, address _dappOwner, bytes32 _templateHash) returns(address) -func (_CartesiDAppFactory *CartesiDAppFactoryTransactor) NewApplication0(opts *bind.TransactOpts, _consensus common.Address, _dappOwner common.Address, _templateHash [32]byte) (*types.Transaction, error) { - return _CartesiDAppFactory.contract.Transact(opts, "newApplication0", _consensus, _dappOwner, _templateHash) -} - -// NewApplication0 is a paid mutator transaction binding the contract method 0x3648bfb5. -// -// Solidity: function newApplication(address _consensus, address _dappOwner, bytes32 _templateHash) returns(address) -func (_CartesiDAppFactory *CartesiDAppFactorySession) NewApplication0(_consensus common.Address, _dappOwner common.Address, _templateHash [32]byte) (*types.Transaction, error) { - return _CartesiDAppFactory.Contract.NewApplication0(&_CartesiDAppFactory.TransactOpts, _consensus, _dappOwner, _templateHash) -} - -// NewApplication0 is a paid mutator transaction binding the contract method 0x3648bfb5. -// -// Solidity: function newApplication(address _consensus, address _dappOwner, bytes32 _templateHash) returns(address) -func (_CartesiDAppFactory *CartesiDAppFactoryTransactorSession) NewApplication0(_consensus common.Address, _dappOwner common.Address, _templateHash [32]byte) (*types.Transaction, error) { - return _CartesiDAppFactory.Contract.NewApplication0(&_CartesiDAppFactory.TransactOpts, _consensus, _dappOwner, _templateHash) -} - -// CartesiDAppFactoryApplicationCreatedIterator is returned from FilterApplicationCreated and is used to iterate over the raw logs and unpacked data for ApplicationCreated events raised by the CartesiDAppFactory contract. -type CartesiDAppFactoryApplicationCreatedIterator struct { - Event *CartesiDAppFactoryApplicationCreated // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *CartesiDAppFactoryApplicationCreatedIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(CartesiDAppFactoryApplicationCreated) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(CartesiDAppFactoryApplicationCreated) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *CartesiDAppFactoryApplicationCreatedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *CartesiDAppFactoryApplicationCreatedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// CartesiDAppFactoryApplicationCreated represents a ApplicationCreated event raised by the CartesiDAppFactory contract. -type CartesiDAppFactoryApplicationCreated struct { - Consensus common.Address - DappOwner common.Address - TemplateHash [32]byte - Application common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterApplicationCreated is a free log retrieval operation binding the contract event 0xe73165c2d277daf8713fd08b40845cb6bb7a20b2b543f3d35324a475660fcebd. -// -// Solidity: event ApplicationCreated(address indexed consensus, address dappOwner, bytes32 templateHash, address application) -func (_CartesiDAppFactory *CartesiDAppFactoryFilterer) FilterApplicationCreated(opts *bind.FilterOpts, consensus []common.Address) (*CartesiDAppFactoryApplicationCreatedIterator, error) { - - var consensusRule []interface{} - for _, consensusItem := range consensus { - consensusRule = append(consensusRule, consensusItem) - } - - logs, sub, err := _CartesiDAppFactory.contract.FilterLogs(opts, "ApplicationCreated", consensusRule) - if err != nil { - return nil, err - } - return &CartesiDAppFactoryApplicationCreatedIterator{contract: _CartesiDAppFactory.contract, event: "ApplicationCreated", logs: logs, sub: sub}, nil -} - -// WatchApplicationCreated is a free log subscription operation binding the contract event 0xe73165c2d277daf8713fd08b40845cb6bb7a20b2b543f3d35324a475660fcebd. -// -// Solidity: event ApplicationCreated(address indexed consensus, address dappOwner, bytes32 templateHash, address application) -func (_CartesiDAppFactory *CartesiDAppFactoryFilterer) WatchApplicationCreated(opts *bind.WatchOpts, sink chan<- *CartesiDAppFactoryApplicationCreated, consensus []common.Address) (event.Subscription, error) { - - var consensusRule []interface{} - for _, consensusItem := range consensus { - consensusRule = append(consensusRule, consensusItem) - } - - logs, sub, err := _CartesiDAppFactory.contract.WatchLogs(opts, "ApplicationCreated", consensusRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(CartesiDAppFactoryApplicationCreated) - if err := _CartesiDAppFactory.contract.UnpackLog(event, "ApplicationCreated", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseApplicationCreated is a log parse operation binding the contract event 0xe73165c2d277daf8713fd08b40845cb6bb7a20b2b543f3d35324a475660fcebd. -// -// Solidity: event ApplicationCreated(address indexed consensus, address dappOwner, bytes32 templateHash, address application) -func (_CartesiDAppFactory *CartesiDAppFactoryFilterer) ParseApplicationCreated(log types.Log) (*CartesiDAppFactoryApplicationCreated, error) { - event := new(CartesiDAppFactoryApplicationCreated) - if err := _CartesiDAppFactory.contract.UnpackLog(event, "ApplicationCreated", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} diff --git a/pkg/contracts/generate/main.go b/pkg/contracts/generate/main.go index a0dba4861..c210a8fcc 100644 --- a/pkg/contracts/generate/main.go +++ b/pkg/contracts/generate/main.go @@ -12,49 +12,45 @@ import ( "archive/tar" "compress/gzip" "encoding/json" + "errors" "io" + "io/fs" "log" "net/http" "os" + "strings" "github.com/ethereum/go-ethereum/accounts/abi/bind" ) -const rollupsContractsUrl = "https://registry.npmjs.org/@cartesi/rollups/-/rollups-1.2.0.tgz" +const rollupsContractsUrl = "https://registry.npmjs.org/@cartesi/rollups/-/rollups-2.0.0-rc.2.tgz" const baseContractsPath = "package/export/artifacts/contracts/" -const bindingPkg = "contracts" type contractBinding struct { jsonPath string typeName string - outFile string } var bindings = []contractBinding{ { - jsonPath: baseContractsPath + "inputs/InputBox.sol/InputBox.json", - typeName: "InputBox", - outFile: "input_box.go", + jsonPath: baseContractsPath + "consensus/IConsensus.sol/IConsensus.json", + typeName: "IConsensus", }, { - jsonPath: baseContractsPath + "dapp/CartesiDAppFactory.sol/CartesiDAppFactory.json", - typeName: "CartesiDAppFactory", - outFile: "cartesi_dapp_factory.go", + jsonPath: baseContractsPath + "dapp/Application.sol/Application.json", + typeName: "Application", }, { - jsonPath: baseContractsPath + "dapp/CartesiDApp.sol/CartesiDApp.json", - typeName: "CartesiDApp", - outFile: "cartesi_dapp.go", + jsonPath: baseContractsPath + "inputs/InputBox.sol/InputBox.json", + typeName: "InputBox", }, { - jsonPath: baseContractsPath + "consensus/authority/Authority.sol/Authority.json", - typeName: "Authority", - outFile: "authority.go", + jsonPath: baseContractsPath + "common/Inputs.sol/Inputs.json", + typeName: "Inputs", }, { - jsonPath: baseContractsPath + "history/History.sol/History.json", - typeName: "History", - outFile: "history.go", + jsonPath: baseContractsPath + "common/Outputs.sol/Outputs.json", + typeName: "Outputs", }, } @@ -136,9 +132,16 @@ func getAbi(rawJson []byte) []byte { return contents.Abi } +// Check whether file exists. +func fileExists(filePath string) bool { + _, err := os.Stat(filePath) + return !errors.Is(err, fs.ErrNotExist) +} + // Generate the Go bindings for the contracts. func generateBinding(b contractBinding, content []byte) { var ( + pkg = strings.ToLower(b.typeName) sigs []map[string]string abis = []string{string(getAbi(content))} bins = []string{""} @@ -146,10 +149,22 @@ func generateBinding(b contractBinding, content []byte) { libs = make(map[string]string) aliases = make(map[string]string) ) - code, err := bind.Bind(types, abis, bins, sigs, bindingPkg, bind.LangGo, libs, aliases) + code, err := bind.Bind(types, abis, bins, sigs, pkg, bind.LangGo, libs, aliases) checkErr("generate binding", err) + + if fileExists(pkg) { + err := os.RemoveAll(pkg) + checkErr("removing dir", err) + } + + const dirMode = 0700 + err = os.Mkdir(pkg, dirMode) + checkErr("creating dir", err) + const fileMode = 0600 - err = os.WriteFile(b.outFile, []byte(code), fileMode) + filePath := pkg + "/" + pkg + ".go" + err = os.WriteFile(filePath, []byte(code), fileMode) checkErr("write binding file", err) - log.Print("generated binding ", b.outFile) + + log.Print("generated binding for ", filePath) } diff --git a/pkg/contracts/history.go b/pkg/contracts/history.go deleted file mode 100644 index 47489c82e..000000000 --- a/pkg/contracts/history.go +++ /dev/null @@ -1,634 +0,0 @@ -// Code generated - DO NOT EDIT. -// This file is a generated binding and any manual changes will be lost. - -package contracts - -import ( - "errors" - "math/big" - "strings" - - ethereum "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/event" -) - -// Reference imports to suppress errors if they are not otherwise used. -var ( - _ = errors.New - _ = big.NewInt - _ = strings.NewReader - _ = ethereum.NotFound - _ = bind.Bind - _ = common.Big1 - _ = types.BloomLookup - _ = event.NewSubscription - _ = abi.ConvertType -) - -// HistoryClaim is an auto generated low-level Go binding around an user-defined struct. -type HistoryClaim struct { - EpochHash [32]byte - FirstIndex *big.Int - LastIndex *big.Int -} - -// HistoryMetaData contains all meta data concerning the History contract. -var HistoryMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"InvalidClaimIndex\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidInputIndices\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UnclaimedInputs\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"dapp\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"epochHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint128\",\"name\":\"firstIndex\",\"type\":\"uint128\"},{\"internalType\":\"uint128\",\"name\":\"lastIndex\",\"type\":\"uint128\"}],\"indexed\":false,\"internalType\":\"structHistory.Claim\",\"name\":\"claim\",\"type\":\"tuple\"}],\"name\":\"NewClaimToHistory\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_dapp\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_proofContext\",\"type\":\"bytes\"}],\"name\":\"getClaim\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_consensus\",\"type\":\"address\"}],\"name\":\"migrateToConsensus\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"_claimData\",\"type\":\"bytes\"}],\"name\":\"submitClaim\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", -} - -// HistoryABI is the input ABI used to generate the binding from. -// Deprecated: Use HistoryMetaData.ABI instead. -var HistoryABI = HistoryMetaData.ABI - -// History is an auto generated Go binding around an Ethereum contract. -type History struct { - HistoryCaller // Read-only binding to the contract - HistoryTransactor // Write-only binding to the contract - HistoryFilterer // Log filterer for contract events -} - -// HistoryCaller is an auto generated read-only Go binding around an Ethereum contract. -type HistoryCaller struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// HistoryTransactor is an auto generated write-only Go binding around an Ethereum contract. -type HistoryTransactor struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// HistoryFilterer is an auto generated log filtering Go binding around an Ethereum contract events. -type HistoryFilterer struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// HistorySession is an auto generated Go binding around an Ethereum contract, -// with pre-set call and transact options. -type HistorySession struct { - Contract *History // Generic contract binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// HistoryCallerSession is an auto generated read-only Go binding around an Ethereum contract, -// with pre-set call options. -type HistoryCallerSession struct { - Contract *HistoryCaller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session -} - -// HistoryTransactorSession is an auto generated write-only Go binding around an Ethereum contract, -// with pre-set transact options. -type HistoryTransactorSession struct { - Contract *HistoryTransactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// HistoryRaw is an auto generated low-level Go binding around an Ethereum contract. -type HistoryRaw struct { - Contract *History // Generic contract binding to access the raw methods on -} - -// HistoryCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type HistoryCallerRaw struct { - Contract *HistoryCaller // Generic read-only contract binding to access the raw methods on -} - -// HistoryTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type HistoryTransactorRaw struct { - Contract *HistoryTransactor // Generic write-only contract binding to access the raw methods on -} - -// NewHistory creates a new instance of History, bound to a specific deployed contract. -func NewHistory(address common.Address, backend bind.ContractBackend) (*History, error) { - contract, err := bindHistory(address, backend, backend, backend) - if err != nil { - return nil, err - } - return &History{HistoryCaller: HistoryCaller{contract: contract}, HistoryTransactor: HistoryTransactor{contract: contract}, HistoryFilterer: HistoryFilterer{contract: contract}}, nil -} - -// NewHistoryCaller creates a new read-only instance of History, bound to a specific deployed contract. -func NewHistoryCaller(address common.Address, caller bind.ContractCaller) (*HistoryCaller, error) { - contract, err := bindHistory(address, caller, nil, nil) - if err != nil { - return nil, err - } - return &HistoryCaller{contract: contract}, nil -} - -// NewHistoryTransactor creates a new write-only instance of History, bound to a specific deployed contract. -func NewHistoryTransactor(address common.Address, transactor bind.ContractTransactor) (*HistoryTransactor, error) { - contract, err := bindHistory(address, nil, transactor, nil) - if err != nil { - return nil, err - } - return &HistoryTransactor{contract: contract}, nil -} - -// NewHistoryFilterer creates a new log filterer instance of History, bound to a specific deployed contract. -func NewHistoryFilterer(address common.Address, filterer bind.ContractFilterer) (*HistoryFilterer, error) { - contract, err := bindHistory(address, nil, nil, filterer) - if err != nil { - return nil, err - } - return &HistoryFilterer{contract: contract}, nil -} - -// bindHistory binds a generic wrapper to an already deployed contract. -func bindHistory(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := HistoryMetaData.GetAbi() - if err != nil { - return nil, err - } - return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_History *HistoryRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _History.Contract.HistoryCaller.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_History *HistoryRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _History.Contract.HistoryTransactor.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_History *HistoryRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _History.Contract.HistoryTransactor.contract.Transact(opts, method, params...) -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_History *HistoryCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _History.Contract.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_History *HistoryTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _History.Contract.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_History *HistoryTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _History.Contract.contract.Transact(opts, method, params...) -} - -// GetClaim is a free data retrieval call binding the contract method 0xd79a8240. -// -// Solidity: function getClaim(address _dapp, bytes _proofContext) view returns(bytes32, uint256, uint256) -func (_History *HistoryCaller) GetClaim(opts *bind.CallOpts, _dapp common.Address, _proofContext []byte) ([32]byte, *big.Int, *big.Int, error) { - var out []interface{} - err := _History.contract.Call(opts, &out, "getClaim", _dapp, _proofContext) - - if err != nil { - return *new([32]byte), *new(*big.Int), *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) - out1 := *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) - out2 := *abi.ConvertType(out[2], new(*big.Int)).(**big.Int) - - return out0, out1, out2, err - -} - -// GetClaim is a free data retrieval call binding the contract method 0xd79a8240. -// -// Solidity: function getClaim(address _dapp, bytes _proofContext) view returns(bytes32, uint256, uint256) -func (_History *HistorySession) GetClaim(_dapp common.Address, _proofContext []byte) ([32]byte, *big.Int, *big.Int, error) { - return _History.Contract.GetClaim(&_History.CallOpts, _dapp, _proofContext) -} - -// GetClaim is a free data retrieval call binding the contract method 0xd79a8240. -// -// Solidity: function getClaim(address _dapp, bytes _proofContext) view returns(bytes32, uint256, uint256) -func (_History *HistoryCallerSession) GetClaim(_dapp common.Address, _proofContext []byte) ([32]byte, *big.Int, *big.Int, error) { - return _History.Contract.GetClaim(&_History.CallOpts, _dapp, _proofContext) -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_History *HistoryCaller) Owner(opts *bind.CallOpts) (common.Address, error) { - var out []interface{} - err := _History.contract.Call(opts, &out, "owner") - - if err != nil { - return *new(common.Address), err - } - - out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - - return out0, err - -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_History *HistorySession) Owner() (common.Address, error) { - return _History.Contract.Owner(&_History.CallOpts) -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_History *HistoryCallerSession) Owner() (common.Address, error) { - return _History.Contract.Owner(&_History.CallOpts) -} - -// MigrateToConsensus is a paid mutator transaction binding the contract method 0xfc411683. -// -// Solidity: function migrateToConsensus(address _consensus) returns() -func (_History *HistoryTransactor) MigrateToConsensus(opts *bind.TransactOpts, _consensus common.Address) (*types.Transaction, error) { - return _History.contract.Transact(opts, "migrateToConsensus", _consensus) -} - -// MigrateToConsensus is a paid mutator transaction binding the contract method 0xfc411683. -// -// Solidity: function migrateToConsensus(address _consensus) returns() -func (_History *HistorySession) MigrateToConsensus(_consensus common.Address) (*types.Transaction, error) { - return _History.Contract.MigrateToConsensus(&_History.TransactOpts, _consensus) -} - -// MigrateToConsensus is a paid mutator transaction binding the contract method 0xfc411683. -// -// Solidity: function migrateToConsensus(address _consensus) returns() -func (_History *HistoryTransactorSession) MigrateToConsensus(_consensus common.Address) (*types.Transaction, error) { - return _History.Contract.MigrateToConsensus(&_History.TransactOpts, _consensus) -} - -// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. -// -// Solidity: function renounceOwnership() returns() -func (_History *HistoryTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { - return _History.contract.Transact(opts, "renounceOwnership") -} - -// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. -// -// Solidity: function renounceOwnership() returns() -func (_History *HistorySession) RenounceOwnership() (*types.Transaction, error) { - return _History.Contract.RenounceOwnership(&_History.TransactOpts) -} - -// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. -// -// Solidity: function renounceOwnership() returns() -func (_History *HistoryTransactorSession) RenounceOwnership() (*types.Transaction, error) { - return _History.Contract.RenounceOwnership(&_History.TransactOpts) -} - -// SubmitClaim is a paid mutator transaction binding the contract method 0xddfdfbb0. -// -// Solidity: function submitClaim(bytes _claimData) returns() -func (_History *HistoryTransactor) SubmitClaim(opts *bind.TransactOpts, _claimData []byte) (*types.Transaction, error) { - return _History.contract.Transact(opts, "submitClaim", _claimData) -} - -// SubmitClaim is a paid mutator transaction binding the contract method 0xddfdfbb0. -// -// Solidity: function submitClaim(bytes _claimData) returns() -func (_History *HistorySession) SubmitClaim(_claimData []byte) (*types.Transaction, error) { - return _History.Contract.SubmitClaim(&_History.TransactOpts, _claimData) -} - -// SubmitClaim is a paid mutator transaction binding the contract method 0xddfdfbb0. -// -// Solidity: function submitClaim(bytes _claimData) returns() -func (_History *HistoryTransactorSession) SubmitClaim(_claimData []byte) (*types.Transaction, error) { - return _History.Contract.SubmitClaim(&_History.TransactOpts, _claimData) -} - -// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. -// -// Solidity: function transferOwnership(address newOwner) returns() -func (_History *HistoryTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { - return _History.contract.Transact(opts, "transferOwnership", newOwner) -} - -// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. -// -// Solidity: function transferOwnership(address newOwner) returns() -func (_History *HistorySession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { - return _History.Contract.TransferOwnership(&_History.TransactOpts, newOwner) -} - -// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. -// -// Solidity: function transferOwnership(address newOwner) returns() -func (_History *HistoryTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { - return _History.Contract.TransferOwnership(&_History.TransactOpts, newOwner) -} - -// HistoryNewClaimToHistoryIterator is returned from FilterNewClaimToHistory and is used to iterate over the raw logs and unpacked data for NewClaimToHistory events raised by the History contract. -type HistoryNewClaimToHistoryIterator struct { - Event *HistoryNewClaimToHistory // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *HistoryNewClaimToHistoryIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(HistoryNewClaimToHistory) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(HistoryNewClaimToHistory) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *HistoryNewClaimToHistoryIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *HistoryNewClaimToHistoryIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// HistoryNewClaimToHistory represents a NewClaimToHistory event raised by the History contract. -type HistoryNewClaimToHistory struct { - Dapp common.Address - Claim HistoryClaim - Raw types.Log // Blockchain specific contextual infos -} - -// FilterNewClaimToHistory is a free log retrieval operation binding the contract event 0xb71880d7a0c514d48c0296b2721b0a4f9641a45117960f2ca86b5b7873c4ab2f. -// -// Solidity: event NewClaimToHistory(address indexed dapp, (bytes32,uint128,uint128) claim) -func (_History *HistoryFilterer) FilterNewClaimToHistory(opts *bind.FilterOpts, dapp []common.Address) (*HistoryNewClaimToHistoryIterator, error) { - - var dappRule []interface{} - for _, dappItem := range dapp { - dappRule = append(dappRule, dappItem) - } - - logs, sub, err := _History.contract.FilterLogs(opts, "NewClaimToHistory", dappRule) - if err != nil { - return nil, err - } - return &HistoryNewClaimToHistoryIterator{contract: _History.contract, event: "NewClaimToHistory", logs: logs, sub: sub}, nil -} - -// WatchNewClaimToHistory is a free log subscription operation binding the contract event 0xb71880d7a0c514d48c0296b2721b0a4f9641a45117960f2ca86b5b7873c4ab2f. -// -// Solidity: event NewClaimToHistory(address indexed dapp, (bytes32,uint128,uint128) claim) -func (_History *HistoryFilterer) WatchNewClaimToHistory(opts *bind.WatchOpts, sink chan<- *HistoryNewClaimToHistory, dapp []common.Address) (event.Subscription, error) { - - var dappRule []interface{} - for _, dappItem := range dapp { - dappRule = append(dappRule, dappItem) - } - - logs, sub, err := _History.contract.WatchLogs(opts, "NewClaimToHistory", dappRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(HistoryNewClaimToHistory) - if err := _History.contract.UnpackLog(event, "NewClaimToHistory", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseNewClaimToHistory is a log parse operation binding the contract event 0xb71880d7a0c514d48c0296b2721b0a4f9641a45117960f2ca86b5b7873c4ab2f. -// -// Solidity: event NewClaimToHistory(address indexed dapp, (bytes32,uint128,uint128) claim) -func (_History *HistoryFilterer) ParseNewClaimToHistory(log types.Log) (*HistoryNewClaimToHistory, error) { - event := new(HistoryNewClaimToHistory) - if err := _History.contract.UnpackLog(event, "NewClaimToHistory", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// HistoryOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the History contract. -type HistoryOwnershipTransferredIterator struct { - Event *HistoryOwnershipTransferred // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *HistoryOwnershipTransferredIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(HistoryOwnershipTransferred) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(HistoryOwnershipTransferred) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *HistoryOwnershipTransferredIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *HistoryOwnershipTransferredIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// HistoryOwnershipTransferred represents a OwnershipTransferred event raised by the History contract. -type HistoryOwnershipTransferred struct { - PreviousOwner common.Address - NewOwner common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. -// -// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) -func (_History *HistoryFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*HistoryOwnershipTransferredIterator, error) { - - var previousOwnerRule []interface{} - for _, previousOwnerItem := range previousOwner { - previousOwnerRule = append(previousOwnerRule, previousOwnerItem) - } - var newOwnerRule []interface{} - for _, newOwnerItem := range newOwner { - newOwnerRule = append(newOwnerRule, newOwnerItem) - } - - logs, sub, err := _History.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) - if err != nil { - return nil, err - } - return &HistoryOwnershipTransferredIterator{contract: _History.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil -} - -// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. -// -// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) -func (_History *HistoryFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *HistoryOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { - - var previousOwnerRule []interface{} - for _, previousOwnerItem := range previousOwner { - previousOwnerRule = append(previousOwnerRule, previousOwnerItem) - } - var newOwnerRule []interface{} - for _, newOwnerItem := range newOwner { - newOwnerRule = append(newOwnerRule, newOwnerItem) - } - - logs, sub, err := _History.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(HistoryOwnershipTransferred) - if err := _History.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. -// -// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) -func (_History *HistoryFilterer) ParseOwnershipTransferred(log types.Log) (*HistoryOwnershipTransferred, error) { - event := new(HistoryOwnershipTransferred) - if err := _History.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} diff --git a/pkg/contracts/iconsensus/iconsensus.go b/pkg/contracts/iconsensus/iconsensus.go new file mode 100644 index 000000000..5919fff1e --- /dev/null +++ b/pkg/contracts/iconsensus/iconsensus.go @@ -0,0 +1,540 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package iconsensus + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// InputRange is an auto generated low-level Go binding around an user-defined struct. +type InputRange struct { + FirstIndex uint64 + LastIndex uint64 +} + +// IConsensusMetaData contains all meta data concerning the IConsensus contract. +var IConsensusMetaData = &bind.MetaData{ + ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"appContract\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"uint64\",\"name\":\"firstIndex\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"lastIndex\",\"type\":\"uint64\"}],\"indexed\":false,\"internalType\":\"structInputRange\",\"name\":\"inputRange\",\"type\":\"tuple\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"epochHash\",\"type\":\"bytes32\"}],\"name\":\"ClaimAcceptance\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"submitter\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"appContract\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"uint64\",\"name\":\"firstIndex\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"lastIndex\",\"type\":\"uint64\"}],\"indexed\":false,\"internalType\":\"structInputRange\",\"name\":\"inputRange\",\"type\":\"tuple\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"epochHash\",\"type\":\"bytes32\"}],\"name\":\"ClaimSubmission\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"appContract\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"uint64\",\"name\":\"firstIndex\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"lastIndex\",\"type\":\"uint64\"}],\"internalType\":\"structInputRange\",\"name\":\"inputRange\",\"type\":\"tuple\"}],\"name\":\"getEpochHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"epochHash\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"appContract\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"uint64\",\"name\":\"firstIndex\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"lastIndex\",\"type\":\"uint64\"}],\"internalType\":\"structInputRange\",\"name\":\"inputRange\",\"type\":\"tuple\"},{\"internalType\":\"bytes32\",\"name\":\"epochHash\",\"type\":\"bytes32\"}],\"name\":\"submitClaim\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +} + +// IConsensusABI is the input ABI used to generate the binding from. +// Deprecated: Use IConsensusMetaData.ABI instead. +var IConsensusABI = IConsensusMetaData.ABI + +// IConsensus is an auto generated Go binding around an Ethereum contract. +type IConsensus struct { + IConsensusCaller // Read-only binding to the contract + IConsensusTransactor // Write-only binding to the contract + IConsensusFilterer // Log filterer for contract events +} + +// IConsensusCaller is an auto generated read-only Go binding around an Ethereum contract. +type IConsensusCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// IConsensusTransactor is an auto generated write-only Go binding around an Ethereum contract. +type IConsensusTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// IConsensusFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type IConsensusFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// IConsensusSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type IConsensusSession struct { + Contract *IConsensus // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// IConsensusCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type IConsensusCallerSession struct { + Contract *IConsensusCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// IConsensusTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type IConsensusTransactorSession struct { + Contract *IConsensusTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// IConsensusRaw is an auto generated low-level Go binding around an Ethereum contract. +type IConsensusRaw struct { + Contract *IConsensus // Generic contract binding to access the raw methods on +} + +// IConsensusCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type IConsensusCallerRaw struct { + Contract *IConsensusCaller // Generic read-only contract binding to access the raw methods on +} + +// IConsensusTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type IConsensusTransactorRaw struct { + Contract *IConsensusTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewIConsensus creates a new instance of IConsensus, bound to a specific deployed contract. +func NewIConsensus(address common.Address, backend bind.ContractBackend) (*IConsensus, error) { + contract, err := bindIConsensus(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &IConsensus{IConsensusCaller: IConsensusCaller{contract: contract}, IConsensusTransactor: IConsensusTransactor{contract: contract}, IConsensusFilterer: IConsensusFilterer{contract: contract}}, nil +} + +// NewIConsensusCaller creates a new read-only instance of IConsensus, bound to a specific deployed contract. +func NewIConsensusCaller(address common.Address, caller bind.ContractCaller) (*IConsensusCaller, error) { + contract, err := bindIConsensus(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &IConsensusCaller{contract: contract}, nil +} + +// NewIConsensusTransactor creates a new write-only instance of IConsensus, bound to a specific deployed contract. +func NewIConsensusTransactor(address common.Address, transactor bind.ContractTransactor) (*IConsensusTransactor, error) { + contract, err := bindIConsensus(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &IConsensusTransactor{contract: contract}, nil +} + +// NewIConsensusFilterer creates a new log filterer instance of IConsensus, bound to a specific deployed contract. +func NewIConsensusFilterer(address common.Address, filterer bind.ContractFilterer) (*IConsensusFilterer, error) { + contract, err := bindIConsensus(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &IConsensusFilterer{contract: contract}, nil +} + +// bindIConsensus binds a generic wrapper to an already deployed contract. +func bindIConsensus(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := IConsensusMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_IConsensus *IConsensusRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _IConsensus.Contract.IConsensusCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_IConsensus *IConsensusRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _IConsensus.Contract.IConsensusTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_IConsensus *IConsensusRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _IConsensus.Contract.IConsensusTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_IConsensus *IConsensusCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _IConsensus.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_IConsensus *IConsensusTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _IConsensus.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_IConsensus *IConsensusTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _IConsensus.Contract.contract.Transact(opts, method, params...) +} + +// GetEpochHash is a free data retrieval call binding the contract method 0xc1f59afc. +// +// Solidity: function getEpochHash(address appContract, (uint64,uint64) inputRange) view returns(bytes32 epochHash) +func (_IConsensus *IConsensusCaller) GetEpochHash(opts *bind.CallOpts, appContract common.Address, inputRange InputRange) ([32]byte, error) { + var out []interface{} + err := _IConsensus.contract.Call(opts, &out, "getEpochHash", appContract, inputRange) + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// GetEpochHash is a free data retrieval call binding the contract method 0xc1f59afc. +// +// Solidity: function getEpochHash(address appContract, (uint64,uint64) inputRange) view returns(bytes32 epochHash) +func (_IConsensus *IConsensusSession) GetEpochHash(appContract common.Address, inputRange InputRange) ([32]byte, error) { + return _IConsensus.Contract.GetEpochHash(&_IConsensus.CallOpts, appContract, inputRange) +} + +// GetEpochHash is a free data retrieval call binding the contract method 0xc1f59afc. +// +// Solidity: function getEpochHash(address appContract, (uint64,uint64) inputRange) view returns(bytes32 epochHash) +func (_IConsensus *IConsensusCallerSession) GetEpochHash(appContract common.Address, inputRange InputRange) ([32]byte, error) { + return _IConsensus.Contract.GetEpochHash(&_IConsensus.CallOpts, appContract, inputRange) +} + +// SubmitClaim is a paid mutator transaction binding the contract method 0x866b85fa. +// +// Solidity: function submitClaim(address appContract, (uint64,uint64) inputRange, bytes32 epochHash) returns() +func (_IConsensus *IConsensusTransactor) SubmitClaim(opts *bind.TransactOpts, appContract common.Address, inputRange InputRange, epochHash [32]byte) (*types.Transaction, error) { + return _IConsensus.contract.Transact(opts, "submitClaim", appContract, inputRange, epochHash) +} + +// SubmitClaim is a paid mutator transaction binding the contract method 0x866b85fa. +// +// Solidity: function submitClaim(address appContract, (uint64,uint64) inputRange, bytes32 epochHash) returns() +func (_IConsensus *IConsensusSession) SubmitClaim(appContract common.Address, inputRange InputRange, epochHash [32]byte) (*types.Transaction, error) { + return _IConsensus.Contract.SubmitClaim(&_IConsensus.TransactOpts, appContract, inputRange, epochHash) +} + +// SubmitClaim is a paid mutator transaction binding the contract method 0x866b85fa. +// +// Solidity: function submitClaim(address appContract, (uint64,uint64) inputRange, bytes32 epochHash) returns() +func (_IConsensus *IConsensusTransactorSession) SubmitClaim(appContract common.Address, inputRange InputRange, epochHash [32]byte) (*types.Transaction, error) { + return _IConsensus.Contract.SubmitClaim(&_IConsensus.TransactOpts, appContract, inputRange, epochHash) +} + +// IConsensusClaimAcceptanceIterator is returned from FilterClaimAcceptance and is used to iterate over the raw logs and unpacked data for ClaimAcceptance events raised by the IConsensus contract. +type IConsensusClaimAcceptanceIterator struct { + Event *IConsensusClaimAcceptance // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *IConsensusClaimAcceptanceIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(IConsensusClaimAcceptance) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(IConsensusClaimAcceptance) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *IConsensusClaimAcceptanceIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *IConsensusClaimAcceptanceIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// IConsensusClaimAcceptance represents a ClaimAcceptance event raised by the IConsensus contract. +type IConsensusClaimAcceptance struct { + AppContract common.Address + InputRange InputRange + EpochHash [32]byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterClaimAcceptance is a free log retrieval operation binding the contract event 0x4e068a6b8ed35e6ee03244135874f91ccebb5cd1f3a258a6dc2ad0ebd2988476. +// +// Solidity: event ClaimAcceptance(address indexed appContract, (uint64,uint64) inputRange, bytes32 epochHash) +func (_IConsensus *IConsensusFilterer) FilterClaimAcceptance(opts *bind.FilterOpts, appContract []common.Address) (*IConsensusClaimAcceptanceIterator, error) { + + var appContractRule []interface{} + for _, appContractItem := range appContract { + appContractRule = append(appContractRule, appContractItem) + } + + logs, sub, err := _IConsensus.contract.FilterLogs(opts, "ClaimAcceptance", appContractRule) + if err != nil { + return nil, err + } + return &IConsensusClaimAcceptanceIterator{contract: _IConsensus.contract, event: "ClaimAcceptance", logs: logs, sub: sub}, nil +} + +// WatchClaimAcceptance is a free log subscription operation binding the contract event 0x4e068a6b8ed35e6ee03244135874f91ccebb5cd1f3a258a6dc2ad0ebd2988476. +// +// Solidity: event ClaimAcceptance(address indexed appContract, (uint64,uint64) inputRange, bytes32 epochHash) +func (_IConsensus *IConsensusFilterer) WatchClaimAcceptance(opts *bind.WatchOpts, sink chan<- *IConsensusClaimAcceptance, appContract []common.Address) (event.Subscription, error) { + + var appContractRule []interface{} + for _, appContractItem := range appContract { + appContractRule = append(appContractRule, appContractItem) + } + + logs, sub, err := _IConsensus.contract.WatchLogs(opts, "ClaimAcceptance", appContractRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(IConsensusClaimAcceptance) + if err := _IConsensus.contract.UnpackLog(event, "ClaimAcceptance", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseClaimAcceptance is a log parse operation binding the contract event 0x4e068a6b8ed35e6ee03244135874f91ccebb5cd1f3a258a6dc2ad0ebd2988476. +// +// Solidity: event ClaimAcceptance(address indexed appContract, (uint64,uint64) inputRange, bytes32 epochHash) +func (_IConsensus *IConsensusFilterer) ParseClaimAcceptance(log types.Log) (*IConsensusClaimAcceptance, error) { + event := new(IConsensusClaimAcceptance) + if err := _IConsensus.contract.UnpackLog(event, "ClaimAcceptance", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// IConsensusClaimSubmissionIterator is returned from FilterClaimSubmission and is used to iterate over the raw logs and unpacked data for ClaimSubmission events raised by the IConsensus contract. +type IConsensusClaimSubmissionIterator struct { + Event *IConsensusClaimSubmission // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *IConsensusClaimSubmissionIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(IConsensusClaimSubmission) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(IConsensusClaimSubmission) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *IConsensusClaimSubmissionIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *IConsensusClaimSubmissionIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// IConsensusClaimSubmission represents a ClaimSubmission event raised by the IConsensus contract. +type IConsensusClaimSubmission struct { + Submitter common.Address + AppContract common.Address + InputRange InputRange + EpochHash [32]byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterClaimSubmission is a free log retrieval operation binding the contract event 0x940326476a755934b6ae9d2b36ffcf1f447c3a8223f6d9f8a796b54fbfcce582. +// +// Solidity: event ClaimSubmission(address indexed submitter, address indexed appContract, (uint64,uint64) inputRange, bytes32 epochHash) +func (_IConsensus *IConsensusFilterer) FilterClaimSubmission(opts *bind.FilterOpts, submitter []common.Address, appContract []common.Address) (*IConsensusClaimSubmissionIterator, error) { + + var submitterRule []interface{} + for _, submitterItem := range submitter { + submitterRule = append(submitterRule, submitterItem) + } + var appContractRule []interface{} + for _, appContractItem := range appContract { + appContractRule = append(appContractRule, appContractItem) + } + + logs, sub, err := _IConsensus.contract.FilterLogs(opts, "ClaimSubmission", submitterRule, appContractRule) + if err != nil { + return nil, err + } + return &IConsensusClaimSubmissionIterator{contract: _IConsensus.contract, event: "ClaimSubmission", logs: logs, sub: sub}, nil +} + +// WatchClaimSubmission is a free log subscription operation binding the contract event 0x940326476a755934b6ae9d2b36ffcf1f447c3a8223f6d9f8a796b54fbfcce582. +// +// Solidity: event ClaimSubmission(address indexed submitter, address indexed appContract, (uint64,uint64) inputRange, bytes32 epochHash) +func (_IConsensus *IConsensusFilterer) WatchClaimSubmission(opts *bind.WatchOpts, sink chan<- *IConsensusClaimSubmission, submitter []common.Address, appContract []common.Address) (event.Subscription, error) { + + var submitterRule []interface{} + for _, submitterItem := range submitter { + submitterRule = append(submitterRule, submitterItem) + } + var appContractRule []interface{} + for _, appContractItem := range appContract { + appContractRule = append(appContractRule, appContractItem) + } + + logs, sub, err := _IConsensus.contract.WatchLogs(opts, "ClaimSubmission", submitterRule, appContractRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(IConsensusClaimSubmission) + if err := _IConsensus.contract.UnpackLog(event, "ClaimSubmission", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseClaimSubmission is a log parse operation binding the contract event 0x940326476a755934b6ae9d2b36ffcf1f447c3a8223f6d9f8a796b54fbfcce582. +// +// Solidity: event ClaimSubmission(address indexed submitter, address indexed appContract, (uint64,uint64) inputRange, bytes32 epochHash) +func (_IConsensus *IConsensusFilterer) ParseClaimSubmission(log types.Log) (*IConsensusClaimSubmission, error) { + event := new(IConsensusClaimSubmission) + if err := _IConsensus.contract.UnpackLog(event, "ClaimSubmission", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/pkg/contracts/input_box.go b/pkg/contracts/inputbox/inputbox.go similarity index 71% rename from pkg/contracts/input_box.go rename to pkg/contracts/inputbox/inputbox.go index 494c9ed40..a9e0620b8 100644 --- a/pkg/contracts/input_box.go +++ b/pkg/contracts/inputbox/inputbox.go @@ -1,7 +1,7 @@ // Code generated - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package contracts +package inputbox import ( "errors" @@ -31,7 +31,7 @@ var ( // InputBoxMetaData contains all meta data concerning the InputBox contract. var InputBoxMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[],\"name\":\"InputSizeExceedsLimit\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"dapp\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"inputIndex\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"input\",\"type\":\"bytes\"}],\"name\":\"InputAdded\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_dapp\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_input\",\"type\":\"bytes\"}],\"name\":\"addInput\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_dapp\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"getInputHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_dapp\",\"type\":\"address\"}],\"name\":\"getNumberOfInputs\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"appContract\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"inputLength\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxInputLength\",\"type\":\"uint256\"}],\"name\":\"InputTooLarge\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"appContract\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"input\",\"type\":\"bytes\"}],\"name\":\"InputAdded\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"appContract\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"payload\",\"type\":\"bytes\"}],\"name\":\"addInput\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"appContract\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getInputHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"appContract\",\"type\":\"address\"}],\"name\":\"getNumberOfInputs\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", } // InputBoxABI is the input ABI used to generate the binding from. @@ -182,10 +182,10 @@ func (_InputBox *InputBoxTransactorRaw) Transact(opts *bind.TransactOpts, method // GetInputHash is a free data retrieval call binding the contract method 0x677087c9. // -// Solidity: function getInputHash(address _dapp, uint256 _index) view returns(bytes32) -func (_InputBox *InputBoxCaller) GetInputHash(opts *bind.CallOpts, _dapp common.Address, _index *big.Int) ([32]byte, error) { +// Solidity: function getInputHash(address appContract, uint256 index) view returns(bytes32) +func (_InputBox *InputBoxCaller) GetInputHash(opts *bind.CallOpts, appContract common.Address, index *big.Int) ([32]byte, error) { var out []interface{} - err := _InputBox.contract.Call(opts, &out, "getInputHash", _dapp, _index) + err := _InputBox.contract.Call(opts, &out, "getInputHash", appContract, index) if err != nil { return *new([32]byte), err @@ -199,24 +199,24 @@ func (_InputBox *InputBoxCaller) GetInputHash(opts *bind.CallOpts, _dapp common. // GetInputHash is a free data retrieval call binding the contract method 0x677087c9. // -// Solidity: function getInputHash(address _dapp, uint256 _index) view returns(bytes32) -func (_InputBox *InputBoxSession) GetInputHash(_dapp common.Address, _index *big.Int) ([32]byte, error) { - return _InputBox.Contract.GetInputHash(&_InputBox.CallOpts, _dapp, _index) +// Solidity: function getInputHash(address appContract, uint256 index) view returns(bytes32) +func (_InputBox *InputBoxSession) GetInputHash(appContract common.Address, index *big.Int) ([32]byte, error) { + return _InputBox.Contract.GetInputHash(&_InputBox.CallOpts, appContract, index) } // GetInputHash is a free data retrieval call binding the contract method 0x677087c9. // -// Solidity: function getInputHash(address _dapp, uint256 _index) view returns(bytes32) -func (_InputBox *InputBoxCallerSession) GetInputHash(_dapp common.Address, _index *big.Int) ([32]byte, error) { - return _InputBox.Contract.GetInputHash(&_InputBox.CallOpts, _dapp, _index) +// Solidity: function getInputHash(address appContract, uint256 index) view returns(bytes32) +func (_InputBox *InputBoxCallerSession) GetInputHash(appContract common.Address, index *big.Int) ([32]byte, error) { + return _InputBox.Contract.GetInputHash(&_InputBox.CallOpts, appContract, index) } // GetNumberOfInputs is a free data retrieval call binding the contract method 0x61a93c87. // -// Solidity: function getNumberOfInputs(address _dapp) view returns(uint256) -func (_InputBox *InputBoxCaller) GetNumberOfInputs(opts *bind.CallOpts, _dapp common.Address) (*big.Int, error) { +// Solidity: function getNumberOfInputs(address appContract) view returns(uint256) +func (_InputBox *InputBoxCaller) GetNumberOfInputs(opts *bind.CallOpts, appContract common.Address) (*big.Int, error) { var out []interface{} - err := _InputBox.contract.Call(opts, &out, "getNumberOfInputs", _dapp) + err := _InputBox.contract.Call(opts, &out, "getNumberOfInputs", appContract) if err != nil { return *new(*big.Int), err @@ -230,37 +230,37 @@ func (_InputBox *InputBoxCaller) GetNumberOfInputs(opts *bind.CallOpts, _dapp co // GetNumberOfInputs is a free data retrieval call binding the contract method 0x61a93c87. // -// Solidity: function getNumberOfInputs(address _dapp) view returns(uint256) -func (_InputBox *InputBoxSession) GetNumberOfInputs(_dapp common.Address) (*big.Int, error) { - return _InputBox.Contract.GetNumberOfInputs(&_InputBox.CallOpts, _dapp) +// Solidity: function getNumberOfInputs(address appContract) view returns(uint256) +func (_InputBox *InputBoxSession) GetNumberOfInputs(appContract common.Address) (*big.Int, error) { + return _InputBox.Contract.GetNumberOfInputs(&_InputBox.CallOpts, appContract) } // GetNumberOfInputs is a free data retrieval call binding the contract method 0x61a93c87. // -// Solidity: function getNumberOfInputs(address _dapp) view returns(uint256) -func (_InputBox *InputBoxCallerSession) GetNumberOfInputs(_dapp common.Address) (*big.Int, error) { - return _InputBox.Contract.GetNumberOfInputs(&_InputBox.CallOpts, _dapp) +// Solidity: function getNumberOfInputs(address appContract) view returns(uint256) +func (_InputBox *InputBoxCallerSession) GetNumberOfInputs(appContract common.Address) (*big.Int, error) { + return _InputBox.Contract.GetNumberOfInputs(&_InputBox.CallOpts, appContract) } // AddInput is a paid mutator transaction binding the contract method 0x1789cd63. // -// Solidity: function addInput(address _dapp, bytes _input) returns(bytes32) -func (_InputBox *InputBoxTransactor) AddInput(opts *bind.TransactOpts, _dapp common.Address, _input []byte) (*types.Transaction, error) { - return _InputBox.contract.Transact(opts, "addInput", _dapp, _input) +// Solidity: function addInput(address appContract, bytes payload) returns(bytes32) +func (_InputBox *InputBoxTransactor) AddInput(opts *bind.TransactOpts, appContract common.Address, payload []byte) (*types.Transaction, error) { + return _InputBox.contract.Transact(opts, "addInput", appContract, payload) } // AddInput is a paid mutator transaction binding the contract method 0x1789cd63. // -// Solidity: function addInput(address _dapp, bytes _input) returns(bytes32) -func (_InputBox *InputBoxSession) AddInput(_dapp common.Address, _input []byte) (*types.Transaction, error) { - return _InputBox.Contract.AddInput(&_InputBox.TransactOpts, _dapp, _input) +// Solidity: function addInput(address appContract, bytes payload) returns(bytes32) +func (_InputBox *InputBoxSession) AddInput(appContract common.Address, payload []byte) (*types.Transaction, error) { + return _InputBox.Contract.AddInput(&_InputBox.TransactOpts, appContract, payload) } // AddInput is a paid mutator transaction binding the contract method 0x1789cd63. // -// Solidity: function addInput(address _dapp, bytes _input) returns(bytes32) -func (_InputBox *InputBoxTransactorSession) AddInput(_dapp common.Address, _input []byte) (*types.Transaction, error) { - return _InputBox.Contract.AddInput(&_InputBox.TransactOpts, _dapp, _input) +// Solidity: function addInput(address appContract, bytes payload) returns(bytes32) +func (_InputBox *InputBoxTransactorSession) AddInput(appContract common.Address, payload []byte) (*types.Transaction, error) { + return _InputBox.Contract.AddInput(&_InputBox.TransactOpts, appContract, payload) } // InputBoxInputAddedIterator is returned from FilterInputAdded and is used to iterate over the raw logs and unpacked data for InputAdded events raised by the InputBox contract. @@ -332,49 +332,48 @@ func (it *InputBoxInputAddedIterator) Close() error { // InputBoxInputAdded represents a InputAdded event raised by the InputBox contract. type InputBoxInputAdded struct { - Dapp common.Address - InputIndex *big.Int - Sender common.Address - Input []byte - Raw types.Log // Blockchain specific contextual infos + AppContract common.Address + Index *big.Int + Input []byte + Raw types.Log // Blockchain specific contextual infos } -// FilterInputAdded is a free log retrieval operation binding the contract event 0x6aaa400068bf4ca337265e2a1e1e841f66b8597fd5b452fdc52a44bed28a0784. +// FilterInputAdded is a free log retrieval operation binding the contract event 0xc05d337121a6e8605c6ec0b72aa29c4210ffe6e5b9cefdd6a7058188a8f66f98. // -// Solidity: event InputAdded(address indexed dapp, uint256 indexed inputIndex, address sender, bytes input) -func (_InputBox *InputBoxFilterer) FilterInputAdded(opts *bind.FilterOpts, dapp []common.Address, inputIndex []*big.Int) (*InputBoxInputAddedIterator, error) { +// Solidity: event InputAdded(address indexed appContract, uint256 indexed index, bytes input) +func (_InputBox *InputBoxFilterer) FilterInputAdded(opts *bind.FilterOpts, appContract []common.Address, index []*big.Int) (*InputBoxInputAddedIterator, error) { - var dappRule []interface{} - for _, dappItem := range dapp { - dappRule = append(dappRule, dappItem) + var appContractRule []interface{} + for _, appContractItem := range appContract { + appContractRule = append(appContractRule, appContractItem) } - var inputIndexRule []interface{} - for _, inputIndexItem := range inputIndex { - inputIndexRule = append(inputIndexRule, inputIndexItem) + var indexRule []interface{} + for _, indexItem := range index { + indexRule = append(indexRule, indexItem) } - logs, sub, err := _InputBox.contract.FilterLogs(opts, "InputAdded", dappRule, inputIndexRule) + logs, sub, err := _InputBox.contract.FilterLogs(opts, "InputAdded", appContractRule, indexRule) if err != nil { return nil, err } return &InputBoxInputAddedIterator{contract: _InputBox.contract, event: "InputAdded", logs: logs, sub: sub}, nil } -// WatchInputAdded is a free log subscription operation binding the contract event 0x6aaa400068bf4ca337265e2a1e1e841f66b8597fd5b452fdc52a44bed28a0784. +// WatchInputAdded is a free log subscription operation binding the contract event 0xc05d337121a6e8605c6ec0b72aa29c4210ffe6e5b9cefdd6a7058188a8f66f98. // -// Solidity: event InputAdded(address indexed dapp, uint256 indexed inputIndex, address sender, bytes input) -func (_InputBox *InputBoxFilterer) WatchInputAdded(opts *bind.WatchOpts, sink chan<- *InputBoxInputAdded, dapp []common.Address, inputIndex []*big.Int) (event.Subscription, error) { +// Solidity: event InputAdded(address indexed appContract, uint256 indexed index, bytes input) +func (_InputBox *InputBoxFilterer) WatchInputAdded(opts *bind.WatchOpts, sink chan<- *InputBoxInputAdded, appContract []common.Address, index []*big.Int) (event.Subscription, error) { - var dappRule []interface{} - for _, dappItem := range dapp { - dappRule = append(dappRule, dappItem) + var appContractRule []interface{} + for _, appContractItem := range appContract { + appContractRule = append(appContractRule, appContractItem) } - var inputIndexRule []interface{} - for _, inputIndexItem := range inputIndex { - inputIndexRule = append(inputIndexRule, inputIndexItem) + var indexRule []interface{} + for _, indexItem := range index { + indexRule = append(indexRule, indexItem) } - logs, sub, err := _InputBox.contract.WatchLogs(opts, "InputAdded", dappRule, inputIndexRule) + logs, sub, err := _InputBox.contract.WatchLogs(opts, "InputAdded", appContractRule, indexRule) if err != nil { return nil, err } @@ -406,9 +405,9 @@ func (_InputBox *InputBoxFilterer) WatchInputAdded(opts *bind.WatchOpts, sink ch }), nil } -// ParseInputAdded is a log parse operation binding the contract event 0x6aaa400068bf4ca337265e2a1e1e841f66b8597fd5b452fdc52a44bed28a0784. +// ParseInputAdded is a log parse operation binding the contract event 0xc05d337121a6e8605c6ec0b72aa29c4210ffe6e5b9cefdd6a7058188a8f66f98. // -// Solidity: event InputAdded(address indexed dapp, uint256 indexed inputIndex, address sender, bytes input) +// Solidity: event InputAdded(address indexed appContract, uint256 indexed index, bytes input) func (_InputBox *InputBoxFilterer) ParseInputAdded(log types.Log) (*InputBoxInputAdded, error) { event := new(InputBoxInputAdded) if err := _InputBox.contract.UnpackLog(event, "InputAdded", log); err != nil { diff --git a/pkg/contracts/inputs/inputs.go b/pkg/contracts/inputs/inputs.go new file mode 100644 index 000000000..0e143e126 --- /dev/null +++ b/pkg/contracts/inputs/inputs.go @@ -0,0 +1,202 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package inputs + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// InputsMetaData contains all meta data concerning the Inputs contract. +var InputsMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"appContract\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"msgSender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"blockTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"payload\",\"type\":\"bytes\"}],\"name\":\"EvmAdvance\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +} + +// InputsABI is the input ABI used to generate the binding from. +// Deprecated: Use InputsMetaData.ABI instead. +var InputsABI = InputsMetaData.ABI + +// Inputs is an auto generated Go binding around an Ethereum contract. +type Inputs struct { + InputsCaller // Read-only binding to the contract + InputsTransactor // Write-only binding to the contract + InputsFilterer // Log filterer for contract events +} + +// InputsCaller is an auto generated read-only Go binding around an Ethereum contract. +type InputsCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// InputsTransactor is an auto generated write-only Go binding around an Ethereum contract. +type InputsTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// InputsFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type InputsFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// InputsSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type InputsSession struct { + Contract *Inputs // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// InputsCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type InputsCallerSession struct { + Contract *InputsCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// InputsTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type InputsTransactorSession struct { + Contract *InputsTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// InputsRaw is an auto generated low-level Go binding around an Ethereum contract. +type InputsRaw struct { + Contract *Inputs // Generic contract binding to access the raw methods on +} + +// InputsCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type InputsCallerRaw struct { + Contract *InputsCaller // Generic read-only contract binding to access the raw methods on +} + +// InputsTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type InputsTransactorRaw struct { + Contract *InputsTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewInputs creates a new instance of Inputs, bound to a specific deployed contract. +func NewInputs(address common.Address, backend bind.ContractBackend) (*Inputs, error) { + contract, err := bindInputs(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &Inputs{InputsCaller: InputsCaller{contract: contract}, InputsTransactor: InputsTransactor{contract: contract}, InputsFilterer: InputsFilterer{contract: contract}}, nil +} + +// NewInputsCaller creates a new read-only instance of Inputs, bound to a specific deployed contract. +func NewInputsCaller(address common.Address, caller bind.ContractCaller) (*InputsCaller, error) { + contract, err := bindInputs(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &InputsCaller{contract: contract}, nil +} + +// NewInputsTransactor creates a new write-only instance of Inputs, bound to a specific deployed contract. +func NewInputsTransactor(address common.Address, transactor bind.ContractTransactor) (*InputsTransactor, error) { + contract, err := bindInputs(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &InputsTransactor{contract: contract}, nil +} + +// NewInputsFilterer creates a new log filterer instance of Inputs, bound to a specific deployed contract. +func NewInputsFilterer(address common.Address, filterer bind.ContractFilterer) (*InputsFilterer, error) { + contract, err := bindInputs(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &InputsFilterer{contract: contract}, nil +} + +// bindInputs binds a generic wrapper to an already deployed contract. +func bindInputs(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := InputsMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Inputs *InputsRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Inputs.Contract.InputsCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Inputs *InputsRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Inputs.Contract.InputsTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Inputs *InputsRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Inputs.Contract.InputsTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Inputs *InputsCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Inputs.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Inputs *InputsTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Inputs.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Inputs *InputsTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Inputs.Contract.contract.Transact(opts, method, params...) +} + +// EvmAdvance is a paid mutator transaction binding the contract method 0xcc7dee1f. +// +// Solidity: function EvmAdvance(uint256 chainId, address appContract, address msgSender, uint256 blockNumber, uint256 blockTimestamp, uint256 index, bytes payload) returns() +func (_Inputs *InputsTransactor) EvmAdvance(opts *bind.TransactOpts, chainId *big.Int, appContract common.Address, msgSender common.Address, blockNumber *big.Int, blockTimestamp *big.Int, index *big.Int, payload []byte) (*types.Transaction, error) { + return _Inputs.contract.Transact(opts, "EvmAdvance", chainId, appContract, msgSender, blockNumber, blockTimestamp, index, payload) +} + +// EvmAdvance is a paid mutator transaction binding the contract method 0xcc7dee1f. +// +// Solidity: function EvmAdvance(uint256 chainId, address appContract, address msgSender, uint256 blockNumber, uint256 blockTimestamp, uint256 index, bytes payload) returns() +func (_Inputs *InputsSession) EvmAdvance(chainId *big.Int, appContract common.Address, msgSender common.Address, blockNumber *big.Int, blockTimestamp *big.Int, index *big.Int, payload []byte) (*types.Transaction, error) { + return _Inputs.Contract.EvmAdvance(&_Inputs.TransactOpts, chainId, appContract, msgSender, blockNumber, blockTimestamp, index, payload) +} + +// EvmAdvance is a paid mutator transaction binding the contract method 0xcc7dee1f. +// +// Solidity: function EvmAdvance(uint256 chainId, address appContract, address msgSender, uint256 blockNumber, uint256 blockTimestamp, uint256 index, bytes payload) returns() +func (_Inputs *InputsTransactorSession) EvmAdvance(chainId *big.Int, appContract common.Address, msgSender common.Address, blockNumber *big.Int, blockTimestamp *big.Int, index *big.Int, payload []byte) (*types.Transaction, error) { + return _Inputs.Contract.EvmAdvance(&_Inputs.TransactOpts, chainId, appContract, msgSender, blockNumber, blockTimestamp, index, payload) +} diff --git a/pkg/contracts/outputs/outputs.go b/pkg/contracts/outputs/outputs.go new file mode 100644 index 000000000..00dc229f2 --- /dev/null +++ b/pkg/contracts/outputs/outputs.go @@ -0,0 +1,223 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package outputs + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// OutputsMetaData contains all meta data concerning the Outputs contract. +var OutputsMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"payload\",\"type\":\"bytes\"}],\"name\":\"Notice\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"destination\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"payload\",\"type\":\"bytes\"}],\"name\":\"Voucher\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +} + +// OutputsABI is the input ABI used to generate the binding from. +// Deprecated: Use OutputsMetaData.ABI instead. +var OutputsABI = OutputsMetaData.ABI + +// Outputs is an auto generated Go binding around an Ethereum contract. +type Outputs struct { + OutputsCaller // Read-only binding to the contract + OutputsTransactor // Write-only binding to the contract + OutputsFilterer // Log filterer for contract events +} + +// OutputsCaller is an auto generated read-only Go binding around an Ethereum contract. +type OutputsCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// OutputsTransactor is an auto generated write-only Go binding around an Ethereum contract. +type OutputsTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// OutputsFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type OutputsFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// OutputsSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type OutputsSession struct { + Contract *Outputs // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// OutputsCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type OutputsCallerSession struct { + Contract *OutputsCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// OutputsTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type OutputsTransactorSession struct { + Contract *OutputsTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// OutputsRaw is an auto generated low-level Go binding around an Ethereum contract. +type OutputsRaw struct { + Contract *Outputs // Generic contract binding to access the raw methods on +} + +// OutputsCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type OutputsCallerRaw struct { + Contract *OutputsCaller // Generic read-only contract binding to access the raw methods on +} + +// OutputsTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type OutputsTransactorRaw struct { + Contract *OutputsTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewOutputs creates a new instance of Outputs, bound to a specific deployed contract. +func NewOutputs(address common.Address, backend bind.ContractBackend) (*Outputs, error) { + contract, err := bindOutputs(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &Outputs{OutputsCaller: OutputsCaller{contract: contract}, OutputsTransactor: OutputsTransactor{contract: contract}, OutputsFilterer: OutputsFilterer{contract: contract}}, nil +} + +// NewOutputsCaller creates a new read-only instance of Outputs, bound to a specific deployed contract. +func NewOutputsCaller(address common.Address, caller bind.ContractCaller) (*OutputsCaller, error) { + contract, err := bindOutputs(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &OutputsCaller{contract: contract}, nil +} + +// NewOutputsTransactor creates a new write-only instance of Outputs, bound to a specific deployed contract. +func NewOutputsTransactor(address common.Address, transactor bind.ContractTransactor) (*OutputsTransactor, error) { + contract, err := bindOutputs(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &OutputsTransactor{contract: contract}, nil +} + +// NewOutputsFilterer creates a new log filterer instance of Outputs, bound to a specific deployed contract. +func NewOutputsFilterer(address common.Address, filterer bind.ContractFilterer) (*OutputsFilterer, error) { + contract, err := bindOutputs(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &OutputsFilterer{contract: contract}, nil +} + +// bindOutputs binds a generic wrapper to an already deployed contract. +func bindOutputs(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := OutputsMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Outputs *OutputsRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Outputs.Contract.OutputsCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Outputs *OutputsRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Outputs.Contract.OutputsTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Outputs *OutputsRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Outputs.Contract.OutputsTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Outputs *OutputsCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Outputs.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Outputs *OutputsTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Outputs.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Outputs *OutputsTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Outputs.Contract.contract.Transact(opts, method, params...) +} + +// Notice is a paid mutator transaction binding the contract method 0xc258d6e5. +// +// Solidity: function Notice(bytes payload) returns() +func (_Outputs *OutputsTransactor) Notice(opts *bind.TransactOpts, payload []byte) (*types.Transaction, error) { + return _Outputs.contract.Transact(opts, "Notice", payload) +} + +// Notice is a paid mutator transaction binding the contract method 0xc258d6e5. +// +// Solidity: function Notice(bytes payload) returns() +func (_Outputs *OutputsSession) Notice(payload []byte) (*types.Transaction, error) { + return _Outputs.Contract.Notice(&_Outputs.TransactOpts, payload) +} + +// Notice is a paid mutator transaction binding the contract method 0xc258d6e5. +// +// Solidity: function Notice(bytes payload) returns() +func (_Outputs *OutputsTransactorSession) Notice(payload []byte) (*types.Transaction, error) { + return _Outputs.Contract.Notice(&_Outputs.TransactOpts, payload) +} + +// Voucher is a paid mutator transaction binding the contract method 0x237a816f. +// +// Solidity: function Voucher(address destination, uint256 value, bytes payload) returns() +func (_Outputs *OutputsTransactor) Voucher(opts *bind.TransactOpts, destination common.Address, value *big.Int, payload []byte) (*types.Transaction, error) { + return _Outputs.contract.Transact(opts, "Voucher", destination, value, payload) +} + +// Voucher is a paid mutator transaction binding the contract method 0x237a816f. +// +// Solidity: function Voucher(address destination, uint256 value, bytes payload) returns() +func (_Outputs *OutputsSession) Voucher(destination common.Address, value *big.Int, payload []byte) (*types.Transaction, error) { + return _Outputs.Contract.Voucher(&_Outputs.TransactOpts, destination, value, payload) +} + +// Voucher is a paid mutator transaction binding the contract method 0x237a816f. +// +// Solidity: function Voucher(address destination, uint256 value, bytes payload) returns() +func (_Outputs *OutputsTransactorSession) Voucher(destination common.Address, value *big.Int, payload []byte) (*types.Transaction, error) { + return _Outputs.Contract.Voucher(&_Outputs.TransactOpts, destination, value, payload) +} diff --git a/pkg/ethutil/ethutil.go b/pkg/ethutil/ethutil.go index 89e884c1e..1ec16f1a1 100644 --- a/pkg/ethutil/ethutil.go +++ b/pkg/ethutil/ethutil.go @@ -11,7 +11,8 @@ import ( "math/big" "github.com/cartesi/rollups-node/pkg/addresses" - "github.com/cartesi/rollups-node/pkg/contracts" + "github.com/cartesi/rollups-node/pkg/contracts/application" + "github.com/cartesi/rollups-node/pkg/contracts/inputbox" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" @@ -45,14 +46,14 @@ func AddInput( signer Signer, input []byte, ) (int, error) { - inputBox, err := contracts.NewInputBox(book.InputBox, client) + inputBox, err := inputbox.NewInputBox(book.InputBox, client) if err != nil { return 0, fmt.Errorf("failed to connect to InputBox contract: %v", err) } receipt, err := sendTransaction( ctx, client, signer, big.NewInt(0), GasLimit, func(txOpts *bind.TransactOpts) (*types.Transaction, error) { - return inputBox.AddInput(txOpts, book.CartesiDApp, input) + return inputBox.AddInput(txOpts, book.Application, input) }, ) if err != nil { @@ -94,7 +95,7 @@ func getInputIndex( ctx context.Context, client *ethclient.Client, book *addresses.Book, - inputBox *contracts.InputBox, + inputBox *inputbox.InputBox, receipt *types.Receipt, ) (int, error) { for _, log := range receipt.Logs { @@ -106,7 +107,7 @@ func getInputIndex( return 0, fmt.Errorf("failed to parse input added event: %v", err) } // We assume that int will fit all dapp inputs - inputIndex := int(inputAdded.InputIndex.Int64()) + inputIndex := int(inputAdded.Index.Int64()) return inputIndex, nil } return 0, fmt.Errorf("input index not found") @@ -118,14 +119,14 @@ func GetInputFromInputBox( client *ethclient.Client, book *addresses.Book, inputIndex int, -) (*contracts.InputBoxInputAdded, error) { - inputBox, err := contracts.NewInputBox(book.InputBox, client) +) (*inputbox.InputBoxInputAdded, error) { + inputBox, err := inputbox.NewInputBox(book.InputBox, client) if err != nil { return nil, fmt.Errorf("failed to connect to InputBox contract: %v", err) } it, err := inputBox.FilterInputAdded( nil, - []common.Address{book.CartesiDApp}, + []common.Address{book.Application}, []*big.Int{big.NewInt(int64(inputIndex))}, ) if err != nil { @@ -140,47 +141,38 @@ func GetInputFromInputBox( // ValidateNotice validates the given notice for the specified Dapp. // It returns nil if the notice is valid and an execution-reverted error otherwise. -func ValidateNotice( +func ValidateOutput( ctx context.Context, client *ethclient.Client, book *addresses.Book, - notice []byte, - proof *contracts.Proof, + output []byte, + proof *application.OutputValidityProof, ) error { - - dapp, err := contracts.NewCartesiDApp(book.CartesiDApp, client) + app, err := application.NewApplication(book.Application, client) if err != nil { return fmt.Errorf("failed to connect to CartesiDapp contract: %v", err) } - - response, err := dapp.ValidateNotice(&bind.CallOpts{Context: ctx}, notice, *proof) - _ = response - if err != nil { - return err - } - - return nil + return app.ValidateOutput(&bind.CallOpts{Context: ctx}, output, *proof) } // Executes a voucher given its payload, destination and proof. // This function waits until the transaction is added to a block and returns the transaction hash. -func ExecuteVoucher( +func ExecuteOutput( ctx context.Context, client *ethclient.Client, book *addresses.Book, signer Signer, - voucher []byte, - destination *common.Address, - proof *contracts.Proof, + output []byte, + proof *application.OutputValidityProof, ) (*common.Hash, error) { - dapp, err := contracts.NewCartesiDApp(book.CartesiDApp, client) + app, err := application.NewApplication(book.Application, client) if err != nil { return nil, fmt.Errorf("failed to connect to CartesiDapp contract: %v", err) } receipt, err := sendTransaction( ctx, client, signer, big.NewInt(0), GasLimit, func(txOpts *bind.TransactOpts) (*types.Transaction, error) { - return dapp.ExecuteVoucher(txOpts, *destination, voucher, *proof) + return app.ExecuteOutput(txOpts, output, *proof) }, ) if err != nil { diff --git a/pkg/ethutil/ethutil_test.go b/pkg/ethutil/ethutil_test.go index 34a3d154d..f06a62b3f 100644 --- a/pkg/ethutil/ethutil_test.go +++ b/pkg/ethutil/ethutil_test.go @@ -11,6 +11,7 @@ import ( "github.com/cartesi/rollups-node/internal/deps" "github.com/cartesi/rollups-node/pkg/addresses" + "github.com/cartesi/rollups-node/pkg/contracts/inputs" "github.com/cartesi/rollups-node/pkg/testutil" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" @@ -57,7 +58,7 @@ func (s *EthUtilSuite) TearDownTest() { } func (s *EthUtilSuite) TestAddInput() { - sender := common.HexToAddress("f39fd6e51aad88f6f4ce6ab8827279cfffb92266") + sender := common.HexToAddress("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266") payload := common.Hex2Bytes("deadbeef") inputIndex, err := AddInput(s.ctx, s.client, s.book, s.signer, payload) @@ -65,13 +66,21 @@ func (s *EthUtilSuite) TestAddInput() { s.logDevnetOutput() s.T().FailNow() } - s.Require().Equal(0, inputIndex) event, err := GetInputFromInputBox(s.client, s.book, inputIndex) s.Require().Nil(err) - s.Require().Equal(sender, event.Sender) - s.Require().Equal(payload, event.Input) + + inputsABI, err := inputs.InputsMetaData.GetAbi() + s.Require().Nil(err) + advanceInputABI := inputsABI.Methods["EvmAdvance"] + inputArgs := map[string]interface{}{} + err = advanceInputABI.Inputs.UnpackIntoMap(inputArgs, event.Input[4:]) + s.Require().Nil(err) + + s.T().Log(inputArgs) + s.Require().Equal(sender, inputArgs["msgSender"]) + s.Require().Equal(payload, inputArgs["payload"]) } // Log the output of the given container diff --git a/pkg/readerclient/proof.go b/pkg/readerclient/proof.go index 57e0547fd..1c5f9de40 100644 --- a/pkg/readerclient/proof.go +++ b/pkg/readerclient/proof.go @@ -6,7 +6,7 @@ package readerclient import ( "fmt" - "github.com/cartesi/rollups-node/pkg/contracts" + "github.com/cartesi/rollups-node/pkg/contracts/application" "github.com/ethereum/go-ethereum/common/hexutil" ) @@ -126,35 +126,8 @@ func newProof( return &proof, err } -func ConvertToContractProof(proof *Proof) *contracts.Proof { - var ( - outputHashOutputSiblings [][32]byte - outputHashEpochSiblings [][32]byte - ) - - for _, hash := range proof.OutputHashInOutputHashesSiblings { - outputHashOutputSiblings = append(outputHashOutputSiblings, [32]byte(hash)) - } - - for _, hash := range proof.OutputHashesInEpochSiblings { - outputHashEpochSiblings = append(outputHashEpochSiblings, [32]byte(hash)) +func ConvertToContractProof(proof *Proof) *application.OutputValidityProof { + return &application.OutputValidityProof{ + // implement this once we have the new GraphQL schema } - - outputValidityProof := contracts.OutputValidityProof{ - InputIndexWithinEpoch: uint64(proof.InputIndexWithinEpoch), - OutputIndexWithinInput: uint64(proof.OutputIndexWithinInput), - OutputHashesRootHash: [32]byte(proof.OutputHashesRootHash), - VouchersEpochRootHash: [32]byte(proof.VouchersEpochRootHash), - NoticesEpochRootHash: [32]byte(proof.NoticesEpochRootHash), - MachineStateHash: [32]byte(proof.MachineStateHash), - OutputHashInOutputHashesSiblings: outputHashOutputSiblings, - OutputHashesInEpochSiblings: outputHashEpochSiblings, - } - - contractProof := contracts.Proof{ - Validity: outputValidityProof, - Context: proof.Context, - } - - return &contractProof } diff --git a/rollups-contracts b/rollups-contracts index 77ff2c089..4b03ced84 160000 --- a/rollups-contracts +++ b/rollups-contracts @@ -1 +1 @@ -Subproject commit 77ff2c08928b871348b6e2bf3b6f5d7f3c95c9dc +Subproject commit 4b03ced840668ca6fc98780c8104708fd775b188 diff --git a/setup_env.sh b/setup_env.sh index fe19a1748..b6f7fcf45 100644 --- a/setup_env.sh +++ b/setup_env.sh @@ -9,12 +9,10 @@ export CARTESI_BLOCKCHAIN_WS_ENDPOINT="ws://localhost:8545" export CARTESI_BLOCKCHAIN_IS_LEGACY="false" export CARTESI_BLOCKCHAIN_FINALITY_OFFSET="1" export CARTESI_BLOCKCHAIN_BLOCK_TIMEOUT="60" -export CARTESI_CONTRACTS_APPLICATION_ADDRESS="0x7C54E3f7A8070a54223469965A871fB8f6f88c22" -export CARTESI_CONTRACTS_APPLICATION_DEPLOYMENT_BLOCK_NUMBER="20" -export CARTESI_CONTRACTS_HISTORY_ADDRESS="0x325272217ae6815b494bF38cED004c5Eb8a7CdA7" -export CARTESI_CONTRACTS_AUTHORITY_ADDRESS="0x58c93F83fb3304730C95aad2E360cdb88b782010" -export CARTESI_CONTRACTS_INPUT_BOX_ADDRESS="0x59b22D57D4f067708AB0c00552767405926dc768" -export CARTESI_CONTRACTS_INPUT_BOX_DEPLOYMENT_BLOCK_NUMBER="20" +export CARTESI_CONTRACTS_APPLICATION_ADDRESS="0xb72c832dDeA10326143831F1E5F1646920C9c990" +export CARTESI_CONTRACTS_ICONSENSUS_ADDRESS="0x77e5a5fb18F72b5106621f66C704c006c6dB4578" +export CARTESI_CONTRACTS_INPUT_BOX_ADDRESS="0xA1b8EB1F13d8D5Db976a653BbDF8972cfD14691C" +export CARTESI_CONTRACTS_INPUT_BOX_DEPLOYMENT_BLOCK_NUMBER="16" export CARTESI_SNAPSHOT_DIR="$PWD/machine-snapshot" export CARTESI_AUTH_KIND="mnemonic" export CARTESI_AUTH_MNEMONIC="test test test test test test test test test test test junk" diff --git a/test/config.go b/test/config.go index 60db4f77a..75e0fa4d8 100644 --- a/test/config.go +++ b/test/config.go @@ -15,14 +15,13 @@ import ( ) const ( - LocalBlockchainID = 31337 - LocalApplicationDeploymentBlockNumber = 20 - LocalInputBoxDeploymentBlockNumber = 20 - LocalHttpAddress = "0.0.0.0" - LocalHttpPort = 10000 - LocalBlockTimeout = 120 - LocalFinalityOffset = 1 - LocalEpochDurationInSeconds = 240 + LocalBlockchainID = 31337 + LocalInputBoxDeploymentBlockNumber = 16 + LocalHttpAddress = "0.0.0.0" + LocalHttpPort = 10000 + LocalBlockTimeout = 120 + LocalFinalityOffset = 1 + LocalEpochDurationInSeconds = 240 ) func NewLocalNodeConfig(localPostgresEnpoint string, localBlockchainHttpEndpoint string, @@ -55,10 +54,8 @@ func NewLocalNodeConfig(localPostgresEnpoint string, localBlockchainHttpEndpoint nodeConfig.BlockchainBlockTimeout = LocalBlockTimeout //Contracts - nodeConfig.ContractsHistoryAddress = book.HistoryAddress.Hex() - nodeConfig.ContractsAuthorityAddress = book.AuthorityAddress.Hex() - nodeConfig.ContractsApplicationAddress = book.CartesiDApp.Hex() - nodeConfig.ContractsApplicationDeploymentBlockNumber = LocalApplicationDeploymentBlockNumber + nodeConfig.ContractsApplicationAddress = book.Application.Hex() + nodeConfig.ContractsIConsensusAddress = book.Authority.Hex() nodeConfig.ContractsInputBoxAddress = book.InputBox.Hex() nodeConfig.ContractsInputBoxDeploymentBlockNumber = LocalInputBoxDeploymentBlockNumber