@@ -68,16 +68,21 @@ pub contract FlowContractAudits {
68
68
// Auditors can create new vouchers and remove them
69
69
pub resource Auditor {
70
70
71
- // Create new voucher
71
+ // Create new voucher with contract code
72
72
pub fun addVoucher (address : Address ?, recurrent : Bool , expiryOffset : UInt64 ?, code : String ) {
73
+ let codeHash = FlowContractAudits.hashContractCode (code)
74
+ self .addVoucherHashed (address : address, recurrent : recurrent, expiryOffset : expiryOffset, codeHash : codeHash)
75
+ }
76
+
77
+ // Create new voucher with hashed contract code
78
+ pub fun addVoucherHashed (address : Address ?, recurrent : Bool , expiryOffset : UInt64 ?, codeHash : String ) {
73
79
74
80
// calculate expiry block height based on expiryOffset
75
81
var expiryBlockHeight : UInt64 ? = nil
76
82
if expiryOffset ! = nil {
77
83
expiryBlockHeight = getCurrentBlock ().height + expiryOffset!
78
84
}
79
-
80
- let codeHash = FlowContractAudits.hashContractCode (code)
85
+
81
86
let key = FlowContractAudits.generateVoucherKey (address : address, codeHash : codeHash)
82
87
83
88
// if a voucher with the same key exists, remove it first
@@ -115,6 +120,10 @@ pub contract FlowContractAudits {
115
120
self .auditorCapability! .borrow ()! .addVoucher (address : address, recurrent : recurrent, expiryOffset : expiryOffset, code : code)
116
121
}
117
122
123
+ pub fun addVoucherHashed (address : Address ?, recurrent : Bool , expiryOffset : UInt64 ?, codeHash : String ) {
124
+ self .auditorCapability! .borrow ()! .addVoucherHashed (address : address, recurrent : recurrent, expiryOffset : expiryOffset, codeHash : codeHash)
125
+ }
126
+
118
127
pub fun deleteVoucher (key : String ) {
119
128
self .auditorCapability! .borrow ()! .deleteVoucher (key : key)
120
129
}
0 commit comments