tx · GQFFJjXxLVxbPippXRDPGN5V8gSbj23XWeARhesn9aLp 3N5TDZHiXyXByfTA47imbhEqAbzAupJR5xY: -0.01000000 Waves 2022.11.22 21:28 [2328684] smart account 3N5TDZHiXyXByfTA47imbhEqAbzAupJR5xY > SELF 0.00000000 Waves
{ "type": 13, "id": "GQFFJjXxLVxbPippXRDPGN5V8gSbj23XWeARhesn9aLp", "fee": 1000000, "feeAssetId": null, "timestamp": 1669141709632, "version": 2, "chainId": 84, "sender": "3N5TDZHiXyXByfTA47imbhEqAbzAupJR5xY", "senderPublicKey": "9rkQ1ChfNZ585cJFqVhjLk1mTNMXT93CZidHoYERtHML", "proofs": [ "d8zvUwmfi9e7TE1HD3ACNzeQmaVLpKZoLYagbr61GBz6DctMoEwhqogmkRDTzWkfeXQsQEaNCWYoAGQd3mZ8dq7" ], "script": "base64:BgIaCAISBAoCCAgSAwoBCBIDCgEIEgYKBAgIAQEUAANTRVACAl9fAAVFTVBUWQIAAAlQUkVDSVNJT04AgICQu7rWrfANAAhERUNJTUFMUwCAwtcvAAlXRVNUX1BBUlQJAGkCBQlQUkVDSVNJT04ABQELa2V5QXNzZXRDZmcBDGJhc2VBc3NldFN0cgkAuQkCCQDMCAICBiVzJXMlcwkAzAgCAgZjb25maWcJAMwIAgIFYXNzZXQJAMwIAgUMYmFzZUFzc2V0U3RyBQNuaWwFA1NFUAEOa2V5SW5pdGlhbGl6ZWQACQC5CQIJAMwIAgICJXMJAMwIAgILaW5pdGlhbGl6ZWQFA25pbAUDU0VQAQhrZXlBZG1pbgAJALkJAgkAzAgCAgIlcwkAzAgCAgVhZG1pbgUDbmlsBQNTRVABDGtleUVhc3RBc3NldAAJALkJAgkAzAgCAgIlcwkAzAgCAgllYXN0QXNzZXQFA25pbAUDU0VQAQxrZXlXZXN0QXNzZXQACQC5CQIJAMwIAgICJXMJAMwIAgIJd2VzdEFzc2V0BQNuaWwFA1NFUAEPa2V5QXNzZXRTdG9yYWdlAAkAuQkCCQDMCAICA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VxdWFsIHRvIGl0c2VsZi4BAnR4AQZ2ZXJpZnkACQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAACAUCdHgPc2VuZGVyUHVibGljS2V5/jGO9w==", "height": 2328684, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: 6a7JYocrJow4W7uQF54hFEMez5X5kmbhosamSNeCSw5N Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let SEP = "__" | |
5 | + | ||
6 | + | let EMPTY = "" | |
7 | + | ||
8 | + | let PRECISION = 1000000000000000000 | |
9 | + | ||
10 | + | let DECIMALS = 100000000 | |
11 | + | ||
12 | + | let WEST_PART = (PRECISION / 5) | |
13 | + | ||
14 | + | func keyAssetCfg (baseAssetStr) = makeString(["%s%s%s", "config", "asset", baseAssetStr], SEP) | |
15 | + | ||
16 | + | ||
17 | + | func keyInitialized () = makeString(["%s", "initialized"], SEP) | |
18 | + | ||
19 | + | ||
20 | + | func keyAdmin () = makeString(["%s", "admin"], SEP) | |
21 | + | ||
22 | + | ||
23 | + | func keyEastAsset () = makeString(["%s", "eastAsset"], SEP) | |
24 | + | ||
25 | + | ||
26 | + | func keyWestAsset () = makeString(["%s", "westAsset"], SEP) | |
27 | + | ||
28 | + | ||
29 | + | func keyAssetStorage () = makeString(["%s", "assetStorage"], SEP) | |
30 | + | ||
31 | + | ||
32 | + | func keyBAssetId () = "B_asset_id" | |
33 | + | ||
34 | + | ||
35 | + | func dataAssetCfg (_contractId,_assetId,_backingRatio,_liquidationCollateral) = makeString(["%s%s%d%d", _contractId, _assetId, toString(_backingRatio), toString(_liquidationCollateral)], SEP) | |
36 | + | ||
37 | + | ||
38 | + | func initialized () = valueOrElse(getBoolean(this, keyInitialized()), false) | |
39 | + | ||
40 | + | ||
41 | + | func isOwner (i) = (this == i.caller) | |
42 | + | ||
43 | + | ||
44 | + | func adminAddressOrUnit () = match getString(this, keyAdmin()) { | |
45 | + | case s: String => | |
46 | + | Address(fromBase58String(s)) | |
47 | + | case _: Unit => | |
48 | + | unit | |
49 | + | case _ => | |
50 | + | throw("Match error") | |
51 | + | } | |
52 | + | ||
53 | + | ||
54 | + | func int0 (k) = valueOrElse(getInteger(this, k), 0) | |
55 | + | ||
56 | + | ||
57 | + | func mustAdmin (i) = { | |
58 | + | let pd = throw("permission denied") | |
59 | + | match adminAddressOrUnit() { | |
60 | + | case address: Address => | |
61 | + | if ((i.caller == address)) | |
62 | + | then true | |
63 | + | else pd | |
64 | + | case _: Unit => | |
65 | + | if ((i.caller == this)) | |
66 | + | then true | |
67 | + | else pd | |
68 | + | case _ => | |
69 | + | throw("Match error") | |
70 | + | } | |
71 | + | } | |
72 | + | ||
73 | + | ||
74 | + | func checkContractAndAsset (_assetId,_contractId) = { | |
75 | + | let contractId = Address(fromBase58String(_contractId)) | |
76 | + | let assetId = valueOrErrorMessage(getString(contractId, keyBAssetId()), "Wrong contract id") | |
77 | + | if ((assetId != _assetId)) | |
78 | + | then throw("Wrong asset id") | |
79 | + | else nil | |
80 | + | } | |
81 | + | ||
82 | + | ||
83 | + | func checkRanges (value) = if (if ((value > 0)) | |
84 | + | then (300 > value) | |
85 | + | else false) | |
86 | + | then true | |
87 | + | else throw("Out of range") | |
88 | + | ||
89 | + | ||
90 | + | @Callable(i) | |
91 | + | func initialize (_assetStoreAddress,_westAssetId) = if (if (initialized()) | |
92 | + | then isOwner(i) | |
93 | + | else false) | |
94 | + | then throw("Not allowed") | |
95 | + | else { | |
96 | + | let east = Issue("East", "", 0, 8, true, unit, 0) | |
97 | + | let _eastAssetId = calculateAssetId(east) | |
98 | + | [StringEntry(keyEastAsset(), toBase58String(_eastAssetId)), StringEntry(keyWestAsset(), _westAssetId), BooleanEntry(keyInitialized(), true)] | |
99 | + | } | |
100 | + | ||
101 | + | ||
102 | + | ||
103 | + | @Callable(i) | |
104 | + | func setAdmin (_address) = { | |
105 | + | let check = if (initialized()) | |
106 | + | then mustAdmin(i) | |
107 | + | else false | |
108 | + | if ((check == check)) | |
109 | + | then if (!(check)) | |
110 | + | then throw("Not allowed") | |
111 | + | else [StringEntry(keyAdmin(), _address)] | |
112 | + | else throw("Strict value is not equal to itself.") | |
113 | + | } | |
114 | + | ||
115 | + | ||
116 | + | ||
117 | + | @Callable(i) | |
118 | + | func adminSetAssetStorage (_address) = { | |
119 | + | let check = if (initialized()) | |
120 | + | then mustAdmin(i) | |
121 | + | else false | |
122 | + | if ((check == check)) | |
123 | + | then if (!(check)) | |
124 | + | then throw("Not allowed") | |
125 | + | else [StringEntry(keyAssetStorage(), _address)] | |
126 | + | else throw("Strict value is not equal to itself.") | |
127 | + | } | |
128 | + | ||
129 | + | ||
130 | + | ||
131 | + | @Callable(i) | |
132 | + | func adminSetAsset (_assetId,_contractId,_backingRatio,_liquidationCollateral) = { | |
133 | + | let inited = if (initialized()) | |
134 | + | then mustAdmin(i) | |
135 | + | else false | |
136 | + | if ((inited == inited)) | |
137 | + | then if (!(inited)) | |
138 | + | then throw("Not allowed") | |
139 | + | else { | |
140 | + | let westAssetId = getStringValue(keyWestAsset()) | |
141 | + | if ((westAssetId == _assetId)) | |
142 | + | then throw("West asset is not allowed") | |
143 | + | else { | |
144 | + | let checks = [checkContractAndAsset(_assetId, _contractId), checkRanges(_backingRatio), checkRanges(_liquidationCollateral)] | |
145 | + | if ((checks == checks)) | |
146 | + | then { | |
147 | + | let assetCfg = dataAssetCfg(_contractId, _assetId, _backingRatio, _liquidationCollateral) | |
148 | + | [StringEntry(keyAssetCfg(_assetId), assetCfg)] | |
149 | + | } | |
150 | + | else throw("Strict value is not equal to itself.") | |
151 | + | } | |
152 | + | } | |
153 | + | else throw("Strict value is not equal to itself.") | |
154 | + | } | |
155 | + | ||
156 | + | ||
157 | + | @Verifier(tx) | |
158 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
159 | + |
github/deemru/w8io/026f985 16.90 ms ◑