generated from MetaMask/metamask-module-template
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial setup * Dedupe yarn.lock + fix some issues * Remove build from workflow * Remove unused intersection * Simplify test * Fix lint * Re-add build and publishing * Fix tsconfig * Use utils package * Rename exports * Fix import * Update description, README and PR template
- Loading branch information
1 parent
97d94ec
commit 2497d45
Showing
16 changed files
with
289 additions
and
1,180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Lines starting with '#' are comments. | ||
# Each line is a file pattern followed by one or more owners. | ||
|
||
* @MetaMask/devs | ||
* @MetaMask/snaps-devs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
"name": "@metamask/module-template", | ||
"name": "@metamask/snaps-registry", | ||
"version": "0.0.0", | ||
"description": "The MetaMask Node module template.", | ||
"description": "A registry containing metadata about verified and blocked Snaps.", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/MetaMask/metamask-module-template.git" | ||
"url": "https://github.com/MetaMask/snaps-registry.git" | ||
}, | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
|
@@ -14,7 +14,6 @@ | |
"scripts": { | ||
"build": "tsc --project tsconfig.build.json", | ||
"build:clean": "rimraf dist && yarn build", | ||
"build:docs": "typedoc", | ||
"lint": "yarn lint:eslint && yarn lint:misc --check", | ||
"lint:eslint": "eslint . --cache --ext js,ts", | ||
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write", | ||
|
@@ -23,13 +22,17 @@ | |
"test": "jest && jest-it-up", | ||
"test:watch": "jest --watch" | ||
}, | ||
"dependencies": { | ||
"@metamask/utils": "^3.4.0", | ||
"superstruct": "^1.0.3" | ||
}, | ||
"devDependencies": { | ||
"@lavamoat/allow-scripts": "^2.0.3", | ||
"@metamask/auto-changelog": "^3.1.0", | ||
"@metamask/eslint-config": "^11.0.1", | ||
"@metamask/eslint-config-jest": "^11.0.0", | ||
"@metamask/eslint-config-nodejs": "^11.0.1", | ||
"@metamask/eslint-config-typescript": "^11.0.0", | ||
"@metamask/eslint-config": "^11.1.0", | ||
"@metamask/eslint-config-jest": "^11.1.0", | ||
"@metamask/eslint-config-nodejs": "^11.1.0", | ||
"@metamask/eslint-config-typescript": "^11.1.0", | ||
"@types/jest": "^28.1.6", | ||
"@types/node": "^17.0.23", | ||
"@typescript-eslint/eslint-plugin": "^5.43.0", | ||
|
@@ -48,7 +51,6 @@ | |
"rimraf": "^3.0.2", | ||
"ts-jest": "^28.0.7", | ||
"ts-node": "^10.7.0", | ||
"typedoc": "^0.23.15", | ||
"typescript": "~4.8.4" | ||
}, | ||
"packageManager": "[email protected]", | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,46 @@ | ||
/** | ||
* Example function that returns a greeting for the given name. | ||
* | ||
* @param name - The name to greet. | ||
* @returns The greeting. | ||
*/ | ||
export default function greeter(name: string): string { | ||
return `Hello, ${name}!`; | ||
} | ||
import { | ||
VersionStruct, | ||
VersionRangeStruct, | ||
ChecksumStruct, | ||
} from '@metamask/utils'; | ||
import { | ||
object, | ||
array, | ||
record, | ||
string, | ||
union, | ||
optional, | ||
Infer, | ||
} from 'superstruct'; | ||
|
||
const VerifiedSnapVersionStruct = object({ | ||
checksum: ChecksumStruct, | ||
}); | ||
|
||
export const VerifiedSnapStruct = object({ | ||
id: string(), | ||
versions: record(VersionStruct, VerifiedSnapVersionStruct), | ||
}); | ||
|
||
export const BlockReasonStruct = object({ | ||
explanation: optional(string()), | ||
url: optional(string()), | ||
}); | ||
|
||
export type BlockReason = Infer<typeof BlockReasonStruct>; | ||
|
||
export const BlockedSnapStruct = union([ | ||
object({ | ||
id: string(), | ||
versionRange: VersionRangeStruct, | ||
reason: optional(BlockReasonStruct), | ||
}), | ||
object({ checksum: ChecksumStruct, reason: optional(BlockReasonStruct) }), | ||
]); | ||
|
||
export const SnapsRegistryDatabaseStruct = object({ | ||
verifiedSnaps: record(string(), VerifiedSnapStruct), | ||
blockedSnaps: array(BlockedSnapStruct), | ||
}); | ||
|
||
export type SnapsRegistryDatabase = Infer<typeof SnapsRegistryDatabaseStruct>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"verifiedSnaps": {}, | ||
"blockedSnaps": [ | ||
{ | ||
"id": "npm:@consensys/starknet-snap", | ||
"versionRange": "<0.1.11" | ||
}, | ||
{ | ||
"checksum": "A83r5/ZIcKuKwuAnQHHByVFCuofj7jGK5hOStmHY6A0=" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { assert } from 'superstruct'; | ||
|
||
import { SnapsRegistryDatabaseStruct } from '.'; | ||
import registry from './registry.json'; | ||
|
||
describe('Snaps Registry', () => { | ||
it('has valid format', () => { | ||
expect(() => assert(registry, SnapsRegistryDatabaseStruct)).not.toThrow(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.