Skip to content

Commit 60e062c

Browse files
authored
Initial commit
0 parents  commit 60e062c

19 files changed

+3482
-0
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 4
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

.eslintrc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"root": true,
3+
"ignorePatterns": ["lib/*", "node_modules/**"],
4+
"extends": [
5+
"eslint:recommended",
6+
"plugin:@typescript-eslint/eslint-recommended",
7+
"plugin:@typescript-eslint/recommended",
8+
"plugin:prettier/recommended"
9+
],
10+
"rules": {
11+
"prettier/prettier": "warn",
12+
"no-console": "warn",
13+
"sort-imports": [
14+
"warn",
15+
{
16+
"ignoreCase": true,
17+
"ignoreDeclarationSort": true
18+
}
19+
],
20+
"@typescript-eslint/explicit-module-boundary-types": "off",
21+
"@typescript-eslint/no-explicit-any": "off",
22+
"@typescript-eslint/no-namespace": "off",
23+
"@typescript-eslint/no-non-null-assertion": "off",
24+
"@typescript-eslint/no-empty-function": "warn",
25+
"no-inner-declarations": "off"
26+
}
27+
}

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
custom: 'https://greymass.com/support-us'

.github/workflows/test.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Tests
2+
on: push
3+
jobs:
4+
test-node-js:
5+
runs-on: ubuntu-latest
6+
strategy:
7+
fail-fast: false
8+
matrix:
9+
node-version: [14, 16, 18]
10+
name: Node.js v${{ matrix.node-version }}
11+
steps:
12+
- name: Setup Node.js
13+
uses: actions/setup-node@v2
14+
with:
15+
node-version: ${{ matrix.node-version }}
16+
- name: Checkout code
17+
uses: actions/checkout@v2
18+
- name: Install dependencies
19+
run: make node_modules
20+
- name: Run checks
21+
run: make check
22+
- name: Run tests
23+
run: make ci-test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
lib/

.prettierrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
arrowParens: "always"
2+
bracketSpacing: false
3+
endOfLine: "lf"
4+
printWidth: 100
5+
semi: false
6+
singleQuote: true
7+
tabWidth: 4
8+
trailingComma: "es5"

LICENSE

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Copyright (c) 2023 Greymass Inc. All Rights Reserved.
2+
3+
Redistribution and use in source and binary forms, with or without modification,
4+
are permitted provided that the following conditions are met:
5+
6+
1. Redistribution of source code must retain the above copyright notice, this
7+
list of conditions and the following disclaimer.
8+
9+
2. Redistribution in binary form must reproduce the above copyright notice,
10+
this list of conditions and the following disclaimer in the documentation
11+
and/or other materials provided with the distribution.
12+
13+
3. Neither the name of the copyright holder nor the names of its contributors
14+
may be used to endorse or promote products derived from this software without
15+
specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20+
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25+
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
26+
OF THE POSSIBILITY OF SUCH DAMAGE.
27+
28+
YOU ACKNOWLEDGE THAT THIS SOFTWARE IS NOT DESIGNED, LICENSED OR INTENDED FOR USE
29+
IN THE DESIGN, CONSTRUCTION, OPERATION OR MAINTENANCE OF ANY MILITARY FACILITY.

Makefile

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
SHELL := /bin/bash
2+
SRC_FILES := $(shell find src -name '*.ts')
3+
TEST_FILES := $(shell find test/tests -name '*.ts')
4+
BIN := ./node_modules/.bin
5+
MOCHA_OPTS := -u tdd -r ts-node/register -r tsconfig-paths/register --extension ts
6+
NYC_OPTS := --temp-dir build/nyc_output --report-dir build/coverage
7+
8+
lib: ${SRC_FILES} package.json tsconfig.json node_modules rollup.config.js
9+
@${BIN}/rollup -c && touch lib
10+
11+
.PHONY: test
12+
test: node_modules
13+
@TS_NODE_PROJECT='./test/tsconfig.json' MOCK_DIR='./test/data' \
14+
${BIN}/mocha ${MOCHA_OPTS} ${TEST_FILES} --grep '$(grep)'
15+
16+
build/coverage: ${SRC_FILES} ${TEST_FILES} node_modules
17+
@TS_NODE_PROJECT='./test/tsconfig.json' \
18+
${BIN}/nyc ${NYC_OPTS} --reporter=html \
19+
${BIN}/mocha ${MOCHA_OPTS} -R nyan ${TEST_FILES}
20+
21+
.PHONY: coverage
22+
coverage: build/coverage
23+
@open build/coverage/index.html
24+
25+
.PHONY: ci-test
26+
ci-test: node_modules
27+
@TS_NODE_PROJECT='./test/tsconfig.json' MOCK_DIR='./test/data' \
28+
${BIN}/nyc ${NYC_OPTS} --reporter=text \
29+
${BIN}/mocha ${MOCHA_OPTS} -R list ${TEST_FILES}
30+
31+
.PHONY: check
32+
check: node_modules
33+
@${BIN}/eslint src --ext .ts --max-warnings 0 --format unix && echo "Ok"
34+
35+
.PHONY: format
36+
format: node_modules
37+
@${BIN}/eslint src --ext .ts --fix
38+
39+
.PHONY: publish
40+
publish: | distclean node_modules
41+
@git diff-index --quiet HEAD || (echo "Uncommitted changes, please commit first" && exit 1)
42+
@git fetch origin && git diff origin/master --quiet || (echo "Changes not pushed to origin, please push first" && exit 1)
43+
@yarn config set version-tag-prefix "" && yarn config set version-git-message "Version %s"
44+
@yarn publish && git push && git push --tags
45+
46+
.PHONY: docs
47+
docs: build/docs
48+
@open build/docs/index.html
49+
50+
build/docs: $(SRC_FILES) node_modules
51+
@${BIN}/typedoc --out build/docs \
52+
--excludeInternal --excludePrivate --excludeProtected \
53+
--includeVersion --hideGenerator --readme none \
54+
src/index.ts
55+
56+
build/pages: build/docs test/browser.html
57+
@mkdir -p build/pages
58+
@cp -r build/docs/* build/pages/
59+
@cp test/browser.html build/pages/tests.html
60+
61+
.PHONY: deploy-pages
62+
deploy-pages: | clean build/pages node_modules
63+
@${BIN}/gh-pages -d build/pages
64+
65+
test/browser.html: $(SRC_FILES) $(TEST_FILES) test/rollup.config.js node_modules
66+
@${BIN}/rollup -c test/rollup.config.js
67+
68+
.PHONY: browser-test
69+
browser-test: test/browser.html
70+
@open test/browser.html
71+
72+
node_modules:
73+
yarn install --non-interactive --frozen-lockfile --ignore-scripts
74+
75+
.PHONY: clean
76+
clean:
77+
rm -rf lib/ build/ test/browser.html
78+
79+
.PHONY: distclean
80+
distclean: clean
81+
rm -rf node_modules/

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# @wharfkit/wallet-plugin-template
2+
3+
A template to create a `WalletPlugin` for use within the `@wharfkit/session` library.
4+
5+
## Usage
6+
7+
- [Use this as a template.](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template)
8+
- Write your wallet plugin's logic.
9+
- Publish it on Github or npmjs.com
10+
- Include it in your project and use it.
11+
12+
## Developing
13+
14+
You need [Make](https://www.gnu.org/software/make/), [node.js](https://nodejs.org/en/) and [yarn](https://classic.yarnpkg.com/en/docs/install) installed.
15+
16+
Clone the repository and run `make` to checkout all dependencies and build the project. See the [Makefile](./Makefile) for other useful targets. Before submitting a pull request make sure to run `make lint`.
17+
18+
---
19+
20+
Made with ☕️ & ❤️ by [Greymass](https://greymass.com), if you find this useful please consider [supporting us](https://greymass.com/support-us).

package.json

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"name": "@wharfkit/wallet-plugin-template",
3+
"description": "A template to create wallet plugins for use with @wharfkit/session.",
4+
"version": "1.1.0",
5+
"homepage": "https://github.com/wharfkit/wallet-plugin-template",
6+
"license": "BSD-3-Clause",
7+
"main": "lib/wallet-plugin-template.js",
8+
"module": "lib/wallet-plugin-template.m.js",
9+
"types": "lib/wallet-plugin-template.d.ts",
10+
"sideEffects": false,
11+
"files": [
12+
"lib/*",
13+
"src/*"
14+
],
15+
"scripts": {
16+
"prepare": "make"
17+
},
18+
"dependencies": {
19+
"tslib": "^2.1.0"
20+
},
21+
"peerDependencies": {
22+
"@wharfkit/session": "^1.1.0"
23+
},
24+
"devDependencies": {
25+
"@rollup/plugin-alias": "^3.1.4",
26+
"@rollup/plugin-commonjs": "^22.0.0",
27+
"@rollup/plugin-json": "^4.1.0",
28+
"@rollup/plugin-node-resolve": "^14.1.0",
29+
"@rollup/plugin-replace": "^5.0.1",
30+
"@rollup/plugin-typescript": "^10.0.1",
31+
"@rollup/plugin-virtual": "^2.0.3",
32+
"@types/chai": "^4.3.1",
33+
"@types/mocha": "^9.0.0",
34+
"@types/node": "^18.7.18",
35+
"@typescript-eslint/eslint-plugin": "^5.20.0",
36+
"@typescript-eslint/parser": "^5.20.0",
37+
"@wharfkit/mock-data": "^1.2.0",
38+
"@wharfkit/session": "^1.1.0-rcfinal",
39+
"chai": "^4.3.4",
40+
"eslint": "^8.13.0",
41+
"eslint-config-prettier": "^8.1.0",
42+
"eslint-plugin-prettier": "^4.0.0",
43+
"gh-pages": "^4.0.0",
44+
"mocha": "^10.0.0",
45+
"node-fetch": "^2.6.1",
46+
"nyc": "^15.1.0",
47+
"prettier": "^2.2.1",
48+
"rollup": "^2.70.2",
49+
"rollup-plugin-dts": "^4.2.1",
50+
"rollup-plugin-terser": "^7.0.2",
51+
"ts-node": "^10.9.1",
52+
"tsconfig-paths": "^4.1.1",
53+
"typedoc": "^0.23.14",
54+
"typescript": "^4.1.2",
55+
"yarn-deduplicate": "^6.0.1"
56+
}
57+
}

rollup.config.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import fs from 'fs'
2+
import dts from 'rollup-plugin-dts'
3+
import typescript from '@rollup/plugin-typescript'
4+
5+
import pkg from './package.json'
6+
7+
const name = pkg.name
8+
const license = fs.readFileSync('LICENSE').toString('utf-8').trim()
9+
const banner = `
10+
/**
11+
* ${name} v${pkg.version}
12+
* ${pkg.homepage}
13+
*
14+
* @license
15+
* ${license.replace(/\n/g, '\n * ')}
16+
*/
17+
`.trim()
18+
19+
const external = Object.keys(pkg.peerDependencies)
20+
21+
/** @type {import('rollup').RollupOptions} */
22+
export default [
23+
{
24+
input: 'src/index.ts',
25+
output: {
26+
banner,
27+
file: pkg.main,
28+
format: 'cjs',
29+
sourcemap: true,
30+
exports: 'named',
31+
},
32+
plugins: [typescript({target: 'es6'})],
33+
external,
34+
},
35+
{
36+
input: 'src/index.ts',
37+
output: {
38+
banner,
39+
file: pkg.module,
40+
format: 'esm',
41+
sourcemap: true,
42+
},
43+
plugins: [typescript({target: 'es2020'})],
44+
external,
45+
},
46+
{
47+
input: 'src/index.ts',
48+
output: {banner, file: pkg.types, format: 'esm'},
49+
plugins: [dts()],
50+
},
51+
]

0 commit comments

Comments
 (0)