π Framework Detection
SuperSafe Wallet automatically detects dApp frameworks and adapts connection behavior accordingly, ensuring seamless integration with RainbowKit, Wagmi, Dynamic, and other popular frameworks.
Overviewβ
SuperSafe implements automatic framework detection to provide optimal connection behavior for different dApp frameworks. This ensures compatibility with modern React-based dApp frameworks without requiring manual configuration.
Supported Frameworksβ
- β RainbowKit: Full compatibility with RainbowKit's provider detection
- β Wagmi: React hooks compatibility
- β Dynamic: Framework detection and adaptation
- β Web3-React: Standard web3-react compatibility
- β WalletConnect: WalletConnect v2/Reown integration
Automatic Detection Systemβ
Location: src/utils/dAppFrameworkDetector.js
Detection Logicβ
export function detectDAppFramework(origin, injectedObjects = {}) {
const detectionResults = {
framework: 'unknown',
confidence: 'low',
indicators: []
};
// Check for RainbowKit
if (injectedObjects.isRainbowKit ||
window.location.href.includes('rainbow')) {
detectionResults.framework = 'rainbowkit';
detectionResults.confidence = 'high';
detectionResults.indicators.push('RainbowKit detected');
}
// Check for Wagmi
else if (injectedObjects.isWagmi) {
detectionResults.framework = 'wagmi';
detectionResults.confidence = 'high';
detectionResults.indicators.push('Wagmi detected');
}
// Check for Dynamic
else if (window.dynamic || injectedObjects.isDynamic) {
detectionResults.framework = 'dynamic';
detectionResults.confidence = 'high';
detectionResults.indicators.push('Dynamic detected');
}
// Check for Web3-React
else if (injectedObjects.isWeb3React) {
detectionResults.framework = 'web3-react';
detectionResults.confidence = 'medium';
}
return detectionResults;
}
Detection Indicatorsβ
The detection system uses multiple indicators to identify frameworks:
- Window Object Properties: Checks for framework-specific global objects
- URL Patterns: Analyzes URL patterns for framework-specific paths
- Injected Objects: Checks for framework-specific injected objects
- Event Listeners: Monitors for framework-specific event patterns
Framework-Specific Strategiesβ
Location: src/background/strategy/ConnectionStrategies.js
Strategy Configurationβ
export function getConnectionStrategy(framework) {
const strategies = {
rainbowkit: {
name: 'RainbowKit',
requiresImmediateResponse: true,
supportsAccountsChanged: true,
supportsChainChanged: true,
handshake: null // Smart Native Connection
},
wagmi: {
name: 'Wagmi',
requiresImmediateResponse: true,
supportsAccountsChanged: true,
supportsChainChanged: true,
handshake: null
},
walletconnect: {
name: 'WalletConnect',
requiresSession: true,
supportsMultiChain: true,
usesNamespaces: true
}
};
return strategies[framework] || strategies.rainbowkit;
}
RainbowKit Strategyβ
Characteristics:
- Uses EIP-6963 provider discovery
- Supports automatic wallet detection
- Requires immediate response to connection requests
- Fully compatible with Smart Native Connection
Connection Flow:
- RainbowKit detects SuperSafe via EIP-6963
- User clicks "Connect Wallet" in RainbowKit UI
- RainbowKit calls
eth_requestAccounts - SuperSafe shows connection popup
- User approves connection
- RainbowKit receives account address
- Connection established
Wagmi Strategyβ
Characteristics:
- Uses React hooks for wallet connection
- Supports EIP-6963 provider discovery
- Requires immediate response to connection requests
- Compatible with Smart Native Connection
Connection Flow:
- Wagmi detects SuperSafe via EIP-6963
- Wagmi hook calls
eth_requestAccounts - SuperSafe shows connection popup
- User approves connection
- Wagmi hook receives account address
- Connection established
Dynamic Strategyβ
Characteristics:
- Uses Dynamic SDK for wallet connection
- Supports multiple wallet providers
- Requires framework-specific detection
- Adapts connection behavior for Dynamic
Connection Flow:
- Dynamic detects SuperSafe provider
- Dynamic SDK initiates connection
- SuperSafe shows connection popup
- User approves connection
- Dynamic SDK receives account address
- Connection established
EIP-6963 Provider Discoveryβ
Overviewβ
EIP-6963 provides a standardized way for wallets to announce themselves to dApps, enabling automatic detection without relying on window.ethereum.
Implementationβ
// EIP-6963: Announce provider to dApps
function announceProvider(provider) {
const detail = {
info: {
uuid: 'super-safe-wallet',
name: 'SuperSafe',
icon: 'data:image/svg+xml;base64,...',
rdns: 'cool.supersafe'
},
provider: provider
};
// Announce provider
window.dispatchEvent(new CustomEvent('eip6963:announceProvider', {
detail: detail
}));
// Listen for provider requests
window.addEventListener('eip6963:requestProvider', () => {
window.dispatchEvent(new CustomEvent('eip6963:announceProvider', {
detail: detail
}));
});
}
Benefitsβ
- β RainbowKit/Wagmi Automatic Detection: Frameworks automatically detect SuperSafe
- β Multi-Wallet Coexistence: Multiple wallets can coexist without conflicts
- β Standardized Discovery Protocol: Follows EIP-6963 standard
- β Better dApp Compatibility: Works with modern dApp frameworks
Framework Detection in Actionβ
RainbowKit Detectionβ
When a RainbowKit dApp loads:
- Framework Detection: SuperSafe detects RainbowKit indicators
- Provider Announcement: SuperSafe announces via EIP-6963
- RainbowKit Detection: RainbowKit detects SuperSafe provider
- Connection Ready: RainbowKit shows SuperSafe in wallet list
- User Selection: User selects SuperSafe from RainbowKit UI
- Connection Established: Connection proceeds normally
Wagmi Detectionβ
When a Wagmi dApp loads:
- Framework Detection: SuperSafe detects Wagmi indicators
- Provider Announcement: SuperSafe announces via EIP-6963
- Wagmi Detection: Wagmi detects SuperSafe provider
- Hook Integration: Wagmi hooks integrate with SuperSafe provider
- Connection Ready: Wagmi hooks ready for connection
- User Interaction: User triggers connection via Wagmi hook
- Connection Established: Connection proceeds normally
AllowList Integrationβ
Framework detection integrates with the AllowList system:
{
"version": "1.0.0",
"policies": {
"https://velodrome.finance": {
"name": "Velodrome Finance",
"supportedChains": [10, 5330],
"defaultChain": 10,
"autoApprove": false,
"requiresConsent": true,
"framework": "rainbowkit"
}
}
}
The framework field in allowlist policies helps SuperSafe:
- Optimize connection behavior for specific frameworks
- Provide framework-specific error messages
- Adapt UI/UX for framework-specific patterns
Debugging Framework Detectionβ
Checking Detection Resultsβ
To check which framework was detected:
- Open browser console
- Check for SuperSafe detection logs
- Look for framework detection indicators
- Verify EIP-6963 announcements
Common Issuesβ
Framework Not Detected:
- Check if framework is supported
- Verify EIP-6963 implementation
- Check browser console for errors
Connection Not Working:
- Verify framework is in allowlist
- Check network compatibility
- Verify provider injection
Document Status: β
Current as of November 15, 2025
Code Version: v3.0.0+
Maintenance: Review after adding new framework support