@@ -19,6 +19,7 @@ import { decodeText } from '@windingtree/sdk-utils';
19
19
import { CashedMessageEntry , MessagesCache } from './cache.js' ;
20
20
import { createLogger } from '@windingtree/sdk-logger' ;
21
21
import { parse } from 'superjson' ;
22
+ import { peerIdFromBytes } from '@libp2p/peer-id' ;
22
23
23
24
const logger = createLogger ( 'CenterSub' ) ;
24
25
@@ -179,13 +180,20 @@ export class CenterSub extends GossipSub {
179
180
logger . trace ( 'messageTransformer not defined' ) ;
180
181
return ;
181
182
}
183
+
184
+ rpcMsg . from = new Uint8Array ( rpcMsg . from as ArrayBufferLike ) ;
185
+ rpcMsg . signature = new Uint8Array ( rpcMsg . signature as ArrayBufferLike ) ;
186
+ rpcMsg . key = new Uint8Array ( rpcMsg . key as ArrayBufferLike ) ;
187
+ rpcMsg . data = new Uint8Array ( rpcMsg . data as ArrayBufferLike ) ;
188
+ rpcMsg . seqno = new Uint8Array ( rpcMsg . seqno as ArrayBufferLike ) ;
189
+
182
190
const msgId = await sha256 . encode ( rpcMsg . data ) ;
183
191
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
184
192
const msgIdStr = this [ 'msgIdToStrFn' ] ( msgId ) as string ;
185
193
const transformed = this . messageTransformer ( rpcMsg . data ) ;
186
194
await this . messages . set (
187
195
msgIdStr ,
188
- rpcMsg . from . toString ( ) ,
196
+ peerIdFromBytes ( rpcMsg . from ) . toString ( ) ,
189
197
rpcMsg ,
190
198
Number ( transformed . expire ) ,
191
199
Number ( transformed . nonce ) ,
0 commit comments