File tree Expand file tree Collapse file tree 4 files changed +31
-18
lines changed Expand file tree Collapse file tree 4 files changed +31
-18
lines changed Original file line number Diff line number Diff line change @@ -24,8 +24,9 @@ describe('Dm3Sdk', () => {
2424 backendUrl : 'backend.io' ,
2525 } ;
2626
27- const sdk = new Dm3Sdk ( mockConfig ) ;
28-
29- const dm3 = await sdk . universalProfileLogin ( ) ;
27+ const dm3 = await new Dm3Sdk ( ) . universalProfileLogin ( ) ;
28+ await dm3 . conversations . addConversation ( 'karl.eth' ) ;
29+ const c = dm3 . conversations . list ;
30+ const karl = c [ 0 ] ;
3031 } ) ;
3132} ) ;
Original file line number Diff line number Diff line change @@ -14,6 +14,13 @@ import { ethers } from 'ethers';
1414import { Tld } from './tld/Tld' ;
1515import { Dm3 } from './Dm3' ;
1616
17+ /**
18+ * DM3SDK
19+ * -contacts
20+ * -message
21+ * -profile
22+ */
23+
1724const DEFAULT_CONVERSATION_PAGE_SIZE = 10 ;
1825
1926export function getIdForAddress ( address : string , addrEnsSubdomain : string ) {
@@ -62,14 +69,17 @@ export class Dm3Sdk {
6269 public conversations : Conversations ;
6370
6471 constructor ( config : Dm3SdkConfig ) {
72+ //TODO keep ethers v5 for know but extract into common interface later
6573 this . mainnetProvider = config . mainnetProvider ;
6674 this . nonce = config . nonce ;
75+ //TODO make the name more concise and make it a array -> defaultDeliveryServiceEnsNames
6776 this . defaultDeliveryService = config . defaultDeliveryService ;
6877 this . addressEnsSubdomain = config . addressEnsSubdomain ;
6978 this . userEnsSubdomain = config . userEnsSubdomain ;
7079 this . resolverBackendUrl = config . resolverBackendUrl ;
71- this . backendUrl = config . backendUrl ;
80+ // this.backendUrl = config.backendUrl;
7281 this . lukso = config . lukso ;
82+ this . storageApi = config . storageApi ;
7383 }
7484
7585 public async universalProfileLogin ( ) {
Original file line number Diff line number Diff line change @@ -4,20 +4,24 @@ import {
44 getAccountDisplayName ,
55} from '@dm3-org/dm3-lib-profile' ;
66
7- export interface Contact {
8- account : Account ;
9- deliveryServiceProfiles : DeliveryServiceProfile [ ] ;
7+ class Messages {
8+ public readonly list : string [ ] ;
9+ public addMessage ( message : string ) { }
1010}
1111
12- export interface ContactPreview {
12+ interface Contact {
1313 name : string ;
1414 contactProfileLocation : string [ ] ;
15- message : string | undefined ;
1615 image : string ;
17- contactDetails : Contact ;
1816 isHidden : boolean ;
1917 messageSizeLimit : number ;
2018 updatedAt : number ;
19+ account : Account ;
20+ deliveryServiceProfiles : DeliveryServiceProfile [ ] ;
21+ }
22+ export interface Conversation {
23+ messages : Messages ;
24+ contact : Contact ;
2125}
2226
2327export const getEmptyContact = (
@@ -27,17 +31,15 @@ export const getEmptyContact = (
2731 updatedAt : number ,
2832 contactProfileLocation : string [ ] ,
2933) => {
30- const newContact : ContactPreview = {
34+ const newContact : Contact = {
3135 name : getAccountDisplayName ( ensName , 25 ) ,
3236 contactProfileLocation,
33- message,
37+ previewMessage : message ,
3438 image : '' ,
35- contactDetails : {
36- account : {
37- ensName,
38- } ,
39- deliveryServiceProfiles : [ ] ,
39+ account : {
40+ ensName,
4041 } ,
42+ deliveryServiceProfiles : [ ] ,
4143 isHidden,
4244 messageSizeLimit : 0 ,
4345 updatedAt : updatedAt ,
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ export class EthAddressResolver implements ITLDResolver {
1919 return ensName . split ( '.' ) [ 0 ] ;
2020 }
2121 //The alias format is used to store the contact in the DB
22- //e.g. 0x1234 -> 0x1234.user .dm3.eth
22+ //e.g. 0x1234 -> 0x1234.addr .dm3.eth
2323 async resolveTLDtoAlias ( address : string ) : Promise < string > {
2424 return address + this . addrEnsSubdomain ;
2525 }
You can’t perform that action at this time.
0 commit comments