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

bad words #278

Merged
merged 1 commit into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions scripts/rename.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -euo pipefail
pushd $(dirname "$0")/..


export LOBBY_ADDRESS=$(cat ./target/dev/manifest.json | jq -r '.contracts[] | select(.name == "lobby" ).address')


sozo execute $LOBBY_ADDRESS set_name -c $1,$2,0x2a2a2a2a2a2a2a
19 changes: 12 additions & 7 deletions src/systems/lobby.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ trait ILobby<TContractState> {
self: @TContractState, game_mode: GameMode, player_name: felt252, avatar_id: u8, mainnet_address: ContractAddress
) -> (u32, ContractAddress);

fn set_name(self: @TContractState, game_id: u32, player_name: felt252);
fn set_name(self: @TContractState, game_id: u32, player_id: ContractAddress, player_name: felt252);
}


#[dojo::contract]
mod lobby {
use starknet::ContractAddress;
use starknet::get_caller_address;
use starknet::get_contract_address;
use starknet::get_block_timestamp;
use starknet::info::get_tx_info;

Expand Down Expand Up @@ -143,14 +144,18 @@ mod lobby {
(game_id, caller)
}

fn set_name(self: @ContractState, game_id: u32, player_name: felt252) {
// assert_valid_name(player_name);
fn set_name(self: @ContractState, game_id: u32, player_id: ContractAddress, player_name: felt252) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we should remove this. I don't think we want to administer this onchain. Let's filter at the client input and rendering level. We can hash the words to avoid putting them all in our code base (i assume there must be a lib that does this already)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i added simple filter on display #280

assert_valid_name(player_name);

assert(
self.world().is_owner(get_caller_address(), get_contract_address().into()),
'CALLER_IS_NOT_OWNER'
);

// let player_id = get_caller_address();
// let mut player = get!(self.world(), (game_id, player_id), Player);
// player.name = player_name;
let mut player = get!(self.world(), (game_id, player_id), Player);
player.name = player_name;

// set!(self.world(), (player))
set!(self.world(), (player))
}
}

Expand Down
1 change: 1 addition & 0 deletions src/systems/ryo.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ mod ryo {
#[external(v0)]
impl RyoExternalImpl of IRyo<ContractState> {
fn initialize(self: @ContractState) {
//todo check caller is world owner
let meta_manager = RyoMetaManagerTrait::new(self.world());
let mut metas = meta_manager.get();

Expand Down
1 change: 0 additions & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"@chakra-ui/react": "^2.8.1",
"@dojoengine/core": "^0.1.30",
"@dojoengine/create-burner": "0.1.30",
"@dojoengine/torii": "link:../../dojo-packages/packages/torii",
"@dojoengine/utils": "0.1.30",
"@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.6",
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/[gameId]/logs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ function renderDay(log: LogByDay) {
break;

case WorldEvents.GameOver:
return renderGameOver(i as GameOverEventData, key);
// return renderGameOver(i as GameOverEventData, key);
break;

case WorldEvents.AtPawnshop:
Expand Down
3 changes: 0 additions & 3 deletions web/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2250,9 +2250,6 @@
get-starknet-core "^3.2.0"
js-cookie "^3.0.5"

"@dojoengine/torii@link:../../dojo-packages/packages/torii":
version "0.0.0"
uid ""

"@dojoengine/[email protected]":
version "0.1.30"
Expand Down
Loading