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
2 changes: 1 addition & 1 deletion airdrops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void create_escrow::airdrop(string dapp, name account)
}
else
{
check(false, ("Not enough " + row.airdrop->balance.symbol.code().to_string() + " with createescrow to airdrop for"+ row.dapp +"app").c_str());
check(false, ("Not enough " + row.airdrop->balance.symbol.code().to_string() + " with createescrow to airdrop for"+ row.dapp +"app [createescrow.airdrop]").c_str());
}
}
});
Expand Down
45 changes: 28 additions & 17 deletions constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,38 +53,49 @@ asset create_escrow::getRamCost(uint64_t ram_bytes, uint64_t priceKey)
RamInfo ramInfo(name("eosio"), name("eosio").value);
auto ramData = ramInfo.find(S_RAM.raw());
symbol coreSymbol = create_escrow::getCoreSymbol();
check(ramData != ramInfo.end(), "Could not get RAM info");
check(ramData != ramInfo.end(), "Could not get RAM info [createescrow.getRamCost]");

uint64_t base = ramData->base.balance.amount;
uint64_t quote = ramData->quote.balance.amount;
ramcost = asset((((double)quote / base)) * ram_bytes, coreSymbol);
}
else
{ //if account is tier fixed
Token token(_self, _self.value);
name newaccountcontract = create_escrow::getNewAccountContract();
priceTable price(newaccountcontract, newaccountcontract.value);
auto priceItr = price.find(priceKey);
ramcost.amount = priceItr->createprice.amount - (priceItr->netamount.amount + priceItr->cpuamount.amount);
ramcost.symbol = priceItr->createprice.symbol;
ramcost = create_escrow::getTierRamPrice(priceKey);
}
return ramcost;
}

asset create_escrow::getFixedCpu(uint64_t priceKey)
asset create_escrow::getTierRamPrice(uint64_t tierKey) {
name newaccountcontract = create_escrow::getNewAccountContract();
priceTable _prices(newaccountcontract, newaccountcontract.value);
tierTable _tiers(newaccountcontract, newaccountcontract.value);
auto priceitr = _prices.find(name("minimalaccnt").value);
check(priceitr != _prices.end(), "No price found [createescrow.getTierRamPrice]");
auto tieritr = _tiers.find(tierKey);
check(tieritr != _tiers.end(), "No tier found [createescrow.getTierRamPrice]");
asset price;
price = priceitr->price;
price.amount = uint64_t(priceitr->price.amount * tieritr->ramfactor / 10000);
return price;
}

asset create_escrow::getFixedCpu(uint64_t tierKey)
{
name newaccountcontract = create_escrow::getNewAccountContract();
priceTable price(newaccountcontract, newaccountcontract.value);
auto priceItr = price.find(priceKey);
return priceItr->cpuamount;
tierTable _tiers(newaccountcontract, newaccountcontract.value);
auto tieritr = _tiers.find(tierKey);
check(tieritr != _tiers.end(), "No tier found [createescrow.getFixedCpu]");
return tieritr->cpuamount;
}

asset create_escrow::getFixedNet(uint64_t priceKey)
asset create_escrow::getFixedNet(uint64_t tierKey)
{
name newaccountcontract = create_escrow::getNewAccountContract();
priceTable price(newaccountcontract, newaccountcontract.value);
auto priceItr = price.find(priceKey);
return priceItr->netamount;
tierTable _tiers(newaccountcontract, newaccountcontract.value);
auto tieritr = _tiers.find(tierKey);
check(tieritr != _tiers.end(), "No tier found [createescrow.getFixedNet]");
return tieritr->netamount;
}

auto create_escrow::getCpuLoanRecord(name account)
Expand All @@ -104,7 +115,7 @@ auto create_escrow::getCpuLoanRecord(name account)
i++;
};

check(false, ("No existing loan found for" + account.to_string()).c_str());
check(false, ("No existing loan found for" + account.to_string() + "[createescrow.getCpuLoanRecord]").c_str());
}

auto create_escrow::getNetLoanRecord(name account)
Expand All @@ -124,6 +135,6 @@ auto create_escrow::getNetLoanRecord(name account)
i++;
};

check(false, ("No existing loan found for" + account.to_string()).c_str());
check(false, ("No existing loan found for" + account.to_string() + "[createescrow.getNetLoanRecord]").c_str());
}
} // namespace createescrow
18 changes: 9 additions & 9 deletions contributions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void create_escrow::addBalance(const name &from, const asset &quantity, string &
}
else
{
check(false, ("Rex not enabled for " + dapp).c_str());
check(false, ("Rex not enabled for " + dapp + "[createescrow.addBalance]").c_str());
}
}

Expand Down Expand Up @@ -134,8 +134,8 @@ void create_escrow::subBalance(string memo, string &origin, const asset &quantit
balance::Balances balances(_self, _self.value);
auto iterator = balances.find(id);

check(iterator != balances.end(), "No balance object");
check(iterator->total_balance.amount >= quantity.amount, "overdrawn balance");
check(iterator != balances.end(), "No balance object [createescrow.subBalance]");
check(iterator->total_balance.amount >= quantity.amount, "overdrawn balance [createescrow.subBalance]");

balances.modify(iterator, same_payer, [&](auto &row) {
auto pred = [memo](const balance::contributors &item) {
Expand All @@ -160,7 +160,7 @@ void create_escrow::subBalance(string memo, string &origin, const asset &quantit
}
else
{
check(false, ("The account " + memo + "not found as one of the contributors for " + origin).c_str());
check(false, ("The account " + memo + "not found as one of the contributors for " + origin + "[createescrow.subBalance]").c_str());
}
});
}
Expand All @@ -173,7 +173,7 @@ void create_escrow::subCpuOrNetBalance(string memo, string &origin, const asset
balance::Balances balances(_self, _self.value);
auto iterator = balances.find(id);

check(iterator != balances.end(), "No balance object");
check(iterator != balances.end(), "No balance object [createescrow.subCpuOrNetBalance]");

balances.modify(iterator, same_payer, [&](auto &row) {
auto pred = [memo](const balance::contributors &item) {
Expand All @@ -182,7 +182,7 @@ void create_escrow::subCpuOrNetBalance(string memo, string &origin, const asset
auto itr = std::find_if(std::begin(row.contributors), std::end(row.contributors), pred);
if (itr != std::end(row.contributors))
{
check(itr->balance.amount >= quantity.amount, "overdrawn balance");
check(itr->balance.amount >= quantity.amount, "overdrawn balance [createescrow.subCpuOrNetBalance]");
itr->balance -= quantity;

if (use_rex_balance)
Expand All @@ -196,7 +196,7 @@ void create_escrow::subCpuOrNetBalance(string memo, string &origin, const asset
}
else
{
check(false, ("The account " + memo + " not found as one of the contributors for " + origin).c_str());
check(false, ("The account " + memo + " not found as one of the contributors for " + origin + "[createescrow.subCpuOrNetBalance]").c_str());
}
});
}
Expand All @@ -219,7 +219,7 @@ asset create_escrow::findContribution(string dapp, name contributor, string type

symbol coreSymbol = create_escrow::getCoreSymbol();

auto msg = "No contribution found for " + dapp + " by " + contributor.to_string() + ".";
auto msg = "No contribution found for " + dapp + " by " + contributor.to_string() + ". [createescrow.findContribution]";

// if no record found for the dapp in the balances table, return the balance for the contributor as 0
if (iterator != balances.end())
Expand Down Expand Up @@ -265,7 +265,7 @@ int create_escrow::findRamContribution(string dapp, name contributor)

symbol coreSymbol = create_escrow::getCoreSymbol();

auto msg = "No contribution found for " + dapp + " by " + contributor.to_string() + ". Checking the globally available free fund.";
auto msg = "No contribution found for " + dapp + " by " + contributor.to_string() + ". Checking the globally available free fund. [createescrow.findRamContribution]";

// if no record found for the dapp in the balances table, return the balance for the contributor as 0
if (iterator != balances.end())
Expand Down
8 changes: 4 additions & 4 deletions createaccounts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ void create_escrow::create(string &memo, name &account, public_key &ownerkey, pu
else if (origin == "free")
print("using globally available free funds to create account");
else
check(false, ("only owner or whitelisted accounts can create new user accounts for " + origin).c_str());
check(false, ("only owner or whitelisted accounts can create new user accounts for " + origin + "[createescrow.create]").c_str());
}
else
{
check(false, ("no owner account found for " + origin).c_str());
check(false, ("no owner account found for " + origin + "[createescrow.create]").c_str());
}

authority owner{.threshold = 1, .keys = {key_weight{ownerkey, 1}}, .accounts = {}, .waits = {}};
Expand Down Expand Up @@ -119,7 +119,7 @@ void create_escrow::createJointAccount(string &memo, name &account, string &orig

if (cpu > cpu_balance || net > net_balance)
{
check(false, ("Not enough cpu or net balance in " + memo + "for " + origin + " to pay for account's bandwidth.").c_str());
check(false, ("Not enough cpu or net balance in " + memo + "for " + origin + " to pay for account's bandwidth. [createescrow.createJointAccount]").c_str());
}

if (useOwnerNetBalance)
Expand Down Expand Up @@ -177,7 +177,7 @@ void create_escrow::createJointAccount(string &memo, name &account, string &orig
// if the "memo" account doesn't have enough fund, check globally available "free" pool
if (balance < requiredBalance)
{
check(false, ("Not enough balance in " + memo + " or donated by the contributors for " + origin + " to pay for account creation.").c_str());
check(false, ("Not enough balance in " + memo + " or donated by the contributors for " + origin + " to pay for account creation. [createescrow.createJointAccount]").c_str());
}
}

Expand Down
18 changes: 9 additions & 9 deletions createescrow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ void create_escrow::define(name &owner, string dapp, uint64_t ram_bytes, asset n
auto iterator = dapps.find(toUUID(dapp));

check(iterator == dapps.end() || (iterator != dapps.end() && iterator->owner == owner),
("the dapp " + dapp + " is already registered by another account").c_str());
("the dapp " + dapp + " is already registered by another account [createescrow.define]").c_str());

uint64_t min_ram = create_escrow::getMinimumRAM();

check(ram_bytes >= min_ram, ("ram for new accounts must be equal to or greater than " + to_string(min_ram) + " bytes.").c_str());
check(ram_bytes >= min_ram, ("ram for new accounts must be equal to or greater than " + to_string(min_ram) + " bytes. [createescrow.define]").c_str());

// Creating a new dapp reference
if (iterator == dapps.end())
Expand Down Expand Up @@ -141,7 +141,7 @@ void create_escrow::whitelist(name owner, name account, string dapp)
});

else
check(false, ("the dapp " + dapp + " is not owned by account " + owner.to_string()).c_str());
check(false, ("the dapp " + dapp + " is not owned by account " + owner.to_string() + "[createescrow.whitelist]").c_str());
}

/***
Expand Down Expand Up @@ -191,7 +191,7 @@ void create_escrow::reclaim(name reclaimer, string dapp, string sym)
}
else
{
check(false, ("no remaining contribution for " + dapp + " by " + reclaimer.to_string()).c_str());
check(false, ("no remaining contribution for " + dapp + " by " + reclaimer.to_string() + " [createescrow.reclaim]").c_str());
}

nocontributor = row.contributors.empty();
Expand All @@ -218,7 +218,7 @@ void create_escrow::reclaim(name reclaimer, string dapp, string sym)
}
else
{
check(false, ("no funds given by " + reclaimer.to_string() + " for " + dapp).c_str());
check(false, ("no funds given by " + reclaimer.to_string() + " for " + dapp + " [createescrow.reclaim]").c_str());
}
}
// user is trying to reclaim custom dapp tokens
Expand All @@ -242,12 +242,12 @@ void create_escrow::reclaim(name reclaimer, string dapp, string sym)
}
else
{
check(false, ("No remaining airdrop balance for " + dapp + ".").c_str());
check(false, ("No remaining airdrop balance for " + dapp + ". [createescrow.reclaim]").c_str());
}
}
else
{
check(false, ("the remaining airdrop balance for " + dapp + " can only be claimed by its owner/whitelisted account.").c_str());
check(false, ("the remaining airdrop balance for " + dapp + " can only be claimed by its owner/whitelisted account. [createescrow.reclaim]").c_str());
}
});
}
Expand Down Expand Up @@ -321,11 +321,11 @@ bool create_escrow::checkIfOwnerOrWhitelisted(name account, string origin)
else if (origin == "free")
print("using globally available free funds to create account");
else
check(false, ("only owner or whitelisted accounts can call this action for " + origin).c_str());
check(false, ("only owner or whitelisted accounts can call this action for " + origin + "[createescrow.checkIfOwnerOrWhitelisted]").c_str());
}
else
{
check(false, ("no owner account found for " + origin).c_str());
check(false, ("no owner account found for " + origin + "[createescrow.checkIfOwnerOrWhitelisted]").c_str());
}
}

Expand Down
5 changes: 3 additions & 2 deletions createescrow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,9 @@ class[[eosio::contract("createescrow")]] create_escrow : public eosio::contract
name getNewAccountAction();
uint64_t getMinimumRAM();
asset getRamCost(uint64_t ram_bytes, uint64_t priceKey);
asset getFixedCpu(uint64_t priceKey);
asset getFixedNet(uint64_t priceKey);
asset getTierRamPrice(uint64_t tierKey);
asset getFixedCpu(uint64_t tierKey);
asset getFixedNet(uint64_t tierKey);

auto getCpuLoanRecord(name account);
auto getNetLoanRecord(name account);
Expand Down
Binary file modified createescrow.wasm
Binary file not shown.
Loading