@@ -207,8 +207,8 @@ export async function toAddress(name: string, provider: EthersProvider) {
207
207
/**
208
208
* @notice Returns public keys from the recipientId
209
209
* @dev When providing a public key, transaction hash, or address with advanced mode, the spending and viewing
210
- * public keys will be the same. Only keys retrieved from the StealthKeyRegistry will have different spending
211
- * and viewing keys
210
+ * public keys will be the same. Only keys retrieved from the StealthKeyRegistry (or the subgraph) will have different spending
211
+ * and viewing keys. Additionally, the block number when the user registered will be returned.
212
212
* @param id Recipient identifier, must be an ENS name, CNS name, address, transaction hash, or public key
213
213
* @param provider ethers provider to use
214
214
* @param options Object containing lookup options:
@@ -230,15 +230,15 @@ export async function lookupRecipient(
230
230
const isPublicKey = id . length === 132 && isHexString ( id ) ;
231
231
if ( supportPubKey && isPublicKey ) {
232
232
assertValidPoint ( id ) ;
233
- return { spendingPublicKey : id , viewingPublicKey : id } ;
233
+ return { spendingPublicKey : id , viewingPublicKey : id , block : undefined } ;
234
234
}
235
235
236
236
// Check if identifier is a transaction hash. If so, we recover the sender's public keys from the transaction
237
237
const isTxHash = id . length === 66 && isHexString ( id ) ;
238
238
if ( supportTxHash && isTxHash ) {
239
239
const publicKey = await recoverPublicKeyFromTransaction ( id , provider ) ;
240
240
assertValidPoint ( publicKey ) ;
241
- return { spendingPublicKey : publicKey , viewingPublicKey : publicKey } ;
241
+ return { spendingPublicKey : publicKey , viewingPublicKey : publicKey , block : undefined } ;
242
242
}
243
243
244
244
// The remaining checks are dependent on the advanced mode option. The provided identifier is now either an
@@ -259,7 +259,11 @@ export async function lookupRecipient(
259
259
stealthKeyChangedEvent . viewingPubKey ,
260
260
stealthKeyChangedEvent . viewingPubKeyPrefix . toString ( )
261
261
) ;
262
- return { spendingPublicKey : spendingPublicKey , viewingPublicKey : viewingPublicKey } ;
262
+ return {
263
+ spendingPublicKey : spendingPublicKey ,
264
+ viewingPublicKey : viewingPublicKey ,
265
+ block : stealthKeyChangedEvent . block ,
266
+ } ;
263
267
} catch ( error ) {
264
268
if ( error instanceof Error ) {
265
269
console . log ( 'Public key subgraph fetch error: ' , error . message ) ;
@@ -268,7 +272,8 @@ export async function lookupRecipient(
268
272
}
269
273
console . log ( 'Error using subgraph to lookup receipient stealth keys, will query registry contract' ) ;
270
274
const registry = new StealthKeyRegistry ( provider ) ;
271
- return registry . getStealthKeys ( address ) ;
275
+ const { spendingPublicKey, viewingPublicKey } = await registry . getStealthKeys ( address ) ;
276
+ return { spendingPublicKey, viewingPublicKey, block : undefined } ;
272
277
}
273
278
}
274
279
@@ -277,7 +282,7 @@ export async function lookupRecipient(
277
282
if ( ! txHash ) throw new Error ( 'Could not get public key because the provided account has not sent any transactions' ) ;
278
283
const publicKey = await recoverPublicKeyFromTransaction ( txHash , provider ) ;
279
284
assertValidPoint ( publicKey ) ;
280
- return { spendingPublicKey : publicKey , viewingPublicKey : publicKey } ;
285
+ return { spendingPublicKey : publicKey , viewingPublicKey : publicKey , block : undefined } ;
281
286
}
282
287
283
288
export async function getBlockNumberUserRegistered (
0 commit comments