@somnia-chain/markets-sdk / reactivity / unwrap
Function: unwrap()
unwrap<
T>(result):T
Defined in: packages/sdk/src/reactivity/index.ts:208
Turn an upstream result into a value or a throw.
Every @somnia-chain/reactivity method resolves to T | Error rather than
throwing — a shape a caller can forget to check, then treat a failure as a
transaction hash. This SDK's contract is that failures throw
(CONVENTIONS.md), so wrap upstream calls in unwrap to get that back.
ts
import { unwrap } from "@somnia-chain/markets-sdk/reactivity";
// Throws on a rejected subscription instead of returning an Error object.
const hash = unwrap(
await reactivity.subscribe({ handlerContractAddress, filter: { emitter }, options }),
);
Type Parameters
T
T
Parameters
result
Error | T
Whatever an upstream reactivity method resolved to.
Returns
T
result, narrowed to exclude Error.
Throws
The Error upstream returned, unchanged.