Skip to content

Commit 2d2a326

Browse files
authored
A0-1236: Minting and burning reward tokens (#657)
1 parent 3f8e68a commit 2d2a326

File tree

23 files changed

+472
-171
lines changed

23 files changed

+472
-171
lines changed

.github/workflows/e2e-tests-contracts.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
run: |
5959
cargo install cargo-dylint dylint-link --force
6060
# revision merging Hans's PR changes [fix for node URL parsing ]
61-
cargo install --git https://github.com/paritytech/cargo-contract.git --rev 5e6f941805e3d6032dbfa17771a887a362cb3460 --force
61+
cargo install --git https://github.com/paritytech/cargo-contract.git --rev 2b1758756de59bd81e7bed5f8429d364f281cb9a --force
6262
6363
- name: Configure AWS credentials
6464
uses: aws-actions/configure-aws-credentials@v1

contracts/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ Game continues in perpetuity (but in practice as long as there are accounts that
4646
- Tokens are continuously minted at the end of each iteration
4747
- Players are rewarded for playing, with the ultimate goal of being the Pressiah (the last person to click the button)
4848
- Reward rules:
49-
- If youre not ThePressiah, you get _k_ tokens if you pressed the button as the _k-th_ person in a row.
49+
- If you're not ThePressiah, you get _k_ tokens if you pressed the button as the _k-th_ person in a row.
5050
- ThePressiah gets 20% of the total reward pool.
5151

5252
# Development
5353

5454
## Prerequisites
5555

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

5959
## Instructions
6060

@@ -74,7 +74,7 @@ Specifically it will:
7474

7575
- Deploy the contracts.
7676
- Set access control on them.
77-
- Make neccessary token transfers.
77+
- Make necessary token transfers.
7878

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

contracts/access_control/roles.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@ use scale::{Decode, Encode};
1010
pub enum Role {
1111
/// Indicates a superuser.
1212
Admin(AccountId),
13-
/// Indicates account can terminate a contract.
13+
/// Indicates account that can terminate a contract.
1414
Owner(AccountId),
15-
/// Indicates account can initialize a contract from a given code hash.
15+
/// Indicates account that can initialize a contract from a given code hash.
1616
Initializer(Hash),
17-
/// Indicates account can add liquidity to a DEX contract (call certain functions)
17+
/// Indicates account that can add liquidity to a DEX contract (call certain functions)
1818
LiquidityProvider(AccountId),
19+
/// Indicates account that can mint tokens of a given token contract,
20+
Minter(AccountId),
21+
/// Indicates account that can burn tokens of a given token contract,
22+
Burner(AccountId),
1923
}

contracts/button/Cargo.lock

Lines changed: 64 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contracts/button/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ access_control = { path = "../access_control", default-features = false, feature
1919
game_token = { path = "../game_token", default-features = false, features = ["ink-as-dependency"] }
2020
ticket_token = { path = "../ticket_token", default-features = false, features = ["ink-as-dependency"] }
2121
marketplace = { path = "../marketplace", default-features = false, features = ["ink-as-dependency"] }
22-
openbrush = { git = "https://github.com/Supercolony-net/openbrush-contracts.git", rev = "8a20f95", default-features = false, features = ["psp22"] }
22+
openbrush = { git = "https://github.com/Supercolony-net/openbrush-contracts.git", rev = "15e6366", default-features = false, features = ["psp22"] }
2323

2424
[lib]
2525
name = "button"

contracts/button/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use ink_lang as ink;
77
#[ink::contract]
88
mod button_game {
99
use access_control::{roles::Role, traits::AccessControlled, ACCESS_CONTROL_PUBKEY};
10-
use game_token::MINT_TO_SELECTOR;
10+
use game_token::MINT_SELECTOR;
1111
use ink_env::{
1212
call::{build_call, Call, ExecutionInput, Selector},
1313
CallFlags, DefaultEnvironment, Error as InkEnvError,
@@ -336,7 +336,7 @@ mod button_game {
336336
ExecutionInput::new(Selector::new(TRANSFER_SELECTOR))
337337
.push_arg(self.marketplace)
338338
.push_arg(self.held_tickets()?)
339-
.push_arg(vec![0x0]),
339+
.push_arg::<vec::Vec<u8>>(vec![]),
340340
)
341341
.call_flags(CallFlags::default().set_allow_reentry(true))
342342
.returns::<Result<(), PSP22Error>>()
@@ -414,7 +414,7 @@ mod button_game {
414414
.push_arg(from)
415415
.push_arg(to)
416416
.push_arg(value)
417-
.push_arg(vec![0x0]),
417+
.push_arg::<vec::Vec<u8>>(vec![]),
418418
)
419419
.call_flags(CallFlags::default().set_allow_reentry(true))
420420
.returns::<Result<(), PSP22Error>>()
@@ -429,7 +429,7 @@ mod button_game {
429429
build_call::<DefaultEnvironment>()
430430
.call_type(Call::new().callee(self.reward_token))
431431
.exec_input(
432-
ExecutionInput::new(Selector::new(MINT_TO_SELECTOR))
432+
ExecutionInput::new(Selector::new(MINT_SELECTOR))
433433
.push_arg(to)
434434
.push_arg(amount),
435435
)

contracts/env/dev

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@ export AUTHORITY_SEED=//Alice
88
export LIFETIME=20
99

1010
# mint this many ticket tokens
11-
export TOTAL_BALANCE=1000
11+
export TICKET_BALANCE=100
12+
13+
# initial price of ticket on the marketplace
14+
export INITIAL_PRICE=69

contracts/game_token/Cargo.lock

Lines changed: 64 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contracts/game_token/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ink_engine = { version = "~3.3.0", default-features = false, optional = true }
1717
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
1818
scale-info = { version = "2", default-features = false, features = ["derive"], optional = true }
1919

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

2323
[lib]

0 commit comments

Comments
 (0)