Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
KillianH committed Jan 5, 2025
1 parent 93278c4 commit 88f3cc7
Show file tree
Hide file tree
Showing 43 changed files with 8,929 additions and 6,617 deletions.
15 changes: 4 additions & 11 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
module.exports = {
root: true,

parserOptions: {
sourceType: 'module',
},
env: {
jest: true,
},

extends: ['@metamask/eslint-config'],

overrides: [
{
files: ['**/*.js'],
files: ['*.js'],
extends: ['@metamask/eslint-config-nodejs'],
},

{
files: ['**/*.{ts,tsx}'],
files: ['*.ts', '*.tsx'],
extends: ['@metamask/eslint-config-typescript'],
rules: {
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
},
},

{
files: ['**/*.test.ts', '**/*.test.js'],
files: ['*.test.ts', '*.test.js'],
extends: ['@metamask/eslint-config-jest'],
rules: {
'@typescript-eslint/no-shadow': [
Expand All @@ -39,11 +34,9 @@ module.exports = {
'!.prettierrc.js',
'**/!.eslintrc.js',
'**/dist*/',
'**/docs*/',
'**/*__GENERATED__*',
'**/build',
'**/public',
'**/.cache',
'**/truffle',
],
};
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,8 @@ node_modules/
.yarn/install-state.gz
.pnp.*

packages/snap/.yalc/

packages/snap/yalc.lock

.idea/
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16
lts/*
9 changes: 9 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-allow-scripts.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable */
//prettier-ignore
module.exports = {
name: "@yarnpkg/plugin-allow-scripts",
factory: function (require) {
var plugin=(()=>{var l=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var p=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(o,e)=>(typeof require<"u"?require:o)[e]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var u=(t,o)=>{for(var e in o)l(t,e,{get:o[e],enumerable:!0})},f=(t,o,e,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of a(o))!c.call(t,i)&&i!==e&&l(t,i,{get:()=>o[i],enumerable:!(r=s(o,i))||r.enumerable});return t};var m=t=>f(l({},"__esModule",{value:!0}),t);var g={};u(g,{default:()=>d});var n=p("@yarnpkg/shell"),x={hooks:{afterAllInstalled:async()=>{let t=await(0,n.execute)("yarn run allow-scripts");t!==0&&process.exit(t)}}},d=x;return m(g);})();
return plugin;
}
};
786 changes: 0 additions & 786 deletions .yarn/releases/yarn-3.2.1.cjs

This file was deleted.

12 changes: 10 additions & 2 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
enableScripts: false

enableTelemetry: 0

logFilters:
- code: YN0004
level: discard

nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: '@yarnpkg/plugin-workspace-tools'

yarnPath: .yarn/releases/yarn-3.2.1.cjs
- path: .yarn/plugins/@yarnpkg/plugin-allow-scripts.cjs
spec: 'https://raw.githubusercontent.com/LavaMoat/LavaMoat/main/packages/yarn-plugin-allow-scripts/bundles/@yarnpkg/plugin-allow-scripts.js'
78 changes: 34 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,63 +1,53 @@
# Casper Snap
# @metamask/template-snap-monorepo

Snap to enable MetaMask users interaction with [Casper](https://docs.casperlabs.io/) dapps.
For detailed documentation and integration instructions see our [helper](https://casper-ecosystem.github.io/casper-manager/).
This repository demonstrates how to develop a snap with TypeScript. For detailed
instructions, see [the MetaMask documentation](https://docs.metamask.io/guide/snaps.html#serving-a-snap-to-your-local-environment).

Read the [FAQ](FAQ.md) and the [Knowledge Base](KnowledgeBase.md).
MetaMask Snaps is a system that allows anyone to safely expand the capabilities
of MetaMask. A _snap_ is a program that we run in an isolated environment that
can customize the wallet experience.

## Testing Casper Snap
## Snaps is pre-release software

The snap have been audited by [Halborn](https://www.halborn.com/) on the 20th June 2023.
You can find the audit [here](./audits/20_06_2023_Casper_Management_Snap_App_WebApp_Pentest_Report_Halborn_Final.pdf).
You can find the code difference between the audit and now [here](https://github.com/casper-ecosystem/casper-manager/compare/halbornAudit...main).
To interact with (your) Snaps, you will need to install [MetaMask Flask](https://metamask.io/flask/),
a canary distribution for developers that provides access to upcoming features.

## Testing Casper Manager Snap
## Getting Started

### MetaMask Snaps Open Beta
The MetaMask Snaps Open Beta is a first look at what's possible when extending the capabilities of your wallet. We invite those who are comfortable trying new features to test out these Snaps built by talented community developers.
Clone the template-snap repository [using this template](https://github.com/MetaMask/template-snap-monorepo/generate)
and set up the development environment:

### Live demo dapp

Test Casper Snap inside [CasperHolders Testnet](https://testnet.casperholders.io/) or [Div3](https://div3.in).

## Development

### Requirements

```
node version 16 or above
```shell
yarn install && yarn start
```

### Usage
## Cloning

- For nvm users
This repository contains GitHub Actions that you may find useful, see
`.github/workflows` and [Releasing & Publishing](https://github.com/MetaMask/template-snap-monorepo/edit/main/README.md#releasing--publishing)
below for more information.

```sh
nvm use
```
If you clone or create this repository outside the MetaMask GitHub organization,
you probably want to run `./scripts/cleanup.sh` to remove some files that will
not work properly outside the MetaMask GitHub organization.

---
If you don't wish to use any of the existing GitHub actions in this repository,
simply delete the `.github/workflows` directory.

- Enable corepack
## Contributing

```sh
corepack enable
```
### Testing and Linting

- Install packages
Run `yarn test` to run the tests once.

```sh
yarn install
```
Run `yarn lint` to run the linter, or run `yarn lint:fix` to run the linter and
fix any automatically fixable issues.

- Run local snap server
### Using NPM packages with scripts

```sh
yarn start
```
Scripts are disabled by default for security reasons. If you need to use NPM
packages with scripts, you can run `yarn allow-scripts auto`, and enable the
script in the `lavamoat.allowScripts` section of `package.json`.

- Run snap tests

```sh
yarn test
```
See the documentation for [@lavamoat/allow-scripts](https://github.com/LavaMoat/LavaMoat/tree/main/packages/allow-scripts)
for more information.
84 changes: 32 additions & 52 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
{
"name": "@metamask/snap-box",
"version": "1.0.4",
"private": true,
"name": "root",
"version": "0.1.0",
"description": "",
"homepage": "https://github.com/MetaMask/snap-box#readme",
"homepage": "https://github.com/MetaMask/template-snap-monorepo#readme",
"bugs": {
"url": "https://github.com/MetaMask/snap-box/issues"
"url": "https://github.com/MetaMask/template-snap-monorepo/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/MetaMask/snap-box.git"
"url": "git+https://github.com/MetaMask/template-snap-monorepo.git"
},
"license": "(MIT-0 OR Apache-2.0)",
"author": "",
Expand All @@ -19,61 +18,42 @@
"scripts": {
"build": "yarn workspaces foreach --parallel --topological --verbose run build",
"lint": "yarn lint:eslint && yarn lint:misc --check",
"lint:eslint": "eslint . --cache --ext js,ts",
"lint:eslint": "eslint . --cache --ext js,jsx,ts,tsx",
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
"lint:misc": "prettier '**/*.json' '**/*.md' '!**/CHANGELOG.md' '**/*.yml' --ignore-path .gitignore",
"release": "release-it",
"start": "yarn workspaces foreach --parallel --interlaced --verbose run start",
"test": "yarn workspaces foreach --parallel --verbose run test"
"test": "yarn workspace snap run test"
},
"devDependencies": {
"@metamask/eslint-config": "10.0.0",
"@metamask/eslint-config-jest": "10.0.0",
"@metamask/eslint-config-nodejs": "10.0.0",
"@metamask/eslint-config-typescript": "10.0.0",
"@playwright/test": "1.34.3",
"@release-it-plugins/workspaces": "^3.2.0",
"@types/isomorphic-fetch": "0.0.36",
"@types/jest": "29.5.1",
"@typescript-eslint/eslint-plugin": "5.59.7",
"@typescript-eslint/parser": "5.59.7",
"eslint": "8.41.0",
"eslint-config-prettier": "8.8.0",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-jest": "26.9.0",
"eslint-plugin-jsdoc": "39.9.1",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-prettier": "4.2.1",
"jest": "29.5.0",
"prettier": "2.8.8",
"prettier-plugin-packagejson": "2.4.3",
"release-it": "15.10.3",
"ts-jest": "29.1.0",
"typescript": "4.9.5"
"@lavamoat/allow-scripts": "^3.0.0",
"@lavamoat/preinstall-always-fail": "^2.0.0",
"@metamask/eslint-config": "^12.2.0",
"@metamask/eslint-config-jest": "^12.1.0",
"@metamask/eslint-config-nodejs": "^12.1.0",
"@metamask/eslint-config-typescript": "^12.1.0",
"@typescript-eslint/eslint-plugin": "^5.42.1",
"@typescript-eslint/parser": "^5.42.1",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "~2.26.0",
"eslint-plugin-jest": "^27.1.5",
"eslint-plugin-jsdoc": "^41.1.2",
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
"prettier": "^2.7.1",
"prettier-plugin-packagejson": "^2.2.18",
"sharp": "^0.32.6",
"typescript": "5.1.6"
},
"packageManager": "[email protected]",
"engines": {
"node": ">=16.0.0"
"node": ">=18.6.0"
},
"release-it": {
"plugins": {
"@release-it-plugins/workspaces": {
"workspaces": [
"packages/snap",
"packages/lib"
]
}
},
"git": {
"requireCleanWorkingDir": false,
"commitMessage": "chore: release v${version}"
},
"hooks": {
"after:bump": "yarn build"
},
"npm": false,
"github": {
"release": true
"lavamoat": {
"allowScripts": {
"@lavamoat/preinstall-always-fail": false,
"sharp": true
}
}
}
8 changes: 4 additions & 4 deletions packages/lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
"test": "exit 0"
},
"dependencies": {
"@metamask/providers": "10.2.1",
"buffer": "5.7.1",
"casper-js-sdk": "2.14.0"
"@metamask/providers": "18.3.1",
"buffer": "6.0.3",
"casper-js-sdk": "5.0.2-beta2"
},
"devDependencies": {
"esdoc-typescript-plugin": "1.0.1",
"typedoc": "0.23.28"
"typedoc": "0.27.5"
}
}
Loading

0 comments on commit 88f3cc7

Please sign in to comment.