Skip to content

Commit

Permalink
Initial setup (#5)
Browse files Browse the repository at this point in the history
* 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
FrederikBolding authored Jan 5, 2023
1 parent 97d94ec commit 2497d45
Show file tree
Hide file tree
Showing 16 changed files with 289 additions and 1,180 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
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
8 changes: 0 additions & 8 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,3 @@ Are there any issues or other links reviewers should consult to understand this
* Fixes #12345
* See: #67890
-->

## Examples

<!--
Are there any examples of this change being used in another repository?
When considering changes to the MetaMask module template, it's strongly preferred that the change be experimented with in another repository first. This gives reviewers a better sense of how the change works, making it less likely the change will need to be reverted or adjusted later.
-->
36 changes: 0 additions & 36 deletions .github/workflows/publish-docs.yml

This file was deleted.

14 changes: 0 additions & 14 deletions .github/workflows/publish-main-docs.yml

This file was deleted.

26 changes: 0 additions & 26 deletions .github/workflows/publish-rc-docs.yml

This file was deleted.

31 changes: 0 additions & 31 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,34 +77,3 @@ jobs:
npm-token: ${{ secrets.NPM_TOKEN }}
env:
SKIP_PREPACK: true

get-release-version:
runs-on: ubuntu-latest
needs: publish-npm
outputs:
RELEASE_VERSION: ${{ steps.get-release-version.outputs.RELEASE_VERSION }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.sha }}
- id: get-release-version
shell: bash
run: ./scripts/get.sh ".version" "RELEASE_VERSION"

publish-release-to-gh-pages:
needs: get-release-version
name: Publish docs to `${{ needs.get-release-version.outputs.RELEASE_VERSION }}` directory of `gh-pages` branch
permissions:
contents: write
uses: ./.github/workflows/publish-docs.yml
with:
destination_dir: ${{ needs.get-release-version.outputs.RELEASE_VERSION }}

publish-release-to-latest-gh-pages:
needs: publish-npm
name: Publish docs to `latest` directory of `gh-pages` branch
permissions:
contents: write
uses: ./.github/workflows/publish-docs.yml
with:
destination_dir: latest
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

[Unreleased]: https://github.com/MetaMask/metamask-module-template/
[Unreleased]: https://github.com/MetaMask/snaps-registry/
32 changes: 4 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,14 @@
# MetaMask Module Template
# snaps-registry

This TypeScript module is maintained in the style of the MetaMask team.

## Template Instructions

Follow these instructions when using this template.

- Update the package name
- The package name is referenced in the following places:
- The `name` field of `package.json`
- The README title
- The README "Usage" section
- Update the package description
- The package description is referenced at the beginning of the README, and in the `description` field of `package.json`.
- Update the `repository` field of `package.json` to point at the new repository URL.
- Update the pull request template (`.github/pull_request_template.md`) to remove the `Examples` section that is specific to this template.
- Update the README "Usage" and "API" sections, removing them if they aren't needed.
- Delete these instructions.
A registry containing metadata about verified and blocked Snaps.

## Installation

`yarn add @metamask/this-module`
`yarn add @metamask/snaps-registry`

or

`npm install @metamask/this-module`

## Usage

_Add examples here_

## API

_Add examples here_
`npm install @metamask/snaps-registry`

## Contributing

Expand Down
20 changes: 11 additions & 9 deletions package.json
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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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]",
Expand Down
9 changes: 0 additions & 9 deletions src/index.test.ts

This file was deleted.

55 changes: 46 additions & 9 deletions src/index.ts
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>;
12 changes: 12 additions & 0 deletions src/registry.json
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="
}
]
}
10 changes: 10 additions & 0 deletions src/registry.test.ts
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();
});
});
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
"esModuleInterop": true,
"exactOptionalPropertyTypes": true,
"forceConsistentCasingInFileNames": true,
"lib": ["ES2020"],
"lib": ["ES2020", "DOM"],
"module": "CommonJS",
"moduleResolution": "node",
"noEmit": true,
"noErrorTruncation": true,
"noUncheckedIndexedAccess": true,
"strict": true,
"target": "es2017"
"target": "es2017",
"resolveJsonModule": true
},
"exclude": ["./dist/**/*"]
}
6 changes: 0 additions & 6 deletions typedoc.json

This file was deleted.

Loading

0 comments on commit 2497d45

Please sign in to comment.