Skip to main content

Function: isWalletUserRejection()

GalaChain core SDK 1.0.0-rc.8


GalaChain core SDK 1.0.0-rc.8 / wallet / isWalletUserRejection

Function: isWalletUserRejection()

isWalletUserRejection(value): boolean

Defined in: packages/gala-core-sdk/dist/wallet.d.ts:58

True when a wallet's error (or just its message text) says the person DECLINED the request in their wallet. This is exactly the test behind SIGNING_FAILED with params.reason === 'user_rejected', exported for wallet code outside the SDK (connect and registration flows, a v1 write path) so an app keeps no matcher of its own.

It is decided from the wallet's own fields first: a code of 4001 (EIP-1193), 'ACTION_REJECTED' (ethers) or 'USER_REJECTED', or name === 'UserRejectedRequestError' (viem). Only when those are absent is the wallet's TEXT read (message, Message, shortMessage, details, errorDetails, reason, up to three levels deep, or a bare string): "user rejected", "user denied", "user cancelled", "request rejected", "rejected by user", "rejected the request", "cancelled" / "canceled", or a "signature ... cancel" sentence. The wording fallback is a last resort for wallets that do not set codes; prefer code and name wherever you control the wallet.

An SDK error is never read by its text: a SIGNING_FAILED is a decline exactly when its params.reason is user_rejected, and every other SDK error is not one. The same holds for a plain-object VIEW of an SDK error ({ code: 'SIGNING_FAILED', params: { reason } }, the shape of an app's wrapper): a string code plus an object params is decided by the code alone, with the wallet code list above still honoured for a view that is not branded, and its English is never read. This works without instanceof, so it is safe across two copies of the SDK.

Parameters​

value​

unknown

Returns​

boolean

Example​

try {
await wallet.connect();
} catch (error) {
if (isWalletUserRejection(error)) return; // the person said no: not an error to report
report(error);
}