tx · Ci24eHvqsf7b9uU45enZdQmBjgtKnWPtQwUyDwMGCKgy

3PM2vvWZeVpKhriZNvSpcaPaFHXsjcS2D5M:  -0.01400000 Waves

2021.02.09 17:41 [2454537] smart account 3PM2vvWZeVpKhriZNvSpcaPaFHXsjcS2D5M > SELF 0.00000000 Waves

{ "type": 13, "id": "Ci24eHvqsf7b9uU45enZdQmBjgtKnWPtQwUyDwMGCKgy", "fee": 1400000, "feeAssetId": null, "timestamp": 1612881694749, "version": 1, "sender": "3PM2vvWZeVpKhriZNvSpcaPaFHXsjcS2D5M", "senderPublicKey": "b8kbZtEuJnQqparqDdHovx8g9yZYuLV3EBUbLdXRDkd", "proofs": [ "5NcziYeUy6qcNBFb169DtdxPxgqRo8JsDhjGQdsaQYqbTQVVKsFdUvLFJzZFHBq8CtG3aZv64vhUkYTmLRdvfBpu", "2Ah1n6LUMUdtrQKkTpQexg7iGhTpjmsT9nXtw4PnLaVsmqrZzznfeWoJ3jtSdc5WvVekyYzvd8U4DxXRLGTV1ThP", "QqJUGXZArzoC7gBc7pkDgogoDMrypqvz5ZJQhXXvtYzJtgnVqTBYhENsRY6bNQ8MrST857v8aFBPGTAUwuruKi2" ], "script": "base64:AwQAAAALYWRkcmVzc0Jvb2sJAQAAAAdBZGRyZXNzAAAAAQEAAAAaAVf6soDmjFd+junITXbw+v7pmTln1PV2N0kEAAAAE3doaXRlbGlzdEFkZHJlc3NLZXkCAAAAEHdoaXRlbGlzdEFkZHJlc3MEAAAAF2RBcHBXaGl0ZWxpc3RBZGRyZXNzS2V5AgAAABRkQXBwV2hpdGVsaXN0QWRkcmVzcwQAAAARbWF0Y2hlckFkZHJlc3NLZXkCAAAADm1hdGNoZXJBZGRyZXNzBAAAABFnYXRld2F5QWRkcmVzc0tleQIAAAAOZ2F0ZXdheUFkZHJlc3MEAAAAFmdhdGV3YXlDb250cm9sQXNzZXRLZXkCAAAAE2dhdGV3YXlDb250cm9sQXNzZXQEAAAACnZhbGlkU3RhdGUAAAA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AAIFAAAAByRtYXRjaDACAAAAD0J1cm5UcmFuc2FjdGlvbgcDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAE0V4Y2hhbmdlVHJhbnNhY3Rpb24HAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABdJbnZva2VTY3JpcHRUcmFuc2FjdGlvbgQAAAACdHgFAAAAByRtYXRjaDAEAAAACGlzU2lnbmVkCQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tleQQAAAAHcGF5bWVudAQAAAAHJG1hdGNoMQgFAAAAAnR4AAAAB3BheW1lbnQDCQAAAQAAAAIFAAAAByRtYXRjaDECAAAAD0F0dGFjaGVkUGF5bWVudAQAAAAHJG1hdGNoMgkABBoAAAACCQEAAAASZ2V0QWRkcmVzc0Zyb21Cb29rAAAAAQUAAAAXZEFwcFdoaXRlbGlzdEFkZHJlc3NLZXkJAAJYAAAAAQgJAAQkAAAAAQgFAAAAAnR4AAAABGRBcHAAAAAFYnl0ZXMDCQAAAQAAAAIFAAAAByRtYXRjaDICAAAAA0ludAYHBgMFAAAACGlzU2lnbmVkBQAAAAdwYXltZW50BwkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXmim7kh", "chainId": 87, "height": 2454537, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: HLfMJXV265wGo1xpH13uvygoaPoUqdVXs5RYzMFswDcg Next: none Diff:
OldNewDifferences
1-{-# STDLIB_VERSION 4 #-}
2-{-# SCRIPT_TYPE ACCOUNT #-}
3-{-# CONTENT_TYPE DAPP #-}
4-let paramPrefix = "param_"
5-
1+{-# STDLIB_VERSION 3 #-}
2+{-# CONTENT_TYPE EXPRESSION #-}
63 let addressBook = Address(base58'3PQnTVr1QV9NAyfJkco7ZittcXf53NjeJg8')
7-
84 let whitelistAddressKey = "whitelistAddress"
9-
105 let dAppWhitelistAddressKey = "dAppWhitelistAddress"
11-
12-let burnerAddressKey = "burnerAddress"
13-
14-func getStringParam (key) = match getString(this, (paramPrefix + key)) {
15- case a: String =>
16- a
17- case _ =>
18- throw("no string key")
19-}
20-
21-
22-func getIntParam (key) = match getInteger(this, (paramPrefix + key)) {
23- case a: Int =>
24- a
25- case _ =>
26- throw("no int key")
27-}
28-
29-
30-func getBooleanParam (key) = match getBoolean(this, (paramPrefix + key)) {
31- case a: Boolean =>
32- a
33- case _ =>
34- throw("no boolean key")
35-}
36-
37-
38-let issuerAssetId = base58'CJYmf3ScoMiVuL86NGg2zp8VYPwbwB3N21QPZBvzLA23'
39-
40-let investmentAssetId = base58'9SxLVHaEGTeEjRiAMnEw74YWWndQDRw8SZhknK9EYoUd'
41-
42-let investmentAssetIdIsWaves = false
43-
44-let ownerAddressString = getStringParam("issuerAccountAddress")
45-
46-let ownerAddress = Address(fromBase58String(ownerAddressString))
47-
48-let assetDecimalsOffset = 1
49-
50-let tokensaleAmount = getIntParam("tokensaleAmount")
51-
52-let startTime = getIntParam("startTime")
53-
54-let endTime = getIntParam("endTime")
55-
56-let price = getIntParam("price")
57-
58-let softCapAmount = getIntParam("softCapAmount")
59-
60-let minPayment = getIntParam("minPayment")
61-
62-let swapAssetId = base58'DhrMJdz5MVhWDaSNVmDvZ6eJ3ndtC3Xmz5iZrPKMjCqx'
63-
64-let swapAmount = getIntParam("swapAmount")
65-
66-let swapPrice = getIntParam("swapPrice")
67-
68-let serviceFee = getIntParam("serviceFee")
69-
70-let serviceFeeAddressString = getStringParam("serviceFeeAddress")
71-
72-let companyType = 2
73-
74-let isTokensale = 0
75-
76-let isSwap = 1
77-
78-let isTokensaleAndSwap = 2
79-
80-let swapKeySumAmountPrefix = "swapSumAmount "
81-
82-let swapKeySumAssetsPrefix = "swapSumAssets "
83-
84-let swapKeyDistAssets = "swapAssets"
85-
86-let swapKeyCollectedAmount = "swapAmount"
87-
88-let keySumAmountPrefix = "sumAmount "
89-
90-let keySumPaidAmountPrefix = "paidAmount "
91-
92-let keySumAssetsPrefix = "sumAssets "
93-
94-let keyAllowAccountPrefix = "allow "
95-
96-let keyDistAssets = "assets"
97-
98-let keyCollectedAmount = "amount"
99-
100-let keyIssuer = "issuer"
101-
102-let ver = "6.4.0-withreissue"
103-
6+let matcherAddressKey = "matcherAddress"
7+let gatewayAddressKey = "gatewayAddress"
8+let gatewayControlAssetKey = "gatewayControlAsset"
1049 let validState = 1000
105-
10+let ver = "5.0.2"
10611 func getAddressFromBook (key) = match getString(addressBook, key) {
10712 case a: String =>
10813 Address(fromBase58String(a))
10914 case _ =>
110- throw("no key")
15+ throw("#008 no key")
11116 }
11217
113-
114-let whitelistAddress = getAddressFromBook(whitelistAddressKey)
115-
116-let dAppWhitelistAddress = getAddressFromBook(dAppWhitelistAddressKey)
117-
118-let burnerAddress = getAddressFromBook(burnerAddressKey)
119-
120-func isTokensaleAllow () = if ((companyType == isTokensale))
121- then true
122- else (companyType == isTokensaleAndSwap)
123-
124-
125-func isSwapAllow () = if ((companyType == isSwap))
126- then true
127- else (companyType == isTokensaleAndSwap)
128-
129-
130-func isServiceFeeActive () = (serviceFee != 0)
131-
132-
133-func getCurrentTime () = {
134- let blockInfo = value(blockInfoByHeight(height))
135- (blockInfo.timestamp / 1000)
136- }
137-
138-
139-func getInvestmentAssetIdForTransfer (isWaves,assetId) = if ((isWaves == false))
140- then assetId
141- else unit
142-
143-
144-func getCurrentPrice () = price
145-
146-
147-func getAmount (key) = match getInteger(this, key) {
148- case a: Int =>
149- a
18+func getAssetFromAddressBook () = match getString(extract(addressBook), gatewayControlAssetKey) {
19+ case a: String =>
20+ toBytes(a)
15021 case _ =>
151- 0
22+ throw("#009 no key")
15223 }
15324
154-
155-func hasStarted () = (getCurrentTime() >= startTime)
156-
157-
158-func tokensaleHasEnded () = {
159- let assets = match getInteger(this, keyDistAssets) {
160- case a: Int =>
161- a
162- case _ =>
163- tokensaleAmount
164- }
165- if ((getCurrentTime() > endTime))
166- then true
167- else (assets == 0)
168- }
169-
170-
171-func swapHasEnded () = {
172- let assets = match getInteger(this, swapKeyDistAssets) {
173- case a: Int =>
174- a
175- case _ =>
176- swapAmount
177- }
178- if ((getCurrentTime() > endTime))
179- then true
180- else (assets == 0)
181- }
182-
183-
184-func companyHasEnded () = if (if (isSwapAllow())
185- then isTokensaleAllow()
186- else false)
187- then if (tokensaleHasEnded())
188- then swapHasEnded()
189- else false
190- else if (isTokensaleAllow())
191- then tokensaleHasEnded()
192- else if (isSwapAllow())
193- then swapHasEnded()
25+match tx {
26+ case o: Order =>
27+ if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey))
28+ then (addressFromPublicKey(o.matcherPublicKey) == getAddressFromBook(matcherAddressKey))
19429 else false
195-
196-
197-func getPayment (i) = if ((size(i.payments) == 0))
198- then throw("#0100 Payment must be attached")
199- else {
200- let p = i.payments[0]
201- let isPaymentOk = match p.assetId {
202- case assetId: ByteVector =>
203- if (!(investmentAssetIdIsWaves))
204- then (assetId == investmentAssetId)
205- else false
206- case _ =>
207- (investmentAssetIdIsWaves == true)
208- }
209- if (isPaymentOk)
210- then if ((assetDecimalsOffset == 1))
211- then if (((p.amount % price) == 0))
212- then p.amount
213- else throw("#0300 payment amount must be a multiple of token price")
214- else p.amount
215- else throw("#0200 Invalid asset ID of investment")
216- }
217-
218-
219-func getSwapPayment (i) = if ((size(i.payments) == 0))
220- then throw("#0100 Payment must be attached")
221- else {
222- let p = i.payments[0]
223- let isPaymentOk = match p.assetId {
224- case assetId: ByteVector =>
225- (assetId == swapAssetId)
226- case _ =>
227- false
228- }
229- if (isPaymentOk)
230- then if ((assetDecimalsOffset == 1))
231- then if (((p.amount % swapPrice) == 0))
232- then p.amount
233- else throw("payment amount must be a multiple of token price")
234- else p.amount
235- else throw("Invalid asset ID of investment")
236- }
237-
238-
239-func getInvestorAddressForWithdrawal (argAddress,callerAddress) = if ((size(argAddress) > 10))
240- then argAddress
241- else callerAddress
242-
243-
244-@Callable(i)
245-func deposit () = {
246- let currentPrice = getCurrentPrice()
247- let accountAmount = getAmount(keyCollectedAmount)
248- let dAppStatus = match getInteger(dAppWhitelistAddress, toString(this)) {
249- case a: Int =>
250- a
251- case _ =>
252- -1000
253- }
254- if (!(isTokensaleAllow()))
255- then throw("#1000 This deposit method is unsopperted for this company")
256- else if (!(hasStarted()))
257- then throw(((("#0001 The Tokensale works between " + toString(startTime)) + " and ") + toString(endTime)))
258- else if (tokensaleHasEnded())
259- then throw("#0002 The required amount has already been accumulated. If you are an investor, you can withdraw your funds.")
260- else if ((dAppStatus == -1000))
261- then throw("#0010 This company is unsopperted")
262- else {
263- let payment = getPayment(i)
264- let currentKey = toBase58String(i.caller.bytes)
265- let isAccountAllow = match getInteger(whitelistAddress, currentKey) {
266- case a: Int =>
267- a
268- case _ =>
269- -255
270- }
271- if ((currentKey == ownerAddressString))
272- then throw("#0030 The issuer can`t invest in its own company")
273- else if ((validState > isAccountAllow))
274- then throw(((("#0020 Your account has no right to send funds. _ " + currentKey) + " ") + ownerAddressString))
30+ case tx: TransferTransaction =>
31+ if (!(sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)))
32+ then throw("#001 Transaction must be signed by owner")
33+ else {
34+ let userState = getInteger(getAddressFromBook(whitelistAddressKey), toBase58String(tx.sender.bytes))
35+ if (!(isDefined(userState)))
36+ then throw("#002 Address not in whitelist")
37+ else if ((userState != validState))
38+ then throw("#003 User not in valid state")
39+ else if (!(isDefined(tx.assetId)))
40+ then {
41+ let key = (toBase58String(tx.sender.bytes) + "_WAVES")
42+ let minAmount = getInteger(getAddressFromBook(whitelistAddressKey), key)
43+ if (isDefined(minAmount))
44+ then {
45+ let curBalance = wavesBalance(extract(tx.sender))
46+ if ((extract(minAmount) > (curBalance - tx.amount)))
47+ then throw("#004 Unable to send such amount (type=2)")
48+ else true
49+ }
50+ else {
51+ let keyOverall = "res_WAVES"
52+ let minAmountOverall = getInteger(getAddressFromBook(whitelistAddressKey), keyOverall)
53+ if (isDefined(minAmountOverall))
54+ then {
55+ let curBalance = wavesBalance(extract(tx.sender))
56+ if ((extract(minAmountOverall) > (curBalance - tx.amount)))
57+ then throw("#005 Unable to send such amount (type=1)")
58+ else true
59+ }
60+ else true
61+ }
62+ }
63+ else if ((tx.assetId == getAssetFromAddressBook()))
64+ then (tx.recipient == getAddressFromBook(gatewayAddressKey))
27565 else {
276- let accountAssets = match getInteger(this, keyDistAssets) {
277- case a: Int =>
278- a
279- case _ =>
280- tokensaleAmount
281- }
282- let tokensCalc = fraction(payment, assetDecimalsOffset, currentPrice)
283- let minPaymentInAssets = fraction(minPayment, assetDecimalsOffset, currentPrice)
284- if (if (if ((0 > (accountAssets - tokensCalc)))
285- then true
286- else (minPaymentInAssets > tokensCalc))
287- then true
288- else if ((tokensCalc != accountAssets))
289- then (tokensCalc > (accountAssets - minPaymentInAssets))
290- else false)
291- then throw("#0400 Incorrect payment amount.")
66+ let white1List = toBase58String(tx.sender.bytes)
67+ let assetTxt = toBase58String(extract(tx.assetId))
68+ let white1ListAsset = ((white1List + "_") + assetTxt)
69+ let white1ListOverall = ("res_" + assetTxt)
70+ let white1ListAssetEntry = getInteger(getAddressFromBook(whitelistAddressKey), white1ListAsset)
71+ if (!(isDefined(white1ListAssetEntry)))
72+ then {
73+ let white1ListOverallEntry = getInteger(getAddressFromBook(whitelistAddressKey), white1ListOverall)
74+ if (!(isDefined(white1ListOverallEntry)))
75+ then true
76+ else {
77+ let cur1Balance = assetBalance(tx.sender, tx.assetId)
78+ if ((extract(white1ListOverallEntry) > (cur1Balance - tx.amount)))
79+ then throw("#006 Unable to send such amount (type=1)")
80+ else true
81+ }
82+ }
29283 else {
293- let newInvestorAmount = (getAmount((keySumAmountPrefix + currentKey)) + payment)
294- let newInvestorAssets = (getAmount((keySumAssetsPrefix + currentKey)) + tokensCalc)
295- let newAccountAssets = (accountAssets - tokensCalc)
296- let newAccountAmount = (accountAmount + payment)
297-[IntegerEntry((keySumAmountPrefix + currentKey), newInvestorAmount), IntegerEntry((keySumAssetsPrefix + currentKey), newInvestorAssets), IntegerEntry(keyDistAssets, newAccountAssets), IntegerEntry(keyCollectedAmount, newAccountAmount)]
84+ let cur1Balance = assetBalance(tx.sender, tx.assetId)
85+ if ((extract(white1ListAssetEntry) > (cur1Balance - tx.amount)))
86+ then throw("#007 Unable to send such amount (type=2)")
87+ else true
29888 }
29989 }
300- }
301- }
302-
303-
304-
305-@Callable(i)
306-func swapDeposit () = {
307- let currentPrice = swapPrice
308- let accountAmount = getAmount(swapKeyCollectedAmount)
309- let dAppStatus = match getInteger(dAppWhitelistAddress, toString(this)) {
310- case a: Int =>
311- a
312- case _ =>
313- -1000
314- }
315- if (!(isSwapAllow()))
316- then throw("#2000 This swap-deposit method is unsopperted for this company")
317- else if (!(hasStarted()))
318- then throw(((("The Tokensale works between " + toString(startTime)) + " and ") + toString(endTime)))
319- else if (swapHasEnded())
320- then throw("The required amount has already been accumulated. If you are an investor, you can withdraw your funds.")
321- else if ((dAppStatus == -1000))
322- then throw("#0010 This company is unsupported")
323- else {
324- let payment = getSwapPayment(i)
325- let currentKey = toBase58String(i.caller.bytes)
326- let isAccountAllow = match getInteger(whitelistAddress, currentKey) {
327- case a: Int =>
328- a
329- case _ =>
330- -255
331- }
332- if ((validState > isAccountAllow))
333- then throw("#0020 Your account has no right to send funds.")
334- else {
335- let accountAssets = match getInteger(this, swapKeyDistAssets) {
336- case a: Int =>
337- a
338- case _ =>
339- swapAmount
340- }
341- let tokensCalc = fraction(payment, assetDecimalsOffset, currentPrice)
342- if ((0 > (accountAssets - tokensCalc)))
343- then throw("Incorrect payment amount.")
344- else {
345- let newInvestorAmount = (getAmount((swapKeySumAmountPrefix + currentKey)) + payment)
346- let newInvestorAssets = (getAmount((swapKeySumAssetsPrefix + currentKey)) + tokensCalc)
347- let newAccountAssets = (accountAssets - tokensCalc)
348- let newAccountAmount = (accountAmount + payment)
349-[IntegerEntry((swapKeySumAmountPrefix + currentKey), newInvestorAmount), IntegerEntry((swapKeySumAssetsPrefix + currentKey), newInvestorAssets), IntegerEntry(swapKeyDistAssets, newAccountAssets), IntegerEntry(swapKeyCollectedAmount, newAccountAmount)]
350- }
351- }
352- }
353- }
354-
355-
356-
357-@Callable(i)
358-func withdrawal (address) = {
359- let dAppStatus = match getInteger(dAppWhitelistAddress, toString(this)) {
360- case a: Int =>
361- a
362- case _ =>
363- 0
364- }
365- if ((dAppStatus == 0))
366- then throw("#0030 Withdrawals are not available until the issuer passes verification")
367- else {
368- let currentKey = getInvestorAddressForWithdrawal(address, toBase58String(i.caller.bytes))
369- let currentKeyAddress = Address(fromBase58String(currentKey))
370- let currentInvestorAssets = getAmount((keySumAssetsPrefix + currentKey))
371- let currentInvestorAmount = getAmount((keySumAmountPrefix + currentKey))
372- let currentInvestorSwapAssets = getAmount((swapKeySumAssetsPrefix + currentKey))
373- let currentInvestorSwapAmount = getAmount((swapKeySumAmountPrefix + currentKey))
374- let accountSwapAmount = getAmount(swapKeyCollectedAmount)
375- let accountSwapAssets = getAmount(swapKeyDistAssets)
376- let accountAmount = getAmount(keyCollectedAmount)
377- let accountAssets = getAmount(keyDistAssets)
378- let investmentAssetIdForTransfer = getInvestmentAssetIdForTransfer(investmentAssetIdIsWaves, investmentAssetId)
379- if (!(companyHasEnded()))
380- then throw("#0003 The Company is still active")
381- else if (if ((currentKey == ownerAddressString))
382- then (dAppStatus == 1)
383- else false)
384- then {
385- let issuerAlreadyGotFunds = getAmount(keyIssuer)
386- if ((issuerAlreadyGotFunds == 0))
387- then if (if (isTokensaleAllow())
388- then isSwapAllow()
389- else false)
390- then if ((accountAmount >= softCapAmount))
391- then if (isServiceFeeActive())
392- then {
393- let serviceAmount = fraction(accountAmount, serviceFee, 100)
394- let issuerAmount = (accountAmount - serviceAmount)
395- let serviceFeeAddress = Address(fromBase58String(serviceFeeAddressString))
396-[IntegerEntry(keyIssuer, 1), ScriptTransfer(serviceFeeAddress, serviceAmount, investmentAssetIdForTransfer), ScriptTransfer(ownerAddress, issuerAmount, investmentAssetIdForTransfer), ScriptTransfer(ownerAddress, accountSwapAmount, swapAssetId)]
397- }
398- else [IntegerEntry(keyIssuer, 1), ScriptTransfer(ownerAddress, accountAmount, investmentAssetIdForTransfer), ScriptTransfer(ownerAddress, accountSwapAmount, swapAssetId)]
399- else [IntegerEntry(keyIssuer, 1), ScriptTransfer(ownerAddress, accountSwapAmount, swapAssetId)]
400- else if (isTokensaleAllow())
401- then if ((accountAmount >= softCapAmount))
402- then if (isServiceFeeActive())
403- then {
404- let serviceAmount = fraction(accountAmount, serviceFee, 100)
405- let issuerAmount = (accountAmount - serviceAmount)
406- let serviceFeeAddress = Address(fromBase58String(serviceFeeAddressString))
407-[IntegerEntry(keyIssuer, 1), ScriptTransfer(serviceFeeAddress, serviceAmount, investmentAssetIdForTransfer), ScriptTransfer(ownerAddress, issuerAmount, investmentAssetIdForTransfer)]
408- }
409- else [IntegerEntry(keyIssuer, 1), ScriptTransfer(ownerAddress, accountAmount, investmentAssetIdForTransfer)]
410- else throw("#0500 No funds for issuer")
411- else [IntegerEntry(keyIssuer, 1), ScriptTransfer(ownerAddress, accountSwapAmount, swapAssetId)]
412- else throw("#0700 The issuer has already taken its share!")
413- }
414- else if (if ((currentInvestorAmount == 0))
415- then (currentInvestorSwapAmount == 0)
416- else false)
417- then throw("#0600 Don't have money")
418- else if (if (isTokensaleAllow())
419- then isSwapAllow()
420- else false)
421- then if (if ((softCapAmount > accountAmount))
422- then (dAppStatus == 1)
423- else false)
424- then [IntegerEntry((keySumAmountPrefix + currentKey), 0), IntegerEntry((keySumAssetsPrefix + currentKey), 0), IntegerEntry((swapKeySumAmountPrefix + currentKey), 0), IntegerEntry((swapKeySumAssetsPrefix + currentKey), 0), ScriptTransfer(currentKeyAddress, currentInvestorAmount, investmentAssetIdForTransfer), ScriptTransfer(currentKeyAddress, currentInvestorSwapAssets, issuerAssetId)]
425- else if ((dAppStatus == 1))
426- then [IntegerEntry((keySumAmountPrefix + currentKey), 0), IntegerEntry((keySumAssetsPrefix + currentKey), 0), IntegerEntry((swapKeySumAmountPrefix + currentKey), 0), IntegerEntry((swapKeySumAssetsPrefix + currentKey), 0), ScriptTransfer(currentKeyAddress, currentInvestorAssets, issuerAssetId), ScriptTransfer(currentKeyAddress, currentInvestorSwapAssets, issuerAssetId)]
427- else [IntegerEntry((keySumAmountPrefix + currentKey), 0), IntegerEntry((keySumAssetsPrefix + currentKey), 0), IntegerEntry((swapKeySumAmountPrefix + currentKey), 0), IntegerEntry((swapKeySumAssetsPrefix + currentKey), 0), ScriptTransfer(currentKeyAddress, currentInvestorAmount, investmentAssetIdForTransfer), ScriptTransfer(currentKeyAddress, currentInvestorSwapAmount, swapAssetId)]
428- else if (isTokensaleAllow())
429- then if (if ((accountAmount >= softCapAmount))
430- then (dAppStatus == 1)
431- else false)
432- then [IntegerEntry((keySumAmountPrefix + currentKey), 0), IntegerEntry((keySumAssetsPrefix + currentKey), 0), ScriptTransfer(currentKeyAddress, currentInvestorAssets, issuerAssetId)]
433- else [IntegerEntry((keySumAmountPrefix + currentKey), 0), IntegerEntry((keySumAssetsPrefix + currentKey), 0), ScriptTransfer(currentKeyAddress, currentInvestorAmount, investmentAssetIdForTransfer)]
434- else if ((dAppStatus == 1))
435- then [IntegerEntry((swapKeySumAmountPrefix + currentKey), 0), IntegerEntry((swapKeySumAssetsPrefix + currentKey), 0), ScriptTransfer(currentKeyAddress, currentInvestorSwapAssets, issuerAssetId)]
436- else [IntegerEntry((swapKeySumAmountPrefix + currentKey), 0), IntegerEntry((swapKeySumAssetsPrefix + currentKey), 0), ScriptTransfer(currentKeyAddress, currentInvestorSwapAmount, swapAssetId)]
437- }
438- }
439-
440-
441-
442-@Callable(i)
443-func reissueSecurityForAddress (quantity,address) = {
444- let callerAddressString = toBase58String(i.caller.bytes)
445- if (if ((callerAddressString != ownerAddressString))
446- then (callerAddressString != toString(dAppWhitelistAddress))
447- else false)
448- then throw("#001 caller has no rights for this operation")
449- else {
450- let isAccountAllow = match getInteger(whitelistAddress, address) {
451- case a: Int =>
452- a
453- case _ =>
454- -255
455- }
456- let dAppStatus = match getInteger(dAppWhitelistAddress, address) {
457- case a: Int =>
458- a
459- case _ =>
460- -1000
461- }
462- if (if ((dAppStatus != -1000))
463- then true
464- else (isAccountAllow != -255))
465- then {
466- let currentKeyAddress = Address(fromBase58String(address))
467- let balanceAmount = assetBalance(this, issuerAssetId)
468- if ((balanceAmount >= quantity))
469- then [ScriptTransfer(currentKeyAddress, quantity, issuerAssetId)]
470- else [Reissue(issuerAssetId, (quantity - balanceAmount), true), ScriptTransfer(currentKeyAddress, quantity, issuerAssetId)]
471- }
472- else throw("#002 invalid recipient")
473- }
474- }
475-
476-
477-@Verifier(tx)
478-func verify () = match tx {
479- case tx: BurnTransaction =>
480- true
481- case tx: DataTransaction|SetAssetScriptTransaction|SetScriptTransaction =>
90+ }
91+ case tx: SetScriptTransaction =>
48292 let txId = toBase58String(tx.id)
48393 let pAddress1 = getAddressFromBook("pAddress1")
48494 let pAddress2 = getAddressFromBook("pAddress2")
513123 then 1
514124 else 0
515125 ((((((((pKey1Signed + pKey2Signed) + pKey3Signed) + pKey4Signed) + pKey5Signed) + pKey6Signed) + pKey7Signed) + pKey8Signed) >= 3)
126+ case _: LeaseTransaction =>
127+ false
128+ case _: SponsorFeeTransaction =>
129+ false
130+ case _: MassTransferTransaction =>
131+ false
132+ case _: IssueTransaction =>
133+ false
134+ case _: ReissueTransaction =>
135+ false
136+ case _: BurnTransaction =>
137+ false
138+ case _: ExchangeTransaction =>
139+ false
140+ case tx: InvokeScriptTransaction =>
141+ let isSigned = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
142+ let payment = match tx.payment {
143+ case _: AttachedPayment =>
144+ match getInteger(getAddressFromBook(dAppWhitelistAddressKey), toBase58String(addressFromRecipient(tx.dApp).bytes)) {
145+ case _: Int =>
146+ true
147+ case _ =>
148+ false
149+ }
150+ case _ =>
151+ true
152+ }
153+ if (isSigned)
154+ then payment
155+ else false
516156 case _ =>
517- false
157+ sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
518158 }
519-
Full:
OldNewDifferences
1-{-# STDLIB_VERSION 4 #-}
2-{-# SCRIPT_TYPE ACCOUNT #-}
3-{-# CONTENT_TYPE DAPP #-}
4-let paramPrefix = "param_"
5-
1+{-# STDLIB_VERSION 3 #-}
2+{-# CONTENT_TYPE EXPRESSION #-}
63 let addressBook = Address(base58'3PQnTVr1QV9NAyfJkco7ZittcXf53NjeJg8')
7-
84 let whitelistAddressKey = "whitelistAddress"
9-
105 let dAppWhitelistAddressKey = "dAppWhitelistAddress"
11-
12-let burnerAddressKey = "burnerAddress"
13-
14-func getStringParam (key) = match getString(this, (paramPrefix + key)) {
15- case a: String =>
16- a
17- case _ =>
18- throw("no string key")
19-}
20-
21-
22-func getIntParam (key) = match getInteger(this, (paramPrefix + key)) {
23- case a: Int =>
24- a
25- case _ =>
26- throw("no int key")
27-}
28-
29-
30-func getBooleanParam (key) = match getBoolean(this, (paramPrefix + key)) {
31- case a: Boolean =>
32- a
33- case _ =>
34- throw("no boolean key")
35-}
36-
37-
38-let issuerAssetId = base58'CJYmf3ScoMiVuL86NGg2zp8VYPwbwB3N21QPZBvzLA23'
39-
40-let investmentAssetId = base58'9SxLVHaEGTeEjRiAMnEw74YWWndQDRw8SZhknK9EYoUd'
41-
42-let investmentAssetIdIsWaves = false
43-
44-let ownerAddressString = getStringParam("issuerAccountAddress")
45-
46-let ownerAddress = Address(fromBase58String(ownerAddressString))
47-
48-let assetDecimalsOffset = 1
49-
50-let tokensaleAmount = getIntParam("tokensaleAmount")
51-
52-let startTime = getIntParam("startTime")
53-
54-let endTime = getIntParam("endTime")
55-
56-let price = getIntParam("price")
57-
58-let softCapAmount = getIntParam("softCapAmount")
59-
60-let minPayment = getIntParam("minPayment")
61-
62-let swapAssetId = base58'DhrMJdz5MVhWDaSNVmDvZ6eJ3ndtC3Xmz5iZrPKMjCqx'
63-
64-let swapAmount = getIntParam("swapAmount")
65-
66-let swapPrice = getIntParam("swapPrice")
67-
68-let serviceFee = getIntParam("serviceFee")
69-
70-let serviceFeeAddressString = getStringParam("serviceFeeAddress")
71-
72-let companyType = 2
73-
74-let isTokensale = 0
75-
76-let isSwap = 1
77-
78-let isTokensaleAndSwap = 2
79-
80-let swapKeySumAmountPrefix = "swapSumAmount "
81-
82-let swapKeySumAssetsPrefix = "swapSumAssets "
83-
84-let swapKeyDistAssets = "swapAssets"
85-
86-let swapKeyCollectedAmount = "swapAmount"
87-
88-let keySumAmountPrefix = "sumAmount "
89-
90-let keySumPaidAmountPrefix = "paidAmount "
91-
92-let keySumAssetsPrefix = "sumAssets "
93-
94-let keyAllowAccountPrefix = "allow "
95-
96-let keyDistAssets = "assets"
97-
98-let keyCollectedAmount = "amount"
99-
100-let keyIssuer = "issuer"
101-
102-let ver = "6.4.0-withreissue"
103-
6+let matcherAddressKey = "matcherAddress"
7+let gatewayAddressKey = "gatewayAddress"
8+let gatewayControlAssetKey = "gatewayControlAsset"
1049 let validState = 1000
105-
10+let ver = "5.0.2"
10611 func getAddressFromBook (key) = match getString(addressBook, key) {
10712 case a: String =>
10813 Address(fromBase58String(a))
10914 case _ =>
110- throw("no key")
15+ throw("#008 no key")
11116 }
11217
113-
114-let whitelistAddress = getAddressFromBook(whitelistAddressKey)
115-
116-let dAppWhitelistAddress = getAddressFromBook(dAppWhitelistAddressKey)
117-
118-let burnerAddress = getAddressFromBook(burnerAddressKey)
119-
120-func isTokensaleAllow () = if ((companyType == isTokensale))
121- then true
122- else (companyType == isTokensaleAndSwap)
123-
124-
125-func isSwapAllow () = if ((companyType == isSwap))
126- then true
127- else (companyType == isTokensaleAndSwap)
128-
129-
130-func isServiceFeeActive () = (serviceFee != 0)
131-
132-
133-func getCurrentTime () = {
134- let blockInfo = value(blockInfoByHeight(height))
135- (blockInfo.timestamp / 1000)
136- }
137-
138-
139-func getInvestmentAssetIdForTransfer (isWaves,assetId) = if ((isWaves == false))
140- then assetId
141- else unit
142-
143-
144-func getCurrentPrice () = price
145-
146-
147-func getAmount (key) = match getInteger(this, key) {
148- case a: Int =>
149- a
18+func getAssetFromAddressBook () = match getString(extract(addressBook), gatewayControlAssetKey) {
19+ case a: String =>
20+ toBytes(a)
15021 case _ =>
151- 0
22+ throw("#009 no key")
15223 }
15324
154-
155-func hasStarted () = (getCurrentTime() >= startTime)
156-
157-
158-func tokensaleHasEnded () = {
159- let assets = match getInteger(this, keyDistAssets) {
160- case a: Int =>
161- a
162- case _ =>
163- tokensaleAmount
164- }
165- if ((getCurrentTime() > endTime))
166- then true
167- else (assets == 0)
168- }
169-
170-
171-func swapHasEnded () = {
172- let assets = match getInteger(this, swapKeyDistAssets) {
173- case a: Int =>
174- a
175- case _ =>
176- swapAmount
177- }
178- if ((getCurrentTime() > endTime))
179- then true
180- else (assets == 0)
181- }
182-
183-
184-func companyHasEnded () = if (if (isSwapAllow())
185- then isTokensaleAllow()
186- else false)
187- then if (tokensaleHasEnded())
188- then swapHasEnded()
189- else false
190- else if (isTokensaleAllow())
191- then tokensaleHasEnded()
192- else if (isSwapAllow())
193- then swapHasEnded()
25+match tx {
26+ case o: Order =>
27+ if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey))
28+ then (addressFromPublicKey(o.matcherPublicKey) == getAddressFromBook(matcherAddressKey))
19429 else false
195-
196-
197-func getPayment (i) = if ((size(i.payments) == 0))
198- then throw("#0100 Payment must be attached")
199- else {
200- let p = i.payments[0]
201- let isPaymentOk = match p.assetId {
202- case assetId: ByteVector =>
203- if (!(investmentAssetIdIsWaves))
204- then (assetId == investmentAssetId)
205- else false
206- case _ =>
207- (investmentAssetIdIsWaves == true)
208- }
209- if (isPaymentOk)
210- then if ((assetDecimalsOffset == 1))
211- then if (((p.amount % price) == 0))
212- then p.amount
213- else throw("#0300 payment amount must be a multiple of token price")
214- else p.amount
215- else throw("#0200 Invalid asset ID of investment")
216- }
217-
218-
219-func getSwapPayment (i) = if ((size(i.payments) == 0))
220- then throw("#0100 Payment must be attached")
221- else {
222- let p = i.payments[0]
223- let isPaymentOk = match p.assetId {
224- case assetId: ByteVector =>
225- (assetId == swapAssetId)
226- case _ =>
227- false
228- }
229- if (isPaymentOk)
230- then if ((assetDecimalsOffset == 1))
231- then if (((p.amount % swapPrice) == 0))
232- then p.amount
233- else throw("payment amount must be a multiple of token price")
234- else p.amount
235- else throw("Invalid asset ID of investment")
236- }
237-
238-
239-func getInvestorAddressForWithdrawal (argAddress,callerAddress) = if ((size(argAddress) > 10))
240- then argAddress
241- else callerAddress
242-
243-
244-@Callable(i)
245-func deposit () = {
246- let currentPrice = getCurrentPrice()
247- let accountAmount = getAmount(keyCollectedAmount)
248- let dAppStatus = match getInteger(dAppWhitelistAddress, toString(this)) {
249- case a: Int =>
250- a
251- case _ =>
252- -1000
253- }
254- if (!(isTokensaleAllow()))
255- then throw("#1000 This deposit method is unsopperted for this company")
256- else if (!(hasStarted()))
257- then throw(((("#0001 The Tokensale works between " + toString(startTime)) + " and ") + toString(endTime)))
258- else if (tokensaleHasEnded())
259- then throw("#0002 The required amount has already been accumulated. If you are an investor, you can withdraw your funds.")
260- else if ((dAppStatus == -1000))
261- then throw("#0010 This company is unsopperted")
262- else {
263- let payment = getPayment(i)
264- let currentKey = toBase58String(i.caller.bytes)
265- let isAccountAllow = match getInteger(whitelistAddress, currentKey) {
266- case a: Int =>
267- a
268- case _ =>
269- -255
270- }
271- if ((currentKey == ownerAddressString))
272- then throw("#0030 The issuer can`t invest in its own company")
273- else if ((validState > isAccountAllow))
274- then throw(((("#0020 Your account has no right to send funds. _ " + currentKey) + " ") + ownerAddressString))
30+ case tx: TransferTransaction =>
31+ if (!(sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)))
32+ then throw("#001 Transaction must be signed by owner")
33+ else {
34+ let userState = getInteger(getAddressFromBook(whitelistAddressKey), toBase58String(tx.sender.bytes))
35+ if (!(isDefined(userState)))
36+ then throw("#002 Address not in whitelist")
37+ else if ((userState != validState))
38+ then throw("#003 User not in valid state")
39+ else if (!(isDefined(tx.assetId)))
40+ then {
41+ let key = (toBase58String(tx.sender.bytes) + "_WAVES")
42+ let minAmount = getInteger(getAddressFromBook(whitelistAddressKey), key)
43+ if (isDefined(minAmount))
44+ then {
45+ let curBalance = wavesBalance(extract(tx.sender))
46+ if ((extract(minAmount) > (curBalance - tx.amount)))
47+ then throw("#004 Unable to send such amount (type=2)")
48+ else true
49+ }
50+ else {
51+ let keyOverall = "res_WAVES"
52+ let minAmountOverall = getInteger(getAddressFromBook(whitelistAddressKey), keyOverall)
53+ if (isDefined(minAmountOverall))
54+ then {
55+ let curBalance = wavesBalance(extract(tx.sender))
56+ if ((extract(minAmountOverall) > (curBalance - tx.amount)))
57+ then throw("#005 Unable to send such amount (type=1)")
58+ else true
59+ }
60+ else true
61+ }
62+ }
63+ else if ((tx.assetId == getAssetFromAddressBook()))
64+ then (tx.recipient == getAddressFromBook(gatewayAddressKey))
27565 else {
276- let accountAssets = match getInteger(this, keyDistAssets) {
277- case a: Int =>
278- a
279- case _ =>
280- tokensaleAmount
281- }
282- let tokensCalc = fraction(payment, assetDecimalsOffset, currentPrice)
283- let minPaymentInAssets = fraction(minPayment, assetDecimalsOffset, currentPrice)
284- if (if (if ((0 > (accountAssets - tokensCalc)))
285- then true
286- else (minPaymentInAssets > tokensCalc))
287- then true
288- else if ((tokensCalc != accountAssets))
289- then (tokensCalc > (accountAssets - minPaymentInAssets))
290- else false)
291- then throw("#0400 Incorrect payment amount.")
66+ let white1List = toBase58String(tx.sender.bytes)
67+ let assetTxt = toBase58String(extract(tx.assetId))
68+ let white1ListAsset = ((white1List + "_") + assetTxt)
69+ let white1ListOverall = ("res_" + assetTxt)
70+ let white1ListAssetEntry = getInteger(getAddressFromBook(whitelistAddressKey), white1ListAsset)
71+ if (!(isDefined(white1ListAssetEntry)))
72+ then {
73+ let white1ListOverallEntry = getInteger(getAddressFromBook(whitelistAddressKey), white1ListOverall)
74+ if (!(isDefined(white1ListOverallEntry)))
75+ then true
76+ else {
77+ let cur1Balance = assetBalance(tx.sender, tx.assetId)
78+ if ((extract(white1ListOverallEntry) > (cur1Balance - tx.amount)))
79+ then throw("#006 Unable to send such amount (type=1)")
80+ else true
81+ }
82+ }
29283 else {
293- let newInvestorAmount = (getAmount((keySumAmountPrefix + currentKey)) + payment)
294- let newInvestorAssets = (getAmount((keySumAssetsPrefix + currentKey)) + tokensCalc)
295- let newAccountAssets = (accountAssets - tokensCalc)
296- let newAccountAmount = (accountAmount + payment)
297-[IntegerEntry((keySumAmountPrefix + currentKey), newInvestorAmount), IntegerEntry((keySumAssetsPrefix + currentKey), newInvestorAssets), IntegerEntry(keyDistAssets, newAccountAssets), IntegerEntry(keyCollectedAmount, newAccountAmount)]
84+ let cur1Balance = assetBalance(tx.sender, tx.assetId)
85+ if ((extract(white1ListAssetEntry) > (cur1Balance - tx.amount)))
86+ then throw("#007 Unable to send such amount (type=2)")
87+ else true
29888 }
29989 }
300- }
301- }
302-
303-
304-
305-@Callable(i)
306-func swapDeposit () = {
307- let currentPrice = swapPrice
308- let accountAmount = getAmount(swapKeyCollectedAmount)
309- let dAppStatus = match getInteger(dAppWhitelistAddress, toString(this)) {
310- case a: Int =>
311- a
312- case _ =>
313- -1000
314- }
315- if (!(isSwapAllow()))
316- then throw("#2000 This swap-deposit method is unsopperted for this company")
317- else if (!(hasStarted()))
318- then throw(((("The Tokensale works between " + toString(startTime)) + " and ") + toString(endTime)))
319- else if (swapHasEnded())
320- then throw("The required amount has already been accumulated. If you are an investor, you can withdraw your funds.")
321- else if ((dAppStatus == -1000))
322- then throw("#0010 This company is unsupported")
323- else {
324- let payment = getSwapPayment(i)
325- let currentKey = toBase58String(i.caller.bytes)
326- let isAccountAllow = match getInteger(whitelistAddress, currentKey) {
327- case a: Int =>
328- a
329- case _ =>
330- -255
331- }
332- if ((validState > isAccountAllow))
333- then throw("#0020 Your account has no right to send funds.")
334- else {
335- let accountAssets = match getInteger(this, swapKeyDistAssets) {
336- case a: Int =>
337- a
338- case _ =>
339- swapAmount
340- }
341- let tokensCalc = fraction(payment, assetDecimalsOffset, currentPrice)
342- if ((0 > (accountAssets - tokensCalc)))
343- then throw("Incorrect payment amount.")
344- else {
345- let newInvestorAmount = (getAmount((swapKeySumAmountPrefix + currentKey)) + payment)
346- let newInvestorAssets = (getAmount((swapKeySumAssetsPrefix + currentKey)) + tokensCalc)
347- let newAccountAssets = (accountAssets - tokensCalc)
348- let newAccountAmount = (accountAmount + payment)
349-[IntegerEntry((swapKeySumAmountPrefix + currentKey), newInvestorAmount), IntegerEntry((swapKeySumAssetsPrefix + currentKey), newInvestorAssets), IntegerEntry(swapKeyDistAssets, newAccountAssets), IntegerEntry(swapKeyCollectedAmount, newAccountAmount)]
350- }
351- }
352- }
353- }
354-
355-
356-
357-@Callable(i)
358-func withdrawal (address) = {
359- let dAppStatus = match getInteger(dAppWhitelistAddress, toString(this)) {
360- case a: Int =>
361- a
362- case _ =>
363- 0
364- }
365- if ((dAppStatus == 0))
366- then throw("#0030 Withdrawals are not available until the issuer passes verification")
367- else {
368- let currentKey = getInvestorAddressForWithdrawal(address, toBase58String(i.caller.bytes))
369- let currentKeyAddress = Address(fromBase58String(currentKey))
370- let currentInvestorAssets = getAmount((keySumAssetsPrefix + currentKey))
371- let currentInvestorAmount = getAmount((keySumAmountPrefix + currentKey))
372- let currentInvestorSwapAssets = getAmount((swapKeySumAssetsPrefix + currentKey))
373- let currentInvestorSwapAmount = getAmount((swapKeySumAmountPrefix + currentKey))
374- let accountSwapAmount = getAmount(swapKeyCollectedAmount)
375- let accountSwapAssets = getAmount(swapKeyDistAssets)
376- let accountAmount = getAmount(keyCollectedAmount)
377- let accountAssets = getAmount(keyDistAssets)
378- let investmentAssetIdForTransfer = getInvestmentAssetIdForTransfer(investmentAssetIdIsWaves, investmentAssetId)
379- if (!(companyHasEnded()))
380- then throw("#0003 The Company is still active")
381- else if (if ((currentKey == ownerAddressString))
382- then (dAppStatus == 1)
383- else false)
384- then {
385- let issuerAlreadyGotFunds = getAmount(keyIssuer)
386- if ((issuerAlreadyGotFunds == 0))
387- then if (if (isTokensaleAllow())
388- then isSwapAllow()
389- else false)
390- then if ((accountAmount >= softCapAmount))
391- then if (isServiceFeeActive())
392- then {
393- let serviceAmount = fraction(accountAmount, serviceFee, 100)
394- let issuerAmount = (accountAmount - serviceAmount)
395- let serviceFeeAddress = Address(fromBase58String(serviceFeeAddressString))
396-[IntegerEntry(keyIssuer, 1), ScriptTransfer(serviceFeeAddress, serviceAmount, investmentAssetIdForTransfer), ScriptTransfer(ownerAddress, issuerAmount, investmentAssetIdForTransfer), ScriptTransfer(ownerAddress, accountSwapAmount, swapAssetId)]
397- }
398- else [IntegerEntry(keyIssuer, 1), ScriptTransfer(ownerAddress, accountAmount, investmentAssetIdForTransfer), ScriptTransfer(ownerAddress, accountSwapAmount, swapAssetId)]
399- else [IntegerEntry(keyIssuer, 1), ScriptTransfer(ownerAddress, accountSwapAmount, swapAssetId)]
400- else if (isTokensaleAllow())
401- then if ((accountAmount >= softCapAmount))
402- then if (isServiceFeeActive())
403- then {
404- let serviceAmount = fraction(accountAmount, serviceFee, 100)
405- let issuerAmount = (accountAmount - serviceAmount)
406- let serviceFeeAddress = Address(fromBase58String(serviceFeeAddressString))
407-[IntegerEntry(keyIssuer, 1), ScriptTransfer(serviceFeeAddress, serviceAmount, investmentAssetIdForTransfer), ScriptTransfer(ownerAddress, issuerAmount, investmentAssetIdForTransfer)]
408- }
409- else [IntegerEntry(keyIssuer, 1), ScriptTransfer(ownerAddress, accountAmount, investmentAssetIdForTransfer)]
410- else throw("#0500 No funds for issuer")
411- else [IntegerEntry(keyIssuer, 1), ScriptTransfer(ownerAddress, accountSwapAmount, swapAssetId)]
412- else throw("#0700 The issuer has already taken its share!")
413- }
414- else if (if ((currentInvestorAmount == 0))
415- then (currentInvestorSwapAmount == 0)
416- else false)
417- then throw("#0600 Don't have money")
418- else if (if (isTokensaleAllow())
419- then isSwapAllow()
420- else false)
421- then if (if ((softCapAmount > accountAmount))
422- then (dAppStatus == 1)
423- else false)
424- then [IntegerEntry((keySumAmountPrefix + currentKey), 0), IntegerEntry((keySumAssetsPrefix + currentKey), 0), IntegerEntry((swapKeySumAmountPrefix + currentKey), 0), IntegerEntry((swapKeySumAssetsPrefix + currentKey), 0), ScriptTransfer(currentKeyAddress, currentInvestorAmount, investmentAssetIdForTransfer), ScriptTransfer(currentKeyAddress, currentInvestorSwapAssets, issuerAssetId)]
425- else if ((dAppStatus == 1))
426- then [IntegerEntry((keySumAmountPrefix + currentKey), 0), IntegerEntry((keySumAssetsPrefix + currentKey), 0), IntegerEntry((swapKeySumAmountPrefix + currentKey), 0), IntegerEntry((swapKeySumAssetsPrefix + currentKey), 0), ScriptTransfer(currentKeyAddress, currentInvestorAssets, issuerAssetId), ScriptTransfer(currentKeyAddress, currentInvestorSwapAssets, issuerAssetId)]
427- else [IntegerEntry((keySumAmountPrefix + currentKey), 0), IntegerEntry((keySumAssetsPrefix + currentKey), 0), IntegerEntry((swapKeySumAmountPrefix + currentKey), 0), IntegerEntry((swapKeySumAssetsPrefix + currentKey), 0), ScriptTransfer(currentKeyAddress, currentInvestorAmount, investmentAssetIdForTransfer), ScriptTransfer(currentKeyAddress, currentInvestorSwapAmount, swapAssetId)]
428- else if (isTokensaleAllow())
429- then if (if ((accountAmount >= softCapAmount))
430- then (dAppStatus == 1)
431- else false)
432- then [IntegerEntry((keySumAmountPrefix + currentKey), 0), IntegerEntry((keySumAssetsPrefix + currentKey), 0), ScriptTransfer(currentKeyAddress, currentInvestorAssets, issuerAssetId)]
433- else [IntegerEntry((keySumAmountPrefix + currentKey), 0), IntegerEntry((keySumAssetsPrefix + currentKey), 0), ScriptTransfer(currentKeyAddress, currentInvestorAmount, investmentAssetIdForTransfer)]
434- else if ((dAppStatus == 1))
435- then [IntegerEntry((swapKeySumAmountPrefix + currentKey), 0), IntegerEntry((swapKeySumAssetsPrefix + currentKey), 0), ScriptTransfer(currentKeyAddress, currentInvestorSwapAssets, issuerAssetId)]
436- else [IntegerEntry((swapKeySumAmountPrefix + currentKey), 0), IntegerEntry((swapKeySumAssetsPrefix + currentKey), 0), ScriptTransfer(currentKeyAddress, currentInvestorSwapAmount, swapAssetId)]
437- }
438- }
439-
440-
441-
442-@Callable(i)
443-func reissueSecurityForAddress (quantity,address) = {
444- let callerAddressString = toBase58String(i.caller.bytes)
445- if (if ((callerAddressString != ownerAddressString))
446- then (callerAddressString != toString(dAppWhitelistAddress))
447- else false)
448- then throw("#001 caller has no rights for this operation")
449- else {
450- let isAccountAllow = match getInteger(whitelistAddress, address) {
451- case a: Int =>
452- a
453- case _ =>
454- -255
455- }
456- let dAppStatus = match getInteger(dAppWhitelistAddress, address) {
457- case a: Int =>
458- a
459- case _ =>
460- -1000
461- }
462- if (if ((dAppStatus != -1000))
463- then true
464- else (isAccountAllow != -255))
465- then {
466- let currentKeyAddress = Address(fromBase58String(address))
467- let balanceAmount = assetBalance(this, issuerAssetId)
468- if ((balanceAmount >= quantity))
469- then [ScriptTransfer(currentKeyAddress, quantity, issuerAssetId)]
470- else [Reissue(issuerAssetId, (quantity - balanceAmount), true), ScriptTransfer(currentKeyAddress, quantity, issuerAssetId)]
471- }
472- else throw("#002 invalid recipient")
473- }
474- }
475-
476-
477-@Verifier(tx)
478-func verify () = match tx {
479- case tx: BurnTransaction =>
480- true
481- case tx: DataTransaction|SetAssetScriptTransaction|SetScriptTransaction =>
90+ }
91+ case tx: SetScriptTransaction =>
48292 let txId = toBase58String(tx.id)
48393 let pAddress1 = getAddressFromBook("pAddress1")
48494 let pAddress2 = getAddressFromBook("pAddress2")
48595 let pAddress3 = getAddressFromBook("pAddress3")
48696 let pAddress4 = getAddressFromBook("pAddress4")
48797 let pAddress5 = getAddressFromBook("pAddress5")
48898 let pAddress6 = getAddressFromBook("pAddress6")
48999 let pAddress7 = getAddressFromBook("pAddress7")
490100 let pAddress8 = getAddressFromBook("pAddress8")
491101 let pKey1Signed = if (isDefined(getInteger(pAddress1, txId)))
492102 then 1
493103 else 0
494104 let pKey2Signed = if (isDefined(getInteger(pAddress2, txId)))
495105 then 1
496106 else 0
497107 let pKey3Signed = if (isDefined(getInteger(pAddress3, txId)))
498108 then 1
499109 else 0
500110 let pKey4Signed = if (isDefined(getInteger(pAddress4, txId)))
501111 then 1
502112 else 0
503113 let pKey5Signed = if (isDefined(getInteger(pAddress5, txId)))
504114 then 1
505115 else 0
506116 let pKey6Signed = if (isDefined(getInteger(pAddress6, txId)))
507117 then 1
508118 else 0
509119 let pKey7Signed = if (isDefined(getInteger(pAddress7, txId)))
510120 then 1
511121 else 0
512122 let pKey8Signed = if (isDefined(getInteger(pAddress8, txId)))
513123 then 1
514124 else 0
515125 ((((((((pKey1Signed + pKey2Signed) + pKey3Signed) + pKey4Signed) + pKey5Signed) + pKey6Signed) + pKey7Signed) + pKey8Signed) >= 3)
126+ case _: LeaseTransaction =>
127+ false
128+ case _: SponsorFeeTransaction =>
129+ false
130+ case _: MassTransferTransaction =>
131+ false
132+ case _: IssueTransaction =>
133+ false
134+ case _: ReissueTransaction =>
135+ false
136+ case _: BurnTransaction =>
137+ false
138+ case _: ExchangeTransaction =>
139+ false
140+ case tx: InvokeScriptTransaction =>
141+ let isSigned = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
142+ let payment = match tx.payment {
143+ case _: AttachedPayment =>
144+ match getInteger(getAddressFromBook(dAppWhitelistAddressKey), toBase58String(addressFromRecipient(tx.dApp).bytes)) {
145+ case _: Int =>
146+ true
147+ case _ =>
148+ false
149+ }
150+ case _ =>
151+ true
152+ }
153+ if (isSigned)
154+ then payment
155+ else false
516156 case _ =>
517- false
157+ sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
518158 }
519-

github/deemru/w8io/3ef1775 
83.08 ms