4 | | - | let nftAssetId = base58'' |
---|
5 | | - | |
---|
6 | | - | let incubatorAddress = base58'' |
---|
7 | | - | |
---|
8 | | - | let userAddress = base58'' |
---|
9 | | - | |
---|
10 | | - | let collectiveMasterAddress = base58'' |
---|
11 | | - | |
---|
12 | | - | let ref20 = [""] |
---|
13 | | - | |
---|
14 | | - | func tryGetInteger (key) = match getInteger(this, key) { |
---|
15 | | - | case b: Int => |
---|
16 | | - | b |
---|
17 | | - | case _ => |
---|
18 | | - | 0 |
---|
19 | | - | } |
---|
20 | | - | |
---|
21 | | - | |
---|
22 | | - | func masterTryGetBoolean (key) = match getBoolean(Address(collectiveMasterAddress), key) { |
---|
23 | | - | case b: Boolean => |
---|
24 | | - | b |
---|
25 | | - | case _ => |
---|
26 | | - | false |
---|
27 | | - | } |
---|
28 | | - | |
---|
29 | | - | |
---|
30 | | - | func isValidAddress (address) = match addressFromString(address) { |
---|
31 | | - | case a: Address => |
---|
32 | | - | true |
---|
33 | | - | case _ => |
---|
34 | | - | false |
---|
35 | | - | } |
---|
36 | | - | |
---|
37 | | - | |
---|
38 | | - | func tryGetString (key) = match getString(this, key) { |
---|
39 | | - | case a: String => |
---|
40 | | - | a |
---|
41 | | - | case _ => |
---|
42 | | - | "" |
---|
43 | | - | } |
---|
44 | | - | |
---|
45 | | - | |
---|
46 | | - | func getRefMultiplier (gatewayAddress) = if ((indexOf(ref20, gatewayAddress) != unit)) |
---|
47 | | - | then 4 |
---|
48 | | - | else 1 |
---|
52 | | - | func addgatewayKey (gatewayAddress,gatewayKey) = if ((i.caller != this)) |
---|
53 | | - | then throw("admin only") |
---|
54 | | - | else { |
---|
55 | | - | let refStateKey = (("key_" + gatewayKey) + "_refererAddress") |
---|
56 | | - | if ((tryGetString(refStateKey) == "")) |
---|
57 | | - | then [StringEntry(refStateKey, gatewayAddress), StringEntry(((("address_" + gatewayAddress) + "_refererKey_") + gatewayKey), gatewayKey)] |
---|
58 | | - | else throw((("The ref key \"" + gatewayKey) + "\" is already registered")) |
---|
59 | | - | } |
---|
60 | | - | |
---|
61 | | - | |
---|
62 | | - | |
---|
63 | | - | @Callable(i) |
---|
64 | | - | func gatewayreward (refererKey) = { |
---|
65 | | - | let referalAddress = toString(i.originCaller) |
---|
66 | | - | if (if ((i.caller.bytes != incubatorAddress)) |
---|
67 | | - | then (i.caller.bytes != userAddress) |
---|
68 | | - | else false) |
---|
69 | | - | then throw("This method can be called only by farming and incubator dApps") |
---|
70 | | - | else if (if ((refererKey == "")) |
---|
71 | | - | then (tryGetString((("address_" + referalAddress) + "_referedBy")) == "") |
---|
72 | | - | else false) |
---|
73 | | - | then nil |
---|
74 | | - | else if (masterTryGetBoolean(("gateway_" + referalAddress))) |
---|
75 | | - | then nil |
---|
76 | | - | else { |
---|
77 | | - | let givenReferer = match getString(this, (("key_" + refererKey) + "_refererAddress")) { |
---|
78 | | - | case x: String => |
---|
79 | | - | x |
---|
80 | | - | case _ => |
---|
81 | | - | refererKey |
---|
82 | | - | } |
---|
83 | | - | let refererAddress = match getString(this, (("address_" + referalAddress) + "_referedBy")) { |
---|
84 | | - | case x: String => |
---|
85 | | - | x |
---|
86 | | - | case _ => |
---|
87 | | - | givenReferer |
---|
88 | | - | } |
---|
89 | | - | let refAmount = (i.payments[0].amount * getRefMultiplier(refererAddress)) |
---|
90 | | - | if ((addressFromString(refererAddress) == unit)) |
---|
91 | | - | then nil |
---|
92 | | - | else { |
---|
93 | | - | let refererAddressValue = addressFromStringValue(refererAddress) |
---|
94 | | - | let referalAddressValue = addressFromStringValue(referalAddress) |
---|
95 | | - | let paymentForReferer = refAmount |
---|
96 | | - | let refererEarnedReward = (("address_" + refererAddress) + "_earnedReward") |
---|
97 | | - | let referalDeliveredReward = (((("referer_" + refererAddress) + "_referal_") + referalAddress) + "_deliveredReward") |
---|
98 | | - | if ((refererAddress == referalAddress)) |
---|
99 | | - | then nil |
---|
100 | | - | else [StringEntry((("address_" + referalAddress) + "_referedBy"), refererAddress), IntegerEntry(refererEarnedReward, (tryGetInteger(refererEarnedReward) + paymentForReferer)), IntegerEntry(referalDeliveredReward, (tryGetInteger(referalDeliveredReward) + paymentForReferer)), IntegerEntry((((("referer_" + refererAddress) + "_referal_") + referalAddress) + "_amount"), (tryGetInteger((((("referer_" + refererAddress) + "_referal_") + referalAddress) + "_amount")) + 1)), ScriptTransfer(refererAddressValue, paymentForReferer, userAddress)] |
---|
101 | | - | } |
---|
102 | | - | } |
---|
| 7 | + | func sellart (artId,Price,maxMint,assetId,BlockEnd) = { |
---|
| 8 | + | let nftId = toBase58String(i.transactionId) |
---|
| 9 | + | let endHeight = lastBlock.height |
---|
| 10 | + | let pmt = extract(i.payment) |
---|
| 11 | + | WriteSet([DataEntry(nftId, endHeight), DataEntry((nftId + "_organizer"), toBase58String(i.caller.bytes)), DataEntry((nftId + "_lot_assetId"), if (isDefined(pmt.assetId)) |
---|
| 12 | + | then toBase58String(value(pmt.assetId)) |
---|
| 13 | + | else "WAVES"), DataEntry((nftId + "_lot_amount"), pmt.amount), DataEntry((nftId + "_startPrice"), Price), DataEntry((nftId + "_priceAssetId"), assetId)]) |
---|