Skip to content

Commit

Permalink
Merge pull request #39 from telosnetwork/ibc-account-block
Browse files Browse the repository at this point in the history
Disable the creation of accounts starting with `ibc`
  • Loading branch information
guilledk authored Jan 20, 2023
2 parents 9c3756c + c5d908a commit 87022a6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions contracts/eosio.system/src/eosio.system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,14 @@ namespace eosiosystem {
ignore<authority> owner,
ignore<authority> active ) {

// BEGIN TELOS
if (!has_auth(_self))
check(
new_account_name.to_string().find("ibc.", 0, 4) != 0,
"only eosio can create names that start with 'ibc.'"
);
// END TELOS

if( creator != get_self() ) {
uint64_t tmp = new_account_name.value >> 4;
bool has_dot = false;
Expand Down
16 changes: 16 additions & 0 deletions tests/telos.system_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,4 +387,20 @@ BOOST_FIXTURE_TEST_CASE(multi_producer_pay, eosio_system_tester, * boost::unit_t
}
} FC_LOG_AND_RETHROW()

BOOST_FIXTURE_TEST_CASE( ibc_new_account, eosio_system_tester ) try {

// fail if alice tries
BOOST_REQUIRE_EXCEPTION(
create_account_with_resources("ibc.testing"_n, "alice1111111"_n),
eosio_assert_message_exception,
eosio_assert_message_is("only eosio can create names that start with 'ibc.'")
);

// success if sudo account tries
BOOST_REQUIRE_EQUAL(
false,
create_account_with_resources("ibc.testing"_n, "eosio"_n)->except.has_value());

} FC_LOG_AND_RETHROW()

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit 87022a6

Please sign in to comment.