1 | | - | {-# STDLIB_VERSION 6 #-} |
---|
2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let SEP = "__" |
---|
5 | | - | |
---|
6 | | - | let contractFilename = "proxy_treasury.ride" |
---|
7 | | - | |
---|
8 | | - | func wrapErr (s) = ((contractFilename + ": ") + s) |
---|
9 | | - | |
---|
10 | | - | |
---|
11 | | - | func throwErr (s) = throw(wrapErr(s)) |
---|
12 | | - | |
---|
13 | | - | |
---|
14 | | - | func keyFactoryAddress () = makeString(["%s", "factory"], SEP) |
---|
15 | | - | |
---|
16 | | - | |
---|
17 | | - | func keyManagerPublicKey () = makeString(["%s", "managerPublicKey"], SEP) |
---|
18 | | - | |
---|
19 | | - | |
---|
20 | | - | let factoryAddressOption = match getString(this, keyFactoryAddress()) { |
---|
21 | | - | case s: String => |
---|
22 | | - | addressFromString(s) |
---|
23 | | - | case _: Unit => |
---|
24 | | - | unit |
---|
25 | | - | case _ => |
---|
26 | | - | throw("Match error") |
---|
27 | | - | } |
---|
28 | | - | |
---|
29 | | - | let factoryAddressOrFail = valueOrErrorMessage(factoryAddressOption, wrapErr("invalid factory address")) |
---|
30 | | - | |
---|
31 | | - | func onlyAddress (i,address) = if ((i.caller == address)) |
---|
32 | | - | then true |
---|
33 | | - | else throwErr("permission denied") |
---|
34 | | - | |
---|
35 | | - | |
---|
36 | | - | func onlyFactory (i) = onlyAddress(i, factoryAddressOrFail) |
---|
37 | | - | |
---|
38 | | - | |
---|
39 | | - | func getManagerPublicKeyOrUnit () = match factoryAddressOption { |
---|
40 | | - | case fa: Address => |
---|
41 | | - | match getString(fa, keyManagerPublicKey()) { |
---|
42 | | - | case pub: String => |
---|
43 | | - | fromBase58String(pub) |
---|
44 | | - | case _ => |
---|
45 | | - | unit |
---|
46 | | - | } |
---|
47 | | - | case _ => |
---|
48 | | - | unit |
---|
49 | | - | } |
---|
50 | | - | |
---|
51 | | - | |
---|
52 | | - | @Callable(i) |
---|
53 | | - | func transferWaves (recipientBytes,amount) = { |
---|
54 | | - | let checkCaller = onlyFactory(i) |
---|
55 | | - | if ((checkCaller == checkCaller)) |
---|
56 | | - | then [ScriptTransfer(Address(recipientBytes), amount, unit)] |
---|
57 | | - | else throw("Strict value is not equal to itself.") |
---|
58 | | - | } |
---|
59 | | - | |
---|
60 | | - | |
---|
61 | | - | @Verifier(tx) |
---|
62 | | - | func verify () = { |
---|
63 | | - | let publicKey = match getManagerPublicKeyOrUnit() { |
---|
64 | | - | case pub: ByteVector => |
---|
65 | | - | pub |
---|
66 | | - | case _ => |
---|
67 | | - | tx.senderPublicKey |
---|
68 | | - | } |
---|
69 | | - | sigVerify(tx.bodyBytes, tx.proofs[0], publicKey) |
---|
70 | | - | } |
---|
71 | | - | |
---|
| 1 | + | # no script |
---|