Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
fix: update libp2p interfaces (#109)
Browse files Browse the repository at this point in the history
Remove deprecated interfaces for newer versions.
  • Loading branch information
achingbrain authored Oct 25, 2023
1 parent 31c3f5c commit 514b6e1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/ipns/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@
},
"dependencies": {
"@libp2p/interface": "^0.1.2",
"@libp2p/kad-dht": "^10.0.11",
"@libp2p/logger": "^3.0.2",
"@libp2p/peer-id": "^3.0.2",
"@libp2p/record": "^3.0.0",
"hashlru": "^2.3.0",
"interface-datastore": "^8.0.0",
"ipns": "^7.0.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/ipns/src/routing/local-store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Libp2pRecord } from '@libp2p/record'
import { Record } from '@libp2p/kad-dht'
import { type Datastore, Key } from 'interface-datastore'
import { CustomProgressEvent, type ProgressEvent } from 'progress-events'
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
Expand Down Expand Up @@ -30,7 +30,7 @@ export function localStore (datastore: Datastore): LocalStore {
const key = dhtRoutingKey(routingKey)

// Marshal to libp2p record as the DHT does
const record = new Libp2pRecord(routingKey, marshalledRecord, new Date())
const record = new Record(routingKey, marshalledRecord, new Date())

options.onProgress?.(new CustomProgressEvent('ipns:routing:datastore:put'))
await datastore.put(key, record.serialize(), options)
Expand All @@ -47,7 +47,7 @@ export function localStore (datastore: Datastore): LocalStore {
const buf = await datastore.get(key, options)

// Unmarshal libp2p record as the DHT does
const record = Libp2pRecord.deserialize(buf)
const record = Record.deserialize(buf)

return record.value
} catch (err: any) {
Expand Down
4 changes: 2 additions & 2 deletions packages/ipns/test/resolve.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-env mocha */

import { Record } from '@libp2p/kad-dht'
import { createEd25519PeerId } from '@libp2p/peer-id-factory'
import { Libp2pRecord } from '@libp2p/record'
import { expect } from 'aegir/chai'
import { MemoryDatastore } from 'datastore-core'
import { type Datastore, Key } from 'interface-datastore'
Expand Down Expand Up @@ -141,7 +141,7 @@ describe('resolve', () => {
expect(result.toString()).to.equal(cid.toV1().toString(), 'incorrect record resolved')

const cached = await datastore.get(dhtKey)
const record = Libp2pRecord.deserialize(cached)
const record = Record.deserialize(cached)

// should have cached the updated record
expect(record.value).to.equalBytes(marshalledRecordB)
Expand Down

0 comments on commit 514b6e1

Please sign in to comment.