Skip to content
Closed
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
3 changes: 2 additions & 1 deletion demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ npm install
| `VITE_ADMIN_ADDRESS` | Admin/minter account address |
| `VITE_ADMIN_KEY` | Admin account private key |
| `VITE_ACCOUNTS` | JSON array of user accounts (see `.env.example`) |
| `VITE_PROVING_SERVICE_URL` | Optional. Proving service URL (e.g. `http://136.115.124.93:3000`). If unset, the app uses the mock prover (`execute_view` only) |

## Running

Expand Down Expand Up @@ -85,6 +86,6 @@ Open http://localhost:5173.

- **Vite + React + TypeScript** — single-page app
- **SDK consumption** — `starknet-sdk` linked from `../sdk` (same as e2e)
- **Proof provider** — `NoValidateProofProvider` calls `execute_view` directly (no real proving)
- **Proof provider** — With `VITE_PROVING_SERVICE_URL` set, uses the real proving service; otherwise `NoValidateProofProvider` calls `execute_view` directly (mock, no real proof). In the browser, the real prover requires the service to allow CORS.
- **Discovery** — `IndexerDiscoveryProvider` talks to the local discovery service
- **Resource bounds** — hardcoded for integration sepolia (2x headroom over actual block prices)
5 changes: 5 additions & 0 deletions demo/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export type AppConfig = {
adminAddress: string;
adminKey: string;
accounts: AccountConfig[];
/** Proving service URL (e.g. http://136.115.124.93:3000). If set, uses real prover; otherwise mock. */
provingServiceUrl?: string;
};

function requireEnv(key: string): string {
Expand Down Expand Up @@ -44,5 +46,8 @@ export function loadConfig(): AppConfig {
adminAddress: requireEnv("VITE_ADMIN_ADDRESS"),
adminKey: requireEnv("VITE_ADMIN_KEY"),
accounts,
provingServiceUrl: import.meta.env.VITE_PROVING_SERVICE_URL as
| string
| undefined,
};
}
9 changes: 9 additions & 0 deletions demo/src/hooks/useTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ export function useTransactions(

const executeTx = await userAccount.execute(callAndProof.call, {
resourceBounds: POOL_RESOURCE_BOUNDS,
...(callAndProof.proof.proofFacts?.length
? { proofFacts: callAndProof.proof.proofFacts }
: {}),
});
console.log(`[Deposit] pool tx: ${executeTx.transaction_hash}`);
const receipt = await provider.waitForTransaction(
Expand Down Expand Up @@ -160,6 +163,9 @@ export function useTransactions(

const executeTx = await userAccount.execute(callAndProof.call, {
resourceBounds: POOL_RESOURCE_BOUNDS,
...(callAndProof.proof.proofFacts?.length
? { proofFacts: callAndProof.proof.proofFacts }
: {}),
});
console.log(`[Withdraw] pool tx: ${executeTx.transaction_hash}`);
const receipt = await provider.waitForTransaction(
Expand Down Expand Up @@ -196,6 +202,9 @@ export function useTransactions(

const executeTx = await userAccount.execute(callAndProof.call, {
resourceBounds: POOL_RESOURCE_BOUNDS,
...(callAndProof.proof.proofFacts?.length
? { proofFacts: callAndProof.proof.proofFacts }
: {}),
});
console.log(`[Transfer] pool tx: ${executeTx.transaction_hash}`);
const receipt = await provider.waitForTransaction(
Expand Down
2 changes: 1 addition & 1 deletion demo/src/proof-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ export class NoValidateProofProvider implements ProofProviderInterface {
entrypoint: "execute_view",
calldata: invocation.calldata!,
});
return { output: result, outputHash: undefined!, data: undefined! };
return { output: result, data: undefined!, proofFacts: [] };
}
}
16 changes: 14 additions & 2 deletions demo/src/starknet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { Account, RpcProvider, type constants } from "starknet";
import { createPrivateTransfers, type PrivateTransfersInterface } from "starknet-sdk";
import {
createPrivateTransfers,
ProvingServiceProofProvider,
type PrivateTransfersInterface,
} from "starknet-sdk";
// Direct import avoids pulling in Node-only modules from the testing barrel
// @ts-expect-error — deep import into dist, not part of the declared exports
import { IndexerDiscoveryProvider } from "starknet-sdk/dist/internal/indexer-discovery.js";
Expand All @@ -25,10 +29,18 @@ export function createTransfers(
config: AppConfig,
): PrivateTransfersInterface {
const discovery = new IndexerDiscoveryProvider(config.indexerUrl);
const provingProvider = config.provingServiceUrl
? new ProvingServiceProofProvider(
config.provingServiceUrl,
provider,
config.chainId,
account,
)
: new NoValidateProofProvider(provider, config.chainId);
return createPrivateTransfers({
account,
viewingKeyProvider: { getViewingKey: () => BigInt(accountConfig.viewingKey) },
provingProvider: new NoValidateProofProvider(provider, config.chainId),
provingProvider,
discoveryProvider: discovery,
poolContractAddress: config.poolAddress,
});
Expand Down