getUserDID function

Future<String> getUserDID({
  1. required String address,
})

Implementation

Future<String> getUserDID({required String address}) async {
  if (isValidCAIP10NFTAddress(address)) {
    if (address.split(':').length == 6) {
      return address;
    }

    User? user = await getUser(address: address);
    if (user != null && user.did != null) {
      return user.did!;
    }

    var epoch = DateTime.now().millisecondsSinceEpoch ~/ 1000;
    address = '$address:$epoch';
  }

  if (isValidETHAddress(address)) {
    return walletToPCAIP10(address);
  }

  return address;
}