ChainHeadEvent.fromJson constructor
Parse a chainHead event from a JSON map.
Implementation
factory ChainHeadEvent.fromJson(Map<String, dynamic> json) {
final String event = json['event'] as String;
switch (event) {
case 'initialized':
return ChainHeadInitialized.fromJson(json);
case 'newBlock':
return ChainHeadNewBlock.fromJson(json);
case 'bestBlockChanged':
return ChainHeadBestBlockChanged.fromJson(json);
case 'finalized':
return ChainHeadFinalized.fromJson(json);
case 'stop':
return const ChainHeadStop();
case 'operationBodyDone':
return ChainHeadOperationBodyDone.fromJson(json);
case 'operationCallDone':
return ChainHeadOperationCallDone.fromJson(json);
case 'operationStorageItems':
return ChainHeadOperationStorageItems.fromJson(json);
case 'operationStorageDone':
return ChainHeadOperationStorageDone.fromJson(json);
case 'operationError':
return ChainHeadOperationError.fromJson(json);
case 'operationInaccessible':
return ChainHeadOperationInaccessible.fromJson(json);
default:
throw Exception('Unknown chainHead event type: $event');
}
}