2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | func getValue (json,key) = if ((key != "first_name")) |
---|
5 | | - | then throw("You cannot update this property") |
---|
6 | | - | else { |
---|
7 | | - | let keyIndex = value(indexOf(json, (("\"" + key) + "\":"))) |
---|
8 | | - | let data = drop(json, ((keyIndex + size(key)) + 3)) |
---|
9 | | - | data |
---|
10 | | - | } |
---|
11 | | - | |
---|
12 | | - | |
---|
13 | | - | func getJsonBeforeKey (json,key) = if ((key != "first_name")) |
---|
14 | | - | then throw("You cannot update this property") |
---|
15 | | - | else { |
---|
16 | | - | let keyIndex = value(indexOf(json, (("\"" + key) + "\":"))) |
---|
17 | | - | let data = take(json, ((keyIndex + size(key)) + 3)) |
---|
18 | | - | data |
---|
19 | | - | } |
---|
20 | | - | |
---|
21 | | - | |
---|
22 | | - | func getJsonAfterKey (json,key,oldValueSize) = if ((key != "first_name")) |
---|
23 | | - | then throw("You cannot update this property") |
---|
24 | | - | else { |
---|
25 | | - | let keyIndex = value(indexOf(json, (("\"" + key) + "\":"))) |
---|
26 | | - | let data = takeRight(json, (size(json) - ((((keyIndex + size(key)) + 3) + oldValueSize) + 2))) |
---|
27 | | - | data |
---|
28 | | - | } |
---|
29 | | - | |
---|
30 | | - | |
---|
31 | | - | func getValueString (json) = take(drop(json, 1), value(indexOf(drop(json, 1), "\""))) |
---|
32 | | - | |
---|
33 | | - | |
---|
34 | | - | @Callable(i) |
---|
35 | | - | func testUpdateJsonKeyValue (jsonKey,key,newValue) = { |
---|
36 | | - | let valueJSON = match getString(this, jsonKey) { |
---|
37 | | - | case s: String => |
---|
38 | | - | s |
---|
39 | | - | case _ => |
---|
40 | | - | throw("The key doesn't exist") |
---|
41 | | - | } |
---|
42 | | - | let valueBeforeJson = getJsonBeforeKey(valueJSON, key) |
---|
43 | | - | let valueAfterJson = getJsonAfterKey(valueJSON, key, size(getValueString(getValue(valueJSON, key)))) |
---|
44 | | - | let valueInJson = getValueString(getValue(valueJSON, key)) |
---|
45 | | - | if ((valueInJson == newValue)) |
---|
46 | | - | then throw("same value so no changes") |
---|
47 | | - | else WriteSet([DataEntry(jsonKey, ((((valueBeforeJson + "\"") + newValue) + "\"") + valueAfterJson))]) |
---|
48 | | - | } |
---|
49 | | - | |
---|
50 | | - | |
---|
| 2 | + | {-# CONTENT_TYPE EXPRESSION #-} |
---|
| 3 | + | match tx { |
---|
| 4 | + | case t: TransferTransaction => |
---|
| 5 | + | let passwordHash = "c788cd1aa394b03ef75a74ed724aa55656f67b73401b5e222fae361c9c16f70e" |
---|
| 6 | + | let passSecret = toBase16String(sha256(tx.proofs[1])) |
---|
| 7 | + | if (if ((passwordHash == passSecret)) |
---|
| 8 | + | then sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) |
---|
| 9 | + | else false) |
---|
| 10 | + | then true |
---|
| 11 | + | else throw(passSecret) |
---|
| 12 | + | case _ => |
---|
| 13 | + | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) |
---|
| 14 | + | } |
---|