Skip to content

A0-1236: Minting and burning reward tokens #657

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ Game continues in perpetuity (but in practice as long as there are accounts that
- Tokens are continuously minted at the end of each iteration
- Players are rewarded for playing, with the ultimate goal of being the Pressiah (the last person to click the button)
- Reward rules:
- If youre not ThePressiah, you get _k_ tokens if you pressed the button as the _k-th_ person in a row.
- If you're not ThePressiah, you get _k_ tokens if you pressed the button as the _k-th_ person in a row.
- ThePressiah gets 20% of the total reward pool.

# Development

## Prerequisites

- Rust nightly
- cargo-contract with bug fixes around URL parsing: `cargo install --git https://github.com/paritytech/cargo-contract.git --rev 5e6f941805e3d6032dbfa17771a887a362cb3460 --force`
- cargo-contract with bug fixes around URL parsing: `cargo install --git https://github.com/paritytech/cargo-contract.git --rev 2b1758756de59bd81e7bed5f8429d364f281cb9a --force`

## Instructions

Expand All @@ -74,7 +74,7 @@ Specifically it will:

- Deploy the contracts.
- Set access control on them.
- Make neccessary token transfers.
- Make necessary token transfers.

Third `test.sh` script plays the game from two well-known dev addresses.

Expand Down
10 changes: 7 additions & 3 deletions contracts/access_control/roles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ use scale::{Decode, Encode};
pub enum Role {
/// Indicates a superuser.
Admin(AccountId),
/// Indicates account can terminate a contract.
/// Indicates account that can terminate a contract.
Owner(AccountId),
/// Indicates account can initialize a contract from a given code hash.
/// Indicates account that can initialize a contract from a given code hash.
Initializer(Hash),
/// Indicates account can add liquidity to a DEX contract (call certain functions)
/// Indicates account that can add liquidity to a DEX contract (call certain functions)
LiquidityProvider(AccountId),
/// Indicates account that can mint tokens of a given token contract,
Minter(AccountId),
/// Indicates account that can burn tokens of a given token contract,
Burner(AccountId),
}
74 changes: 64 additions & 10 deletions contracts/button/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contracts/button/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ 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"] }
marketplace = { path = "../marketplace", default-features = false, features = ["ink-as-dependency"] }
openbrush = { git = "https://github.com/Supercolony-net/openbrush-contracts.git", rev = "8a20f95", default-features = false, features = ["psp22"] }
openbrush = { git = "https://github.com/Supercolony-net/openbrush-contracts.git", rev = "15e6366", default-features = false, features = ["psp22"] }

[lib]
name = "button"
Expand Down
8 changes: 4 additions & 4 deletions contracts/button/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use ink_lang as ink;
#[ink::contract]
mod button_game {
use access_control::{roles::Role, traits::AccessControlled, ACCESS_CONTROL_PUBKEY};
use game_token::MINT_TO_SELECTOR;
use game_token::MINT_SELECTOR;
use ink_env::{
call::{build_call, Call, ExecutionInput, Selector},
CallFlags, DefaultEnvironment, Error as InkEnvError,
Expand Down Expand Up @@ -336,7 +336,7 @@ mod button_game {
ExecutionInput::new(Selector::new(TRANSFER_SELECTOR))
.push_arg(self.marketplace)
.push_arg(self.held_tickets()?)
.push_arg(vec![0x0]),
.push_arg::<vec::Vec<u8>>(vec![]),
)
.call_flags(CallFlags::default().set_allow_reentry(true))
.returns::<Result<(), PSP22Error>>()
Expand Down Expand Up @@ -414,7 +414,7 @@ mod button_game {
.push_arg(from)
.push_arg(to)
.push_arg(value)
.push_arg(vec![0x0]),
.push_arg::<vec::Vec<u8>>(vec![]),
)
.call_flags(CallFlags::default().set_allow_reentry(true))
.returns::<Result<(), PSP22Error>>()
Expand All @@ -429,7 +429,7 @@ mod button_game {
build_call::<DefaultEnvironment>()
.call_type(Call::new().callee(self.reward_token))
.exec_input(
ExecutionInput::new(Selector::new(MINT_TO_SELECTOR))
ExecutionInput::new(Selector::new(MINT_SELECTOR))
.push_arg(to)
.push_arg(amount),
)
Expand Down
5 changes: 4 additions & 1 deletion contracts/env/dev
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ export AUTHORITY_SEED=//Alice
export LIFETIME=20

# mint this many ticket tokens
export TOTAL_BALANCE=1000
export TICKET_BALANCE=100

# initial price of ticket on the marketplace
export INITIAL_PRICE=69
74 changes: 64 additions & 10 deletions contracts/game_token/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contracts/game_token/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ink_engine = { version = "~3.3.0", default-features = false, optional = true }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2", default-features = false, features = ["derive"], optional = true }

openbrush = { git = "https://github.com/Supercolony-net/openbrush-contracts.git", rev = "8a20f95", default-features = false, features = ["psp22"] }
openbrush = { git = "https://github.com/Supercolony-net/openbrush-contracts.git", rev = "15e6366", default-features = false, features = ["psp22"] }
access_control = { path = "../access_control", default-features = false, features = ["ink-as-dependency"] }

[lib]
Expand Down
Loading