From 6b3c37a585c56f17913264e82857341e660daddf Mon Sep 17 00:00:00 2001 From: Jovi Date: Wed, 4 Dec 2024 17:06:32 -0500 Subject: [PATCH 1/3] added require_recipient to newaccount action --- contracts/sysio.system/src/sysio.system.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/contracts/sysio.system/src/sysio.system.cpp b/contracts/sysio.system/src/sysio.system.cpp index c5698da..5d2403b 100644 --- a/contracts/sysio.system/src/sysio.system.cpp +++ b/contracts/sysio.system/src/sysio.system.cpp @@ -454,6 +454,7 @@ namespace sysiosystem { check( current->high_bidder == creator, "only highest bidder can claim" ); check( current->high_bid < 0, "auction for name is not closed yet" ); bids.erase( current ); + require_recipient(name("domain_market")); } else { check( creator == suffix, "only suffix may create this account" ); } From d648fbb30ad6359d8ce91b6a9e863d3fea67be77 Mon Sep 17 00:00:00 2001 From: Jovi Date: Tue, 10 Dec 2024 14:12:50 -0500 Subject: [PATCH 2/3] fixed name in require_recipient function call: domain_market -> domainmarket --- contracts/sysio.system/src/sysio.system.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/sysio.system/src/sysio.system.cpp b/contracts/sysio.system/src/sysio.system.cpp index 5d2403b..fe1ff48 100644 --- a/contracts/sysio.system/src/sysio.system.cpp +++ b/contracts/sysio.system/src/sysio.system.cpp @@ -454,7 +454,7 @@ namespace sysiosystem { check( current->high_bidder == creator, "only highest bidder can claim" ); check( current->high_bid < 0, "auction for name is not closed yet" ); bids.erase( current ); - require_recipient(name("domain_market")); + require_recipient(name("domainmarket")); } else { check( creator == suffix, "only suffix may create this account" ); } From aa4e2149aee10a37f9f7434f35f50873ffc13e97 Mon Sep 17 00:00:00 2001 From: Jovi Date: Mon, 16 Dec 2024 11:10:52 -0500 Subject: [PATCH 3/3] added user-table/domain-table --- .../include/sysio.system/sysio.system.hpp | 23 ++++++ contracts/sysio.system/src/sysio.system.cpp | 79 +++++++++++-------- 2 files changed, 69 insertions(+), 33 deletions(-) diff --git a/contracts/sysio.system/include/sysio.system/sysio.system.hpp b/contracts/sysio.system/include/sysio.system/sysio.system.hpp index 14ed820..10bca3b 100644 --- a/contracts/sysio.system/include/sysio.system/sysio.system.hpp +++ b/contracts/sysio.system/include/sysio.system/sysio.system.hpp @@ -282,6 +282,29 @@ namespace sysiosystem { SYSLIB_SERIALIZE( producer_info2, (owner)(votepay_share)(last_votepay_share_update) ) }; + + // Defines 'domain_info' structure to be stored in 'domains' table (jovi-update) + struct [[sysio::table, sysio::contract("sysio.system")]] domain_info { + uint64_t key; // Unique primary key for the table + name account_name; // Name of the account (domain) + name creator; // Creator of the domain + time_point created_at; // Timestamp of domain creation + + // Primary key + uint64_t primary_key() const { return key; } + + // Secondary index to retrieve by creator + uint64_t by_creator() const { return creator.value; } + + // Serialization macro + SYSLIB_SERIALIZE(domain_info, (key)(account_name)(creator)(created_at)) +}; + +// Define the multi-index table +typedef sysio::multi_index<"domains"_n, domain_info, + indexed_by<"bycreator"_n, const_mem_fun> +> domains_t; + // Voter info. Voter info stores information about the voter: // - `owner` the voter // - `proxy` the proxy set by the voter, if any diff --git a/contracts/sysio.system/src/sysio.system.cpp b/contracts/sysio.system/src/sysio.system.cpp index fe1ff48..f5e81aa 100644 --- a/contracts/sysio.system/src/sysio.system.cpp +++ b/contracts/sysio.system/src/sysio.system.cpp @@ -432,45 +432,58 @@ namespace sysiosystem { * who can create accounts with the creator's name as a suffix. * */ - void native::newaccount( const name& creator, - const name& new_account_name, - ignore owner, - ignore active ) { - - if( creator != get_self() ) { - uint64_t tmp = new_account_name.value >> 4; - bool has_dot = false; - - for( uint32_t i = 0; i < 12; ++i ) { - has_dot |= !(tmp & 0x1f); - tmp >>= 5; - } - if( has_dot ) { // or is less than 12 characters + void native::newaccount( const name& creator, + const name& new_account_name, + ignore owner, + ignore active ) { + if (creator != get_self()) { + uint64_t tmp = new_account_name.value >> 4; + bool has_dot = false; + + for (uint32_t i = 0; i < 12; ++i) { + has_dot |= !(tmp & 0x1f); + tmp >>= 5; + } + if (has_dot) { auto suffix = new_account_name.suffix(); - if( suffix == new_account_name ) { - name_bid_table bids(get_self(), get_self().value); - auto current = bids.find( new_account_name.value ); - check( current != bids.end(), "no active bid for name" ); - check( current->high_bidder == creator, "only highest bidder can claim" ); - check( current->high_bid < 0, "auction for name is not closed yet" ); - bids.erase( current ); - require_recipient(name("domainmarket")); + if (suffix == new_account_name) { + name_bid_table bids(get_self(), get_self().value); + auto current = bids.find(new_account_name.value); + check(current != bids.end(), "no active bid for name"); + check(current->high_bidder == creator, "only highest bidder can claim"); + check(current->high_bid < 0, "auction for name is not closed yet"); + bids.erase(current); } else { - check( creator == suffix, "only suffix may create this account" ); + check(creator == suffix, "only suffix may create this account"); } - } - } + } + } - user_resources_table userres( get_self(), new_account_name.value ); - userres.emplace( new_account_name, [&]( auto& res ) { - res.owner = new_account_name; - res.net_weight = asset( 0, system_contract::get_core_symbol() ); - res.cpu_weight = asset( 0, system_contract::get_core_symbol() ); - }); + // user_resources_table userres( get_self(), new_account_name.value ); - set_resource_limits( new_account_name, 0, 0, 0 ); - } + // userres.emplace( new_account_name, [&]( auto& res ) { + // res.owner = new_account_name; + // res.net_weight = asset( 0, system_contract::get_core_symbol() ); + // res.cpu_weight = asset( 0, system_contract::get_core_symbol() ); + // }); + + + // Add the account to the domains table + domains_t domains(get_self(), get_self().value); + auto existing = domains.find(new_account_name.value); + check(existing == domains.end(), "Account already exists in the domains table"); + + domains.emplace(get_self(), [&](auto& row) { + row.key = domains.available_primary_key(); + row.account_name = new_account_name; + row.creator = creator; + row.created_at = time_point(current_time_point()); + }); + + // Set initial resource limits for the new account + set_resource_limits(new_account_name, 0, 0, 0); +} void native::setabi( const name& acnt, const std::vector& abi, const binary_extension& memo ) {