getSigchainHash method

SealdGetSigchainResponse getSigchainHash(
  1. String userId, {
  2. int position = -1,
})

Get a user's sigchain transaction hash at index position.

userId - The Seald ID of the concerned user. position - Get the hash at the given position. -1 to get the last. Default to -1. Returns a SealdGetSigchainResponse instance.

Implementation

SealdGetSigchainResponse getSigchainHash(String userId, {int position = -1}) {
  if (_closed) {
    throw SealdException(
        code: "INSTANCE_CLOSED",
        id: "FLUTTER_INSTANCE_CLOSED",
        description: "Instance already closed.");
  }
  final Pointer<Utf8> nativeUserId = userId.toNativeUtf8();
  final Pointer<Pointer<NativeSealdGetSigchainResponse>> result =
      calloc<Pointer<NativeSealdGetSigchainResponse>>();
  final Pointer<Pointer<NativeSealdError>> err =
      calloc<Pointer<NativeSealdError>>();

  final int resultCode = _bindings.SealdSdk_GetSigchainHash(
      _ptr.pointer(), nativeUserId, position, result, err);

  if (resultCode != 0) {
    calloc.free(result);
    throw SealdException._fromCPtr(err);
  } else {
    final SealdGetSigchainResponse sigchainInfo =
        SealdGetSigchainResponse._fromC(result.value);
    calloc.free(result);
    calloc.free(err);
    return sigchainInfo;
  }
}