1 | | - | {-# STDLIB_VERSION 5 #-} |
---|
2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let a = "__" |
---|
5 | | - | |
---|
6 | | - | let b = makeString(["%s", "referral"], a) |
---|
7 | | - | |
---|
8 | | - | let c = makeString(["%s", "wxAssetId"], a) |
---|
9 | | - | |
---|
10 | | - | func d () = "%s__managerPublicKey" |
---|
11 | | - | |
---|
12 | | - | |
---|
13 | | - | func e () = "%s__pendingManagerPublicKey" |
---|
14 | | - | |
---|
15 | | - | |
---|
16 | | - | let f = 1 |
---|
17 | | - | |
---|
18 | | - | let g = 2 |
---|
19 | | - | |
---|
20 | | - | let h = 3 |
---|
21 | | - | |
---|
22 | | - | let i = 4 |
---|
23 | | - | |
---|
24 | | - | let j = 5 |
---|
25 | | - | |
---|
26 | | - | let k = 6 |
---|
27 | | - | |
---|
28 | | - | let l = 1 |
---|
29 | | - | |
---|
30 | | - | let m = 2 |
---|
31 | | - | |
---|
32 | | - | let n = 3 |
---|
33 | | - | |
---|
34 | | - | func o (p) = throw(makeString(["marketing.ride:", p], " ")) |
---|
35 | | - | |
---|
36 | | - | |
---|
37 | | - | func q (r) = valueOrErrorMessage(getString(r), (("mandatory this." + r) + " is not defined")) |
---|
38 | | - | |
---|
39 | | - | |
---|
40 | | - | func s (t,u,v,w,x,y) = makeString(["%d%d%s%d%s%d%", t, u, v, w, x, y], a) |
---|
41 | | - | |
---|
42 | | - | |
---|
43 | | - | func z (t,u,v,w,A,B) = s(toString(t), toString(u), v, toString(w), A, toString(B)) |
---|
44 | | - | |
---|
45 | | - | |
---|
46 | | - | func C (D,E,F) = makeString(["%d%d%d", D, E, F], a) |
---|
47 | | - | |
---|
48 | | - | |
---|
49 | | - | func G (H,I,J,K) = makeString(["%d%d%d%d%d%d", toString(height), toString(lastBlock.timestamp), toString(H), toString(I), toString(J), toString(K)], a) |
---|
50 | | - | |
---|
51 | | - | |
---|
52 | | - | func L () = "%s__config" |
---|
53 | | - | |
---|
54 | | - | |
---|
55 | | - | func M () = "%s__totals" |
---|
56 | | - | |
---|
57 | | - | |
---|
58 | | - | let N = makeString(["%s", "amountUnclaimed"], a) |
---|
59 | | - | |
---|
60 | | - | func O (P,Q,R) = makeString(["%s%s%s%s__history", P, Q, R], a) |
---|
61 | | - | |
---|
62 | | - | |
---|
63 | | - | func S () = split(q(L()), a) |
---|
64 | | - | |
---|
65 | | - | |
---|
66 | | - | func T () = split(q(M()), a) |
---|
67 | | - | |
---|
68 | | - | |
---|
69 | | - | func U (r,V,W,X) = { |
---|
70 | | - | let D = parseIntValue(V[l]) |
---|
71 | | - | let Y = parseIntValue(V[m]) |
---|
72 | | - | let F = parseIntValue(V[n]) |
---|
73 | | - | let Z = (D + W) |
---|
74 | | - | let aa = (Y - W) |
---|
75 | | - | if ((0 > aa)) |
---|
76 | | - | then throw("invalid math") |
---|
77 | | - | else StringEntry(r, C(toString(Z), toString(aa), toString(X))) |
---|
78 | | - | } |
---|
79 | | - | |
---|
80 | | - | |
---|
81 | | - | func ab (Q,H,I,ac,ad,ae) = StringEntry(O("claim", Q, toBase58String(ae)), G(H, I, ac, ad)) |
---|
82 | | - | |
---|
83 | | - | |
---|
84 | | - | func af () = { |
---|
85 | | - | let ag = getString(d()) |
---|
86 | | - | if ($isInstanceOf(ag, "String")) |
---|
87 | | - | then { |
---|
88 | | - | let ah = ag |
---|
89 | | - | fromBase58String(ah) |
---|
90 | | - | } |
---|
91 | | - | else if ($isInstanceOf(ag, "Unit")) |
---|
92 | | - | then unit |
---|
93 | | - | else throw("Match error") |
---|
94 | | - | } |
---|
95 | | - | |
---|
96 | | - | |
---|
97 | | - | func ai () = { |
---|
98 | | - | let ag = getString(e()) |
---|
99 | | - | if ($isInstanceOf(ag, "String")) |
---|
100 | | - | then { |
---|
101 | | - | let ah = ag |
---|
102 | | - | fromBase58String(ah) |
---|
103 | | - | } |
---|
104 | | - | else if ($isInstanceOf(ag, "Unit")) |
---|
105 | | - | then unit |
---|
106 | | - | else throw("Match error") |
---|
107 | | - | } |
---|
108 | | - | |
---|
109 | | - | |
---|
110 | | - | func aj (ak) = { |
---|
111 | | - | let al = o("permission denied") |
---|
112 | | - | let ag = af() |
---|
113 | | - | if ($isInstanceOf(ag, "ByteVector")) |
---|
114 | | - | then { |
---|
115 | | - | let am = ag |
---|
116 | | - | if ((ak.callerPublicKey == am)) |
---|
117 | | - | then true |
---|
118 | | - | else al |
---|
119 | | - | } |
---|
120 | | - | else if ($isInstanceOf(ag, "Unit")) |
---|
121 | | - | then if ((ak.caller == this)) |
---|
122 | | - | then true |
---|
123 | | - | else al |
---|
124 | | - | else throw("Match error") |
---|
125 | | - | } |
---|
126 | | - | |
---|
127 | | - | |
---|
128 | | - | func an (ak,ao) = { |
---|
129 | | - | let ap = S() |
---|
130 | | - | let aq = parseIntValue(ap[f]) |
---|
131 | | - | let ar = parseIntValue(ap[g]) |
---|
132 | | - | let as = (aq + ar) |
---|
133 | | - | let at = fromBase58String(ap[h]) |
---|
134 | | - | let au = addressFromStringValue(ap[j]) |
---|
135 | | - | let av = parseIntValue(ap[k]) |
---|
136 | | - | let aw = T() |
---|
137 | | - | let D = parseIntValue(aw[l]) |
---|
138 | | - | let ax = parseIntValue(aw[m]) |
---|
139 | | - | let F = parseIntValue(aw[n]) |
---|
140 | | - | if ((ak.caller != au)) |
---|
141 | | - | then throw("permissions denied") |
---|
142 | | - | else if ((aq > height)) |
---|
143 | | - | then throw(("Wait claim start block: " + toString(aq))) |
---|
144 | | - | else { |
---|
145 | | - | let K = if ((height > as)) |
---|
146 | | - | then as |
---|
147 | | - | else height |
---|
148 | | - | let J = if ((F == 0)) |
---|
149 | | - | then aq |
---|
150 | | - | else F |
---|
151 | | - | let I = (K - J) |
---|
152 | | - | let ay = fraction(av, I, ar) |
---|
153 | | - | let az = valueOrElse(getInteger(this, N), 0) |
---|
154 | | - | let aA = (ay + az) |
---|
155 | | - | let aB = if (if ((0 >= ao)) |
---|
156 | | - | then true |
---|
157 | | - | else (ao >= aA)) |
---|
158 | | - | then aA |
---|
159 | | - | else ao |
---|
160 | | - | let aC = (aA - aB) |
---|
161 | | - | $Tuple2([IntegerEntry(N, aC), ScriptTransfer(au, aB, at), U(M(), T(), aB, K), ab(toString(au), aB, I, J, K, ak.transactionId)], aB) |
---|
162 | | - | } |
---|
163 | | - | } |
---|
164 | | - | |
---|
165 | | - | |
---|
166 | | - | @Callable(ak) |
---|
167 | | - | func constructor (t,aD,aE) = { |
---|
168 | | - | let aF = (t + aD) |
---|
169 | | - | if (isDefined(getString(L()))) |
---|
170 | | - | then throw("already initialized") |
---|
171 | | - | else if ((size(ak.payments) != 1)) |
---|
172 | | - | then throw("exactly 1 payment must be attached") |
---|
173 | | - | else if ((ak.callerPublicKey != base58'2Cbd8ozG7A1RyRNC3nNnZgHu7Ru4K3JCfpyPkhqr9zxq')) |
---|
174 | | - | then throw("not authorized") |
---|
175 | | - | else { |
---|
176 | | - | let aG = valueOrErrorMessage(addressFromString(aE), "Invalid beneficiarAddress passed") |
---|
177 | | - | let aH = value(ak.payments[0]) |
---|
178 | | - | let aI = value(aH.assetId) |
---|
179 | | - | let aJ = valueOrErrorMessage(assetInfo(aI), "fail to load ido asset info") |
---|
180 | | - | let aK = toBase58String(aI) |
---|
181 | | - | let aL = pow(10, 0, aJ.decimals, 0, 0, DOWN) |
---|
182 | | - | let aM = aH.amount |
---|
183 | | - | [StringEntry(L(), z(t, aD, aK, aL, toString(aG), aM)), StringEntry(M(), C("0", toString(aM), "0"))] |
---|
184 | | - | } |
---|
185 | | - | } |
---|
186 | | - | |
---|
187 | | - | |
---|
188 | | - | |
---|
189 | | - | @Callable(ak) |
---|
190 | | - | func claimAmount (ao) = an(ak, ao) |
---|
191 | | - | |
---|
192 | | - | |
---|
193 | | - | |
---|
194 | | - | @Callable(ak) |
---|
195 | | - | func claim () = an(ak, -1) |
---|
196 | | - | |
---|
197 | | - | |
---|
198 | | - | |
---|
199 | | - | @Callable(ak) |
---|
200 | | - | func withdrawReferralReward (aN) = { |
---|
201 | | - | let aO = value(getString(b)) |
---|
202 | | - | let aP = if ((toString(ak.caller) == aO)) |
---|
203 | | - | then true |
---|
204 | | - | else o("permission denied") |
---|
205 | | - | if ((aP == aP)) |
---|
206 | | - | then { |
---|
207 | | - | let aQ = fromBase58String(value(getString(c))) |
---|
208 | | - | $Tuple2([ScriptTransfer(ak.caller, aN, aQ), ab(aO, aN, 0, 0, 0, ak.transactionId)], unit) |
---|
209 | | - | } |
---|
210 | | - | else throw("Strict value is not equal to itself.") |
---|
211 | | - | } |
---|
212 | | - | |
---|
213 | | - | |
---|
214 | | - | |
---|
215 | | - | @Callable(ak) |
---|
216 | | - | func setManager (aR) = { |
---|
217 | | - | let aS = aj(ak) |
---|
218 | | - | if ((aS == aS)) |
---|
219 | | - | then { |
---|
220 | | - | let aT = fromBase58String(aR) |
---|
221 | | - | if ((aT == aT)) |
---|
222 | | - | then [StringEntry(e(), aR)] |
---|
223 | | - | else throw("Strict value is not equal to itself.") |
---|
224 | | - | } |
---|
225 | | - | else throw("Strict value is not equal to itself.") |
---|
226 | | - | } |
---|
227 | | - | |
---|
228 | | - | |
---|
229 | | - | |
---|
230 | | - | @Callable(ak) |
---|
231 | | - | func confirmManager () = { |
---|
232 | | - | let aU = ai() |
---|
233 | | - | let aV = if (isDefined(aU)) |
---|
234 | | - | then true |
---|
235 | | - | else o("no pending manager") |
---|
236 | | - | if ((aV == aV)) |
---|
237 | | - | then { |
---|
238 | | - | let aW = if ((ak.callerPublicKey == value(aU))) |
---|
239 | | - | then true |
---|
240 | | - | else o("you are not pending manager") |
---|
241 | | - | if ((aW == aW)) |
---|
242 | | - | then [StringEntry(d(), toBase58String(value(aU))), DeleteEntry(e())] |
---|
243 | | - | else throw("Strict value is not equal to itself.") |
---|
244 | | - | } |
---|
245 | | - | else throw("Strict value is not equal to itself.") |
---|
246 | | - | } |
---|
247 | | - | |
---|
248 | | - | |
---|
249 | | - | @Verifier(aX) |
---|
250 | | - | func aY () = { |
---|
251 | | - | let aZ = { |
---|
252 | | - | let ag = af() |
---|
253 | | - | if ($isInstanceOf(ag, "ByteVector")) |
---|
254 | | - | then { |
---|
255 | | - | let am = ag |
---|
256 | | - | am |
---|
257 | | - | } |
---|
258 | | - | else if ($isInstanceOf(ag, "Unit")) |
---|
259 | | - | then aX.senderPublicKey |
---|
260 | | - | else throw("Match error") |
---|
261 | | - | } |
---|
262 | | - | sigVerify(aX.bodyBytes, aX.proofs[0], aZ) |
---|
263 | | - | } |
---|
264 | | - | |
---|
| 1 | + | # no script |
---|