tx · 7t3hKbDaEDscitJVr4p2E8VYHPpHPdBu2XdTzHaHbpfw

3N91zFrRoofbPpkoDbWKrQsQSdLu2EgLL8c:  -0.01000000 Waves

2023.10.23 15:48 [2811272] smart account 3N91zFrRoofbPpkoDbWKrQsQSdLu2EgLL8c > SELF 0.00000000 Waves

{ "type": 13, "id": "7t3hKbDaEDscitJVr4p2E8VYHPpHPdBu2XdTzHaHbpfw", "fee": 1000000, "feeAssetId": null, "timestamp": 1698065312393, "version": 2, "chainId": 84, "sender": "3N91zFrRoofbPpkoDbWKrQsQSdLu2EgLL8c", "senderPublicKey": "5FyjUYCR5Q8jvG6ri6Ysz574HerUK6r1LJzzQ7DvSkLk", "proofs": [ "3PoE7kRYzWX16BYuFvokKMWEbC2rTeXpVmYhf4xdz8F7p9NRMv4VoC7CJEddpntMo43DEMjY7VcqDXZfc4dpAsNm" ], "script": "base64:BgIWCAISBgoEAgICARIECgIICBIECgIIAh0ACXNlcGFyYXRvcgICX18AB2NoYWluSWQJAMkBAgkAygECCAUEdGhpcwVieXRlcwABAAEACGNoYWluSWRUAQFUAAhjaGFpbklkVwEBVwELbXVzdEFkZHJlc3MCAWkHYWRkcmVzcwMJAAACCAUBaQZjYWxsZXIFB2FkZHJlc3MGCQACAQIRcGVybWlzc2lvbiBkZW5pZWQBCG11c3RUaGlzAQFpCQELbXVzdEFkZHJlc3MCBQFpBQR0aGlzAAt3YXZlc1N0cmluZwIFV0FWRVMBDHBhcnNlQXNzZXRJZAEFaW5wdXQDCQAAAgUFaW5wdXQFC3dhdmVzU3RyaW5nBQR1bml0CQDZBAEFBWlucHV0AQ9hc3NldElkVG9TdHJpbmcBBWlucHV0AwkAAAIFBWlucHV0BQR1bml0BQt3YXZlc1N0cmluZwkA2AQBCQEFdmFsdWUBBQVpbnB1dAARa1NlcnZpY2VQdWJsaWNLZXkCFCVzX19zZXJ2aWNlUHVibGljS2V5AA1rQm90UHVibGljS2V5AhAlc19fYm90UHVibGljS2V5AA5rQWNjb3V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Y3JpcHQFA25pbAMJAAACBQZjaGVja3MFBmNoZWNrcwQOY3JlYXRvckFkZHJlc3MJAKcIAQUQY3JlYXRvclB1YmxpY0tleQkAlAoCCQDMCAIJAQxJbnRlZ2VyRW50cnkCCQEOa0FjY291bnRTdGF0dXMBBQlhY2NvdW50SWQFFEFDQ09VTlRfU1RBVFVTX1JFQURZCQDMCAIJAQtCaW5hcnlFbnRyeQIJARhrQWNjb3VudENyZWF0b3JQdWJsaWNLZXkBBQlhY2NvdW50SWQFEGNyZWF0b3JQdWJsaWNLZXkJAMwIAgkBC0JpbmFyeUVudHJ5AgkBHGtBY2NvdW50SWRUb0FjY291bnRQdWJsaWNLZXkBBQlhY2NvdW50SWQFEGFjY291bnRQdWJsaWNLZXkJAMwIAgkBC1N0cmluZ0VudHJ5AgkBGmtBY2NvdW50QWRkcmVzc1RvQWNjb3VudElkAQUOYWNjb3VudEFkZHJlc3MFCWFjY291bnRJZAkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDBQ5jcmVhdG9yQWRkcmVzcwkBDHJld2FyZEFtb3VudAAFBHVuaXQFA25pbAUEdW5pdAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgB31fZ8", "height": 2811272, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: ekrk3RoaYGx5v5Sm47tvYU1fNAuUmsg9N85pwhynBd3 Next: FfCyS8xwSAAYPb9DTjHEHZhzGvJ2EfbVxbom5qMCQUts Diff:
OldNewDifferences
1515
1616
1717 func mustThis (i) = mustAddress(i, this)
18+
19+
20+let wavesString = "WAVES"
21+
22+func parseAssetId (input) = if ((input == wavesString))
23+ then unit
24+ else fromBase58String(input)
25+
26+
27+func assetIdToString (input) = if ((input == unit))
28+ then wavesString
29+ else toBase58String(value(input))
1830
1931
2032 let kServicePublicKey = "%s__servicePublicKey"
5971 func kAccountAddressToAccountId (accountAddress) = makeString(["%s%s", toString(accountAddress), "accountAddressToAccountId"], separator)
6072
6173
62-func kPairAllowed (amountAssetId,priceAssetId) = makeString(["%s%s%s", toBase58String(amountAssetId), toBase58String(priceAssetId), "pairAllowed"], separator)
74+func kPairAllowed (amountAssetId,priceAssetId) = makeString(["%s%s%s", assetIdToString(amountAssetId), assetIdToString(priceAssetId), "pairAllowed"], separator)
6375
6476
6577 func pairAllowed (amountAssetId,priceAssetId) = valueOrElse(getBoolean(this, kPairAllowed(amountAssetId, priceAssetId)), false)
8092
8193
8294 @Callable(i)
83-func request (amountAssetId,priceAssetId) = {
84- let accountId = toBase58String(sha256(((i.caller.bytes + amountAssetId) + priceAssetId)))
95+func request (amountAssetIdStr,priceAssetIdStr) = {
96+ let accountId = makeString([toString(i.caller), amountAssetIdStr, priceAssetIdStr], ":")
97+ let amountAssetId = parseAssetId(amountAssetIdStr)
98+ let priceAssetId = parseAssetId(priceAssetIdStr)
8599 let checks = [if ((size(i.payments) == 1))
86100 then true
87101 else throw("1 payment is required"), if ((i.payments[0].assetId == unit))
94108 then true
95109 else throw("account already exists")]
96110 if ((checks == checks))
97- then $Tuple2([IntegerEntry(kAccountStatus(accountId), 0), BinaryEntry(kAccountOwnerPublicKey(accountId), i.callerPublicKey), BinaryEntry(kAccountAmountAssetId(accountId), amountAssetId), BinaryEntry(kAccountPriceAssetId(accountId), priceAssetId)], unit)
111+ then $Tuple2([IntegerEntry(kAccountStatus(accountId), 0), BinaryEntry(kAccountOwnerPublicKey(accountId), i.callerPublicKey), StringEntry(kAccountAmountAssetId(accountId), amountAssetIdStr), StringEntry(kAccountPriceAssetId(accountId), priceAssetIdStr)], unit)
98112 else throw("Strict value is not equal to itself.")
99113 }
100114
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let separator = "__"
55
66 let chainId = take(drop(this.bytes, 1), 1)
77
88 let chainIdT = base58'2T'
99
1010 let chainIdW = base58'2W'
1111
1212 func mustAddress (i,address) = if ((i.caller == address))
1313 then true
1414 else throw("permission denied")
1515
1616
1717 func mustThis (i) = mustAddress(i, this)
18+
19+
20+let wavesString = "WAVES"
21+
22+func parseAssetId (input) = if ((input == wavesString))
23+ then unit
24+ else fromBase58String(input)
25+
26+
27+func assetIdToString (input) = if ((input == unit))
28+ then wavesString
29+ else toBase58String(value(input))
1830
1931
2032 let kServicePublicKey = "%s__servicePublicKey"
2133
2234 let kBotPublicKey = "%s__botPublicKey"
2335
2436 let kAccountScript = "%s__accountScript"
2537
2638 func accountScript () = valueOrErrorMessage(getBinary(this, kAccountScript), "account script is not set")
2739
2840
2941 let kRewardAmount = "%s__rewardAmount"
3042
3143 func rewardAmount () = valueOrErrorMessage(getInteger(this, kRewardAmount), "reward amount is not set")
3244
3345
3446 let ACCOUNT_STATUS_EMPTY = 0
3547
3648 let ACCOUNT_STATUS_READY = 1
3749
3850 func kAccountStatus (accountId) = makeString(["%s%s", accountId, "status"], separator)
3951
4052
4153 func accountStatus (accountId) = valueOrErrorMessage(getInteger(this, kAccountStatus(accountId)), "account is not found")
4254
4355
4456 func kAccountCreatorPublicKey (accountId) = makeString(["%s%s", accountId, "creatorPublicKey"], separator)
4557
4658
4759 func kAccountOwnerPublicKey (accountId) = makeString(["%s%s", accountId, "ownerPublicKey"], separator)
4860
4961
5062 func kAccountAmountAssetId (accountId) = makeString(["%s%s", accountId, "amountAssetId"], separator)
5163
5264
5365 func kAccountPriceAssetId (accountId) = makeString(["%s%s", accountId, "priceAssetId"], separator)
5466
5567
5668 func kAccountIdToAccountPublicKey (accountId) = makeString(["%s%s", accountId, "accountIdToAccountPublicKey"], separator)
5769
5870
5971 func kAccountAddressToAccountId (accountAddress) = makeString(["%s%s", toString(accountAddress), "accountAddressToAccountId"], separator)
6072
6173
62-func kPairAllowed (amountAssetId,priceAssetId) = makeString(["%s%s%s", toBase58String(amountAssetId), toBase58String(priceAssetId), "pairAllowed"], separator)
74+func kPairAllowed (amountAssetId,priceAssetId) = makeString(["%s%s%s", assetIdToString(amountAssetId), assetIdToString(priceAssetId), "pairAllowed"], separator)
6375
6476
6577 func pairAllowed (amountAssetId,priceAssetId) = valueOrElse(getBoolean(this, kPairAllowed(amountAssetId, priceAssetId)), false)
6678
6779
6880 let serviceAddress = addressFromPublicKey(getBinaryValue(this, kServicePublicKey))
6981
7082 let botPublicKey = getBinaryValue(this, kBotPublicKey)
7183
7284 @Callable(i)
7385 func init (servicePublicKey,botPublicKey,accountScript,rewardAmount) = {
7486 let checkCaller = mustThis(i)
7587 if ((checkCaller == checkCaller))
7688 then $Tuple2([BinaryEntry(kServicePublicKey, servicePublicKey), BinaryEntry(kBotPublicKey, botPublicKey), BinaryEntry(kAccountScript, accountScript), IntegerEntry(kRewardAmount, rewardAmount)], unit)
7789 else throw("Strict value is not equal to itself.")
7890 }
7991
8092
8193
8294 @Callable(i)
83-func request (amountAssetId,priceAssetId) = {
84- let accountId = toBase58String(sha256(((i.caller.bytes + amountAssetId) + priceAssetId)))
95+func request (amountAssetIdStr,priceAssetIdStr) = {
96+ let accountId = makeString([toString(i.caller), amountAssetIdStr, priceAssetIdStr], ":")
97+ let amountAssetId = parseAssetId(amountAssetIdStr)
98+ let priceAssetId = parseAssetId(priceAssetIdStr)
8599 let checks = [if ((size(i.payments) == 1))
86100 then true
87101 else throw("1 payment is required"), if ((i.payments[0].assetId == unit))
88102 then true
89103 else throw("invalid asset"), if ((i.payments[0].amount == rewardAmount()))
90104 then true
91105 else throw("invalid amount"), if (pairAllowed(amountAssetId, priceAssetId))
92106 then true
93107 else throw("pair is not allowed"), if ((getInteger(this, kAccountStatus(accountId)) == unit))
94108 then true
95109 else throw("account already exists")]
96110 if ((checks == checks))
97- then $Tuple2([IntegerEntry(kAccountStatus(accountId), 0), BinaryEntry(kAccountOwnerPublicKey(accountId), i.callerPublicKey), BinaryEntry(kAccountAmountAssetId(accountId), amountAssetId), BinaryEntry(kAccountPriceAssetId(accountId), priceAssetId)], unit)
111+ then $Tuple2([IntegerEntry(kAccountStatus(accountId), 0), BinaryEntry(kAccountOwnerPublicKey(accountId), i.callerPublicKey), StringEntry(kAccountAmountAssetId(accountId), amountAssetIdStr), StringEntry(kAccountPriceAssetId(accountId), priceAssetIdStr)], unit)
98112 else throw("Strict value is not equal to itself.")
99113 }
100114
101115
102116
103117 @Callable(i)
104118 func complete (accountId,creatorPublicKey) = {
105119 let accountPublicKey = i.callerPublicKey
106120 let accountAddress = i.caller
107121 let checks = [if ((accountStatus(accountId) == ACCOUNT_STATUS_EMPTY))
108122 then true
109123 else throw("account is already exists"), if ( match scriptHash(accountAddress) {
110124 case b: ByteVector =>
111125 (b == blake2b256_32Kb(accountScript()))
112126 case _ =>
113127 false
114128 })
115129 then true
116130 else throw("invalid script")]
117131 if ((checks == checks))
118132 then {
119133 let creatorAddress = addressFromPublicKey(creatorPublicKey)
120134 $Tuple2([IntegerEntry(kAccountStatus(accountId), ACCOUNT_STATUS_READY), BinaryEntry(kAccountCreatorPublicKey(accountId), creatorPublicKey), BinaryEntry(kAccountIdToAccountPublicKey(accountId), accountPublicKey), StringEntry(kAccountAddressToAccountId(accountAddress), accountId), ScriptTransfer(creatorAddress, rewardAmount(), unit)], unit)
121135 }
122136 else throw("Strict value is not equal to itself.")
123137 }
124138
125139

github/deemru/w8io/026f985 
44.01 ms