Skip to content

Commit 51832c5

Browse files
committed
Update NewUser.sim
1 parent 385d339 commit 51832c5

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

src/system/contracts/NewUser.sim

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,19 @@ contract NewUser {
22
data {
33
NewPubkey string
44
}
5-
65
conditions {
7-
$newId = PubToID($NewPubkey)
8-
if $newId == 0 {
9-
warning LangRes("@1wrong_pub", "en")
6+
$id = PubToID($NewPubkey)
7+
if $id == 0 {
8+
error "Wrong pubkey"
109
}
11-
if DBFind("@1keys").Columns("id").Where({"id": $newId, "ecosystem": $ecosystem_id}).One("id") != nil {
12-
warning LangRes("@1template_user_exists", "en")
10+
if DBFind("keys").Columns("id").WhereId($id).One("id") != nil {
11+
error "User already exists"
1312
}
14-
15-
$amount = Money(1000) * Money(1000000000000000000)
1613
}
17-
1814
action {
19-
NewMoney($newId, Str($amount), "New user deposit")
20-
SetPubKey($newId, StringToBytes($NewPubkey))
21-
$result = $newId
15+
$pub = HexToPub($NewPubkey)
16+
$account = IdToAddress($id)
17+
$amount = Money(1000) * Money(1000000000000000000)
18+
DBInsert("keys", {"id": $id, "account": $account, "pub": $pub, "amount": $amount, "ecosystem": 1})
2219
}
2320
}

0 commit comments

Comments
 (0)