Skip to content

Commit 1a43ee4

Browse files
authored
Merge branch 'development' into feature/setstats-function
2 parents 1a7d768 + 82e4479 commit 1a43ee4

File tree

7 files changed

+83
-64
lines changed

7 files changed

+83
-64
lines changed

contracts/compile_contract.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@ function compile_contract {
2424
else
2525
docker run -v "${PARENT_PATH}:${WORKING_DIR}" antelope_blockchain bash -c "${BUILD_COMMAND}"
2626
fi
27+
28+
echo ""
29+
echo "Compiled ${CONTRACT_NAME} successfully"
2730
}

contracts/tonomy/build.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@ if [ "$BUILD_METHOD" == "local" ]; then
2424
bash -c "${BUILD_COMMAND}"
2525
else
2626
docker run -v "${PARENT_PATH}:${WORKING_DIR}" antelope_blockchain bash -c "${BUILD_COMMAND}"
27-
fi
27+
fi
28+
29+
echo ""
30+
echo "Compiled ${CONTRACT_NAME} successfully"

contracts/tonomy/include/tonomy/tonomy.hpp

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,26 @@ namespace tonomysystem
9292
checksum256 username_hash,
9393
public_key password_key,
9494
checksum256 password_salt);
95-
/**
96-
* Manually sets the details of an app (admin only)
97-
*
98-
* @param account_name - name of the account
99-
* @param json_data - JSON string containing app details (name,description, logo_url, background_color, accent_color)
100-
* @param username_hash - hash of the username
101-
* @param origin - domain associated with the app
102-
*/
103-
[[eosio::action]] void adminsetapp(
104-
name account_name,
105-
string json_data,
106-
checksum256 username_hash,
107-
string origin);
95+
/**
96+
* Manually sets the details of an app (admin only)
97+
*
98+
* @param account_name - name of the account
99+
* @param json_data - JSON string containing app details (name,description, logo_url, background_color, accent_color)
100+
* @param username_hash - hash of the username
101+
* @param origin - domain associated with the app
102+
*/
103+
[[eosio::action]] void adminsetapp(
104+
name account_name,
105+
string json_data,
106+
checksum256 username_hash,
107+
string origin);
108+
109+
/**
110+
* Removes an app (admin only)
111+
* @param account_name - name of the account
112+
*/
113+
[[eosio::action]] void deleteapp(name account_name);
114+
108115
/**
109116
* Create a new account for an app and registers its details
110117
*
@@ -118,7 +125,6 @@ namespace tonomysystem
118125
checksum256 username_hash,
119126
string origin,
120127
public_key key);
121-
122128

123129
/**
124130
* Adds a new key to a person's account to log into an app with

contracts/tonomy/src/native.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,15 @@ namespace tonomysystem
9292
void native::setcode(name account, uint8_t vmtype, uint8_t vmversion, const std::vector<char> &code)
9393
{
9494
special_governance_check(account);
95+
require_auth(account);
9596
native::setcode_action action("eosio"_n, {account, "active"_n});
9697
action.send(account, vmtype, vmversion, code);
9798
}
9899

99100
void native::setabi(name account, const std::vector<char> &abi)
100101
{
101102
special_governance_check(account);
103+
require_auth(account);
102104
native::setabi_action action("eosio"_n, {account, "active"_n});
103105
action.send(account, abi);
104106
}

contracts/tonomy/src/tonomy.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ namespace tonomysystem
257257
{
258258
eosio::require_auth(get_self()); // signed by tonomy@active permission
259259

260+
eosio::check(is_account(account_name), "Account does not exist");
261+
260262
// Add to the account_type table
261263
account_type_table account_type(get_self(), get_self().value);
262264

@@ -301,6 +303,22 @@ namespace tonomysystem
301303
}
302304
}
303305

306+
void tonomy::deleteapp(name account_name) {
307+
eosio::require_auth(get_self()); // signed by tonomy@active permission
308+
309+
auto itr1 = _apps.find(account_name.value);
310+
if (itr1 != _apps.end())
311+
{
312+
_apps.erase(itr1);
313+
}
314+
315+
auto itr2 = _appsv2.find(account_name.value);
316+
if (itr2 != _appsv2.end())
317+
{
318+
_appsv2.erase(itr2);
319+
}
320+
}
321+
304322
void tonomy::updatekeyper(name account,
305323
permission_level_name permission_level,
306324
public_key key,

contracts/vesting.tmy/include/vesting.tmy/vesting.tmy.hpp

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,38 @@ namespace vestingtoken
2929
};
3030

3131
static const std::map<int, vesting_category> vesting_categories = {
32-
// DEPRECIATED:
33-
{1, {days(6 * 30), days(0 * 30), days(2 * 365), 0.0}}, // Seed Private Sale (DEPRECIATED),
34-
{2, {days(6 * 30), days(6 * 30), days(2 * 365), 0.0}}, // Strategic Partnerships Private Sale (DEPRECIATED),
35-
{3, {days(0 * 30), days(0 * 30), days(0 * 30), 0.0}}, // Public Sale (DEPRECIATED),
36-
{5, {days(0 * 30), days(0 * 30), days(1 * 365), 0.0}}, // Legal and Compliance
37-
{8, {days(0 * 30), days(6 * 30), days(12 * 30), 0.05}}, // Seed
38-
{9, {days(0 * 30), days(4 * 30), days(12 * 30), 0.075}}, // Pre-sale
39-
{11, {days(0 * 30), days(3 * 30), days(9 * 30), 0.125}}, // Private
40-
{15, {days(0 * 30), days(1 * 30), days(1 * 30), 1.0}}, // Special Token Round
41-
// Unchanged:
32+
// OLD:
33+
{1, {days(6 * 30), days(0 * 30), days(2 * 365), 0.0}}, // Seed Private Sale,
34+
{2, {days(6 * 30), days(6 * 30), days(2 * 365), 0.0}}, // Strategic Partnerships Private Sale,
35+
{3, {days(0 * 30), days(0 * 30), days(0 * 30), 0.0}}, // Public Sale,
4236
{4, {days(0 * 30), days(1 * 365), days(5 * 365), 0.0}}, // Team
37+
{5, {days(0 * 30), days(0 * 30), days(1 * 365), 0.0}}, // Legal and Compliance
4338
{6, {days(0 * 30), days(0 * 30), days(2 * 365), 0.0}}, // Reserves, Partnerships
4439
{7, {days(0 * 30), days(0 * 30), days(5 * 365), 0.0}}, // Community & Marketing, Platform Dev, Staking & Infra Rewards, Ecosystem
40+
{8, {days(0 * 30), days(6 * 30), days(12 * 30), 0.05}}, // Seed
41+
{9, {days(0 * 30), days(4 * 30), days(12 * 30), 0.075}}, // Pre-sale
4542
{10, {days(0 * 30), days(1 * 30), days(3 * 30), 0.25}}, // Public (TGE)
46-
// New (replacing depreciated):
47-
{16, {days(0 * 30), days(6 * 30), days(12 * 30), 0.05}}, // Seed
48-
{17, {days(0 * 30), days(4 * 30), days(12 * 30), 0.075}}, // Pre-sale
49-
{18, {days(0 * 30), days(3 * 30), days(9 * 30), 0.125}}, // Private
50-
{19, {days(0 * 30), days(1 * 30), days(1 * 30), 1.0}}, // Special Token Round
51-
// New:
43+
{11, {days(0 * 30), days(3 * 30), days(9 * 30), 0.125}}, // Private
5244
{12, {days(0 * 30), days(1 * 30), days(3 * 30), 0.25}}, // KOL
5345
{13, {days(0 * 30), days(0 * 30), days(6 * 30), 0.7}}, // Incubator
54-
{14, {days(0 * 30), days(0 * 30), days(6 * 30), 0.0}}, // Liquidity (there is actually a 25% TGE unlock, but we handle that manually in the migration script)
46+
{14, {days(0 * 30), days(0 * 30), days(6 * 30), 0.25}}, // Liquidity
47+
{15, {days(0 * 30), days(1 * 30), days(1 * 30), 1.0}}, // Special Token Round
48+
// New:
49+
{16, {days(0 * 30), days(4 * 30), days(9 * 30), 0.05}}, // Seed
50+
{17, {days(0 * 30), days(4 * 30), days(9 * 30), 0.05}}, // Pre-sale
51+
{18, {days(0 * 30), days(2 * 30), days(0 * 30), 0.5}}, // Special Token Round
52+
{19, {days(0 * 30), days(0 * 30), days(3 * 30), 0.4}}, // Private
53+
{20, {days(0 * 30), days(1 * 30), days(3 * 30), 0.4}}, // Public (TGE)
54+
{21, {days(0 * 30), days(0 * 30), days(6 * 30), 1.0 / 3.0}}, // Liquidity
55+
// NOTE: there is actually a 25% TGE unlock, but we handle that manually in the migration script
56+
// The TGE + 72 hour unlock is increased from 25% to 33.33% to account for the fact that 25% is not vested at TGE (to give the 25% unlock)
57+
{22, {days(0 * 30), days(1 * 365), days(5 * 365), 0.0}}, // Team
58+
{23, {days(0 * 30), days(0 * 30), days(2 * 365), 0.0}}, // Reserves
59+
{24, {days(0 * 30), days(0 * 30), days(2 * 365), 0.0}}, // Partnerships
60+
{25, {days(0 * 30), days(0 * 30), days(5 * 365), 0.0}}, // Community & Marketing
61+
{26, {days(0 * 30), days(0 * 30), days(5 * 365), 0.0}}, // Platform Dev
62+
{27, {days(0 * 30), days(0 * 30), days(5 * 365), 0.0}}, // Staking & Infra Rewards
63+
{28, {days(0 * 30), days(0 * 30), days(5 * 365), 0.0}}, // Ecosystem
5564
// Testing categories:
5665
#ifdef BUILD_TEST
5766
{997, {days(6 * 30), days(0 * 30), days(2 * 365), 0.0}}, // TESTING ONLY
@@ -60,14 +69,17 @@ namespace vestingtoken
6069
#endif
6170
};
6271

63-
static const std::map<int, bool> depreciated_categories = {{1, true}, {2, true}, {8, true}, {9, true}, {10, true}, {11, true}, {15, true}};
72+
static const std::map<int, bool> depreciated_categories = {
73+
{1, true}, {2, true}, {3, true}, {4, true}, {5, true},
74+
{6, true}, {7, true}, {8, true}, {9, true}, {10, true},
75+
{11, true}, {12, true}, {13, true}, {14, true}, {15, true}
76+
};
6477

6578
class [[eosio::contract("vesting.tmy")]] vestingToken : public eosio::contract
6679
{
6780
public:
6881
using contract::contract;
6982
static constexpr eosio::symbol system_resource_currency = eosio::symbol("TONO", 6);
70-
static constexpr eosio::symbol SYSTEM_RESOURCE_CURRENCY_OLD = eosio::symbol("LEOS", 6);
7183
static constexpr eosio::name token_contract_name = "eosio.token"_n;
7284
#ifdef BUILD_TEST
7385
static const uint8_t MAX_ALLOCATIONS = 5;
@@ -105,13 +117,13 @@ namespace vestingtoken
105117
/**
106118
* @details Updates the start date for vesting schedules to a new specified date
107119
*
108-
* @param sales_start_date {string} - The new start date for vesting schedules.
109-
* @param launch_date {string} - The new start date for vesting schedules.
120+
* @param sales_start_date {string} - The new start date for vesting schedules (ISO format).
121+
* @param launch_date {string} - The new start date for vesting schedules (ISO format).
110122
* @details
111123
* Before any allocations can be executed, the start date should be set using this action.
112124
* If the launch date is not known when the sale starts, set it to a long time in the future.
113125
*
114-
* Example of the string format expected: "2024-04-01T24:00:00"
126+
* Example of the ISO string format expected: "2024-04-01T24:00:00.000Z"
115127
*/
116128
[[eosio::action]] void setsettings(string sales_start_date, string launch_date);
117129

@@ -145,11 +157,6 @@ namespace vestingtoken
145157
*/
146158
[[eosio::action]] void migratealloc(eosio::name sender, name holder, uint64_t allocation_id, eosio::asset old_amount, eosio::asset new_amount, int old_category_id, int new_category_id);
147159

148-
/**
149-
* Migrates the allocation symbols of an account from the old symbol to the new symbol
150-
*/
151-
[[eosio::action]] void migrateacc(const name &account);
152-
153160
using setsettings_action = action_wrapper<"setsettings"_n, &vestingToken::setsettings>;
154161
using assigntokens_action = action_wrapper<"assigntokens"_n, &vestingToken::assigntokens>;
155162
using withdraw_action = action_wrapper<"withdraw"_n, &vestingToken::withdraw>;

contracts/vesting.tmy/src/vesting.tmy.cpp

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ namespace vestingtoken
1313

1414
void check_category(int category_id)
1515
{
16-
eosio::check(vesting_categories.contains(category_id), "Invalid new vesting category");
17-
eosio::check(!depreciated_categories.contains(category_id), "New category is depreciated");
16+
eosio::check(vesting_categories.contains(category_id), "Invalid new vesting category: " + std::to_string(category_id));
17+
eosio::check(!depreciated_categories.contains(category_id), "New category is depreciated: " + std::to_string(category_id));
1818
}
1919

2020
void vestingToken::setsettings(string sales_date_str, string launch_date_str)
@@ -208,24 +208,4 @@ namespace vestingtoken
208208
.send();
209209
}
210210
}
211-
212-
void vestingToken::migrateacc(const name &account)
213-
{
214-
// Admin only
215-
require_auth(get_self());
216-
217-
vesting_allocations vesting_table(get_self(), account.value);
218-
219-
for (auto iter = vesting_table.begin(); iter != vesting_table.end(); ++iter)
220-
{
221-
if (iter->tokens_allocated.symbol == SYSTEM_RESOURCE_CURRENCY_OLD)
222-
{
223-
vesting_table.modify(iter, get_self(), [&](auto &row)
224-
{
225-
row.tokens_allocated = asset(row.tokens_allocated.amount, system_resource_currency);
226-
row.tokens_claimed = asset(row.tokens_claimed.amount, system_resource_currency);
227-
});
228-
}
229-
}
230-
}
231211
}

0 commit comments

Comments
 (0)