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

BD-4580 add action to transaction log for burn of domains #312

Merged
merged 5 commits into from
Jul 10, 2023
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
19 changes: 19 additions & 0 deletions contracts/fio.address/fio.address.abi
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,20 @@
}
]
},
{
"name": "burndomain",
"base": "",
"fields": [
{
"name": "domainname",
"type": "string"
},
{
"name": "domainidx",
"type": "uint64"
}
]
},
{
"name": "burnexpired",
"base": "",
Expand Down Expand Up @@ -808,6 +822,11 @@
"type": "renewaddress",
"ricardian_contract": ""
},
{
"name": "burndomain",
"type": "burndomain",
"ricardian_contract": ""
},
{
"name": "burnexpired",
"type": "burnexpired",
Expand Down
40 changes: 38 additions & 2 deletions contracts/fio.address/fio.address.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1389,6 +1389,37 @@ namespace fioio {
send_response(response_string.c_str());
}

[[eosio::action]]
void burndomain(const string &domainname, const uint64_t &domainidx) {
//only fio.address able to call this.
eosio_assert(has_auth(AddressContract),
"missing required authority of fio.address");

auto domainiter = domains.find(domainidx);
fio_400_assert(domainiter->name.compare(domainname) == 0, "domainname", domainname,
"Domain name does not match name at index", ErrorDomainNotFound);

fio_400_assert(domainiter != domains.end(), "domainidx", std::to_string(domainidx),
"Domain index not found", ErrorDomainNotFound);

const auto domainhash = domainiter->domainhash;
auto nameexpidx = fionames.get_index<"bydomain"_n>();
auto nameiter = nameexpidx.find(domainhash);

fio_400_assert(nameiter == nameexpidx.end(), "domainidx", std::to_string(domainidx),
"Cannot burn domain when domain has fio handles", ErrorDomainNotFound);

domains.erase(domainiter);


const string response_string = string("{\"status\": \"OK\" },\"");

fio_400_assert(transaction_size() <= MAX_TRX_SIZE, "transaction_size", std::to_string(transaction_size()),
"Transaction is too large", ErrorTransactionTooLarge);

send_response(response_string.c_str());
}

/*
* This action will look for expired domains, then look for expired addresses, it will burn a total
* of 25 addresses each time called. please see the code for the logic of identifying expired domains
Expand Down Expand Up @@ -1474,7 +1505,12 @@ namespace fioio {
}

if (nameiter == nameexpidx.end()) {
domains.erase(domainiter);
action(
permission_level{get_self(), "active"_n},
"fio.address"_n,
"burndomain"_n,
std::make_tuple(domainiter->name,index)
).send();
recordProcessed++;

// Find any domains listed for sale on the fio.escrow contract table
Expand Down Expand Up @@ -2695,6 +2731,6 @@ namespace fioio {
};

EOSIO_DISPATCH(FioNameLookup,(regaddress)(addaddress)(remaddress)(remalladdr)(regdomain)(renewdomain)(renewaddress)
(setdomainpub)(burnexpired)(decrcounter)(bind2eosio)(burnaddress)(xferdomain)(xferaddress)(addbundles)(xferescrow)
(setdomainpub)(burnexpired)(burndomain)(decrcounter)(bind2eosio)(burnaddress)(xferdomain)(xferaddress)(addbundles)(xferescrow)
(addnft)(remnft)(remallnfts)(burnnfts)(regdomadd)(updcryptkey))
}