Skip to content

Commit

Permalink
feat: add wasm miniscript to web demo
Browse files Browse the repository at this point in the history
Issue: BTC-1722
  • Loading branch information
OttoAllmendinger committed Jan 8, 2025
1 parent a71afc1 commit 0477848
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/web-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
},
"dependencies": {
"@bitgo/key-card": "^0.23.43",
"@bitgo/abstract-utxo": "^9.10.0",
"@bitgo/sdk-api": "^1.57.6",
"@bitgo/sdk-coin-ada": "^4.5.3",
"@bitgo/sdk-coin-algo": "^2.1.55",
Expand Down
7 changes: 7 additions & 0 deletions modules/web-demo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ const BGComponent = lazy(() => import('@components/BitGoJS'));
const BGApiComponent = lazy(() => import('@components/BitGoAPI'));
const CoinsComponent = lazy(() => import('@components/Coins'));
const KeyCardComponent = lazy(() => import('@components/KeyCard'));
const WasmMiniscriptComponent = lazy(
() => import('@components/WasmMiniscript'),
);
const EcdsaChallengeComponent = lazy(
() => import('@components/EcdsaChallenge'),
);
Expand All @@ -24,6 +27,10 @@ const App = () => {
<Route path="/bitgo-api" element={<BGApiComponent />} />
<Route path="/coins" element={<CoinsComponent />} />
<Route path="/keycard" element={<KeyCardComponent />} />
<Route
path="/wasm-miniscript"
element={<WasmMiniscriptComponent />}
/>
<Route
path="/ecdsachallenge"
element={<EcdsaChallengeComponent />}
Expand Down
6 changes: 6 additions & 0 deletions modules/web-demo/src/components/Navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ const Navbar = () => {
>
Key Card
</NavItem>
<NavItem
activeRoute={pathname === '/wasm-miniscript'}
onClick={() => navigate('/wasm-miniscript')}
>
Wasm Miniscript
</NavItem>
<NavItem
activeRoute={pathname === '/ecdsachallenge'}
onClick={() => navigate('/ecdsachallenge')}
Expand Down
25 changes: 25 additions & 0 deletions modules/web-demo/src/components/WasmMiniscript/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React, { useState } from 'react';

import * as AbstractUtxo from '@bitgo/abstract-utxo';

const defaultDescriptor =
'wpkh(xpub661MyMwAqRbcFQpwd6c6aaioiXWuygdeknqE8v6PSNusNjwZypj1uXTVNysfsFPEDL6X3yS1kL6JeWyy9bAiR97Gz8KD9Z1W54uBw9U9j2t/*)';

export default function () {
const [descriptorString] = useState(defaultDescriptor);

const descriptor = AbstractUtxo.descriptor.Descriptor.fromString(
descriptorString,
'derivable',
);
return (
<div>
<pre>{descriptor.toString()}</pre>
<pre>
{Buffer.from(descriptor.atDerivationIndex(0).scriptPubkey()).toString(
'hex',
)}
</pre>
</div>
);
}
3 changes: 3 additions & 0 deletions modules/web-demo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
{
"path": "../bitgo"
},
{
"path": "../abstract-utxo"
},
{
"path": "../key-card"
},
Expand Down
4 changes: 4 additions & 0 deletions modules/web-demo/webpack/base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ const rules = [
emitFile: false,
},
},
{
test: /miniscript.*\.wasm$/,
type: 'webassembly/sync',
},
];

const devRules = [
Expand Down

0 comments on commit 0477848

Please sign in to comment.