decode method Null safety

XdrHostFunction decode(
  1. XdrDataInputStream stream
)

Implementation

static XdrHostFunction decode(XdrDataInputStream stream) {
  XdrHostFunction decoded =
      XdrHostFunction(XdrHostFunctionType.decode(stream));
  switch (decoded.type) {
    case XdrHostFunctionType.HOST_FUNCTION_TYPE_INVOKE_CONTRACT:
      int vecSize = stream.readInt();
      decoded.invokeContract = List<XdrSCVal>.empty(growable: true);
      for (int i = 0; i < vecSize; i++) {
        decoded.invokeContract!.add(XdrSCVal.decode(stream));
      }
      break;
    case XdrHostFunctionType.HOST_FUNCTION_TYPE_CREATE_CONTRACT:
      decoded.createContract = XdrCreateContractArgs.decode(stream);
      break;
    case XdrHostFunctionType.HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM:
      decoded.wasm = XdrDataValue.decode(stream);
      break;
  }
  return decoded;
}