tx · 2yfkJz8bA9jFnTmLhMY6hBa7BHHAPHDpGCBVaQPQeayg

3NCMVbH9EWZogGDLtS8sf1N4ShcoDUqxrn7:  -0.01400000 Waves

2020.02.03 16:36 [883054] smart account 3NCMVbH9EWZogGDLtS8sf1N4ShcoDUqxrn7 > SELF 0.00000000 Waves

{ "type": 13, "id": "2yfkJz8bA9jFnTmLhMY6hBa7BHHAPHDpGCBVaQPQeayg", "fee": 1400000, "feeAssetId": null, "timestamp": 1580736987978, "version": 1, "sender": "3NCMVbH9EWZogGDLtS8sf1N4ShcoDUqxrn7", "senderPublicKey": "JAAzQjxgzdgjCEdwXpfgpoMVcDpJRs4WgA9eTKxJYitU", "proofs": [ "4rJsNciUQV944uRWJWNaiB3YkmiFFWqTMvy6uWpW9gZPcsEEF6NT155w6nVNFRM3y1Mx18eg9sgVPg7i1bmX9eMn" ], "script": "base64:AAIDAAAAAAAAAAkIARIDCgECEgAAAAADAAAAABRyb290QWNjb3VudFB1YmxpY0tleQEAAAAaAVT2IQwdZvI4cdfE/aE0KgPNEyFI1dNVNJQBAAAACGlzUGxheWVyAAAAAgAAAAFpAAAABnB1YktleQkAAAAAAAACCAUAAAABaQAAAA9jYWxsZXJQdWJsaWNLZXkFAAAABnB1YktleQEAAAAGaXNSb290AAAAAQAAAAFpCQAAAAAAAAIIBQAAAAFpAAAAD2NhbGxlclB1YmxpY0tleQUAAAAUcm9vdEFjY291bnRQdWJsaWNLZXkAAAACAAAAAWkBAAAAEXNldEFjY2VwdGVkUGxheWVyAAAAAQAAAA9wbGF5ZXJQdWJsaWNLZXkDCQEAAAABIQAAAAEJAQAAAAZpc1Jvb3QAAAABBQAAAAFpCQAAAgAAAAECAAAAGE9ubHkgcm9vdCBjYW4gY2FsbCB0aGlzLgkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkAAlgAAAABBQAAAA9wbGF5ZXJQdWJsaWNLZXkAAAAAAAAAAAEFAAAAA25pbAAAAAFpAQAAAAxwbGF5ZXJJbnZva2UAAAAABAAAAA9wbGF5ZXJQdWJsaWNLZXkIBQAAAAFpAAAAD2NhbGxlclB1YmxpY0tleQkBAAAADFNjcmlwdFJlc3VsdAAAAAIJAQAAAAhXcml0ZVNldAAAAAEFAAAAA25pbAkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCQEAAAAUYWRkcmVzc0Zyb21QdWJsaWNLZXkAAAABBQAAAA9wbGF5ZXJQdWJsaWNLZXkAAAAAAAAHoSAFAAAABHVuaXQFAAAAA25pbAAAAAD710QW", "chainId": 84, "height": 883054, "spentComplexity": 0 } View: original | compacted Prev: FywMGUCg8kNDPzaKEHwFLE6h8SYkyW3j2wHdbaS4CQGU Next: 3BJb3yRxUqFXumbtXr61vTCPdYRn37X8DMeA9KU7eGBr Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let rootAccountPublicKey = base58''
5-
6-func getPlayerPublicKey (data) = take(data, 32)
7-
8-
9-func getRandom (data) = take(drop(data, 32), 32)
10-
11-
12-func getStartHeight (data) = toInt(take(drop(data, (32 + 32)), 8))
13-
14-
15-func getEndHeight (data) = toInt(take(drop(data, ((32 + 32) + 8)), 8))
16-
17-
18-func getIsUsed (data) = toInt(take(drop(data, (((32 + 32) + 8) + 8)), 8))
19-
20-
21-func userDailyQuestKey (key,startHeight,endHeight) = ((((("QUESTS_" + toBase58String(key)) + "_") + toString(startHeight)) + "_") + toString(endHeight))
22-
23-
24-func userDailyQuest (key,random,startHeight,endHeight,isUsed) = DataEntry(userDailyQuestKey(key, startHeight, endHeight), ((((key + random) + toBytes(startHeight)) + toBytes(endHeight)) + toBytes(isUsed)))
25-
4+let rootAccountPublicKey = base58'3NCMVbH9EWZogGDLtS8sf1N4ShcoDUqxrn7'
265
276 func isPlayer (i,pubKey) = (i.callerPublicKey == pubKey)
287
3110
3211
3312 @Callable(i)
34-func setPlayerDailyQuest (playerPublicKey,random) = if (!(isRoot(i)))
13+func setAcceptedPlayer (playerPublicKey) = if (!(isRoot(i)))
3514 then throw("Only root can call this.")
36- else WriteSet([userDailyQuest(playerPublicKey, random, height, (height + (24 * 60)), 0)])
15+ else WriteSet([DataEntry(toBase58String(playerPublicKey), 1)])
3716
3817
3918
4019 @Callable(i)
41-func playerInvoke (dailyQuestKey,signedRandom) = {
42- let data = extract(getBinary(this, dailyQuestKey))
43- let playerPublicKey = getPlayerPublicKey(data)
44- let random = getRandom(data)
45- let startHeight = getStartHeight(data)
46- let endHeight = getEndHeight(data)
47- let isUsed = (getIsUsed(data) == 1)
48- let isValid = rsaVerify(Sha256(), random, signedRandom, playerPublicKey)
49- if (!(isPlayer(i, playerPublicKey)))
50- then throw((("Only " + toBase58String(playerPublicKey)) + " player can do this."))
51- else if (!(isValid))
52- then throw("Signature is not valid.")
53- else if (isUsed)
54- then throw("Already used.")
55- else if ((height > endHeight))
56- then throw("Too late.")
57- else if ((startHeight > height))
58- then throw("Too early.")
59- else {
60- let r = (((((toInt(take(signedRandom, 8)) % 100) + (toInt(take(drop(signedRandom, 8), 8)) % 100)) + (toInt(take(drop(signedRandom, 16), 8)) % 100)) + (toInt(take(drop(signedRandom, 24), 8)) % 100)) / 4)
61- let itemId = if ((r > 90))
62- then "uniqAssetId"
63- else if ((r > 70))
64- then "rareAssetId"
65- else if ((r > 30))
66- then "uncommonAssetId"
67- else "commonAssetId"
68- ScriptResult(WriteSet([userDailyQuest(playerPublicKey, random, startHeight, endHeight, 1)]), TransferSet([ScriptTransfer(addressFromPublicKey(playerPublicKey), 1, fromBase58String(itemId)), ScriptTransfer(addressFromPublicKey(playerPublicKey), 500000, unit)]))
69- }
20+func playerInvoke () = {
21+ let playerPublicKey = i.callerPublicKey
22+ ScriptResult(WriteSet(nil), TransferSet([ScriptTransfer(addressFromPublicKey(playerPublicKey), 500000, unit)]))
7023 }
71-
72-
73-
74-@Callable(i)
75-func birdInvoke (playerPublicKey) = ScriptResult(WriteSet(nil), TransferSet([ScriptTransfer(addressFromPublicKey(playerPublicKey), 500000, unit)]))
7624
7725
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let rootAccountPublicKey = base58''
5-
6-func getPlayerPublicKey (data) = take(data, 32)
7-
8-
9-func getRandom (data) = take(drop(data, 32), 32)
10-
11-
12-func getStartHeight (data) = toInt(take(drop(data, (32 + 32)), 8))
13-
14-
15-func getEndHeight (data) = toInt(take(drop(data, ((32 + 32) + 8)), 8))
16-
17-
18-func getIsUsed (data) = toInt(take(drop(data, (((32 + 32) + 8) + 8)), 8))
19-
20-
21-func userDailyQuestKey (key,startHeight,endHeight) = ((((("QUESTS_" + toBase58String(key)) + "_") + toString(startHeight)) + "_") + toString(endHeight))
22-
23-
24-func userDailyQuest (key,random,startHeight,endHeight,isUsed) = DataEntry(userDailyQuestKey(key, startHeight, endHeight), ((((key + random) + toBytes(startHeight)) + toBytes(endHeight)) + toBytes(isUsed)))
25-
4+let rootAccountPublicKey = base58'3NCMVbH9EWZogGDLtS8sf1N4ShcoDUqxrn7'
265
276 func isPlayer (i,pubKey) = (i.callerPublicKey == pubKey)
287
298
309 func isRoot (i) = (i.callerPublicKey == rootAccountPublicKey)
3110
3211
3312 @Callable(i)
34-func setPlayerDailyQuest (playerPublicKey,random) = if (!(isRoot(i)))
13+func setAcceptedPlayer (playerPublicKey) = if (!(isRoot(i)))
3514 then throw("Only root can call this.")
36- else WriteSet([userDailyQuest(playerPublicKey, random, height, (height + (24 * 60)), 0)])
15+ else WriteSet([DataEntry(toBase58String(playerPublicKey), 1)])
3716
3817
3918
4019 @Callable(i)
41-func playerInvoke (dailyQuestKey,signedRandom) = {
42- let data = extract(getBinary(this, dailyQuestKey))
43- let playerPublicKey = getPlayerPublicKey(data)
44- let random = getRandom(data)
45- let startHeight = getStartHeight(data)
46- let endHeight = getEndHeight(data)
47- let isUsed = (getIsUsed(data) == 1)
48- let isValid = rsaVerify(Sha256(), random, signedRandom, playerPublicKey)
49- if (!(isPlayer(i, playerPublicKey)))
50- then throw((("Only " + toBase58String(playerPublicKey)) + " player can do this."))
51- else if (!(isValid))
52- then throw("Signature is not valid.")
53- else if (isUsed)
54- then throw("Already used.")
55- else if ((height > endHeight))
56- then throw("Too late.")
57- else if ((startHeight > height))
58- then throw("Too early.")
59- else {
60- let r = (((((toInt(take(signedRandom, 8)) % 100) + (toInt(take(drop(signedRandom, 8), 8)) % 100)) + (toInt(take(drop(signedRandom, 16), 8)) % 100)) + (toInt(take(drop(signedRandom, 24), 8)) % 100)) / 4)
61- let itemId = if ((r > 90))
62- then "uniqAssetId"
63- else if ((r > 70))
64- then "rareAssetId"
65- else if ((r > 30))
66- then "uncommonAssetId"
67- else "commonAssetId"
68- ScriptResult(WriteSet([userDailyQuest(playerPublicKey, random, startHeight, endHeight, 1)]), TransferSet([ScriptTransfer(addressFromPublicKey(playerPublicKey), 1, fromBase58String(itemId)), ScriptTransfer(addressFromPublicKey(playerPublicKey), 500000, unit)]))
69- }
20+func playerInvoke () = {
21+ let playerPublicKey = i.callerPublicKey
22+ ScriptResult(WriteSet(nil), TransferSet([ScriptTransfer(addressFromPublicKey(playerPublicKey), 500000, unit)]))
7023 }
71-
72-
73-
74-@Callable(i)
75-func birdInvoke (playerPublicKey) = ScriptResult(WriteSet(nil), TransferSet([ScriptTransfer(addressFromPublicKey(playerPublicKey), 500000, unit)]))
7624
7725

github/deemru/w8io/c3f4982 
30.22 ms