Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
9ef3a08
poc: first code with snap integration in rpc monorepo
pedroferreira1 Apr 4, 2025
1c7439e
chore: added polyfills
andreabadesso Apr 4, 2025
d879b4a
chore: update libs
andreabadesso Apr 4, 2025
23114c4
bitcore patches
pedroferreira1 Apr 4, 2025
25cb3ec
fix: process browser fix and new bitcore lib patch
pedroferreira1 Apr 8, 2025
bcec880
feat: add snap utils
pedroferreira1 Apr 8, 2025
762ef56
feat: add home page and post install page, and refactor utils methods
pedroferreira1 Jun 18, 2025
38cf271
chore: yarn lock fix after rebase
pedroferreira1 Jul 3, 2025
900fe88
feat: initial web wallet version
andreabadesso Jul 3, 2025
bfd91b9
feat: several improvements to UI
andreabadesso Jul 4, 2025
110cc25
feat: ttags + lucide icons
andreabadesso Jul 4, 2025
7b0d596
refactor(web-wallet): updated UI and added snap integration
andreabadesso Sep 26, 2025
f5168d7
feat: added get-xpub rpc request and snap to display it
andreabadesso Oct 7, 2025
69de841
tests(rpc-handler): added getxpub tests
andreabadesso Oct 7, 2025
316f97f
Merge branch 'master' into feat/get-xpub
andreabadesso Oct 7, 2025
270ab8e
refactor(rpc-handler): throwing a specific error for xpub not availab…
andreabadesso Oct 9, 2025
2ec7ef8
Merge branch 'feat/get-xpub' into feat/web-wallet
andreabadesso Oct 9, 2025
a8ad4c0
feat: using xpubkey to load addresses and wallet details
andreabadesso Oct 10, 2025
4332938
feat: web-wallet connects to dev-testnet and added polyfills
andreabadesso Oct 10, 2025
62d74c2
feat: added dev-testnet and intiialize start without waiting
andreabadesso Oct 10, 2025
481e130
feat: load xpubkey from storage
andreabadesso Oct 10, 2025
dc8391b
feat: complete UI
andreabadesso Oct 10, 2025
0123a77
feat(snap): initializing and using the read-only wallet for read-only…
andreabadesso Oct 21, 2025
076f278
refactor(snap): enableWs false on snap wallet initialzation
andreabadesso Oct 21, 2025
ba5333d
refactor(snap): wallet-lib 2.8.3
andreabadesso Oct 21, 2025
3c62656
refactor(snap): remove useless logs and onUpdate
andreabadesso Oct 21, 2025
07e503a
refactor(snap): mainnet should be the default network, not dev-testnet
andreabadesso Oct 21, 2025
94b1b49
refactor(snap): htr_changeNetwork should be a read only method
andreabadesso Oct 21, 2025
5339ce4
refactor(snap): remove duplicate code
andreabadesso Oct 22, 2025
c11e2c9
chore(snap): updated snap shasum
andreabadesso Oct 22, 2025
d2a964c
Merge branch 'feat/read-only-wallet-for-read-only-methods' into feat/…
andreabadesso Oct 22, 2025
d748593
fix(snap): snaps-sdk version -> 9.3.0
andreabadesso Oct 22, 2025
6728808
feat(web-wallet): handling errors from metamask provider
andreabadesso Oct 22, 2025
4b4dc0c
refactor(snap): starting wallet before returning it.
andreabadesso Oct 22, 2025
d7a83f3
feat(snap): initialize wallet on network change
andreabadesso Oct 22, 2025
dcf4970
chore(snap): updated manifest
andreabadesso Oct 22, 2025
da0205e
chore: updated locked packages
andreabadesso Oct 22, 2025
85b886b
feat(snap): change network with rollback
andreabadesso Oct 22, 2025
a956766
chore(snap): updated manifest
andreabadesso Oct 22, 2025
5f10aa1
feat(snap): initialize wallet on network change
andreabadesso Oct 22, 2025
06c24d1
Merge feat/initialize-wallet-on-network-change
andreabadesso Oct 22, 2025
8c0aa76
Merge branch 'feat/initialize-wallet-on-network-change' into feat/rea…
andreabadesso Oct 22, 2025
e7575b6
fix: remove hardcoded testnet override and fix silent error handling
andreabadesso Oct 22, 2025
7c16f54
fix: resolve remaining critical issues in wallet state management
andreabadesso Oct 22, 2025
7fec9ba
fix: address important issues from code review
andreabadesso Oct 22, 2025
e30d206
ci: add web-wallet and snap testing to GitHub Actions workflow
andreabadesso Oct 22, 2025
41f67c7
test: fix unit tests to pass in CI
andreabadesso Oct 22, 2025
447c977
test: fix E2E tests and add to CI
andreabadesso Oct 22, 2025
eb3f98f
fix: critical error handling and address validation
andreabadesso Oct 23, 2025
d112ace
feat(web-wallet): using published lib version
andreabadesso Oct 23, 2025
e9ee766
fix: lint errors in tests and remove hardcoded wallet-lib path
andreabadesso Oct 23, 2025
f2f391b
fix: make getCurrentAddress synchronous and add Docker support
andreabadesso Oct 28, 2025
e9af935
fix: resolve all TypeScript build errors for Docker build
andreabadesso Oct 28, 2025
1bd6859
fix: update Dockerfile paths for Dokploy deployment context
andreabadesso Oct 28, 2025
0b2ecfe
feat: add root-level Dockerfile for web-wallet deployment
andreabadesso Oct 28, 2025
c9fbbf6
fix: build workspace dependencies before web-wallet
andreabadesso Oct 28, 2025
df895a8
fix: add timeout and better error handling for connection check
andreabadesso Oct 28, 2025
b1a8f61
fix: set isCheckingConnection to false in initial state
andreabadesso Oct 28, 2025
9891146
fix: add 10-second timeout to prevent infinite loading
andreabadesso Oct 28, 2025
6f7589e
refactor(web-wallet): remove pointless comments and logs
andreabadesso Oct 28, 2025
5130381
Merge branch 'master' into feat/read-only-xpub
andreabadesso Oct 28, 2025
dfc4e01
refactor(web-wallet): using zod + react-form
andreabadesso Oct 28, 2025
7269964
refactor(snap): revert debugging changes
andreabadesso Oct 28, 2025
80e2f9c
refactor(web-wallet): stop using hard coded network names
andreabadesso Oct 28, 2025
67771b3
refactor(web-wallet): removed unused error ids file
andreabadesso Oct 28, 2025
0a2e999
refactor(web-wallet): using lib constants
andreabadesso Oct 29, 2025
f7bdbdc
chore: removed rpc-examples
andreabadesso Oct 29, 2025
716bdce
chore: revert snap changes
andreabadesso Oct 29, 2025
7ecb71b
refactor(web-wallet): removed dev-testnet
andreabadesso Oct 29, 2025
48ef330
chore(snap): revert package changes
andreabadesso Oct 29, 2025
12b0934
feat(web-wallet): favicon
andreabadesso Oct 29, 2025
e06db65
refactor(web-wallet): improved dark/light mode favicon
andreabadesso Oct 29, 2025
beee189
feat(web-wallet): tx notifier + better error handling
andreabadesso Oct 30, 2025
25b9794
refactor(web-wallet): passing lint
andreabadesso Oct 30, 2025
52bc82a
refactor(web-wallet): using bigint
andreabadesso Nov 4, 2025
33ca236
refactor(web-wallet): using bigint
andreabadesso Nov 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,34 @@ jobs:
run: |
nix develop . -c yarn install

- name: lint
- name: Lint hathor-rpc-handler
run: |
nix develop . -c yarn workspace @hathor/hathor-rpc-handler run lint

- name: tests
- name: Test hathor-rpc-handler
run: |
nix develop . -c yarn workspace @hathor/hathor-rpc-handler run test

- name: Lint web-wallet
run: |
nix develop . -c yarn workspace @hathor/web-wallet run lint

- name: Test web-wallet
run: |
nix develop . -c yarn workspace @hathor/web-wallet run test --run

- name: Install Playwright browsers
run: |
nix develop . -c yarn workspace @hathor/web-wallet exec playwright install chromium --with-deps

- name: E2E test web-wallet
run: |
nix develop . -c yarn workspace @hathor/web-wallet exec playwright test --project=chromium

- name: Lint snap
run: |
nix develop . -c yarn workspace @hathor/snap run lint

- name: Test snap
run: |
nix develop . -c yarn workspace @hathor/snap run test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ coverage/
public/
*.swp
*.swo
.claude
12 changes: 12 additions & 0 deletions .yarn/patches/bitcore-lib-npm-8.25.10-2b2055eaf2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/index.js b/index.js
index 4cbe6bf2ac69202558e0cfb8457fec21c2d48017..98cad3a403bacc0ebd2d1223d3c17adc23a53bc7 100644
--- a/index.js
+++ b/index.js
@@ -5,6 +5,7 @@ var bitcore = module.exports;
// module information
bitcore.version = 'v' + require('./package.json').version;
bitcore.versionGuard = function(version) {
+ return;
if (version !== undefined) {
var message = 'More than one instance of bitcore-lib found. ' +
'Please make sure to require bitcore-lib and check that submodules do' +
2 changes: 1 addition & 1 deletion .yarn/patches/bitcore-lib-npm-8.25.47-62066b9183.patch
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ index 6bea796b8a174a1ecb24d3c745fc32edf83bf4c2..7002d96c2e5571ca8097f286190f937a
+ r = Q.getX().umod(N);
s = k.invm(N).mul(e.add(d.mul(r))).umod(N);
} while (r.cmp(BN.Zero) <= 0 || s.cmp(BN.Zero) <= 0);

45 changes: 45 additions & 0 deletions Dockerfile.web-wallet
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Build stage
FROM node:20-alpine AS builder

WORKDIR /app

# Copy yarn configuration and patches
COPY .yarnrc.yml ./
COPY .yarn ./.yarn
COPY package.json yarn.lock ./
COPY packages/web-wallet/package.json ./packages/web-wallet/
COPY packages/snap-utils/package.json ./packages/snap-utils/
COPY packages/hathor-rpc-handler/package.json ./packages/hathor-rpc-handler/

# Install dependencies
RUN corepack enable && yarn install

# Copy source code
COPY packages/web-wallet ./packages/web-wallet
COPY packages/snap-utils ./packages/snap-utils
COPY packages/hathor-rpc-handler ./packages/hathor-rpc-handler

# Build snap-utils first (web-wallet depends on it)
WORKDIR /app/packages/snap-utils
RUN yarn build

# Build hathor-rpc-handler (snap-utils depends on it)
WORKDIR /app/packages/hathor-rpc-handler
RUN yarn build

# Build the web-wallet application
WORKDIR /app/packages/web-wallet
RUN yarn build

# Production stage
FROM nginx:alpine

# Copy built files to nginx
COPY --from=builder /app/packages/web-wallet/dist /usr/share/nginx/html

# Copy nginx configuration
COPY packages/web-wallet/nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"workspaces": [
"packages/hathor-rpc-handler",
"packages/snap",
"packages/snap-utils"
"packages/snap-utils",
"packages/web-wallet"
],
"resolutions": {
"bitcore-lib@npm:8.25.10": "patch:bitcore-lib@npm%3A8.25.47#~/.yarn/patches/bitcore-lib-npm-8.25.47-62066b9183.patch",
Expand Down
2 changes: 1 addition & 1 deletion packages/snap-utils/src/react-hooks/MetamaskContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ export const MetaMaskProvider = ({ children }: { children: ReactNode }) => {
*/
export function useMetaMaskContext() {
return useContext(MetaMaskContext);
}
}
8 changes: 6 additions & 2 deletions packages/snap-utils/src/react-hooks/useRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ export const useRequest = () => {
* @param params.method - The method to call.
* @param params.params - The method params.
* @returns The result of the request.
* @throws Will throw an error if the request fails.
*/
const request: Request = async ({ method, params }) => {
try {
setError(null);
const data =
(await provider?.request({
method,
Expand All @@ -31,9 +31,13 @@ export const useRequest = () => {

return data;
} catch (requestError: any) {
// Set error in context for UI notifications
setError(requestError);

return null;
// Re-throw the error so callers can distinguish between
// null response vs error. This allows proper error handling
// instead of treating all errors as null responses.
throw requestError;
}
};

Expand Down
2 changes: 1 addition & 1 deletion packages/snap-utils/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface EIP6963AnnounceProviderEvent extends CustomEvent<{
rdns: string;
};
provider: MetaMaskInpageProvider;
}> {}
}> { }

declare global {
interface WindowEventMap {
Expand Down
1 change: 0 additions & 1 deletion packages/snap-utils/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@
"dist"
]
}

2 changes: 1 addition & 1 deletion packages/snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Hathor Network Snap integration",
"proposedName": "Hathor Wallet",
"source": {
"shasum": "9j6opOXoJBG0aZv1ZsDnlCpUZ55XZbUVWBABoFvJYIQ=",
"shasum": "Zt62bKmJtkjJKomv2U76V5gdAG447bsG8ytJGS144Ac=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
8 changes: 4 additions & 4 deletions packages/snap/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ const NANO_BRAVO_URLS = {
}

const TESTNET_URLS = {
nodeURL: 'https://node1.testnet.hathor.network/v1a/',
walletServiceURL: 'https://wallet-service.testnet.hathor.network',
txMiningURL: 'https://txmining.testnet.hathor.network/',
nodeURL: 'https://node1.india.testnet.hathor.network/v1a/',
walletServiceURL: 'https://wallet-service.india.testnet.hathor.network',
txMiningURL: 'https://txmining.india.testnet.hathor.network/',
network: 'testnet',
}

Expand All @@ -52,6 +52,6 @@ export const NETWORK_MAP = {
'dev-testnet': DEV_TESTNET_URLS,
}

export const DEFAULT_NETWORK = 'mainnet';
export const DEFAULT_NETWORK = 'testnet';

export const DEFAULT_PIN_CODE = '123';
2 changes: 1 addition & 1 deletion packages/snap/src/dialogs/address.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ export const addressPage = async (data, params, origin) => (
),
},
})
)
)
2 changes: 1 addition & 1 deletion packages/snap/src/dialogs/createNano.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { REQUEST_METHODS, DIALOG_TYPES } from '../constants';
import { Bold, Box, Card, Container, Copyable, Divider, Heading, Icon, Section, Text, Tooltip } from '@metamask/snaps-sdk/jsx';
import { Bold, Box, Card, Container, Copyable, Heading, Icon, Section, Text, Tooltip } from '@metamask/snaps-sdk/jsx';
import { constants as libConstants, bigIntUtils, dateUtils, NanoContractActionType, numberUtils } from '@hathor/wallet-lib';

const renderOptionalContractDetail = (param, title) => {
Expand Down
2 changes: 2 additions & 0 deletions packages/snap/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ export const onRpcRequest: OnRpcRequestHandler = async ({
}) => {
// Almost all RPC requests need the network, so I add it here
const networkData = await getNetworkData();

request.params = { ...request.params, network: networkData.network };

// Use read-only wallet for requests that don't require signing
const isReadOnly = READ_ONLY_METHODS.has(request.method as RpcMethods);

Expand Down
1 change: 1 addition & 0 deletions packages/snap/src/utils/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const getNetworkData = async () => {

/*
* Set network, persist data in storage and update wallet lib config
* Also initializes the wallet on the new network's wallet-service
*/
export const setNetwork = async (network: string) => {
const persistedData = await snap.request({
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/src/utils/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,4 @@ export const getAndStartHathorWallet = async (): Promise<HathorWalletServiceWall
await wallet.start({ pinCode: DEFAULT_PIN_CODE, password: DEFAULT_PIN_CODE });

return wallet;
}
};
13 changes: 13 additions & 0 deletions packages/web-wallet/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
node_modules
dist
.git
.gitignore
*.log
.env
.env.*
coverage
test-results
playwright-report
*.md
Dockerfile
.dockerignore
24 changes: 24 additions & 0 deletions packages/web-wallet/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
36 changes: 36 additions & 0 deletions packages/web-wallet/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Build stage
FROM node:20-alpine AS builder

WORKDIR /app

# Copy yarn configuration and patches from repo root
COPY ../../.yarnrc.yml ./
COPY ../../.yarn ./.yarn
COPY ../../package.json ../../yarn.lock ./
COPY ../hathor-rpc-handler/package.json ./packages/hathor-rpc-handler/
COPY ../snap-utils/package.json ./packages/snap-utils/
COPY package.json ./packages/web-wallet/

# Install dependencies
RUN corepack enable && yarn install

# Copy source code
COPY . ./packages/web-wallet
COPY ../snap-utils ../snap-utils

# Build the application
WORKDIR /app/packages/web-wallet
RUN yarn build

# Production stage
FROM nginx:alpine

# Copy built files to nginx
COPY --from=builder /app/packages/web-wallet/dist /usr/share/nginx/html

# Copy nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
69 changes: 69 additions & 0 deletions packages/web-wallet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:

```js
export default tseslint.config([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...

// Remove tseslint.configs.recommended and replace with this
...tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
...tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
...tseslint.configs.stylisticTypeChecked,

// Other configs...
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
```

You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:

```js
// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'

export default tseslint.config([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Enable lint rules for React
reactX.configs['recommended-typescript'],
// Enable lint rules for React DOM
reactDom.configs.recommended,
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
```
17 changes: 17 additions & 0 deletions packages/web-wallet/components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": false,
"tsx": true,
"tailwind": {
"config": "tailwind.config.js",
"css": "src/index.css",
"baseColor": "slate",
"cssVariables": true,
"prefix": ""
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils"
}
}
Loading
Loading