Skip to content

Commit 66da398

Browse files
Merge pull request #258 from BitGo/BTC-0.webui-fixes
feat(webui)!: modernize module system and remove inline wasm
2 parents bf5058b + e9ec9b5 commit 66da398

13 files changed

Lines changed: 198 additions & 7407 deletions

File tree

packages/webui/eslint.config.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import tseslint from "typescript-eslint";
2+
3+
export default tseslint.config(
4+
{
5+
ignores: [
6+
"dist/",
7+
"node_modules/",
8+
"wasm/",
9+
"webpack.config.js",
10+
"playwright.config.ts",
11+
"scripts/",
12+
"tests/",
13+
],
14+
},
15+
tseslint.configs.recommended,
16+
{
17+
files: ["src/**/*.{ts,tsx}"],
18+
languageOptions: {
19+
parserOptions: {
20+
project: ["./tsconfig.json"],
21+
tsconfigRootDir: import.meta.dirname,
22+
},
23+
},
24+
},
25+
);

packages/webui/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "@bitgo/wasm-web-ui",
33
"version": "0.1.0",
44
"description": "Web frontend for BitGoWASM libraries",
5+
"type": "module",
56
"repository": {
67
"type": "git",
78
"url": "git+https://github.com/BitGo/BitGoWASM.git"

packages/webui/scripts/extract-samples.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@
1010
* Usage: node scripts/extract-samples.js
1111
*/
1212

13-
const fs = require("fs");
14-
const path = require("path");
13+
import fs from "fs";
14+
import path from "path";
15+
import { fileURLToPath } from "url";
16+
17+
const __filename = fileURLToPath(import.meta.url);
18+
const __dirname = path.dirname(__filename);
1519

1620
const FIXTURES_DIR = path.resolve(__dirname, "../src/fixtures/fixed-script");
1721
const OUTPUT_FILE = path.resolve(__dirname, "../src/wasm-utxo/parser/samples.ts");

packages/webui/src/lib/router.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ let currentPath: string | null = null;
3232
*/
3333
export function parseHash(hash: string = location.hash): ParsedHash {
3434
// Remove leading # if present
35-
let hashContent = hash.startsWith("#") ? hash.slice(1) : hash;
35+
const hashContent = hash.startsWith("#") ? hash.slice(1) : hash;
3636

3737
// Default to root path
3838
if (!hashContent || hashContent === "/") {

packages/webui/src/wasm-solana/transaction/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ class SolanaTransactionParser extends BaseComponent {
703703
}
704704

705705
private share(): void {
706-
copyToClipboard(location.href, this.$(".btn")!);
706+
void copyToClipboard(location.href, this.$(".btn")!);
707707
}
708708

709709
private clear(): void {

packages/webui/src/wasm-utxo/addresses/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ class AddressConverter extends BaseComponent {
507507
{
508508
class: "copy-btn",
509509
style: "margin-left: 0.5rem",
510-
onclick: (e: Event) => copyToClipboard(hexString, e.target as HTMLElement),
510+
onclick: (e: Event) => void copyToClipboard(hexString, e.target as HTMLElement),
511511
},
512512
"Copy",
513513
),
@@ -569,7 +569,7 @@ class AddressConverter extends BaseComponent {
569569
"button",
570570
{
571571
class: "copy-btn",
572-
onclick: (e: Event) => copyToClipboard(outcome.address, e.target as HTMLElement),
572+
onclick: (e: Event) => void copyToClipboard(outcome.address, e.target as HTMLElement),
573573
},
574574
"Copy",
575575
),
@@ -595,7 +595,7 @@ class AddressConverter extends BaseComponent {
595595
}
596596

597597
private share(): void {
598-
copyToClipboard(location.href, this.$(".btn")!);
598+
void copyToClipboard(location.href, this.$(".btn")!);
599599
}
600600

601601
private clear(): void {

packages/webui/src/wasm-utxo/parser/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ function renderTreeNode(
231231
class: "copy-btn",
232232
onclick: (e: Event) => {
233233
e.stopPropagation();
234-
copyToClipboard(getFullValue(node.value), e.target as HTMLElement);
234+
void copyToClipboard(getFullValue(node.value), e.target as HTMLElement);
235235
},
236236
},
237237
"Copy",
@@ -1437,7 +1437,8 @@ class PsbtTxParser extends BaseComponent {
14371437
this.applyPsbtEdit();
14381438
} catch (e) {
14391439
if (errorEl) {
1440-
errorEl.replaceChildren(h("div", { class: "error-message" }, `${e}`));
1440+
const message = e instanceof Error ? e.message : String(e);
1441+
errorEl.replaceChildren(h("div", { class: "error-message" }, message));
14411442
}
14421443
}
14431444
}
@@ -1502,7 +1503,7 @@ class PsbtTxParser extends BaseComponent {
15021503
}
15031504

15041505
private share(): void {
1505-
copyToClipboard(location.href, this.$(".btn")!);
1506+
void copyToClipboard(location.href, this.$(".btn")!);
15061507
}
15071508

15081509
private clear(): void {

packages/webui/src/wasm-utxo/parser/samples.ts

Lines changed: 150 additions & 175 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)