getCreatedContractId method Null safety

String? getCreatedContractId()

Extracts the contract is from the response if the transaction created a contract

Implementation

String? getCreatedContractId() {
  XdrSCVal? resultValue = getResultValue();
  if (resultValue != null &&
      resultValue.discriminant == XdrSCValType.SCV_ADDRESS &&
      resultValue.address != null) {
    XdrSCAddress address = resultValue.address!;
    if (address.discriminant == XdrSCAddressType.SC_ADDRESS_TYPE_CONTRACT &&
        address.contractId != null) {
      return Util.bytesToHex(address.contractId!.hash);
    }
  }
  return null;
}