fromXdr method Null safety

ContractAuth fromXdr(
  1. XdrContractAuth xdr
)

Implementation

static ContractAuth fromXdr(XdrContractAuth xdr) {
  AuthorizedInvocation rootInvocation =
      AuthorizedInvocation.fromXdr(xdr.rootInvocation);
  Address? address;
  int? nonce;
  if (xdr.addressWithNonce != null) {
    address = Address.fromXdr(xdr.addressWithNonce!.address);
    nonce = xdr.addressWithNonce!.nonce.uint64;
  }

  // PATCH: See: https://discord.com/channels/897514728459468821/1076723574884282398/1078095366890729595
  List<XdrSCVal> argsArr = List<XdrSCVal>.empty(growable: true);
  if (xdr.signatureArgs.length > 0) {
    XdrSCVal innerVal = xdr.signatureArgs[0];
    if (innerVal.obj != null && innerVal.obj!.vec != null) {
      argsArr = innerVal.obj!.vec!;
    } else {
      argsArr = xdr.signatureArgs;
    }
  }
  return new ContractAuth(rootInvocation,
      signatureArgs: argsArr, address: address, nonce: nonce);
}