Skip to content

Commit 177126a

Browse files
committed
Add initial setup + pause/unpause commands
1 parent 5eee8ec commit 177126a

26 files changed

Lines changed: 10560 additions & 1 deletion

.eslintrc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
require('@rushstack/eslint-patch/modern-module-resolution')
2+
3+
module.exports = {
4+
root: true,
5+
extends: ['@chainsafe'],
6+
}

.gitignore

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
**/*/node_modules
6+
/.pnp
7+
.pnp.js
8+
9+
# testing
10+
/coverage
11+
12+
# production
13+
/build
14+
/bin
15+
rpcEndpoints.json
16+
17+
# misc
18+
.DS_Store
19+
.env.local
20+
.env.development.local
21+
.env.test.local
22+
.env.production.local
23+
24+
npm-debug.log*
25+
yarn-debug.log*
26+
yarn-error.log*
27+
28+
.env
29+
.vscode
30+
.history
31+
32+
# runtime config
33+
public/chainbridge-runtime-config.js
34+
35+
# IDE
36+
.idea/
37+
38+
.yarn/*
39+
!.yarn/patches
40+
!.yarn/plugins
41+
!.yarn/releases
42+
!.yarn/sdks
43+
!.yarn/versions

@types/gluegun/index.d.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Bridge } from '@buildwithsygma/sygma-contracts'
2+
import { RawConfig } from '@buildwithsygma/sygma-sdk-core'
3+
import { Wallet } from 'ethers'
4+
5+
declare module 'gluegun' {
6+
interface GluegunToolbox {
7+
bridge: {
8+
initBridgeInstances(
9+
rawConfig: RawConfig,
10+
wallets: Array<Wallet | KeyringPair>
11+
): Array<Bridge>
12+
}
13+
wallet: {
14+
initializeWallets(rawConfig: RawConfig): InitializedWallets
15+
}
16+
sharedConfig: {
17+
fetchSharedConfig(): Promise<RawConfig>
18+
}
19+
}
20+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2017
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,13 @@
1-
# maintenance-utils
1+
# maintenance-utils CLI
2+
3+
A CLI for maintenance-utils.
4+
5+
## How to run the maintenance-utils CLI
6+
7+
* populate `rpcEndpoints.json` with your supported networks
8+
* run `yarn build` - this will generate a executable file
9+
10+
## Commands
11+
12+
`bridge pause` - pauses all bridge instances across the selected network
13+
`bridge unpause` - unpauses all bridge instances across the selected network

docs/commands.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Command Reference for maintenance-utils
2+
3+
TODO: Add your command reference here

docs/plugins.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Plugin guide for maintenance-utils
2+
3+
Plugins allow you to add features to maintenance-utils, such as commands and
4+
extensions to the `toolbox` object that provides the majority of the functionality
5+
used by maintenance-utils.
6+
7+
Creating a maintenance-utils plugin is easy. Just create a repo with two folders:
8+
9+
```
10+
commands/
11+
extensions/
12+
```
13+
14+
A command is a file that looks something like this:
15+
16+
```js
17+
// commands/foo.js
18+
19+
module.exports = {
20+
run: (toolbox) => {
21+
const { print, filesystem } = toolbox
22+
23+
const desktopDirectories = filesystem.subdirectories(`~/Desktop`)
24+
print.info(desktopDirectories)
25+
}
26+
}
27+
```
28+
29+
An extension lets you add additional features to the `toolbox`.
30+
31+
```js
32+
// extensions/bar-extension.js
33+
34+
module.exports = (toolbox) => {
35+
const { print } = toolbox
36+
37+
toolbox.bar = () => { print.info('Bar!') }
38+
}
39+
```
40+
41+
This is then accessible in your plugin's commands as `toolbox.bar`.
42+
43+
# Loading a plugin
44+
45+
To load a particular plugin (which has to start with `maintenance-utils-*`),
46+
install it to your project using `npm install --save-dev maintenance-utils-PLUGINNAME`,
47+
and maintenance-utils will pick it up automatically.

package.json

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"name": "maintenance-utils",
3+
"version": "0.0.1",
4+
"description": "maintenance-utils CLI",
5+
"private": true,
6+
"types": "build/types/types.d.ts",
7+
"bin": {
8+
"maintenance-utils": "bin/maintenance-utils"
9+
},
10+
"scripts": {
11+
"clean-build": "rm -rf ./build",
12+
"compile": "tsc -p .",
13+
"copy-templates": "copyfiles ./src/templates/* ./build/templates",
14+
"build": "yarn clean-build && yarn compile && yarn copy-templates",
15+
"prepublishOnly": "yarn build",
16+
"format": "eslint \"src/**/*.{ts,tsx}\" --fix && prettier \"src/**/*.{ts,tsx}\" --write",
17+
"test": "jest",
18+
"watch": "jest --watch",
19+
"snapupdate": "jest --updateSnapshot",
20+
"coverage": "jest --coverage"
21+
},
22+
"files": [
23+
"build",
24+
"LICENSE",
25+
"readme.md",
26+
"docs",
27+
"bin"
28+
],
29+
"license": "MIT",
30+
"dependencies": {
31+
"@buildwithsygma/sygma-contracts": "^2.3.0",
32+
"@polkadot/api": "^10.9.1",
33+
"@polkadot/keyring": "^12.3.2",
34+
"gluegun": "^5.1.2"
35+
},
36+
"devDependencies": {
37+
"@buildwithsygma/sygma-sdk-core": "^2.1.0",
38+
"@chainsafe/eslint-config": "^2.0.0",
39+
"@polkadot/types": "^10.9.1",
40+
"@rushstack/eslint-patch": "^1.3.2",
41+
"@types/jest": "^26.0.20",
42+
"@types/node": "^12.7.11",
43+
"@typescript-eslint/eslint-plugin": "^4.17.0",
44+
"@typescript-eslint/parser": "^4.17.0",
45+
"copyfiles": "^2.4.1",
46+
"eslint": "^7.22.0",
47+
"eslint-config-prettier": "^8.1.0",
48+
"eslint-plugin-prettier": "^3.3.1",
49+
"ethers": "^5",
50+
"jest": "^26.6.3",
51+
"prettier": "^2.2.1",
52+
"pretty-quick": "^3.1.0",
53+
"ts-jest": "^26.5.3",
54+
"ts-node": "^10.9.1",
55+
"typescript": "^5.1.6"
56+
},
57+
"jest": {
58+
"preset": "ts-jest",
59+
"testEnvironment": "node"
60+
},
61+
"prettier": {
62+
"semi": false,
63+
"singleQuote": true
64+
}
65+
}

rpcEndpoints.example.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"chainId": "rpcUrl",
3+
"chainId": "rpcUrl",
4+
"chainId": "rpcUrl"
5+
}

src/cli.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { GluegunToolbox, build } from 'gluegun'
2+
import { Options } from 'gluegun/build/types/domain/options'
3+
4+
/**
5+
* Create the cli and kick it off
6+
*/
7+
async function run(argv: Options): Promise<GluegunToolbox> {
8+
// create a CLI runtime
9+
const cli = build()
10+
.brand('maintenance-utils')
11+
.src(__dirname)
12+
.plugins('./node_modules', {
13+
matching: 'maintenance-utils-*',
14+
hidden: true,
15+
})
16+
.help() // provides default for help, h, --help, -h
17+
.version() // provides default for version, v, --version, -v
18+
.create()
19+
// enable the following method if you'd like to skip loading one of these core extensions
20+
// this can improve performance if they're not necessary for your project:
21+
// .exclude(['meta', 'strings', 'print', 'filesystem', 'semver', 'system', 'prompt', 'http', 'template', 'patching', 'package-manager'])
22+
// and run it
23+
const toolbox = await cli.run(argv).finally(() => process.exit())
24+
25+
// send it back (for testing, mostly)
26+
return toolbox
27+
}
28+
29+
module.exports = { run }

0 commit comments

Comments
 (0)