Skip to content

Commit

Permalink
Merge branch 'staging'
Browse files Browse the repository at this point in the history
  • Loading branch information
xavier506 committed Oct 8, 2021
2 parents 669134a + 808bdc7 commit ef669e3
Show file tree
Hide file tree
Showing 240 changed files with 8,931 additions and 8,468 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ REACT_APP_EOS_API_PROTOCOL=https
REACT_APP_EOS_CHAIN_ID=2a02a0053e5a8cf73a56ba0fda11e4d92e0238a4a2aa74fccf46d5a910746840
REACT_APP_BLOCK_EXPLORER=https://jungle3.bloks.io
REACT_APP_NETWORK_MONITOR_URL=https://jungle.eosio.online/
REACT_APP_VERSION=v1.4.21
REACT_APP_MAINNET_VERSION=v1.4.21
REACT_APP_EDEN_CONTRACT=genesisdeden
REACT_APP_UAL_APP_NAME=EOSRate
2 changes: 1 addition & 1 deletion contracts/rateproducer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.16)
project(demo)
project(rateproducer)


set(CMAKE_CXX_STANDARD 20)
Expand Down
92 changes: 69 additions & 23 deletions contracts/rateproducer/include/rateproducer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <algorithm>
#include <set>
#include "utils.hpp"
#include "../ricardian/rateproducer-ricardian.cpp"

#define MINVAL 0
#define MAXVAL 10
Expand All @@ -43,7 +44,7 @@ using eosio::public_key;
*/
namespace eosio {
constexpr name system_account{"eosio"_n};
constexpr name eden_account{"genesis.eden"_n};
constexpr name eden_account{"genesisdeden"_n};
constexpr name eden_scope{"eden"_n};

/*
Expand Down Expand Up @@ -233,18 +234,6 @@ namespace eosio {
} // namespace eosio

namespace eoscostarica {
extern const char* rate_ricardian;
extern const char* erase_ricardian;
extern const char* wipe_ricardian;
extern const char* rminactive_ricardian;
extern const char* rmrate_ricardian;

extern const char* datastorage_clause;
extern const char* datausage_clause;
extern const char* dataownership_clause;
extern const char* datadistribution_clause;
extern const char* datafuture_clause;

/*
* Stores the rate average stats for a block producer
*/
Expand Down Expand Up @@ -272,6 +261,10 @@ namespace eoscostarica {
)
typedef eosio::multi_index<"stats"_n, stats > stats_table;

uint128_t create_uniq_rating(const uint64_t &user, const uint64_t &bp) {
return (static_cast<uint128_t>(user) << 64) | bp;
}

/*
* Stores the rate vote for a block producer
*/
Expand Down Expand Up @@ -308,6 +301,38 @@ namespace eoscostarica {
indexed_by<"bp"_n, const_mem_fun<ratings, uint64_t, &ratings::by_bp>>
> ratings_table;

/*
* Stores the rate vote for a block producer
*/
struct ratings_v2 {
uint64_t id;
name user;
name bp;
uint8_t transparency;
uint8_t infrastructure;
uint8_t trustiness;
uint8_t development;
uint8_t community;
uint64_t primary_key() const { return id; }
uint128_t by_uniq_rating() const { return create_uniq_rating(user.value, bp.value); }
uint64_t by_bp() const { return bp.value; }
};
EOSIO_REFLECT(
ratings_v2,
id,
user,
bp,
transparency,
infrastructure,
trustiness,
development,
community
)
typedef eosio::multi_index<"rating"_n, ratings_v2,
indexed_by<"uniqrating"_n, const_mem_fun<ratings_v2, uint128_t, &ratings_v2::by_uniq_rating>>,
indexed_by<"bp"_n, const_mem_fun<ratings_v2, uint64_t, &ratings_v2::by_bp>>
> ratings_table_v2;

/*
* Stores contract config for migration versioning
*/
Expand Down Expand Up @@ -410,7 +435,7 @@ namespace eoscostarica {
*/
void save_bp_stats (
name scope,
name user,
name ram_payer,
name bp_name,
float transparency,
float infrastructure,
Expand Down Expand Up @@ -471,7 +496,7 @@ namespace eoscostarica {
*/
void update_bp_stats (
name scope,
name * user,
name * ram_payer,
name * bp_name,
float * transparency,
float * infrastructure,
Expand Down Expand Up @@ -569,19 +594,40 @@ namespace eoscostarica {

/**
*
* Load existing eden member rates into rateproducer scope
* NOTE: This function should be removed after migration run
* Erase a rate made for a specific account
* to a specific block producer
*
* @param scope - Table scope,
* @param user - Voter account name,
* @param bp - Block Producer account name
*
*/
void update_stats_migration(name bp);

/**
*
* Update the current logic to newest
*
*/
void migrate();

/**
*
* Liberate the ram used on ratings table under rateproducer and eden scope
*
*/
void loadedens();
void freeupram();
};

EOSIO_ACTIONS(rateproducer,
"rateproducer"_n,
action(rate, user, bp, transparency, infrastructure, trustiness, community, development),
action(erase, bp_name),
action(wipe),
action(rminactive),
action(rmrate, user, bp),
action(loadedens))
action(rate, user, bp, transparency, infrastructure, trustiness, community, development, ricardian_contract(rate_ricardian)),
action(erase, bp_name, ricardian_contract(erase_ricardian)),
action(wipe, ricardian_contract(wipe_ricardian)),
action(rminactive, ricardian_contract(rminactive_ricardian)),
action(rmrate, user, bp, ricardian_contract(rmrate_ricardian)),
action(migrate, ricardian_contract(migrate_ricardian)),
action(freeupram, ricardian_contract(freeupram_ricardian)))

} // namespace eoscostarica
58 changes: 32 additions & 26 deletions contracts/rateproducer/rateproducer.abi
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,23 @@
]
},
{
"name": "loadedens",
"name": "migrate",
"base": "",
"fields": []
},
{
"name": "ratings",
"name": "freeupram",
"base": "",
"fields": []
},
{
"name": "ratings_v2",
"base": "",
"fields": [
{
"name": "id",
"type": "uint64"
},
{
"name": "uniq_rating",
"type": "uint128"
},
{
"name": "user",
"type": "name"
Expand All @@ -97,23 +98,23 @@
},
{
"name": "transparency",
"type": "float32"
"type": "uint8"
},
{
"name": "infrastructure",
"type": "float32"
"type": "uint8"
},
{
"name": "trustiness",
"type": "float32"
"type": "uint8"
},
{
"name": "development",
"type": "float32"
"type": "uint8"
},
{
"name": "community",
"type": "float32"
"type": "uint8"
}
]
},
Expand Down Expand Up @@ -165,7 +166,7 @@
{
"name": "erase",
"type": "erase",
"ricardian_contract": "---\spec_version: 0.1.0\ntitle: Erase Block Producer Stats\nsummary: The intent of the `{{ erase }}` action is to provide a ways to clear all data related with a specific block producer.\n---"
"ricardian_contract": "---\nspec_version: 0.1.0\ntitle: Erase Block Producer Stats\nsummary: The intent of the `{{ erase }}` action is to provide a ways to clear all data related with a specific block producer.\n---"
},
{
"name": "wipe",
Expand All @@ -183,18 +184,23 @@
"ricardian_contract": "---\nspec_version: 0.1.0\ntitle: Remove a especific rate\nsummary: The intent of the `{{ rmrate }}` action is to remove a rate made from an especific account.\n---"
},
{
"name": "loadedens",
"type": "loadedens",
"ricardian_contract": "---\nspec_version: 0.1.0\ntitle: Load existing eden members\nsummary: The intent of the `{{ loadedens }}` action is to migrate and load existing rates made by eden members into eden scope.\n---"
"name": "migrate",
"type": "migrate",
"ricardian_contract": "---\nspec_version: 0.1.0\ntitle: Update the current logic to newest\nsummary: The intent of the `{{ migrate }}` action is to update the current logic to newest.\n---"
},
{
"name": "freeupram",
"type": "freeupram",
"ricardian_contract": "---\nspec_version: 0.1.0\ntitle: Free up RAM\nsummary: The intent of the `{{ freeupram }}` action is to remove all records from old ratings table including the rateproducer and eden scope.\n---"
}
],
"tables": [
{
"name": "ratings",
"name": "rating",
"index_type": "i64",
"key_names": [],
"key_types": [],
"type": "ratings"
"type": "ratings_v2"
},
{
"name": "stats",
Expand All @@ -206,23 +212,23 @@
],
"ricardian_clauses": [
{
"id": "Data Storage",
"body": "The affiliate application values the security of personal data. We may process only minimal user data as much as it is necessary to maintain the affiliate application running. We only receive and store any information you knowingly provide to us when you create an account, or fill using the app."
"id": "datastorage",
"body": "The rateproducer application values the security of personal data. We may process only minimal user data as much as it is necessary to maintain the rateproducer application running. We only receive and store any information you knowingly provide to us when you create an account, or fill using the app."
},
{
"id": "Data Usage",
"body": "This smart contract will process user data to keep the affiliate application running. Any of the information we collect from you may be used for these purposes:\n - Create and manage user accounts.\n - Run and operate the affiliate application."
"id": "datausage",
"body": "This smart contract will process user data to keep the rateproducer application running. Any of the information we collect from you may be used for these purposes:\n- Create and manage user accounts.\n- Run and operate the rateproducer application."
},
{
"id": "Data Ownership",
"body": "The user of this smart contract verifies that the smart contract owns the data and that it can use the data in accordance with the terms defined in the Ricardian contract.\nYou can delete certain personal information you shared with the affiliate application. When you delete personal information, we may maintain a copy of the unrevised personal information in our records for the duration necessary to comply with our obligations to our affiliates and partners, and for the purposes described below. If you would like to delete your personal information or permanently delete your account, you can do so on your account's profile page in the affiliate application.\nWe will retain and use your personal information for the period necessary to comply with our legal obligations, resolve disputes, and enforce our agreements unless a more extended retention period is required or permitted by law. We may use any aggregated data derived from or incorporating your personal information after you update or delete it, but not in a manner that would identify you personally. Once the retention period expires, personal information shall be deleted."
"id": "dataownership",
"body": "The user of this smart contract verifies that the smart contract owns the data and that it can use the data in accordance with the terms defined in the Ricardian contract.\nYou can delete certain personal information you shared with the rateproducer application. When you delete personal information, we may maintain a copy of the unrevised personal information in our records for the duration necessary to comply with our obligations to our affiliates and partners, and for the purposes described below. If you would like to delete your personal information or permanently delete your account, you can do so on your account's profile page in the rateproducer application.\nWe will retain and use your personal information for the period necessary to comply with our legal obligations, resolve disputes, and enforce our agreements unless a more extended retention period is required or permitted by law. We may use any aggregated data derived from or incorporating your personal information after you update or delete it, but not in a manner that would identify you personally. Once the retention period expires, personal information shall be deleted."
},
{
"id": "Data Distribution",
"body": "The smart contract promises not actively to share or distribute the address data. The smart contract user understands that data stored in a multi-index table is not private and can be accessed by any user of the blockchain.\nDepending on your location, data transfers may involve transferring and storing your information in a country other than your own. Moreover, to keep affiliate running, we must share necessary personal data such as your name with the authorized blood donation centers and sponsors. We do not store any information regarding your blood type, health conditions, or any other confidential information between you and the donation centers."
"id": "datadistribution",
"body": "The smart contract promises not actively to share or distribute the address data. The smart contract user understands that data stored in a multi-index table is not private and can be accessed by any user of the blockchain.\nDepending on your location, data transfers may involve transferring and storing your information in a country other than your own. Moreover, to keep rateproducer running, we must share necessary personal data such as your name with the authorized blood donation centers and sponsors. We do not store any information regarding your blood type, health conditions, or any other confidential information between you and the donation centers."
},
{
"id": "Data Future",
"id": "datafuture",
"body": "The smart contract promises to only use the data following the terms defined in the Ricardian contract, now and at all future dates. You may exercise certain rights regarding your information processed by us. In particular, you have the right to do the following: (i) you have the right to withdraw consent where you have previously given your consent to the processing of your information; (ii) you have the right to object to the processing of your information if the processing is carried out on a legal basis other than consent; (iii) you have the right to learn if information is being processed by us, obtain disclosure regarding certain aspects of the processing and obtain a copy of the information undergoing processing; (iv) you have the right to verify the accuracy of your information and ask for it to be updated or corrected; (v) you have the right, under certain circumstances, to restrict the processing of your information, in which case, we will not process your information for any purpose other than storing it; (vi) you have the right, under certain circumstances, to obtain the erasure of your Personal Information from us; (vii) you have the right to receive your information in a structured, commonly used and machine readable format and, if technically feasible, to have it transmitted to another controller without any hindrance. This provision is applicable provided that your information is processed by automated means and that the processing is based on your consent, on a contract you are part of or on pre-contractual obligations thereof."
}
],
Expand Down
Binary file modified contracts/rateproducer/rateproducer.wasm
Binary file not shown.
Loading

0 comments on commit ef669e3

Please sign in to comment.