Refactor transaction events generator into one interface.
This commit is contained in:
parent
a003bd7124
commit
be3d389078
@ -30,10 +30,10 @@ export class BlockSyncService {
|
|||||||
settings.txHelper = new TransactionHelper(settings.w3.engine, settings.registry);
|
settings.txHelper = new TransactionHelper(settings.w3.engine, settings.registry);
|
||||||
|
|
||||||
settings.txHelper.ontransfer = async (transaction: any): Promise<void> => {
|
settings.txHelper.ontransfer = async (transaction: any): Promise<void> => {
|
||||||
window.dispatchEvent(this.newTransferEvent(transaction));
|
window.dispatchEvent(this.newEvent(transaction, 'cic_transfer'));
|
||||||
};
|
};
|
||||||
settings.txHelper.onconversion = async (transaction: any): Promise<any> => {
|
settings.txHelper.onconversion = async (transaction: any): Promise<any> => {
|
||||||
window.dispatchEvent(this.newConversionEvent(transaction));
|
window.dispatchEvent(this.newEvent(transaction, 'cic_convert'));
|
||||||
};
|
};
|
||||||
settings.registry.onload = (addressReturned: string): void => {
|
settings.registry.onload = (addressReturned: string): void => {
|
||||||
this.loggingService.sendInfoLevelMessage(`Loaded network contracts ${addressReturned}`);
|
this.loggingService.sendInfoLevelMessage(`Loaded network contracts ${addressReturned}`);
|
||||||
@ -76,16 +76,8 @@ export class BlockSyncService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
newTransferEvent(tx: any): any {
|
newEvent(tx: any, eventType: string): any {
|
||||||
return new CustomEvent('cic_transfer', {
|
return new CustomEvent(eventType, {
|
||||||
detail: {
|
|
||||||
tx,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
newConversionEvent(tx: any): any {
|
|
||||||
return new CustomEvent('cic_convert', {
|
|
||||||
detail: {
|
detail: {
|
||||||
tx,
|
tx,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user