This repository has been archived by the owner on Oct 23, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3859682
commit 9ee0393
Showing
12 changed files
with
298 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
root: true, | ||
|
||
extends: ['../../.eslintrc.js'], | ||
|
||
ignorePatterns: ['!.eslintrc.js', 'dist/', 'build/'], | ||
}; |
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,9 @@ | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [Unreleased] | ||
|
||
[Unreleased]: https://github.com/MetaMask/test-snaps/ |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,64 @@ | ||
{ | ||
"name": "@metamask/test-snap-cronjob", | ||
"version": "4.5.0", | ||
"description": "MetaMask Cronjob Test Snap", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/MetaMask/test-snaps.git" | ||
}, | ||
"publishConfig": { | ||
"access": "public", | ||
"registry": "https://registry.npmjs.org/" | ||
}, | ||
"files": [ | ||
"dist/", | ||
"snap.manifest.json", | ||
"images/icon.svg" | ||
], | ||
"scripts": { | ||
"build": "mm-snap build --eval false", | ||
"build:dev": "yarn build", | ||
"build:clean": "yarn clean && yarn build", | ||
"clean": "rimraf 'dist/*'", | ||
"start": "mm-snap watch", | ||
"test": "jest --passWithNoTests", | ||
"test:watch": "jest --watch", | ||
"lint:eslint": "eslint . --cache --ext js,ts", | ||
"lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' '**/*.yml' --single-quote --ignore-path ../../.prettierignore --no-error-on-unmatched-pattern", | ||
"lint": "yarn lint:eslint && yarn lint:misc --check", | ||
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write", | ||
"lint:changelog": "yarn auto-changelog validate" | ||
}, | ||
"dependencies": { | ||
"@metamask/snaps-types": "^0.26.2", | ||
"@metamask/snaps-ui": "^0.27.1" | ||
}, | ||
"devDependencies": { | ||
"@metamask/auto-changelog": "^2.5.0", | ||
"@metamask/eslint-config": "^6.0.0", | ||
"@metamask/eslint-config-jest": "^6.0.0", | ||
"@metamask/eslint-config-nodejs": "^6.0.0", | ||
"@metamask/eslint-config-typescript": "^6.0.0", | ||
"@metamask/snaps-cli": "^0.26.2", | ||
"@types/jest": "^26.0.13", | ||
"@typescript-eslint/eslint-plugin": "^5.19.0", | ||
"@typescript-eslint/parser": "^5.19.0", | ||
"eslint": "^7.30.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-import": "^2.23.4", | ||
"eslint-plugin-jest": "^24.4.0", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-prettier": "^3.4.0", | ||
"jest": "^26.4.2", | ||
"prettier": "^2.2.1", | ||
"rimraf": "^3.0.2", | ||
"ts-jest": "^26.3.0", | ||
"ts-node": "^9.0.0", | ||
"typescript": "^4.4.0" | ||
}, | ||
"engines": { | ||
"node": ">=16.0.0" | ||
} | ||
} |
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,7 @@ | ||
module.exports = { | ||
cliOptions: { | ||
port: 8010, | ||
src: './src/index.ts', | ||
transpilationMode: 'localOnly', | ||
}, | ||
}; |
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,34 @@ | ||
{ | ||
"version": "4.5.0", | ||
"description": "A MetaMask Test Snap that uses the cronjob endowment", | ||
"proposedName": "MetaMask Cronjob Test Snap", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/MetaMask/test-snaps.git" | ||
}, | ||
"source": { | ||
"shasum": "BFD6zxK5fNJ9TO3iICSA/SfPjlpUUxQtO7kwpyx7NDE=", | ||
"location": { | ||
"npm": { | ||
"filePath": "dist/bundle.js", | ||
"iconPath": "images/icon.svg", | ||
"packageName": "@metamask/test-snap-cronjob", | ||
"registry": "https://registry.npmjs.org/" | ||
} | ||
} | ||
}, | ||
"initialPermissions": { | ||
"endowment:cronjob": { | ||
"jobs": [ | ||
{ | ||
"expression": "* * * * *", | ||
"request": { | ||
"method": "fireCronjob" | ||
} | ||
} | ||
] | ||
}, | ||
"snap_dialog": {} | ||
}, | ||
"manifestVersion": "0.1" | ||
} |
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,17 @@ | ||
import { OnCronjobHandler } from '@metamask/snaps-types'; | ||
import { panel, text, heading } from '@metamask/snaps-ui'; | ||
|
||
export const onCronjob: OnCronjobHandler = async ({ request }) => { | ||
switch (request.method) { | ||
case 'fireCronjob': | ||
return snap.request({ | ||
method: 'snap_dialog', | ||
params: { | ||
type: 'Alert', | ||
content: panel([heading('Cronjob'), text('fired')]), | ||
}, | ||
}); | ||
default: | ||
throw new Error('Method not found.'); | ||
} | ||
}; |
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,9 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "build", | ||
"rootDir": "src" | ||
}, | ||
"exclude": ["./src/**/*.test.ts", "./build"], | ||
"include": ["./src/**/*.ts"] | ||
} |
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,16 @@ | ||
import { FunctionComponent } from 'react'; | ||
import { Snap } from '../../components'; | ||
|
||
const CRONJOB_SNAP_ID = 'npm:@metamask/test-snap-cronjob'; | ||
const CRONJOB_SNAP_PORT = 8010; | ||
|
||
export const Cronjob: FunctionComponent = () => { | ||
return ( | ||
<Snap | ||
name="Cronjob Snap" | ||
snapId={CRONJOB_SNAP_ID} | ||
port={CRONJOB_SNAP_PORT} | ||
testId="CronjobSnap" | ||
></Snap> | ||
); | ||
}; |
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 @@ | ||
export * from './Cronjob'; |
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