Overview
Currently, critical blockchain actions in the Boundless platform can be performed without requiring users to connect their wallets. This creates a poor user experience and potential security issues. We need to implement a wallet protection system that shows a modal when wallet connection is required.
ETA: 48hrs
Ensure the ui aligns with our current design
Problem Statement
The following actions currently lack proper wallet connection validation:
- Launching Campaigns - Users can click "Launch Campaign" without wallet connection
- Backing Projects - Users can submit backing forms without wallet validation
- Project Initialization - Project creation lacks wallet authentication
- Milestone Management - Milestone operations don't verify wallet connection
Proposed Solution
Implement a custom hook (useWalletProtection) that:
- Shows a modal when wallet connection is required
- Provides a seamless wallet connection flow
- Validates wallet connection before allowing actions
- Integrates with existing wallet infrastructure
Technical Implementation
1. Custom Hook: hooks/use-wallet-protection.ts
export function useWalletProtection(options: UseWalletProtectionOptions = {}) {
const { actionName = 'perform this action', showModal = true } = options;
const { isConnected, publicKey } = useWalletStore();
const [showWalletModal, setShowWalletModal] = useState(false);
const requireWallet = (callback?: () => void) => {
if (!isConnected) {
if (showModal) {
setShowWalletModal(true);
} else {
toast.error(`Wallet connection required to ${actionName}`);
}
return false;
}
if (callback) {
callback();
}
return true;
};
return {
requireWallet,
isConnected,
publicKey,
showWalletModal,
handleWalletConnected,
closeWalletModal,
};
}
2. Modal Component: components/wallet/WalletRequiredModal.tsx
- Shows when wallet connection is required
- Explains why wallet connection is needed
- Provides wallet connection button
- Handles connection success callback
3. Enhanced WalletConnectButton
- Added
onConnect callback prop
- Integrates with ConnectWallet modal
- Triggers callback on successful connection
User Flow
- User clicks action button (e.g., "Launch Campaign")
- If wallet not connected → Modal appears with explanation
- User clicks "Connect Wallet" → Wallet connection modal opens
- User connects wallet → Modal closes, action proceeds
- If wallet already connected → Action proceeds immediately
Example Usage
Launch Campaign Flow:
const LaunchCampaignFlow = () => {
const { requireWallet, showWalletModal, handleWalletConnected } = useWalletProtection({
actionName: 'launch campaign'
});
const handleLaunch = () => {
requireWallet(() => {
// Proceed with campaign launch
launchCampaign(projectId);
});
};
return (
<>
<Button onClick={handleLaunch}>Launch Campaign</Button>
<WalletRequiredModal
open={showWalletModal}
onOpenChange={setShowWalletModal}
actionName="launch campaign"
onWalletConnected={handleWalletConnected}
/>
</>
);
};
Required Changes
-
Create new files:
hooks/use-wallet-protection.ts
components/wallet/WalletRequiredModal.tsx
-
Update existing files:
components/wallet/WalletConnectButton.tsx - Add onConnect prop
components/connect-wallet/index.tsx - Add onConnect callback
components/project/LaunchCampaignFlow.tsx - Implement wallet protection
components/flows/back-project/back-project-form.tsx - Add wallet validation
-
Integration points:
- All blockchain action buttons
- Form submission handlers
- API call wrappers
Acceptance Criteria
User Experience Requirements
-
Clear Messaging:
- Explain why wallet connection is required
- List benefits of wallet connection
- Provide clear next steps
-
Smooth Flow:
- Modal appears immediately when needed
- Wallet connection is straightforward
- Action proceeds automatically after connection
-
Error Handling:
- Graceful handling of connection failures
- Clear error messages
- Retry options available
Priority
High - This affects core platform security and user experience
Dependencies
- Existing wallet connection infrastructure
- Stellar SDK integration
- Current wallet store implementation
Overview
Currently, critical blockchain actions in the Boundless platform can be performed without requiring users to connect their wallets. This creates a poor user experience and potential security issues. We need to implement a wallet protection system that shows a modal when wallet connection is required.
ETA: 48hrs
Ensure the ui aligns with our current design
Problem Statement
The following actions currently lack proper wallet connection validation:
Proposed Solution
Implement a custom hook (
useWalletProtection) that:Technical Implementation
1. Custom Hook:
hooks/use-wallet-protection.ts2. Modal Component:
components/wallet/WalletRequiredModal.tsx3. Enhanced WalletConnectButton
onConnectcallback propUser Flow
Example Usage
Launch Campaign Flow:
Required Changes
Create new files:
hooks/use-wallet-protection.tscomponents/wallet/WalletRequiredModal.tsxUpdate existing files:
components/wallet/WalletConnectButton.tsx- Add onConnect propcomponents/connect-wallet/index.tsx- Add onConnect callbackcomponents/project/LaunchCampaignFlow.tsx- Implement wallet protectioncomponents/flows/back-project/back-project-form.tsx- Add wallet validationIntegration points:
Acceptance Criteria
useWalletProtectionhook created and testedWalletRequiredModalcomponent implementedUser Experience Requirements
Clear Messaging:
Smooth Flow:
Error Handling:
Priority
High - This affects core platform security and user experience
Dependencies