From aabed1db852ed804bb8d0de94b783bf451cdea85 Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Wed, 15 Jun 2022 12:51:17 +0100 Subject: [PATCH] feat!: update to latest libp2p interfaces (#137) BREAKING CHANGE: uses new single-issue libp2p interface modules --- README.md | 41 ++++++++++++++++++++++++++--------------- package.json | 12 ++++++++---- src/index.ts | 6 +++--- test/bootstrap.spec.ts | 4 ++-- test/compliance.spec.ts | 2 +- 5 files changed, 40 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 1a96286..75483d0 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,26 @@ -# js-libp2p-bootstrap +# @libp2p/bootstrap -[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://protocol.ai) -[![](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/) -[![](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p) -[![Discourse posts](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg)](https://discuss.libp2p.io) -[![](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-bootstrap.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-bootstrap) -[![Build Status](https://github.com/libp2p/js-libp2p-bootstrap/actions/workflows/js-test-and-release.yml/badge.svg?branch=main)](https://github.com/libp2p/js-libp2p-bootstrap/actions/workflows/js-test-and-release.yml) -[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) -![](https://img.shields.io/badge/Node.js-%3E%3D14.0.0-orange.svg?style=flat-square) +[![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/) +[![IRC](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p) +[![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io) +[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-bootstrap.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-bootstrap) +[![CI](https://img.shields.io/github/workflow/status/libp2p/js-libp2p-interfaces/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/libp2p/js-libp2p-bootstrap/actions/workflows/js-test-and-release.yml) -> JavaScript libp2p Implementation of the railing process of a Node through a bootstrap peer list +> Node.js IPFS Implementation of the railing process of a Node through a bootstrap peer list + +## Table of contents + +- [Install](#install) +- [Usage](#usage) +- [Contribute](#contribute) +- [License](#license) +- [Contribution](#contribution) + +## Install + +```console +$ npm i @libp2p/bootstrap +``` ## Usage @@ -60,16 +71,16 @@ start() The libp2p implementation in JavaScript is a work in progress. As such, there are a few things you can do right now to help out: - - Go through the modules and **check out existing issues**. This is especially useful for modules in active development. Some knowledge of IPFS/libp2p may be required, as well as the infrastructure behind it - for instance, you may need to read up on p2p and more complex operations like muxing to be able to help technically. - - **Perform code reviews**. More eyes will help a) speed the project along b) ensure quality and c) reduce possible future bugs. +- Go through the modules and **check out existing issues**. This is especially useful for modules in active development. Some knowledge of IPFS/libp2p may be required, as well as the infrastructure behind it - for instance, you may need to read up on p2p and more complex operations like muxing to be able to help technically. +- **Perform code reviews**. More eyes will help a) speed the project along b) ensure quality and c) reduce possible future bugs. ## License Licensed under either of - * Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / http://www.apache.org/licenses/LICENSE-2.0) - * MIT ([LICENSE-MIT](LICENSE-MIT) / http://opensource.org/licenses/MIT) +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) -### Contribution +## Contribution Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/package.json b/package.json index 54a5858..ba1ea8a 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ ], "exports": { ".": { + "types": "./src/index.d.ts", "import": "./dist/src/index.js" } }, @@ -133,14 +134,17 @@ "release": "aegir release" }, "dependencies": { - "@libp2p/interfaces": "^2.0.1", - "@libp2p/logger": "^1.1.3", + "@libp2p/interface-peer-discovery": "^1.0.0", + "@libp2p/interface-peer-info": "^1.0.1", + "@libp2p/interfaces": "^3.0.2", + "@libp2p/logger": "^2.0.0", "@libp2p/peer-id": "^1.1.9", "@multiformats/mafmt": "^11.0.2", "@multiformats/multiaddr": "^10.1.7" }, "devDependencies": { - "@libp2p/interface-compliance-tests": "^2.0.1", - "aegir": "^37.0.7" + "@libp2p/interface-peer-discovery-compliance-tests": "^1.0.0", + "@libp2p/interface-peer-id": "^1.0.2", + "aegir": "^37.2.0" } } diff --git a/src/index.ts b/src/index.ts index 3cab669..863be51 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,10 +2,10 @@ import { Multiaddr } from '@multiformats/multiaddr' import { P2P } from '@multiformats/mafmt' import { CustomEvent, EventEmitter } from '@libp2p/interfaces/events' import { logger } from '@libp2p/logger' -import type { PeerDiscovery, PeerDiscoveryEvents } from '@libp2p/interfaces/peer-discovery' -import type { PeerInfo } from '@libp2p/interfaces/peer-info' +import type { PeerDiscovery, PeerDiscoveryEvents } from '@libp2p/interface-peer-discovery' +import type { PeerInfo } from '@libp2p/interface-peer-info' import { peerIdFromString } from '@libp2p/peer-id' -import { symbol } from '@libp2p/interfaces/peer-discovery' +import { symbol } from '@libp2p/interface-peer-discovery' const log = logger('libp2p:bootstrap') diff --git a/test/bootstrap.spec.ts b/test/bootstrap.spec.ts index 04e3c7d..806bf22 100644 --- a/test/bootstrap.spec.ts +++ b/test/bootstrap.spec.ts @@ -5,8 +5,8 @@ import { IPFS } from '@multiformats/mafmt' import { Bootstrap } from '../src/index.js' import peerList from './fixtures/default-peers.js' import partialValidPeerList from './fixtures/some-invalid-peers.js' -import type { PeerInfo } from '@libp2p/interfaces/peer-info' -import { isPeerId } from '@libp2p/interfaces/peer-id' +import type { PeerInfo } from '@libp2p/interface-peer-info' +import { isPeerId } from '@libp2p/interface-peer-id' describe('bootstrap', () => { it('should throw if no peer list is provided', () => { diff --git a/test/compliance.spec.ts b/test/compliance.spec.ts index b8564cc..6edd6e5 100644 --- a/test/compliance.spec.ts +++ b/test/compliance.spec.ts @@ -1,6 +1,6 @@ /* eslint-env mocha */ -import tests from '@libp2p/interface-compliance-tests/peer-discovery' +import tests from '@libp2p/interface-peer-discovery-compliance-tests' import { Bootstrap } from '../src/index.js' import peerList from './fixtures/default-peers.js'