-
Notifications
You must be signed in to change notification settings - Fork 542
/
long-running.ts
43 lines (39 loc) · 1.37 KB
/
long-running.ts
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
import {
PermissionSpecificationBuilder,
PermissionType,
EndowmentGetterParams,
ValidPermissionSpecification,
} from '@metamask/permission-controller';
import { SnapEndowments } from './enum';
const permissionName = SnapEndowments.LongRunning;
type LongRunningEndowmentSpecification = ValidPermissionSpecification<{
permissionType: PermissionType.Endowment;
targetKey: typeof permissionName;
endowmentGetter: (_options?: any) => undefined;
allowedCaveats: null;
}>;
/**
* `endowment:long-running` returns nothing; it is intended to be used as a flag
* by the `SnapController` to make it ignore the request processing timeout
* during snap lifecycle management. Essentially, it allows a snap to take an
* infinite amount of time to process a request.
*
* @param _builderOptions - Optional specification builder options.
* @returns The specification for the long-running endowment.
*/
const specificationBuilder: PermissionSpecificationBuilder<
PermissionType.Endowment,
any,
LongRunningEndowmentSpecification
> = (_builderOptions?: any) => {
return {
permissionType: PermissionType.Endowment,
targetKey: permissionName,
allowedCaveats: null,
endowmentGetter: (_getterOptions?: EndowmentGetterParams) => undefined,
};
};
export const longRunningEndowmentBuilder = Object.freeze({
targetKey: permissionName,
specificationBuilder,
} as const);