Skip to content
This repository was archived by the owner on Feb 28, 2024. It is now read-only.

Commit 22d3900

Browse files
committed
fix: linting and deps
1 parent 3d4573d commit 22d3900

10 files changed

+69
-31
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"release": "npm run docs:no-publish && aegir run release && npm run docs"
4040
},
4141
"devDependencies": {
42-
"aegir": "^38.1.0"
42+
"aegir": "^39.0.3"
4343
},
4444
"type": "module",
4545
"workspaces": [

packages/interop/package.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,17 @@
5858
"@helia/strings": "~0.0.0",
5959
"@libp2p/tcp": "^6.1.2",
6060
"@libp2p/websockets": "^5.0.3",
61-
"aegir": "^38.1.0",
61+
"aegir": "^39.0.3",
6262
"blockstore-core": "^4.0.1",
6363
"datastore-core": "^9.0.3",
6464
"go-ipfs": "^0.19.0",
6565
"helia": "^1.0.0",
6666
"ipfs-core-types": "^0.14.0",
67-
"ipfs-unixfs-importer": "^15.1.0",
6867
"ipfsd-ctl": "^13.0.0",
69-
"it-to-buffer": "^4.0.1",
7068
"kubo-rpc-client": "^3.0.0",
7169
"libp2p": "^0.43.2",
7270
"merge-options": "^3.0.4",
73-
"multiformats": "^11.0.1",
71+
"uint8arrays": "^4.0.3",
7472
"wherearewe": "^2.0.1"
7573
},
7674
"browser": {

packages/interop/test/fixtures/create-helia.browser.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { createHelia } from 'helia'
2-
import { createLibp2p } from 'libp2p'
3-
import { webSockets } from '@libp2p/websockets'
4-
import { all } from '@libp2p/websockets/filters'
51
import { noise } from '@chainsafe/libp2p-noise'
62
import { yamux } from '@chainsafe/libp2p-yamux'
3+
import { webSockets } from '@libp2p/websockets'
4+
import { all } from '@libp2p/websockets/filters'
75
import { MemoryBlockstore } from 'blockstore-core'
86
import { MemoryDatastore } from 'datastore-core'
7+
import { createHelia } from 'helia'
8+
import { createLibp2p } from 'libp2p'
99
import type { Helia } from '@helia/interface'
1010

1111
export async function createHeliaNode (): Promise<Helia> {

packages/interop/test/fixtures/create-helia.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { createHelia } from 'helia'
2-
import { createLibp2p, Libp2pOptions } from 'libp2p'
3-
import { tcp } from '@libp2p/tcp'
41
import { noise } from '@chainsafe/libp2p-noise'
52
import { yamux } from '@chainsafe/libp2p-yamux'
3+
import { tcp } from '@libp2p/tcp'
64
import { MemoryBlockstore } from 'blockstore-core'
75
import { MemoryDatastore } from 'datastore-core'
6+
import { createHelia } from 'helia'
7+
import { createLibp2p, type Libp2pOptions } from 'libp2p'
88
import type { Helia } from '@helia/interface'
99

1010
export async function createHeliaNode (config: Libp2pOptions = {}): Promise<Helia> {

packages/interop/test/fixtures/create-kubo.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

22
// @ts-expect-error no types
33
import * as goIpfs from 'go-ipfs'
4-
import { Controller, ControllerOptions, createController } from 'ipfsd-ctl'
4+
import { type Controller, type ControllerOptions, createController } from 'ipfsd-ctl'
55
import * as kuboRpcClient from 'kubo-rpc-client'
6-
import { isElectronMain, isNode } from 'wherearewe'
76
import mergeOptions from 'merge-options'
7+
import { isElectronMain, isNode } from 'wherearewe'
88

99
export async function createKuboNode (options: ControllerOptions<'go'> = {}): Promise<Controller> {
1010
const opts = mergeOptions({
@@ -24,5 +24,5 @@ export async function createKuboNode (options: ControllerOptions<'go'> = {}): Pr
2424
}
2525
}, options)
2626

27-
return await createController(opts)
27+
return createController(opts)
2828
}

packages/interop/test/strings.spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/* eslint-env mocha */
22

3+
import { strings, type Strings, type AddOptions } from '@helia/strings'
34
import { expect } from 'aegir/chai'
5+
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
6+
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
47
import { createHeliaNode } from './fixtures/create-helia.js'
58
import { createKuboNode } from './fixtures/create-kubo.js'
69
import type { Helia } from '@helia/interface'
7-
import type { Controller } from 'ipfsd-ctl'
8-
import { strings, Strings, AddOptions } from '@helia/strings'
9-
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
10-
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
1110
import type { PutOptions as KuboAddOptions } from 'ipfs-core-types/src/block/index.js'
11+
import type { Controller } from 'ipfsd-ctl'
1212

1313
describe('strings interop', () => {
1414
let helia: Helia

packages/strings/package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,15 @@
139139
"release": "aegir release"
140140
},
141141
"dependencies": {
142+
"@helia/interface": "^1.0.0",
143+
"@libp2p/interfaces": "^3.3.1",
142144
"interface-blockstore": "^5.0.0",
143145
"multiformats": "^11.0.1",
144146
"progress-events": "^1.0.0",
145147
"uint8arrays": "^4.0.3"
146148
},
147149
"devDependencies": {
148-
"aegir": "^38.1.0",
150+
"aegir": "^39.0.3",
149151
"blockstore-core": "^4.0.1"
150152
},
151153
"typedoc": {

packages/strings/src/index.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222
*/
2323

2424
import { CID } from 'multiformats/cid'
25-
import type { Blocks, GetBlockProgressEvents, PutBlockProgressEvents } from '@helia/interface/blocks'
26-
import type { AbortOptions } from '@libp2p/interfaces'
27-
import type { ProgressOptions } from 'progress-events'
28-
import { sha256 } from 'multiformats/hashes/sha2'
2925
import * as raw from 'multiformats/codecs/raw'
26+
import { sha256 } from 'multiformats/hashes/sha2'
3027
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
3128
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
29+
import type { Blocks, GetBlockProgressEvents, PutBlockProgressEvents } from '@helia/interface/blocks'
30+
import type { AbortOptions } from '@libp2p/interfaces'
3231
import type { BlockCodec } from 'multiformats/codecs/interface'
3332
import type { MultihashHasher } from 'multiformats/hashes/interface'
33+
import type { ProgressOptions } from 'progress-events'
3434

3535
export interface StringsComponents {
3636
blockstore: Blocks
@@ -46,8 +46,8 @@ export interface GetOptions extends AbortOptions, ProgressOptions<GetBlockProgre
4646
}
4747

4848
/**
49-
* The UnixFS interface provides familiar filesystem operations to make working with
50-
* UnixFS DAGs simple and intuitive.
49+
* The Strings interface provides a simple and intuitive way to add/get strings
50+
* with your Helia node and is a great place to start learning about IPFS.
5151
*/
5252
export interface Strings {
5353
/**

packages/strings/test/add.spec.ts

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
/* eslint-env mocha */
22

33
import { expect } from 'aegir/chai'
4-
import type { Blockstore } from 'interface-blockstore'
5-
import { strings, Strings } from '../src/index.js'
64
import { MemoryBlockstore } from 'blockstore-core'
5+
import * as json from 'multiformats/codecs/json'
6+
import { identity } from 'multiformats/hashes/identity'
7+
import { strings, type Strings } from '../src/index.js'
8+
import type { Blockstore } from 'interface-blockstore'
79

810
describe('put', () => {
911
let blockstore: Blockstore
@@ -20,4 +22,20 @@ describe('put', () => {
2022

2123
expect(`${cid}`).to.equal('bafkreifzjut3te2nhyekklss27nh3k72ysco7y32koao5eei66wof36n5e')
2224
})
25+
26+
it('adds a string with a non-default hashing algorithm', async () => {
27+
const cid = await str.add('hello world', {
28+
hasher: identity
29+
})
30+
31+
expect(`${cid}`).to.equal('bafkqac3imvwgy3zao5xxe3de')
32+
})
33+
34+
it('adds a string with a non-default block codec', async () => {
35+
const cid = await str.add('hello world', {
36+
codec: json
37+
})
38+
39+
expect(`${cid}`).to.equal('bagaaieraxfgspomtju7arjjokll5u7nl7lcij37dpjjyb3uqrd32zyxpzxuq')
40+
})
2341
})

packages/strings/test/get.spec.ts

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
/* eslint-env mocha */
22

33
import { expect } from 'aegir/chai'
4-
import type { Blockstore } from 'interface-blockstore'
5-
import { strings, Strings } from '../src/index.js'
64
import { MemoryBlockstore } from 'blockstore-core'
5+
import * as json from 'multiformats/codecs/json'
6+
import { identity } from 'multiformats/hashes/identity'
7+
import { strings, type Strings } from '../src/index.js'
8+
import type { Blockstore } from 'interface-blockstore'
79
import type { CID } from 'multiformats/cid'
810

911
describe('get', () => {
@@ -18,9 +20,27 @@ describe('get', () => {
1820
cid = await str.add('hello world')
1921
})
2022

21-
it('adds a string', async () => {
23+
it('gets a string', async () => {
2224
const string = await str.get(cid)
2325

2426
expect(`${string}`).to.equal('hello world')
2527
})
28+
29+
it('gets a string with a non-default hashing algorithm', async () => {
30+
const input = 'hello world'
31+
const cid = await str.add(input, {
32+
hasher: identity
33+
})
34+
35+
await expect(str.get(cid)).to.eventually.equal(input)
36+
})
37+
38+
it('gets a string with a non-default block codec', async () => {
39+
const input = 'hello world'
40+
const cid = await str.add(input, {
41+
codec: json
42+
})
43+
44+
await expect(str.get(cid)).to.eventually.equal(input)
45+
})
2646
})

0 commit comments

Comments
 (0)