tx · 9YhdhF59bKVXCBEFwTYseRGCbc2h46RGpakR82MWURs9 3N3evGP2tTeuXuq3iHz13Wrjm7BonuiSMd2: -0.05000000 Waves 2022.12.22 14:37 [2371448] smart account 3N3evGP2tTeuXuq3iHz13Wrjm7BonuiSMd2 > SELF 0.00000000 Waves
{ "type": 13, "id": "9YhdhF59bKVXCBEFwTYseRGCbc2h46RGpakR82MWURs9", "fee": 5000000, "feeAssetId": null, "timestamp": 1671709059933, "version": 2, "chainId": 84, "sender": "3N3evGP2tTeuXuq3iHz13Wrjm7BonuiSMd2", "senderPublicKey": "3XEAduJnZeFRL74JfaQk7MgrGDo9a9xREYyfLvyivREU", "proofs": [ "pEj2UqZCq3t9iLtEPxcRq2TPoF4hmah7btfrdWSMxDpEki6W4bXp2mPi5U38WoGbFMgx6iRPAW5GMWVUJacWgBj" ], "script": "base64:BgIRCAISAwoBCBIDCgEIEgMKAQgGAA9NRVNTQUdFX0NPVU5URVICD21lc3NhZ2VfY291bnRlcgANRk9MTE9XX1NUUklORwIHZm9sbG93cwAQVFdFRVRfS0VZX1NUUklORwIGdHdlZXRfARFnZXRNZXNzYWdlQ291bnRlcgAJAQt2YWx1ZU9yRWxzZQIJAJ8IAQUPTUVTU0FHRV9DT1VOVEVSAAABKWdldExhdGVzdFR3ZWV0SWZGcm9tU29tZW9uZUFkZHJlc3NGb2xsb3dzAgVhY2N1bQZvZmZzZXQEB2FkZHJlc3MCIzNNdVN2eHpmenFMVERQcTFqNW1USHdLNXRMeDVDaERjUU1pBA5tZXNzYWdlQ291bnRlcgkBEWdldE1lc3NhZ2VDb3VudGVyAAQHdHdlZXRJZAkBC3ZhbHVlT3JFbHNlAgkAoggBCQCsAgIFEFRXRUVUX0tFWV9TVFJJTkcJAKQDAQkAZQIFDm1lc3NhZ2VDb3VudGVyBQZvZmZzZXQCAAQFcGFydHMJALUJAgUHdHdlZXRJZAIBXwQGc2VuZGVyCQCRAwIFBXBhcnRzAAAEE2tleVRvQ2hlY2tGb2x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XQBB21lc3NhZ2UEDm1lc3NhZ2VDb3VudGVyCQBkAgkBEWdldE1lc3NhZ2VDb3VudGVyAAABBAZzZW5kZXIJAKUIAQgFAWkGY2FsbGVyBAR0eElkCQDYBAEIBQFpDXRyYW5zYWN0aW9uSWQEBm1zZ0tleQkArAICCQCsAgIFBnNlbmRlcgIBXwUEdHhJZAQIdHdlZXRLZXkJAKwCAgUQVFdFRVRfS0VZX1NUUklORwkApAMBBQ5tZXNzYWdlQ291bnRlcgkAzAgCCQELU3RyaW5nRW50cnkCBQZtc2dLZXkFB21lc3NhZ2UJAMwIAgkBC1N0cmluZ0VudHJ5AgUIdHdlZXRLZXkFBm1zZ0tleQkAzAgCCQEMSW50ZWdlckVudHJ5AgUPTUVTU0FHRV9DT1VOVEVSBQ5tZXNzYWdlQ291bnRlcgUDbmlsAQJ0eAEGdmVyaWZ5AAkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleTUXtsI=", "height": 2371448, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: G73z9UzfxhSayKNW6cqW12MYi1xjMQkjCHVeKz2VNw1W Next: 8RDBbqchKHDpMCkXTgXAKcs2CjwrDVh84iKKwqUy1RHn Diff:
Old | New | Differences | |
---|---|---|---|
10 | 10 | func getMessageCounter () = valueOrElse(getInteger(MESSAGE_COUNTER), 0) | |
11 | 11 | ||
12 | 12 | ||
13 | - | func getLatestTweetIfFromSomeoneAddressFollows (address,offset) = { | |
13 | + | func getLatestTweetIfFromSomeoneAddressFollows (accum,offset) = { | |
14 | + | let address = "3MuSvxzfzqLTDPq1j5mTHwK5tLx5ChDcQMi" | |
14 | 15 | let messageCounter = getMessageCounter() | |
15 | 16 | let tweetId = valueOrElse(getString((TWEET_KEY_STRING + toString((messageCounter - offset)))), "") | |
16 | 17 | let parts = split(tweetId, "_") | |
18 | 19 | let keyToCheckFollowing = ((((address + "_") + FOLLOW_STRING) + "_") + sender) | |
19 | 20 | let following = valueOrElse(getBoolean(keyToCheckFollowing), false) | |
20 | 21 | if (following) | |
21 | - | then getString(tweetId) | |
22 | - | else "" | |
22 | + | then (accum :+ getString(tweetId)) | |
23 | + | else accum | |
24 | + | } | |
25 | + | ||
26 | + | ||
27 | + | func getLatestTweetsFromFollowingAddresses (address) = { | |
28 | + | let list = [0, 1, 2] | |
29 | + | let $l = list | |
30 | + | let $s = size($l) | |
31 | + | let $acc0 = nil | |
32 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
33 | + | then $a | |
34 | + | else getLatestTweetIfFromSomeoneAddressFollows($a, $l[$i]) | |
35 | + | ||
36 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
37 | + | then $a | |
38 | + | else throw("List size exceeds 3") | |
39 | + | ||
40 | + | $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3) | |
23 | 41 | } | |
24 | 42 | ||
25 | 43 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let MESSAGE_COUNTER = "message_counter" | |
5 | 5 | ||
6 | 6 | let FOLLOW_STRING = "follows" | |
7 | 7 | ||
8 | 8 | let TWEET_KEY_STRING = "tweet_" | |
9 | 9 | ||
10 | 10 | func getMessageCounter () = valueOrElse(getInteger(MESSAGE_COUNTER), 0) | |
11 | 11 | ||
12 | 12 | ||
13 | - | func getLatestTweetIfFromSomeoneAddressFollows (address,offset) = { | |
13 | + | func getLatestTweetIfFromSomeoneAddressFollows (accum,offset) = { | |
14 | + | let address = "3MuSvxzfzqLTDPq1j5mTHwK5tLx5ChDcQMi" | |
14 | 15 | let messageCounter = getMessageCounter() | |
15 | 16 | let tweetId = valueOrElse(getString((TWEET_KEY_STRING + toString((messageCounter - offset)))), "") | |
16 | 17 | let parts = split(tweetId, "_") | |
17 | 18 | let sender = parts[0] | |
18 | 19 | let keyToCheckFollowing = ((((address + "_") + FOLLOW_STRING) + "_") + sender) | |
19 | 20 | let following = valueOrElse(getBoolean(keyToCheckFollowing), false) | |
20 | 21 | if (following) | |
21 | - | then getString(tweetId) | |
22 | - | else "" | |
22 | + | then (accum :+ getString(tweetId)) | |
23 | + | else accum | |
24 | + | } | |
25 | + | ||
26 | + | ||
27 | + | func getLatestTweetsFromFollowingAddresses (address) = { | |
28 | + | let list = [0, 1, 2] | |
29 | + | let $l = list | |
30 | + | let $s = size($l) | |
31 | + | let $acc0 = nil | |
32 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
33 | + | then $a | |
34 | + | else getLatestTweetIfFromSomeoneAddressFollows($a, $l[$i]) | |
35 | + | ||
36 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
37 | + | then $a | |
38 | + | else throw("List size exceeds 3") | |
39 | + | ||
40 | + | $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3) | |
23 | 41 | } | |
24 | 42 | ||
25 | 43 | ||
26 | 44 | @Callable(i) | |
27 | 45 | func follow (address) = { | |
28 | 46 | let sender = toString(i.caller) | |
29 | 47 | let followKey = ((((sender + "_") + FOLLOW_STRING) + "_") + address) | |
30 | 48 | [BooleanEntry(followKey, true)] | |
31 | 49 | } | |
32 | 50 | ||
33 | 51 | ||
34 | 52 | ||
35 | 53 | @Callable(i) | |
36 | 54 | func unfollow (address) = { | |
37 | 55 | let sender = toString(i.caller) | |
38 | 56 | let followKey = ((((sender + "_") + FOLLOW_STRING) + "_") + address) | |
39 | 57 | [DeleteEntry(followKey)] | |
40 | 58 | } | |
41 | 59 | ||
42 | 60 | ||
43 | 61 | ||
44 | 62 | @Callable(i) | |
45 | 63 | func tweet (message) = { | |
46 | 64 | let messageCounter = (getMessageCounter() + 1) | |
47 | 65 | let sender = toString(i.caller) | |
48 | 66 | let txId = toBase58String(i.transactionId) | |
49 | 67 | let msgKey = ((sender + "_") + txId) | |
50 | 68 | let tweetKey = (TWEET_KEY_STRING + toString(messageCounter)) | |
51 | 69 | [StringEntry(msgKey, message), StringEntry(tweetKey, msgKey), IntegerEntry(MESSAGE_COUNTER, messageCounter)] | |
52 | 70 | } | |
53 | 71 | ||
54 | 72 | ||
55 | 73 | @Verifier(tx) | |
56 | 74 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
57 | 75 |
github/deemru/w8io/169f3d6 36.82 ms ◑