11import ERC725 , { ERC725JSONSchema } from '@erc725/erc725.js' ;
2- import { Dm3KeyStore } from '../KeyStore/IKeyStore' ;
2+ import { IDm3KeyStore } from '../KeyStore/IKeyStore' ;
33import { EncodeDataReturn } from '@erc725/erc725.js/build/main/src/types' ;
44import { ethers } from 'ethers' ;
55import {
88} from '@erc725/erc725.js/build/main/src/types/decodeData' ;
99import LSP6Schema from '@erc725/erc725.js/schemas/LSP6KeyManager.json' ;
1010import { SignedUserProfile } from '@dm3-org/dm3-lib-profile' ;
11+ import { isStringArray } from './utils/isStringArray' ;
1112
1213export class ERC725JsonCoder {
1314 public static readonly schemas : ERC725JSONSchema [ ] = [
@@ -96,7 +97,7 @@ export class ERC725JsonCoder {
9697 keyName : 'DM3UserProfile:<address>' ,
9798 dynamicKeyParts : upAddress ,
9899 } ) ;
99- if ( encodedUserProfile . value === null ) {
100+ if ( ! isStringArray ( encodedUserProfile . value ) ) {
100101 return undefined ;
101102 }
102103
@@ -105,25 +106,22 @@ export class ERC725JsonCoder {
105106 publicEncryptionKey ,
106107 deliveryServices ,
107108 signature ,
108- ] = encodedUserProfile . value as Data [ ] ;
109+ ] = encodedUserProfile . value ;
109110
110111 return {
111112 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 ) ,
118116 deliveryServices : JSON . parse (
119- ethers . utils . toUtf8String ( deliveryServices as string ) ,
117+ ethers . utils . toUtf8String ( deliveryServices ) ,
120118 ) ,
121119 } ,
122- signature : ethers . utils . toUtf8String ( signature as string ) ,
120+ signature : ethers . utils . toUtf8String ( signature ) ,
123121 } ;
124122 }
125123
126- public async decodeDm3KeyStore ( ) : Promise < Dm3KeyStore > {
124+ public async decodeDm3KeyStore ( ) : Promise < IDm3KeyStore > {
127125 const controllerAddresses = await this . erc725 . getData (
128126 'AddressPermissions[]' ,
129127 ) ;
@@ -150,10 +148,8 @@ export class ERC725JsonCoder {
150148 ) ,
151149 } ;
152150 return acc ;
153- } , { } as Dm3KeyStore ) ;
151+ } , { } as IDm3KeyStore ) ;
154152
155153 return ks ;
156154 }
157155}
158- //"0x89197c814f5df4249c180000c73abaa79d9d562d07f09d8135b72b047908bbe6"
159- //"0x89197c814f5df4249c1800007870c5b8bc9572a8001c3f96f7ff59961b23500d"
0 commit comments