public override async Task <string> GetCredentialsAsync( VASPId vaspId, VASPCredentialsRef vaspCredentialsRef, ConfirmationLevel minimalConfirmationLevel = default) { var vaspCredentialsRefString = vaspCredentialsRef.ToString(); if (!_vaspCredentialsRefRegex.IsMatch(vaspCredentialsRefString)) { throw new FormatException("Specified VASP credentials ref is not properly formatted to be used with a VASP directory."); } var credentialsInsertedEventHandler = Web3.Eth.GetEvent <CredentialsInsertedEvent>(ContractAddress); var credentialsInsertedEventFilter = credentialsInsertedEventHandler.CreateFilterInput ( firstIndexedParameterValue: (byte[])vaspId, secondIndexedParameterValue: vaspCredentialsRefString.HexToByteArray(), fromBlock: BlockParameter.CreateEarliest(), toBlock: await Web3.GetBestTrustedBlockAsync(minimalConfirmationLevel) ); var latestCredentials = (await credentialsInsertedEventHandler.GetAllChanges(credentialsInsertedEventFilter)) .OrderBy(x => x.Log.BlockNumber) .Select(x => x.Event.Credentials) .LastOrDefault() ?? string.Empty; return(latestCredentials); }
public static async Task <bool> VASPIsRegisteredAsync( this IVASPDirectoryClient vaspDirectory, VASPId vaspId, ConfirmationLevel minimalConfirmationLevel = default) { var refAndHash = await vaspDirectory.GetCredentialsRefAndHashAsync(vaspId, minimalConfirmationLevel); return(VASPIsRegistered(refAndHash)); }
public static async Task <(bool VASPIsRegistered, string Credentials)> TryGetCredentialsAsync( this IVASPDirectoryClient vaspDirectory, VASPId vaspId, ConfirmationLevel minimalConfirmationLevel = default) { var(vaspIsRegistered, (@ref, _)) = await vaspDirectory.TryGetCredentialsRefAndHashAsync(vaspId, minimalConfirmationLevel); var credentials = vaspIsRegistered ? await vaspDirectory.GetCredentialsAsync(vaspId, @ref, minimalConfirmationLevel) : string.Empty; return(vaspIsRegistered, credentials); }
public override async Task <VASPCredentialsRefAndHash> GetCredentialsRefAndHashAsync( VASPId vaspId, ConfirmationLevel minimalConfirmationLevel = default) { var vaspCredentialsRefAndHash = await base.GetCredentialsRefAndHashAsync(vaspId, minimalConfirmationLevel); var(@ref, hash) = vaspCredentialsRefAndHash; if (VASPCredentialsRef.IsEmpty(@ref) != VASPCredentialsHash.IsEmpty(hash)) { throw new Exception("Smart contract returned an unexpected combination of VASP credentials reference and hash."); } return(vaspCredentialsRefAndHash); }
public virtual async Task <VASPCredentialsRefAndHash> GetCredentialsRefAndHashAsync( VASPId vaspId, ConfirmationLevel minimalConfirmationLevel = default) { var callResult = await CallWithComplexResultAsync ( new GetCredentialsRefCall { VASPId = vaspId }, minimalConfirmationLevel ); return(new VASPCredentialsRefAndHash ( new VASPCredentialsHash(callResult.CredentialsHashBytes), new VASPCredentialsRef(callResult.CredentialsRefString) )); }
public static bool IsEmpty( VASPId vaspId) { return(ByteArray <Digest> .IsEmpty(vaspId._value)); }
public bool Equals( VASPId other) { return(_value.Equals(other._value)); }
public abstract Task <string> GetCredentialsAsync( VASPId vaspId, VASPCredentialsRef vaspCredentialsRef, ConfirmationLevel minimalConfirmationLevel = default);