6 | | - | let b = "" |
---|
7 | | - | |
---|
8 | | - | let c = "farmNft_nextNumber" |
---|
9 | | - | |
---|
10 | | - | let d = "Assotiated Farm NFT" |
---|
11 | | - | |
---|
12 | | - | let e = "Assotiated Cow NFT" |
---|
13 | | - | |
---|
14 | | - | let f = "{\"image\": \"" |
---|
15 | | - | |
---|
16 | | - | let g = "ACTIVE" |
---|
17 | | - | |
---|
18 | | - | let h = "INACTIVE" |
---|
19 | | - | |
---|
20 | | - | let i = "FATTEN" |
---|
21 | | - | |
---|
22 | | - | func j (k) = { |
---|
23 | | - | let l = getInteger(this, k) |
---|
24 | | - | if ($isInstanceOf(l, "Int")) |
---|
25 | | - | then { |
---|
26 | | - | let m = l |
---|
27 | | - | m |
---|
28 | | - | } |
---|
29 | | - | else 0 |
---|
30 | | - | } |
---|
31 | | - | |
---|
32 | | - | |
---|
33 | | - | func n (k) = { |
---|
34 | | - | let l = getString(this, k) |
---|
35 | | - | if ($isInstanceOf(l, "String")) |
---|
36 | | - | then { |
---|
37 | | - | let o = l |
---|
38 | | - | o |
---|
39 | | - | } |
---|
40 | | - | else "" |
---|
41 | | - | } |
---|
42 | | - | |
---|
43 | | - | |
---|
44 | | - | func p (q) = if (if ((q == a)) |
---|
45 | | - | then true |
---|
46 | | - | else (q == b)) |
---|
47 | | - | then true |
---|
48 | | - | else false |
---|
49 | | - | |
---|
50 | | - | |
---|
51 | | - | @Callable(r) |
---|
52 | | - | func registerFarm (s,t) = { |
---|
53 | | - | let q = toBase58String(r.callerPublicKey) |
---|
54 | | - | if (p(q)) |
---|
55 | | - | then { |
---|
56 | | - | let u = addressFromStringValue(s) |
---|
57 | | - | let v = split_4C(t, "|") |
---|
58 | | - | let w = $Tuple3(v[0], v[1], v[2]) |
---|
59 | | - | let x = w._1 |
---|
60 | | - | let y = w._2 |
---|
61 | | - | let z = w._3 |
---|
62 | | - | let A = j(c) |
---|
63 | | - | if ((A == A)) |
---|
64 | | - | then { |
---|
65 | | - | let B = Issue((d + toString(A)), ((f + z) + "\"}"), 1, 0, false) |
---|
66 | | - | let C = calculateAssetId(B) |
---|
67 | | - | [B, ScriptTransfer(u, 1, C), IntegerEntry(c, (A + 1)), StringEntry((("farm_" + s) + "_name"), x), StringEntry((("farm_" + s) + "_location"), y)] |
---|
68 | | - | } |
---|
69 | | - | else throw("Strict value is not equal to itself.") |
---|
70 | | - | } |
---|
71 | | - | else throw("Not allowed caller") |
---|
72 | | - | } |
---|
73 | | - | |
---|
74 | | - | |
---|
75 | | - | |
---|
76 | | - | @Callable(r) |
---|
77 | | - | func registerCow (s,t) = { |
---|
78 | | - | let q = toBase58String(r.callerPublicKey) |
---|
79 | | - | if (p(q)) |
---|
80 | | - | then { |
---|
81 | | - | let u = addressFromStringValue(s) |
---|
82 | | - | let v = split_4C(t, t) |
---|
83 | | - | let D = $Tuple7(v[0], v[1], v[2], v[3], v[4], v[5], v[6]) |
---|
84 | | - | let E = D._1 |
---|
85 | | - | let F = D._2 |
---|
86 | | - | let G = D._3 |
---|
87 | | - | let H = D._4 |
---|
88 | | - | let I = D._5 |
---|
89 | | - | let J = D._6 |
---|
90 | | - | let z = D._7 |
---|
91 | | - | let K = (((((((((((((("{\"cowCode\": \"" + E) + "\", \"bornedFarmAddress\": \"") + F) + "\", \"genes\": \"") + G) + "\", \"motherId\": \"") + H) + "\", \"fatherId\": \"") + I) + "\", \"type\": \"") + J) + "\", \"imageLink\": \"") + z) + "\"") |
---|
92 | | - | let B = Issue(e, ((K + z) + "\"}"), 1, 0, false) |
---|
93 | | - | let C = calculateAssetId(B) |
---|
94 | | - | [B, ScriptTransfer(u, 1, C), StringEntry((((("farm_" + s) + "_cow_") + toBase58String(C)) + "_status"), g), StringEntry((("cow_" + toBase58String(C)) + "_owner"), s)] |
---|
95 | | - | } |
---|
96 | | - | else throw("Not allowed caller") |
---|
97 | | - | } |
---|
98 | | - | |
---|
99 | | - | |
---|
100 | | - | |
---|
101 | | - | @Callable(r) |
---|
102 | | - | func init () = [IntegerEntry(c, 1)] |
---|