tx · 4MKMPVS2fNroh4Eu9rGne7XCupDKZ14YDz7xVogmAoyP 3N1bfGrC9iBWbv1Rhb64cccc3cQswW8VyCV: -0.01400000 Waves 2020.07.21 10:15 [1096908] smart account 3N1bfGrC9iBWbv1Rhb64cccc3cQswW8VyCV > SELF 0.00000000 Waves
{ "type": 13, "id": "4MKMPVS2fNroh4Eu9rGne7XCupDKZ14YDz7xVogmAoyP", "fee": 1400000, "feeAssetId": null, "timestamp": 1595315723785, "version": 1, "sender": "3N1bfGrC9iBWbv1Rhb64cccc3cQswW8VyCV", "senderPublicKey": "BF56eooJyMKnwSL3B65fqLBFPfubUbW6wdky9pCGQajE", "proofs": [ "4UHEDKtvSk5oumHKHg2E7u87A3utL39EYde62ctLSKCXVnLUDwEkAaKLNCHArbS3eB56ByxV6xiXwUsm4D3iUuPp" ], "script": "base64:AAIDAAAAAAAAAAoIARIGCgQICAgIAAAABQEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAEAAAAOZ2V0U3RyaW5nQnlLZXkAAAABAAAAA2tleQQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQIAAAAAAQAAAAxnZXRCb29sQnlLZXkAAAABAAAAA2tleQQAAAAHJG1hdGNoMAkABBsAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAB0Jvb2xlYW4EAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEHAAAAAAt1c2VyQ3JlYXRlZAIAAAAHQ1JFQVRFRAAAAAANdXNlclN1c3BlbmRlZAIAAAAJU1VTUEVORE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NvY2lhbAkABEwAAAACBQAAAAplbnRyeVRodW1iCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQABLAAAAAICAAAABXVzZXJfBQAAAApjYWxsZXJBZGRyBQAAAAJpZAUAAAADbmlsCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIFAAAAC2VudHJpZXNOYW1lCQAETAAAAAIFAAAACWVudHJ5RGVzYwkABEwAAAACBQAAAAtlbnRyeVNvY2lhbAkABEwAAAACBQAAAAplbnRyeVRodW1iBQAAAANuaWwAAAAAzh/1nw==", "chainId": 84, "height": 1096908, "spentComplexity": 0 } View: original | compacted Prev: 2yjW4bJTeTuPYiNMHhjSGbDT1iagWUhgKHNHkRMwMQRN Next: JDF12wDaoKN5UTg7hPNGzsxVj5kpoWYPA4RR5ofbpkDL Diff:
Old | New | Differences | |
---|---|---|---|
25 | 25 | } | |
26 | 26 | ||
27 | 27 | ||
28 | + | let userCreated = "CREATED" | |
29 | + | ||
30 | + | let userSuspended = "SUSPENDED" | |
31 | + | ||
28 | 32 | @Callable(i) | |
29 | 33 | func registerUser (name,description,social,thumb) = { | |
30 | 34 | let callerAddr = toString(addressFromPublicKey(i.callerPublicKey)) | |
31 | 35 | let id = toBase58String(i.transactionId) | |
32 | - | let createOn = lastBlock.timestamp | |
33 | - | let json = (((((((((("{\"id\": \"" + id) + "\",\"name\": \"") + name) + "\",\"desc\": \"") + description) + "\",\"social\": \"") + social) + "\",\"thumb\": \"") + thumb) + "\"}") | |
34 | - | if ((name == "")) | |
35 | - | then throw(("Ton json = " + json)) | |
36 | - | else WriteSet([DataEntry(("user_" + callerAddr), json)]) | |
36 | + | let newUser = getStringByKey(("user_" + callerAddr)) | |
37 | + | if (if ((name == "")) | |
38 | + | then true | |
39 | + | else (description == "")) | |
40 | + | then throw("Name and description cannot be empty") | |
41 | + | else { | |
42 | + | let entriesName = DataEntry(("user_name_" + callerAddr), name) | |
43 | + | let entryDesc = DataEntry(("user_desc_" + callerAddr), description) | |
44 | + | let entrySocial = DataEntry(("user_social_" + callerAddr), social) | |
45 | + | let entryThumb = DataEntry(("user_thumb_" + callerAddr), thumb) | |
46 | + | if ((newUser == "")) | |
47 | + | then WriteSet([entriesName, entryDesc, entrySocial, entryThumb, DataEntry(("user_" + callerAddr), id)]) | |
48 | + | else WriteSet([entriesName, entryDesc, entrySocial, entryThumb]) | |
49 | + | } | |
37 | 50 | } | |
38 | 51 | ||
39 | 52 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func getNumberByKey (key) = match getInteger(this, key) { | |
5 | 5 | case a: Int => | |
6 | 6 | a | |
7 | 7 | case _ => | |
8 | 8 | 0 | |
9 | 9 | } | |
10 | 10 | ||
11 | 11 | ||
12 | 12 | func getStringByKey (key) = match getString(this, key) { | |
13 | 13 | case a: String => | |
14 | 14 | a | |
15 | 15 | case _ => | |
16 | 16 | "" | |
17 | 17 | } | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | func getBoolByKey (key) = match getBoolean(this, key) { | |
21 | 21 | case a: Boolean => | |
22 | 22 | a | |
23 | 23 | case _ => | |
24 | 24 | false | |
25 | 25 | } | |
26 | 26 | ||
27 | 27 | ||
28 | + | let userCreated = "CREATED" | |
29 | + | ||
30 | + | let userSuspended = "SUSPENDED" | |
31 | + | ||
28 | 32 | @Callable(i) | |
29 | 33 | func registerUser (name,description,social,thumb) = { | |
30 | 34 | let callerAddr = toString(addressFromPublicKey(i.callerPublicKey)) | |
31 | 35 | let id = toBase58String(i.transactionId) | |
32 | - | let createOn = lastBlock.timestamp | |
33 | - | let json = (((((((((("{\"id\": \"" + id) + "\",\"name\": \"") + name) + "\",\"desc\": \"") + description) + "\",\"social\": \"") + social) + "\",\"thumb\": \"") + thumb) + "\"}") | |
34 | - | if ((name == "")) | |
35 | - | then throw(("Ton json = " + json)) | |
36 | - | else WriteSet([DataEntry(("user_" + callerAddr), json)]) | |
36 | + | let newUser = getStringByKey(("user_" + callerAddr)) | |
37 | + | if (if ((name == "")) | |
38 | + | then true | |
39 | + | else (description == "")) | |
40 | + | then throw("Name and description cannot be empty") | |
41 | + | else { | |
42 | + | let entriesName = DataEntry(("user_name_" + callerAddr), name) | |
43 | + | let entryDesc = DataEntry(("user_desc_" + callerAddr), description) | |
44 | + | let entrySocial = DataEntry(("user_social_" + callerAddr), social) | |
45 | + | let entryThumb = DataEntry(("user_thumb_" + callerAddr), thumb) | |
46 | + | if ((newUser == "")) | |
47 | + | then WriteSet([entriesName, entryDesc, entrySocial, entryThumb, DataEntry(("user_" + callerAddr), id)]) | |
48 | + | else WriteSet([entriesName, entryDesc, entrySocial, entryThumb]) | |
49 | + | } | |
37 | 50 | } | |
38 | 51 | ||
39 | 52 |
github/deemru/w8io/169f3d6 58.54 ms ◑