Skip to content

Commit

Permalink
Merge branch 'staging'
Browse files Browse the repository at this point in the history
  • Loading branch information
xavier506 committed Sep 1, 2021
2 parents 3232ddf + b89f305 commit d34f811
Show file tree
Hide file tree
Showing 4 changed files with 241 additions and 13 deletions.
8 changes: 1 addition & 7 deletions contracts/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,4 @@

.DS_Store
build
.vscode


# EOS contracts wasm and abi
*.wast
*.abi
*.wasm
.vscode
232 changes: 232 additions & 0 deletions contracts/rateproducer/rateproducer.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
{
"version": "eosio::abi/1.1",
"types": [],
"structs": [
{
"name": "rate",
"base": "",
"fields": [
{
"name": "user",
"type": "name"
},
{
"name": "bp",
"type": "name"
},
{
"name": "transparency",
"type": "int8"
},
{
"name": "infrastructure",
"type": "int8"
},
{
"name": "trustiness",
"type": "int8"
},
{
"name": "community",
"type": "int8"
},
{
"name": "development",
"type": "int8"
}
]
},
{
"name": "erase",
"base": "",
"fields": [
{
"name": "bp_name",
"type": "name"
}
]
},
{
"name": "wipe",
"base": "",
"fields": []
},
{
"name": "rminactive",
"base": "",
"fields": []
},
{
"name": "rmrate",
"base": "",
"fields": [
{
"name": "user",
"type": "name"
},
{
"name": "bp",
"type": "name"
}
]
},
{
"name": "loadedens",
"base": "",
"fields": []
},
{
"name": "ratings",
"base": "",
"fields": [
{
"name": "id",
"type": "uint64"
},
{
"name": "uniq_rating",
"type": "uint128"
},
{
"name": "user",
"type": "name"
},
{
"name": "bp",
"type": "name"
},
{
"name": "transparency",
"type": "float32"
},
{
"name": "infrastructure",
"type": "float32"
},
{
"name": "trustiness",
"type": "float32"
},
{
"name": "development",
"type": "float32"
},
{
"name": "community",
"type": "float32"
}
]
},
{
"name": "stats",
"base": "",
"fields": [
{
"name": "bp",
"type": "name"
},
{
"name": "ratings_cntr",
"type": "uint32"
},
{
"name": "average",
"type": "float32"
},
{
"name": "transparency",
"type": "float32"
},
{
"name": "infrastructure",
"type": "float32"
},
{
"name": "trustiness",
"type": "float32"
},
{
"name": "development",
"type": "float32"
},
{
"name": "community",
"type": "float32"
}
]
}
],
"actions": [
{
"name": "rate",
"type": "rate",
"ricardian_contract": "---\nspec_version: 0.1.0\ntitle: Rate a block producer\nsummary: The intent of the `{{ rate }}` action is to allow the `issuer` account to rate a blockproducer into five categories: Community, Development, Infraestructure, Transparency, Trustiness.\n---"
},
{
"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---"
},
{
"name": "wipe",
"type": "wipe",
"ricardian_contract": "---\nspec_version: 0.1.0\ntitle: Wipe all contract's tables\nsummary: The intent of the `{{ wipe }}` action is to provide a way to release the stored data within the contract.\n---"
},
{
"name": "rminactive",
"type": "rminactive",
"ricardian_contract": "---\nspec_version: 0.1.0\ntitle: Erase innactive Block Producer\nsummary: The intent of the `{{ rminactive }}` action is to provide a method to purge stats related with inactive block producers.\n---"
},
{
"name": "rmrate",
"type": "rmrate",
"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---"
}
],
"tables": [
{
"name": "ratings",
"index_type": "i64",
"key_names": [],
"key_types": [],
"type": "ratings"
},
{
"name": "stats",
"index_type": "i64",
"key_names": [],
"key_types": [],
"type": "stats"
}
],
"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": "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": "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": "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": "Data Future",
"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."
}
],
"error_messages": [],
"abi_extensions": [],
"variants": []
}
Binary file added contracts/rateproducer/rateproducer.wasm
Binary file not shown.
14 changes: 8 additions & 6 deletions contracts/rateproducer/src/rateproducer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,20 @@ namespace eoscostarica {
check( (MINVAL<= development && development <=MAXVAL ), "Error development value out of range" );
check( (MINVAL<= community && community<=MAXVAL ), "Error community value out of range" );

//checks if the bp is active
bool isEden = is_eden(user);

// checks if the bp is active
check( is_blockproducer(bp), "votes are allowed only for registered block producers" );

eosio::name proxy_name = get_proxy(user);
if(proxy_name.length()) {
//active proxy??
// active proxy??
check(is_active_proxy(proxy_name), "votes are allowed only for active proxies" );
//account votes through a proxy
check(!(MIN_VOTERS > get_voters(proxy_name)), "delegated proxy does not have enough voters" );
// account votes through a proxy
if(!isEden) check( MIN_VOTERS <= get_voters(proxy_name), "delegated proxy does not have enough voters" );
} else {
// acount must vote for at least 21 bp
check(!(MIN_VOTERS > get_voters(user)), "account does not have enough voters" );
if(!isEden) check( MIN_VOTERS <= get_voters(user), "account does not have enough voters" );
}

// upsert bp rating
Expand Down Expand Up @@ -115,7 +117,7 @@ namespace eoscostarica {
&bp_average);
}
}

void rateproducer::save_bp_stats (
name scope,
name user,
Expand Down

0 comments on commit d34f811

Please sign in to comment.