processJson method

  1. @override
Future<String> processJson(
  1. String jsonString
)
override

Implementation-specific: take the unsigned transaction JSON, compute the signing digests, and return the result transaction JSON string.

Implementation

@override
Future<String> processJson(String jsonString) async {
  _ensureInitialized();
  final memory = _memory!;
  final bytes = utf8.encode(jsonString);

  final alloc = _getFunc('alloc');
  final ptr = _toInt(alloc([bytes.length]));
  memory.buffer.asUint8List().setRange(ptr, ptr + bytes.length, bytes);

  try {
    final packed = _toInt(
      _getFunc('getUnsignedV2Transaction')([ptr, bytes.length]),
    );
    final resultPtr = _toInt(_getFunc('resultPtr')([packed]));
    final resultLen = _toInt(_getFunc('resultLen')([packed]));

    final resultBytes = memory.buffer.asUint8List().sublist(
      resultPtr,
      resultPtr + resultLen,
    );
    _getFunc('release')([resultPtr]);

    return utf8.decode(resultBytes);
  } finally {
    _getFunc('release')([ptr]);
  }
}