revocationTimestamp method
Implementation
Future<DateTime> revocationTimestamp(String credentialDid) async {
var revokedEvent = _contract.event('RevokedEvent');
var revEventSig = bytesToHex(revokedEvent.signature);
var deployedBlock = await deployed();
var logs = await web3Client.getLogs(FilterOptions(
address: _contract.address,
fromBlock: BlockNum.exact(deployedBlock!.toInt()),
topics: [
['0x${revEventSig.padLeft(64, '0')}'],
['0x${_didToAddress(credentialDid).hexNo0x.padLeft(64, '0')}']
]));
if (logs.isNotEmpty) {
var firstLog = logs.first;
var res = await _rpc.call('eth_getBlockByNumber', [
bytesToHex(intToBytes(BigInt.from(firstLog.blockNum!)),
include0x: true),
false
]);
return DateTime.fromMillisecondsSinceEpoch(
hexToDartInt(res.result['timestamp']) * 1000);
} else {
throw Exception('Credential was not revoked');
}
}