Skip to content

Commit

Permalink
popm/wasm: lint, fix ci publish, remove unneeded file, pin deps
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuasing committed Jun 28, 2024
1 parent 5b6f83a commit f939576
Show file tree
Hide file tree
Showing 9 changed files with 373 additions and 602 deletions.
24 changes: 12 additions & 12 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@
"build": "make wasm",
"build:opt": "make wasm-opt",
"build:pop-miner": "pnpm --filter @hemilabs/pop-miner run build",
"lint": "eslint \"packages/**/src/**/*.ts\"",
"lint": "eslint \"packages/**/src/**/*.ts\" && prettier . --check",
"format": "prettier -w ."
},
"packageManager": "pnpm@9.4.0",
"workspaces": [
"packages/*"
],
"engines": {
"node": "^18 || >=20"
"node": "^18.0.0 || >=20.0.0"
},
"devDependencies": {
"@eslint/js": "^9.3.0",
"eslint": "9.x",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-tsdoc": "^0.3.0",
"globals": "^15.3.0",
"prettier": "^3.2.5",
"typescript": "^5.4.5",
"typescript-eslint": "^7.11.0",
"vitest": "^1.6.0"
"@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"
}
}
7 changes: 3 additions & 4 deletions web/packages/pop-miner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
"main": "./dist/browser/index.js",
"types": "./dist/types.d.ts",
"files": [
"dist",
"types.d.ts"
"dist"
],
"exports": {
".": {
Expand All @@ -38,7 +37,7 @@
"./package.json": "./package.json"
},
"devDependencies": {
"tsup": "^8.0.2",
"typescript": "^5.4.5"
"tsup": "8.0.2",
"typescript": "5.4.5"
}
}
12 changes: 9 additions & 3 deletions web/packages/pop-miner/src/browser/wasm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import * as types from '../types';
import { Go } from './wasm_exec';

// Keep in sync with Method in web/popminer/api.go
export type Method = 'version'
export type Method =
| 'version'
| 'wasmPing'
| 'generateKey'
| 'startPoPMiner'
Expand Down Expand Up @@ -85,7 +86,10 @@ const getWASM = (): WASM => {
return globalWASM;
};

const instantiateWASM = async ({ wasmURL, importObject }: {
const instantiateWASM = async ({
wasmURL,
importObject,
}: {
wasmURL: string | URL;
importObject: Record<string, any>;
}): Promise<WebAssembly.WebAssemblyInstantiatedSource> => {
Expand All @@ -102,7 +106,9 @@ const instantiateWASM = async ({ wasmURL, importObject }: {
return await instantiateStreaming();
};

const loadWASM = async ({ wasmURL }: {
const loadWASM = async ({
wasmURL,
}: {
wasmURL: string | URL;
}): Promise<WASM> => {
const go = new Go();
Expand Down
17 changes: 9 additions & 8 deletions web/packages/pop-miner/src/browser/wasm_exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const enosys = () => {

let outputBuf = '';
const fs = {
constants: { // unused
constants: {
// unused
O_WRONLY: -1,
O_RDWR: -1,
O_CREAT: -1,
Expand Down Expand Up @@ -160,7 +161,7 @@ export class Go {
public importObject;

constructor() {
this.argv = [ 'js' ];
this.argv = ['js'];
this.env = {};
this.exit = (code) => {
if (code !== 0) {
Expand Down Expand Up @@ -566,12 +567,12 @@ export class Go {
this._goRefCounts = new Array(this._values.length).fill(Infinity); // number of references that Go has to a JS value, indexed by reference id
this._ids = new Map([
// mapping from JS values to reference ids
[ 0, 1 ],
[ null, 2 ],
[ true, 3 ],
[ false, 4 ],
[ globalThis, 5 ],
[ this, 6 ],
[0, 1],
[null, 2],
[true, 3],
[false, 4],
[globalThis, 5],
[this, 6],
]);
this._idPool = []; // unused ids that have been garbage collected
this.exited = false; // whether the Go program has exited
Expand Down
18 changes: 13 additions & 5 deletions web/packages/pop-miner/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ export type GenerateKeyResult = {
*
* @param args Key generation parameters.
*/
export declare function generateKey(args: GenerateKeyArgs): Promise<GenerateKeyResult>;
export declare function generateKey(
args: GenerateKeyArgs,
): Promise<GenerateKeyResult>;

/**
* @see startPoPMiner
Expand Down Expand Up @@ -296,7 +298,9 @@ export type L2Keystone = {
*
* @param args Retrieval options.
*/
export declare function l2Keystones(args: L2KeystonesArgs): Promise<L2KeystonesResult>;
export declare function l2Keystones(
args: L2KeystonesArgs,
): Promise<L2KeystonesResult>;

/**
* @see bitcoinBalance
Expand Down Expand Up @@ -330,7 +334,9 @@ export type BitcoinBalanceResult = {
*
* @param args Retrieval options.
*/
export declare function bitcoinBalance(args: BitcoinBalanceArgs): Promise<BitcoinBalanceResult>;
export declare function bitcoinBalance(
args: BitcoinBalanceArgs,
): Promise<BitcoinBalanceResult>;

/**
* @see bitcoinInfo
Expand Down Expand Up @@ -364,7 +370,7 @@ export type BitcoinUTXOsResult = {
* The UTXOs for the script hash.
*/
readonly utxos: BitcoinUTXO[];
}
};

/**
* Represents a Bitcoin UTXO.
Expand Down Expand Up @@ -393,4 +399,6 @@ export type BitcoinUTXO = {
*
* @param args Retrieval options.
*/
export declare function bitcoinUTXOs(args: BitcoinUTXOsArgs): Promise<BitcoinUTXOsResult>;
export declare function bitcoinUTXOs(
args: BitcoinUTXOsArgs,
): Promise<BitcoinUTXOsResult>;
2 changes: 1 addition & 1 deletion web/packages/pop-miner/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"declaration": true,
"noImplicitOverride": true,
"noUnusedLocals": true,
"esModuleInterop": true,
"esModuleInterop": true
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules"]
Expand Down
7 changes: 0 additions & 7 deletions web/packages/pop-miner/types.d.ts

This file was deleted.

Loading

0 comments on commit f939576

Please sign in to comment.