Skip to content

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 ​

CodeWhenWhat to do
REACT_WALLET_VERIFICATION_PROVIDER_REQUIREDA hook ran outside WalletVerificationProviderWrap the page in WalletVerificationProvider
REACT_CLIENT_ALREADY_PROVIDEDThe same client was passed to two providersOne provider per client instance
WALLET_VERIFICATION_IN_PROGRESSsetCustomerId / setNetwork / setAddress (or a second start) while a run is already goingWait, call cancel(), or verify({ transport: 'injected' }) to take over a live prepare()

All other codes match Core Errors.