tx · 6CiJjNEkVb8e1VD9MCuAmNnaCuQW3rpN3p4YoXxSpFwi 3Mz29fiz3zgY9JDbiHKANvHsFgQutdfu4Ua: -0.01400000 Waves 2021.03.19 17:08 [1444722] smart account 3Mz29fiz3zgY9JDbiHKANvHsFgQutdfu4Ua > SELF 0.00000000 Waves
{ "type": 13, "id": "6CiJjNEkVb8e1VD9MCuAmNnaCuQW3rpN3p4YoXxSpFwi", "fee": 1400000, "feeAssetId": null, "timestamp": 1616162940438, "version": 2, "chainId": 84, "sender": "3Mz29fiz3zgY9JDbiHKANvHsFgQutdfu4Ua", "senderPublicKey": "CTyHhnVTxf16Z4CmGGneAK8WB5g2QyT4MB8kUn8vPPcu", "proofs": [ "udHT8in2rnJLY3XtcBRzqoutvjjJitfEMqN54hNMuSpWDSvBDiCHG4LV9vgP6G3TtgnvQnRdwKi6VfitfCjTRCS" ], "script": "base64:AAIEAAAAAAAAAAQIAhIAAAAAAAAAAAEAAAABaQEAAAAEY2FsbAAAAAAEAAAABWFzc2V0CQAEQwAAAAcCAAAABUFzc2V0AgAAAAAAAAAAAAAAAAEAAAAAAAAAAAAGBQAAAAR1bml0AAAAAAAAAAAABAAAAAdhc3NldElkCQAEOAAAAAEFAAAABWFzc2V0CQAETAAAAAIJAQAAAAtCaW5hcnlFbnRyeQAAAAICAAAAA2JpbgEAAAAACQAETAAAAAIJAQAAAAxCb29sZWFuRW50cnkAAAACAgAAAARib29sBgkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgIAAAADaW50AAAAAAAAAAABCQAETAAAAAIJAQAAAAtTdHJpbmdFbnRyeQAAAAICAAAAA3N0cgIAAAAACQAETAAAAAIJAQAAAAtEZWxldGVFbnRyeQAAAAECAAAAA3N0cgkABEwAAAACBQAAAAVhc3NldAkABEwAAAACCQEAAAAHUmVpc3N1ZQAAAAMFAAAAB2Fzc2V0SWQAAAAAAAAAAAEHCQAETAAAAAIJAQAAAARCdXJuAAAAAgUAAAAHYXNzZXRJZAAAAAAAAAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIAAAAAAAAAAAEFAAAAB2Fzc2V0SWQFAAAAA25pbAAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5KOU8bg==", "height": 1444722, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: EUufYq4Z6LiepzM6iCUpjhpinnk2LPoLa9HACoMNLhHK Next: 361J2E2Exey8agc4m3ABoc6iJtTeCykeYwFCVDLgUT4a Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let separator = "___" | |
5 | - | ||
6 | - | let hardcoredMaximumDepositFee = 100 | |
7 | - | ||
8 | - | let hardcoredDappName = "FOKOFF" | |
9 | - | ||
10 | - | let hardcoredAssetIdForWaves = "WAVES" | |
11 | - | ||
12 | - | let keyAssetToStake = (hardcoredDappName + "_AssetToStake_") | |
13 | - | ||
14 | - | let keyAssetsToStakeList = (hardcoredDappName + "_AssetsToStakeList") | |
15 | - | ||
16 | - | let keyDefaultDepositFee = (hardcoredDappName + "_DefaultDepositFee") | |
17 | - | ||
18 | - | let keySuffixIsEnabled = "_isEnabled" | |
19 | - | ||
20 | - | let keySuffixMinAmount = "_minimumAmount" | |
21 | - | ||
22 | - | let keySuffixAfterHeight = "_allowStakingAfterBlockHeight" | |
23 | - | ||
24 | - | let keySuffixBlockDelay = "_BlocksDelayAfterDepositToStake" | |
25 | - | ||
26 | - | let keySuffixEnableSpecFee = "_enableSpecificDepositFee" | |
27 | - | ||
28 | - | let keySuffixSpecFee = "_specificDepositFee" | |
29 | - | ||
30 | - | let keyTreasury = (hardcoredDappName + "_Treasury_") | |
31 | - | ||
32 | - | let keySettingsAddress = (hardcoredDappName + "_SettingsAddress") | |
33 | - | ||
34 | - | let keyNonce = (hardcoredDappName + "_Nonce") | |
35 | - | ||
36 | - | let keyStakingAmount = (hardcoredDappName + "_StakingAmount_") | |
37 | - | ||
38 | - | let keyIssuedStakingContract = (hardcoredDappName + "_IssuedSContract_") | |
39 | - | ||
40 | - | let keyBurnedStakingContract = (hardcoredDappName + "_BurnedSContract_") | |
41 | - | ||
42 | - | let keyATSContractName = (hardcoredDappName + "Contract1") | |
43 | - | ||
44 | - | func getSettingsAddress () = Address(fromBase58String(getStringValue(this, keySettingsAddress))) | |
45 | - | ||
46 | - | ||
47 | - | func isSelf (caller) = if ((this == caller)) | |
48 | - | then true | |
49 | - | else (caller == getSettingsAddress()) | |
50 | - | ||
51 | - | ||
52 | - | func calcDepositFee (depositedAmount,feePerc) = { | |
53 | - | let fee = ((depositedAmount * feePerc) / 10000) | |
54 | - | if ((1 > fee)) | |
55 | - | then 1 | |
56 | - | else fee | |
57 | - | } | |
58 | - | ||
59 | - | ||
60 | - | func getAssetDepositFeePerc (assetIdStr) = { | |
61 | - | let settingsAddress = getSettingsAddress() | |
62 | - | let keyOrigin = (keyAssetToStake + assetIdStr) | |
63 | - | let isSpecificFeeEnabled = getBooleanValue(settingsAddress, (keyOrigin + keySuffixEnableSpecFee)) | |
64 | - | if ((isSpecificFeeEnabled == true)) | |
65 | - | then { | |
66 | - | let specificFee = getIntegerValue(settingsAddress, (keyOrigin + keySuffixSpecFee)) | |
67 | - | if ((specificFee > hardcoredMaximumDepositFee)) | |
68 | - | then hardcoredMaximumDepositFee | |
69 | - | else if ((0 > specificFee)) | |
70 | - | then 0 | |
71 | - | else specificFee | |
72 | - | } | |
73 | - | else { | |
74 | - | let defaultDepositFee = getIntegerValue(settingsAddress, keyDefaultDepositFee) | |
75 | - | if ((defaultDepositFee > hardcoredMaximumDepositFee)) | |
76 | - | then hardcoredMaximumDepositFee | |
77 | - | else if ((0 > defaultDepositFee)) | |
78 | - | then 0 | |
79 | - | else defaultDepositFee | |
80 | - | } | |
81 | - | } | |
82 | - | ||
83 | - | ||
84 | - | func getIntegerOrZero (keyName) = match getInteger(this, keyName) { | |
85 | - | case isInt: Int => | |
86 | - | isInt | |
87 | - | case _ => | |
88 | - | 0 | |
89 | - | } | |
90 | - | ||
91 | - | ||
92 | - | func getNewNonce () = { | |
93 | - | let incrNonce = (getIntegerOrZero(keyNonce) + 1) | |
94 | - | [parseIntValue((toString(incrNonce) + toString(height))), incrNonce] | |
95 | - | } | |
96 | 4 | ||
97 | 5 | ||
98 | 6 | @Callable(i) | |
99 | - | func init () = [DeleteEntry("Treasury-WAVES"), DeleteEntry("dApp_LockableAsset_Go6FQZHeZzqeAn7wrcywA6ZwsVFGWYBKx7jgnoCMJJtY"), DeleteEntry("dApp_LockableAssets"), DeleteEntry("dApp_LockableAssetsList"), DeleteEntry("governorCreationPrice"), DeleteEntry("keyLockableAssets")] | |
100 | - | ||
101 | - | ||
102 | - | ||
103 | - | @Callable(i) | |
104 | - | func updateSettingsAddress (newAddress) = if ((this != i.caller)) | |
105 | - | then throw("Access denied") | |
106 | - | else [StringEntry(keySettingsAddress, newAddress)] | |
107 | - | ||
108 | - | ||
109 | - | ||
110 | - | @Callable(i) | |
111 | - | func depositAssetToStake () = if ((isSelf(i.caller) != false)) | |
112 | - | then throw("dApp can't act for self") | |
113 | - | else if ((size(i.payments) != 1)) | |
114 | - | then throw("Not a valid amount of payments (require 1)") | |
115 | - | else { | |
116 | - | let amount = i.payments[0].amount | |
117 | - | let assetIdStr = match i.payments[0].assetId { | |
118 | - | case isAsset: ByteVector => | |
119 | - | toBase58String(isAsset) | |
120 | - | case _ => | |
121 | - | hardcoredAssetIdForWaves | |
122 | - | } | |
123 | - | let keyOrigin = (keyAssetToStake + assetIdStr) | |
124 | - | let settingAddress = getSettingsAddress() | |
125 | - | let isEnabled = getBooleanValue(settingAddress, (keyOrigin + keySuffixIsEnabled)) | |
126 | - | let minimumAmount = getIntegerValue(settingAddress, (keyOrigin + keySuffixMinAmount)) | |
127 | - | if ((isEnabled != true)) | |
128 | - | then throw("Disabled") | |
129 | - | else if ((minimumAmount > amount)) | |
130 | - | then throw("Below minimum amount") | |
131 | - | else { | |
132 | - | let depositFee = calcDepositFee(amount, getAssetDepositFeePerc(assetIdStr)) | |
133 | - | let nonce = getNewNonce() | |
134 | - | let ATSContractDesc = ((((((((toString(height) + separator) + toBase58String(i.caller.bytes)) + separator) + assetIdStr) + separator) + toString(amount)) + separator) + toString(depositFee)) | |
135 | - | let ATSContract = Issue(keyATSContractName, ATSContractDesc, 1, 0, false, unit, nonce[0]) | |
136 | - | let ATSContractId = calculateAssetId(ATSContract) | |
137 | - | let newStakingAmount = (getIntegerOrZero((keyStakingAmount + assetIdStr)) + amount) | |
138 | - | let newIssuedAmount = (getIntegerOrZero((keyIssuedStakingContract + assetIdStr)) + 1) | |
139 | - | [IntegerEntry(keyNonce, nonce[1]), IntegerEntry((keyStakingAmount + assetIdStr), newStakingAmount), IntegerEntry((keyIssuedStakingContract + assetIdStr), newIssuedAmount), ATSContract, ScriptTransfer(i.caller, ATSContract.quantity, ATSContractId)] | |
140 | - | } | |
141 | - | } | |
142 | - | ||
143 | - | ||
144 | - | ||
145 | - | @Callable(i) | |
146 | - | func withdrawAssetToStake () = if ((isSelf(i.caller) != false)) | |
147 | - | then throw("dApp can't act for self") | |
148 | - | else if ((size(i.payments) != 1)) | |
149 | - | then throw("Not a valid amount of payments (require 1)") | |
150 | - | else { | |
151 | - | let contractId = match i.payments[0].assetId { | |
152 | - | case isBV: ByteVector => | |
153 | - | isBV | |
154 | - | case _ => | |
155 | - | throw("Contract is an Asset, not Waves") | |
156 | - | } | |
157 | - | let contractDetails = match assetInfo(contractId) { | |
158 | - | case isAsset: Asset => | |
159 | - | isAsset | |
160 | - | case _ => | |
161 | - | throw("Contract should be an existing Asset") | |
162 | - | } | |
163 | - | if (if (if (if (if ((contractDetails.issuer != this)) | |
164 | - | then true | |
165 | - | else (contractDetails.decimals != 0)) | |
166 | - | then true | |
167 | - | else (contractDetails.quantity != 1)) | |
168 | - | then true | |
169 | - | else (contractDetails.reissuable != false)) | |
170 | - | then true | |
171 | - | else (contractDetails.name != keyATSContractName)) | |
172 | - | then throw("Corrupted Contract") | |
173 | - | else { | |
174 | - | let contractInfo = split(contractDetails.description, separator) | |
175 | - | let startingBlockHeight = parseIntValue(contractInfo[0]) | |
176 | - | let stakerAddress = addressFromStringValue(contractInfo[1]) | |
177 | - | let ATSInfo = match assetInfo(fromBase58String(contractInfo[2])) { | |
178 | - | case isAsset: Asset => | |
179 | - | isAsset | |
180 | - | case _ => | |
181 | - | throw("ATS Contract not recognized") | |
182 | - | } | |
183 | - | let amountToStake = parseIntValue(contractInfo[3]) | |
184 | - | let feeToPay = parseIntValue(contractInfo[4]) | |
185 | - | let amountToReturn = (amountToStake - feeToPay) | |
186 | - | if ((startingBlockHeight > height)) | |
187 | - | then throw("startingBlockHeight corrupted") | |
188 | - | else if (if ((1 > amountToStake)) | |
189 | - | then true | |
190 | - | else (amountToStake > ATSInfo.quantity)) | |
191 | - | then throw("amountToStake corrupted") | |
192 | - | else if (if ((1 > feeToPay)) | |
193 | - | then true | |
194 | - | else (feeToPay > amountToStake)) | |
195 | - | then throw("feeToPay corrupted") | |
196 | - | else if (if ((1 > amountToReturn)) | |
197 | - | then true | |
198 | - | else (amountToReturn > ATSInfo.quantity)) | |
199 | - | then throw("amountToReturn corrupted") | |
200 | - | else if ((amountToReturn > assetBalance(this, ATSInfo.id))) | |
201 | - | then throw("ATS balance too low") | |
202 | - | else { | |
203 | - | let ATSIdStr = toBase58String(ATSInfo.id) | |
204 | - | let newStakingAmount = (getIntegerOrZero((keyStakingAmount + ATSIdStr)) - amountToStake) | |
205 | - | let newBurnedAmount = (getIntegerOrZero((keyBurnedStakingContract + ATSIdStr)) + 1) | |
206 | - | let newTreasury = (getIntegerOrZero((keyTreasury + ATSIdStr)) + feeToPay) | |
207 | - | [Burn(contractId, 1), IntegerEntry((keyStakingAmount + ATSIdStr), newStakingAmount), IntegerEntry((keyBurnedStakingContract + ATSIdStr), newBurnedAmount), IntegerEntry((keyTreasury + ATSIdStr), newTreasury), ScriptTransfer(i.caller, amountToReturn, ATSInfo.id)] | |
208 | - | } | |
209 | - | } | |
210 | - | } | |
7 | + | func call () = { | |
8 | + | let asset = Issue("Asset", "", 1, 0, true, unit, 0) | |
9 | + | let assetId = calculateAssetId(asset) | |
10 | + | [BinaryEntry("bin", base58''), BooleanEntry("bool", true), IntegerEntry("int", 1), StringEntry("str", ""), DeleteEntry("str"), asset, Reissue(assetId, 1, false), Burn(assetId, 1), ScriptTransfer(i.caller, 1, assetId)] | |
11 | + | } | |
211 | 12 | ||
212 | 13 | ||
213 | 14 | @Verifier(tx) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let separator = "___" | |
5 | - | ||
6 | - | let hardcoredMaximumDepositFee = 100 | |
7 | - | ||
8 | - | let hardcoredDappName = "FOKOFF" | |
9 | - | ||
10 | - | let hardcoredAssetIdForWaves = "WAVES" | |
11 | - | ||
12 | - | let keyAssetToStake = (hardcoredDappName + "_AssetToStake_") | |
13 | - | ||
14 | - | let keyAssetsToStakeList = (hardcoredDappName + "_AssetsToStakeList") | |
15 | - | ||
16 | - | let keyDefaultDepositFee = (hardcoredDappName + "_DefaultDepositFee") | |
17 | - | ||
18 | - | let keySuffixIsEnabled = "_isEnabled" | |
19 | - | ||
20 | - | let keySuffixMinAmount = "_minimumAmount" | |
21 | - | ||
22 | - | let keySuffixAfterHeight = "_allowStakingAfterBlockHeight" | |
23 | - | ||
24 | - | let keySuffixBlockDelay = "_BlocksDelayAfterDepositToStake" | |
25 | - | ||
26 | - | let keySuffixEnableSpecFee = "_enableSpecificDepositFee" | |
27 | - | ||
28 | - | let keySuffixSpecFee = "_specificDepositFee" | |
29 | - | ||
30 | - | let keyTreasury = (hardcoredDappName + "_Treasury_") | |
31 | - | ||
32 | - | let keySettingsAddress = (hardcoredDappName + "_SettingsAddress") | |
33 | - | ||
34 | - | let keyNonce = (hardcoredDappName + "_Nonce") | |
35 | - | ||
36 | - | let keyStakingAmount = (hardcoredDappName + "_StakingAmount_") | |
37 | - | ||
38 | - | let keyIssuedStakingContract = (hardcoredDappName + "_IssuedSContract_") | |
39 | - | ||
40 | - | let keyBurnedStakingContract = (hardcoredDappName + "_BurnedSContract_") | |
41 | - | ||
42 | - | let keyATSContractName = (hardcoredDappName + "Contract1") | |
43 | - | ||
44 | - | func getSettingsAddress () = Address(fromBase58String(getStringValue(this, keySettingsAddress))) | |
45 | - | ||
46 | - | ||
47 | - | func isSelf (caller) = if ((this == caller)) | |
48 | - | then true | |
49 | - | else (caller == getSettingsAddress()) | |
50 | - | ||
51 | - | ||
52 | - | func calcDepositFee (depositedAmount,feePerc) = { | |
53 | - | let fee = ((depositedAmount * feePerc) / 10000) | |
54 | - | if ((1 > fee)) | |
55 | - | then 1 | |
56 | - | else fee | |
57 | - | } | |
58 | - | ||
59 | - | ||
60 | - | func getAssetDepositFeePerc (assetIdStr) = { | |
61 | - | let settingsAddress = getSettingsAddress() | |
62 | - | let keyOrigin = (keyAssetToStake + assetIdStr) | |
63 | - | let isSpecificFeeEnabled = getBooleanValue(settingsAddress, (keyOrigin + keySuffixEnableSpecFee)) | |
64 | - | if ((isSpecificFeeEnabled == true)) | |
65 | - | then { | |
66 | - | let specificFee = getIntegerValue(settingsAddress, (keyOrigin + keySuffixSpecFee)) | |
67 | - | if ((specificFee > hardcoredMaximumDepositFee)) | |
68 | - | then hardcoredMaximumDepositFee | |
69 | - | else if ((0 > specificFee)) | |
70 | - | then 0 | |
71 | - | else specificFee | |
72 | - | } | |
73 | - | else { | |
74 | - | let defaultDepositFee = getIntegerValue(settingsAddress, keyDefaultDepositFee) | |
75 | - | if ((defaultDepositFee > hardcoredMaximumDepositFee)) | |
76 | - | then hardcoredMaximumDepositFee | |
77 | - | else if ((0 > defaultDepositFee)) | |
78 | - | then 0 | |
79 | - | else defaultDepositFee | |
80 | - | } | |
81 | - | } | |
82 | - | ||
83 | - | ||
84 | - | func getIntegerOrZero (keyName) = match getInteger(this, keyName) { | |
85 | - | case isInt: Int => | |
86 | - | isInt | |
87 | - | case _ => | |
88 | - | 0 | |
89 | - | } | |
90 | - | ||
91 | - | ||
92 | - | func getNewNonce () = { | |
93 | - | let incrNonce = (getIntegerOrZero(keyNonce) + 1) | |
94 | - | [parseIntValue((toString(incrNonce) + toString(height))), incrNonce] | |
95 | - | } | |
96 | 4 | ||
97 | 5 | ||
98 | 6 | @Callable(i) | |
99 | - | func init () = [DeleteEntry("Treasury-WAVES"), DeleteEntry("dApp_LockableAsset_Go6FQZHeZzqeAn7wrcywA6ZwsVFGWYBKx7jgnoCMJJtY"), DeleteEntry("dApp_LockableAssets"), DeleteEntry("dApp_LockableAssetsList"), DeleteEntry("governorCreationPrice"), DeleteEntry("keyLockableAssets")] | |
100 | - | ||
101 | - | ||
102 | - | ||
103 | - | @Callable(i) | |
104 | - | func updateSettingsAddress (newAddress) = if ((this != i.caller)) | |
105 | - | then throw("Access denied") | |
106 | - | else [StringEntry(keySettingsAddress, newAddress)] | |
107 | - | ||
108 | - | ||
109 | - | ||
110 | - | @Callable(i) | |
111 | - | func depositAssetToStake () = if ((isSelf(i.caller) != false)) | |
112 | - | then throw("dApp can't act for self") | |
113 | - | else if ((size(i.payments) != 1)) | |
114 | - | then throw("Not a valid amount of payments (require 1)") | |
115 | - | else { | |
116 | - | let amount = i.payments[0].amount | |
117 | - | let assetIdStr = match i.payments[0].assetId { | |
118 | - | case isAsset: ByteVector => | |
119 | - | toBase58String(isAsset) | |
120 | - | case _ => | |
121 | - | hardcoredAssetIdForWaves | |
122 | - | } | |
123 | - | let keyOrigin = (keyAssetToStake + assetIdStr) | |
124 | - | let settingAddress = getSettingsAddress() | |
125 | - | let isEnabled = getBooleanValue(settingAddress, (keyOrigin + keySuffixIsEnabled)) | |
126 | - | let minimumAmount = getIntegerValue(settingAddress, (keyOrigin + keySuffixMinAmount)) | |
127 | - | if ((isEnabled != true)) | |
128 | - | then throw("Disabled") | |
129 | - | else if ((minimumAmount > amount)) | |
130 | - | then throw("Below minimum amount") | |
131 | - | else { | |
132 | - | let depositFee = calcDepositFee(amount, getAssetDepositFeePerc(assetIdStr)) | |
133 | - | let nonce = getNewNonce() | |
134 | - | let ATSContractDesc = ((((((((toString(height) + separator) + toBase58String(i.caller.bytes)) + separator) + assetIdStr) + separator) + toString(amount)) + separator) + toString(depositFee)) | |
135 | - | let ATSContract = Issue(keyATSContractName, ATSContractDesc, 1, 0, false, unit, nonce[0]) | |
136 | - | let ATSContractId = calculateAssetId(ATSContract) | |
137 | - | let newStakingAmount = (getIntegerOrZero((keyStakingAmount + assetIdStr)) + amount) | |
138 | - | let newIssuedAmount = (getIntegerOrZero((keyIssuedStakingContract + assetIdStr)) + 1) | |
139 | - | [IntegerEntry(keyNonce, nonce[1]), IntegerEntry((keyStakingAmount + assetIdStr), newStakingAmount), IntegerEntry((keyIssuedStakingContract + assetIdStr), newIssuedAmount), ATSContract, ScriptTransfer(i.caller, ATSContract.quantity, ATSContractId)] | |
140 | - | } | |
141 | - | } | |
142 | - | ||
143 | - | ||
144 | - | ||
145 | - | @Callable(i) | |
146 | - | func withdrawAssetToStake () = if ((isSelf(i.caller) != false)) | |
147 | - | then throw("dApp can't act for self") | |
148 | - | else if ((size(i.payments) != 1)) | |
149 | - | then throw("Not a valid amount of payments (require 1)") | |
150 | - | else { | |
151 | - | let contractId = match i.payments[0].assetId { | |
152 | - | case isBV: ByteVector => | |
153 | - | isBV | |
154 | - | case _ => | |
155 | - | throw("Contract is an Asset, not Waves") | |
156 | - | } | |
157 | - | let contractDetails = match assetInfo(contractId) { | |
158 | - | case isAsset: Asset => | |
159 | - | isAsset | |
160 | - | case _ => | |
161 | - | throw("Contract should be an existing Asset") | |
162 | - | } | |
163 | - | if (if (if (if (if ((contractDetails.issuer != this)) | |
164 | - | then true | |
165 | - | else (contractDetails.decimals != 0)) | |
166 | - | then true | |
167 | - | else (contractDetails.quantity != 1)) | |
168 | - | then true | |
169 | - | else (contractDetails.reissuable != false)) | |
170 | - | then true | |
171 | - | else (contractDetails.name != keyATSContractName)) | |
172 | - | then throw("Corrupted Contract") | |
173 | - | else { | |
174 | - | let contractInfo = split(contractDetails.description, separator) | |
175 | - | let startingBlockHeight = parseIntValue(contractInfo[0]) | |
176 | - | let stakerAddress = addressFromStringValue(contractInfo[1]) | |
177 | - | let ATSInfo = match assetInfo(fromBase58String(contractInfo[2])) { | |
178 | - | case isAsset: Asset => | |
179 | - | isAsset | |
180 | - | case _ => | |
181 | - | throw("ATS Contract not recognized") | |
182 | - | } | |
183 | - | let amountToStake = parseIntValue(contractInfo[3]) | |
184 | - | let feeToPay = parseIntValue(contractInfo[4]) | |
185 | - | let amountToReturn = (amountToStake - feeToPay) | |
186 | - | if ((startingBlockHeight > height)) | |
187 | - | then throw("startingBlockHeight corrupted") | |
188 | - | else if (if ((1 > amountToStake)) | |
189 | - | then true | |
190 | - | else (amountToStake > ATSInfo.quantity)) | |
191 | - | then throw("amountToStake corrupted") | |
192 | - | else if (if ((1 > feeToPay)) | |
193 | - | then true | |
194 | - | else (feeToPay > amountToStake)) | |
195 | - | then throw("feeToPay corrupted") | |
196 | - | else if (if ((1 > amountToReturn)) | |
197 | - | then true | |
198 | - | else (amountToReturn > ATSInfo.quantity)) | |
199 | - | then throw("amountToReturn corrupted") | |
200 | - | else if ((amountToReturn > assetBalance(this, ATSInfo.id))) | |
201 | - | then throw("ATS balance too low") | |
202 | - | else { | |
203 | - | let ATSIdStr = toBase58String(ATSInfo.id) | |
204 | - | let newStakingAmount = (getIntegerOrZero((keyStakingAmount + ATSIdStr)) - amountToStake) | |
205 | - | let newBurnedAmount = (getIntegerOrZero((keyBurnedStakingContract + ATSIdStr)) + 1) | |
206 | - | let newTreasury = (getIntegerOrZero((keyTreasury + ATSIdStr)) + feeToPay) | |
207 | - | [Burn(contractId, 1), IntegerEntry((keyStakingAmount + ATSIdStr), newStakingAmount), IntegerEntry((keyBurnedStakingContract + ATSIdStr), newBurnedAmount), IntegerEntry((keyTreasury + ATSIdStr), newTreasury), ScriptTransfer(i.caller, amountToReturn, ATSInfo.id)] | |
208 | - | } | |
209 | - | } | |
210 | - | } | |
7 | + | func call () = { | |
8 | + | let asset = Issue("Asset", "", 1, 0, true, unit, 0) | |
9 | + | let assetId = calculateAssetId(asset) | |
10 | + | [BinaryEntry("bin", base58''), BooleanEntry("bool", true), IntegerEntry("int", 1), StringEntry("str", ""), DeleteEntry("str"), asset, Reissue(assetId, 1, false), Burn(assetId, 1), ScriptTransfer(i.caller, 1, assetId)] | |
11 | + | } | |
211 | 12 | ||
212 | 13 | ||
213 | 14 | @Verifier(tx) | |
214 | 15 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
215 | 16 |
github/deemru/w8io/169f3d6 29.23 ms ◑![]()