Skip to content

Commit

Permalink
Merge pull request #312 from fioprotocol/feature/BD-4580-fiocontracts…
Browse files Browse the repository at this point in the history
…-develop-07012023

BD-4580 add action to transaction log for burn of domains
  • Loading branch information
edrotthoff authored Jul 10, 2023
2 parents 85d1917 + c95c72b commit 92cc1b8
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
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))
}

0 comments on commit 92cc1b8

Please sign in to comment.