Skip to content

Commit 2422d21

Browse files
feat: remove web-client (#158)
1 parent 0022dc5 commit 2422d21

File tree

7 files changed

+20
-85
lines changed

7 files changed

+20
-85
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.12.2 (2025-11-12)
4+
5+
- Removed the web-client to improve frontend loading time ([#158](https://github.com/0xMiden/miden-faucet/pull/158)).
6+
37
## 0.12.1 (2025-11-11)
48

59
- Fixed release workflow by storing frontend artifacts in `OUT_DIR` (([#154](https://github.com/0xMiden/miden-faucet/pull/154))).

Cargo.lock

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ license = "MIT"
1212
readme = "README.md"
1313
repository = "https://github.com/0xMiden/miden-faucet"
1414
rust-version = "1.90"
15-
version = "0.12.1"
15+
version = "0.12.2"
1616

1717
# Optimize the cryptography for faster tests involving account creation.
1818
[profile.test.package.miden-crypto]

bin/faucet/frontend/app.js

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { MidenWalletAdapter } from "@demox-labs/miden-wallet-adapter-miden";
22
import { PrivateDataPermission, WalletAdapterNetwork } from "@demox-labs/miden-wallet-adapter-base";
3-
import { Endpoint, NoteId, RpcClient } from "@demox-labs/miden-sdk";
43
import { Utils } from './utils.js';
54
import { UIController } from './ui.js';
65
import { getConfig, getMetadata, getPowChallenge, getTokens, get_note } from "./api.js";
@@ -11,7 +10,6 @@ export class MidenFaucetApp {
1110
this.tokenAmountOptions = [100, 500, 1000];
1211
this.metadataInitialized = false;
1312
this.apiUrl = null;
14-
this.rpcClient = null;
1513
this.baseAmount = null;
1614
this.powLoadDifficulty = null;
1715

@@ -30,7 +28,6 @@ export class MidenFaucetApp {
3028
try {
3129
let config = await getConfig();
3230
this.apiUrl = config.api_url;
33-
this.rpcClient = new RpcClient(new Endpoint(config.node_url));
3431
this.setupEventListeners();
3532
this.startMetadataPolling();
3633
} catch (error) {
@@ -86,15 +83,10 @@ export class MidenFaucetApp {
8683
const nonce = await this.findValidNonce(powData.challenge, powData.target);
8784

8885
this.ui.updateMintingTitle('MINTING TOKENS');
89-
this.ui.updateProgressBar(33);
86+
this.ui.updateProgressBar(50);
9087

9188
const getTokensResponse = await getTokens(this.apiUrl, powData.challenge, nonce, recipient, amount, isPrivateNote);
9289

93-
this.ui.updateMintingTitle('CONFIRMING TRANSACTION');
94-
this.ui.updateProgressBar(66);
95-
96-
await this.pollNote(getTokensResponse.note_id);
97-
9890
this.ui.showCompletedModal(
9991
recipient,
10092
amountAsTokens,
@@ -193,54 +185,6 @@ export class MidenFaucetApp {
193185
}
194186
}
195187

196-
pollNote(noteId) {
197-
return new Promise((resolve, reject) => {
198-
// Poll every 500ms for the first 10 seconds, then every 1s for the next 30 seconds, then every 5s.
199-
let currentInterval = 500;
200-
let pollInterval;
201-
let elapsedTime = 0;
202-
// Timeout after 5 minutes
203-
const timeout = 300000;
204-
let timeoutId;
205-
206-
const poll = async () => {
207-
try {
208-
const note = await this.rpcClient.getNotesById([NoteId.fromHex(noteId)]);
209-
if (note && note.length > 0) {
210-
clearInterval(pollInterval);
211-
clearTimeout(timeoutId);
212-
resolve();
213-
return;
214-
}
215-
216-
elapsedTime += currentInterval;
217-
218-
if (elapsedTime <= 10000) {
219-
currentInterval = 500;
220-
} else if (elapsedTime <= 40000) {
221-
currentInterval = 1000;
222-
} else {
223-
currentInterval = 5000;
224-
}
225-
226-
// Update the interval
227-
clearInterval(pollInterval);
228-
pollInterval = setInterval(poll, currentInterval);
229-
} catch (error) {
230-
console.error('Error polling for note:', error);
231-
clearInterval(pollInterval);
232-
clearTimeout(timeoutId);
233-
reject('Error fetching note confirmation.');
234-
}
235-
};
236-
pollInterval = setInterval(poll, currentInterval);
237-
timeoutId = setTimeout(() => {
238-
clearInterval(pollInterval);
239-
reject(new Error('Timeout while waiting for tx to be committed. Please try again later.'));
240-
}, timeout);
241-
});
242-
}
243-
244188
async findValidNonce(challenge, target) {
245189
let nonce = 0;
246190
let targetNum = BigInt(target);

bin/faucet/frontend/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"license": "MIT",
1515
"dependencies": {
1616
"@demox-labs/miden-wallet-adapter-base": "^0.7.0",
17-
"@demox-labs/miden-wallet-adapter-miden": "^0.7.0",
18-
"@demox-labs/miden-sdk": "^0.12"
17+
"@demox-labs/miden-wallet-adapter-miden": "^0.7.0"
1918
},
2019
"devDependencies": {
2120
"esbuild": "^0.25.11"

bin/faucet/src/frontend.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ pub async fn serve_frontend(url: Url, api_public_url: Url, node_url: String) ->
3030
.route("/wallet-icon.png", get(get_wallet_icon))
3131
.route("/favicon.ico", get(get_favicon))
3232
.route("/config.json", get(config_json))
33-
// TODO: this is a hacky way of making the web-client work. Ideally the wasm file should be included in the bundle.
34-
.route("/assets/miden_client_web.wasm", get(get_miden_client_web_wasm))
3533
.fallback(get(get_not_found_html));
3634

3735
let listener = url
@@ -50,17 +48,6 @@ pub async fn get_index_html() -> Html<&'static str> {
5048
Html(include_str!(concat!(env!("OUT_DIR"), "/frontend/index.html")))
5149
}
5250

53-
pub async fn get_miden_client_web_wasm() -> Response {
54-
(
55-
[(header::CONTENT_TYPE, header::HeaderValue::from_static("application/wasm"))],
56-
include_bytes!(concat!(
57-
env!("OUT_DIR"),
58-
"/frontend/node_modules/@demox-labs/miden-sdk/dist/assets/miden_client_web.wasm"
59-
),),
60-
)
61-
.into_response()
62-
}
63-
6451
pub async fn get_not_found_html() -> Html<&'static str> {
6552
Html(include_str!(concat!(env!("OUT_DIR"), "/frontend/not_found.html")))
6653
}

crates/faucet/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,7 @@ mod tests {
640640
None,
641641
None,
642642
None,
643+
None,
643644
)
644645
.await
645646
.unwrap();

0 commit comments

Comments
 (0)