tx · 4veqf1rKZj98VkW5eHW4Xpq45bP1axVAgNLFxRCMHqDy

3N91zFrRoofbPpkoDbWKrQsQSdLu2EgLL8c:  -0.01000000 Waves

2023.09.29 13:20 [2776572] smart account 3N91zFrRoofbPpkoDbWKrQsQSdLu2EgLL8c > SELF 0.00000000 Waves

{ "type": 13, "id": "4veqf1rKZj98VkW5eHW4Xpq45bP1axVAgNLFxRCMHqDy", "fee": 1000000, "feeAssetId": null, "timestamp": 1695982849675, "version": 2, "chainId": 84, "sender": "3N91zFrRoofbPpkoDbWKrQsQSdLu2EgLL8c", "senderPublicKey": "5FyjUYCR5Q8jvG6ri6Ysz574HerUK6r1LJzzQ7DvSkLk", "proofs": [ "3HYyaGuF45eV83zf3YfgMxCMXpgCXJ7FoFoY51gvYEuYgjfqhuCWJa8a4Ewik5MfFCctV92DinVX3RRNQPZKkZ3x" ], "script": "base64:BgIWCAISBgoEAgICARIECgICAhIECgIIAhUACXNlcGFyYXRvcgICX18BC211c3RBZGRyZXNzAgFpB2FkZHJlc3MDCQAAAggFAWkGY2FsbGVyBQdhZGRyZXNzBgkBBXRocm93AAEIbXVzdFRoaXMBAWkJAQttdXN0QWRkcmVzcwIFAWkFBHRoaXMAEWtTZXJ2aWNlUHVibGljS2V5AhQlc19fc2VydmljZVB1YmxpY0tleQANa0JvdFB1YmxpY0tleQIQJXNfX2JvdFB1YmxpY0tleQAOa0FjY291bnRTY3JpcHQCESVzX19hY2NvdW50U2NyaXB0AQ1hY2NvdW50U2NyaXB0AAkBE3ZhbHVlT3JFcnJvck1lc3NhZ2UCCQCcCAIFBHRoaXMFDmtBY2NvdW50U2NyaXB0AhlhY2NvdW50IHNjcmlwdCBpcyBub3Qgc2V0AA1rUmV3YXJkQW1vdW50AhAlc19fcmV3YXJkQW1vdW50AQxyZXdhcmRBbW91bnQACQETdmFsdWVPckVycm9yTWVzc2FnZQIJAJoIAgUEdGhpcwUNa1Jld2FyZEFtb3VudAIYcmV3YXJkIGFtb3VudCBpcyB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MJAAECBQckbWF0Y2gwAgpCeXRlVmVjdG9yBAFiBQckbWF0Y2gwCQAAAgUBYgkA8RUBCQENYWNjb3VudFNjcmlwdAAHBgkAAgECDmludmFsaWQgc2NyaXB0BQNuaWwDCQAAAgUGY2hlY2tzBQZjaGVja3MEDmNyZWF0b3JBZGRyZXNzCQCnCAEFEGNyZWF0b3JQdWJsaWNLZXkJAJQKAgkAzAgCCQEMSW50ZWdlckVudHJ5AgkBDmtBY2NvdW50U3RhdHVzAQUJYWNjb3VudElkBRRBQ0NPVU5UX1NUQVRVU19SRUFEWQkAzAgCCQELQmluYXJ5RW50cnkCCQEYa0FjY291bnRDcmVhdG9yUHVibGljS2V5AQUJYWNjb3VudElkBRBjcmVhdG9yUHVibGljS2V5CQDMCAIJAQtCaW5hcnlFbnRyeQIJARxrQWNjb3VudElkVG9BY2NvdW50UHVibGljS2V5AQUJYWNjb3VudElkBRBhY2NvdW50UHVibGljS2V5CQDMCAIJAQtTdHJpbmdFbnRyeQIJARprQWNjb3VudEFkZHJlc3NUb0FjY291bnRJZAEFDmFjY291bnRBZGRyZXNzBQlhY2NvdW50SWQJAMwIAgkBDlNjcmlwdFRyYW5zZmVyAwUOY3JlYXRvckFkZHJlc3MJAQxyZXdhcmRBbW91bnQABQR1bml0BQNuaWwFBHVuaXQJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4AxeKCYA==", "height": 2776572, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 52UDy65RNS29aikC2CuuPbHQjnq13HFAUit4vngCNody Next: ekrk3RoaYGx5v5Sm47tvYU1fNAuUmsg9N85pwhynBd3 Diff:
OldNewDifferences
1515
1616 let kBotPublicKey = "%s__botPublicKey"
1717
18-let kFactoryPublicKey = "%s__factoryPublicKey"
18+let kAccountScript = "%s__accountScript"
1919
20-let kOwnerPublicKey = "%s__ownerPublicKey"
21-
22-let kCreatorPublicKey = "%s__creatorPublicKey"
23-
24-let kAccountScriptHash = "%s__accountScriptHash"
25-
26-func accountScriptHash () = valueOrErrorMessage(getBinary(this, kAccountScriptHash), "account script hash is not set")
27-
28-
29-let kCounter = "%s__counter"
30-
31-func counter () = valueOrElse(getInteger(this, kCounter), 0)
20+func accountScript () = valueOrErrorMessage(getBinary(this, kAccountScript), "account script is not set")
3221
3322
3423 let kRewardAmount = "%s__rewardAmount"
3625 func rewardAmount () = valueOrErrorMessage(getInteger(this, kRewardAmount), "reward amount is not set")
3726
3827
39-func kRequestCompleted (requestId) = makeString(["%s%s", requestId, "completed"], separator)
28+let ACCOUNT_STATUS_EMPTY = 0
29+
30+let ACCOUNT_STATUS_READY = 1
31+
32+func kAccountStatus (accountId) = makeString(["%s%s", accountId, "status"], separator)
4033
4134
42-func requestCompleted (requestId) = valueOrErrorMessage(getBoolean(this, kRequestCompleted(requestId)), "request is not found")
35+func accountStatus (accountId) = valueOrErrorMessage(getInteger(this, kAccountStatus(accountId)), "account is not found")
4336
4437
45-func kRequestOwner (requestId) = makeString(["%s%s", requestId, "owner"], separator)
38+func kAccountCreatorPublicKey (accountId) = makeString(["%s%s", accountId, "creatorPublicKey"], separator)
4639
4740
48-func requestOwner (requestId) = valueOrErrorMessage(getBinary(this, kRequestOwner(requestId)), "request is not found")
41+func kAccountOwnerPublicKey (accountId) = makeString(["%s%s", accountId, "ownerPublicKey"], separator)
42+
43+
44+func kAccountAmountAssetId (accountId) = makeString(["%s%s", accountId, "amountAssetId"], separator)
45+
46+
47+func kAccountPriceAssetId (accountId) = makeString(["%s%s", accountId, "priceAssetId"], separator)
48+
49+
50+func kAccountIdToAccountPublicKey (accountId) = makeString(["%s%s", accountId, "accountIdToAccountPublicKey"], separator)
51+
52+
53+func kAccountAddressToAccountId (accountAddress) = makeString(["%s%s", toString(accountAddress), "accountAddressToAccountId"], separator)
4954
5055
5156 let serviceAddress = addressFromPublicKey(getBinaryValue(this, kServicePublicKey))
5358 let botPublicKey = getBinaryValue(this, kBotPublicKey)
5459
5560 @Callable(i)
56-func init (servicePublicKey,botPublicKey,accountScriptHash,rewardAmount) = {
61+func init (servicePublicKey,botPublicKey,accountScript,rewardAmount) = {
5762 let checkCaller = mustThis(i)
5863 if ((checkCaller == checkCaller))
59- then $Tuple2([BinaryEntry(kServicePublicKey, servicePublicKey), BinaryEntry(kBotPublicKey, botPublicKey), BinaryEntry(kAccountScriptHash, accountScriptHash), IntegerEntry(kRewardAmount, rewardAmount)], unit)
64+ then $Tuple2([BinaryEntry(kServicePublicKey, servicePublicKey), BinaryEntry(kBotPublicKey, botPublicKey), BinaryEntry(kAccountScript, accountScript), IntegerEntry(kRewardAmount, rewardAmount)], unit)
6065 else throw("Strict value is not equal to itself.")
6166 }
6267
6368
6469
6570 @Callable(i)
66-func request () = {
71+func request (amountAssetId,priceAssetId) = {
72+ let accountId = toBase58String(sha256(((i.caller.bytes + amountAssetId) + priceAssetId)))
6773 let checks = [if ((size(i.payments) == 1))
6874 then true
6975 else throw("1 payment is required"), if ((i.payments[0].assetId == unit))
7076 then true
7177 else throw("invalid asset"), if ((i.payments[0].amount == rewardAmount()))
7278 then true
73- else throw("invalid amount")]
79+ else throw("invalid amount"), if ((getInteger(this, kAccountStatus(accountId)) == unit))
80+ then true
81+ else throw("account already exists")]
7482 if ((checks == checks))
75- then {
76- let requestId = toBase58String(sha256((i.caller.bytes + toBytes(counter()))))
77- $Tuple2([BooleanEntry(kRequestCompleted(requestId), false), BinaryEntry(kRequestOwner(requestId), i.callerPublicKey), IntegerEntry(kCounter, (counter() + 1))], unit)
78- }
83+ then $Tuple2([IntegerEntry(kAccountStatus(accountId), 0), BinaryEntry(kAccountOwnerPublicKey(accountId), i.callerPublicKey), BinaryEntry(kAccountAmountAssetId(accountId), amountAssetId), BinaryEntry(kAccountPriceAssetId(accountId), priceAssetId)], unit)
7984 else throw("Strict value is not equal to itself.")
8085 }
8186
8287
8388
8489 @Callable(i)
85-func complete (requestId,accountPublicKey) = {
86- let accountAddress = addressFromPublicKey(accountPublicKey)
87- let checks = [if (!(requestCompleted(requestId)))
90+func complete (accountId,creatorPublicKey) = {
91+ let accountPublicKey = i.callerPublicKey
92+ let accountAddress = i.caller
93+ let checks = [if ((accountStatus(accountId) == ACCOUNT_STATUS_EMPTY))
8894 then true
89- else throw("request is already completed"), if ((scriptHash(accountAddress) == accountScriptHash()))
90- then true
91- else throw("invalid script"), if ( match getBinary(accountAddress, kFactoryPublicKey) {
95+ else throw("account is already exists"), if ( match scriptHash(accountAddress) {
9296 case b: ByteVector =>
93- (addressFromPublicKey(b) == this)
97+ (b == blake2b256_32Kb(accountScript()))
9498 case _ =>
9599 false
96100 })
97101 then true
98- else throw("invalid factory public key"), if ( match getBinary(accountAddress, kOwnerPublicKey) {
99- case b: ByteVector =>
100- (b == requestOwner(requestId))
101- case _ =>
102- false
103- })
104- then true
105- else throw("invalid owner public key")]
102+ else throw("invalid script")]
106103 if ((checks == checks))
107104 then {
108- let creatorPublicKey = valueOrErrorMessage(getBinary(accountAddress, kCreatorPublicKey), "creator public key is not set")
109105 let creatorAddress = addressFromPublicKey(creatorPublicKey)
110- let result = invoke(accountAddress, "approve", nil, nil)
111- $Tuple2([BooleanEntry(kRequestCompleted(requestId), true), ScriptTransfer(creatorAddress, rewardAmount(), unit)], result)
106+ $Tuple2([IntegerEntry(kAccountStatus(accountId), ACCOUNT_STATUS_READY), BinaryEntry(kAccountCreatorPublicKey(accountId), creatorPublicKey), BinaryEntry(kAccountIdToAccountPublicKey(accountId), accountPublicKey), StringEntry(kAccountAddressToAccountId(accountAddress), accountId), ScriptTransfer(creatorAddress, rewardAmount(), unit)], unit)
112107 }
113108 else throw("Strict value is not equal to itself.")
114109 }
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let separator = "__"
55
66 func mustAddress (i,address) = if ((i.caller == address))
77 then true
88 else throw()
99
1010
1111 func mustThis (i) = mustAddress(i, this)
1212
1313
1414 let kServicePublicKey = "%s__servicePublicKey"
1515
1616 let kBotPublicKey = "%s__botPublicKey"
1717
18-let kFactoryPublicKey = "%s__factoryPublicKey"
18+let kAccountScript = "%s__accountScript"
1919
20-let kOwnerPublicKey = "%s__ownerPublicKey"
21-
22-let kCreatorPublicKey = "%s__creatorPublicKey"
23-
24-let kAccountScriptHash = "%s__accountScriptHash"
25-
26-func accountScriptHash () = valueOrErrorMessage(getBinary(this, kAccountScriptHash), "account script hash is not set")
27-
28-
29-let kCounter = "%s__counter"
30-
31-func counter () = valueOrElse(getInteger(this, kCounter), 0)
20+func accountScript () = valueOrErrorMessage(getBinary(this, kAccountScript), "account script is not set")
3221
3322
3423 let kRewardAmount = "%s__rewardAmount"
3524
3625 func rewardAmount () = valueOrErrorMessage(getInteger(this, kRewardAmount), "reward amount is not set")
3726
3827
39-func kRequestCompleted (requestId) = makeString(["%s%s", requestId, "completed"], separator)
28+let ACCOUNT_STATUS_EMPTY = 0
29+
30+let ACCOUNT_STATUS_READY = 1
31+
32+func kAccountStatus (accountId) = makeString(["%s%s", accountId, "status"], separator)
4033
4134
42-func requestCompleted (requestId) = valueOrErrorMessage(getBoolean(this, kRequestCompleted(requestId)), "request is not found")
35+func accountStatus (accountId) = valueOrErrorMessage(getInteger(this, kAccountStatus(accountId)), "account is not found")
4336
4437
45-func kRequestOwner (requestId) = makeString(["%s%s", requestId, "owner"], separator)
38+func kAccountCreatorPublicKey (accountId) = makeString(["%s%s", accountId, "creatorPublicKey"], separator)
4639
4740
48-func requestOwner (requestId) = valueOrErrorMessage(getBinary(this, kRequestOwner(requestId)), "request is not found")
41+func kAccountOwnerPublicKey (accountId) = makeString(["%s%s", accountId, "ownerPublicKey"], separator)
42+
43+
44+func kAccountAmountAssetId (accountId) = makeString(["%s%s", accountId, "amountAssetId"], separator)
45+
46+
47+func kAccountPriceAssetId (accountId) = makeString(["%s%s", accountId, "priceAssetId"], separator)
48+
49+
50+func kAccountIdToAccountPublicKey (accountId) = makeString(["%s%s", accountId, "accountIdToAccountPublicKey"], separator)
51+
52+
53+func kAccountAddressToAccountId (accountAddress) = makeString(["%s%s", toString(accountAddress), "accountAddressToAccountId"], separator)
4954
5055
5156 let serviceAddress = addressFromPublicKey(getBinaryValue(this, kServicePublicKey))
5257
5358 let botPublicKey = getBinaryValue(this, kBotPublicKey)
5459
5560 @Callable(i)
56-func init (servicePublicKey,botPublicKey,accountScriptHash,rewardAmount) = {
61+func init (servicePublicKey,botPublicKey,accountScript,rewardAmount) = {
5762 let checkCaller = mustThis(i)
5863 if ((checkCaller == checkCaller))
59- then $Tuple2([BinaryEntry(kServicePublicKey, servicePublicKey), BinaryEntry(kBotPublicKey, botPublicKey), BinaryEntry(kAccountScriptHash, accountScriptHash), IntegerEntry(kRewardAmount, rewardAmount)], unit)
64+ then $Tuple2([BinaryEntry(kServicePublicKey, servicePublicKey), BinaryEntry(kBotPublicKey, botPublicKey), BinaryEntry(kAccountScript, accountScript), IntegerEntry(kRewardAmount, rewardAmount)], unit)
6065 else throw("Strict value is not equal to itself.")
6166 }
6267
6368
6469
6570 @Callable(i)
66-func request () = {
71+func request (amountAssetId,priceAssetId) = {
72+ let accountId = toBase58String(sha256(((i.caller.bytes + amountAssetId) + priceAssetId)))
6773 let checks = [if ((size(i.payments) == 1))
6874 then true
6975 else throw("1 payment is required"), if ((i.payments[0].assetId == unit))
7076 then true
7177 else throw("invalid asset"), if ((i.payments[0].amount == rewardAmount()))
7278 then true
73- else throw("invalid amount")]
79+ else throw("invalid amount"), if ((getInteger(this, kAccountStatus(accountId)) == unit))
80+ then true
81+ else throw("account already exists")]
7482 if ((checks == checks))
75- then {
76- let requestId = toBase58String(sha256((i.caller.bytes + toBytes(counter()))))
77- $Tuple2([BooleanEntry(kRequestCompleted(requestId), false), BinaryEntry(kRequestOwner(requestId), i.callerPublicKey), IntegerEntry(kCounter, (counter() + 1))], unit)
78- }
83+ then $Tuple2([IntegerEntry(kAccountStatus(accountId), 0), BinaryEntry(kAccountOwnerPublicKey(accountId), i.callerPublicKey), BinaryEntry(kAccountAmountAssetId(accountId), amountAssetId), BinaryEntry(kAccountPriceAssetId(accountId), priceAssetId)], unit)
7984 else throw("Strict value is not equal to itself.")
8085 }
8186
8287
8388
8489 @Callable(i)
85-func complete (requestId,accountPublicKey) = {
86- let accountAddress = addressFromPublicKey(accountPublicKey)
87- let checks = [if (!(requestCompleted(requestId)))
90+func complete (accountId,creatorPublicKey) = {
91+ let accountPublicKey = i.callerPublicKey
92+ let accountAddress = i.caller
93+ let checks = [if ((accountStatus(accountId) == ACCOUNT_STATUS_EMPTY))
8894 then true
89- else throw("request is already completed"), if ((scriptHash(accountAddress) == accountScriptHash()))
90- then true
91- else throw("invalid script"), if ( match getBinary(accountAddress, kFactoryPublicKey) {
95+ else throw("account is already exists"), if ( match scriptHash(accountAddress) {
9296 case b: ByteVector =>
93- (addressFromPublicKey(b) == this)
97+ (b == blake2b256_32Kb(accountScript()))
9498 case _ =>
9599 false
96100 })
97101 then true
98- else throw("invalid factory public key"), if ( match getBinary(accountAddress, kOwnerPublicKey) {
99- case b: ByteVector =>
100- (b == requestOwner(requestId))
101- case _ =>
102- false
103- })
104- then true
105- else throw("invalid owner public key")]
102+ else throw("invalid script")]
106103 if ((checks == checks))
107104 then {
108- let creatorPublicKey = valueOrErrorMessage(getBinary(accountAddress, kCreatorPublicKey), "creator public key is not set")
109105 let creatorAddress = addressFromPublicKey(creatorPublicKey)
110- let result = invoke(accountAddress, "approve", nil, nil)
111- $Tuple2([BooleanEntry(kRequestCompleted(requestId), true), ScriptTransfer(creatorAddress, rewardAmount(), unit)], result)
106+ $Tuple2([IntegerEntry(kAccountStatus(accountId), ACCOUNT_STATUS_READY), BinaryEntry(kAccountCreatorPublicKey(accountId), creatorPublicKey), BinaryEntry(kAccountIdToAccountPublicKey(accountId), accountPublicKey), StringEntry(kAccountAddressToAccountId(accountAddress), accountId), ScriptTransfer(creatorAddress, rewardAmount(), unit)], unit)
112107 }
113108 else throw("Strict value is not equal to itself.")
114109 }
115110
116111

github/deemru/w8io/169f3d6 
49.51 ms