tx · 8GasfyfQ9dWSyYpp4VVgYuLEhZ9p4hbUQrE6fyqZFmmX 3MyLnBsVm9pw43K9eba5UExxb3efeai91KP: -0.01000000 Waves 2022.12.22 13:51 [2371403] smart account 3MyLnBsVm9pw43K9eba5UExxb3efeai91KP > SELF 0.00000000 Waves
{ "type": 13, "id": "8GasfyfQ9dWSyYpp4VVgYuLEhZ9p4hbUQrE6fyqZFmmX", "fee": 1000000, "feeAssetId": null, "timestamp": 1671706321684, "version": 2, "chainId": 84, "sender": "3MyLnBsVm9pw43K9eba5UExxb3efeai91KP", "senderPublicKey": "E5xdZLn3yHKAn29pTyubhr9R1mkRGg9WKAcpPrCYFYHx", "proofs": [ "29LsUnM2G2oSBvhn1GosEzyLjdV6JDntqMu95ASWbPmtvovjZTkVPfRoQsS7o2AQ9dCzMrj5ZjbaF6mcyHDU7jsd" ], "script": "base64:AAIFAAAAAAAAAB8IAhIAEgASCQoHCAgIAQEIARIDCgEBEgASABIDCgEIAAAADwAAAAAGYWRtUHViAQAAACDCbSeYCFZIOpb4r9LWa8L402jDi6OfxQF86gIW2LZmcwAAAAAMcGF5bWVudEFzc2V0AQAAACAhOUTpKXxfz4r4M5I49SS+rwv2+rnVA49FLcaoUr/6uQAAAAAIZXZlbnRLZXkCAAAAB19ldmVudF8AAAAAEGdsb2JhbEV2ZW50SWRLZXkCAAAACV9ldmVudElkXwAAAAANc3RhcnRCbG9ja0tleQIAAAAMX3N0YXJ0QmxvY2tfAAAAAAtlbmRCbG9ja0tleQIAAAAKX2VuZEJsb2NrXwAAAAAIaW1hZ2VLZXkCAAAAB19pbWFnZV8AAAAACG93bmVyS2V5AgAAAAdfb3duZXJfAAAAAAZ1cmxLZXkCAAAABV91cmxfAAAAAApoYXJkQ2FwS2V5AgAAAAlfaGFyZENhcF8AAAAACHRpdGxlS2V5AgAAAAdfdGl0bGVfAAAAABNzaGFyZUhvbGRlckNvdW50S2V5AgAAABJfc2hhcmVIb2xkZXJDb3VudF8AAAAAD3RvdG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ubmEgcmVmdW5kAAAAAWkBAAAABmRlbGV0ZQAAAAEAAAADa2V5AwkAAAAAAAACCAUAAAABaQAAAA9jYWxsZXJQdWJsaWNLZXkFAAAABmFkbVB1YgkABEwAAAACCQEAAAALRGVsZXRlRW50cnkAAAABBQAAAANrZXkFAAAAA25pbAkAAAIAAAABAgAAAB95b3UgYXJlIG5vdCBhbGxvd2VkIHRvIGRvIHRoaXMhAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXk5BR18", "height": 2371403, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: EKaxq2QYUnvq8VV9p7j7mdtTaY4gfqmHNSXyZ6BDtWmC Next: AApqRyrQSF48dUxEgMy55suavF82ipXJAGmNo3ngKDxp Diff:
Old | New | Differences | |
---|---|---|---|
22 | 22 | let hardCapKey = "_hardCap_" | |
23 | 23 | ||
24 | 24 | let titleKey = "_title_" | |
25 | + | ||
26 | + | let shareHolderCountKey = "_shareHolderCount_" | |
27 | + | ||
28 | + | let totalPaymentKey = "_totalPayment_" | |
29 | + | ||
30 | + | let walletPaymentKey = "_walletPayment_" | |
25 | 31 | ||
26 | 32 | func isPaymentOk (i) = { | |
27 | 33 | let acceptableAssetId = paymentAsset | |
63 | 69 | ||
64 | 70 | ||
65 | 71 | @Callable(i) | |
66 | - | func funding () = throw("funding") | |
72 | + | func funding (eventId) = { | |
73 | + | let startBlock = valueOrErrorMessage(getInteger(this, (startBlockKey + toString(eventId))), "err") | |
74 | + | let endBlock = valueOrErrorMessage(getInteger(this, (endBlockKey + toString(eventId))), "err") | |
75 | + | let hardCap = valueOrErrorMessage(getInteger(this, (hardCapKey + toString(eventId))), "err") | |
76 | + | let currentKey = toBase58String(i.caller.bytes) | |
77 | + | let totalPayment = valueOrElse(getInteger(this, (totalPaymentKey + toString(eventId))), 0) | |
78 | + | let walletPayment = valueOrElse(getInteger(this, ((walletPaymentKey + currentKey) + toString(eventId))), 0) | |
79 | + | let shareHolderCount = valueOrElse(getInteger(this, shareHolderCountKey), 0) | |
80 | + | if ((height > startBlock)) | |
81 | + | then throw("crowdfunding not started") | |
82 | + | else if ((endBlock >= height)) | |
83 | + | then throw("crowdfunding is over") | |
84 | + | else if ((totalPayment >= hardCap)) | |
85 | + | then throw("crowdfunding is reached to hard cap. thank you for participating!") | |
86 | + | else if (!(isPaymentOk(i))) | |
87 | + | then throw("you have to attach payment greater than zero") | |
88 | + | else { | |
89 | + | let p = i.payments[0] | |
90 | + | let paymentAmount = p.amount | |
91 | + | [IntegerEntry((shareHolderCountKey + toString(eventId)), (shareHolderCount + 1)), IntegerEntry((totalPaymentKey + toString(eventId)), (totalPayment + paymentAmount)), IntegerEntry(((walletPaymentKey + currentKey) + toString(eventId)), (walletPayment + paymentAmount))] | |
92 | + | } | |
93 | + | } | |
67 | 94 | ||
68 | 95 | ||
69 | 96 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let admPub = base58'E5xdZLn3yHKAn29pTyubhr9R1mkRGg9WKAcpPrCYFYHx' | |
5 | 5 | ||
6 | 6 | let paymentAsset = base58'3Eh6z6z6ouFpWxGKrPaPnZwmDnDjgYHV6tqCmZf2G7tk' | |
7 | 7 | ||
8 | 8 | let eventKey = "_event_" | |
9 | 9 | ||
10 | 10 | let globalEventIdKey = "_eventId_" | |
11 | 11 | ||
12 | 12 | let startBlockKey = "_startBlock_" | |
13 | 13 | ||
14 | 14 | let endBlockKey = "_endBlock_" | |
15 | 15 | ||
16 | 16 | let imageKey = "_image_" | |
17 | 17 | ||
18 | 18 | let ownerKey = "_owner_" | |
19 | 19 | ||
20 | 20 | let urlKey = "_url_" | |
21 | 21 | ||
22 | 22 | let hardCapKey = "_hardCap_" | |
23 | 23 | ||
24 | 24 | let titleKey = "_title_" | |
25 | + | ||
26 | + | let shareHolderCountKey = "_shareHolderCount_" | |
27 | + | ||
28 | + | let totalPaymentKey = "_totalPayment_" | |
29 | + | ||
30 | + | let walletPaymentKey = "_walletPayment_" | |
25 | 31 | ||
26 | 32 | func isPaymentOk (i) = { | |
27 | 33 | let acceptableAssetId = paymentAsset | |
28 | 34 | if ((size(i.payments) == 0)) | |
29 | 35 | then throw("Payment not attached") | |
30 | 36 | else { | |
31 | 37 | let p = i.payments[0] | |
32 | 38 | match p.assetId { | |
33 | 39 | case assetId: ByteVector => | |
34 | 40 | if ((assetId == acceptableAssetId)) | |
35 | 41 | then (p.amount > 0) | |
36 | 42 | else false | |
37 | 43 | case _ => | |
38 | 44 | throw("Wrong payment asset") | |
39 | 45 | } | |
40 | 46 | } | |
41 | 47 | } | |
42 | 48 | ||
43 | 49 | ||
44 | 50 | @Callable(i) | |
45 | 51 | func shutdown () = throw("shutdown") | |
46 | 52 | ||
47 | 53 | ||
48 | 54 | ||
49 | 55 | @Callable(i) | |
50 | 56 | func settings () = throw("settings") | |
51 | 57 | ||
52 | 58 | ||
53 | 59 | ||
54 | 60 | @Callable(i) | |
55 | 61 | func create (title,image,owner,startBlock,endBlock,url,hardCap) = { | |
56 | 62 | let eventId = valueOrElse(getInteger(this, globalEventIdKey), 0) | |
57 | 63 | let increaseEventId = (eventId + 1) | |
58 | 64 | if ((i.callerPublicKey == admPub)) | |
59 | 65 | then [StringEntry((imageKey + toString(increaseEventId)), image), StringEntry((ownerKey + toString(increaseEventId)), owner), StringEntry((titleKey + toString(increaseEventId)), title), IntegerEntry((startBlockKey + toString(increaseEventId)), startBlock), IntegerEntry((endBlockKey + toString(increaseEventId)), endBlock), StringEntry((urlKey + toString(increaseEventId)), url), IntegerEntry((hardCapKey + toString(increaseEventId)), hardCap), IntegerEntry(globalEventIdKey, increaseEventId)] | |
60 | 66 | else throw("you are not allowed") | |
61 | 67 | } | |
62 | 68 | ||
63 | 69 | ||
64 | 70 | ||
65 | 71 | @Callable(i) | |
66 | - | func funding () = throw("funding") | |
72 | + | func funding (eventId) = { | |
73 | + | let startBlock = valueOrErrorMessage(getInteger(this, (startBlockKey + toString(eventId))), "err") | |
74 | + | let endBlock = valueOrErrorMessage(getInteger(this, (endBlockKey + toString(eventId))), "err") | |
75 | + | let hardCap = valueOrErrorMessage(getInteger(this, (hardCapKey + toString(eventId))), "err") | |
76 | + | let currentKey = toBase58String(i.caller.bytes) | |
77 | + | let totalPayment = valueOrElse(getInteger(this, (totalPaymentKey + toString(eventId))), 0) | |
78 | + | let walletPayment = valueOrElse(getInteger(this, ((walletPaymentKey + currentKey) + toString(eventId))), 0) | |
79 | + | let shareHolderCount = valueOrElse(getInteger(this, shareHolderCountKey), 0) | |
80 | + | if ((height > startBlock)) | |
81 | + | then throw("crowdfunding not started") | |
82 | + | else if ((endBlock >= height)) | |
83 | + | then throw("crowdfunding is over") | |
84 | + | else if ((totalPayment >= hardCap)) | |
85 | + | then throw("crowdfunding is reached to hard cap. thank you for participating!") | |
86 | + | else if (!(isPaymentOk(i))) | |
87 | + | then throw("you have to attach payment greater than zero") | |
88 | + | else { | |
89 | + | let p = i.payments[0] | |
90 | + | let paymentAmount = p.amount | |
91 | + | [IntegerEntry((shareHolderCountKey + toString(eventId)), (shareHolderCount + 1)), IntegerEntry((totalPaymentKey + toString(eventId)), (totalPayment + paymentAmount)), IntegerEntry(((walletPaymentKey + currentKey) + toString(eventId)), (walletPayment + paymentAmount))] | |
92 | + | } | |
93 | + | } | |
67 | 94 | ||
68 | 95 | ||
69 | 96 | ||
70 | 97 | @Callable(i) | |
71 | 98 | func claim () = throw("event owner will claim the money") | |
72 | 99 | ||
73 | 100 | ||
74 | 101 | ||
75 | 102 | @Callable(i) | |
76 | 103 | func refund () = throw("if not success payers gonna refund") | |
77 | 104 | ||
78 | 105 | ||
79 | 106 | ||
80 | 107 | @Callable(i) | |
81 | 108 | func delete (key) = if ((i.callerPublicKey == admPub)) | |
82 | 109 | then [DeleteEntry(key)] | |
83 | 110 | else throw("you are not allowed to do this!") | |
84 | 111 | ||
85 | 112 | ||
86 | 113 | @Verifier(tx) | |
87 | 114 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
88 | 115 |
github/deemru/w8io/026f985 25.31 ms ◑