Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1,022 changes: 734 additions & 288 deletions Cargo.lock

Large diffs are not rendered by default.

30 changes: 14 additions & 16 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,29 @@ members = [
"crates/coordinator/domain",
"crates/coordinator/engine",
"crates/coordinator/store",
"crates/coordinator/utils",
"crates/miden-multisig-client",
"crates/test-utils",
]
resolver = "3"

[workspace.dependencies]
miden-client = "0.11.9"
miden-multisig-client = { path = "crates/miden-multisig-client" }
miden-multisig-coordinator-domain = { path = "crates/coordinator/domain" }
miden-multisig-coordinator-engine = { path = "crates/coordinator/engine" }
miden-multisig-coordinator-store = { path = "crates/coordinator/store" }
miden-multisig-coordinator-utils = { path = "crates/coordinator/utils" }
miden-multisig-test-utils = { path = "crates/test-utils" }
miden-objects = "0.11"

anyhow = "1"
bon = { default-features = false, version = "3" }
chrono = { default-features = false, version = "0.4" }
dissolve-derive = "0.1.2"
rand = "0.9"
serde = { default-features = false, version = "1" }
serde_with = { default-features = false, version = "3" }
thiserror = { default-features = false, version = "2" }
tokio = { default-features = false, version = "1.40" }
tracing = "0.1"
url = "2.5"
uuid = { default-features = false, version = "1" }
anyhow = "1"
bon = { default-features = false, version = "3" }
chrono = { default-features = false, version = "0.4" }
dissolve-derive = "0.1.4"
miden-client = { default-features = false, version = "0.12" }
miden-client-sqlite-store = "0.12"
rand = "0.9"
serde = { default-features = false, version = "1" }
serde_with = { default-features = false, version = "3" }
thiserror = { default-features = false, version = "2" }
tokio = { default-features = false, version = "1.40" }
tracing = "0.1"
url = "2.5"
uuid = { default-features = false, version = "1" }
27 changes: 23 additions & 4 deletions Dockerfile.coordinator
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
FROM rust:1.90-alpine AS builder
FROM rust:1.90-alpine AS chef

RUN apk add --no-cache \
musl-dev

RUN cargo install cargo-chef --locked

WORKDIR /build

FROM chef AS planner

COPY Cargo.toml Cargo.lock ./
COPY bin/coordinator-server ./bin/coordinator-server
COPY crates ./crates

RUN cargo chef prepare --recipe-path recipe.json

FROM chef AS builder

COPY --from=planner /build/recipe.json recipe.json


RUN apk add --no-cache \
musl-dev \
pkgconfig \
openssl-dev \
openssl-libs-static \
perl \
make

WORKDIR /build
RUN cargo chef cook --release --recipe-path recipe.json --features sysbundle

COPY Cargo.toml Cargo.lock ./
COPY bin ./bin
COPY bin/coordinator-server ./bin/coordinator-server
COPY crates ./crates

RUN cargo build --release --bin miden-multisig-coordinator-server --features sysbundle
Expand Down
57 changes: 56 additions & 1 deletion bin/coordinator-frontend/lib/miden-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,62 @@ export class MidenWebClientHandle {
console.log("Initializing Miden Web Client...");
const nodeEndpoint = process.env.NEXT_PUBLIC_MIDEN_NODE_ENDPOINT || "https://rpc.testnet.miden.io:443";
console.log(`Using Miden node endpoint: ${nodeEndpoint}`);
this.webClient = await WebClient.createClient(nodeEndpoint);

try {
this.webClient = await WebClient.createClient(nodeEndpoint);
} catch (error: any) {
console.error("Error creating Miden client:", error);

// Check for specific IndexedDB upgrade error or generic WebStore initialization failure
// The SDK might wrap the underlying DB error into "Failed to initialize WebStore"
if (error?.message?.includes("UpgradeError") ||
error?.message?.includes("Not yet support for changing primary key") ||
error?.message?.includes("Failed to initialize WebStore") ||
error?.toString().includes("Failed to initialize WebStore")) {
console.warn("Database schema mismatch or init failure detected. Attempting to clear database...");

const DB_NAME = "MidenClientDB";

try {
await new Promise<void>((resolve, reject) => {
const req = indexedDB.deleteDatabase(DB_NAME);

// Add a timeout to prevent hanging
const timeoutId = setTimeout(() => {
reject(new Error("Database deletion timed out. Please close other tabs and reload."));
}, 5000);

req.onsuccess = () => {
clearTimeout(timeoutId);
console.log(`Successfully deleted database: ${DB_NAME}`);
resolve();
};

req.onerror = () => {
clearTimeout(timeoutId);
console.error(`Failed to delete database: ${DB_NAME}`);
reject(req.error);
};

req.onblocked = () => {
console.warn(`Database deletion blocked: ${DB_NAME}. Please close other tabs using this app.`);
// We don't reject immediately on blocked, as it might unblock if user closes tabs,
// but the timeout will catch it if it takes too long.
};
});

// Retry initialization
console.log("Retrying initialization after database cleanup...");
this.webClient = await WebClient.createClient(nodeEndpoint);
} catch (cleanupError) {
console.error("Failed to recover from database error:", cleanupError);
throw cleanupError; // Re-throw to be caught by outer catch
}
} else {
throw error;
}
}

console.log("Miden Web Client initialized successfully!");

return true;
Expand Down
Loading
Loading