-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdao-factory-gas.pact
55 lines (42 loc) · 1.1 KB
/
dao-factory-gas.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
45
46
47
48
49
50
51
52
53
54
55
(namespace 'free)
(module dao-hive-gas GOVERNANCE
(defcap GOVERNANCE ()
true
)
(implements gas-payer-v1)
(use coin)
(defschema gas
balance:decimal
guard:guard)
(deftable ledger:{gas})
(defcap GAS_PAYER:bool
( user:string
limit:integer
price:decimal
)
(compose-capability (ALLOW_GAS))
)
(defun chain-gas-price ()
(at 'gas-price (chain-data)))
(defun chain-gas-limit ()
(at 'gas-limit (chain-data)))
(defun enforce-below-or-at-gas-price:bool (gasPrice:decimal)
(enforce (<= (chain-gas-price) gasPrice)
(format "Gas Price > {}" [gasPrice])))
(defun enforce-below-or-at-gas-limit:bool (gasLimit:integer)
(enforce (<= (chain-gas-limit) gasLimit)
(format "Gas limit > {}" [gasLimit])))
(defcap ALLOW_GAS () true)
(defun create-gas-payer-guard:guard ()
(create-user-guard (gas-payer-guard))
)
(defcap DAO_GAS (msg:object)
@event true
)
(defun gas-payer-guard ()
(require-capability (GAS))
(at "miner-keyset" (read-msg))
(enforce-below-or-at-gas-price 0.000001)
(enforce-below-or-at-gas-limit 10000)
)
)