Skip to content

Commit

Permalink
feat(eden): load existing eden rate into eden scope (#686)
Browse files Browse the repository at this point in the history
* Publish changes to prod  (#566)

* avoid statefulsets update errors on actions runs refs #535. (#536)

* deprecate demux service. refs #538 (#540)

* add handler url from env var & other minor bug fixes (#542)

* Add missing env var to config map (#543)

* add handler url from env var & other minor bug fixes

* add missing env var

* fix: update some env vars

* fix: update some env vars

* fix: replace .env values with the previous ones

* Feat/add tx link (#545)

* feat: add tx link

* feat: remove secrets

* setup env workflow (#546)

* wip

* wip: add env files & db_data to .gitignore

* fix: remove .env files

* fix: remove .env files

* fix: delete unnecessary code

* refactor: remove unnecessary code

* fix: minimal

* Fix/rate action buttons not showing (#547)

* wip

* wip: add env files & db_data to .gitignore

* fix: remove .env files

* fix: remove .env files

* fix: delete unnecessary code

* refactor: remove unnecessary code

* fix: minimal

* fix: rate buttons not showing in certains densities

* Fix/hasura console config (#556)

* Deploy to mainnet (#544)

* avoid statefulsets update errors on actions runs refs #535. (#536)

* deprecate demux service. refs #538 (#540)

* add handler url from env var & other minor bug fixes (#542)

* Add missing env var to config map (#543)

* add handler url from env var & other minor bug fixes

* add missing env var

* fix: update some env vars

* fix: update some env vars

* fix: replace .env values with the previous ones

Co-authored-by: Andres Gomez <[email protected]>
Co-authored-by: JustinCast <[email protected]>

* wip

* wip: add env files & db_data to .gitignore

* fix: remove .env files

* fix: remove .env files

* fix: delete unnecessary code

* refactor: remove unnecessary code

* fix: minimal

* feat: voting tool revamp

* fix: remove comments

* fix: add i18n entries

* fix: bug fixes

* fix: hasura console config

Co-authored-by: Xavier <[email protected]>
Co-authored-by: Andres Gomez <[email protected]>

* Fix/add missing i18n entries (#554)

* Deploy to mainnet (#544)

* avoid statefulsets update errors on actions runs refs #535. (#536)

* deprecate demux service. refs #538 (#540)

* add handler url from env var & other minor bug fixes (#542)

* Add missing env var to config map (#543)

* add handler url from env var & other minor bug fixes

* add missing env var

* fix: update some env vars

* fix: update some env vars

* fix: replace .env values with the previous ones

Co-authored-by: Andres Gomez <[email protected]>
Co-authored-by: JustinCast <[email protected]>

* wip

* wip: add env files & db_data to .gitignore

* fix: remove .env files

* fix: remove .env files

* fix: delete unnecessary code

* refactor: remove unnecessary code

* fix: minimal

* feat: voting tool revamp

* fix: remove comments

* fix: add i18n entries

* fix: bug fixes

Co-authored-by: Xavier <[email protected]>
Co-authored-by: Andres Gomez <[email protected]>

* docs: add env example (#565)

* fix: not able to sync proxies locally (#564)

* fix: update hasura version

* fix: hasura version && other minor bug fixes

* Fix/update hasura version (#567)

* fix: remove build:staging statement

* latest changes

Co-authored-by: Andres Gomez <[email protected]>
Co-authored-by: JustinCast <[email protected]>

* Update push-master-environment.yaml (#576)

* fix(cron): update config values (#579)

* Revert "fix(cron): update config values (#579)" (#580)

This reverts commit 13ecf78.

* feat(eden): load existing eden rate into eden scope

* feat(rateproducer): add singleton mutatino control

* feat(rateproducer): add default contructor initializer

* feat(rateproducer): final eden members migration

Co-authored-by: Xavier <[email protected]>
Co-authored-by: Andres Gomez <[email protected]>
Co-authored-by: JustinCast <[email protected]>
Co-authored-by: Xavier Fernandez <[email protected]>
Co-authored-by: Leister Alvarez Campos <[email protected]>
  • Loading branch information
6 people authored Aug 24, 2021
1 parent 7f2294d commit cc3ca7d
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 4 deletions.
33 changes: 30 additions & 3 deletions contracts/rateproducer/include/rateproducer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#include <eosio/eosio.hpp>
#include <eosio/singleton.hpp>
#include <eosio/print.hpp>
#include <eosio/asset.hpp>
#include <eosio/multi_index.hpp>
Expand All @@ -27,7 +28,7 @@

#define MINVAL 0
#define MAXVAL 10
#define MIN_VOTERS 21
#define MIN_VOTERS 21

using namespace std;
using namespace eosio;
Expand Down Expand Up @@ -278,10 +279,28 @@ namespace eoscostarica {
indexed_by<"bp"_n, const_mem_fun<ratings, uint64_t, &ratings::by_bp>>
> ratings_table;

/*
* Stores contract config for migration versioning
*/
struct config {
name owner;
uint32_t version;
};
EOSIO_REFLECT(
config,
owner,
version
)
typedef eosio::singleton<"globalconfig"_n, config> config_table;

struct rateproducer : public eosio::contract {
// Use the base class constructors
using eosio::contract::contract;

rateproducer(name receiver, name code, datastream<const char *> ds) :
contract(receiver, code, ds), cfg(receiver, receiver.value) {}

config_table cfg;

/**
*
Expand Down Expand Up @@ -516,8 +535,15 @@ namespace eoscostarica {
* @param user - Voter account name,
* @param bp - Block Producer account name
*
*/
*/
void rmrate_aux(name scope, name user, name bp);

/**
*
* Load existing eden member rates into rateproducer scope
*
*/
void loadedens();
};

EOSIO_ACTIONS(rateproducer,
Expand All @@ -526,6 +552,7 @@ namespace eoscostarica {
action(erase, bp_name),
action(wipe),
action(rminactive),
action(rmrate, user, bp))
action(rmrate, user, bp),
action(loadedens))

} // namespace eoscostarica
42 changes: 41 additions & 1 deletion contracts/rateproducer/src/rateproducer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ namespace eoscostarica {
});
} else {
//update the entry
_stats.modify(itr,user, [&]( auto& row ) {
_stats.modify(itr, user, [&]( auto& row ) {
if (transparency) {
sum += transparency;
if(row.transparency) {
Expand Down Expand Up @@ -491,6 +491,46 @@ namespace eoscostarica {

}
}

void rateproducer::loadedens() {
config c = cfg.get_or_create(_self, config{.owner = _self, .version = 0});
require_auth(c.owner);

// assert we only run once
// the comparison value needs to be hard-coded with each new migration
eosio::check(c.version < 1, "Migration already ran");

ratings_table _ratings_self(_self, _self.value);
ratings_table _ratings_eden(_self, eden_scope.value);

for(auto itr = _ratings_self.begin(); itr != _ratings_self.end(); itr++) {
if(is_eden(itr->user)) {
_ratings_eden.emplace(_self, [&]( auto& row ) {
row.id = itr->id;
row.uniq_rating = itr->uniq_rating;
row.user = itr->user;
row.bp = itr->bp;
row.transparency = itr->transparency;
row.infrastructure = itr->infrastructure;
row.trustiness = itr->trustiness;
row.community = itr->community;
row.development = itr->development ;
});
//save stats
save_bp_stats(eden_scope,
_self,
itr->bp,
itr->transparency,
itr->infrastructure,
itr->trustiness,
itr->community,
itr->development);
}
}

c.version++;
cfg.set(c, c.owner);
}
} // namespace eoscostarica


Expand Down

0 comments on commit cc3ca7d

Please sign in to comment.