diff --git a/lib/iden3comm/domain/entities/interaction/interaction_base_entity.dart b/lib/iden3comm/domain/entities/interaction/interaction_base_entity.dart index cecca303..4446693f 100644 --- a/lib/iden3comm/domain/entities/interaction/interaction_base_entity.dart +++ b/lib/iden3comm/domain/entities/interaction/interaction_base_entity.dart @@ -3,6 +3,7 @@ enum InteractionType { revocation, update, authRequest, + credentialProposal, } enum InteractionState { @@ -19,6 +20,7 @@ class InteractionBaseEntity { final InteractionState state; final int timestamp; final String message; + final String? to; InteractionBaseEntity({ required this.id, @@ -27,12 +29,14 @@ class InteractionBaseEntity { this.state = InteractionState.received, required this.timestamp, required this.message, + required this.to, }); factory InteractionBaseEntity.fromJson(Map json) { return InteractionBaseEntity( id: json['id'], from: json['from'], + to: json['to'], type: InteractionType.values.firstWhere((type) => type.name == json['type'] || type.toString() == json['type']), state: InteractionState.values.firstWhere((type) => @@ -49,11 +53,12 @@ class InteractionBaseEntity { 'state': state.toString(), 'timestamp': timestamp, 'message': message, + 'to': to, }; @override String toString() => - "[InteractionBaseEntity] {id: $id, from: $from, type: $type, state: $state, timestamp: $timestamp, message: $message}"; + "[InteractionBaseEntity] {id: $id, from: $from, type: $type, state: $state, timestamp: $timestamp, message: $message, to: $to}"; @override bool operator ==(Object other) => @@ -65,7 +70,8 @@ class InteractionBaseEntity { type == other.type && state == other.state && timestamp == other.timestamp && - message == other.message; + message == other.message && + to == other.to; @override int get hashCode => runtimeType.hashCode; diff --git a/lib/iden3comm/domain/entities/interaction/interaction_entity.dart b/lib/iden3comm/domain/entities/interaction/interaction_entity.dart index e5078d10..227ae0cf 100644 --- a/lib/iden3comm/domain/entities/interaction/interaction_entity.dart +++ b/lib/iden3comm/domain/entities/interaction/interaction_entity.dart @@ -7,6 +7,7 @@ class InteractionEntity extends InteractionBaseEntity { InteractionEntity({ required super.id, required super.from, + required super.to, required this.genesisDid, required this.profileNonce, required super.type, @@ -19,6 +20,7 @@ class InteractionEntity extends InteractionBaseEntity { return InteractionEntity( id: json['id'], from: json['from'], + to: json['to'], genesisDid: json['genesisDid'], profileNonce: BigInt.parse(json['profileNonce']), type: InteractionType.values.firstWhere((type) => @@ -48,6 +50,7 @@ class InteractionEntity extends InteractionBaseEntity { runtimeType == other.runtimeType && id == other.id && from == other.from && + to == other.to && genesisDid == other.genesisDid && profileNonce == other.profileNonce && type == other.type && diff --git a/lib/iden3comm/domain/use_cases/interaction/update_interaction_use_case.dart b/lib/iden3comm/domain/use_cases/interaction/update_interaction_use_case.dart index 9ed73a64..2c6c68f2 100644 --- a/lib/iden3comm/domain/use_cases/interaction/update_interaction_use_case.dart +++ b/lib/iden3comm/domain/use_cases/interaction/update_interaction_use_case.dart @@ -75,6 +75,7 @@ class UpdateInteractionUseCase timestamp: interactionToBeUpdated.timestamp, message: interactionToBeUpdated.message, state: param.state ?? interactionToBeUpdated.state, + to: interactionToBeUpdated.to, ); return _addInteractionUseCase.execute( param: AddInteractionParam( @@ -91,6 +92,7 @@ class UpdateInteractionUseCase timestamp: interactionToBeUpdated.timestamp, message: interactionToBeUpdated.message, state: param.state ?? interactionToBeUpdated.state, + to: interactionToBeUpdated.to, )) .then((interaction) => _addInteractionUseCase.execute( param: AddInteractionParam(interaction: interaction))) diff --git a/test/common/iden3comm_mocks.dart b/test/common/iden3comm_mocks.dart index a6cdd3c2..e7774765 100644 --- a/test/common/iden3comm_mocks.dart +++ b/test/common/iden3comm_mocks.dart @@ -292,14 +292,16 @@ class Iden3commMocks { static List interactionEntities = [ InteractionEntity( - id: CommonMocks.intValues[0].toString(), - from: CommonMocks.did, - genesisDid: CommonMocks.did, - profileNonce: CommonMocks.nonce, - type: InteractionType.offer, - timestamp: 0, - message: CommonMocks.message, - state: InteractionState.opened), + id: CommonMocks.intValues[0].toString(), + from: CommonMocks.did, + genesisDid: CommonMocks.did, + profileNonce: CommonMocks.nonce, + type: InteractionType.offer, + timestamp: 0, + message: CommonMocks.message, + state: InteractionState.opened, + to: CommonMocks.did, + ), InteractionEntity( id: CommonMocks.intValues[1].toString(), from: CommonMocks.did, @@ -309,15 +311,18 @@ class Iden3commMocks { timestamp: 0, message: CommonMocks.message, state: InteractionState.received, + to: CommonMocks.did, ), InteractionEntity( - id: CommonMocks.intValues[2].toString(), - from: CommonMocks.did, - genesisDid: CommonMocks.did, - profileNonce: CommonMocks.nonce, - type: InteractionType.offer, - timestamp: 0, - message: CommonMocks.message, - state: InteractionState.accepted), + id: CommonMocks.intValues[2].toString(), + from: CommonMocks.did, + genesisDid: CommonMocks.did, + profileNonce: CommonMocks.nonce, + type: InteractionType.offer, + timestamp: 0, + message: CommonMocks.message, + state: InteractionState.accepted, + to: CommonMocks.did, + ), ]; }