diff --git a/package-lock.json b/package-lock.json index 87adc20..c1fa0a0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1620,6 +1620,20 @@ "node": ">=20" } }, + "node_modules/@coinbase/cdp-sdk/node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "optional": true, + "peer": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/@coinbase/wallet-sdk": { "version": "4.3.6", "resolved": "https://registry.npmjs.org/@coinbase/wallet-sdk/-/wallet-sdk-4.3.6.tgz", @@ -1929,6 +1943,20 @@ "node": ">= 6" } }, + "node_modules/@creit.tech/stellar-wallets-kit/node_modules/typescript": { + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "optional": true, + "peer": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "node_modules/@creit.tech/xbull-wallet-connect": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/@creit.tech/xbull-wallet-connect/-/xbull-wallet-connect-0.4.0.tgz", @@ -8185,6 +8213,20 @@ "ws": "^7.5.1" } }, + "node_modules/@walletconnect/jsonrpc-ws-connection/node_modules/utf-8-validate": { + "version": "5.0.10", + "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.10.tgz", + "integrity": "sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ==", + "hasInstallScript": true, + "optional": true, + "peer": true, + "dependencies": { + "node-gyp-build": "^4.3.0" + }, + "engines": { + "node": ">=6.14.2" + } + }, "node_modules/@walletconnect/jsonrpc-ws-connection/node_modules/ws": { "version": "7.5.13", "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.13.tgz", @@ -11610,6 +11652,19 @@ } } }, + "node_modules/html-encoding-sniffer/node_modules/@noble/hashes": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-2.4.0.tgz", + "integrity": "sha512-X5XaVWZIBCT7HHZGm5I7ZQXDwLG+bGXuSrMQAW+7Zvl87h1kmc1ZB1VSRJcpUfoUrGQp4Fkoxm5kZ+Ms+aW+eA==", + "optional": true, + "peer": true, + "engines": { + "node": ">= 20.19.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/http-errors": { "version": "1.7.2", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", @@ -12063,6 +12118,20 @@ "license": "MIT", "peer": true }, + "node_modules/jayson/node_modules/utf-8-validate": { + "version": "5.0.10", + "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.10.tgz", + "integrity": "sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ==", + "hasInstallScript": true, + "optional": true, + "peer": true, + "dependencies": { + "node-gyp-build": "^4.3.0" + }, + "engines": { + "node": ">=6.14.2" + } + }, "node_modules/jayson/node_modules/ws": { "version": "7.5.13", "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.13.tgz", @@ -12178,6 +12247,19 @@ } } }, + "node_modules/jsdom/node_modules/@noble/hashes": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-2.4.0.tgz", + "integrity": "sha512-X5XaVWZIBCT7HHZGm5I7ZQXDwLG+bGXuSrMQAW+7Zvl87h1kmc1ZB1VSRJcpUfoUrGQp4Fkoxm5kZ+Ms+aW+eA==", + "optional": true, + "peer": true, + "engines": { + "node": ">= 20.19.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/jsdom/node_modules/lru-cache": { "version": "11.5.2", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.2.tgz", @@ -16795,6 +16877,19 @@ } } }, + "node_modules/whatwg-url/node_modules/@noble/hashes": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-2.4.0.tgz", + "integrity": "sha512-X5XaVWZIBCT7HHZGm5I7ZQXDwLG+bGXuSrMQAW+7Zvl87h1kmc1ZB1VSRJcpUfoUrGQp4Fkoxm5kZ+Ms+aW+eA==", + "optional": true, + "peer": true, + "engines": { + "node": ">= 20.19.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/src/components/ClaimableBalanceCard.tsx b/src/components/ClaimableBalanceCard.tsx index 00580c1..9fb7036 100644 --- a/src/components/ClaimableBalanceCard.tsx +++ b/src/components/ClaimableBalanceCard.tsx @@ -168,6 +168,10 @@ export function ClaimableBalanceCard({ confirmThreshold }: ClaimableBalanceCardP const [loading, setLoading] = useState(false); const [error, setError] = useState(null); + function handleClaimSuccess(balanceId: string) { + setBalances((prev) => prev.filter((b) => b.id !== balanceId)); + } + useEffect(() => { if (!address || !client) { return; diff --git a/src/context/SorokitProvider.tsx b/src/context/SorokitProvider.tsx index 4f9d03b..ce78c5b 100644 --- a/src/context/SorokitProvider.tsx +++ b/src/context/SorokitProvider.tsx @@ -162,8 +162,17 @@ export function SorokitProvider({ if (!active) return; if (accountRes.data) setAccount(accountRes.data); if (balancesRes.data) setBalances(balancesRes.data); - if (accountRes.error) reportError(accountRes.error, "account", "error"); - else if (balancesRes.error) reportError(balancesRes.error, "account", "error"); + if (accountRes.error && balancesRes.error) { + reportError( + `${accountRes.error}; ${balancesRes.error}`, + "account", + "error", + ); + } else if (accountRes.error) { + reportError(accountRes.error, "account", "error"); + } else if (balancesRes.error) { + reportError(balancesRes.error, "account", "error"); + } }) .finally(() => { if (active) setIsLoadingAccount(false); @@ -189,6 +198,8 @@ export function SorokitProvider({ const connectWallet = useCallback(async () => { setIsConnecting(true); setWalletError(null); + setAccountError(null); + setNetworkError(null); try { const name = detectWalletName(); setWalletName(name); @@ -323,8 +334,17 @@ export function SorokitProvider({ ]); if (accountRes.data) setAccount(accountRes.data); if (balancesRes.data) setBalances(balancesRes.data); - if (accountRes.error) reportError(accountRes.error, "account", "error"); - else if (balancesRes.error) reportError(balancesRes.error, "account", "error"); + if (accountRes.error && balancesRes.error) { + reportError( + `${accountRes.error}; ${balancesRes.error}`, + "account", + "error", + ); + } else if (accountRes.error) { + reportError(accountRes.error, "account", "error"); + } else if (balancesRes.error) { + reportError(balancesRes.error, "account", "error"); + } } finally { setIsLoadingAccount(false); isRefreshingRef.current = false; diff --git a/src/lib/mock-client.ts b/src/lib/mock-client.ts index c9f4d6b..f643494 100644 --- a/src/lib/mock-client.ts +++ b/src/lib/mock-client.ts @@ -241,7 +241,7 @@ export function createMockClient( export function createMockClient( networkName?: string, ): SorokitClient | { data: null; error: string } { - const activeNetwork = + let activeNetwork = networkName && networkName in NETWORKS ? networkName : "testnet"; if (networkName && !(networkName in NETWORKS)) { @@ -433,10 +433,12 @@ export function createMockClient( }), switchNetwork: async (param: NetworkName | NetworkInfo) => { if (typeof param === "object" && param !== null) { + activeNetwork = param.name; return { data: { status: "online", ...param }, error: null }; } const info = MOCK_NETWORK_INFO[param]; if (info) { + activeNetwork = param; return { data: info, error: null }; } return { data: null, error: `Invalid network: ${param}` };