Repository metrics
- Stars
- (1 star)
- PR merge metrics
- (PR metrics pending)
Description
Here’s a refreshed template for your ethereum_wallet_view_safe_app, following the latest trends and improvements inspired by modern wallets like Gnosis Safe Wallet:
🛠 1. Upgrade Dependencies & Architecture
Migrate to safe-wallet-web@v1.44.x, the latest release as of late 2024 with enhanced EIP‑712 support, better gas estimation, and improved Safe App handling .
Use Modular UI stacks (React/TypeScript or Vue) mirroring Web3‑Wallet modular design—a flexible core, with separate connectors and UI components .
📁 2. Project Structure
/src/ /connectors/ // wallet connectors (MetaMask, WalletConnect, Safe) /utils/ // web3 helpers, formatters, EIP‑155, EIP‑712 /components/ Header.tsx BalanceView.tsx TxHistoryList.tsx SafeAppHandler.tsx /views/ Dashboard.tsx SendTokens.tsx App.tsx index.tsx safeConfig.ts // Safe config
⚙ 3. Core Connection Logic – Example (TypeScript + React):
import { SafeAppProvider, getSafeApiKit } from '@safe-global/safe-apps-provider'; import Safe, { SafeFactory, EthersAdapter } from '@safe-global/safe-core-sdk'; import { ethers } from 'ethers';
export async function initSafe() { const provider = new ethers.providers.Web3Provider((window as any).ethereum); const ethAdapter = new EthersAdapter({ ethers, signer: provider.getSigner() }); const safeFactory = await SafeFactory.create({ ethAdapter }); // Example: instantiate or connect to a known Safe const safeAddress = await Safe.create({ ethAdapter, safeAccountConfig: { owners: [await provider.getSigner().getAddress()], threshold: 1 } }); return safeAddress; }
export function SafeAppHandler() { const [safeInfo, setSafeInfo] = useState(null); useEffect(() => { const appProvider = new SafeAppProvider(window.ethereum, window.location.origin); const sdk = getSafeApiKit({ ethAdapter: appProvider.ethAdapter, safeAddress: appProvider.safeAddress }); sdk.getSafeInfo().then(setSafeInfo); }, []); // UI render }
💰 4. Display Balance & Historical Transactions
Utilize provider methods or Safe API SDK to fetch:
const balances = await sdk.getTokenBalances(); // Safe-specific assets const history = await sdk.getTransactions({ limit: 20 });
Render them with your BalanceView and TxHistoryList components.
📦 5. Sending Transactions via Safe
Example pattern—creating & submitting transactions instead of raw transfers (for multisig flow):
async function sendTx(to: string, valueWei: string, data = '0x') { const safeSdk = await Safe.create({ ethAdapter, safeAddress }); const safeTransaction = await safeSdk.createTransaction({ to, data, value: valueWei }); const txResponse = await safeSdk.executeTransaction(safeTransaction); await txResponse.transactionResponse?.wait(); }
📱 6. Safe App Integration
Ensure full compatibility with Safe app ecosystem:
Handle URL message signing & transaction requests using SafeAppProvider.
Support EIP‑712. Version 1.44+ includes typed-data support .
Use separate UI elements/messages like “Open in Safe” if not accessed inside a Safe context.
🎨 7. UI/UX Suggestions
Modern token view: fetch token logos via Coingecko/web3 or local SVG assets.
Gas & fee estimates: Use estimateGas and show fees to users upfront.
Themeable UI: Dark/light mode via CSS variables or Tailwind themes.
Error handling: Global error boundary for RPC/network issues.
✅ Checklist Summary
Task Status
Upgrade to safe-wallet-web latest version 🔲 Modular connector architecture 🔲 Wallet & Safe init 🔲 Balance fetch & rendering 🔲 Transaction history 🔲 EIP‑712 signing support 🔲 UX polish: gas, theme, logos 🔲
🚀 Next Steps
-
Update your package.json with the latest @safe-global/* dependencies.
-
Refactor your connection & UI layers using the new modular structure.
-
Deploy a prototype and test inside a Safe.
-
Iterate on UI/UX: improved experiences for token display, errors, themes.