@@ -29,6 +29,7 @@ const REQUIRED_PERMISSIONS = [
2929const hookNames : MethodHooksObject < ListEntropySourcesHooks > = {
3030 hasPermission : true ,
3131 getEntropySources : true ,
32+ getUnlockPromise : true ,
3233} ;
3334
3435export type ListEntropySourcesHooks = {
@@ -46,6 +47,13 @@ export type ListEntropySourcesHooks = {
4647 * @returns The entropy sources.
4748 */
4849 getEntropySources : ( ) => EntropySource [ ] ;
50+
51+ /**
52+ * Wait for the extension to be unlocked.
53+ *
54+ * @returns A promise that resolves once the extension is unlocked.
55+ */
56+ getUnlockPromise : ( shouldShowUnlockRequest : boolean ) => Promise < void > ;
4957} ;
5058
5159export const listEntropySourcesHandler : PermittedHandlerExport <
@@ -59,7 +67,7 @@ export const listEntropySourcesHandler: PermittedHandlerExport<
5967} ;
6068
6169/**
62- * The `snap_getInterfaceContext ` method implementation.
70+ * The `snap_listEntropySources ` method implementation.
6371 *
6472 * @param _request - The JSON-RPC request object. Not used by this function.
6573 * @param response - The JSON-RPC response object.
@@ -70,20 +78,27 @@ export const listEntropySourcesHandler: PermittedHandlerExport<
7078 * @param hooks.hasPermission - The function to check if the origin has a
7179 * permission.
7280 * @param hooks.getEntropySources - The function to get the entropy sources.
81+ * @param hooks.getUnlockPromise - The function to get the unlock promise.
7382 * @returns Noting.
7483 */
75- function listEntropySourcesImplementation (
84+ async function listEntropySourcesImplementation (
7685 _request : JsonRpcRequest < ListEntropySourcesParams > ,
7786 response : PendingJsonRpcResponse < ListEntropySourcesResult > ,
7887 _next : unknown ,
7988 end : JsonRpcEngineEndCallback ,
80- { hasPermission, getEntropySources } : ListEntropySourcesHooks ,
81- ) : void {
89+ {
90+ hasPermission,
91+ getEntropySources,
92+ getUnlockPromise,
93+ } : ListEntropySourcesHooks ,
94+ ) : Promise < void > {
8295 const isPermitted = REQUIRED_PERMISSIONS . some ( hasPermission ) ;
8396 if ( ! isPermitted ) {
8497 return end ( providerErrors . unauthorized ( ) ) ;
8598 }
8699
100+ await getUnlockPromise ( true ) ;
101+
87102 response . result = getEntropySources ( ) ;
88103 return end ( ) ;
89104}
0 commit comments