tx · 9T7AzoNsvxmEAz51mhk7dtbKEVxkQ9NF45Sc8mR3etZb 3N1q2ieDU25PkmLZxFZrdGxETB1vWeLQo4y: -0.01000000 Waves 2022.03.07 20:32 [1953847] smart account 3N1q2ieDU25PkmLZxFZrdGxETB1vWeLQo4y > SELF 0.00000000 Waves
{ "type": 13, "id": "9T7AzoNsvxmEAz51mhk7dtbKEVxkQ9NF45Sc8mR3etZb", "fee": 1000000, "feeAssetId": null, "timestamp": 1646674387984, "version": 2, "chainId": 84, "sender": "3N1q2ieDU25PkmLZxFZrdGxETB1vWeLQo4y", "senderPublicKey": "EgxqmjPExKP8GAbJQALcx5po8T3xyXNAKUPuvben5unh", "proofs": [ "5vtHC3dnk1V123K7nePLS23QfLJRa1tBEFvLp446pRESPRDwFkMm2sHaBwcgVXxa7e9jQbjaS3ndzF8fkowCt5sz" ], "script": "base64:AAIFAAAAAAAAAA4IAhIDCgEIEgUKAwgICAAAAA0AAAAAEWNlcnRTdGF0dXNSZXZva2VkAgAAAAdSRVZPS0VEAAAAABBjZXJ0U3RhdHVzQWN0aXZlAgAAAAZBQ1RJVkUAAAAACW9yYWNsZUtleQIAAAAJb3JhY2xlS2V5AQAAAAZnZXRTdHIAAAABAAAAA2tleQQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYgUAAAAHJG1hdGNoMAUAAAABYgIAAAAAAAAAAAZvcmFjbGUJAQAAAAZnZXRTdHIAAAABBQAAAAlvcmFjbGVLZXkAAAAACW9yYWNsZUZlZQkBAAAABXZhbHVlAAAAAQkABCYAAAABBQAAAAZvcmFjbGUAAAAACnJlc2VsbERhcHAJAAQmAAAAAQkBAAAAE3ZhbHVlT3JFcnJvck1lc3NhZ2UAAAACCQAEHQAAAAIFAAAACW9yYWNsZUZlZQIAAAAKcmVzZWxsRGFwcAIAAAAUcmVzZWxsRGFwcCBub3QgZm91bmQAAAA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W50cnkAAAACCQABLAAAAAIJAAEsAAAAAgIAAAAFY2VydF8FAAAABmNlcnRJZAIAAAAGX25mdElkBQAAAAVuZnRJZAkABEwAAAACCQEAAAALU3RyaW5nRW50cnkAAAACCQABLAAAAAIJAAEsAAAAAgIAAAAFY2VydF8FAAAABmNlcnRJZAIAAAAGX293bmVyBQAAAAhuZnRPd25lcgkABEwAAAACCQEAAAALU3RyaW5nRW50cnkAAAACCQABLAAAAAIJAAEsAAAAAgIAAAAFY2VydF8FAAAABmNlcnRJZAIAAAAHX2FydGlzdAUAAAANYXJ0aXN0QWRkcmVzcwkABEwAAAACCQEAAAALU3RyaW5nRW50cnkAAAACCQABLAAAAAIJAAEsAAAAAgIAAAAFY2VydF8FAAAABmNlcnRJZAIAAAAHX3N0YXR1cwUAAAAQY2VydFN0YXR1c0FjdGl2ZQUAAAADbmlsCQAETgAAAAIFAAAACnJldm9rZURhdGEFAAAACmNyZWF0ZURhdGEJAAACAAAAAQkAASwAAAACAgAAABdUaGUgTkZUIGlzbid0IG93bmVkIGJ5IAUAAAAIbmZ0T3duZXIJAAACAAAAAQIAAAAfVGhpcyBkYXBwIGNhbiBub3QgY3JlYXRlIGNlcnRzIQAAAADV/epb", "height": 1953847, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5fgFeiytuhktSbJ3t2nwZiv7TFTKBgvcgAi1o2bFCKt2 Next: 6ATv1GSBEwaG32a9MBsQCDWQCC1HmAtLjqMARpTfXxQ3 Diff:
Old | New | Differences | |
---|---|---|---|
4 | 4 | let certStatusRevoked = "REVOKED" | |
5 | 5 | ||
6 | 6 | let certStatusActive = "ACTIVE" | |
7 | + | ||
8 | + | let oracleKey = "oracleKey" | |
9 | + | ||
10 | + | func getStr (key) = match getString(this, key) { | |
11 | + | case b: String => | |
12 | + | b | |
13 | + | case _ => | |
14 | + | "" | |
15 | + | } | |
16 | + | ||
17 | + | ||
18 | + | let oracle = getStr(oracleKey) | |
19 | + | ||
20 | + | let oracleFee = value(addressFromString(oracle)) | |
21 | + | ||
22 | + | let resellDapp = addressFromString(valueOrErrorMessage(getString(oracleFee, "resellDapp"), "resellDapp not found")) | |
23 | + | ||
24 | + | let sconexDapp = addressFromString(valueOrErrorMessage(getString(oracleFee, "sconexDapp"), "sconexDapp not found")) | |
25 | + | ||
26 | + | let allowedDapps = [resellDapp, sconexDapp] | |
7 | 27 | ||
8 | 28 | func getStringByKey (key) = valueOrElse(getString(this, key), "") | |
9 | 29 | ||
33 | 53 | ||
34 | 54 | ||
35 | 55 | @Callable(i) | |
36 | - | func createCert (nftOwner,nftId,artistAddress) = { | |
37 | - | let certId = toBase58String(i.transactionId) | |
38 | - | let assetIdBytes = fromBase58String(nftId) | |
39 | - | let assetInfoOutput = tryGetNftInfo(assetIdBytes) | |
40 | - | if ((assetInfoOutput != 1)) | |
41 | - | then throw("This is not an NFT!") | |
42 | - | else if (doesAddressOwnNft(assetIdBytes, nftOwner)) | |
43 | - | then { | |
44 | - | let revokeData = revokeOldCert(nftId) | |
45 | - | let createData = [StringEntry(("cert_" + nftId), certId), StringEntry((("cert_" + certId) + "_nftId"), nftId), StringEntry((("cert_" + certId) + "_owner"), nftOwner), StringEntry((("cert_" + certId) + "_artist"), artistAddress), StringEntry((("cert_" + certId) + "_status"), certStatusActive)] | |
46 | - | (revokeData ++ createData) | |
47 | - | } | |
48 | - | else throw(("The NFT isn't owned by " + nftOwner)) | |
49 | - | } | |
56 | + | func initDapp (dappKey) = if ((i.caller != this)) | |
57 | + | then throw("You cannot do this action") | |
58 | + | else if ((oracle != "")) | |
59 | + | then throw("oracle already set, you can't override!") | |
60 | + | else [StringEntry(oracleKey, dappKey)] | |
61 | + | ||
62 | + | ||
63 | + | ||
64 | + | @Callable(i) | |
65 | + | func createCert (nftOwner,nftId,artistAddress) = if (containsElement(allowedDapps, i.caller)) | |
66 | + | then { | |
67 | + | let certId = toBase58String(i.transactionId) | |
68 | + | let assetIdBytes = fromBase58String(nftId) | |
69 | + | let assetInfoOutput = tryGetNftInfo(assetIdBytes) | |
70 | + | if ((assetInfoOutput != 1)) | |
71 | + | then throw("This is not an NFT!") | |
72 | + | else if (doesAddressOwnNft(assetIdBytes, nftOwner)) | |
73 | + | then { | |
74 | + | let revokeData = revokeOldCert(nftId) | |
75 | + | let createData = [StringEntry(("cert_" + nftId), certId), StringEntry((("cert_" + certId) + "_nftId"), nftId), StringEntry((("cert_" + certId) + "_owner"), nftOwner), StringEntry((("cert_" + certId) + "_artist"), artistAddress), StringEntry((("cert_" + certId) + "_status"), certStatusActive)] | |
76 | + | (revokeData ++ createData) | |
77 | + | } | |
78 | + | else throw(("The NFT isn't owned by " + nftOwner)) | |
79 | + | } | |
80 | + | else throw("This dapp can not create certs!") | |
50 | 81 | ||
51 | 82 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let certStatusRevoked = "REVOKED" | |
5 | 5 | ||
6 | 6 | let certStatusActive = "ACTIVE" | |
7 | + | ||
8 | + | let oracleKey = "oracleKey" | |
9 | + | ||
10 | + | func getStr (key) = match getString(this, key) { | |
11 | + | case b: String => | |
12 | + | b | |
13 | + | case _ => | |
14 | + | "" | |
15 | + | } | |
16 | + | ||
17 | + | ||
18 | + | let oracle = getStr(oracleKey) | |
19 | + | ||
20 | + | let oracleFee = value(addressFromString(oracle)) | |
21 | + | ||
22 | + | let resellDapp = addressFromString(valueOrErrorMessage(getString(oracleFee, "resellDapp"), "resellDapp not found")) | |
23 | + | ||
24 | + | let sconexDapp = addressFromString(valueOrErrorMessage(getString(oracleFee, "sconexDapp"), "sconexDapp not found")) | |
25 | + | ||
26 | + | let allowedDapps = [resellDapp, sconexDapp] | |
7 | 27 | ||
8 | 28 | func getStringByKey (key) = valueOrElse(getString(this, key), "") | |
9 | 29 | ||
10 | 30 | ||
11 | 31 | func tryGetNftInfo (assetId) = { | |
12 | 32 | let x = match assetInfo(assetId) { | |
13 | 33 | case asset: Asset => | |
14 | 34 | asset.quantity | |
15 | 35 | case _ => | |
16 | 36 | throw("Invalid NFT id") | |
17 | 37 | } | |
18 | 38 | x | |
19 | 39 | } | |
20 | 40 | ||
21 | 41 | ||
22 | 42 | func doesAddressOwnNft (assetId,address) = if ((assetBalance(Address(fromBase58String(address)), assetId) != 1)) | |
23 | 43 | then false | |
24 | 44 | else true | |
25 | 45 | ||
26 | 46 | ||
27 | 47 | func revokeOldCert (nftId) = { | |
28 | 48 | let certId = getStringByKey(("cert_" + nftId)) | |
29 | 49 | if ((certId != "")) | |
30 | 50 | then [StringEntry((("cert_" + certId) + "_status"), certStatusRevoked)] | |
31 | 51 | else nil | |
32 | 52 | } | |
33 | 53 | ||
34 | 54 | ||
35 | 55 | @Callable(i) | |
36 | - | func createCert (nftOwner,nftId,artistAddress) = { | |
37 | - | let certId = toBase58String(i.transactionId) | |
38 | - | let assetIdBytes = fromBase58String(nftId) | |
39 | - | let assetInfoOutput = tryGetNftInfo(assetIdBytes) | |
40 | - | if ((assetInfoOutput != 1)) | |
41 | - | then throw("This is not an NFT!") | |
42 | - | else if (doesAddressOwnNft(assetIdBytes, nftOwner)) | |
43 | - | then { | |
44 | - | let revokeData = revokeOldCert(nftId) | |
45 | - | let createData = [StringEntry(("cert_" + nftId), certId), StringEntry((("cert_" + certId) + "_nftId"), nftId), StringEntry((("cert_" + certId) + "_owner"), nftOwner), StringEntry((("cert_" + certId) + "_artist"), artistAddress), StringEntry((("cert_" + certId) + "_status"), certStatusActive)] | |
46 | - | (revokeData ++ createData) | |
47 | - | } | |
48 | - | else throw(("The NFT isn't owned by " + nftOwner)) | |
49 | - | } | |
56 | + | func initDapp (dappKey) = if ((i.caller != this)) | |
57 | + | then throw("You cannot do this action") | |
58 | + | else if ((oracle != "")) | |
59 | + | then throw("oracle already set, you can't override!") | |
60 | + | else [StringEntry(oracleKey, dappKey)] | |
61 | + | ||
62 | + | ||
63 | + | ||
64 | + | @Callable(i) | |
65 | + | func createCert (nftOwner,nftId,artistAddress) = if (containsElement(allowedDapps, i.caller)) | |
66 | + | then { | |
67 | + | let certId = toBase58String(i.transactionId) | |
68 | + | let assetIdBytes = fromBase58String(nftId) | |
69 | + | let assetInfoOutput = tryGetNftInfo(assetIdBytes) | |
70 | + | if ((assetInfoOutput != 1)) | |
71 | + | then throw("This is not an NFT!") | |
72 | + | else if (doesAddressOwnNft(assetIdBytes, nftOwner)) | |
73 | + | then { | |
74 | + | let revokeData = revokeOldCert(nftId) | |
75 | + | let createData = [StringEntry(("cert_" + nftId), certId), StringEntry((("cert_" + certId) + "_nftId"), nftId), StringEntry((("cert_" + certId) + "_owner"), nftOwner), StringEntry((("cert_" + certId) + "_artist"), artistAddress), StringEntry((("cert_" + certId) + "_status"), certStatusActive)] | |
76 | + | (revokeData ++ createData) | |
77 | + | } | |
78 | + | else throw(("The NFT isn't owned by " + nftOwner)) | |
79 | + | } | |
80 | + | else throw("This dapp can not create certs!") | |
50 | 81 | ||
51 | 82 |
github/deemru/w8io/026f985 30.55 ms ◑