@@ -15,8 +15,6 @@ import {
1515 Channel ,
1616 type SendAlertRequest ,
1717} from '../../dialect-cloud-api/v2/application-api' ;
18- import { IllegalStateError } from '../../sdk/errors' ;
19- import type { DataServiceDappsApi } from '../../dialect-cloud-api/data-service-dapps-api' ;
2018import { withErrorParsing } from '../../dialect-cloud-api/data-service-errors' ;
2119
2220export const AddressTypeToChannel = {
@@ -28,23 +26,21 @@ export const AddressTypeToChannel = {
2826
2927export class AlertsV2DappMessages implements DappMessages {
3028 constructor (
31- private readonly dapps : DataServiceDappsApi ,
29+ private readonly dappId : string ,
3230 private readonly api : AppV2Api ,
3331 ) { }
3432
3533 async send ( command : SendDappMessageCommand ) : Promise < void > {
36- const dapp = await withErrorParsing ( this . dapps . find ( ) ) ; // TODO: cache
37-
3834 if ( command . addressTypes ?. length === 0 ) {
3935 return ;
4036 }
4137 if ( 'recipient' in command ) {
42- return this . unicast ( command , dapp . id ) ;
38+ return this . unicast ( command ) ;
4339 }
4440 if ( 'recipients' in command ) {
45- return this . multicast ( command , dapp . id ) ;
41+ return this . multicast ( command ) ;
4642 }
47- return this . broadcast ( command , dapp . id ) ;
43+ return this . broadcast ( command ) ;
4844 }
4945
5046 static mapChannels ( addressTypes ?: AddressType [ ] ) {
@@ -76,9 +72,9 @@ export class AlertsV2DappMessages implements DappMessages {
7672 }
7773 }
7874
79- private async unicast ( command : UnicastDappMessageCommand , appId : string ) {
75+ private async unicast ( command : UnicastDappMessageCommand ) {
8076 await withErrorParsing (
81- this . api . sendAlert ( appId , {
77+ this . api . sendAlert ( this . dappId , {
8278 recipient : {
8379 type : 'subscriber' ,
8480 walletAddress : command . recipient . toString ( ) ,
@@ -95,7 +91,7 @@ export class AlertsV2DappMessages implements DappMessages {
9591 ) ;
9692 }
9793
98- private async multicast ( command : MulticastDappMessageCommand , appId : string ) {
94+ private async multicast ( command : MulticastDappMessageCommand ) {
9995 if ( command . recipients . length === 0 ) {
10096 return ;
10197 }
@@ -117,15 +113,15 @@ export class AlertsV2DappMessages implements DappMessages {
117113 } satisfies SendAlertRequest ) ,
118114 ) ;
119115 await withErrorParsing (
120- this . api . sendBatch ( appId , {
116+ this . api . sendBatch ( this . dappId , {
121117 alerts : commands ,
122118 } ) ,
123119 ) ;
124120 }
125121
126- private async broadcast ( command : BroadcastDappMessageCommand , appId : string ) {
122+ private async broadcast ( command : BroadcastDappMessageCommand ) {
127123 await withErrorParsing (
128- this . api . sendAlert ( appId , {
124+ this . api . sendAlert ( this . dappId , {
129125 recipient : {
130126 type : 'all-subscribers' ,
131127 } ,
0 commit comments