-
Notifications
You must be signed in to change notification settings - Fork 2
chore: enable Snap TypeScript checking #237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,18 @@ | ||
| { | ||
| "extends": "../../tsconfig.packages.build.json", | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This package is the only exception so let's not have that root file |
||
| "extends": "./tsconfig.json", | ||
| "compilerOptions": { | ||
| "baseUrl": "./", | ||
| "composite": true, | ||
| "declaration": true, | ||
| "declarationMap": true, | ||
| "emitDeclarationOnly": true, | ||
| "inlineSources": true, | ||
| "noEmit": false, | ||
| "sourceMap": true, | ||
| "outDir": "./dist", | ||
| "rootDir": "./src" | ||
| }, | ||
| "references": [], | ||
| "include": ["../../types", "./src"] | ||
| "include": ["../../types", "./src"], | ||
| "exclude": ["**/*.test.ts", "**/tests", "**/jest.config.ts"] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,5 @@ | |
| "skipLibCheck": true, | ||
| "types": ["jest"] | ||
| }, | ||
| "references": [], | ||
| "include": ["../../types", "./src"] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,12 +59,14 @@ BigNumber.config({ EXPONENTIAL_AT: 16 }); | |
| * @param args - The request handler args as object. | ||
| * @param args.origin - The origin of the request, e.g., the website that | ||
| * invoked the snap. | ||
| * @param args.originMetadata - Metadata reported by the requesting origin. | ||
| * @param args.request - A validated JSON-RPC request object. | ||
| * @returns A promise that resolves to the result of the RPC request. | ||
| * @throws If the request method is not valid for this snap. | ||
| */ | ||
| export const onRpcRequest: OnRpcRequestHandler = async ({ | ||
| origin, | ||
| originMetadata, | ||
| request, | ||
| }) => { | ||
| logger.log('[🔄 onRpcRequest]', request.method, request); | ||
|
|
@@ -84,7 +86,7 @@ export const onRpcRequest: OnRpcRequestHandler = async ({ | |
| } | ||
|
|
||
| const result = await withCatchAndThrowSnapError(async () => | ||
| handler({ origin, request }), | ||
| handler({ origin, originMetadata, request }), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we wanna to support support originMetadata now ? as they are optional from the keyring API bump PR
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah from what I saw I think it complained when I didn't add it |
||
| ); | ||
|
|
||
| return result ?? null; | ||
|
|
@@ -179,13 +181,12 @@ export const onCronjob: OnCronjobHandler = async ({ request }) => { | |
| _logger.log(request.method, request); | ||
|
|
||
| const { method } = request; | ||
| assert( | ||
| method, | ||
| enums([ | ||
| ...Object.values(CronjobMethod), | ||
| ...Object.values(ScheduleBackgroundEventMethod), | ||
| ]), | ||
| ); | ||
| const validMethods = [ | ||
| ...Object.values(CronjobMethod), | ||
| ...Object.values(ScheduleBackgroundEventMethod), | ||
| ]; | ||
|
|
||
| assert(method, enums(validMethods as [string, ...string[]])); | ||
|
|
||
| const result = await withCatchAndThrowSnapError(async () => { | ||
| _logger.log('Running cronjob', { method }); | ||
|
|
@@ -197,10 +198,7 @@ export const onCronjob: OnCronjobHandler = async ({ request }) => { | |
|
|
||
| if (!handler) { | ||
| throw new MethodNotFoundError( | ||
| `Cronjob / ScheduleBackgroundEvent method ${String(method)} not found. Available methods: ${[ | ||
| ...Object.values(CronjobMethod), | ||
| ...Object.values(ScheduleBackgroundEventMethod), | ||
| ].join(',')}`, | ||
| `Cronjob / ScheduleBackgroundEvent method ${method} not found. Available methods: ${validMethods.toString()}`, | ||
| ) as unknown as Error; | ||
| } | ||
| return handler({ request }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed these to match the other Snaps