Skip to content

Commit

Permalink
Merge pull request #93 from AplaProject/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
syypoo authored Aug 21, 2019
2 parents 9fa87dc + efa0b9d commit e59e5fa
Show file tree
Hide file tree
Showing 437 changed files with 5,623 additions and 4,988 deletions.
368 changes: 184 additions & 184 deletions basic.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion conditions.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
{
"Name": "full_nodes",
"Conditions": "ContractConditions(\"@1DeveloperCondition\")",
"Value": "contract full_nodes {\n data {\n Value string\n }\n\n conditions {\n if Size($Value) == 0 {\n warning \"Value was not received\"\n }\n\n var full_nodes_arr array\n full_nodes_arr = JSONDecode($Value)\n\n var len_arr int\n len_arr = Len(full_nodes_arr)\n\n if len_arr == 0 {\n warning \"Wrong array structure\"\n }\n\n var i int\n while(i < len_arr){\n var node_map map\n node_map = full_nodes_arr[i]\n\n var public_key string\n var tcp_address string\n var api_address string\n var key_id string\n\n public_key = node_map[\"public_key\"]\n tcp_address = node_map[\"tcp_address\"]\n api_address = node_map[\"api_address\"]\n key_id = node_map[\"key_id\"]\n\n if Size(public_key) == 0 {\n warning \"Public key was not received\"\n }\n if Size(tcp_address) == 0 {\n warning \"TCP address was not received\"\n }\n if Size(api_address) == 0 {\n warning \"API address was not received\"\n }\n if Size(key_id) == 0 {\n warning \"Key ID was not received\"\n }\n\n i = i + 1\n }\n }\n}",
"Value": "contract full_nodes {\n data {\n Value string\n }\n\n conditions {\n if Size($Value) == 0 {\n warning \"Value was not received\"\n }\n\n var full_nodes_arr array\n full_nodes_arr = JSONDecode($Value)\n\n var len_arr int\n len_arr = Len(full_nodes_arr)\n\n if len_arr == 0 {\n warning \"Wrong array structure\"\n }\n\n var i int\n while(i < len_arr){\n var node_map map\n node_map = full_nodes_arr[i]\n\n var public_key string\n var tcp_address string\n var api_address string\n var key_id string\n\n public_key = node_map[\"public_key\"]\n tcp_address = node_map[\"tcp_address\"]\n api_address = node_map[\"api_address\"]\n key_id = node_map[\"key_id\"]\n\n if Size(public_key) == 0 {\n warning \"Public key was not received\"\n }\n if Size(tcp_address) == 0 {\n warning \"TCP address was not received\"\n }\n if Size(api_address) == 0 {\n warning \"API address was not received\"\n }\n if Size(key_id) == 0 {\n warning \"Account was not received\"\n }\n\n i = i + 1\n }\n }\n}",
"Type": "contracts"
},
{
Expand Down
34 changes: 17 additions & 17 deletions ecosystem_apps/crediting.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions ecosystem_apps/crediting/contracts/CreditingAdd.sim
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ contract CreditingAdd {
$check_access = AppParam(Int($app), "crediting_borrower_role", $ecosystem_id)
var rids array
rids = JSONDecode("["+$check_access+"]")
if !DBFind("@1roles_participants").Where({"ecosystem": $ecosystem_id, "role->id": {"$in": rids}, "member->member_id": $key_id, "deleted": 0}).Row() {
if !DBFind("@1roles_participants").Where({"ecosystem": $ecosystem_id, "role->id": {"$in": rids}, "member->account": $account_id, "deleted": 0}).Row() {
warning LangRes("@1access_denied", "en")
}

Expand All @@ -75,7 +75,7 @@ contract CreditingAdd {

//check borrower
if Int($Id) > 0 {
if AddressToId(borrower) != $key_id {
if borrower != $account_id {
warning LangRes("@1access_denied", "en")
}
}
Expand All @@ -95,7 +95,7 @@ contract CreditingAdd {
action {
var m map
if Int($Id) == 0 {
m["borrower"] = IdToAddress($key_id)
m["borrower"] = $account_id
m["status"] = 0
m["deleted"] = 0
m["date_created"] = $block_time
Expand Down
15 changes: 7 additions & 8 deletions ecosystem_apps/crediting/contracts/CreditingBid.sim
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ contract CreditingBid {

func closeMyNotes() {
var notes array i int
notes = DBFind("@1notifications").Where({"closed": 0, "ecosystem": $ecosystem_id, "recipient->member_id": $key_id, "page_name": "crediting_view", "page_params->crediting_id": $RequestId})
notes = DBFind("@1notifications").Where({"closed": 0, "ecosystem": $ecosystem_id, "recipient->account": $account_id, "page_name": "crediting_view", "page_params->crediting_id": $RequestId})
while i < Len(notes){
var note map
note = notes[i]
Expand All @@ -17,19 +17,18 @@ contract CreditingBid {

func sendNotesNewBid() {
var i int subs_arr array
$KeyId = IdToAddress($key_id)
subs_arr = DBFind("crediting_subs").Columns("creditor").Limit(10000).Where({"creditor": {"$neq": $KeyId}, "request_id": $RequestId, "deleted": 0})
subs_arr = DBFind("crediting_subs").Where({"creditor": {"$neq": $account_id}, "request_id": $RequestId, "deleted": 0}).Columns("creditor").Limit(10000)
while i < Len(subs_arr) {
var sub_map memberId int
var sub_map int memberAccount string
sub_map = subs_arr[i]
memberId = AddressToId(sub_map["creditor"])
memberAccount = sub_map["creditor"]

var header body string params map
header = "New bid on auction №" + Str($RequestId)
body = "Check auction for information"
params["crediting_id"] = $RequestId
params["optional"] = 1
@1NotificationsSend("MemberId,Sender,Icon,Header,Body,Page,Params", memberId, 1, "fa-fire", header, body, "crediting_view", params)
@1NotificationsSend("MemberAccount,Sender,Icon,Header,Body,Page,Params", memberAccount, 1, "fa-fire", header, body, "crediting_view", params)
i = i + 1
}
}
Expand All @@ -40,7 +39,7 @@ contract CreditingBid {
$check_access = AppParam(Int($app), "crediting_creditor_role", $ecosystem_id)
var rids array
rids = JSONDecode("["+$check_access+"]")
if !DBFind("@1roles_participants").Where({"ecosystem": $ecosystem_id, "role->id": {"$in": rids}, "member->member_id": $key_id, "deleted": 0}).Row() {
if !DBFind("@1roles_participants").Where({"ecosystem": $ecosystem_id, "role->id": {"$in": rids}, "member->account": $account_id, "deleted": 0}).Row() {
warning LangRes("@1access_denied", "en")
}

Expand All @@ -59,7 +58,7 @@ contract CreditingBid {
sendNotesNewBid()

var m map
m["creditor"] = IdToAddress($key_id)
m["creditor"] = $account_id
m["date_created"] = $block_time
m["rate"] = $Rate
m["request_id"] = $RequestId
Expand Down
2 changes: 1 addition & 1 deletion ecosystem_apps/crediting/contracts/CreditingBlock.sim
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ contract CreditingBlock {
$check_access = AppParam(Int($app), "crediting_admin_role", $ecosystem_id)
var rids array
rids = JSONDecode("["+$check_access+"]")
if !DBFind("@1roles_participants").Where({"ecosystem": $ecosystem_id, "role->id": {"$in": rids}, "member->member_id": $key_id, "deleted": 0}).Row() {
if !DBFind("@1roles_participants").Where({"ecosystem": $ecosystem_id, "role->id": {"$in": rids}, "member->account": $account_id, "deleted": 0}).Row() {
warning LangRes("@1access_denied", "en")
}
}
Expand Down
2 changes: 1 addition & 1 deletion ecosystem_apps/crediting/contracts/CreditingDel.sim
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ contract CreditingDel {
}

//check borrower
if AddressToId(borrower) != $key_id {
if borrower != $account_id {
warning LangRes("@1access_denied", "en")
}
}
Expand Down
14 changes: 6 additions & 8 deletions ecosystem_apps/crediting/contracts/CreditingSignAccept.sim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ contract CreditingSignAccept {

func closeMyNotes() {
var notes array i int
notes = DBFind("@1notifications").Where({"closed": 0, "ecosystem": $ecosystem_id, "recipient->member_id": $key_id, "page_name": "crediting_view", "page_params->crediting_id": $Id})
notes = DBFind("@1notifications").Where({"closed": 0, "ecosystem": $ecosystem_id, "recipient->account": $account_id, "page_name": "crediting_view", "page_params->crediting_id": $Id})
while i < Len(notes){
var note map
note = notes[i]
Expand All @@ -32,31 +32,29 @@ contract CreditingSignAccept {
}

//check borrower && creditor
if AddressToId($borrower) != $key_id && AddressToId($creditor) != $key_id {
if $borrower != $account_id && $creditor != $account_id {
warning LangRes("@1access_denied", "en")
}

$pub = DBFind("@1keys").Where({"ecosystem": $ecosystem_id, "id": $key_id}).One("pub")
$pub = DBFind("@1keys").Where({"ecosystem": $ecosystem_id, "account": $account_id, "deleted": 0}).One("pub")
$pub = PubToHex($pub)
}

action {
closeMyNotes()

var m map
if AddressToId($borrower) == $key_id && $sign_borrower == 0 {
if $borrower == $account_id && $sign_borrower == 0 {
m["sign_borrower"] = $block_time
m["pub_borrower"] = $pub
$sign_borrower = $block_time

var memberId int
var header body string params map
memberId = AddressToId($creditor)
header = "Signature for auction №" + Str($Id)
body = "Your signature is required!"
params["crediting_id"] = $Id
@1NotificationsSend("MemberId,Sender,Icon,Header,Body,Page,Params", memberId, 1, "fa-edit", header, body, "crediting_view", params)
} elif AddressToId($creditor) == $key_id && $sign_creditor == 0 {
@1NotificationsSend("MemberAccount,Sender,Icon,Header,Body,Page,Params", $creditor, 1, "fa-edit", header, body, "crediting_view", params)
} elif $creditor == $account_id && $sign_creditor == 0 {
m["sign_creditor"] = $block_time
m["pub_creditor"] = $pub
$sign_creditor = $block_time
Expand Down
4 changes: 2 additions & 2 deletions ecosystem_apps/crediting/contracts/CreditingSignReject.sim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ contract CreditingSignReject {

func closeMyNotes() {
var notes array i int
notes = DBFind("@1notifications").Where({"closed": 0, "ecosystem": $ecosystem_id, "recipient->member_id": $key_id, "page_name": "crediting_view", "page_params->crediting_id": $Id})
notes = DBFind("@1notifications").Where({"closed": 0, "ecosystem": $ecosystem_id, "recipient->account": $account_id, "page_name": "crediting_view", "page_params->crediting_id": $Id})
while i < Len(notes){
var note map
note = notes[i]
Expand All @@ -27,7 +27,7 @@ contract CreditingSignReject {
}

//check borrower && creditor
if AddressToId($borrower) != $key_id && AddressToId($creditor) != $key_id {
if $borrower != $account_id && $creditor != $account_id {
warning LangRes("@1access_denied", "en")
}
}
Expand Down
25 changes: 12 additions & 13 deletions ecosystem_apps/crediting/contracts/CreditingStatusUpdate.sim
Original file line number Diff line number Diff line change
Expand Up @@ -14,51 +14,50 @@ contract CreditingStatusUpdate {
offer_date = offers["date_created"]
DBUpdate("crediting_requests", request_id, {"creditor": creditor, "rate": rate, "offer_id": offer_id, "offer_date": offer_date})

var memberId int
var header body string params map
memberId = AddressToId(request["borrower"])
var header body memberAccount string params map
memberAccount = request["borrower"]
header = "Signature for auction №" + Str(request_id)
body = "Your signature is required!"
params["crediting_id"] = request_id
@1NotificationsSend("MemberId,Sender,Icon,Header,Body,Page,Params", memberId, 1, "fa-edit", header, body, "crediting_view", params)
@1NotificationsSend("MemberAccount,Sender,Icon,Header,Body,Page,Params", memberAccount, 1, "fa-edit", header, body, "crediting_view", params)
}
return offer_id
}

func sendNotesAuctionStarted(request map) {
var request_id i int subs_arr array
request_id = Int(request["id"])
subs_arr = DBFind("crediting_subs").Columns("creditor").Limit(10000).Where({"request_id": request_id, "deleted": 0})
subs_arr = DBFind("crediting_subs").Where({"request_id": request_id, "deleted": 0}).Columns("creditor").Limit(10000)
while i < Len(subs_arr) {
var sub_map memberId int
var sub_map int memberAccount string
sub_map = subs_arr[i]
memberId = AddressToId(sub_map["creditor"])
memberAccount = sub_map["creditor"]

var header body string params map
header = "Auction №" + Str(request_id) + " started"
body = "You can bid now!"
params["crediting_id"] = request_id
params["optional"] = 1
@1NotificationsSend("MemberId,Sender,Icon,Header,Body,Page,Params", memberId, 1, "fa-check", header, body, "crediting_view", params)
@1NotificationsSend("MemberAccount,Sender,Icon,Header,Body,Page,Params", memberAccount, 1, "fa-check", header, body, "crediting_view", params)
i = i + 1
}
}

func sendNotesAuctionFinished(request map) {
var request_id i int subs_arr array
request_id = Int(request["id"])
subs_arr = DBFind("crediting_subs").Columns("creditor").Limit(10000).Where({"request_id": request_id, "deleted": 0})
subs_arr = DBFind("crediting_subs").Where({"request_id": request_id, "deleted": 0}).Columns("creditor").Limit(10000)
while i < Len(subs_arr) {
var sub_map memberId int
var sub_map int memberAccount string
sub_map = subs_arr[i]
memberId = AddressToId(sub_map["creditor"])
memberAccount = sub_map["creditor"]

var header body string params map
header = "Auction №" + Str(request_id) + " finished"
body = "You can't bid anymore!"
params["crediting_id"] = request_id
params["optional"] = 1
@1NotificationsSend("MemberId,Sender,Icon,Header,Body,Page,Params", memberId, 1, "fa-close", header, body, "crediting_view", params)
@1NotificationsSend("MemberAccount,Sender,Icon,Header,Body,Page,Params", memberAccount, 1, "fa-close", header, body, "crediting_view", params)
i = i + 1
}
}
Expand Down Expand Up @@ -97,7 +96,7 @@ contract CreditingStatusUpdate {
$check_access = AppParam(Int($app), "crediting_admin_role", $ecosystem_id)
var rids array
rids = JSONDecode("["+$check_access+"]")
if !DBFind("@1roles_participants").Where({"ecosystem": $ecosystem_id, "role->id": {"$in": rids}, "member->member_id": $key_id, "deleted": 0}).Row() {
if !DBFind("@1roles_participants").Where({"ecosystem": $ecosystem_id, "role->id": {"$in": rids}, "member->account": $account_id, "deleted": 0}).Row() {
warning LangRes("@1access_denied", "en")
}
}
Expand Down
5 changes: 2 additions & 3 deletions ecosystem_apps/crediting/contracts/CreditingSubscribe.sim
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ contract CreditingSubscribe {
}

conditions {
$KeyId = IdToAddress($key_id)
$request = DBFind("crediting_subs").Where({"request_id": $Id, "creditor": $KeyId, "deleted": 0}).One("id")
$request = DBFind("crediting_subs").Where({"request_id": $Id, "creditor": $account_id, "deleted": 0}).One("id")
}

action {
Expand All @@ -15,7 +14,7 @@ contract CreditingSubscribe {
DBUpdate("crediting_subs", Int($request), m)
} else {
m["request_id"] = $Id
m["creditor"] = $KeyId
m["creditor"] = $account_id
DBInsert("crediting_subs", m)
}
}
Expand Down
2 changes: 1 addition & 1 deletion ecosystem_apps/crediting/languages/crediting_settings.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"en": "Crediting settings", "ru": "Настройки Кридитования"}
{"en": "Crediting settings", "ru": "Настройки Кредитования"}
6 changes: 3 additions & 3 deletions ecosystem_apps/crediting/pages/crediting_add.ptl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
DBFind(@1applications).Where({"ecosystem": #ecosystem_id#, "name": "Crediting"}).Columns("name,id").Vars(application)
DBFind("@1applications").Where({"ecosystem": "#ecosystem_id#", "name": "Crediting"}).Columns("name,id").Vars(application)
If(#Id#>0){
DBFind(crediting_requests).Where({"id": #Id#}).Vars(request)
DBFind("crediting_requests").Where({"id": "#Id#"}).Vars(request)
}
Form(){
Div(list-group-item){
Expand All @@ -12,7 +12,7 @@ Form(){
}
}
Div(col-md-9 text-left){
SetVar(borrower, Address(#key_id#))
SetVar(borrower, #account_id#)
Input(Name: Borrower, Disabled: 1, Value: #borrower#)
}
}
Expand Down
7 changes: 3 additions & 4 deletions ecosystem_apps/crediting/pages/crediting_history.ptl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
DBFind(crediting_offers, offers).Where({"request_id": #Id#}).Order({"rate": 1, "date_created": 1}).Custom(custom_creditor){
SetVar(creditor_id, AddressToId(#creditor#))
DBFind(@1members).Where({"ecosystem": #ecosystem_id#, "id": #creditor_id#}).Columns("member_info->information").Vars(c)
LinkPage(Class: text-primary h5 text-bold, Page: @1profile_view, PageParams: "v_key_id=#c_id#"){
DBFind("crediting_offers", offers).Where({"request_id": "#Id#"}).Order({"rate": 1, "date_created": 1}).Custom(custom_creditor){
DBFind("@1members").Where({"ecosystem": "#ecosystem_id#", "account": "#creditor#"}).Columns("member_info->information").Vars(c)
LinkPage(Class: text-primary h5 text-bold, Page: @1profile_view, PageParams: "v_account=#c_account#"){
Div(){
Span(Em(Class: fa icon-user fa-2x)).Style(margin-right:10px;)
Span(){
Expand Down
Loading

0 comments on commit e59e5fa

Please sign in to comment.