Skip to content

Commit a4ff89d

Browse files
committed
Map enriched event types to the child objects they will contain
Signed-off-by: Andrew Richardson <[email protected]>
1 parent 089f39b commit a4ff89d

File tree

1 file changed

+52
-16
lines changed

1 file changed

+52
-16
lines changed

lib/interfaces.ts

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -146,27 +146,63 @@ export interface FireFlyEphemeralSubscription extends FireFlySubscriptionBase {
146146
namespace: string;
147147
}
148148

149-
export interface FireFlyEnrichedEvent extends FireFlyEventResponse {
150-
blockchainEvent?: FireFlyBlockchainEventResponse;
151-
contractAPI?: FireFlyContractAPIResponse;
152-
contractInterface?: FireFlyContractInterfaceResponse;
153-
datatype?: FireFlyDatatypeResponse;
154-
identity?: FireFlyIdentityResponse;
155-
message?: FireFlyMessageResponse;
156-
tokenApproval?: FireFlyTokenApprovalResponse;
157-
tokenPool?: FireFlyTokenPoolResponse;
158-
tokenTransfer?: FireFlyTokenTransferResponse;
159-
transaction?: FireFlyTransactionResponse;
160-
operation?: FireFlyOperationResponse;
161-
}
162-
163-
export interface FireFlyEventDelivery extends FireFlyEnrichedEvent {
149+
export type FireFlyEnrichedEvent = FireFlyEventResponse &
150+
(
151+
| {
152+
type: 'transaction_submitted';
153+
transaction: FireFlyTransactionResponse;
154+
}
155+
| {
156+
type: 'message_confirmed' | 'message_rejected';
157+
message: FireFlyMessageResponse;
158+
}
159+
| {
160+
type: 'identity_confirmed' | 'identity_updated';
161+
identity: FireFlyIdentityResponse;
162+
}
163+
| {
164+
type: 'token_pool_confirmed';
165+
tokenPool: FireFlyTokenPoolResponse;
166+
}
167+
| {
168+
type: 'token_transfer_confirmed';
169+
tokenTransfer: FireFlyTokenTransferResponse;
170+
}
171+
| {
172+
type: 'token_approval_confirmed';
173+
tokenApproval: FireFlyTokenApprovalResponse;
174+
}
175+
| {
176+
type: 'contract_interface_confirmed';
177+
contractInterface: FireFlyContractInterfaceResponse;
178+
}
179+
| {
180+
type: 'contract_api_confirmed';
181+
contractAPI: FireFlyContractAPIResponse;
182+
}
183+
| {
184+
type: 'blockchain_event_received';
185+
blockchainEvent: FireFlyBlockchainEventResponse;
186+
}
187+
| {
188+
type:
189+
| 'token_pool_op_failed'
190+
| 'token_approval_op_failed'
191+
| 'blockchain_invoke_op_succeeded'
192+
| 'blockchain_invoke_op_failed'
193+
| 'blockchain_contract_deploy_op_succeeded'
194+
| 'blockchain_contract_deploy_op_failed';
195+
operation: FireFlyOperationResponse;
196+
}
197+
);
198+
199+
export type FireFlyEventDelivery = FireFlyEnrichedEvent & {
164200
subscription: {
165201
id: string;
166202
name: string;
167203
namespace: string;
168204
};
169-
}
205+
};
170206

171207
// Datatypes
172208

0 commit comments

Comments
 (0)