@@ -136,6 +136,12 @@ export function useEncryptedBalance(
136
136
const privateMint = useCallback (
137
137
( recipient : `0x${string } `, amount : bigint ) => {
138
138
if ( ! eerc || ! auditorPublicKey ) throw new Error ( "EERC not initialized" ) ;
139
+ if (
140
+ ! auditorPublicKey . length ||
141
+ auditorPublicKey . some ( ( key ) => key === 0n )
142
+ )
143
+ throw new Error ( "Auditor public key is not set" ) ;
144
+
139
145
return eerc . privateMint ( recipient , amount , auditorPublicKey as Point ) ;
140
146
} ,
141
147
[ eerc , auditorPublicKey ] ,
@@ -149,8 +155,13 @@ export function useEncryptedBalance(
149
155
const privateBurn = useCallback (
150
156
( amount : bigint ) => {
151
157
try {
152
- if ( ! eerc || ! auditorPublicKey || ! balanceState . encrypted . length )
158
+ if ( ! eerc || ! balanceState . encrypted . length )
153
159
throw new Error ( "EERC not initialized" ) ;
160
+ if (
161
+ ! auditorPublicKey . length ||
162
+ auditorPublicKey . some ( ( key ) => key === 0n )
163
+ )
164
+ throw new Error ( "Auditor public key is not set" ) ;
154
165
if ( balanceState . decrypted < amount || amount <= 0n )
155
166
throw new Error ( "Invalid amount" ) ;
156
167
@@ -177,8 +188,13 @@ export function useEncryptedBalance(
177
188
const privateTransfer = useCallback (
178
189
( to : string , amount : bigint ) => {
179
190
try {
180
- if ( ! eerc || ! auditorPublicKey || ! balanceState . encrypted . length )
191
+ if ( ! eerc || ! balanceState . encrypted . length )
181
192
throw new Error ( "EERC not initialized" ) ;
193
+ if (
194
+ ! auditorPublicKey . length ||
195
+ auditorPublicKey . some ( ( key ) => key === 0n )
196
+ )
197
+ throw new Error ( "Auditor public key is not set" ) ;
182
198
if ( balanceState . decrypted < amount || amount <= 0n )
183
199
throw new Error ( "Invalid amount" ) ;
184
200
@@ -209,14 +225,19 @@ export function useEncryptedBalance(
209
225
if ( ! eerc ) throw new Error ( "EERC not initialized" ) ;
210
226
if ( ! tokenAddress ) throw new Error ( "Token address is not set" ) ;
211
227
if ( ! decimals ) throw new Error ( "Decimals not set" ) ;
228
+ if (
229
+ ! auditorPublicKey . length ||
230
+ auditorPublicKey . some ( ( key ) => key === 0n )
231
+ )
232
+ throw new Error ( "Auditor public key is not set" ) ;
212
233
213
234
return eerc . deposit ( amount , tokenAddress , decimals ) ;
214
235
} catch ( error ) {
215
236
console . error ( "Deposit failed" , error ) ;
216
237
throw error ;
217
238
}
218
239
} ,
219
- [ eerc , tokenAddress , decimals ] ,
240
+ [ eerc , tokenAddress , decimals , auditorPublicKey ] ,
220
241
) ;
221
242
222
243
/**
@@ -229,6 +250,11 @@ export function useEncryptedBalance(
229
250
try {
230
251
if ( ! eerc ) throw new Error ( "EERC not initialized" ) ;
231
252
if ( ! tokenAddress ) throw new Error ( "Token address is not set" ) ;
253
+ if (
254
+ ! auditorPublicKey . length ||
255
+ auditorPublicKey . some ( ( key ) => key === 0n )
256
+ )
257
+ throw new Error ( "Auditor public key is not set" ) ;
232
258
233
259
return eerc . withdraw (
234
260
amount ,
0 commit comments