Skip to content
Open
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 packages/contracts/src/libraries/LibUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,13 @@ library LibUtils {
}
return false;
}

/**
* @dev Only meant as a temporary measure:
* can be circumvented (although it's harder if the check is used across 2+ txs),
* and doesn't combine well with account abstraction
*/
function isMaybeEOA(address target) internal view returns (bool) {
return target.code.length == 0;
}
}
1 change: 1 addition & 0 deletions packages/contracts/src/systems/progression/SpawnSystem.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ contract SpawnSystem is System {
*/
function spawn(string memory _name) public returns (bytes32 playerEntity) {
require(!LibUtils.stringEq(_name, ""), "name empty");
require(LibUtils.isMaybeEOA(_msgSender()), "sender not EOA");

playerEntity = LibUtils.addressToEntityKey(_msgSender());

Expand Down
2 changes: 2 additions & 0 deletions packages/contracts/src/systems/progression/StartSystem.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ contract StartSystem is System {
* @return podEntity Id of pod entity
*/
function start() public returns (bytes32 podEntity) {
require(LibUtils.isMaybeEOA(_msgSender()), "sender not EOA");

bytes32 playerEntity = LibUtils.addressToEntityKey(_msgSender());

// todo: check that player is spawned
Expand Down