Skip to content

Commit

Permalink
Release v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
syypoo committed Nov 16, 2018
1 parent 30a1eac commit 0cee834
Show file tree
Hide file tree
Showing 115 changed files with 2,133 additions and 857 deletions.
90 changes: 62 additions & 28 deletions basic.json

Large diffs are not rendered by default.

207 changes: 196 additions & 11 deletions lang_res.json

Large diffs are not rendered by default.

60 changes: 43 additions & 17 deletions other/tokens_sale.json

Large diffs are not rendered by default.

18 changes: 8 additions & 10 deletions other/tokens_sale/blocks/ts_contract_investors.ptl
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,19 @@ Div(list-group-item mt-lg mb-lg ml-lg mr-lg){
Div(Class: h3 text-bold m0 text-center, Body: the KYC screening at SnapSwap International S.A.)

Div(Class: h4 mt-xl, Body: Em(Date: 1st of November 2018))
Div(Class: h4, Body: Em(Re: Invitation to submit purchase orders to buy APL Tokens))
Div(Class: h4, Body: Em(Re: Invitation to submit purchase orders to buy APLA Tokens))

Div(Class: h4 mt-xl, Body: Dear Apla User,)
Div(Class: h4, Body: We are very delighted that you have chosen the Apla blockchain platform to build decentralised applications, create ecosystems and accommodate your other business needs.)
Div(Class: h4, Body: According to Article 8.1 of the Apla General Terms and Conditions (link to the site), EGAAS S.A. will be charging a license fee for each transaction signed by Apla users on the platform. The license fee is payable in the internal virtual currency of the Apla platform ecosystem named APL tokens. Hence, in order to use the platform, you will need to have APL tokens on your APL Wallet prior to signing each transaction.)
Div(Class: h4, Body: EGAAS S.A. will be conducting an initial sale of APL Tokens from November 2018 until July 2019. The commercial terms of the sale are summarised below:)
Div(row){
Div(col-sm-12 text-center){
Button(Class: btn-xs btn-link, Page: ts_commercial_terms){
Span(Class: h4, Body: The commercial terms)
}.Popup(70, The commercial terms)
}
Div(Class: h4, Body: According to Article 8.1 of the Apla General Terms and Conditions (Span(Class: text-primary, Body: www.apla.io)), EGAAS S.A. will be charging a license fee for each transaction signed by Apla users on the platform. The license fee is payable in the internal virtual currency of the Apla platform ecosystem named APLA tokens. Hence, in order to use the platform, you will need to have APLA tokens on your APLA Wallet prior to signing each transaction.)
Div(Class: h4){
Span(EGAAS S.A. will be conducting an initial sale of APLA Tokens from November 2018 until July 2019. The commercial terms of the sale are summarised below:)
Button(Class: btn-xs btn-link, Page: ts_commercial_terms){
Span(Class: h4, Body: The commercial terms)
}.Popup(70, The commercial terms)
}

Div(Class: h4, Body: Please submit your purchase order to buy APL tokens after you have reviewed and agreed with the legal terms of sale.)
Div(Class: h4, Body: Please submit your purchase order to buy APLA tokens after you have reviewed and agreed with the legal terms of sale.)
Div(Class: h4, Body: After we have received your purchase order, we will send you an invoice for making the payment of the purchase price.)
Div(Class: h4, Body: Please reach out to us via the email Span(Class: text-primary, Body: [email protected]) if you have any questions or require any clarification of the above terms. We’ll also give you an access to the online data room with all information and legal documents concerning the Apla project, if you require so.)

Expand Down
20 changes: 19 additions & 1 deletion other/tokens_sale/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
"Name": "TsConsensusAction",
"Conditions": "ContractConditions(\"@1DeveloperCondition\")"
},
{
"Name": "TsFreeWalletAdd",
"Conditions": "ContractConditions(\"@1DeveloperCondition\")"
},
{
"Name": "TsFreeWalletDelete",
"Conditions": "ContractConditions(\"@1DeveloperCondition\")"
},
{
"Name": "TsKeyApprove",
"Conditions": "ContractConditions(\"@1DeveloperCondition\")"
Expand Down Expand Up @@ -77,6 +85,16 @@
"Conditions": "ContractConditions(\"@1DeveloperCondition\")",
"Menu": "default_menu"
},
{
"Name": "ts_free_wallet_add",
"Conditions": "ContractConditions(\"@1DeveloperCondition\")",
"Menu": "default_menu"
},
{
"Name": "ts_free_wallets",
"Conditions": "ContractConditions(\"@1DeveloperCondition\")",
"Menu": "default_menu"
},
{
"Name": "ts_key_approve",
"Conditions": "ContractConditions(\"@1DeveloperCondition\")",
Expand Down Expand Up @@ -135,7 +153,7 @@
},
{
"Name": "ts_wallets",
"Permissions": "{\"insert\": \"ContractAccess(\\\"@1TsKeyApprove\\\")\", \"update\": \"ContractAccess(\\\"@1TsBuyerAction\\\",\\\"@1TsConsensusAction\\\")\", \"new_column\": \"ContractConditions(\\\"@1AdminCondition\\\")\"}"
"Permissions": "{\"insert\": \"ContractAccess(\\\"@1TsFreeWalletAdd\\\")\", \"update\": \"ContractAccess(\\\"@1TsBuyerAction\\\",\\\"@1TsConsensusAction\\\",\\\"@1TsKeyApprove\\\",\\\"@1TsFreeWalletDelete\\\")\", \"new_column\": \"ContractConditions(\\\"@1AdminCondition\\\")\"}"
}
],
"parameters": [
Expand Down
32 changes: 32 additions & 0 deletions other/tokens_sale/contracts/TsFreeWalletAdd.sim
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
contract TsFreeWalletAdd {
data {
wallet_btc string
wallet_eth string
}

conditions {
var adminRoleId int adminRoleName string
adminRoleId = Int(EcosysParam("role_sale_admin"))
adminRoleName = DBFind("@1roles").Where({"id": adminRoleId}).One("role_name")

if adminRoleId == 0 {
warning Sprintf(LangRes("@1role_not_set_application_parameter", "en"), "role_sale_admin")
}

if !RoleAccess(adminRoleId) {
warning Sprintf(LangRes("x_role_only_action", "en"), adminRoleName)
}

if DBFind("ts_wallets").Where({"wallet_btc": $wallet_btc}).One("id") {
warning Sprintf(LangRes("wallet_btc_exists", "en"), $wallet_btc)
}

if DBFind("ts_wallets").Where({"wallet_eth": $wallet_eth}).One("id") {
warning Sprintf(LangRes("wallet_eth_exists", "en"), $wallet_eth)
}
}

action {
DBInsert("ts_wallets", {"wallet_btc": $wallet_btc, "wallet_eth": $wallet_eth})
}
}
23 changes: 23 additions & 0 deletions other/tokens_sale/contracts/TsFreeWalletDelete.sim
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
contract TsFreeWalletDelete {
data {
wallet_id int
}

conditions {
var adminRoleId int adminRoleName string
adminRoleId = Int(EcosysParam("role_sale_admin"))
adminRoleName = DBFind("@1roles").Where({"id": adminRoleId}).One("role_name")

if adminRoleId == 0 {
warning Sprintf(LangRes("@1role_not_set_application_parameter", "en"), "role_sale_admin")
}

if !RoleAccess(adminRoleId) {
warning Sprintf(LangRes("x_role_only_action", "en"), adminRoleName)
}
}

action {
DBUpdate("ts_wallets", $wallet_id, {"deleted": 1})
}
}
30 changes: 29 additions & 1 deletion other/tokens_sale/contracts/TsKeyApprove.sim
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,31 @@ contract TsKeyApprove {
current_role_id int
}

func getFreeWallet() int {
var count_wallets int wallet_map map wallet_arr array
wallet_arr = DBFind("ts_wallets").Where({"key_id_buyer": 0, "deleted":0}).Order({"id": 1})

count_wallets = Len(wallet_arr)
if count_wallets == 0 {
warning LangRes("@1ts_free_wallet_not_found", "en")
}

if count_wallets == 1 {
var managerRoleId int
managerRoleId = Int(EcosysParam("role_sale_manager"))
if managerRoleId > 0 {
var params map title page body string
title = LangRes("@1ts_free_wallets_emptied", "en")
body = LangRes("@1ts_free_wallets_need", "en")
page = "@1ts_notification"
@1NotificationsSend("rid,sender,text_header,text_body,page_name,params_map,closure_type,current_role_id", managerRoleId, 2, title, body, page, params, 1, $current_role_id)
}
}

wallet_map = wallet_arr[0]
return Int(wallet_map["id"])
}

conditions {
if $public_key == "" {
warning LangRes("@1public_key_empty", "en")
Expand Down Expand Up @@ -48,7 +73,10 @@ contract TsKeyApprove {
@1TokensSend("Recipient,Amount", IdToAddress($userKey), start_balance)

if $key_type == "investor" {
DBInsert("ts_wallets", {"key_id_buyer": $userKey, "created_at": $block_time})
$wallet_id = getFreeWallet()
$public_key = "04" + $public_key
$pub_short_buyer = Substr($public_key, 0, 12) + "..." + Substr($public_key, Size($public_key)-12, 12)
DBUpdate("ts_wallets", $wallet_id, {"key_id_buyer": $userKey, "created_at": $block_time, "pub_buyer": $public_key, "pub_short_buyer": $pub_short_buyer})

// new user notification
var params map title page body string
Expand Down
63 changes: 43 additions & 20 deletions other/tokens_sale/contracts/TsTransferAdmin.sim
Original file line number Diff line number Diff line change
@@ -1,74 +1,97 @@
contract TsTransferAdmin {
data {
WalletStr string
Amount string
CurrencyType int
AmountApl money
TransferredDate string
TransferredTime string
}
func getRoleId(name string) int{

func getRoleId(name string) int {
var rid int
rid = Int(EcosysParam(name))
if rid == 0{
if rid == 0 {
warning Sprintf(LangRes("@1role_not_set_application_parameter", "en"), name)
}
return rid
}

func trimZeroTime(s string) string {
if Contains(s, "T00:00:00Z") {
s = s Replace(s, "T00:00:00Z", "")
}
return s
}

func dateAddTime(d, t string) string {
var dt string
if Size(t) == 5 {
dt = Sprintf("%v %v:00", trimZeroTime(d), t)
}
return dt
}
conditions{

conditions {
$WAITING_MANAGER = 1
$WAITING_SELLER = 2
$FINISHED = 3
$REJECTED = 4
if $AmountApl <= 0{
warning "invalid amount APL"
}
if $Amount <= 0.0{
warning "invalid amount"
if $AmountApl <= 0 {
warning "invalid amount APLA"
}

$transferredAt = UnixDateTime(dateAddTime($TransferredDate, $TransferredTime))
if $transferredAt == 0 {
warning "invalid transfer datetime"
}

$appId = Int(DBFind("@1applications").Where({ecosystem:$ecosystem_id, name:"Tokens sale"}).One("id"))
if $appId == 0{
if $appId == 0 {
warning LangRes("@1app_not_found", "en")
}
$roleAplManager = getRoleId("role_sale_manager")

$currentRole = getRoleId("role_sale_admin")
if !RoleAccess($currentRole){
if !RoleAccess($currentRole) {
warning "this action allowed only for role id #" + $currentRole
}

$WalletId = AddressToId($WalletStr)
$wallet = DBFind("ts_wallets").Where({key_id_buyer:$WalletId}).Row()
if !$wallet{
warning "Buyer wallet not found"
}
if $CurrencyType <= 0 || $CurrencyType > 3{
if $CurrencyType <= 0 || $CurrencyType > 3 {
warning "Invalid Currency Type"
}

if $CurrencyType == 1 {
$wallet = DBFind("ts_wallets").Where({wallet_btc: $WalletStr}).Row()
}
if $CurrencyType == 2 {
$wallet = DBFind("ts_wallets").Where({wallet_eth: $WalletStr}).Row()
}
if $CurrencyType == 3 {
if $WalletStr == "" {
warning LangRes("@1public_key_empty", "en")
}

$WalletStr = Replace($WalletStr, " ", "")
if HasPrefix($WalletStr, "04") {
$WalletStr = Substr($WalletStr, 2, Size($WalletStr) - 2)
}
var key_id_buyer int
key_id_buyer = PubToID($WalletStr)
if key_id_buyer == 0 || Size($WalletStr) != 128 {
warning LangRes("@1public_key_invalid", "en")
}

$wallet = DBFind("ts_wallets").Where({key_id_buyer: key_id_buyer}).Row()
}

if !$wallet {
warning "Buyer wallet not found"
}
}

action {
var sale map saleId int
sale["key_id_buyer"] = $wallet["key_id_buyer"]
sale["currency_type"] = $CurrencyType
sale["amount"] = $Amount
sale["amount_apl"] = $AmountApl
sale["key_id_sale_apl_admin"] = $key_id
sale["created_at"] = $time
Expand All @@ -82,7 +105,7 @@ contract TsTransferAdmin {
title = Sprintf("Check sale id %v", saleId)
page = "ts_transfer_manager"
params["sale_id"] = saleId
$roleAplManager = getRoleId("role_sale_manager")
@1NotificationsSend("rid,sender,text_header,page_name,params_map,closure_type,current_role_id", $roleAplManager, 2, title, page, params, 1, $currentRole)

}
}
9 changes: 6 additions & 3 deletions other/tokens_sale/menus/default_menu.ptl
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ If(#ecosystem_id# == 1){
SetVar(seller_role_id, EcosysParam(Name:role_sale_seller))

Span("Set here the menu of the first ecosystem")
If(And(#admin_role_id#>0,Or(#role_id#==#admin_role_id#,#role_id#==#manager_role_id#,#role_id#==#seller_role_id#))){
MenuItem(Title:$@1ts_sales$, Page:@1ts_sales, Icon:"icon-credit-card")
If(And(#role_id#>0,Or(#role_id#==#admin_role_id#,#role_id#==#manager_role_id#,#role_id#==#seller_role_id#,#role_id#==#snapswap_role_id#))){
MenuItem(Title:$@1ts_free_wallets$, Page:@1ts_free_wallets, Icon:"icon-credit-card")
}
If(And(#snapswap_role_id#>0,#role_id#==#snapswap_role_id#)){
If(And(#role_id#>0,Or(#role_id#==#admin_role_id#,#role_id#==#manager_role_id#,#role_id#==#seller_role_id#,#role_id#==#snapswap_role_id#))){
MenuItem(Title:$@1ts_wallets$, Page:@1ts_wallets, Icon:"icon-credit-card")
}
If(And(#role_id#>0,Or(#role_id#==#admin_role_id#,#role_id#==#manager_role_id#,#role_id#==#seller_role_id#,#role_id#==#snapswap_role_id#))){
MenuItem(Title:$@1ts_sales$, Page:@1ts_sales, Icon:"icon-credit-card")
}
}
}
Loading

0 comments on commit 0cee834

Please sign in to comment.