From 01cd5fd766a3d563ad3d62602a36cc39f953ee31 Mon Sep 17 00:00:00 2001 From: Michal Handzlik Date: Wed, 17 Aug 2022 16:04:56 +0200 Subject: [PATCH 1/7] One contract to rule them all --- contracts/button/Cargo.lock | 68 ---- contracts/button/Cargo.toml | 4 +- contracts/button/errors.rs | 87 +++++ contracts/button/lib.rs | 686 ++++++++++++++++++------------------ 4 files changed, 424 insertions(+), 421 deletions(-) create mode 100644 contracts/button/errors.rs diff --git a/contracts/button/Cargo.lock b/contracts/button/Cargo.lock index e67c537d50..84ab724a11 100644 --- a/contracts/button/Cargo.lock +++ b/contracts/button/Cargo.lock @@ -91,7 +91,6 @@ dependencies = [ "ink_prelude", "ink_primitives", "ink_storage", - "num", "openbrush", "parity-scale-codec", "scale-info", @@ -526,73 +525,6 @@ version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" -[[package]] -name = "num" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ae39348c8bc5fbd7f40c727a9925f03517afd2ab27d46702108b6a7e5414c19" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" -dependencies = [ - "autocfg", - "num-bigint", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.15" diff --git a/contracts/button/Cargo.toml b/contracts/button/Cargo.toml index c558d1414d..433cbb1bf7 100644 --- a/contracts/button/Cargo.toml +++ b/contracts/button/Cargo.toml @@ -19,12 +19,12 @@ access_control = { path = "../access_control", default-features = false, feature game_token = { path = "../game_token", default-features = false, features = ["ink-as-dependency"] } ticket_token = { path = "../ticket_token", default-features = false, features = ["ink-as-dependency"] } openbrush = { git = "https://github.com/Supercolony-net/openbrush-contracts.git", rev = "8a20f95", default-features = false, features = ["psp22"] } -num = {version = "0.4.0", default-features = false } [lib] name = "button" path = "lib.rs" crate-type = [ + "cdylib", "rlib", ] @@ -34,7 +34,7 @@ std = [ "ink_env/std", "ink_lang/std", "ink_metadata/std", - "ink_prelude/std", + "ink_prelude/std", "ink_primitives/std", "ink_storage/std", "scale-info/std", diff --git a/contracts/button/errors.rs b/contracts/button/errors.rs new file mode 100644 index 0000000000..ce9d4a3ad2 --- /dev/null +++ b/contracts/button/errors.rs @@ -0,0 +1,87 @@ +use ink_env::Error as InkEnvError; +use ink_prelude::{format, string::String}; +use openbrush::contracts::psp22::PSP22Error; + +/// GameError types +#[derive(Debug, PartialEq, Eq, scale::Encode, scale::Decode)] +#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] +pub enum GameError { + /// Returned if reset is called before the deadline + BeforeDeadline, + /// Returned if button is pressed after the deadline + AfterDeadline, + /// Returned if a call is made from an account with missing access control privileges + MissingRole(String), + /// Returned if a call to another contract has failed + ContractCall(String), +} + +impl From for GameError { + fn from(e: PSP22Error) -> Self { + match e { + PSP22Error::Custom(message) => GameError::ContractCall(message), + PSP22Error::InsufficientBalance => { + GameError::ContractCall(String::from("PSP22::InsufficientBalance")) + } + PSP22Error::InsufficientAllowance => { + GameError::ContractCall(String::from("PSP22::InsufficientAllowance")) + } + PSP22Error::ZeroRecipientAddress => { + GameError::ContractCall(String::from("PSP22::ZeroRecipientAddress")) + } + PSP22Error::ZeroSenderAddress => { + GameError::ContractCall(String::from("PSP22::ZeroSenderAddress")) + } + PSP22Error::SafeTransferCheckFailed(message) => { + GameError::ContractCall(format!("PSP22::SafeTransferCheckFailed({})", message)) + } + } + } +} + +impl From for GameError { + fn from(e: InkEnvError) -> Self { + match e { + InkEnvError::Decode(_e) => { + GameError::ContractCall(String::from("Contract call failed due to Decode error")) + } + InkEnvError::CalleeTrapped => GameError::ContractCall(String::from( + "Contract call failed due to CalleeTrapped error", + )), + InkEnvError::CalleeReverted => GameError::ContractCall(String::from( + "Contract call failed due to CalleeReverted error", + )), + InkEnvError::KeyNotFound => GameError::ContractCall(String::from( + "Contract call failed due to KeyNotFound error", + )), + InkEnvError::_BelowSubsistenceThreshold => GameError::ContractCall(String::from( + "Contract call failed due to _BelowSubsistenceThreshold error", + )), + InkEnvError::TransferFailed => GameError::ContractCall(String::from( + "Contract call failed due to TransferFailed error", + )), + InkEnvError::_EndowmentTooLow => GameError::ContractCall(String::from( + "Contract call failed due to _EndowmentTooLow error", + )), + InkEnvError::CodeNotFound => GameError::ContractCall(String::from( + "Contract call failed due to CodeNotFound error", + )), + InkEnvError::NotCallable => GameError::ContractCall(String::from( + "Contract call failed due to NotCallable error", + )), + InkEnvError::Unknown => { + GameError::ContractCall(String::from("Contract call failed due to Unknown error")) + } + InkEnvError::LoggingDisabled => GameError::ContractCall(String::from( + "Contract call failed due to LoggingDisabled error", + )), + InkEnvError::EcdsaRecoveryFailed => GameError::ContractCall(String::from( + "Contract call failed due to EcdsaRecoveryFailed error", + )), + #[cfg(any(feature = "std", test, doc))] + InkEnvError::OffChain(_e) => { + GameError::ContractCall(String::from("Contract call failed due to OffChain error")) + } + } + } +} diff --git a/contracts/button/lib.rs b/contracts/button/lib.rs index ab1506e0ec..89ab1fd948 100644 --- a/contracts/button/lib.rs +++ b/contracts/button/lib.rs @@ -1,390 +1,374 @@ #![cfg_attr(not(feature = "std"), no_std)] -use access_control::{traits::AccessControlled, Role}; -use game_token::MINT_TO_SELECTOR; -use ink_env::{ - call::{build_call, Call, ExecutionInput, Selector}, - AccountId, DefaultEnvironment, Environment, Error as InkEnvError, -}; +mod errors; + use ink_lang as ink; -use ink_prelude::{format, string::String, vec}; -use ink_storage::traits::{SpreadAllocate, SpreadLayout}; -use openbrush::contracts::psp22::PSP22Error; -use ticket_token::{BALANCE_OF_SELECTOR, TRANSFER_FROM_SELECTOR}; - -pub type BlockNumber = ::BlockNumber; -pub type Balance = ::Balance; -pub type ButtonResult = core::result::Result; - -/// GameError types -#[derive(Debug, PartialEq, Eq, scale::Encode, scale::Decode)] -#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] -pub enum GameError { - /// Returned if reset is called before the deadline - BeforeDeadline, - /// Returned if button is pressed after the deadline - AfterDeadline, - /// Returned if a call is made from an account with missing access control privileges - MissingRole(String), - /// Returned if a call to another contract has failed - ContractCall(String), -} -impl From for GameError { - fn from(e: PSP22Error) -> Self { - match e { - PSP22Error::Custom(message) => GameError::ContractCall(message), - PSP22Error::InsufficientBalance => { - GameError::ContractCall(String::from("PSP22::InsufficientBalance")) - } - PSP22Error::InsufficientAllowance => { - GameError::ContractCall(String::from("PSP22::InsufficientAllowance")) - } - PSP22Error::ZeroRecipientAddress => { - GameError::ContractCall(String::from("PSP22::ZeroRecipientAddress")) - } - PSP22Error::ZeroSenderAddress => { - GameError::ContractCall(String::from("PSP22::ZeroSenderAddress")) - } - PSP22Error::SafeTransferCheckFailed(message) => { - GameError::ContractCall(format!("PSP22::SafeTransferCheckFailed({})", message)) - } - } +#[ink::contract] +mod button_game { + use access_control::{traits::AccessControlled, Role, ACCESS_CONTROL_PUBKEY}; + use game_token::MINT_TO_SELECTOR; + use ink_env::{ + call::{build_call, Call, ExecutionInput, Selector}, + DefaultEnvironment, Error as InkEnvError, + }; + use ink_lang::{codegen::EmitEvent, reflect::ContractEventBase}; + use ink_prelude::{format, vec}; + use ink_storage::traits::{PackedLayout, SpreadLayout}; + use openbrush::contracts::psp22::PSP22Error; + use scale::{Decode, Encode}; + use ticket_token::TRANSFER_FROM_SELECTOR; + + use crate::errors::GameError; + + /// Result type + type ButtonResult = core::result::Result; + + /// Event type + type Event = ::Type; + + /// Event emitted when TheButton is created + #[ink(event)] + #[derive(Debug)] + pub struct ButtonCreated { + #[ink(topic)] + reward_token: AccountId, + #[ink(topic)] + ticket_token: AccountId, + start: BlockNumber, + deadline: BlockNumber, } -} -impl From for GameError { - fn from(e: InkEnvError) -> Self { - match e { - InkEnvError::Decode(_e) => { - GameError::ContractCall(String::from("Contract call failed due to Decode error")) - } - InkEnvError::CalleeTrapped => GameError::ContractCall(String::from( - "Contract call failed due to CalleeTrapped error", - )), - InkEnvError::CalleeReverted => GameError::ContractCall(String::from( - "Contract call failed due to CalleeReverted error", - )), - InkEnvError::KeyNotFound => GameError::ContractCall(String::from( - "Contract call failed due to KeyNotFound error", - )), - InkEnvError::_BelowSubsistenceThreshold => GameError::ContractCall(String::from( - "Contract call failed due to _BelowSubsistenceThreshold error", - )), - InkEnvError::TransferFailed => GameError::ContractCall(String::from( - "Contract call failed due to TransferFailed error", - )), - InkEnvError::_EndowmentTooLow => GameError::ContractCall(String::from( - "Contract call failed due to _EndowmentTooLow error", - )), - InkEnvError::CodeNotFound => GameError::ContractCall(String::from( - "Contract call failed due to CodeNotFound error", - )), - InkEnvError::NotCallable => GameError::ContractCall(String::from( - "Contract call failed due to NotCallable error", - )), - InkEnvError::Unknown => { - GameError::ContractCall(String::from("Contract call failed due to Unknown error")) - } - InkEnvError::LoggingDisabled => GameError::ContractCall(String::from( - "Contract call failed due to LoggingDisabled error", - )), - InkEnvError::EcdsaRecoveryFailed => GameError::ContractCall(String::from( - "Contract call failed due to EcdsaRecoveryFailed error", - )), - #[cfg(any(feature = "std", test, doc))] - InkEnvError::OffChain(_e) => { - GameError::ContractCall(String::from("Contract call failed due to OffChain error")) - } - } + /// Event emitted when TheButton is pressed + #[ink(event)] + #[derive(Debug)] + pub struct ButtonPressed { + #[ink(topic)] + by: AccountId, + when: BlockNumber, } -} - -/// Game contracts storage -#[derive(Debug, SpreadLayout, SpreadAllocate, Default)] -#[cfg_attr( - feature = "std", - derive(scale_info::TypeInfo, ink_storage::traits::StorageLayout) -)] -pub struct ButtonData { - /// How long does TheButton live for? - pub button_lifetime: BlockNumber, - /// stores the last account that pressed The Button - pub last_presser: Option, - /// block number of the last press, set to current block number at button start/reset - pub last_press: BlockNumber, - /// sum of rewards paid to players in the current iteration - pub total_rewards: u128, - /// counter for the number of presses - pub presses: u128, - /// AccountId of the PSP22 ButtonToken instance on-chain - pub reward_token: AccountId, - /// Account ID of the ticket token - pub ticket_token: AccountId, - /// access control contract - pub access_control: AccountId, -} -/// Provides default implementations of the games API to be called inside IButtonGame trait methods -/// -/// Implementing contract needs to return ButtonData read-only and mutably -/// as well as implement `score`: the logic that based on the current block number and the contract storage state returns a users score. -/// Remaining methods have default implementations that can be overriden as needed. -/// -/// NOTE: no contract events are being emitted, so the implementing contract is responsible for defining and emitting those. -pub trait ButtonGame { - /// Getter for the button data - fn get(&self) -> &ButtonData; - - /// Mutable getter for the button data - fn get_mut(&mut self) -> &mut ButtonData; - - /// Logic for calculating user score given the particular games rules - fn score(&self, now: BlockNumber) -> Balance; - - /// Logic for calculating pressiah score - /// - /// By default the pressiah gets 20% of the total rewards paid in the current game iteration - /// Can be overriden to some other custom calculation - fn pressiah_score(&self) -> Balance { - (self.get().total_rewards / 4) as Balance + /// Event emitted when the finished game is reset and pressiah is rewarded + #[ink(event)] + #[derive(Debug)] + pub struct GameReset { + when: BlockNumber, } - fn is_dead(&self, now: BlockNumber) -> bool { - now > self.deadline() + /// Scoring strategy indicating what kind of reward users get for pressing the button + #[derive(Debug, Encode, Decode, Clone, Copy, SpreadLayout, PackedLayout, PartialEq, Eq)] + #[cfg_attr( + feature = "std", + derive(scale_info::TypeInfo, ink_storage::traits::StorageLayout) + )] + pub enum Scoring { + /// Pressing the button as soon as possible gives the highest reward + EarlyBirdSpecial, + /// Pressing the button as late as possible gives the highest reward + BackToTheFuture, + /// The reward increases linearly with the number of participants + ThePressiahCometh, } - fn deadline(&self) -> BlockNumber { - let ButtonData { - last_press, - button_lifetime, - .. - } = self.get(); - last_press + button_lifetime + /// Game contracts storage + #[ink(storage)] + pub struct ButtonGame { + /// How long does TheButton live for? + pub button_lifetime: BlockNumber, + /// stores the last account that pressed The Button + pub last_presser: Option, + /// block number of the last press, set to current block number at button start/reset + pub last_press: BlockNumber, + /// sum of rewards paid to players in the current iteration + pub total_rewards: u128, + /// counter for the number of presses + pub presses: u128, + /// AccountId of the PSP22 ButtonToken instance on-chain + pub reward_token: AccountId, + /// Account ID of the ticket token + pub ticket_token: AccountId, + /// access control contract + pub access_control: AccountId, + /// scoring strategy + pub scoring: Scoring, } - fn access_control(&self) -> AccountId { - self.get().access_control + impl AccessControlled for ButtonGame { + type ContractError = GameError; } - fn ticket_token(&self) -> AccountId { - self.get().ticket_token - } + impl ButtonGame { + #[ink(constructor)] + pub fn new( + ticket_token: AccountId, + reward_token: AccountId, + button_lifetime: BlockNumber, + scoring: Scoring, + ) -> Self { + let caller = Self::env().caller(); + let code_hash = Self::env() + .own_code_hash() + .expect("Called new on a contract with no code hash"); + let required_role = Role::Initializer(code_hash); + let access_control = AccountId::from(ACCESS_CONTROL_PUBKEY); + + let role_check = ::check_role( + access_control, + caller, + required_role, + |why: InkEnvError| { + GameError::ContractCall(format!("Calling access control has failed: {:?}", why)) + }, + |role: Role| GameError::MissingRole(format!("{:?}", role)), + ); + + match role_check { + Ok(_) => Self::init(ticket_token, reward_token, button_lifetime, scoring), + Err(why) => panic!("Could not initialize the contract {:?}", why), + } + } - fn set_access_control( - &mut self, - new_access_control: AccountId, - caller: AccountId, - this: AccountId, - ) -> ButtonResult<()> - where - Self: AccessControlled, - { - let required_role = Role::Owner(this); - self.check_role(caller, required_role)?; - self.get_mut().access_control = new_access_control; - Ok(()) - } + /// Returns the current deadline + /// + /// Deadline is the block number at which the game will end if there are no more participants + #[ink(message)] + pub fn deadline(&self) -> BlockNumber { + self.last_press + self.button_lifetime + } - fn last_presser(&self) -> Option { - self.get().last_presser - } + /// Returns the buttons status + #[ink(message)] + pub fn is_dead(&self) -> bool { + self.env().block_number() > self.deadline() + } - fn reward_token(&self) -> AccountId { - self.get().reward_token - } + /// Returns the last player who pressed the button. + /// If button is dead, this is The Pressiah. + #[ink(message)] + pub fn last_presser(&self) -> Option { + self.last_presser + } - fn balance(&self, this: AccountId) -> ButtonResult - where - E: Environment, - { - let ticket_token = self.get().ticket_token; - let balance = build_call::() - .call_type(Call::new().callee(ticket_token)) - .exec_input(ExecutionInput::new(Selector::new(BALANCE_OF_SELECTOR)).push_arg(this)) - .returns::() - .fire()?; - Ok(balance) - } + /// Returns the current access control contract address + #[ink(message)] + pub fn access_control(&self) -> AccountId { + self.access_control + } - fn transfer_from_tx( - &self, - from: AccountId, - to: AccountId, - value: Balance, - ) -> Result, InkEnvError> - where - E: Environment, - { - build_call::() - .call_type(Call::new().callee(self.get().ticket_token)) - .exec_input( - ExecutionInput::new(Selector::new(TRANSFER_FROM_SELECTOR)) - .push_arg(from) - .push_arg(to) - .push_arg(value) - .push_arg(vec![0x0]), - ) - .returns::>() - .fire() - } + /// Returns address of the game's reward token + #[ink(message)] + pub fn reward_token(&self) -> AccountId { + self.reward_token + } - fn mint_tx( - &self, - to: AccountId, - amount: Balance, - ) -> Result, InkEnvError> - where - E: Environment, - { - build_call::() - .call_type(Call::new().callee(self.get().reward_token)) - .exec_input( - ExecutionInput::new(Selector::new(MINT_TO_SELECTOR)) - .push_arg(to) - .push_arg(amount), - ) - .returns::>() - .fire() - } + /// Returns address of the game's ticket token + #[ink(message)] + pub fn ticket_token(&self) -> AccountId { + self.ticket_token + } - fn check_role(&self, account: AccountId, role: Role) -> ButtonResult<()> - where - Self: AccessControlled, - { - ::check_role( - self.get().access_control, - account, - role, - |why: InkEnvError| { - GameError::ContractCall(format!("Calling access control has failed: {:?}", why)) - }, - |role: Role| GameError::MissingRole(format!("{:?}", role)), - ) - } + /// Returns own code hash + #[ink(message)] + pub fn code_hash(&self) -> ButtonResult { + self.env().own_code_hash().map_err(|why| { + GameError::ContractCall(format!("Can't retrieve own code hash: {:?}", why)) + }) + } + + #[ink(message)] + pub fn press(&mut self) -> ButtonResult<()> { + if self.is_dead() { + return Err(GameError::AfterDeadline); + } + + let caller = self.env().caller(); + let now = Self::env().block_number(); + let this = self.env().account_id(); + + // transfers 1 ticket token from the caller to self + // tx will fail if user did not give allowance to the game contract + // or does not have enough balance + self.transfer_ticket(caller, this, 1u128)??; - fn press(&mut self, now: BlockNumber, caller: AccountId, this: AccountId) -> ButtonResult<()> - where - E: Environment, - { - if self.is_dead(now) { - return Err(GameError::AfterDeadline); + let score = self.score(now); + + // mints reward tokens to pay out the reward + // contract needs to have a Minter role on the reward token contract + self.mint_reward(caller, score)??; + + self.presses += 1; + self.last_presser = Some(caller); + self.last_press = now; + self.total_rewards += score; + + Self::emit_event( + self.env(), + Event::ButtonPressed(ButtonPressed { + by: caller, + when: now, + }), + ); + + Ok(()) } - // transfers 1 ticket token from the caller to self - // tx will fail if user did not give allowance to the game contract - // or does not have enough balance - self.transfer_from_tx::(caller, this, 1u128)??; + /// Resets the game + /// + /// Erases the storage and pays award to the Pressiah + /// Can be called by any account on behalf of a player + /// Can only be called after button's deadline + #[ink(message)] + pub fn reset(&mut self) -> ButtonResult<()> { + if !self.is_dead() { + return Err(GameError::BeforeDeadline); + } - let score = self.score(now); + let now = self.env().block_number(); - // mints reward tokens to pay out the reward - // contract needs to have a Minter role on the reward token contract - self.mint_tx::(caller, score)??; + // reward the Pressiah + if let Some(pressiah) = self.last_presser { + let reward = self.pressiah_score(); + self.mint_reward(pressiah, reward)??; + }; - let mut state = self.get_mut(); + self.presses = 0; + self.last_presser = None; + self.last_press = now; + self.total_rewards = 0; - state.presses += 1; - state.last_presser = Some(caller); - state.last_press = now; - state.total_rewards += score; + Self::emit_event(self.env(), Event::GameReset(GameReset { when: now })); + Ok(()) + } - Ok(()) - } + /// Sets new access control contract address + /// + /// Should only be called by the contract owner + /// Implementing contract is responsible for setting up proper AccessControl + #[ink(message)] + pub fn set_access_control(&mut self, new_access_control: AccountId) -> ButtonResult<()> { + let caller = self.env().caller(); + let this = self.env().account_id(); + let required_role = Role::Owner(this); + self.check_role(caller, required_role)?; + self.access_control = new_access_control; + Ok(()) + } - /// Reset the game - /// - /// Erases the storage and pays award to the Pressiah - /// Can be called by any account on behalf of a player - /// Can only be called after button's deadline - fn reset(&mut self, now: BlockNumber) -> ButtonResult<()> - where - E: Environment, - { - let ButtonData { last_presser, .. } = self.get(); - - if !self.is_dead(now) { - return Err(GameError::BeforeDeadline); + /// Terminates the contract + /// + /// Should only be called by the contract Owner + #[ink(message)] + pub fn terminate(&mut self) -> ButtonResult<()> { + let caller = self.env().caller(); + let this = self.env().account_id(); + let required_role = Role::Owner(this); + self.check_role(caller, required_role)?; + self.env().terminate_contract(caller) } - // reward the Pressiah - if let Some(pressiah) = last_presser { - let reward = self.pressiah_score(); - self.mint_tx::(*pressiah, reward)??; - }; + //=================================================================================================== + + fn init( + ticket_token: AccountId, + reward_token: AccountId, + button_lifetime: BlockNumber, + scoring: Scoring, + ) -> Self { + let now = Self::env().block_number(); + let deadline = now + button_lifetime; + + let contract = Self { + access_control: AccountId::from(ACCESS_CONTROL_PUBKEY), + button_lifetime, + reward_token, + ticket_token, + last_press: now, + scoring, + last_presser: None, + presses: 0, + total_rewards: 0, + }; + + Self::emit_event( + Self::env(), + Event::ButtonCreated(ButtonCreated { + start: now, + deadline, + ticket_token, + reward_token, + }), + ); + + contract + } - // zero the counters in storage - let mut state = self.get_mut(); + fn check_role(&self, account: AccountId, role: Role) -> ButtonResult<()> + where + Self: AccessControlled, + { + ::check_role( + self.access_control, + account, + role, + |why: InkEnvError| { + GameError::ContractCall(format!("Calling access control has failed: {:?}", why)) + }, + |role: Role| GameError::MissingRole(format!("{:?}", role)), + ) + } - state.presses = 0; - state.last_presser = None; - state.last_press = now; - state.total_rewards = 0; + fn score(&self, now: BlockNumber) -> Balance { + match self.scoring { + Scoring::EarlyBirdSpecial => self.deadline().saturating_sub(now) as Balance, + Scoring::BackToTheFuture => now.saturating_sub(self.last_press) as Balance, + Scoring::ThePressiahCometh => (self.presses + 1) as Balance, + } + } - Ok(()) - } -} + fn pressiah_score(&self) -> Balance { + (self.total_rewards / 4) as Balance + } + + fn transfer_ticket( + &self, + from: AccountId, + to: AccountId, + value: Balance, + ) -> Result, InkEnvError> { + build_call::() + .call_type(Call::new().callee(self.ticket_token)) + .exec_input( + ExecutionInput::new(Selector::new(TRANSFER_FROM_SELECTOR)) + .push_arg(from) + .push_arg(to) + .push_arg(value) + .push_arg(vec![0x0]), + ) + .returns::>() + .fire() + } -/// Contract trait definition -/// -/// This trait defines the game's API -/// You will get default implementations of the matching methods by impl ButtonGame trait -#[ink::trait_definition] -pub trait IButtonGame { - /// Button press logic - /// - /// Will instantenously mint reward tokens to the caller - #[ink(message)] - fn press(&mut self) -> ButtonResult<()>; - - /// Returns the buttons status - #[ink(message)] - fn is_dead(&self) -> bool; - - /// Returns the current deadline - /// - /// Deadline is the block number at which the game will end if there are no more participants - #[ink(message)] - fn deadline(&self) -> BlockNumber; - - /// Returns the current Pressiah - /// - /// When button is DEAD this is ThePressiah and the winner of the current iteration - #[ink(message)] - fn last_presser(&self) -> Option; - - /// Returns the current access control contract address - #[ink(message)] - fn access_control(&self) -> AccountId; - - /// Returns address of the game's reward token - #[ink(message)] - fn reward_token(&self) -> AccountId; - - /// Returns address of the game's ticket token - #[ink(message)] - fn ticket_token(&self) -> AccountId; - - /// Returns then number of ticket tokens in the game contract - #[ink(message)] - fn balance(&self) -> ButtonResult; - - /// Resets the game - /// - /// rewards the Pressiah and resets the counters as well as all other neccessary storage fields - #[ink(message)] - fn reset(&mut self) -> ButtonResult<()>; - - /// Sets new access control contract address - /// - /// Should only be called by the contract owner - /// Implementing contract is responsible for setting up proper AccessControl - #[ink(message)] - fn set_access_control(&mut self, access_control: AccountId) -> ButtonResult<()>; - - /// Terminates the contract - /// - /// Should only be called by the contract Owner - #[ink(message)] - fn terminate(&mut self) -> ButtonResult<()>; + fn mint_reward( + &self, + to: AccountId, + amount: Balance, + ) -> Result, InkEnvError> { + build_call::() + .call_type(Call::new().callee(self.reward_token)) + .exec_input( + ExecutionInput::new(Selector::new(MINT_TO_SELECTOR)) + .push_arg(to) + .push_arg(amount), + ) + .returns::>() + .fire() + } + + fn emit_event(emitter: EE, event: Event) + where + EE: EmitEvent, + { + emitter.emit_event(event); + } + } } From 46cc9037087fa294d0778d2d0612ecc72c7b6c97 Mon Sep 17 00:00:00 2001 From: Michal Handzlik Date: Wed, 17 Aug 2022 16:12:57 +0200 Subject: [PATCH 2/7] Wydup dedup --- contracts/back_to_the_future/Cargo.lock | 1097 --------------------- contracts/back_to_the_future/Cargo.toml | 46 - contracts/back_to_the_future/LICENSE | 201 ---- contracts/back_to_the_future/lib.rs | 236 ----- contracts/early_bird_special/Cargo.lock | 1095 --------------------- contracts/early_bird_special/Cargo.toml | 44 - contracts/early_bird_special/lib.rs | 238 ----- contracts/the_pressiah_cometh/Cargo.lock | 1103 ---------------------- contracts/the_pressiah_cometh/Cargo.toml | 44 - contracts/the_pressiah_cometh/lib.rs | 237 ----- 10 files changed, 4341 deletions(-) delete mode 100644 contracts/back_to_the_future/Cargo.lock delete mode 100644 contracts/back_to_the_future/Cargo.toml delete mode 100644 contracts/back_to_the_future/LICENSE delete mode 100755 contracts/back_to_the_future/lib.rs delete mode 100644 contracts/early_bird_special/Cargo.lock delete mode 100644 contracts/early_bird_special/Cargo.toml delete mode 100644 contracts/early_bird_special/lib.rs delete mode 100644 contracts/the_pressiah_cometh/Cargo.lock delete mode 100644 contracts/the_pressiah_cometh/Cargo.toml delete mode 100644 contracts/the_pressiah_cometh/lib.rs diff --git a/contracts/back_to_the_future/Cargo.lock b/contracts/back_to_the_future/Cargo.lock deleted file mode 100644 index 5dae75a4b1..0000000000 --- a/contracts/back_to_the_future/Cargo.lock +++ /dev/null @@ -1,1097 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "access_control" -version = "0.1.0" -dependencies = [ - "ink_env", - "ink_lang", - "ink_lang_codegen", - "ink_metadata", - "ink_primitives", - "ink_storage", - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "array-init" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfb6d71005dc22a708c7496eee5c8dc0300ee47355de6256c3b35b12b5fef596" - -[[package]] -name = "arrayref" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" - -[[package]] -name = "arrayvec" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "back_to_the_future" -version = "0.1.0" -dependencies = [ - "access_control", - "button", - "ink_env", - "ink_lang", - "ink_lang_codegen", - "ink_metadata", - "ink_prelude", - "ink_primitives", - "ink_storage", - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - -[[package]] -name = "blake2" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a4e37d16930f5459780f5621038b6382b9bb37c19016f39fb6b5808d831f174" -dependencies = [ - "crypto-mac", - "digest 0.9.0", - "opaque-debug", -] - -[[package]] -name = "blake2" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9cf849ee05b2ee5fba5e36f97ff8ec2533916700fc0758d40d92136a42f3388" -dependencies = [ - "digest 0.10.3", -] - -[[package]] -name = "block-buffer" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" -dependencies = [ - "generic-array", -] - -[[package]] -name = "button" -version = "0.1.0" -dependencies = [ - "access_control", - "game_token", - "ink_env", - "ink_lang", - "ink_metadata", - "ink_prelude", - "ink_primitives", - "ink_storage", - "num", - "openbrush", - "parity-scale-codec", - "scale-info", - "ticket_token", -] - -[[package]] -name = "byte-slice-cast" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87c5fdd0166095e1d463fc6cc01aa8ce547ad77a4e84d42eb6762b084e28067e" - -[[package]] -name = "camino" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "869119e97797867fd90f5e22af7d0bd274bd4635ebb9eb68c04f3f513ae6c412" -dependencies = [ - "serde", -] - -[[package]] -name = "cargo-platform" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" -dependencies = [ - "serde", -] - -[[package]] -name = "cargo_metadata" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "081e3f0755c1f380c2d010481b6fa2e02973586d5f2b24eebb7a2a1d98b143d8" -dependencies = [ - "camino", - "cargo-platform", - "semver", - "semver-parser", - "serde", - "serde_json", -] - -[[package]] -name = "cc" -version = "1.0.73" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "const_format" -version = "0.2.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "939dc9e2eb9077e0679d2ce32de1ded8531779360b003b4a972a7a39ec263495" -dependencies = [ - "const_format_proc_macros", -] - -[[package]] -name = "const_format_proc_macros" -version = "0.2.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef196d5d972878a48da7decb7686eded338b4858fbabeed513d63a7c98b2b82d" -dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", -] - -[[package]] -name = "cpufeatures" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" -dependencies = [ - "libc", -] - -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "crypto-mac" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" -dependencies = [ - "generic-array", - "subtle", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array", -] - -[[package]] -name = "digest" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" -dependencies = [ - "block-buffer", - "crypto-common", - "subtle", -] - -[[package]] -name = "either" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be" - -[[package]] -name = "fs2" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - -[[package]] -name = "game_token" -version = "2.1.0" -dependencies = [ - "access_control", - "ink_env", - "ink_lang", - "ink_prelude", - "ink_primitives", - "ink_storage", - "openbrush", - "parity-scale-codec", -] - -[[package]] -name = "generic-array" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "getrandom" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "heck" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" -dependencies = [ - "unicode-segmentation", -] - -[[package]] -name = "heck" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" - -[[package]] -name = "impl-serde" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4551f042f3438e64dbd6226b20527fc84a6e1fe65688b58746a2f53623f25f5c" -dependencies = [ - "serde", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "ink_allocator" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed249de74298ed051ebcf6d3082b8d3dbd19cbc448d9ed3235d8a7b92713049" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "ink_engine" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acb9d32ec27d71fefb3f2b6a26bae82a2c6509d7ad61e8a5107b6291a1b03ecb" -dependencies = [ - "blake2 0.10.4", - "derive_more", - "parity-scale-codec", - "rand", - "secp256k1", - "sha2", - "sha3", -] - -[[package]] -name = "ink_env" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1549f5966167387c89fb3dfcdc59973bfb396cc3a7110d7a31ad5fdea56db0cf" -dependencies = [ - "arrayref", - "blake2 0.10.4", - "cfg-if", - "derive_more", - "ink_allocator", - "ink_engine", - "ink_metadata", - "ink_prelude", - "ink_primitives", - "num-traits", - "parity-scale-codec", - "paste", - "rand", - "rlibc", - "scale-info", - "secp256k1", - "sha2", - "sha3", - "static_assertions", -] - -[[package]] -name = "ink_lang" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e5282f2722ac6dca469e7f223a7b38b2a6d20fbca6b974497e630d5dc8934e9" -dependencies = [ - "derive_more", - "ink_env", - "ink_lang_macro", - "ink_metadata", - "ink_prelude", - "ink_primitives", - "ink_storage", - "parity-scale-codec", -] - -[[package]] -name = "ink_lang_codegen" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb3a5de33b59450adc3f61c5eb05b768067c7ab8af9d00f33e284310598168dc" -dependencies = [ - "blake2 0.10.4", - "derive_more", - "either", - "heck 0.4.0", - "impl-serde", - "ink_lang_ir", - "itertools", - "parity-scale-codec", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "ink_lang_ir" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d4d614462280fa06e15b9ca5725d7c8440dde93c8dae1c6f15422f7756cacb" -dependencies = [ - "blake2 0.10.4", - "either", - "itertools", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "ink_lang_macro" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72f85f64141957c5db7cbabbb97a9c16c489e5e9d363e9f147d132a43c71cd29" -dependencies = [ - "ink_lang_codegen", - "ink_lang_ir", - "ink_primitives", - "parity-scale-codec", - "proc-macro2", - "syn", -] - -[[package]] -name = "ink_metadata" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dca6c159a2774f07437c6fd9ea710eb73a6b5e9a031a932bddf08742bf2c081a" -dependencies = [ - "derive_more", - "impl-serde", - "ink_prelude", - "ink_primitives", - "scale-info", - "serde", -] - -[[package]] -name = "ink_prelude" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f7f4dec15e573496c9d2af353e78bde84add391251608f25b5adcf175dc777" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "ink_primitives" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3296dd1c4f4fe12ede7c92d60e6fcb94d46a959ec19c701e4ac588b09e0b4a6" -dependencies = [ - "cfg-if", - "ink_prelude", - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "ink_storage" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ff9b503995a7b41fe201a7a2643ce22f5a11e0b67db7b685424b6d5fe0ecf0b" -dependencies = [ - "array-init", - "cfg-if", - "derive_more", - "ink_env", - "ink_metadata", - "ink_prelude", - "ink_primitives", - "ink_storage_derive", - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "ink_storage_derive" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb68e24e93e8327dda1924868d7ee4dbe01e1ed2b392f28583caa96809b585c" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "synstructure", -] - -[[package]] -name = "itertools" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" - -[[package]] -name = "keccak" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9b7d56ba4a8344d6be9729995e6b06f928af29998cdf79fe390cbf6b1fee838" - -[[package]] -name = "libc" -version = "0.2.126" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" - -[[package]] -name = "num" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606" -dependencies = [ - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ae39348c8bc5fbd7f40c727a9925f03517afd2ab27d46702108b6a7e5414c19" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" -dependencies = [ - "autocfg", -] - -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - -[[package]] -name = "openbrush" -version = "2.1.0" -source = "git+https://github.com/Supercolony-net/openbrush-contracts.git?rev=8a20f95#8a20f951feaf8c6ea72c4bf113bf115bad9f158f" -dependencies = [ - "ink_env", - "ink_lang", - "ink_prelude", - "ink_primitives", - "ink_storage", - "openbrush_contracts", - "openbrush_lang", - "parity-scale-codec", -] - -[[package]] -name = "openbrush_contracts" -version = "2.1.0" -source = "git+https://github.com/Supercolony-net/openbrush-contracts.git?rev=8a20f95#8a20f951feaf8c6ea72c4bf113bf115bad9f158f" -dependencies = [ - "ink_env", - "ink_lang", - "ink_prelude", - "ink_primitives", - "ink_storage", - "openbrush_lang", - "parity-scale-codec", -] - -[[package]] -name = "openbrush_lang" -version = "2.1.0" -source = "git+https://github.com/Supercolony-net/openbrush-contracts.git?rev=8a20f95#8a20f951feaf8c6ea72c4bf113bf115bad9f158f" -dependencies = [ - "const_format", - "ink_env", - "ink_lang", - "ink_primitives", - "ink_storage", - "openbrush_lang_macro", - "parity-scale-codec", - "scale-info", - "sha2-const", -] - -[[package]] -name = "openbrush_lang_codegen" -version = "2.1.0" -source = "git+https://github.com/Supercolony-net/openbrush-contracts.git?rev=8a20f95#8a20f951feaf8c6ea72c4bf113bf115bad9f158f" -dependencies = [ - "blake2 0.9.2", - "cargo_metadata", - "fs2", - "heck 0.3.3", - "ink_lang_ir", - "proc-macro2", - "quote", - "serde", - "serde_json", - "syn", - "synstructure", - "unwrap", -] - -[[package]] -name = "openbrush_lang_macro" -version = "2.1.0" -source = "git+https://github.com/Supercolony-net/openbrush-contracts.git?rev=8a20f95#8a20f951feaf8c6ea72c4bf113bf115bad9f158f" -dependencies = [ - "openbrush_lang_codegen", - "proc-macro2", - "syn", - "synstructure", -] - -[[package]] -name = "parity-scale-codec" -version = "3.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9182e4a71cae089267ab03e67c99368db7cd877baf50f931e5d6d4b71e195ac0" -dependencies = [ - "arrayvec", - "bitvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", - "serde", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9299338969a3d2f491d65f140b00ddec470858402f888af98e8642fb5e8965cd" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "paste" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c520e05135d6e763148b6426a837e239041653ba7becd2e538c076c738025fc" - -[[package]] -name = "pest" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" -dependencies = [ - "ucd-trie", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" - -[[package]] -name = "proc-macro-crate" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" -dependencies = [ - "thiserror", - "toml", -] - -[[package]] -name = "proc-macro2" -version = "1.0.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rlibc" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc874b127765f014d792f16763a81245ab80500e2ad921ed4ee9e82481ee08fe" - -[[package]] -name = "ryu" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" - -[[package]] -name = "scale-info" -version = "2.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c46be926081c9f4dd5dd9b6f1d3e3229f2360bc6502dd8836f84a93b7c75e99a" -dependencies = [ - "bitvec", - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", - "serde", -] - -[[package]] -name = "scale-info-derive" -version = "2.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50e334bb10a245e28e5fd755cabcafd96cfcd167c99ae63a46924ca8d8703a3c" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "secp256k1" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26947345339603ae8395f68e2f3d85a6b0a8ddfe6315818e80b8504415099db0" -dependencies = [ - "secp256k1-sys", -] - -[[package]] -name = "secp256k1-sys" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "152e20a0fd0519390fc43ab404663af8a0b794273d2a91d60ad4a39f13ffe110" -dependencies = [ - "cc", -] - -[[package]] -name = "semver" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" -dependencies = [ - "semver-parser", - "serde", -] - -[[package]] -name = "semver-parser" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" -dependencies = [ - "pest", -] - -[[package]] -name = "serde" -version = "1.0.139" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0171ebb889e45aa68b44aee0859b3eede84c6f5f5c228e6f140c0b2a0a46cad6" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.139" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc1d3230c1de7932af58ad8ffbe1d784bd55efd5a9d84ac24f69c72d83543dfb" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.82" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82c2c1fdcd807d1098552c5b9a36e425e42e9fbd7c6a37a8425f390f781f7fa7" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "sha2" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest 0.10.3", -] - -[[package]] -name = "sha2-const" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5edcd790916d95ff81bdc1505b09c74d30d47a755929cc8c71c59cbbfa99f91b" - -[[package]] -name = "sha3" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881bf8156c87b6301fc5ca6b27f11eeb2761224c7081e69b409d5a1951a70c86" -dependencies = [ - "digest 0.10.3", - "keccak", -] - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "subtle" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" - -[[package]] -name = "syn" -version = "1.0.98" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "synstructure" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "unicode-xid", -] - -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "thiserror" -version = "1.0.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "ticket_token" -version = "2.1.0" -dependencies = [ - "access_control", - "ink_env", - "ink_lang", - "ink_prelude", - "ink_primitives", - "ink_storage", - "openbrush", - "parity-scale-codec", -] - -[[package]] -name = "toml" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" -dependencies = [ - "serde", -] - -[[package]] -name = "typenum" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" - -[[package]] -name = "ucd-trie" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89570599c4fe5585de2b388aab47e99f7fa4e9238a1399f707a02e356058141c" - -[[package]] -name = "unicode-ident" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7" - -[[package]] -name = "unicode-segmentation" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" - -[[package]] -name = "unicode-xid" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" - -[[package]] -name = "unwrap" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e33648dd74328e622c7be51f3b40a303c63f93e6fa5f08778b6203a4c25c20f" - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "wyz" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b31594f29d27036c383b53b59ed3476874d518f0efb151b27a4c275141390e" -dependencies = [ - "tap", -] diff --git a/contracts/back_to_the_future/Cargo.toml b/contracts/back_to_the_future/Cargo.toml deleted file mode 100644 index a8ef582114..0000000000 --- a/contracts/back_to_the_future/Cargo.toml +++ /dev/null @@ -1,46 +0,0 @@ -[package] -name = "back_to_the_future" -version = "0.1.0" -authors = ["Cardinal Cryptography"] -edition = "2021" -license = "Apache 2.0" - -[dependencies] -ink_env = { version = "~3.3.0", default-features = false } -ink_lang = { version = "~3.3.0", default-features = false } -ink_lang_codegen = { version = "~3.3.0", default-features = false } -ink_metadata = { version = "~3.3.0", default-features = false, features = ["derive"], optional = true } -ink_prelude = { version = "~3.3.0", default-features = false } -ink_primitives = { version = "~3.3.0", default-features = false } -ink_storage = { version = "~3.3.0", default-features = false } - -scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } -scale-info = { version = "2", default-features = false, features = ["derive"], optional = true } - -button = { path = "../button", default-features = false } -access_control = { path = "../access_control", default-features = false, features = ["ink-as-dependency"] } - -[lib] -name = "back_to_the_future" -path = "lib.rs" -crate-type = [ - # Used for normal contract Wasm blobs. - "cdylib", -] - -[features] -default = ["std"] -std = [ - "access_control/std", - "button/std", - "ink_env/std", - "ink_lang/std", - "ink_lang_codegen/std", - "ink_metadata/std", - "ink_prelude/std", - "ink_primitives/std", - "ink_storage/std", - "scale-info/std", - "scale/std", -] -ink-as-dependency = [] diff --git a/contracts/back_to_the_future/LICENSE b/contracts/back_to_the_future/LICENSE deleted file mode 100644 index 261eeb9e9f..0000000000 --- a/contracts/back_to_the_future/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/contracts/back_to_the_future/lib.rs b/contracts/back_to_the_future/lib.rs deleted file mode 100755 index 849b872c45..0000000000 --- a/contracts/back_to_the_future/lib.rs +++ /dev/null @@ -1,236 +0,0 @@ -#![cfg_attr(not(feature = "std"), no_std)] - -use ink_lang as ink; - -/// This is the BackToTheFuture -/// -/// Larger rewards are distributed for postponing playing for as long as possible, but without letting TheButton die: -/// user_score = now - previous_press -/// ThePressiah (the last player to click) gets 20% of the tokens. - -#[ink::contract] -mod back_to_the_future { - - use access_control::{traits::AccessControlled, Role, ACCESS_CONTROL_PUBKEY}; - use button::{ButtonData, ButtonGame, ButtonResult, GameError, IButtonGame}; - use ink_env::{DefaultEnvironment, Error as InkEnvError}; - use ink_lang::{ - codegen::{initialize_contract, EmitEvent}, - reflect::ContractEventBase, - }; - use ink_prelude::format; - use ink_storage::traits::SpreadAllocate; - - type Event = ::Type; - - /// Event emitted when TheButton is created - #[ink(event)] - #[derive(Debug)] - pub struct ButtonCreated { - #[ink(topic)] - reward_token: AccountId, - #[ink(topic)] - ticket_token: AccountId, - start: BlockNumber, - deadline: BlockNumber, - } - - /// Event emitted when TheButton is pressed - #[ink(event)] - #[derive(Debug)] - pub struct ButtonPressed { - #[ink(topic)] - by: AccountId, - when: BlockNumber, - } - - /// Event emitted when a players reward is claimed - #[ink(event)] - #[derive(Debug)] - pub struct GameReset { - when: BlockNumber, - } - - #[ink(storage)] - #[derive(SpreadAllocate)] - pub struct BackToTheFuture { - data: ButtonData, - } - - impl AccessControlled for BackToTheFuture { - type ContractError = GameError; - } - - impl ButtonGame for BackToTheFuture { - fn get(&self) -> &ButtonData { - &self.data - } - - fn get_mut(&mut self) -> &mut ButtonData { - &mut self.data - } - - fn score(&self, now: BlockNumber) -> Balance { - (now - self.get().last_press) as Balance - } - } - - // because ink! does not allow generics or trait default implementations - impl IButtonGame for BackToTheFuture { - #[ink(message)] - fn is_dead(&self) -> bool { - let now = self.env().block_number(); - ButtonGame::is_dead(self, now) - } - - #[ink(message)] - fn press(&mut self) -> ButtonResult<()> { - let caller = self.env().caller(); - let now = Self::env().block_number(); - let this = self.env().account_id(); - - ButtonGame::press::(self, now, caller, this)?; - - Self::emit_event( - self.env(), - Event::ButtonPressed(ButtonPressed { - by: caller, - when: now, - }), - ); - - Ok(()) - } - - #[ink(message)] - fn reset(&mut self) -> ButtonResult<()> { - let now = Self::env().block_number(); - - ButtonGame::reset::(self, now)?; - - Self::emit_event(self.env(), Event::GameReset(GameReset { when: now })); - Ok(()) - } - - #[ink(message)] - fn deadline(&self) -> BlockNumber { - ButtonGame::deadline(self) - } - - #[ink(message)] - fn access_control(&self) -> AccountId { - ButtonGame::access_control(self) - } - - #[ink(message)] - fn last_presser(&self) -> Option { - ButtonGame::last_presser(self) - } - - #[ink(message)] - fn reward_token(&self) -> AccountId { - ButtonGame::reward_token(self) - } - - #[ink(message)] - fn ticket_token(&self) -> AccountId { - ButtonGame::ticket_token(self) - } - - #[ink(message)] - fn balance(&self) -> ButtonResult { - let this = self.env().account_id(); - ButtonGame::balance::(self, this) - } - - #[ink(message)] - fn set_access_control(&mut self, new_access_control: AccountId) -> ButtonResult<()> { - let caller = self.env().caller(); - let this = self.env().account_id(); - ButtonGame::set_access_control(self, new_access_control, caller, this) - } - - #[ink(message)] - fn terminate(&mut self) -> ButtonResult<()> { - let caller = self.env().caller(); - let this = self.env().account_id(); - let required_role = Role::Owner(this); - self.check_role(caller, required_role)?; - self.env().terminate_contract(caller) - } - } - - impl BackToTheFuture { - #[ink(constructor)] - pub fn new( - ticket_token: AccountId, - reward_token: AccountId, - button_lifetime: BlockNumber, - ) -> Self { - let caller = Self::env().caller(); - let code_hash = Self::env() - .own_code_hash() - .expect("Called new on a contract with no code hash"); - let required_role = Role::Initializer(code_hash); - let access_control = AccountId::from(ACCESS_CONTROL_PUBKEY); - - let role_check = ::check_role( - access_control, - caller, - required_role, - |why: InkEnvError| { - GameError::ContractCall(format!("Calling access control has failed: {:?}", why)) - }, - |role: Role| GameError::MissingRole(format!("{:?}", role)), - ); - - match role_check { - Ok(_) => initialize_contract(|contract| { - Self::new_init(contract, ticket_token, reward_token, button_lifetime) - }), - Err(why) => panic!("Could not initialize the contract {:?}", why), - } - } - - fn new_init( - &mut self, - ticket_token: AccountId, - reward_token: AccountId, - button_lifetime: BlockNumber, - ) { - let now = Self::env().block_number(); - let deadline = now + button_lifetime; - - self.data.access_control = AccountId::from(ACCESS_CONTROL_PUBKEY); - self.data.button_lifetime = button_lifetime; - self.data.reward_token = reward_token; - self.data.ticket_token = ticket_token; - self.data.last_press = now; - - Self::emit_event( - Self::env(), - Event::ButtonCreated(ButtonCreated { - start: now, - deadline, - ticket_token, - reward_token, - }), - ) - } - - fn emit_event(emitter: EE, event: Event) - where - EE: EmitEvent, - { - emitter.emit_event(event); - } - - /// Returns own code hash - #[ink(message)] - pub fn code_hash(&self) -> ButtonResult { - self.env().own_code_hash().map_err(|why| { - GameError::ContractCall(format!("Can't retrieve own code hash: {:?}", why)) - }) - } - } -} diff --git a/contracts/early_bird_special/Cargo.lock b/contracts/early_bird_special/Cargo.lock deleted file mode 100644 index 50696bccdb..0000000000 --- a/contracts/early_bird_special/Cargo.lock +++ /dev/null @@ -1,1095 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "access_control" -version = "0.1.0" -dependencies = [ - "ink_env", - "ink_lang", - "ink_lang_codegen", - "ink_primitives", - "ink_storage", - "parity-scale-codec", -] - -[[package]] -name = "array-init" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfb6d71005dc22a708c7496eee5c8dc0300ee47355de6256c3b35b12b5fef596" - -[[package]] -name = "arrayref" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" - -[[package]] -name = "arrayvec" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "bitvec" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1489fcb93a5bb47da0462ca93ad252ad6af2145cce58d10d46a83931ba9f016b" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - -[[package]] -name = "blake2" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a4e37d16930f5459780f5621038b6382b9bb37c19016f39fb6b5808d831f174" -dependencies = [ - "crypto-mac", - "digest 0.9.0", - "opaque-debug", -] - -[[package]] -name = "blake2" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9cf849ee05b2ee5fba5e36f97ff8ec2533916700fc0758d40d92136a42f3388" -dependencies = [ - "digest 0.10.3", -] - -[[package]] -name = "block-buffer" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" -dependencies = [ - "generic-array", -] - -[[package]] -name = "button" -version = "0.1.0" -dependencies = [ - "access_control", - "game_token", - "ink_env", - "ink_lang", - "ink_metadata", - "ink_prelude", - "ink_primitives", - "ink_storage", - "num", - "openbrush", - "parity-scale-codec", - "scale-info", - "ticket_token", -] - -[[package]] -name = "byte-slice-cast" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87c5fdd0166095e1d463fc6cc01aa8ce547ad77a4e84d42eb6762b084e28067e" - -[[package]] -name = "camino" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "869119e97797867fd90f5e22af7d0bd274bd4635ebb9eb68c04f3f513ae6c412" -dependencies = [ - "serde", -] - -[[package]] -name = "cargo-platform" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" -dependencies = [ - "serde", -] - -[[package]] -name = "cargo_metadata" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "081e3f0755c1f380c2d010481b6fa2e02973586d5f2b24eebb7a2a1d98b143d8" -dependencies = [ - "camino", - "cargo-platform", - "semver", - "semver-parser", - "serde", - "serde_json", -] - -[[package]] -name = "cc" -version = "1.0.73" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "const_format" -version = "0.2.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "939dc9e2eb9077e0679d2ce32de1ded8531779360b003b4a972a7a39ec263495" -dependencies = [ - "const_format_proc_macros", -] - -[[package]] -name = "const_format_proc_macros" -version = "0.2.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef196d5d972878a48da7decb7686eded338b4858fbabeed513d63a7c98b2b82d" -dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", -] - -[[package]] -name = "cpufeatures" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" -dependencies = [ - "libc", -] - -[[package]] -name = "crypto-common" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5999502d32b9c48d492abe66392408144895020ec4709e549e840799f3bb74c0" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "crypto-mac" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" -dependencies = [ - "generic-array", - "subtle", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array", -] - -[[package]] -name = "digest" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" -dependencies = [ - "block-buffer", - "crypto-common", - "subtle", -] - -[[package]] -name = "early_bird_special" -version = "0.1.0" -dependencies = [ - "access_control", - "button", - "ink_env", - "ink_lang", - "ink_lang_codegen", - "ink_metadata", - "ink_prelude", - "ink_primitives", - "ink_storage", - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "either" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be" - -[[package]] -name = "fs2" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - -[[package]] -name = "game_token" -version = "2.1.0" -dependencies = [ - "access_control", - "ink_env", - "ink_lang", - "ink_prelude", - "ink_primitives", - "ink_storage", - "openbrush", - "parity-scale-codec", -] - -[[package]] -name = "generic-array" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "getrandom" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "heck" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" -dependencies = [ - "unicode-segmentation", -] - -[[package]] -name = "heck" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" - -[[package]] -name = "impl-serde" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4551f042f3438e64dbd6226b20527fc84a6e1fe65688b58746a2f53623f25f5c" -dependencies = [ - "serde", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "ink_allocator" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed249de74298ed051ebcf6d3082b8d3dbd19cbc448d9ed3235d8a7b92713049" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "ink_engine" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acb9d32ec27d71fefb3f2b6a26bae82a2c6509d7ad61e8a5107b6291a1b03ecb" -dependencies = [ - "blake2 0.10.4", - "derive_more", - "parity-scale-codec", - "rand", - "secp256k1", - "sha2", - "sha3", -] - -[[package]] -name = "ink_env" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1549f5966167387c89fb3dfcdc59973bfb396cc3a7110d7a31ad5fdea56db0cf" -dependencies = [ - "arrayref", - "blake2 0.10.4", - "cfg-if", - "derive_more", - "ink_allocator", - "ink_engine", - "ink_metadata", - "ink_prelude", - "ink_primitives", - "num-traits", - "parity-scale-codec", - "paste", - "rand", - "rlibc", - "scale-info", - "secp256k1", - "sha2", - "sha3", - "static_assertions", -] - -[[package]] -name = "ink_lang" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e5282f2722ac6dca469e7f223a7b38b2a6d20fbca6b974497e630d5dc8934e9" -dependencies = [ - "derive_more", - "ink_env", - "ink_lang_macro", - "ink_metadata", - "ink_prelude", - "ink_primitives", - "ink_storage", - "parity-scale-codec", -] - -[[package]] -name = "ink_lang_codegen" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb3a5de33b59450adc3f61c5eb05b768067c7ab8af9d00f33e284310598168dc" -dependencies = [ - "blake2 0.10.4", - "derive_more", - "either", - "heck 0.4.0", - "impl-serde", - "ink_lang_ir", - "itertools", - "parity-scale-codec", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "ink_lang_ir" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d4d614462280fa06e15b9ca5725d7c8440dde93c8dae1c6f15422f7756cacb" -dependencies = [ - "blake2 0.10.4", - "either", - "itertools", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "ink_lang_macro" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72f85f64141957c5db7cbabbb97a9c16c489e5e9d363e9f147d132a43c71cd29" -dependencies = [ - "ink_lang_codegen", - "ink_lang_ir", - "ink_primitives", - "parity-scale-codec", - "proc-macro2", - "syn", -] - -[[package]] -name = "ink_metadata" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dca6c159a2774f07437c6fd9ea710eb73a6b5e9a031a932bddf08742bf2c081a" -dependencies = [ - "derive_more", - "impl-serde", - "ink_prelude", - "ink_primitives", - "scale-info", - "serde", -] - -[[package]] -name = "ink_prelude" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f7f4dec15e573496c9d2af353e78bde84add391251608f25b5adcf175dc777" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "ink_primitives" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3296dd1c4f4fe12ede7c92d60e6fcb94d46a959ec19c701e4ac588b09e0b4a6" -dependencies = [ - "cfg-if", - "ink_prelude", - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "ink_storage" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ff9b503995a7b41fe201a7a2643ce22f5a11e0b67db7b685424b6d5fe0ecf0b" -dependencies = [ - "array-init", - "cfg-if", - "derive_more", - "ink_env", - "ink_metadata", - "ink_prelude", - "ink_primitives", - "ink_storage_derive", - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "ink_storage_derive" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb68e24e93e8327dda1924868d7ee4dbe01e1ed2b392f28583caa96809b585c" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "synstructure", -] - -[[package]] -name = "itertools" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" - -[[package]] -name = "keccak" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9b7d56ba4a8344d6be9729995e6b06f928af29998cdf79fe390cbf6b1fee838" - -[[package]] -name = "libc" -version = "0.2.126" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" - -[[package]] -name = "num" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606" -dependencies = [ - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ae39348c8bc5fbd7f40c727a9925f03517afd2ab27d46702108b6a7e5414c19" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" -dependencies = [ - "autocfg", -] - -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - -[[package]] -name = "openbrush" -version = "2.1.0" -source = "git+https://github.com/Supercolony-net/openbrush-contracts.git?rev=8a20f95#8a20f951feaf8c6ea72c4bf113bf115bad9f158f" -dependencies = [ - "ink_env", - "ink_lang", - "ink_prelude", - "ink_primitives", - "ink_storage", - "openbrush_contracts", - "openbrush_lang", - "parity-scale-codec", -] - -[[package]] -name = "openbrush_contracts" -version = "2.1.0" -source = "git+https://github.com/Supercolony-net/openbrush-contracts.git?rev=8a20f95#8a20f951feaf8c6ea72c4bf113bf115bad9f158f" -dependencies = [ - "ink_env", - "ink_lang", - "ink_prelude", - "ink_primitives", - "ink_storage", - "openbrush_lang", - "parity-scale-codec", -] - -[[package]] -name = "openbrush_lang" -version = "2.1.0" -source = "git+https://github.com/Supercolony-net/openbrush-contracts.git?rev=8a20f95#8a20f951feaf8c6ea72c4bf113bf115bad9f158f" -dependencies = [ - "const_format", - "ink_env", - "ink_lang", - "ink_primitives", - "ink_storage", - "openbrush_lang_macro", - "parity-scale-codec", - "scale-info", - "sha2-const", -] - -[[package]] -name = "openbrush_lang_codegen" -version = "2.1.0" -source = "git+https://github.com/Supercolony-net/openbrush-contracts.git?rev=8a20f95#8a20f951feaf8c6ea72c4bf113bf115bad9f158f" -dependencies = [ - "blake2 0.9.2", - "cargo_metadata", - "fs2", - "heck 0.3.3", - "ink_lang_ir", - "proc-macro2", - "quote", - "serde", - "serde_json", - "syn", - "synstructure", - "unwrap", -] - -[[package]] -name = "openbrush_lang_macro" -version = "2.1.0" -source = "git+https://github.com/Supercolony-net/openbrush-contracts.git?rev=8a20f95#8a20f951feaf8c6ea72c4bf113bf115bad9f158f" -dependencies = [ - "openbrush_lang_codegen", - "proc-macro2", - "syn", - "synstructure", -] - -[[package]] -name = "parity-scale-codec" -version = "3.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9182e4a71cae089267ab03e67c99368db7cd877baf50f931e5d6d4b71e195ac0" -dependencies = [ - "arrayvec", - "bitvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", - "serde", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9299338969a3d2f491d65f140b00ddec470858402f888af98e8642fb5e8965cd" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "paste" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c520e05135d6e763148b6426a837e239041653ba7becd2e538c076c738025fc" - -[[package]] -name = "pest" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" -dependencies = [ - "ucd-trie", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" - -[[package]] -name = "proc-macro-crate" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" -dependencies = [ - "thiserror", - "toml", -] - -[[package]] -name = "proc-macro2" -version = "1.0.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rlibc" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc874b127765f014d792f16763a81245ab80500e2ad921ed4ee9e82481ee08fe" - -[[package]] -name = "ryu" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" - -[[package]] -name = "scale-info" -version = "2.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c46be926081c9f4dd5dd9b6f1d3e3229f2360bc6502dd8836f84a93b7c75e99a" -dependencies = [ - "bitvec", - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", - "serde", -] - -[[package]] -name = "scale-info-derive" -version = "2.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50e334bb10a245e28e5fd755cabcafd96cfcd167c99ae63a46924ca8d8703a3c" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "secp256k1" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26947345339603ae8395f68e2f3d85a6b0a8ddfe6315818e80b8504415099db0" -dependencies = [ - "secp256k1-sys", -] - -[[package]] -name = "secp256k1-sys" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "152e20a0fd0519390fc43ab404663af8a0b794273d2a91d60ad4a39f13ffe110" -dependencies = [ - "cc", -] - -[[package]] -name = "semver" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" -dependencies = [ - "semver-parser", - "serde", -] - -[[package]] -name = "semver-parser" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" -dependencies = [ - "pest", -] - -[[package]] -name = "serde" -version = "1.0.138" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1578c6245786b9d168c5447eeacfb96856573ca56c9d68fdcf394be134882a47" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.138" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "023e9b1467aef8a10fb88f25611870ada9800ef7e22afce356bb0d2387b6f27c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.82" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82c2c1fdcd807d1098552c5b9a36e425e42e9fbd7c6a37a8425f390f781f7fa7" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "sha2" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest 0.10.3", -] - -[[package]] -name = "sha2-const" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5edcd790916d95ff81bdc1505b09c74d30d47a755929cc8c71c59cbbfa99f91b" - -[[package]] -name = "sha3" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881bf8156c87b6301fc5ca6b27f11eeb2761224c7081e69b409d5a1951a70c86" -dependencies = [ - "digest 0.10.3", - "keccak", -] - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "subtle" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" - -[[package]] -name = "syn" -version = "1.0.98" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "synstructure" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "unicode-xid", -] - -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "thiserror" -version = "1.0.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "ticket_token" -version = "2.1.0" -dependencies = [ - "access_control", - "ink_env", - "ink_lang", - "ink_prelude", - "ink_primitives", - "ink_storage", - "openbrush", - "parity-scale-codec", -] - -[[package]] -name = "toml" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" -dependencies = [ - "serde", -] - -[[package]] -name = "typenum" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" - -[[package]] -name = "ucd-trie" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89570599c4fe5585de2b388aab47e99f7fa4e9238a1399f707a02e356058141c" - -[[package]] -name = "unicode-ident" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" - -[[package]] -name = "unicode-segmentation" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" - -[[package]] -name = "unicode-xid" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" - -[[package]] -name = "unwrap" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e33648dd74328e622c7be51f3b40a303c63f93e6fa5f08778b6203a4c25c20f" - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "wyz" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b31594f29d27036c383b53b59ed3476874d518f0efb151b27a4c275141390e" -dependencies = [ - "tap", -] diff --git a/contracts/early_bird_special/Cargo.toml b/contracts/early_bird_special/Cargo.toml deleted file mode 100644 index ab2186de46..0000000000 --- a/contracts/early_bird_special/Cargo.toml +++ /dev/null @@ -1,44 +0,0 @@ -[package] -name = "early_bird_special" -version = "0.1.0" -authors = ["Cardinal Cryptography"] -edition = "2021" -license = "Apache 2.0" - -[dependencies] -ink_env = { version = "~3.3.0", default-features = false } -ink_lang = { version = "~3.3.0", default-features = false } -ink_lang_codegen = { version = "~3.3.0", default-features = false } -ink_metadata = { version = "~3.3.0", default-features = false, features = ["derive"], optional = true } -ink_prelude = { version = "~3.3.0", default-features = false } -ink_primitives = { version = "~3.3.0", default-features = false } -ink_storage = { version = "~3.3.0", default-features = false } - -scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } -scale-info = { version = "2", default-features = false, features = ["derive"], optional = true } - -button = { path = "../button", default-features = false } -access_control = { path = "../access_control", default-features = false, features = ["ink-as-dependency"] } - -[lib] -name = "early_bird_special" -path = "lib.rs" -crate-type = [ - # Used for normal contract Wasm blobs. - "cdylib", -] - -[features] -default = ["std"] -std = [ - "button/std", - "ink_env/std", - "ink_lang_codegen/std", - "ink_metadata/std", - "ink_prelude/std", - "ink_primitives/std", - "ink_storage/std", - "scale-info/std", - "scale/std", -] -ink-as-dependency = [] diff --git a/contracts/early_bird_special/lib.rs b/contracts/early_bird_special/lib.rs deleted file mode 100644 index 00461a84a3..0000000000 --- a/contracts/early_bird_special/lib.rs +++ /dev/null @@ -1,238 +0,0 @@ -#![cfg_attr(not(feature = "std"), no_std)] - -use ink_lang as ink; - -/// This is the EarlyBirdSpecial -/// -/// Larger rewards are distributed for engaging in the game as early on as possible: -/// user_score = deadline - now -/// On the other hand ThePressiah (the last player to click) gets 20% of the token pool, which creates two competing strategies. - -#[ink::contract] -mod early_bird_special { - - use access_control::{traits::AccessControlled, Role, ACCESS_CONTROL_PUBKEY}; - use button::{ButtonData, ButtonGame, ButtonResult, GameError, IButtonGame}; - use ink_env::{DefaultEnvironment, Error as InkEnvError}; - use ink_lang::{ - codegen::{initialize_contract, EmitEvent}, - reflect::ContractEventBase, - }; - use ink_prelude::format; - use ink_storage::traits::SpreadAllocate; - - /// Event type - type Event = ::Type; - - /// Event emitted when TheButton is created - #[ink(event)] - #[derive(Debug)] - pub struct ButtonCreated { - #[ink(topic)] - reward_token: AccountId, - #[ink(topic)] - ticket_token: AccountId, - start: BlockNumber, - deadline: BlockNumber, - } - - /// Event emitted when TheButton is pressed - #[ink(event)] - #[derive(Debug)] - pub struct ButtonPressed { - #[ink(topic)] - by: AccountId, - when: BlockNumber, - } - - /// Event emitted when a players reward is claimed - #[ink(event)] - #[derive(Debug)] - pub struct GameReset { - when: BlockNumber, - } - - #[ink(storage)] - #[derive(SpreadAllocate)] - pub struct EarlyBirdSpecial { - data: ButtonData, - } - - impl AccessControlled for EarlyBirdSpecial { - type ContractError = GameError; - } - - impl ButtonGame for EarlyBirdSpecial { - fn get(&self) -> &ButtonData { - &self.data - } - - fn get_mut(&mut self) -> &mut ButtonData { - &mut self.data - } - - fn score(&self, now: BlockNumber) -> Balance { - let deadline = ButtonGame::deadline(self); - deadline.saturating_sub(now) as Balance - } - } - - // because ink! does not allow generics or trait default implementations - impl IButtonGame for EarlyBirdSpecial { - #[ink(message)] - fn is_dead(&self) -> bool { - let now = self.env().block_number(); - ButtonGame::is_dead(self, now) - } - - #[ink(message)] - fn press(&mut self) -> ButtonResult<()> { - let caller = self.env().caller(); - let now = Self::env().block_number(); - let this = self.env().account_id(); - - ButtonGame::press::(self, now, caller, this)?; - - Self::emit_event( - self.env(), - Event::ButtonPressed(ButtonPressed { - by: caller, - when: now, - }), - ); - - Ok(()) - } - - #[ink(message)] - fn reset(&mut self) -> ButtonResult<()> { - let now = Self::env().block_number(); - - ButtonGame::reset::(self, now)?; - - Self::emit_event(self.env(), Event::GameReset(GameReset { when: now })); - Ok(()) - } - - #[ink(message)] - fn deadline(&self) -> BlockNumber { - ButtonGame::deadline(self) - } - - #[ink(message)] - fn access_control(&self) -> AccountId { - ButtonGame::access_control(self) - } - - #[ink(message)] - fn last_presser(&self) -> Option { - ButtonGame::last_presser(self) - } - - #[ink(message)] - fn reward_token(&self) -> AccountId { - ButtonGame::reward_token(self) - } - - #[ink(message)] - fn ticket_token(&self) -> AccountId { - ButtonGame::ticket_token(self) - } - - #[ink(message)] - fn balance(&self) -> ButtonResult { - let this = self.env().account_id(); - ButtonGame::balance::(self, this) - } - - #[ink(message)] - fn set_access_control(&mut self, new_access_control: AccountId) -> ButtonResult<()> { - let caller = self.env().caller(); - let this = self.env().account_id(); - ButtonGame::set_access_control(self, new_access_control, caller, this) - } - - #[ink(message)] - fn terminate(&mut self) -> ButtonResult<()> { - let caller = self.env().caller(); - let this = self.env().account_id(); - let required_role = Role::Owner(this); - self.check_role(caller, required_role)?; - self.env().terminate_contract(caller) - } - } - - impl EarlyBirdSpecial { - #[ink(constructor)] - pub fn new( - ticket_token: AccountId, - reward_token: AccountId, - button_lifetime: BlockNumber, - ) -> Self { - let caller = Self::env().caller(); - let code_hash = Self::env() - .own_code_hash() - .expect("Called new on a contract with no code hash"); - let required_role = Role::Initializer(code_hash); - let access_control = AccountId::from(ACCESS_CONTROL_PUBKEY); - - let role_check = ::check_role( - access_control, - caller, - required_role, - |why: InkEnvError| { - GameError::ContractCall(format!("Calling access control has failed: {:?}", why)) - }, - |role: Role| GameError::MissingRole(format!("{:?}", role)), - ); - - match role_check { - Ok(_) => initialize_contract(|contract| { - Self::new_init(contract, ticket_token, reward_token, button_lifetime) - }), - Err(why) => panic!("Could not initialize the contract {:?}", why), - } - } - - fn new_init( - &mut self, - ticket_token: AccountId, - reward_token: AccountId, - button_lifetime: BlockNumber, - ) { - let now = Self::env().block_number(); - let deadline = now + button_lifetime; - - self.data.access_control = AccountId::from(ACCESS_CONTROL_PUBKEY); - self.data.button_lifetime = button_lifetime; - self.data.reward_token = reward_token; - self.data.ticket_token = ticket_token; - self.data.last_press = now; - - Self::emit_event( - Self::env(), - Event::ButtonCreated(ButtonCreated { - start: now, - deadline, - ticket_token, - reward_token, - }), - ) - } - - fn emit_event(emitter: EE, event: Event) - where - EE: EmitEvent, - { - emitter.emit_event(event); - } - - /// Returns own code hash - #[ink(message)] - pub fn code_hash(&self) -> ButtonResult { - self.env().own_code_hash().map_err(|why| { - GameError::ContractCall(format!("Can't retrieve own code hash: {:?}", why)) - }) - } - } -} diff --git a/contracts/the_pressiah_cometh/Cargo.lock b/contracts/the_pressiah_cometh/Cargo.lock deleted file mode 100644 index ba376826b9..0000000000 --- a/contracts/the_pressiah_cometh/Cargo.lock +++ /dev/null @@ -1,1103 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "access_control" -version = "0.1.0" -dependencies = [ - "ink_env", - "ink_lang", - "ink_lang_codegen", - "ink_primitives", - "ink_storage", - "parity-scale-codec", -] - -[[package]] -name = "array-init" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfb6d71005dc22a708c7496eee5c8dc0300ee47355de6256c3b35b12b5fef596" - -[[package]] -name = "arrayref" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" - -[[package]] -name = "arrayvec" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - -[[package]] -name = "blake2" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a4e37d16930f5459780f5621038b6382b9bb37c19016f39fb6b5808d831f174" -dependencies = [ - "crypto-mac", - "digest 0.9.0", - "opaque-debug", -] - -[[package]] -name = "blake2" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9cf849ee05b2ee5fba5e36f97ff8ec2533916700fc0758d40d92136a42f3388" -dependencies = [ - "digest 0.10.3", -] - -[[package]] -name = "block-buffer" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" -dependencies = [ - "generic-array", -] - -[[package]] -name = "button" -version = "0.1.0" -dependencies = [ - "access_control", - "game_token", - "ink_env", - "ink_lang", - "ink_metadata", - "ink_prelude", - "ink_primitives", - "ink_storage", - "num", - "openbrush", - "parity-scale-codec", - "scale-info", - "ticket_token", -] - -[[package]] -name = "byte-slice-cast" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87c5fdd0166095e1d463fc6cc01aa8ce547ad77a4e84d42eb6762b084e28067e" - -[[package]] -name = "camino" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "869119e97797867fd90f5e22af7d0bd274bd4635ebb9eb68c04f3f513ae6c412" -dependencies = [ - "serde", -] - -[[package]] -name = "cargo-platform" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" -dependencies = [ - "serde", -] - -[[package]] -name = "cargo_metadata" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "081e3f0755c1f380c2d010481b6fa2e02973586d5f2b24eebb7a2a1d98b143d8" -dependencies = [ - "camino", - "cargo-platform", - "semver", - "semver-parser", - "serde", - "serde_json", -] - -[[package]] -name = "cc" -version = "1.0.73" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "const_format" -version = "0.2.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "939dc9e2eb9077e0679d2ce32de1ded8531779360b003b4a972a7a39ec263495" -dependencies = [ - "const_format_proc_macros", -] - -[[package]] -name = "const_format_proc_macros" -version = "0.2.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef196d5d972878a48da7decb7686eded338b4858fbabeed513d63a7c98b2b82d" -dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", -] - -[[package]] -name = "cpufeatures" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" -dependencies = [ - "libc", -] - -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "crypto-mac" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" -dependencies = [ - "generic-array", - "subtle", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array", -] - -[[package]] -name = "digest" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" -dependencies = [ - "block-buffer", - "crypto-common", - "subtle", -] - -[[package]] -name = "either" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be" - -[[package]] -name = "fs2" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - -[[package]] -name = "game_token" -version = "2.1.0" -dependencies = [ - "access_control", - "ink_env", - "ink_lang", - "ink_prelude", - "ink_primitives", - "ink_storage", - "openbrush", - "parity-scale-codec", -] - -[[package]] -name = "generic-array" -version = "0.14.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "getrandom" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "heck" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" -dependencies = [ - "unicode-segmentation", -] - -[[package]] -name = "heck" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" - -[[package]] -name = "impl-serde" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4551f042f3438e64dbd6226b20527fc84a6e1fe65688b58746a2f53623f25f5c" -dependencies = [ - "serde", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "ink_allocator" -version = "3.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a291f411e310b7a3bb01ce21102b8c0aea5b7b523e4bad0b40a8e55a76c58906" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "ink_engine" -version = "3.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "075eab468da2937288ec484be920cb18614147003d7f1afbdfcfb190ed771c46" -dependencies = [ - "blake2 0.10.4", - "derive_more", - "parity-scale-codec", - "rand", - "secp256k1", - "sha2", - "sha3", -] - -[[package]] -name = "ink_env" -version = "3.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271689b643d7ccf2bcd09d7ef07eda79cd3366ee042d5bbfcebf534b08da79d7" -dependencies = [ - "arrayref", - "blake2 0.10.4", - "cfg-if", - "derive_more", - "ink_allocator", - "ink_engine", - "ink_metadata", - "ink_prelude", - "ink_primitives", - "num-traits", - "parity-scale-codec", - "paste", - "rand", - "rlibc", - "scale-info", - "secp256k1", - "sha2", - "sha3", - "static_assertions", -] - -[[package]] -name = "ink_lang" -version = "3.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62cf662fe6a130ea1ada3520142405e3ed521b79c35b7274cc95dd37bc833571" -dependencies = [ - "derive_more", - "ink_env", - "ink_lang_macro", - "ink_metadata", - "ink_prelude", - "ink_primitives", - "ink_storage", - "parity-scale-codec", -] - -[[package]] -name = "ink_lang_codegen" -version = "3.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94dc22732ced2557f0411de5fa31d6fddc3878968041b699ae16ed1c390d2660" -dependencies = [ - "blake2 0.10.4", - "derive_more", - "either", - "heck 0.4.0", - "impl-serde", - "ink_lang_ir", - "itertools", - "parity-scale-codec", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "ink_lang_ir" -version = "3.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a089bcac8d7e6a487b7a18ea8a1d20eb540ed26657706ac221cc0e8239047e45" -dependencies = [ - "blake2 0.10.4", - "either", - "itertools", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "ink_lang_macro" -version = "3.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1330da0b8007b86de94f95fbc74769c0461d3b078b291af5497771598db1c5b4" -dependencies = [ - "ink_lang_codegen", - "ink_lang_ir", - "ink_primitives", - "parity-scale-codec", - "proc-macro2", - "syn", -] - -[[package]] -name = "ink_metadata" -version = "3.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d442f4f5dcbf120aa84cae9e399065ad99d143d5a920b06d3da286e91c03ec70" -dependencies = [ - "derive_more", - "impl-serde", - "ink_prelude", - "ink_primitives", - "scale-info", - "serde", -] - -[[package]] -name = "ink_prelude" -version = "3.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e38d71af62cfec3425727d28665a947d636c3be6ae71ac3a79868ef8a08633f3" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "ink_primitives" -version = "3.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea7afd5330a9d3be1533222a48b8ab44b3a3356a5e6bb090bff0790aa562b418" -dependencies = [ - "cfg-if", - "ink_prelude", - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "ink_storage" -version = "3.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be827b98c102c413b2309075f0835a9bb8c6325fc6aa09e66963424db7a8bcb5" -dependencies = [ - "array-init", - "cfg-if", - "derive_more", - "ink_env", - "ink_metadata", - "ink_prelude", - "ink_primitives", - "ink_storage_derive", - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "ink_storage_derive" -version = "3.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ced452d5d0b2268b1257ffd2ec73cf9c3b4fba5f3632f185a03aafec8888439" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "synstructure", -] - -[[package]] -name = "itertools" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" - -[[package]] -name = "keccak" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9b7d56ba4a8344d6be9729995e6b06f928af29998cdf79fe390cbf6b1fee838" - -[[package]] -name = "libc" -version = "0.2.129" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64de3cc433455c14174d42e554d4027ee631c4d046d43e3ecc6efc4636cdc7a7" - -[[package]] -name = "num" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606" -dependencies = [ - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ae39348c8bc5fbd7f40c727a9925f03517afd2ab27d46702108b6a7e5414c19" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" -dependencies = [ - "autocfg", -] - -[[package]] -name = "once_cell" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" - -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - -[[package]] -name = "openbrush" -version = "2.1.0" -source = "git+https://github.com/Supercolony-net/openbrush-contracts.git?rev=8a20f95#8a20f951feaf8c6ea72c4bf113bf115bad9f158f" -dependencies = [ - "ink_env", - "ink_lang", - "ink_prelude", - "ink_primitives", - "ink_storage", - "openbrush_contracts", - "openbrush_lang", - "parity-scale-codec", -] - -[[package]] -name = "openbrush_contracts" -version = "2.1.0" -source = "git+https://github.com/Supercolony-net/openbrush-contracts.git?rev=8a20f95#8a20f951feaf8c6ea72c4bf113bf115bad9f158f" -dependencies = [ - "ink_env", - "ink_lang", - "ink_prelude", - "ink_primitives", - "ink_storage", - "openbrush_lang", - "parity-scale-codec", -] - -[[package]] -name = "openbrush_lang" -version = "2.1.0" -source = "git+https://github.com/Supercolony-net/openbrush-contracts.git?rev=8a20f95#8a20f951feaf8c6ea72c4bf113bf115bad9f158f" -dependencies = [ - "const_format", - "ink_env", - "ink_lang", - "ink_primitives", - "ink_storage", - "openbrush_lang_macro", - "parity-scale-codec", - "scale-info", - "sha2-const", -] - -[[package]] -name = "openbrush_lang_codegen" -version = "2.1.0" -source = "git+https://github.com/Supercolony-net/openbrush-contracts.git?rev=8a20f95#8a20f951feaf8c6ea72c4bf113bf115bad9f158f" -dependencies = [ - "blake2 0.9.2", - "cargo_metadata", - "fs2", - "heck 0.3.3", - "ink_lang_ir", - "proc-macro2", - "quote", - "serde", - "serde_json", - "syn", - "synstructure", - "unwrap", -] - -[[package]] -name = "openbrush_lang_macro" -version = "2.1.0" -source = "git+https://github.com/Supercolony-net/openbrush-contracts.git?rev=8a20f95#8a20f951feaf8c6ea72c4bf113bf115bad9f158f" -dependencies = [ - "openbrush_lang_codegen", - "proc-macro2", - "syn", - "synstructure", -] - -[[package]] -name = "parity-scale-codec" -version = "3.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9182e4a71cae089267ab03e67c99368db7cd877baf50f931e5d6d4b71e195ac0" -dependencies = [ - "arrayvec", - "bitvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", - "serde", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9299338969a3d2f491d65f140b00ddec470858402f888af98e8642fb5e8965cd" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "paste" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9423e2b32f7a043629287a536f21951e8c6a82482d0acb1eeebfc90bc2225b22" - -[[package]] -name = "pest" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69486e2b8c2d2aeb9762db7b4e00b0331156393555cff467f4163ff06821eef8" -dependencies = [ - "thiserror", - "ucd-trie", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" - -[[package]] -name = "proc-macro-crate" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9" -dependencies = [ - "once_cell", - "thiserror", - "toml", -] - -[[package]] -name = "proc-macro2" -version = "1.0.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rlibc" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc874b127765f014d792f16763a81245ab80500e2ad921ed4ee9e82481ee08fe" - -[[package]] -name = "ryu" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" - -[[package]] -name = "scale-info" -version = "2.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c46be926081c9f4dd5dd9b6f1d3e3229f2360bc6502dd8836f84a93b7c75e99a" -dependencies = [ - "bitvec", - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", - "serde", -] - -[[package]] -name = "scale-info-derive" -version = "2.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50e334bb10a245e28e5fd755cabcafd96cfcd167c99ae63a46924ca8d8703a3c" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "secp256k1" -version = "0.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7649a0b3ffb32636e60c7ce0d70511eda9c52c658cd0634e194d5a19943aeff" -dependencies = [ - "secp256k1-sys", -] - -[[package]] -name = "secp256k1-sys" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7058dc8eaf3f2810d7828680320acda0b25a288f6d288e19278e249bbf74226b" -dependencies = [ - "cc", -] - -[[package]] -name = "semver" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" -dependencies = [ - "semver-parser", - "serde", -] - -[[package]] -name = "semver-parser" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" -dependencies = [ - "pest", -] - -[[package]] -name = "serde" -version = "1.0.143" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53e8e5d5b70924f74ff5c6d64d9a5acd91422117c60f48c4e07855238a254553" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.143" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3d8e8de557aee63c26b85b947f5e59b690d0454c753f3adeb5cd7835ab88391" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38dd04e3c8279e75b31ef29dbdceebfe5ad89f4d0937213c53f7d49d01b3d5a7" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "sha2" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest 0.10.3", -] - -[[package]] -name = "sha2-const" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5edcd790916d95ff81bdc1505b09c74d30d47a755929cc8c71c59cbbfa99f91b" - -[[package]] -name = "sha3" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a31480366ec990f395a61b7c08122d99bd40544fdb5abcfc1b06bb29994312c" -dependencies = [ - "digest 0.10.3", - "keccak", -] - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "subtle" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" - -[[package]] -name = "syn" -version = "1.0.99" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "synstructure" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "unicode-xid", -] - -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "the_pressiah_cometh" -version = "0.1.0" -dependencies = [ - "access_control", - "button", - "ink_env", - "ink_lang", - "ink_lang_codegen", - "ink_metadata", - "ink_prelude", - "ink_primitives", - "ink_storage", - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "thiserror" -version = "1.0.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5f6586b7f764adc0231f4c79be7b920e766bb2f3e51b3661cdb263828f19994" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12bafc5b54507e0149cdf1b145a5d80ab80a90bcd9275df43d4fff68460f6c21" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "ticket_token" -version = "2.1.0" -dependencies = [ - "access_control", - "ink_env", - "ink_lang", - "ink_prelude", - "ink_primitives", - "ink_storage", - "openbrush", - "parity-scale-codec", -] - -[[package]] -name = "toml" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" -dependencies = [ - "serde", -] - -[[package]] -name = "typenum" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" - -[[package]] -name = "ucd-trie" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89570599c4fe5585de2b388aab47e99f7fa4e9238a1399f707a02e356058141c" - -[[package]] -name = "unicode-ident" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf" - -[[package]] -name = "unicode-segmentation" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" - -[[package]] -name = "unicode-xid" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" - -[[package]] -name = "unwrap" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e33648dd74328e622c7be51f3b40a303c63f93e6fa5f08778b6203a4c25c20f" - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "wyz" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b31594f29d27036c383b53b59ed3476874d518f0efb151b27a4c275141390e" -dependencies = [ - "tap", -] diff --git a/contracts/the_pressiah_cometh/Cargo.toml b/contracts/the_pressiah_cometh/Cargo.toml deleted file mode 100644 index 9d01e66e6d..0000000000 --- a/contracts/the_pressiah_cometh/Cargo.toml +++ /dev/null @@ -1,44 +0,0 @@ -[package] -name = "the_pressiah_cometh" -version = "0.1.0" -authors = ["Cardinal Cryptography"] -edition = "2021" -license = "Apache 2.0" - -[dependencies] -ink_env = { version = "~3.3.0", default-features = false } -ink_lang = { version = "~3.3.0", default-features = false } -ink_lang_codegen = { version = "~3.3.0", default-features = false } -ink_metadata = { version = "~3.3.0", default-features = false, features = ["derive"], optional = true } -ink_prelude = { version = "~3.3.0", default-features = false } -ink_primitives = { version = "~3.3.0", default-features = false } -ink_storage = { version = "~3.3.0", default-features = false } - -scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } -scale-info = { version = "2", default-features = false, features = ["derive"], optional = true } - -button = { path = "../button", default-features = false } -access_control = { path = "../access_control", default-features = false, features = ["ink-as-dependency"] } - -[lib] -name = "the_pressiah_cometh" -path = "lib.rs" -crate-type = [ - # Used for normal contract Wasm blobs. - "cdylib", -] - -[features] -default = ["std"] -std = [ - "button/std", - "ink_env/std", - "ink_lang_codegen/std", - "ink_metadata/std", - "ink_prelude/std", - "ink_primitives/std", - "ink_storage/std", - "scale-info/std", - "scale/std", -] -ink-as-dependency = [] diff --git a/contracts/the_pressiah_cometh/lib.rs b/contracts/the_pressiah_cometh/lib.rs deleted file mode 100644 index f35834f846..0000000000 --- a/contracts/the_pressiah_cometh/lib.rs +++ /dev/null @@ -1,237 +0,0 @@ -#![cfg_attr(not(feature = "std"), no_std)] - -use ink_lang as ink; - -/// This is the ThePressiahCometh -/// -/// The reward for each click grows with the amount of previous participants. -/// n-th person to click the button gets n tokens. -/// ThePressiah (the last player to click) gets 20% of the tokens. - -#[ink::contract] -mod the_pressiah_cometh { - - use access_control::{traits::AccessControlled, Role, ACCESS_CONTROL_PUBKEY}; - use button::{ButtonData, ButtonGame, ButtonResult, GameError, IButtonGame}; - use ink_env::{DefaultEnvironment, Error as InkEnvError}; - use ink_lang::{ - codegen::{initialize_contract, EmitEvent}, - reflect::ContractEventBase, - }; - use ink_prelude::format; - use ink_storage::traits::SpreadAllocate; - - /// Event type - type Event = ::Type; - - /// Event emitted when TheButton is created - #[ink(event)] - #[derive(Debug)] - pub struct ButtonCreated { - #[ink(topic)] - reward_token: AccountId, - #[ink(topic)] - ticket_token: AccountId, - start: BlockNumber, - deadline: BlockNumber, - } - - /// Event emitted when TheButton is pressed - #[ink(event)] - #[derive(Debug)] - pub struct ButtonPressed { - #[ink(topic)] - by: AccountId, - when: BlockNumber, - } - - /// Event emitted when a players reward is claimed - #[ink(event)] - #[derive(Debug)] - pub struct GameReset { - when: BlockNumber, - } - - #[ink(storage)] - #[derive(SpreadAllocate)] - pub struct ThePressiahCometh { - data: ButtonData, - } - - impl AccessControlled for ThePressiahCometh { - type ContractError = GameError; - } - - impl ButtonGame for ThePressiahCometh { - fn get(&self) -> &ButtonData { - &self.data - } - - fn get_mut(&mut self) -> &mut ButtonData { - &mut self.data - } - - fn score(&self, _now: BlockNumber) -> Balance { - (self.data.presses + 1) as Balance - } - } - - // because ink! does not allow generics or trait default implementations - impl IButtonGame for ThePressiahCometh { - #[ink(message)] - fn is_dead(&self) -> bool { - let now = self.env().block_number(); - ButtonGame::is_dead(self, now) - } - - #[ink(message)] - fn press(&mut self) -> ButtonResult<()> { - let caller = self.env().caller(); - let now = Self::env().block_number(); - let this = self.env().account_id(); - - ButtonGame::press::(self, now, caller, this)?; - - Self::emit_event( - self.env(), - Event::ButtonPressed(ButtonPressed { - by: caller, - when: now, - }), - ); - - Ok(()) - } - - #[ink(message)] - fn reset(&mut self) -> ButtonResult<()> { - let now = Self::env().block_number(); - - ButtonGame::reset::(self, now)?; - - Self::emit_event(self.env(), Event::GameReset(GameReset { when: now })); - Ok(()) - } - - #[ink(message)] - fn deadline(&self) -> BlockNumber { - ButtonGame::deadline(self) - } - - #[ink(message)] - fn access_control(&self) -> AccountId { - ButtonGame::access_control(self) - } - - #[ink(message)] - fn last_presser(&self) -> Option { - ButtonGame::last_presser(self) - } - - #[ink(message)] - fn reward_token(&self) -> AccountId { - ButtonGame::reward_token(self) - } - - #[ink(message)] - fn ticket_token(&self) -> AccountId { - ButtonGame::ticket_token(self) - } - - #[ink(message)] - fn balance(&self) -> ButtonResult { - let this = self.env().account_id(); - ButtonGame::balance::(self, this) - } - - #[ink(message)] - fn set_access_control(&mut self, new_access_control: AccountId) -> ButtonResult<()> { - let caller = self.env().caller(); - let this = self.env().account_id(); - ButtonGame::set_access_control(self, new_access_control, caller, this) - } - - #[ink(message)] - fn terminate(&mut self) -> ButtonResult<()> { - let caller = self.env().caller(); - let this = self.env().account_id(); - let required_role = Role::Owner(this); - self.check_role(caller, required_role)?; - self.env().terminate_contract(caller) - } - } - - impl ThePressiahCometh { - #[ink(constructor)] - pub fn new( - ticket_token: AccountId, - reward_token: AccountId, - button_lifetime: BlockNumber, - ) -> Self { - let caller = Self::env().caller(); - let code_hash = Self::env() - .own_code_hash() - .expect("Called new on a contract with no code hash"); - let required_role = Role::Initializer(code_hash); - let access_control = AccountId::from(ACCESS_CONTROL_PUBKEY); - - let role_check = ::check_role( - access_control, - caller, - required_role, - |why: InkEnvError| { - GameError::ContractCall(format!("Calling access control has failed: {:?}", why)) - }, - |role: Role| GameError::MissingRole(format!("{:?}", role)), - ); - - match role_check { - Ok(_) => initialize_contract(|contract| { - Self::new_init(contract, ticket_token, reward_token, button_lifetime) - }), - Err(why) => panic!("Could not initialize the contract {:?}", why), - } - } - - fn new_init( - &mut self, - ticket_token: AccountId, - reward_token: AccountId, - button_lifetime: BlockNumber, - ) { - let now = Self::env().block_number(); - let deadline = now + button_lifetime; - - self.data.access_control = AccountId::from(ACCESS_CONTROL_PUBKEY); - self.data.button_lifetime = button_lifetime; - self.data.reward_token = reward_token; - self.data.ticket_token = ticket_token; - self.data.last_press = now; - - Self::emit_event( - Self::env(), - Event::ButtonCreated(ButtonCreated { - start: now, - deadline, - ticket_token, - reward_token, - }), - ) - } - - fn emit_event(emitter: EE, event: Event) - where - EE: EmitEvent, - { - emitter.emit_event(event); - } - - /// Returns own code hash - #[ink(message)] - pub fn code_hash(&self) -> ButtonResult { - self.env().own_code_hash().map_err(|why| { - GameError::ContractCall(format!("Can't retrieve own code hash: {:?}", why)) - }) - } - } -} From eee093d7c914859cbf8d2e3d557173a020fd5a51 Mon Sep 17 00:00:00 2001 From: Michal Handzlik Date: Wed, 17 Aug 2022 17:55:12 +0200 Subject: [PATCH 3/7] Missing comment --- contracts/button/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contracts/button/lib.rs b/contracts/button/lib.rs index 89ab1fd948..b00e20f794 100644 --- a/contracts/button/lib.rs +++ b/contracts/button/lib.rs @@ -175,6 +175,9 @@ mod button_game { }) } + /// Presses the button + /// + /// If called on alive button, instantaneously mints reward tokens to the caller #[ink(message)] pub fn press(&mut self) -> ButtonResult<()> { if self.is_dead() { From f2d747b65e4a0fda23c5d632ce6f6af8dd63d3b9 Mon Sep 17 00:00:00 2001 From: Michal Handzlik Date: Wed, 17 Aug 2022 18:14:55 +0200 Subject: [PATCH 4/7] Update the deployment script --- contracts/scripts/deploy.sh | 198 +++++++++++++++--------------------- 1 file changed, 84 insertions(+), 114 deletions(-) diff --git a/contracts/scripts/deploy.sh b/contracts/scripts/deploy.sh index 7d3dab1eda..e6e73a955b 100755 --- a/contracts/scripts/deploy.sh +++ b/contracts/scripts/deploy.sh @@ -4,52 +4,83 @@ set -euo pipefail # --- FUNCTIONS -function instrument_ticket_token { +function upload_contract { local __resultvar=$1 local contract_name=$2 - local salt=$3 - local token_name=$4 - local token_symbol=$5 - - # --- CREATE AN INSTANCE OF THE TOKEN CONTRACT cd "$CONTRACTS_PATH"/$contract_name - local contract_address=$(cargo contract instantiate --url $NODE --constructor new --args \"$token_name\" \"$token_symbol\" $TOTAL_BALANCE --suri "$AUTHORITY_SEED" --salt $salt) + # --- REPLACE THE ADDRESS OF ACCESS CONTROL CONTRACT + + # replace address placeholder with the on-chain address of the AccessControl contract + link_bytecode $contract_name 4465614444656144446561444465614444656144446561444465614444656144 $ACCESS_CONTROL_PUBKEY + # remove just in case + rm target/ink/$contract_name.wasm + # NOTE : here we go from hex to binary using a nodejs cli tool + # availiable from https://github.com/fbielejec/polkadot-cljs + node ../scripts/hex-to-wasm.js target/ink/$contract_name.contract target/ink/$contract_name.wasm + + # --- UPLOAD CONTRACT CODE + + code_hash=$(cargo contract upload --url "$NODE" --suri "$AUTHORITY_SEED") + code_hash=$(echo "$code_hash" | grep hash | tail -1 | cut -c 15-) + + echo "$contract_name code hash: $code_hash" + + # --- GRANT PRIVILEGES ON THE TICKET CONTRACT + + cd "$CONTRACTS_PATH"/access_control + + # set the initializer of the token contract + cargo contract call --url "$NODE" --contract "$ACCESS_CONTROL" --message grant_role --args "$AUTHORITY" 'Initializer('"$code_hash"')' --suri "$AUTHORITY_SEED" + + eval $__resultvar="'$code_hash'" +} + +function deploy_ticket_token { + + local __resultvar=$1 + local token_name=$2 + local token_symbol=$3 + local salt=$4 + + # --- CREATE AN INSTANCE OF THE TICKET CONTRACT + + cd "$CONTRACTS_PATH"/ticket_token + local contract_address=$(cargo contract instantiate --url "$NODE" --constructor new --args \"$token_name\" \"$token_symbol\" "$TOTAL_BALANCE" --suri "$AUTHORITY_SEED" --salt "$salt") local contract_address=$(echo "$contract_address" | grep Contract | tail -1 | cut -c 15-) - echo $contract_name "ticket contract instance address: " $contract_address + echo "$token_symbol ticket contract instance address: $contract_address" - # --- GRANT PRIVILEGES ON THE TOKEN CONTRACT + # --- GRANT PRIVILEGES ON THE TICKET CONTRACT cd "$CONTRACTS_PATH"/access_control # set the admin and the owner of the contract instance - cargo contract call --url $NODE --contract $ACCESS_CONTROL --message grant_role --args $AUTHORITY 'Owner('$contract_address')' --suri "$AUTHORITY_SEED" + cargo contract call --url "$NODE" --contract "$ACCESS_CONTROL" --message grant_role --args "$AUTHORITY" 'Owner('"$contract_address"')' --suri "$AUTHORITY_SEED" eval $__resultvar="'$contract_address'" } -function instrument_game_token { + +function deploy_game_token { local __resultvar=$1 - local contract_name=$2 - local token_name=\"$3\" - local token_symbol=\"$4\" - local salt=$5 + local token_name=$2 + local token_symbol=$3 + local salt=$4 # --- CREATE AN INSTANCE OF THE TOKEN CONTRACT - cd "$CONTRACTS_PATH"/"$contract_name" + cd "$CONTRACTS_PATH"/game_token - local contract_address # TODO : remove balance when token is mintable - contract_address=$(cargo contract instantiate --url "$NODE" --constructor new --args "$token_name" "$token_symbol" "$TOTAL_BALANCE" --suri "$AUTHORITY_SEED" --salt "$salt") - contract_address=$(echo "$contract_address" | grep Contract | tail -1 | cut -c 15-) + local contract_address=$(cargo contract instantiate --url "$NODE" --constructor new --args \"$token_name\" \"$token_symbol\" "$TOTAL_BALANCE" --suri "$AUTHORITY_SEED" --salt "$salt") + local contract_address=$(echo "$contract_address" | grep Contract | tail -1 | cut -c 15-) - echo "$contract_name token contract instance address: $contract_address" + echo "$token_symbol token contract instance address: $contract_address" # --- GRANT PRIVILEGES ON THE TOKEN CONTRACT @@ -63,48 +94,34 @@ function instrument_game_token { eval "$__resultvar='$contract_address'" } -function deploy_and_instrument_game { + +function deploy_button_game { local __resultvar=$1 - local contract_name=$2 + local game_type=$2 local ticket_token=$3 local game_token=$4 - - # --- UPLOAD CONTRACT CODE - - cd "$CONTRACTS_PATH/$contract_name" - link_bytecode "$contract_name" 4465614444656144446561444465614444656144446561444465614444656144 "$ACCESS_CONTROL_PUBKEY" - rm target/ink/"$contract_name".wasm - node ../scripts/hex-to-wasm.js target/ink/"$contract_name".contract target/ink/"$contract_name".wasm - - local code_hash - code_hash=$(cargo contract upload --url "$NODE" --suri "$AUTHORITY_SEED") - code_hash=$(echo "$code_hash" | grep hash | tail -1 | cut -c 15-) - - # --- GRANT INIT PRIVILEGES ON THE CONTRACT CODE - - cd "$CONTRACTS_PATH"/access_control - - cargo contract call --url "$NODE" --contract "$ACCESS_CONTROL" --message grant_role --args "$AUTHORITY" 'Initializer('"$code_hash"')' --suri "$AUTHORITY_SEED" + local salt=$5 # --- CREATE AN INSTANCE OF THE CONTRACT - cd "$CONTRACTS_PATH/$contract_name" + cd "$CONTRACTS_PATH"/button - local contract_address=$(cargo contract instantiate --url $NODE --constructor new --args $ticket_token $game_token $LIFETIME --suri "$AUTHORITY_SEED") + local contract_address=$(cargo contract instantiate --url "$NODE" --constructor new --args "$ticket_token" "$game_token" "$LIFETIME" "$game_type" --suri "$AUTHORITY_SEED" --salt "$salt") local contract_address=$(echo "$contract_address" | grep Contract | tail -1 | cut -c 15-) - echo "$contract_name contract instance address: $contract_address" + echo "$game_type contract instance address: $contract_address" # --- GRANT PRIVILEGES ON THE CONTRACT cd "$CONTRACTS_PATH"/access_control - cargo contract call --url $NODE --contract $ACCESS_CONTROL --message grant_role --args $AUTHORITY 'Owner('$contract_address')' --suri "$AUTHORITY_SEED" + cargo contract call --url "$NODE" --contract "$ACCESS_CONTROL" --message grant_role --args "$AUTHORITY" 'Owner('"$contract_address"')' --suri "$AUTHORITY_SEED" eval "$__resultvar='$contract_address'" } + function link_bytecode() { local contract=$1 local placeholder=$2 @@ -113,12 +130,14 @@ function link_bytecode() { sed -i 's/'"$placeholder"'/'"$replacement"'/' "target/ink/$contract.contract" } + # --- GLOBAL CONSTANTS NODE_IMAGE=public.ecr.aws/p6e8q1z1/aleph-node:latest CONTRACTS_PATH=$(pwd)/contracts + # --- COMPILE CONTRACTS cd "$CONTRACTS_PATH"/access_control @@ -130,14 +149,9 @@ cargo contract build --release cd "$CONTRACTS_PATH"/game_token cargo contract build --release -cd "$CONTRACTS_PATH"/early_bird_special +cd "$CONTRACTS_PATH"/button cargo contract build --release -cd "$CONTRACTS_PATH"/back_to_the_future -cargo contract build --release - -cd "$CONTRACTS_PATH"/the_pressiah_cometh -cargo contract build --release # --- DEPLOY ACCESS CONTROL CONTRACT @@ -150,91 +164,46 @@ ACCESS_CONTROL_PUBKEY=$(docker run --rm --entrypoint "/bin/sh" "${NODE_IMAGE}" - echo "access control contract address: $ACCESS_CONTROL" echo "access control contract public key \(hex\): $ACCESS_CONTROL_PUBKEY" -# --- UPLOAD TICKET TOKEN CONTRACT CODE - -cd "$CONTRACTS_PATH"/ticket_token -# replace address placeholder with the on-chain address of the AccessControl contract -link_bytecode ticket_token 4465614444656144446561444465614444656144446561444465614444656144 $ACCESS_CONTROL_PUBKEY -# remove just in case -rm target/ink/ticket_token.wasm -# NOTE : here we go from hex to binary using a nodejs cli tool -# availiable from https://github.com/fbielejec/polkadot-cljs -node ../scripts/hex-to-wasm.js target/ink/ticket_token.contract target/ink/ticket_token.wasm -CODE_HASH=$(cargo contract upload --url $NODE --suri "$AUTHORITY_SEED") -TICKET_TOKEN_CODE_HASH=$(echo "$CODE_HASH" | grep hash | tail -1 | cut -c 15-) - -echo "ticket token code hash" $TICKET_TOKEN_CODE_HASH - -# --- UPLOAD REWARD TOKEN CONTRACT CODE - -cd "$CONTRACTS_PATH"/game_token -# replace address placeholder with the on-chain address of the AccessControl contract -link_bytecode game_token 4465614444656144446561444465614444656144446561444465614444656144 "$ACCESS_CONTROL_PUBKEY" -# remove just in case -rm target/ink/game_token.wasm -# NOTE : here we go from hex to binary using a nodejs cli tool -# availiable from https://github.com/fbielejec/polkadot-cljs -node ../scripts/hex-to-wasm.js target/ink/game_token.contract target/ink/game_token.wasm +# --- UPLOAD CONTRACTS CODES -CODE_HASH=$(cargo contract upload --url "$NODE" --suri "$AUTHORITY_SEED") -GAME_TOKEN_CODE_HASH=$(echo "$CODE_HASH" | grep hash | tail -1 | cut -c 15-) +upload_contract TICKET_TOKEN_CODE_HASH ticket_token +upload_contract GAME_TOKEN_CODE_HASH game_token +upload_contract BUTTON_CODE_HASH button -echo "button token code hash" "$GAME_TOKEN_CODE_HASH" - -# --- GRANT INIT PRIVILEGES ON THE TOKEN AND TICKET CONTRACT CODE - -cd "$CONTRACTS_PATH"/access_control - -# set the initializer of the token contract -cargo contract call --url "$NODE" --contract "$ACCESS_CONTROL" --message grant_role --args "$AUTHORITY" 'Initializer('"$GAME_TOKEN_CODE_HASH"')' --suri "$AUTHORITY_SEED" - -# set the initializer of the ticket contract -cargo contract call --url $NODE --contract $ACCESS_CONTROL --message grant_role --args $AUTHORITY 'Initializer('$TICKET_TOKEN_CODE_HASH')' --suri "$AUTHORITY_SEED" start=`date +%s.%N` # # --- EARLY_BIRD_SPECIAL GAME # +echo "Early Bird Special" -# --- CREATE AN INSTANCE OF THE TICKET CONTRACT FOR THE EARLY_BIRD_SPECIAL GAME - -instrument_ticket_token EARLY_BIRD_SPECIAL_TICKET ticket_token 0x4561726C79426972645370656369616C early_bird_special EBS - -instrument_game_token EARLY_BIRD_SPECIAL_TOKEN game_token Ubik UBI 0x4561726C79426972645370656369616C - -# --- UPLOAD CODE AND CREATE AN INSTANCE OF THE EARLY_BIRD_SPECIAL GAME - -deploy_and_instrument_game EARLY_BIRD_SPECIAL early_bird_special $EARLY_BIRD_SPECIAL_TICKET $EARLY_BIRD_SPECIAL_TOKEN +salt="0x4561726C79426972645370656369616C" +deploy_ticket_token EARLY_BIRD_SPECIAL_TICKET early_bird_special_ticket EBST $salt +deploy_game_token EARLY_BIRD_SPECIAL_TOKEN early_bird_special EBS $salt +deploy_button_game EARLY_BIRD_SPECIAL EarlyBirdSpecial $EARLY_BIRD_SPECIAL_TICKET $EARLY_BIRD_SPECIAL_TOKEN $salt # # --- BACK_TO_THE_FUTURE GAME # +echo "Back To The Future" -# --- CREATE AN INSTANCE OF THE TICKET CONTRACT FOR THE BACK_TO_THE_FUTURE GAME - -instrument_ticket_token BACK_TO_THE_FUTURE_TICKET ticket_token 0x4261636B546F546865467574757265 back_to_the_future BTF - -instrument_game_token BACK_TO_THE_FUTURE_TOKEN game_token Cyberiad CYB 0x4261636B546F546865467574757265 - -# --- UPLOAD CODE AND CREATE AN INSTANCE OF THE EARLY_BIRD_SPECIAL GAME - -deploy_and_instrument_game BACK_TO_THE_FUTURE back_to_the_future $BACK_TO_THE_FUTURE_TICKET $BACK_TO_THE_FUTURE_TOKEN +salt="0x4261636B546F546865467574757265" +deploy_ticket_token BACK_TO_THE_FUTURE_TICKET back_to_the_future_ticket BTFT $salt +deploy_game_token BACK_TO_THE_FUTURE_TOKEN back_to_the_future BTF $salt +deploy_button_game BACK_TO_THE_FUTURE BackToTheFuture $BACK_TO_THE_FUTURE_TICKET $BACK_TO_THE_FUTURE_TOKEN $salt # # --- THE_PRESSIAH_COMETH GAME # +echo "The Pressiah Cometh" -# --- CREATE AN INSTANCE OF THE TICKET CONTRACT FOR THE THE_PRESSIAH_COMETH GAME +salt="0x7468655F70726573736961685F636F6D657468" +deploy_ticket_token THE_PRESSIAH_COMETH_TICKET the_pressiah_cometh_ticket TPCT $salt +deploy_game_token THE_PRESSIAH_COMETH_TOKEN the_pressiah_cometh TPC $salt +deploy_button_game THE_PRESSIAH_COMETH ThePressiahCometh $THE_PRESSIAH_COMETH_TICKET $THE_PRESSIAH_COMETH_TOKEN $salt -instrument_ticket_token THE_PRESSIAH_COMETH_TICKET ticket_token 0x7468655F70726573736961685F636F6D657468 the_pressiah_cometh TPC - -instrument_game_token THE_PRESSIAH_COMETH_TOKEN game_token Dune DUN 0x7468655F70726573736961685F636F6D657468 - -# --- UPLOAD CODE AND CREATE AN INSTANCE OF THE EARLY_BIRD_SPECIAL GAME - -deploy_and_instrument_game THE_PRESSIAH_COMETH the_pressiah_cometh $THE_PRESSIAH_COMETH_TICKET $THE_PRESSIAH_COMETH_TOKEN # spit adresses to a JSON file cd "$CONTRACTS_PATH" @@ -258,7 +227,8 @@ jq -n --arg early_bird_special $EARLY_BIRD_SPECIAL \ the_pressiah_cometh_ticket: $the_pressiah_cometh_ticket, the_pressiah_cometh_token: $the_pressiah_cometh_token}' > addresses.json -end=$( date +%s.%N ) + +end=`date +%s.%N` echo "Time elapsed: $( echo "$end - $start" | bc -l )" exit $? From eb7dbca4129ce78c3e6a7be126fcbcd0b720e43c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Mon, 12 Sep 2022 11:30:15 +0200 Subject: [PATCH 5/7] errors --- aleph-client/Cargo.lock | 3 +- benches/payout-stakers/Cargo.lock | 3 +- bin/cliain/Cargo.lock | 3 +- contracts/button/Cargo.lock | 11 +++++ contracts/button/Cargo.toml | 6 ++- contracts/button/errors.rs | 73 ++++--------------------------- contracts/button/lib.rs | 19 +++++--- e2e-tests/Cargo.lock | 3 +- flooder/Cargo.lock | 3 +- 9 files changed, 48 insertions(+), 76 deletions(-) diff --git a/aleph-client/Cargo.lock b/aleph-client/Cargo.lock index 3550f16648..e2d3ca0427 100644 --- a/aleph-client/Cargo.lock +++ b/aleph-client/Cargo.lock @@ -1619,12 +1619,13 @@ dependencies = [ [[package]] name = "pallet-aleph" -version = "0.4.0" +version = "0.5.0" dependencies = [ "frame-support", "frame-system", "pallet-balances", "pallet-session", + "pallets-support", "parity-scale-codec", "primitives", "scale-info", diff --git a/benches/payout-stakers/Cargo.lock b/benches/payout-stakers/Cargo.lock index cfdd1d3a5b..0519d014bd 100644 --- a/benches/payout-stakers/Cargo.lock +++ b/benches/payout-stakers/Cargo.lock @@ -1719,12 +1719,13 @@ checksum = "648001efe5d5c0102d8cea768e348da85d90af8ba91f0bea908f157951493cd4" [[package]] name = "pallet-aleph" -version = "0.4.0" +version = "0.5.0" dependencies = [ "frame-support", "frame-system", "pallet-balances", "pallet-session", + "pallets-support", "parity-scale-codec", "primitives", "scale-info", diff --git a/bin/cliain/Cargo.lock b/bin/cliain/Cargo.lock index ad229d0008..dacf3c6717 100644 --- a/bin/cliain/Cargo.lock +++ b/bin/cliain/Cargo.lock @@ -2000,12 +2000,13 @@ checksum = "648001efe5d5c0102d8cea768e348da85d90af8ba91f0bea908f157951493cd4" [[package]] name = "pallet-aleph" -version = "0.4.0" +version = "0.5.0" dependencies = [ "frame-support", "frame-system", "pallet-balances", "pallet-session", + "pallets-support", "parity-scale-codec", "primitives", "scale-info", diff --git a/contracts/button/Cargo.lock b/contracts/button/Cargo.lock index 84ab724a11..2c36ea0f76 100644 --- a/contracts/button/Cargo.lock +++ b/contracts/button/Cargo.lock @@ -9,9 +9,11 @@ dependencies = [ "ink_env", "ink_lang", "ink_lang_codegen", + "ink_metadata", "ink_primitives", "ink_storage", "parity-scale-codec", + "scale-info", ] [[package]] @@ -256,11 +258,13 @@ dependencies = [ "access_control", "ink_env", "ink_lang", + "ink_metadata", "ink_prelude", "ink_primitives", "ink_storage", "openbrush", "parity-scale-codec", + "scale-info", ] [[package]] @@ -547,12 +551,14 @@ source = "git+https://github.com/Supercolony-net/openbrush-contracts.git?rev=8a2 dependencies = [ "ink_env", "ink_lang", + "ink_metadata", "ink_prelude", "ink_primitives", "ink_storage", "openbrush_contracts", "openbrush_lang", "parity-scale-codec", + "scale-info", ] [[package]] @@ -562,11 +568,13 @@ source = "git+https://github.com/Supercolony-net/openbrush-contracts.git?rev=8a2 dependencies = [ "ink_env", "ink_lang", + "ink_metadata", "ink_prelude", "ink_primitives", "ink_storage", "openbrush_lang", "parity-scale-codec", + "scale-info", ] [[package]] @@ -577,6 +585,7 @@ dependencies = [ "const_format", "ink_env", "ink_lang", + "ink_metadata", "ink_primitives", "ink_storage", "openbrush_lang_macro", @@ -928,11 +937,13 @@ dependencies = [ "access_control", "ink_env", "ink_lang", + "ink_metadata", "ink_prelude", "ink_primitives", "ink_storage", "openbrush", "parity-scale-codec", + "scale-info", ] [[package]] diff --git a/contracts/button/Cargo.toml b/contracts/button/Cargo.toml index 433cbb1bf7..20f1a7c429 100644 --- a/contracts/button/Cargo.toml +++ b/contracts/button/Cargo.toml @@ -38,6 +38,10 @@ std = [ "ink_primitives/std", "ink_storage/std", "scale-info/std", - "scale/std" + "scale/std", + "access_control/std", + "game_token/std", + "ticket_token/std", + "openbrush/std", ] ink-as-dependency = [] diff --git a/contracts/button/errors.rs b/contracts/button/errors.rs index ce9d4a3ad2..9b6af00124 100644 --- a/contracts/button/errors.rs +++ b/contracts/button/errors.rs @@ -1,3 +1,4 @@ +use access_control::Role; use ink_env::Error as InkEnvError; use ink_prelude::{format, string::String}; use openbrush::contracts::psp22::PSP22Error; @@ -6,82 +7,24 @@ use openbrush::contracts::psp22::PSP22Error; #[derive(Debug, PartialEq, Eq, scale::Encode, scale::Decode)] #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] pub enum GameError { - /// Returned if reset is called before the deadline + /// Reset has been called before the deadline BeforeDeadline, - /// Returned if button is pressed after the deadline + /// Button has been pressed after the deadline AfterDeadline, - /// Returned if a call is made from an account with missing access control privileges - MissingRole(String), + /// Call has been made from an account with missing access control privileges + MissingRole(Role), /// Returned if a call to another contract has failed - ContractCall(String), + CrossContractCallFailed(String), } impl From for GameError { fn from(e: PSP22Error) -> Self { - match e { - PSP22Error::Custom(message) => GameError::ContractCall(message), - PSP22Error::InsufficientBalance => { - GameError::ContractCall(String::from("PSP22::InsufficientBalance")) - } - PSP22Error::InsufficientAllowance => { - GameError::ContractCall(String::from("PSP22::InsufficientAllowance")) - } - PSP22Error::ZeroRecipientAddress => { - GameError::ContractCall(String::from("PSP22::ZeroRecipientAddress")) - } - PSP22Error::ZeroSenderAddress => { - GameError::ContractCall(String::from("PSP22::ZeroSenderAddress")) - } - PSP22Error::SafeTransferCheckFailed(message) => { - GameError::ContractCall(format!("PSP22::SafeTransferCheckFailed({})", message)) - } - } + GameError::CrossContractCallFailed(format!("{:?}", e)) } } impl From for GameError { fn from(e: InkEnvError) -> Self { - match e { - InkEnvError::Decode(_e) => { - GameError::ContractCall(String::from("Contract call failed due to Decode error")) - } - InkEnvError::CalleeTrapped => GameError::ContractCall(String::from( - "Contract call failed due to CalleeTrapped error", - )), - InkEnvError::CalleeReverted => GameError::ContractCall(String::from( - "Contract call failed due to CalleeReverted error", - )), - InkEnvError::KeyNotFound => GameError::ContractCall(String::from( - "Contract call failed due to KeyNotFound error", - )), - InkEnvError::_BelowSubsistenceThreshold => GameError::ContractCall(String::from( - "Contract call failed due to _BelowSubsistenceThreshold error", - )), - InkEnvError::TransferFailed => GameError::ContractCall(String::from( - "Contract call failed due to TransferFailed error", - )), - InkEnvError::_EndowmentTooLow => GameError::ContractCall(String::from( - "Contract call failed due to _EndowmentTooLow error", - )), - InkEnvError::CodeNotFound => GameError::ContractCall(String::from( - "Contract call failed due to CodeNotFound error", - )), - InkEnvError::NotCallable => GameError::ContractCall(String::from( - "Contract call failed due to NotCallable error", - )), - InkEnvError::Unknown => { - GameError::ContractCall(String::from("Contract call failed due to Unknown error")) - } - InkEnvError::LoggingDisabled => GameError::ContractCall(String::from( - "Contract call failed due to LoggingDisabled error", - )), - InkEnvError::EcdsaRecoveryFailed => GameError::ContractCall(String::from( - "Contract call failed due to EcdsaRecoveryFailed error", - )), - #[cfg(any(feature = "std", test, doc))] - InkEnvError::OffChain(_e) => { - GameError::ContractCall(String::from("Contract call failed due to OffChain error")) - } - } + GameError::CrossContractCallFailed(format!("Contract call failed due to {:?}", e)) } } diff --git a/contracts/button/lib.rs b/contracts/button/lib.rs index b00e20f794..6da3886a74 100644 --- a/contracts/button/lib.rs +++ b/contracts/button/lib.rs @@ -117,9 +117,12 @@ mod button_game { caller, required_role, |why: InkEnvError| { - GameError::ContractCall(format!("Calling access control has failed: {:?}", why)) + GameError::CrossContractCallFailed(format!( + "Calling access control has failed: {:?}", + why + )) }, - |role: Role| GameError::MissingRole(format!("{:?}", role)), + |role: Role| GameError::MissingRole(role), ); match role_check { @@ -171,7 +174,10 @@ mod button_game { #[ink(message)] pub fn code_hash(&self) -> ButtonResult { self.env().own_code_hash().map_err(|why| { - GameError::ContractCall(format!("Can't retrieve own code hash: {:?}", why)) + GameError::CrossContractCallFailed(format!( + "Can't retrieve own code hash: {:?}", + why + )) }) } @@ -314,9 +320,12 @@ mod button_game { account, role, |why: InkEnvError| { - GameError::ContractCall(format!("Calling access control has failed: {:?}", why)) + GameError::CrossContractCallFailed(format!( + "Calling access control has failed: {:?}", + why + )) }, - |role: Role| GameError::MissingRole(format!("{:?}", role)), + |role: Role| GameError::MissingRole(role), ) } diff --git a/e2e-tests/Cargo.lock b/e2e-tests/Cargo.lock index 7d8c9c4036..90e95ac03b 100644 --- a/e2e-tests/Cargo.lock +++ b/e2e-tests/Cargo.lock @@ -1735,12 +1735,13 @@ checksum = "648001efe5d5c0102d8cea768e348da85d90af8ba91f0bea908f157951493cd4" [[package]] name = "pallet-aleph" -version = "0.4.0" +version = "0.5.0" dependencies = [ "frame-support", "frame-system", "pallet-balances", "pallet-session", + "pallets-support", "parity-scale-codec", "primitives", "scale-info", diff --git a/flooder/Cargo.lock b/flooder/Cargo.lock index 6c8a1c942e..d964b0d914 100644 --- a/flooder/Cargo.lock +++ b/flooder/Cargo.lock @@ -1802,12 +1802,13 @@ checksum = "648001efe5d5c0102d8cea768e348da85d90af8ba91f0bea908f157951493cd4" [[package]] name = "pallet-aleph" -version = "0.4.0" +version = "0.5.0" dependencies = [ "frame-support", "frame-system", "pallet-balances", "pallet-session", + "pallets-support", "parity-scale-codec", "primitives", "scale-info", From 7a9be715f67f475469e3251747d0e5af009c122d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Mon, 12 Sep 2022 16:49:40 +0200 Subject: [PATCH 6/7] last changes? --- contracts/button/errors.rs | 2 ++ contracts/button/lib.rs | 38 +++++++++++++------------------------ contracts/scripts/deploy.sh | 4 +--- 3 files changed, 16 insertions(+), 28 deletions(-) diff --git a/contracts/button/errors.rs b/contracts/button/errors.rs index 9b6af00124..c84675bc71 100644 --- a/contracts/button/errors.rs +++ b/contracts/button/errors.rs @@ -15,6 +15,8 @@ pub enum GameError { MissingRole(Role), /// Returned if a call to another contract has failed CrossContractCallFailed(String), + /// Couldn't have retrieved own code hash + CantRetrieveOwnCodeHash, } impl From for GameError { diff --git a/contracts/button/lib.rs b/contracts/button/lib.rs index 6da3886a74..99fa7bc855 100644 --- a/contracts/button/lib.rs +++ b/contracts/button/lib.rs @@ -112,20 +112,7 @@ mod button_game { let required_role = Role::Initializer(code_hash); let access_control = AccountId::from(ACCESS_CONTROL_PUBKEY); - let role_check = ::check_role( - access_control, - caller, - required_role, - |why: InkEnvError| { - GameError::CrossContractCallFailed(format!( - "Calling access control has failed: {:?}", - why - )) - }, - |role: Role| GameError::MissingRole(role), - ); - - match role_check { + match ButtonGame::check_role(&access_control, &caller, required_role) { Ok(_) => Self::init(ticket_token, reward_token, button_lifetime, scoring), Err(why) => panic!("Could not initialize the contract {:?}", why), } @@ -173,12 +160,9 @@ mod button_game { /// Returns own code hash #[ink(message)] pub fn code_hash(&self) -> ButtonResult { - self.env().own_code_hash().map_err(|why| { - GameError::CrossContractCallFailed(format!( - "Can't retrieve own code hash: {:?}", - why - )) - }) + self.env() + .own_code_hash() + .map_err(|_| GameError::CantRetrieveOwnCodeHash) } /// Presses the button @@ -258,7 +242,7 @@ mod button_game { let caller = self.env().caller(); let this = self.env().account_id(); let required_role = Role::Owner(this); - self.check_role(caller, required_role)?; + ButtonGame::check_role(&self.access_control, &caller, required_role)?; self.access_control = new_access_control; Ok(()) } @@ -271,7 +255,7 @@ mod button_game { let caller = self.env().caller(); let this = self.env().account_id(); let required_role = Role::Owner(this); - self.check_role(caller, required_role)?; + ButtonGame::check_role(&self.access_control, &caller, required_role)?; self.env().terminate_contract(caller) } @@ -311,13 +295,17 @@ mod button_game { contract } - fn check_role(&self, account: AccountId, role: Role) -> ButtonResult<()> + fn check_role( + access_control: &AccountId, + account: &AccountId, + role: Role, + ) -> ButtonResult<()> where Self: AccessControlled, { ::check_role( - self.access_control, - account, + access_control.clone(), + account.clone(), role, |why: InkEnvError| { GameError::CrossContractCallFailed(format!( diff --git a/contracts/scripts/deploy.sh b/contracts/scripts/deploy.sh index e6e73a955b..5cd4498186 100755 --- a/contracts/scripts/deploy.sh +++ b/contracts/scripts/deploy.sh @@ -28,11 +28,9 @@ function upload_contract { echo "$contract_name code hash: $code_hash" - # --- GRANT PRIVILEGES ON THE TICKET CONTRACT - cd "$CONTRACTS_PATH"/access_control - # set the initializer of the token contract + # Set the initializer of the contract cargo contract call --url "$NODE" --contract "$ACCESS_CONTROL" --message grant_role --args "$AUTHORITY" 'Initializer('"$code_hash"')' --suri "$AUTHORITY_SEED" eval $__resultvar="'$code_hash'" From 96d0d24ec1362f45c9017d2edfc312deef28bb20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Tue, 13 Sep 2022 13:39:54 +0200 Subject: [PATCH 7/7] error renaming --- contracts/button/errors.rs | 10 ++++++---- contracts/button/lib.rs | 5 +---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/contracts/button/errors.rs b/contracts/button/errors.rs index c84675bc71..4da4c55914 100644 --- a/contracts/button/errors.rs +++ b/contracts/button/errors.rs @@ -13,20 +13,22 @@ pub enum GameError { AfterDeadline, /// Call has been made from an account with missing access control privileges MissingRole(Role), - /// Returned if a call to another contract has failed - CrossContractCallFailed(String), + /// A call to a PSP22 contract has failed + PSP22Error(PSP22Error), + /// An interaction with ink! environment has failed + InkEnvError(String), /// Couldn't have retrieved own code hash CantRetrieveOwnCodeHash, } impl From for GameError { fn from(e: PSP22Error) -> Self { - GameError::CrossContractCallFailed(format!("{:?}", e)) + GameError::PSP22Error(e) } } impl From for GameError { fn from(e: InkEnvError) -> Self { - GameError::CrossContractCallFailed(format!("Contract call failed due to {:?}", e)) + GameError::InkEnvError(format!("{:?}", e)) } } diff --git a/contracts/button/lib.rs b/contracts/button/lib.rs index 99fa7bc855..6cc6ee8d3d 100644 --- a/contracts/button/lib.rs +++ b/contracts/button/lib.rs @@ -308,10 +308,7 @@ mod button_game { account.clone(), role, |why: InkEnvError| { - GameError::CrossContractCallFailed(format!( - "Calling access control has failed: {:?}", - why - )) + GameError::InkEnvError(format!("Calling access control has failed: {:?}", why)) }, |role: Role| GameError::MissingRole(role), )