Skip to content

Commit 773069b

Browse files
Merge pull request #169 from Tonomy-Foundation/testnet
Master release
2 parents 90a6c51 + 5431145 commit 773069b

File tree

2 files changed

+11
-53
lines changed

2 files changed

+11
-53
lines changed

contracts/eosio.token/include/eosio.token/eosio.token.hpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ namespace eosio {
2626
public:
2727
using contract::contract;
2828
static constexpr eosio::symbol SYSTEM_RESOURCE_CURRENCY = eosio::symbol("TONO", 6);
29-
static constexpr eosio::symbol SYSTEM_RESOURCE_CURRENCY_OLD = eosio::symbol("LEOS", 6);
3029

3130
/**
3231
* Allows `issuer` account to create a token in supply of `maximum_supply`. If validation is successful a new entry in statstable for token symbol scope gets created.
@@ -104,16 +103,10 @@ namespace eosio {
104103
void close( const name& owner, const symbol& symbol );
105104

106105
/**
107-
* Migrates an accounts tokens from the old symbol to the new symbol
106+
* Fixes the stats table, by setting the supply to be the max_supply
108107
*/
109108
[[eosio::action]]
110-
void migrateacc(const name &account);
111-
112-
/**
113-
* Migrates a currency statistics from the old symbol to the new symbol
114-
*/
115-
[[eosio::action]]
116-
void migratestats();
109+
void setstats();
117110

118111
/**
119112
* Issues a token to a user

contracts/eosio.token/src/eosio.token.cpp

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -168,57 +168,22 @@ namespace eosio
168168
acnts.erase(it);
169169
}
170170

171-
void token::migratestats()
171+
void token::setstats()
172172
{
173173
// Admin only function
174174
require_auth(get_self());
175175

176-
asset max_supply;
177-
name issuer;
178-
179-
// Look at the table using old symbol as scope
180-
stats statstable(get_self(), SYSTEM_RESOURCE_CURRENCY_OLD.code().raw());
181-
// Check if old token found
182-
auto existing_itr = statstable.find(SYSTEM_RESOURCE_CURRENCY_OLD.code().raw());
183-
if(existing_itr != statstable.end()) {
184-
max_supply = asset(existing_itr->max_supply.amount, SYSTEM_RESOURCE_CURRENCY);
185-
issuer = existing_itr->issuer;
186-
statstable.erase(existing_itr);
187-
}
188-
// Check if new token found
189-
auto new_itr = statstable.find(SYSTEM_RESOURCE_CURRENCY.code().raw());
190-
if(new_itr != statstable.end()) {
191-
max_supply = asset(new_itr->max_supply.amount, SYSTEM_RESOURCE_CURRENCY);
192-
issuer = new_itr->issuer;
193-
statstable.erase(new_itr);
194-
}
195-
196-
// New symbol as scope
197176
stats statstable2(get_self(), SYSTEM_RESOURCE_CURRENCY.code().raw());
198-
statstable2.emplace(get_self(), [&](auto &s)
177+
auto itr = statstable2.find(SYSTEM_RESOURCE_CURRENCY.code().raw());
178+
check(itr != statstable2.end(), "stats table not found for system currency");
179+
check(itr->supply.amount == 0, "supply is not 0, so should not be updated");
180+
181+
statstable2.modify(itr, same_payer, [&](auto &s)
199182
{
200-
s.supply.symbol = SYSTEM_RESOURCE_CURRENCY;
201-
s.max_supply = max_supply;
202-
s.issuer = issuer;
183+
s.supply = itr->max_supply;
184+
s.max_supply = itr->max_supply;
185+
s.issuer = itr->issuer;
203186
});
204-
205-
}
206-
207-
void token::migrateacc(const name &account)
208-
{
209-
// Admin only function
210-
require_auth(get_self());
211-
212-
accounts account_balance(get_self(), account.value);
213-
214-
auto balance_itr = account_balance.find(SYSTEM_RESOURCE_CURRENCY_OLD.code().raw());
215-
216-
if (balance_itr != account_balance.end()) {
217-
account_balance.emplace(get_self(), [&](auto &a) {
218-
a.balance = asset(balance_itr->balance.amount, SYSTEM_RESOURCE_CURRENCY);
219-
});
220-
account_balance.erase(balance_itr);
221-
}
222187
}
223188

224189
const token::currency_stats& token::get_stats(stats& statstable, const symbol& sym) {

0 commit comments

Comments
 (0)