Skip to content

Commit 7cf119d

Browse files
OttoAllmendingerllm-git
andcommitted
feat(wasm-utxo-ui): replace utxolib with wasm-utxo address functions
Replace utxolib dependency with address utilities from @bitgo/wasm-utxo, simplifying the UI module by removing external dependency. Update address generation to use fromOutputScriptWithCoin instead of fromOutputScript. Co-authored-by: llm-git <[email protected]>
1 parent 767da2f commit 7cf119d

File tree

3 files changed

+5
-24
lines changed

3 files changed

+5
-24
lines changed

packages/wasm-utxo-ui/package.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,11 @@
2323
},
2424
"dependencies": {
2525
"@bitgo/wasm-utxo": "*",
26-
"assert": "^2.1.0",
27-
"buffer": "^6.0.3",
28-
"crypto-browserify": "^3.12.0",
2926
"fp-ts": "^2.16.8",
3027
"io-ts": "^2.2.21",
3128
"io-ts-types": "^0.5.19",
3229
"monocle-ts": "^2.3.13",
33-
"newtype-ts": "^0.3.5",
34-
"process": "^0.11.10",
35-
"stream-browserify": "^3.0.0",
36-
"vm-browserify": "^1.1.2"
30+
"newtype-ts": "^0.3.5"
3731
},
3832
"devDependencies": {
3933
"css-loader": "^7.1.2",

packages/wasm-utxo-ui/src/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import * as utxolib from "@bitgo/utxo-lib";
2-
import { Descriptor, Miniscript, ScriptContext } from "@bitgo/wasm-utxo";
1+
import { address, CoinName, Descriptor, Miniscript, ScriptContext } from "@bitgo/wasm-utxo";
32

43
import "./style.css";
54

@@ -33,8 +32,8 @@ const elDescriptorAst = getElement("output-descriptor-ast", HTMLDivElement);
3332
const elMiniscriptAst = getElement("output-miniscript-ast", HTMLDivElement);
3433
const elStatus = getElement("status", HTMLElement);
3534

36-
function toAddress(scriptPubkeyBytes: Uint8Array, network: utxolib.Network) {
37-
return utxolib.address.fromOutputScript(Buffer.from(scriptPubkeyBytes), network);
35+
function toAddress(scriptPubkeyBytes: Uint8Array, coin: CoinName) {
36+
return address.fromOutputScriptWithCoin(scriptPubkeyBytes, coin);
3837
}
3938

4039
function setHtmlContent(el: HTMLElement, content: HTMLElement | undefined) {
@@ -137,7 +136,7 @@ function applyUpdateWith(
137136
if (scriptPubkeyBytes) {
138137
elScriptPubkeyBytes.value = toHex(scriptPubkeyBytes);
139138
try {
140-
elAddress.value = toAddress(scriptPubkeyBytes, utxolib.networks.bitcoin);
139+
elAddress.value = toAddress(scriptPubkeyBytes, "btc");
141140
} catch (e: any) {
142141
elAddress.value = `error: ${e.message}`;
143142
}

packages/wasm-utxo-ui/webpack.config.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const path = require("path");
2-
const webpack = require("webpack");
32
const HtmlWebpackPlugin = require("html-webpack-plugin");
43

54
module.exports = {
@@ -23,13 +22,6 @@ module.exports = {
2322
},
2423
resolve: {
2524
extensions: [".ts", ".js"],
26-
fallback: {
27-
buffer: require.resolve("buffer/"),
28-
assert: require.resolve("assert/"),
29-
stream: require.resolve("stream-browserify"),
30-
crypto: require.resolve("crypto-browserify"),
31-
vm: require.resolve("vm-browserify"),
32-
},
3325
},
3426
output: {
3527
filename: "bundle.js",
@@ -39,10 +31,6 @@ module.exports = {
3931
new HtmlWebpackPlugin({
4032
template: "./src/index.html",
4133
}),
42-
new webpack.ProvidePlugin({
43-
Buffer: ["buffer", "Buffer"],
44-
process: "process/browser",
45-
}),
4634
],
4735
mode: "development",
4836
experiments: {

0 commit comments

Comments
 (0)