tx · 2jEweJXuiYX5zdXrsxjPp6Y7ub6HcqHtev8tiaS7QgoR
3N7psESThHV5T7gjWF2DLjztWtrhTF6FR3b: -0.03700000 Waves
2023.05.27 12:13 [2596170] smart account 3N7psESThHV5T7gjWF2DLjztWtrhTF6FR3b > SELF 0.00000000 Waves
{
"type": 13,
"id": "2jEweJXuiYX5zdXrsxjPp6Y7ub6HcqHtev8tiaS7QgoR",
"fee": 3700000,
"feeAssetId": null,
"timestamp": 1685178829999,
"version": 2,
"chainId": 84,
"sender": "3N7psESThHV5T7gjWF2DLjztWtrhTF6FR3b",
"senderPublicKey": "AgUKubvVDHDimcoQ6a6GnnzKdymyp2NYJRnjDFhiyM4e",
"proofs": [
"3MWqZ3AfmNiGEmDz9fkP1zAYAi7cHPHxc8ZYGQXZwwWptdZD3C9qLfgNnVqwcozxq1gfZ98FgRjCjeNgHVgKeHv5"
],
"script": "base64:BgIdCAISBgoECAgICBIECgIIARIFCgMICAgSBAoCCAgKAA1rX2luaXRpYWxpemVkAg1rX2luaXRpYWxpemVkABRrX2Nvb3JkaW5hdG9yQWRkcmVzcwIUa19jb29yZGluYXRvckFkZHJlc3MAD2tfYWRtaW5fYWRkcmVzcwIPa19hZG1pbl9hZGRyZXNzAAhrX21hcmtldAIIa19tYXJrZXQBDGdldE1hcmtldEtleQIFX2Zyb20DX3RvCQCsAgIJAKwCAgkArAICCQCsAgIFCGtfbWFya2V0AgFfBQVfZnJvbQIBXwUDX3RvAQtjb29yZGluYXRvcgAJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkApggBCQETdmFsdWVPckVycm9yTWVzc2FnZQIJAJ0IAgUEdGhpcwUUa19jb29yZGluYXRvckFkZHJlc3MCGENvb3JkaW5hdG9yIG5vdCBzZXQgU3dhcAIbQ29vcmRpbmF0b3IgYWRkcmVzcyBpbnZhbGlkAQxhZG1pbkFkZHJlc3MACQCmCAEJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAnQgCCQELY29vcmRpbmF0b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RtaW4JAKwCAgkArAICCQCsAgICB3N0YXR1c18JAKUIAQUEdGhpcwIBXwkA2AQBCAUCdHgCaWQHCQACAQIudW5hYmxlIHRvIHZlcmlmeTogYWRtaW4gbm90IHNldCBpbiBjb29yZGluYXRvcgkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleVns/ug=",
"height": 2596170,
"applicationStatus": "succeeded",
"spentComplexity": 0
}
View: original | compacted
Prev: DdEJRFzxpRx4tA46mbGapGbrcLHV3GEs8wYpADiackLa
Next: none
Diff:
Old | New | | Differences |
---|
21 | 21 | | func j () = valueOrElse(getBoolean(this, a), false) |
---|
22 | 22 | | |
---|
23 | 23 | | |
---|
24 | | - | func k (f,g) = { |
---|
25 | | - | let l = e(f, g) |
---|
26 | | - | let m = value(assetInfo(fromBase58String(f))).name |
---|
27 | | - | let n = value(assetInfo(fromBase58String(g))).name |
---|
28 | | - | let o = (((((((f + " [") + m) + "] -> ") + g) + " [") + n) + "]") |
---|
29 | | - | let p = valueOrErrorMessage(getString(this, l), ("No market for swap: " + o)) |
---|
30 | | - | valueOrErrorMessage(addressFromString(p), ("Invalid market address for swap: " + o)) |
---|
| 24 | + | func k (l) = if ((l == "WAVES")) |
---|
| 25 | + | then "WAVES" |
---|
| 26 | + | else value(assetInfo(fromBase58String(l))).name |
---|
| 27 | + | |
---|
| 28 | + | |
---|
| 29 | + | func m (f,g) = { |
---|
| 30 | + | let n = e(f, g) |
---|
| 31 | + | let o = k(f) |
---|
| 32 | + | let p = k(g) |
---|
| 33 | + | let q = (((((((f + " [") + o) + "] -> ") + g) + " [") + p) + "]") |
---|
| 34 | + | let r = valueOrErrorMessage(getString(this, n), ("No market for swap: " + q)) |
---|
| 35 | + | valueOrErrorMessage(addressFromString(r), ("Invalid market address for swap: " + q)) |
---|
31 | 36 | | } |
---|
32 | 37 | | |
---|
33 | 38 | | |
---|
34 | | - | @Callable(q) |
---|
35 | | - | func initialize (r,s,t,u) = if (if (j()) |
---|
| 39 | + | @Callable(s) |
---|
| 40 | + | func initialize (t,u,v,w) = if (if (j()) |
---|
36 | 41 | | then true |
---|
37 | | - | else (q.caller != this)) |
---|
| 42 | + | else (s.caller != this)) |
---|
38 | 43 | | then throw("Unable to initialize") |
---|
39 | 44 | | else { |
---|
40 | | - | let v = split(s, ",") |
---|
41 | | - | let w = split(t, ",") |
---|
42 | 45 | | let x = split(u, ",") |
---|
43 | | - | if (if (if ((size(v) != size(w))) |
---|
| 46 | + | let y = split(v, ",") |
---|
| 47 | + | let z = split(w, ",") |
---|
| 48 | + | if (if (if ((size(x) != size(y))) |
---|
44 | 49 | | then true |
---|
45 | | - | else (size(v) != size(x))) |
---|
| 50 | + | else (size(x) != size(z))) |
---|
46 | 51 | | then true |
---|
47 | | - | else (size(v) > 5)) |
---|
| 52 | + | else (size(x) > 5)) |
---|
48 | 53 | | then throw("Unable to initialize: invalid assets / markets") |
---|
49 | 54 | | else { |
---|
50 | | - | func y (z,A) = if ((A >= size(v))) |
---|
51 | | - | then z |
---|
| 55 | + | func A (B,C) = if ((C >= size(x))) |
---|
| 56 | + | then B |
---|
52 | 57 | | else { |
---|
53 | | - | let B = v[A] |
---|
54 | | - | let C = w[A] |
---|
55 | | - | let D = x[A] |
---|
56 | | - | if (if (if ((B == "")) |
---|
| 58 | + | let D = x[C] |
---|
| 59 | + | let E = y[C] |
---|
| 60 | + | let F = z[C] |
---|
| 61 | + | if (if (if ((D == "")) |
---|
57 | 62 | | then true |
---|
58 | | - | else (C == "")) |
---|
| 63 | + | else (E == "")) |
---|
59 | 64 | | then true |
---|
60 | | - | else !(isDefined(addressFromString(D)))) |
---|
61 | | - | then throw(("Invalid market at index: " + toString(A))) |
---|
62 | | - | else (z ++ [StringEntry(e(B, C), D)]) |
---|
| 65 | + | else !(isDefined(addressFromString(F)))) |
---|
| 66 | + | then throw(("Invalid market at index: " + toString(C))) |
---|
| 67 | + | else (B ++ [StringEntry(e(D, E), F)]) |
---|
63 | 68 | | } |
---|
64 | 69 | | |
---|
65 | | - | let E = { |
---|
66 | | - | let F = [0, 1, 2, 3, 4] |
---|
67 | | - | let G = size(F) |
---|
68 | | - | let H = nil |
---|
69 | | - | func I (J,K) = if ((K >= G)) |
---|
70 | | - | then J |
---|
71 | | - | else y(J, F[K]) |
---|
| 70 | + | let G = { |
---|
| 71 | + | let H = [0, 1, 2, 3, 4] |
---|
| 72 | + | let I = size(H) |
---|
| 73 | + | let J = nil |
---|
| 74 | + | func K (L,M) = if ((M >= I)) |
---|
| 75 | + | then L |
---|
| 76 | + | else A(L, H[M]) |
---|
72 | 77 | | |
---|
73 | | - | func L (J,K) = if ((K >= G)) |
---|
74 | | - | then J |
---|
| 78 | + | func N (L,M) = if ((M >= I)) |
---|
| 79 | + | then L |
---|
75 | 80 | | else throw("List size exceeds 5") |
---|
76 | 81 | | |
---|
77 | | - | L(I(I(I(I(I(H, 0), 1), 2), 3), 4), 5) |
---|
| 82 | + | N(K(K(K(K(K(J, 0), 1), 2), 3), 4), 5) |
---|
78 | 83 | | } |
---|
79 | | - | ([StringEntry(b, toString(addressFromStringValue(r))), BooleanEntry(a, true)] ++ E) |
---|
| 84 | + | ([StringEntry(b, toString(addressFromStringValue(t))), BooleanEntry(a, true)] ++ G) |
---|
80 | 85 | | } |
---|
81 | 86 | | } |
---|
82 | 87 | | |
---|
83 | 88 | | |
---|
84 | 89 | | |
---|
85 | | - | @Callable(q) |
---|
86 | | - | func swap (g,M) = if (if (if (!(j())) |
---|
| 90 | + | @Callable(s) |
---|
| 91 | + | func swap (g,O) = if (if (if (!(j())) |
---|
87 | 92 | | then true |
---|
88 | | - | else (size(q.payments) != 1)) |
---|
| 93 | + | else (size(s.payments) != 1)) |
---|
89 | 94 | | then true |
---|
90 | | - | else (0 > M)) |
---|
| 95 | + | else (0 > O)) |
---|
91 | 96 | | then throw("Invalid swap params: payment count") |
---|
92 | 97 | | else { |
---|
93 | | - | let N = q.payments[0].assetId |
---|
94 | | - | let B = if (isDefined(N)) |
---|
95 | | - | then toBase58String(value(N)) |
---|
| 98 | + | let P = s.payments[0].assetId |
---|
| 99 | + | let D = if (isDefined(P)) |
---|
| 100 | + | then toBase58String(value(P)) |
---|
96 | 101 | | else "WAVES" |
---|
97 | | - | let D = k(B, g) |
---|
98 | | - | let O = assetBalance(this, fromBase58String(g)) |
---|
99 | | - | if ((O == O)) |
---|
| 102 | + | let F = m(D, g) |
---|
| 103 | + | let Q = assetBalance(this, fromBase58String(g)) |
---|
| 104 | + | if ((Q == Q)) |
---|
100 | 105 | | then { |
---|
101 | | - | let P = invoke(D, "swap", [g, M], q.payments) |
---|
102 | | - | if ((P == P)) |
---|
| 106 | + | let R = invoke(F, "swap", [g, O], s.payments) |
---|
| 107 | + | if ((R == R)) |
---|
103 | 108 | | then { |
---|
104 | | - | let Q = assetBalance(this, fromBase58String(g)) |
---|
105 | | - | if ((Q == Q)) |
---|
| 109 | + | let S = assetBalance(this, fromBase58String(g)) |
---|
| 110 | + | if ((S == S)) |
---|
106 | 111 | | then { |
---|
107 | | - | let R = (Q - O) |
---|
108 | | - | if ((R == R)) |
---|
109 | | - | then $Tuple2([ScriptTransfer(q.caller, R, fromBase58String(g))], R) |
---|
| 112 | + | let T = (S - Q) |
---|
| 113 | + | if ((T == T)) |
---|
| 114 | + | then $Tuple2([ScriptTransfer(s.caller, T, fromBase58String(g))], T) |
---|
110 | 115 | | else throw("Strict value is not equal to itself.") |
---|
111 | 116 | | } |
---|
112 | 117 | | else throw("Strict value is not equal to itself.") |
---|
|
118 | 123 | | |
---|
119 | 124 | | |
---|
120 | 125 | | |
---|
121 | | - | @Callable(q) |
---|
122 | | - | func addMarket (f,g,S) = if (if (if (if (if (if ((q.caller != i())) |
---|
123 | | - | then (q.caller != this) |
---|
| 126 | + | @Callable(s) |
---|
| 127 | + | func addMarket (f,g,U) = if (if (if (if (if (if ((s.caller != i())) |
---|
| 128 | + | then (s.caller != this) |
---|
124 | 129 | | else false) |
---|
125 | 130 | | then true |
---|
126 | 131 | | else !(j())) |
---|
|
129 | 134 | | then true |
---|
130 | 135 | | else (g == "")) |
---|
131 | 136 | | then true |
---|
132 | | - | else !(isDefined(addressFromString(S)))) |
---|
| 137 | + | else !(isDefined(addressFromString(U)))) |
---|
133 | 138 | | then throw("Invalid addMarket params") |
---|
134 | | - | else [StringEntry(e(f, g), S)] |
---|
| 139 | + | else [StringEntry(e(f, g), U)] |
---|
135 | 140 | | |
---|
136 | 141 | | |
---|
137 | 142 | | |
---|
138 | | - | @Callable(q) |
---|
139 | | - | func removeMarket (f,g) = if (if (if (if ((q.caller != i())) |
---|
| 143 | + | @Callable(s) |
---|
| 144 | + | func removeMarket (f,g) = if (if (if (if ((s.caller != i())) |
---|
140 | 145 | | then true |
---|
141 | 146 | | else !(j())) |
---|
142 | 147 | | then true |
---|
|
147 | 152 | | else [DeleteEntry(e(f, g))] |
---|
148 | 153 | | |
---|
149 | 154 | | |
---|
150 | | - | @Verifier(T) |
---|
151 | | - | func U () = { |
---|
152 | | - | let V = getString(this, b) |
---|
153 | | - | if (isDefined(V)) |
---|
| 155 | + | @Verifier(V) |
---|
| 156 | + | func W () = { |
---|
| 157 | + | let X = getString(this, b) |
---|
| 158 | + | if (isDefined(X)) |
---|
154 | 159 | | then { |
---|
155 | | - | let W = getString(addressFromStringValue(value(V)), c) |
---|
156 | | - | if (isDefined(W)) |
---|
157 | | - | then valueOrElse(getBoolean(addressFromStringValue(value(W)), ((("status_" + toString(this)) + "_") + toBase58String(T.id))), false) |
---|
| 160 | + | let Y = getString(addressFromStringValue(value(X)), c) |
---|
| 161 | + | if (isDefined(Y)) |
---|
| 162 | + | then valueOrElse(getBoolean(addressFromStringValue(value(Y)), ((("status_" + toString(this)) + "_") + toBase58String(V.id))), false) |
---|
158 | 163 | | else throw("unable to verify: admin not set in coordinator") |
---|
159 | 164 | | } |
---|
160 | | - | else sigVerify(T.bodyBytes, T.proofs[0], T.senderPublicKey) |
---|
| 165 | + | else sigVerify(V.bodyBytes, V.proofs[0], V.senderPublicKey) |
---|
161 | 166 | | } |
---|
162 | 167 | | |
---|
Full:
Old | New | | Differences |
---|
1 | 1 | | {-# STDLIB_VERSION 6 #-} |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
4 | 4 | | let a = "k_initialized" |
---|
5 | 5 | | |
---|
6 | 6 | | let b = "k_coordinatorAddress" |
---|
7 | 7 | | |
---|
8 | 8 | | let c = "k_admin_address" |
---|
9 | 9 | | |
---|
10 | 10 | | let d = "k_market" |
---|
11 | 11 | | |
---|
12 | 12 | | func e (f,g) = ((((d + "_") + f) + "_") + g) |
---|
13 | 13 | | |
---|
14 | 14 | | |
---|
15 | 15 | | func h () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(this, b), "Coordinator not set Swap")), "Coordinator address invalid") |
---|
16 | 16 | | |
---|
17 | 17 | | |
---|
18 | 18 | | func i () = addressFromString(valueOrErrorMessage(getString(h(), c), "Admin address not set")) |
---|
19 | 19 | | |
---|
20 | 20 | | |
---|
21 | 21 | | func j () = valueOrElse(getBoolean(this, a), false) |
---|
22 | 22 | | |
---|
23 | 23 | | |
---|
24 | | - | func k (f,g) = { |
---|
25 | | - | let l = e(f, g) |
---|
26 | | - | let m = value(assetInfo(fromBase58String(f))).name |
---|
27 | | - | let n = value(assetInfo(fromBase58String(g))).name |
---|
28 | | - | let o = (((((((f + " [") + m) + "] -> ") + g) + " [") + n) + "]") |
---|
29 | | - | let p = valueOrErrorMessage(getString(this, l), ("No market for swap: " + o)) |
---|
30 | | - | valueOrErrorMessage(addressFromString(p), ("Invalid market address for swap: " + o)) |
---|
| 24 | + | func k (l) = if ((l == "WAVES")) |
---|
| 25 | + | then "WAVES" |
---|
| 26 | + | else value(assetInfo(fromBase58String(l))).name |
---|
| 27 | + | |
---|
| 28 | + | |
---|
| 29 | + | func m (f,g) = { |
---|
| 30 | + | let n = e(f, g) |
---|
| 31 | + | let o = k(f) |
---|
| 32 | + | let p = k(g) |
---|
| 33 | + | let q = (((((((f + " [") + o) + "] -> ") + g) + " [") + p) + "]") |
---|
| 34 | + | let r = valueOrErrorMessage(getString(this, n), ("No market for swap: " + q)) |
---|
| 35 | + | valueOrErrorMessage(addressFromString(r), ("Invalid market address for swap: " + q)) |
---|
31 | 36 | | } |
---|
32 | 37 | | |
---|
33 | 38 | | |
---|
34 | | - | @Callable(q) |
---|
35 | | - | func initialize (r,s,t,u) = if (if (j()) |
---|
| 39 | + | @Callable(s) |
---|
| 40 | + | func initialize (t,u,v,w) = if (if (j()) |
---|
36 | 41 | | then true |
---|
37 | | - | else (q.caller != this)) |
---|
| 42 | + | else (s.caller != this)) |
---|
38 | 43 | | then throw("Unable to initialize") |
---|
39 | 44 | | else { |
---|
40 | | - | let v = split(s, ",") |
---|
41 | | - | let w = split(t, ",") |
---|
42 | 45 | | let x = split(u, ",") |
---|
43 | | - | if (if (if ((size(v) != size(w))) |
---|
| 46 | + | let y = split(v, ",") |
---|
| 47 | + | let z = split(w, ",") |
---|
| 48 | + | if (if (if ((size(x) != size(y))) |
---|
44 | 49 | | then true |
---|
45 | | - | else (size(v) != size(x))) |
---|
| 50 | + | else (size(x) != size(z))) |
---|
46 | 51 | | then true |
---|
47 | | - | else (size(v) > 5)) |
---|
| 52 | + | else (size(x) > 5)) |
---|
48 | 53 | | then throw("Unable to initialize: invalid assets / markets") |
---|
49 | 54 | | else { |
---|
50 | | - | func y (z,A) = if ((A >= size(v))) |
---|
51 | | - | then z |
---|
| 55 | + | func A (B,C) = if ((C >= size(x))) |
---|
| 56 | + | then B |
---|
52 | 57 | | else { |
---|
53 | | - | let B = v[A] |
---|
54 | | - | let C = w[A] |
---|
55 | | - | let D = x[A] |
---|
56 | | - | if (if (if ((B == "")) |
---|
| 58 | + | let D = x[C] |
---|
| 59 | + | let E = y[C] |
---|
| 60 | + | let F = z[C] |
---|
| 61 | + | if (if (if ((D == "")) |
---|
57 | 62 | | then true |
---|
58 | | - | else (C == "")) |
---|
| 63 | + | else (E == "")) |
---|
59 | 64 | | then true |
---|
60 | | - | else !(isDefined(addressFromString(D)))) |
---|
61 | | - | then throw(("Invalid market at index: " + toString(A))) |
---|
62 | | - | else (z ++ [StringEntry(e(B, C), D)]) |
---|
| 65 | + | else !(isDefined(addressFromString(F)))) |
---|
| 66 | + | then throw(("Invalid market at index: " + toString(C))) |
---|
| 67 | + | else (B ++ [StringEntry(e(D, E), F)]) |
---|
63 | 68 | | } |
---|
64 | 69 | | |
---|
65 | | - | let E = { |
---|
66 | | - | let F = [0, 1, 2, 3, 4] |
---|
67 | | - | let G = size(F) |
---|
68 | | - | let H = nil |
---|
69 | | - | func I (J,K) = if ((K >= G)) |
---|
70 | | - | then J |
---|
71 | | - | else y(J, F[K]) |
---|
| 70 | + | let G = { |
---|
| 71 | + | let H = [0, 1, 2, 3, 4] |
---|
| 72 | + | let I = size(H) |
---|
| 73 | + | let J = nil |
---|
| 74 | + | func K (L,M) = if ((M >= I)) |
---|
| 75 | + | then L |
---|
| 76 | + | else A(L, H[M]) |
---|
72 | 77 | | |
---|
73 | | - | func L (J,K) = if ((K >= G)) |
---|
74 | | - | then J |
---|
| 78 | + | func N (L,M) = if ((M >= I)) |
---|
| 79 | + | then L |
---|
75 | 80 | | else throw("List size exceeds 5") |
---|
76 | 81 | | |
---|
77 | | - | L(I(I(I(I(I(H, 0), 1), 2), 3), 4), 5) |
---|
| 82 | + | N(K(K(K(K(K(J, 0), 1), 2), 3), 4), 5) |
---|
78 | 83 | | } |
---|
79 | | - | ([StringEntry(b, toString(addressFromStringValue(r))), BooleanEntry(a, true)] ++ E) |
---|
| 84 | + | ([StringEntry(b, toString(addressFromStringValue(t))), BooleanEntry(a, true)] ++ G) |
---|
80 | 85 | | } |
---|
81 | 86 | | } |
---|
82 | 87 | | |
---|
83 | 88 | | |
---|
84 | 89 | | |
---|
85 | | - | @Callable(q) |
---|
86 | | - | func swap (g,M) = if (if (if (!(j())) |
---|
| 90 | + | @Callable(s) |
---|
| 91 | + | func swap (g,O) = if (if (if (!(j())) |
---|
87 | 92 | | then true |
---|
88 | | - | else (size(q.payments) != 1)) |
---|
| 93 | + | else (size(s.payments) != 1)) |
---|
89 | 94 | | then true |
---|
90 | | - | else (0 > M)) |
---|
| 95 | + | else (0 > O)) |
---|
91 | 96 | | then throw("Invalid swap params: payment count") |
---|
92 | 97 | | else { |
---|
93 | | - | let N = q.payments[0].assetId |
---|
94 | | - | let B = if (isDefined(N)) |
---|
95 | | - | then toBase58String(value(N)) |
---|
| 98 | + | let P = s.payments[0].assetId |
---|
| 99 | + | let D = if (isDefined(P)) |
---|
| 100 | + | then toBase58String(value(P)) |
---|
96 | 101 | | else "WAVES" |
---|
97 | | - | let D = k(B, g) |
---|
98 | | - | let O = assetBalance(this, fromBase58String(g)) |
---|
99 | | - | if ((O == O)) |
---|
| 102 | + | let F = m(D, g) |
---|
| 103 | + | let Q = assetBalance(this, fromBase58String(g)) |
---|
| 104 | + | if ((Q == Q)) |
---|
100 | 105 | | then { |
---|
101 | | - | let P = invoke(D, "swap", [g, M], q.payments) |
---|
102 | | - | if ((P == P)) |
---|
| 106 | + | let R = invoke(F, "swap", [g, O], s.payments) |
---|
| 107 | + | if ((R == R)) |
---|
103 | 108 | | then { |
---|
104 | | - | let Q = assetBalance(this, fromBase58String(g)) |
---|
105 | | - | if ((Q == Q)) |
---|
| 109 | + | let S = assetBalance(this, fromBase58String(g)) |
---|
| 110 | + | if ((S == S)) |
---|
106 | 111 | | then { |
---|
107 | | - | let R = (Q - O) |
---|
108 | | - | if ((R == R)) |
---|
109 | | - | then $Tuple2([ScriptTransfer(q.caller, R, fromBase58String(g))], R) |
---|
| 112 | + | let T = (S - Q) |
---|
| 113 | + | if ((T == T)) |
---|
| 114 | + | then $Tuple2([ScriptTransfer(s.caller, T, fromBase58String(g))], T) |
---|
110 | 115 | | else throw("Strict value is not equal to itself.") |
---|
111 | 116 | | } |
---|
112 | 117 | | else throw("Strict value is not equal to itself.") |
---|
113 | 118 | | } |
---|
114 | 119 | | else throw("Strict value is not equal to itself.") |
---|
115 | 120 | | } |
---|
116 | 121 | | else throw("Strict value is not equal to itself.") |
---|
117 | 122 | | } |
---|
118 | 123 | | |
---|
119 | 124 | | |
---|
120 | 125 | | |
---|
121 | | - | @Callable(q) |
---|
122 | | - | func addMarket (f,g,S) = if (if (if (if (if (if ((q.caller != i())) |
---|
123 | | - | then (q.caller != this) |
---|
| 126 | + | @Callable(s) |
---|
| 127 | + | func addMarket (f,g,U) = if (if (if (if (if (if ((s.caller != i())) |
---|
| 128 | + | then (s.caller != this) |
---|
124 | 129 | | else false) |
---|
125 | 130 | | then true |
---|
126 | 131 | | else !(j())) |
---|
127 | 132 | | then true |
---|
128 | 133 | | else (f == "")) |
---|
129 | 134 | | then true |
---|
130 | 135 | | else (g == "")) |
---|
131 | 136 | | then true |
---|
132 | | - | else !(isDefined(addressFromString(S)))) |
---|
| 137 | + | else !(isDefined(addressFromString(U)))) |
---|
133 | 138 | | then throw("Invalid addMarket params") |
---|
134 | | - | else [StringEntry(e(f, g), S)] |
---|
| 139 | + | else [StringEntry(e(f, g), U)] |
---|
135 | 140 | | |
---|
136 | 141 | | |
---|
137 | 142 | | |
---|
138 | | - | @Callable(q) |
---|
139 | | - | func removeMarket (f,g) = if (if (if (if ((q.caller != i())) |
---|
| 143 | + | @Callable(s) |
---|
| 144 | + | func removeMarket (f,g) = if (if (if (if ((s.caller != i())) |
---|
140 | 145 | | then true |
---|
141 | 146 | | else !(j())) |
---|
142 | 147 | | then true |
---|
143 | 148 | | else (f == "")) |
---|
144 | 149 | | then true |
---|
145 | 150 | | else (g == "")) |
---|
146 | 151 | | then throw("Invalid addMarket params") |
---|
147 | 152 | | else [DeleteEntry(e(f, g))] |
---|
148 | 153 | | |
---|
149 | 154 | | |
---|
150 | | - | @Verifier(T) |
---|
151 | | - | func U () = { |
---|
152 | | - | let V = getString(this, b) |
---|
153 | | - | if (isDefined(V)) |
---|
| 155 | + | @Verifier(V) |
---|
| 156 | + | func W () = { |
---|
| 157 | + | let X = getString(this, b) |
---|
| 158 | + | if (isDefined(X)) |
---|
154 | 159 | | then { |
---|
155 | | - | let W = getString(addressFromStringValue(value(V)), c) |
---|
156 | | - | if (isDefined(W)) |
---|
157 | | - | then valueOrElse(getBoolean(addressFromStringValue(value(W)), ((("status_" + toString(this)) + "_") + toBase58String(T.id))), false) |
---|
| 160 | + | let Y = getString(addressFromStringValue(value(X)), c) |
---|
| 161 | + | if (isDefined(Y)) |
---|
| 162 | + | then valueOrElse(getBoolean(addressFromStringValue(value(Y)), ((("status_" + toString(this)) + "_") + toBase58String(V.id))), false) |
---|
158 | 163 | | else throw("unable to verify: admin not set in coordinator") |
---|
159 | 164 | | } |
---|
160 | | - | else sigVerify(T.bodyBytes, T.proofs[0], T.senderPublicKey) |
---|
| 165 | + | else sigVerify(V.bodyBytes, V.proofs[0], V.senderPublicKey) |
---|
161 | 166 | | } |
---|
162 | 167 | | |
---|