import React from "react"; import { deriveMPBBridgeFlowState } from "../../sdk/mpbridge/flow/bridgeFlowState"; interface FlowStateStoryProps { status?: string; errorMessage?: string; isSwitchingChain?: boolean; approveHash?: string; currentHash?: string; } const FlowStatePreview = ({ status, errorMessage, isSwitchingChain, approveHash, currentHash }: FlowStateStoryProps) => { const flow = deriveMPBBridgeFlowState({ bridgeStatus: { status, errorMessage, transaction: currentHash ? { hash: currentHash } : undefined }, isSwitchingChain, previousTxHashes: approveHash ? { approve: approveHash } : undefined }); return (
Input status: {status || "(none)"}
Flow state: {flow.state}
Label: {flow.statusLabel || "(empty)"}
{JSON.stringify(flow, null, 2)}
); }; export default { title: "MPBBridge/Flow States", component: FlowStatePreview }; export const AwaitingNetworkSwitch = { args: { status: "PendingSignature", errorMessage: "Switch requested", isSwitchingChain: true } }; export const AwaitingApprovalSignature = { args: { status: "PendingSignature", currentHash: "0xapprove" } }; export const AwaitingBridgeSignature = { args: { status: "PendingSignature", approveHash: "0xapprove", currentHash: "0xbridge" } }; export const BridgeMining = { args: { status: "Mining", approveHash: "0xapprove", currentHash: "0xbridge" } }; export const Cancelled = { args: { status: "Fail", errorMessage: "User rejected transaction" } }; export const Failed = { args: { status: "Exception", errorMessage: "Bridge fee not available" } }; export const Success = { args: { status: "Success", approveHash: "0xapprove", currentHash: "0xbridge" } };