Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: Swayfarm Gas Station Mainnet Deployment #91

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
92b7f2b
feat: temp deployment
rishabhkeshan Dec 13, 2024
67bb7a4
feat: temp changes
rishabhkeshan Dec 14, 2024
1803a9a
feat: added gasless functionality for burner and fuelet support
rishabhkeshan Dec 16, 2024
168b53e
added fallback for gasless transaction failures
rishabhkeshan Dec 16, 2024
88d9ab8
fix: use limit from tx cost
danielbate Dec 17, 2024
a31c288
Merge pull request #87 from FuelLabs/db/fix/correct-gas
rishabhkeshan Dec 17, 2024
849d943
feat: refactored back the paymaster to a hook
petertonysmith94 Dec 17, 2024
345aba0
chore: missing import
petertonysmith94 Dec 17, 2024
9fa84a2
Merge pull request #88 from FuelLabs/ps/chore/refactored-paymaster
petertonysmith94 Dec 17, 2024
44ee933
chore: cleanup
rishabhkeshan Dec 17, 2024
c92faef
frontend fixes
Dhaiwat10 Dec 17, 2024
3c248cd
feat: added check for gasless supported wallets, added fallback for g…
rishabhkeshan Dec 18, 2024
d5a0f5e
chore: remove unnecessary files
rishabhkeshan Dec 18, 2024
0af0bb0
feat: added no funds modal
rishabhkeshan Dec 18, 2024
c226ebf
feat: prettier fix
rishabhkeshan Dec 18, 2024
6497482
feat: prettier fix
rishabhkeshan Dec 18, 2024
8579659
Merge branch 'testnet/gasless' into dp/frontend-help
Dhaiwat10 Dec 18, 2024
1742fdf
prettier fix
Dhaiwat10 Dec 18, 2024
4f2e549
Update index.css
Dhaiwat10 Dec 18, 2024
9855d6f
Merge pull request #89 from FuelLabs/dp/frontend-help
rishabhkeshan Dec 18, 2024
1d8193b
feat: testnet server URL
rishabhkeshan Dec 18, 2024
34d6c81
feat: added custom toast icons, messaging improvements
rishabhkeshan Dec 18, 2024
7a8bbba
feat: added rate limiting
rishabhkeshan Dec 18, 2024
ff930b8
feat: added fallback for no funds
rishabhkeshan Dec 18, 2024
539952f
feat: minor fixes
rishabhkeshan Dec 18, 2024
d7acdf0
feat: minor fixes
rishabhkeshan Dec 18, 2024
b88d1fc
ui: enlarge text on wallet support notice
maschad Dec 18, 2024
e7ce565
lint: prettier fix
maschad Dec 18, 2024
093ab11
Merge pull request #90 from FuelLabs/mc/ui-adjustments
maschad Dec 18, 2024
21f4313
feat: added mainnet deployment
rishabhkeshan Dec 18, 2024
359f2ba
feat: updated mainnet link
rishabhkeshan Dec 18, 2024
8da5973
feat: added mobile responsiveness to wallet support notice
rishabhkeshan Dec 18, 2024
2162acd
feat: updated keyboard event handler
rishabhkeshan Dec 20, 2024
f3bacac
fix: toast on mobile on top to avoid hiding keypad
rishabhkeshan Dec 20, 2024
11e520b
feat: added links to explorer for success messages
rishabhkeshan Dec 20, 2024
ec14b75
feat: added recaptcha
rishabhkeshan Dec 20, 2024
522a0d3
feat: removed packag-lock
rishabhkeshan Dec 20, 2024
eb3c8e3
feat: added package-lock
rishabhkeshan Dec 20, 2024
aa072ec
feat: added random generator
rishabhkeshan Dec 20, 2024
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
14 changes: 7 additions & 7 deletions contract/src/abi_structs.sw
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@ use std::{bytes::Bytes, hash::{Hash, Hasher}};
abi GameContract {
// initialize player, mint some coins
#[storage(read, write)]
fn new_player();
fn new_player(address: Identity);

// get asset ID
fn get_asset_id() -> AssetId;

// level up farming skill
#[storage(read, write)]
fn level_up();
fn level_up(address: Identity);

// buy any amount of a certain seed
#[storage(read, write), payable]
fn buy_seeds(food_type: FoodType, amount: u64);
fn buy_seeds(food_type: FoodType, amount: u64, address: Identity);

#[storage(read, write)]
fn plant_seed_at_index(food_type: FoodType, index: u64);
fn plant_seed_at_index(food_type: FoodType, index: u64, address: Identity);

// harvest grown seeds at certain indexes
#[storage(read, write)]
fn harvest(indexes: Vec<u64>);
fn harvest(indexes: Vec<u64>, address: Identity);

// sell a harvested item
#[storage(read, write)]
fn sell_item(food_type: FoodType, amount: u64);
fn sell_item(food_type: FoodType, amount: u64, address: Identity);

#[storage(read)]
fn get_player(id: Identity) -> Option<Player>;
Expand All @@ -45,7 +45,7 @@ abi GameContract {
fn can_level_up(id: Identity) -> bool;

#[storage(read)]
fn can_harvest(index: u64) -> bool;
fn can_harvest(index: u64, address: Identity) -> bool;
}

pub struct Player {
Expand Down
37 changes: 19 additions & 18 deletions contract/src/main.sw
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ storage {

impl GameContract for Contract {
#[storage(read, write)]
fn new_player() {
fn new_player(address: Identity) {
// get the message sender
let sender = msg_sender().unwrap();
let sender = address;
// let sender = msg_sender().unwrap();

// make sure the player doesn't already exist
require(
Expand Down Expand Up @@ -73,9 +74,11 @@ impl GameContract for Contract {
}

#[storage(read, write)]
fn level_up() {
fn level_up(address: Identity) {
// get the player with the message sender
let mut player = storage.players.get(msg_sender().unwrap()).try_read().unwrap();
let sender = address;

let mut player = storage.players.get(sender).try_read().unwrap();

// the max skill level is 10
require(player.farming_skill < 10, "skill already max");
Expand All @@ -89,8 +92,6 @@ impl GameContract for Contract {
// increase the player's skill level
player.level_up_skill();

let sender = msg_sender().unwrap();

// overwrite storage with the updated player struct
storage.players.insert(sender, player);

Expand All @@ -102,7 +103,7 @@ impl GameContract for Contract {
}

#[storage(read, write), payable]
fn buy_seeds(food_type: FoodType, amount: u64) {
fn buy_seeds(food_type: FoodType, amount: u64, address: Identity) {
let asset_id = msg_asset_id();
require(
asset_id == AssetId::default(),
Expand All @@ -121,7 +122,7 @@ impl GameContract for Contract {
// require that the amount is at least the price of the item
require(msg_amount() >= cost, InvalidError::NotEnoughTokens(amount));

let sender = msg_sender().unwrap();
let sender = address;

// check how many seeds the player currenly has
let current_amount_option = storage.player_seeds.get((sender, food_type)).try_read();
Expand All @@ -144,9 +145,9 @@ impl GameContract for Contract {
}

#[storage(read, write)]
fn plant_seed_at_index(food_type: FoodType, index: u64) {
fn plant_seed_at_index(food_type: FoodType, index: u64, address: Identity) {
// get the sender
let sender = msg_sender().unwrap();
let sender = address;
// require player has this many seeds
let current_amount_option = storage.player_seeds.get((sender, food_type)).try_read();
let current_amount = current_amount_option.unwrap_or(0);
Expand Down Expand Up @@ -174,13 +175,13 @@ impl GameContract for Contract {
}

#[storage(read, write)]
fn harvest(indexes: Vec<u64>) {
fn harvest(indexes: Vec<u64>, address: Identity) {
// use this for testing
let time = 0;
// let one_min = 120;
// let time = one_min * 5;

let sender = msg_sender().unwrap();
let sender = address;
let mut planted_seeds = storage.planted_seeds.get(sender).try_read().unwrap();
let current_time = timestamp();

Expand Down Expand Up @@ -216,8 +217,8 @@ impl GameContract for Contract {
}

#[storage(read, write)]
fn sell_item(food_type: FoodType, amount: u64) {
let sender = msg_sender().unwrap();
fn sell_item(food_type: FoodType, amount: u64, address: Identity) {
let sender = address;

// make sure they have that amount
let current_amount = storage.player_items.get((sender, food_type)).try_read().unwrap();
Expand All @@ -236,9 +237,9 @@ impl GameContract for Contract {
};

// increase the player's total_value_sold
let mut player = storage.players.get(msg_sender().unwrap()).try_read().unwrap();
let mut player = storage.players.get(sender).try_read().unwrap();
player.increase_tvs(amount_to_mint);
storage.players.insert(msg_sender().unwrap(), player);
storage.players.insert(sender, player);

// send tokens
mint_to(sender, DEFAULT_SUB_ID, amount_to_mint);
Expand Down Expand Up @@ -297,8 +298,8 @@ impl GameContract for Contract {
}

#[storage(read)]
fn can_harvest(index: u64) -> bool {
let sender = msg_sender().unwrap();
fn can_harvest(index: u64, address: Identity) -> bool {
let sender = address;
let planted_seeds_result = storage.planted_seeds.get(sender);
if planted_seeds_result.try_read().is_none() {
return false;
Expand Down
1 change: 1 addition & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ dist-ssr
*.njsproj
*.sln
*.sw?
*.env
Loading
Loading