- "Value": "contract VotingTemplatesInstall {\n data {\n SetDefault string \"optional\"\n }\n\n func applyTemplate(m map, param string) {\n var templateId paramId int\n templateId = DBInsert(\"@1voting_templates\", m)\n\n if $SetDefault == \"yes\" {\n paramId = Int(DBFind(\"@1app_params\").Where({\"app_id\": $app_id, \"name\": param, \"ecosystem\": $ecosystem_id}).One(\"id\"))\n if paramId > 0 {\n @1EditAppParam(\"Id,Value\", paramId, templateId)\n }\n }\n }\n\n func getRoleId(name string) int {\n var rid int\n rid = Int(AppParam(Int($system_app_id), name, $ecosystem_id))\n if rid == 0 {\n warning Sprintf(LangRes(\"@role_not_set_application_parameter\", \"en\"), name)\n }\n return rid\n }\n\n func installSystem() {\n var template map\n\n // Sysparam\n template[\"voting->name\"] = \"Voting for Platform Parameter\"\n template[\"voting->type\"] = 2\n template[\"voting->volume\"] = 70\n template[\"voting->quorum\"] = 51\n template[\"voting->rating\"] = 0\n template[\"voting->count_type_voters\"] = 0\n template[\"voting->type_decision\"] = 4\n template[\"voting->type_participants\"] = 3\n template[\"subject->candidates\"] = 0\n template[\"subject->vacancies\"] = 0\n template[\"subject->voters\"] = $consensusRoleId\n template[\"subject->contract_accept\"] = \"@1UpdateSysParam\"\n template[\"subject->contract_reject\"] = \"\"\n template[\"optional->contract_accept\"] = \"\"\n template[\"optional->contract_reject\"] = \"\"\n template[\"optional->init_contract\"] = \"\"\n template[\"optional->contract_accept_params\"] = \"\"\n template[\"optional->contract_reject_params\"] = \"\"\n template[\"optional->init_contract_params\"] = \"\"\n template[\"ecosystem\"] = 1\n applyTemplate(template, \"voting_template_platformparams\")\n\n // Validator\n template[\"voting->name\"] = \"Voting for Validator\"\n template[\"voting->type\"] = 2\n template[\"voting->volume\"] = 70\n template[\"voting->quorum\"] = 51\n template[\"voting->rating\"] = 0\n template[\"voting->count_type_voters\"] = 0\n template[\"voting->type_decision\"] = 4\n template[\"voting->type_participants\"] = 3\n template[\"subject->candidates\"] = 0\n template[\"subject->vacancies\"] = 0\n template[\"subject->voters\"] = $consensusRoleId\n template[\"subject->contract_accept\"] = \"@1UpdateSysParam\"\n template[\"subject->contract_reject\"] = \"\"\n template[\"optional->contract_accept\"] = \"VotingValidatorAccept\"\n template[\"optional->contract_reject\"] = \"\"\n template[\"optional->init_contract\"] = \"\"\n template[\"optional->contract_accept_params\"] = \"\"\n template[\"optional->contract_reject_params\"] = \"\"\n template[\"optional->init_contract_params\"] = \"\"\n template[\"ecosystem\"] = 1\n applyTemplate(template, \"voting_template_validators\")\n\n // Valued ecosystem\n template[\"voting->name\"] = \"Voting for Valued Ecosystem\"\n template[\"voting->type\"] = 2\n template[\"voting->volume\"] = 70\n template[\"voting->quorum\"] = 51\n template[\"voting->rating\"] = 0\n template[\"voting->count_type_voters\"] = 0\n template[\"voting->type_decision\"] = 4\n template[\"voting->type_participants\"] = 3\n template[\"subject->candidates\"] = 0\n template[\"subject->vacancies\"] = 0\n template[\"subject->voters\"] = $consensusRoleId\n template[\"subject->contract_accept\"] = \"VotingVesAccept\"\n template[\"subject->contract_reject\"] = \"\"\n template[\"optional->contract_accept\"] = \"\"\n template[\"optional->contract_reject\"] = \"\"\n template[\"optional->init_contract\"] = \"\"\n template[\"optional->contract_accept_params\"] = \"\"\n template[\"optional->contract_reject_params\"] = \"\"\n template[\"optional->init_contract_params\"] = \"\"\n template[\"ecosystem\"] = 1\n applyTemplate(template, \"voting_template_ves\")\n\n // Token refund\n template[\"voting->name\"] = \"Voting for Token Refund\"\n template[\"voting->type\"] = 2\n template[\"voting->volume\"] = 70\n template[\"voting->quorum\"] = 51\n template[\"voting->rating\"] = 0\n template[\"voting->count_type_voters\"] = 0\n template[\"voting->type_decision\"] = 4\n template[\"voting->type_participants\"] = 3\n template[\"subject->candidates\"] = 0\n template[\"subject->vacancies\"] = 0\n template[\"subject->voters\"] = $consensusRoleId\n template[\"subject->contract_accept\"] = \"TokensRefundAccept\"\n template[\"subject->contract_reject\"] = \"TokensRefundReject\"\n template[\"optional->contract_accept\"] = \"\"\n template[\"optional->contract_reject\"] = \"\"\n template[\"optional->init_contract\"] = \"\"\n template[\"optional->contract_accept_params\"] = \"\"\n template[\"optional->contract_reject_params\"] = \"\"\n template[\"optional->init_contract_params\"] = \"\"\n template[\"ecosystem\"] = 1\n applyTemplate(template, \"voting_template_tokenrefund\")\n\n // Change parameter of the ecosystem\n template[\"voting->name\"] = \"Voting for Ecosystem Parameter\"\n template[\"voting->type\"] = 2\n template[\"voting->volume\"] = 70\n template[\"voting->quorum\"] = 75\n template[\"voting->rating\"] = 0\n template[\"voting->count_type_voters\"] = 0\n template[\"voting->type_decision\"] = 4\n template[\"voting->type_participants\"] = 3\n template[\"subject->candidates\"] = 0\n template[\"subject->vacancies\"] = 0\n template[\"subject->voters\"] = $consensusRoleId\n template[\"subject->contract_accept\"] = \"@1EditParameter\"\n template[\"subject->contract_reject\"] = \"\"\n template[\"optional->contract_accept\"] = \"\"\n template[\"optional->contract_reject\"] = \"\"\n template[\"optional->init_contract\"] = \"\"\n template[\"optional->contract_accept_params\"] = \"\"\n template[\"optional->contract_reject_params\"] = \"\"\n template[\"optional->init_contract_params\"] = \"\"\n template[\"ecosystem\"] = 1\n applyTemplate(template, \"voting_template_ecosysparams\")\n }\n\n func installCustom() {\n var template map\n\n // A decision by a simple majority of votes\n template[\"voting->name\"] = \"Voting for Decision (simple majority of votes)\"\n template[\"voting->type\"] = 1\n template[\"voting->volume\"] = 70\n template[\"voting->quorum\"] = 51\n template[\"voting->rating\"] = 0\n template[\"voting->count_type_voters\"] = 0\n template[\"voting->type_decision\"] = 3\n template[\"voting->type_participants\"] = 1\n template[\"subject->candidates\"] = 0\n template[\"subject->vacancies\"] = 0\n template[\"subject->voters\"] = 0\n template[\"subject->contract_accept\"] = \"\"\n template[\"subject->contract_reject\"] = \"\"\n template[\"optional->contract_accept\"] = \"\"\n template[\"optional->contract_reject\"] = \"\"\n template[\"optional->init_contract\"] = \"\"\n template[\"optional->contract_accept_params\"] = \"\"\n template[\"optional->contract_reject_params\"] = \"\"\n template[\"optional->init_contract_params\"] = \"\"\n template[\"ecosystem\"] = $ecosystem_id\n applyTemplate(template, \"voting_template_decision\")\n }\n\n conditions {\n $app_id = Int(DBFind(\"@1applications\").Where({\"ecosystem\": $ecosystem_id, \"name\": \"Basic\"}).One(\"id\"))\n $system_app_id = DBFind(\"@1applications\").Where({\"ecosystem\": $ecosystem_id, \"name\": \"System\"}).One(\"id\")\n $consensusRoleId = getRoleId(\"role_consensus\")\n $validatorRoleId = getRoleId(\"role_validator\")\n }\n\n action {\n var arr_templates array count_templates int\n arr_templates = DBFind(\"@1voting_templates\").Where({\"ecosystem\": $ecosystem_id})\n count_templates = Len(arr_templates)\n\n if count_templates == 0 {\n if $ecosystem_id == 1 {\n installSystem()\n }\n installCustom() \n }\n }\n}",
0 commit comments