Appearance
Errors
Wallet verification failures throw ConnectSdkError with a stable code. Branch on code, not on message. Hooks also expose error on the last failure.
tsx
import {
ConnectSdkError,
ConnectSdkErrorCode,
} from '@swapped/connect-sdk/wallet-verification'
import { useVerifyWallet } from '@swapped/connect-sdk/wallet-verification/react'
const { prepare, verify, error } = useVerifyWallet()
try {
await verify({ provider })
} catch (caught) {
if (!(caught instanceof ConnectSdkError)) {
throw caught
}
switch (caught.code) {
case ConnectSdkErrorCode.WALLET_CONNECT_REJECTED:
case ConnectSdkErrorCode.WALLET_SIGNATURE_REJECTED:
case ConnectSdkErrorCode.WALLET_VERIFICATION_CANCELLED:
// user / merchant cancelled - offer retry
break
case ConnectSdkErrorCode.WALLET_POPUP_BLOCKED:
// ask to allow popups; retry from a click
break
default:
// show a retry message; keep the user on this step while pending
break
}
}React-only codes
| Code | When | What to do |
|---|---|---|
REACT_WALLET_VERIFICATION_PROVIDER_REQUIRED | A hook ran outside WalletVerificationProvider | Wrap the page in WalletVerificationProvider |
REACT_CLIENT_ALREADY_PROVIDED | The same client was passed to two providers | One provider per client instance |
WALLET_VERIFICATION_IN_PROGRESS | setCustomerId / setNetwork / setAddress (or a second start) while a run is already going | Wait, call cancel(), or verify({ transport: 'injected' }) to take over a live prepare() |
All other codes match Core Errors.