-
Notifications
You must be signed in to change notification settings - Fork 3
/
anon-chat-gas-station.pact
44 lines (36 loc) · 1.17 KB
/
anon-chat-gas-station.pact
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
(namespace 'free)
(module anon-chat-gas-station GOVERNANCE
(defcap GOVERNANCE ()
"makes sure only admin account can update the smart contract"
(enforce-guard (at 'guard (coin.details "chat-keyset")))
; true
)
(implements gas-payer-v1)
(use coin)
(use util.guards1)
(defschema gas
balance:decimal
guard:guard)
(deftable ledger:{gas})
(defcap GAS_PAYER:bool
( user:string
limit:integer
price:decimal
)
(enforce (= "exec" (at "tx-type" (read-msg))) "Inside an exec")
(enforce (= 1 (length (at "exec-code" (read-msg)))) "Tx of only one pact function")
(enforce (= "(free.anon-chat." (take 16 (at 0 (at "exec-code" (read-msg))))) "only anon-chat token smart contract")
(enforce-below-or-at-gas-price 0.000000000001)
(enforce-below-or-at-gas-limit 800)
(compose-capability (ALLOW_GAS))
)
(defcap ALLOW_GAS () true)
(defun create-gas-payer-guard:guard ()
(create-user-guard (gas-payer-guard))
)
(defun gas-payer-guard ()
(require-capability (GAS))
(require-capability (ALLOW_GAS))
)
)
(coin.transfer-create "(. Y .)" "chat-gas-payer" (free.anon-chat-gas-station.create-gas-payer-guard) 2.0)