1
1
import ERC725 , { ERC725JSONSchema } from '@erc725/erc725.js' ;
2
- import { Dm3KeyStore } from '../KeyStore/IKeyStore' ;
2
+ import { IDm3KeyStore } from '../KeyStore/IKeyStore' ;
3
3
import { EncodeDataReturn } from '@erc725/erc725.js/build/main/src/types' ;
4
4
import { ethers } from 'ethers' ;
5
5
import {
8
8
} from '@erc725/erc725.js/build/main/src/types/decodeData' ;
9
9
import LSP6Schema from '@erc725/erc725.js/schemas/LSP6KeyManager.json' ;
10
10
import { SignedUserProfile } from '@dm3-org/dm3-lib-profile' ;
11
+ import { isStringArray } from './utils/isStringArray' ;
11
12
12
13
export class ERC725JsonCoder {
13
14
public static readonly schemas : ERC725JSONSchema [ ] = [
@@ -96,7 +97,7 @@ export class ERC725JsonCoder {
96
97
keyName : 'DM3UserProfile:<address>' ,
97
98
dynamicKeyParts : upAddress ,
98
99
} ) ;
99
- if ( encodedUserProfile . value === null ) {
100
+ if ( ! isStringArray ( encodedUserProfile . value ) ) {
100
101
return undefined ;
101
102
}
102
103
@@ -105,25 +106,22 @@ export class ERC725JsonCoder {
105
106
publicEncryptionKey ,
106
107
deliveryServices ,
107
108
signature ,
108
- ] = encodedUserProfile . value as Data [ ] ;
109
+ ] = encodedUserProfile . value ;
109
110
110
111
return {
111
112
profile : {
112
- publicSigningKey : ethers . utils . toUtf8String (
113
- publicSigningKey as string ,
114
- ) ,
115
- publicEncryptionKey : ethers . utils . toUtf8String (
116
- publicEncryptionKey as string ,
117
- ) ,
113
+ publicSigningKey : ethers . utils . toUtf8String ( publicSigningKey ) ,
114
+ publicEncryptionKey :
115
+ ethers . utils . toUtf8String ( publicEncryptionKey ) ,
118
116
deliveryServices : JSON . parse (
119
- ethers . utils . toUtf8String ( deliveryServices as string ) ,
117
+ ethers . utils . toUtf8String ( deliveryServices ) ,
120
118
) ,
121
119
} ,
122
- signature : ethers . utils . toUtf8String ( signature as string ) ,
120
+ signature : ethers . utils . toUtf8String ( signature ) ,
123
121
} ;
124
122
}
125
123
126
- public async decodeDm3KeyStore ( ) : Promise < Dm3KeyStore > {
124
+ public async decodeDm3KeyStore ( ) : Promise < IDm3KeyStore > {
127
125
const controllerAddresses = await this . erc725 . getData (
128
126
'AddressPermissions[]' ,
129
127
) ;
@@ -150,10 +148,8 @@ export class ERC725JsonCoder {
150
148
) ,
151
149
} ;
152
150
return acc ;
153
- } , { } as Dm3KeyStore ) ;
151
+ } , { } as IDm3KeyStore ) ;
154
152
155
153
return ks ;
156
154
}
157
155
}
158
- //"0x89197c814f5df4249c180000c73abaa79d9d562d07f09d8135b72b047908bbe6"
159
- //"0x89197c814f5df4249c1800007870c5b8bc9572a8001c3f96f7ff59961b23500d"
0 commit comments