screenTransaction method

  1. @override
Future<ScreenTransactionResponse> screenTransaction(
  1. String chain,
  2. ScreenTransactionContext context,
  3. String? networkId,
  4. String? senderAddress,
)
override

Screens a connected wallet's transaction for sanctioned addresses before you prompt it to sign, and returns the verdict. context carries the chain-specific payload the server extracts addresses from — see screenEvmTransactions/screenBitcoinTransactions/screenSolanaTransactions for the common chains, or build a ScreenTransactionContext by hand for anything else. networkId is recorded for audit only and never changes the verdict.

Implementation

@override
Future<ScreenTransactionResponse> screenTransaction(String chain, ScreenTransactionContext context, String? networkId, String? senderAddress) async {
  Future<ScreenTransactionResponse> instrumentationOperation() async {
    final operationScope = _state.flowScope.capture(replace: false);
    await operationScope.ready();
    if (!_state.initialized) {
      throw DynamicStateException("call initialize() before using the client");
    }
    if (_state.token == null) {
      throw DynamicStateException("not authenticated — sign in first");
    }
    operationScope.check();
    final verdict = await _api.post<ScreenTransactionResponse>(path: "/wallet/screenTransaction", body: <String, dynamic>{"chain": chain, "chainId": networkId, "senderAddress": senderAddress, "context": context}, token: _state.token, sessionPublicKey: _state.sessionPublicKey, parse: ScreenTransactionResponse.fromJson);
    operationScope.check();
    return verdict;
  }
  return await _api.instrumentation.runAsync("compliance.screenTransaction", instrumentationOperation);
}