forked from hemilabs/heminetwork
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
popm/wasm: add new @hemilabs/pop-miner NPM package (hemilabs#162)
Add the initial implementation of the `@hemilabs/pop-miner` NPM package, a TypeScript API layer for the WebAssembly PoP Miner. Also adds supporting files, GitHub Actions workflow changes to build and publish the NPM package. This is the initial version of this package, more functionality will be added in future pull requests. Reviewed-on: hemilabs#162
- Loading branch information
1 parent
ecef76a
commit b9b673a
Showing
22 changed files
with
9,292 additions
and
11 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
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,72 @@ | ||
# Copyright (c) 2024 Hemi Labs, Inc. | ||
# Use of this source code is governed by the MIT License, | ||
# which can be found in the LICENSE file. | ||
|
||
# GitHub Actions workflow to lint, build and test NPM packages. | ||
name: "Node" | ||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
workflow_dispatch: | ||
workflow_call: | ||
|
||
concurrency: | ||
group: "node-${{ github.workflow }}-${{ github.event.number || github.ref }}" | ||
cancel-in-progress: "${{ github.event_name == 'pull_request' }}" | ||
|
||
env: | ||
GO_VERSION: "1.22.x" | ||
PNPM_VERSION: "9.4.x" | ||
|
||
jobs: | ||
build: | ||
name: "Build" | ||
runs-on: "ubuntu-latest" | ||
permissions: | ||
contents: read | ||
steps: | ||
- name: "Checkout repository" | ||
uses: actions/checkout@v4 | ||
|
||
- name: "Setup Go ${{ env.GO_VERSION }}" | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: "${{ env.GO_VERSION }}" | ||
cache: true | ||
check-latest: true | ||
|
||
- name: "Setup pnpm ${{ env.PNPM_VERSION }}" | ||
uses: pnpm/action-setup@v4 | ||
with: | ||
version: "${{ env.PNPM_VERSION }}" | ||
|
||
- name: "Setup Node" | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: "web/.nvmrc" | ||
check-latest: true | ||
cache: "pnpm" | ||
cache-dependency-path: "web/**/pnpm-lock.yaml" | ||
|
||
- name: "Install dependencies" | ||
working-directory: "web/" | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: "Install Go dependencies" | ||
working-directory: "web/" | ||
run: make deps | ||
|
||
# TODO(joshuasing): Install and use binaryen | ||
- name: "Build @hemilabs/pop-miner WebAssembly binary" | ||
working-directory: "web/" | ||
run: make wasm | ||
|
||
- name: "Build @hemilabs/pop-miner package" | ||
working-directory: "web/" | ||
run: pnpm build:pop-miner | ||
|
||
- name: "Lint" | ||
working-directory: "web/" | ||
run: pnpm lint |
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
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 |
---|---|---|
@@ -1 +1,4 @@ | ||
webapp | ||
webapp/ | ||
node_modules/ | ||
dist/ | ||
packages/pop-miner/wasm/ |
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 @@ | ||
20.15.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,5 @@ | ||
**/dist | ||
pnpm-lock.yaml | ||
|
||
www/ | ||
webapp/ |
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 @@ | ||
{ | ||
"semi": true, | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"tabWidth": 2, | ||
"printWidth": 80 | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* Copyright (c) 2024 Hemi Labs, Inc. | ||
* Use of this source code is governed by the MIT License, | ||
* which can be found in the LICENSE file. | ||
*/ | ||
|
||
import globals from 'globals'; | ||
import pluginJs from '@eslint/js'; | ||
import tseslint from 'typescript-eslint'; | ||
import pluginTSDoc from 'eslint-plugin-tsdoc'; | ||
|
||
export default [ | ||
{ | ||
languageOptions: { | ||
globals: { | ||
...globals.browser, | ||
...globals.node, | ||
}, | ||
}, | ||
}, | ||
pluginJs.configs.recommended, | ||
...tseslint.configs.recommended, | ||
{ | ||
plugins: { | ||
pluginTSDoc, | ||
}, | ||
}, | ||
]; |
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,40 @@ | ||
{ | ||
"name": "@hemilabs/heminetwork", | ||
"version": "0.0.0", | ||
"private": true, | ||
"license": "MIT", | ||
"bugs": "https://github.com/hemilabs/heminetwork/issues", | ||
"homepage": "https://github.com/hemilabs/heminetwork", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/hemilabs/heminetwork.git", | ||
"directory": "web" | ||
}, | ||
"scripts": { | ||
"preinstall": "npx only-allow pnpm", | ||
"build": "make wasm", | ||
"build:opt": "make wasm-opt", | ||
"build:pop-miner": "pnpm --filter @hemilabs/pop-miner run build", | ||
"lint": "eslint \"packages/**/src/**/*.ts\" && prettier . --check", | ||
"format": "prettier -w ." | ||
}, | ||
"packageManager": "pnpm@9.4.0", | ||
"workspaces": [ | ||
"packages/*" | ||
], | ||
"engines": { | ||
"node": "^18.0.0 || >=20.0.0" | ||
}, | ||
"devDependencies": { | ||
"@eslint/js": "9.5.0", | ||
"eslint": "9.5.0", | ||
"eslint-config-prettier": "9.1.0", | ||
"eslint-plugin-prettier": "5.1.3", | ||
"eslint-plugin-tsdoc": "0.3.0", | ||
"globals": "15.6.0", | ||
"prettier": "3.3.2", | ||
"typescript": "5.5.2", | ||
"typescript-eslint": "7.14.1", | ||
"vitest": "1.6.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,43 @@ | ||
{ | ||
"name": "@hemilabs/pop-miner", | ||
"version": "0.1.0", | ||
"type": "module", | ||
"license": "MIT", | ||
"author": "Hemi Labs", | ||
"description": "Hemi Labs WebAssembly Proof-of-Proof Miner", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/hemilabs/heminetwork.git", | ||
"directory": "web/packages/pop-miner" | ||
}, | ||
"homepage": "https://hemi.xyz", | ||
"bugs": { | ||
"url": "https://github.com/hemilabs/heminetwork/issues" | ||
}, | ||
"engines": { | ||
"node": "^18.0.0 || >=20.0.0" | ||
}, | ||
"scripts": { | ||
"build": "tsup" | ||
}, | ||
"main": "./dist/browser/index.js", | ||
"types": "./dist/types.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"exports": { | ||
".": { | ||
"types": "./dist/browser/index.d.ts", | ||
"browser": "./dist/browser/index.js", | ||
"import": "./dist/browser/index.js", | ||
"default": "./dist/browser/index.js" | ||
}, | ||
"./popminer.wasm": "./dist/popminer.wasm", | ||
"./types": "./dist/types.d.ts", | ||
"./package.json": "./package.json" | ||
}, | ||
"devDependencies": { | ||
"tsup": "8.0.2", | ||
"typescript": "5.4.5" | ||
} | ||
} |
Oops, something went wrong.