Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: import types from interface module #2946

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/interface-compliance-tests/src/mocks/registrar.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import merge from 'merge-options'
import type { Connection, PeerId, Topology } from '@libp2p/interface'
import type { IncomingStreamData, Registrar, StreamHandler, StreamHandlerOptions, StreamHandlerRecord } from '@libp2p/interface-internal'
import type { Connection, PeerId, Topology, IncomingStreamData, StreamHandler, StreamHandlerOptions, StreamHandlerRecord } from '@libp2p/interface'
import type { Registrar } from '@libp2p/interface-internal'

export class MockRegistrar implements Registrar {
private readonly topologies = new Map<string, Array<{ id: string, topology: Topology }>>()
Expand Down
3 changes: 1 addition & 2 deletions packages/kad-dht/src/rpc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import type { PeerInfoMapper, Validators } from '../index.js'
import type { PeerRouting } from '../peer-routing'
import type { Providers } from '../providers'
import type { RoutingTable } from '../routing-table'
import type { CounterGroup, Logger, Metrics, PeerId } from '@libp2p/interface'
import type { IncomingStreamData } from '@libp2p/interface-internal'
import type { CounterGroup, Logger, Metrics, PeerId, IncomingStreamData } from '@libp2p/interface'

export interface DHTMessageHandler {
handle(peerId: PeerId, msg: Message): Promise<Message | undefined>
Expand Down
4 changes: 2 additions & 2 deletions packages/protocol-autonat/src/autonat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import * as Digest from 'multiformats/hashes/digest'
import { DEFAULT_CONNECTION_THRESHOLD, MAX_INBOUND_STREAMS, MAX_MESSAGE_SIZE, MAX_OUTBOUND_STREAMS, PROTOCOL_NAME, PROTOCOL_PREFIX, PROTOCOL_VERSION, TIMEOUT } from './constants.js'
import { Message } from './pb/index.js'
import type { AutoNATComponents, AutoNATServiceInit } from './index.js'
import type { Logger, Connection, PeerId, Startable, AbortOptions } from '@libp2p/interface'
import type { AddressType, IncomingStreamData } from '@libp2p/interface-internal'
import type { Logger, Connection, PeerId, Startable, AbortOptions, IncomingStreamData } from '@libp2p/interface'
import type { AddressType } from '@libp2p/interface-internal'
import type { PeerSet } from '@libp2p/peer-collections'
import type { Filter } from '@libp2p/utils/filters'
import type { RepeatingTask } from '@libp2p/utils/repeating-task'
Expand Down
3 changes: 1 addition & 2 deletions packages/protocol-fetch/src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import { toString as uint8arrayToString } from 'uint8arrays/to-string'
import { PROTOCOL_NAME, PROTOCOL_VERSION } from './constants.js'
import { FetchRequest, FetchResponse } from './pb/proto.js'
import type { Fetch as FetchInterface, FetchComponents, FetchInit, LookupFunction } from './index.js'
import type { AbortOptions, Logger, Stream, PeerId, Startable } from '@libp2p/interface'
import type { IncomingStreamData } from '@libp2p/interface-internal'
import type { AbortOptions, Logger, Stream, PeerId, Startable, IncomingStreamData } from '@libp2p/interface'

const DEFAULT_TIMEOUT = 10000

Expand Down
4 changes: 2 additions & 2 deletions packages/protocol-identify/src/identify-push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import {
import { Identify as IdentifyMessage } from './pb/message.js'
import { AbstractIdentify, consumeIdentifyMessage, defaultValues } from './utils.js'
import type { IdentifyPush as IdentifyPushInterface, IdentifyPushComponents, IdentifyPushInit } from './index.js'
import type { Stream, Startable } from '@libp2p/interface'
import type { ConnectionManager, IncomingStreamData } from '@libp2p/interface-internal'
import type { Stream, Startable, IncomingStreamData } from '@libp2p/interface'
import type { ConnectionManager } from '@libp2p/interface-internal'

export class IdentifyPush extends AbstractIdentify implements Startable, IdentifyPushInterface {
private readonly connectionManager: ConnectionManager
Expand Down
3 changes: 1 addition & 2 deletions packages/protocol-identify/src/identify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import {
import { Identify as IdentifyMessage } from './pb/message.js'
import { AbstractIdentify, consumeIdentifyMessage, defaultValues, getCleanMultiaddr } from './utils.js'
import type { Identify as IdentifyInterface, IdentifyComponents, IdentifyInit } from './index.js'
import type { IdentifyResult, AbortOptions, Connection, Stream, Startable } from '@libp2p/interface'
import type { IncomingStreamData } from '@libp2p/interface-internal'
import type { IdentifyResult, AbortOptions, Connection, Stream, Startable, IncomingStreamData } from '@libp2p/interface'

const CODEC_IP6 = 0x29

Expand Down
3 changes: 1 addition & 2 deletions packages/protocol-perf/src/perf-service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { pushable } from 'it-pushable'
import { MAX_INBOUND_STREAMS, MAX_OUTBOUND_STREAMS, PROTOCOL_NAME, RUN_ON_LIMITED_CONNECTION, WRITE_BLOCK_SIZE } from './constants.js'
import type { PerfOptions, PerfOutput, PerfComponents, PerfInit, Perf as PerfInterface } from './index.js'
import type { Logger, Startable } from '@libp2p/interface'
import type { IncomingStreamData } from '@libp2p/interface-internal'
import type { Logger, Startable, IncomingStreamData } from '@libp2p/interface'
import type { Multiaddr } from '@multiformats/multiaddr'

export class Perf implements Startable, PerfInterface {
Expand Down
3 changes: 1 addition & 2 deletions packages/protocol-ping/src/ping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { byteStream } from 'it-byte-stream'
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
import { PROTOCOL_PREFIX, PROTOCOL_NAME, PING_LENGTH, PROTOCOL_VERSION, TIMEOUT, MAX_INBOUND_STREAMS, MAX_OUTBOUND_STREAMS } from './constants.js'
import type { PingServiceComponents, PingServiceInit, PingService as PingServiceInterface } from './index.js'
import type { AbortOptions, Logger, Stream, PeerId, Startable } from '@libp2p/interface'
import type { IncomingStreamData } from '@libp2p/interface-internal'
import type { AbortOptions, Logger, Stream, PeerId, Startable, IncomingStreamData } from '@libp2p/interface'
import type { Multiaddr } from '@multiformats/multiaddr'

export class PingService implements Startable, PingServiceInterface {
Expand Down
4 changes: 2 additions & 2 deletions packages/pubsub/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ import {
verifySignature
} from './sign.js'
import { toMessage, ensureArray, noSignMsgId, msgId, toRpcMessage, randomSeqno } from './utils.js'
import type { PubSub, Message, StrictNoSign, StrictSign, PubSubInit, PubSubEvents, PeerStreams, PubSubRPCMessage, PubSubRPC, PubSubRPCSubscription, SubscriptionChangeData, PublishResult, TopicValidatorFn, ComponentLogger, Logger, Connection, PeerId, PrivateKey } from '@libp2p/interface'
import type { IncomingStreamData, Registrar } from '@libp2p/interface-internal'
import type { PubSub, Message, StrictNoSign, StrictSign, PubSubInit, PubSubEvents, PeerStreams, PubSubRPCMessage, PubSubRPC, PubSubRPCSubscription, SubscriptionChangeData, PublishResult, TopicValidatorFn, ComponentLogger, Logger, Connection, PeerId, PrivateKey, IncomingStreamData } from '@libp2p/interface'
import type { Registrar } from '@libp2p/interface-internal'
import type { Uint8ArrayList } from 'uint8arraylist'

export interface PubSubComponents {
Expand Down
4 changes: 2 additions & 2 deletions packages/pubsub/test/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { duplexPair } from 'it-pair/duplex'
import { PubSubBaseProtocol } from '../../src/index.js'
import { RPC } from '../message/rpc.js'
import type { Connection, PeerId, PublishResult, PubSubRPC, PubSubRPCMessage, Topology } from '@libp2p/interface'
import type { IncomingStreamData, Registrar, StreamHandler, StreamHandlerRecord } from '@libp2p/interface-internal'
import type { Connection, PeerId, PublishResult, PubSubRPC, PubSubRPCMessage, Topology, IncomingStreamData, StreamHandler, StreamHandlerRecord } from '@libp2p/interface'
import type { Registrar } from '@libp2p/interface-internal'

export class PubsubImplementation extends PubSubBaseProtocol {
async publishMessage (): Promise<PublishResult> {
Expand Down
4 changes: 2 additions & 2 deletions packages/transport-circuit-relay-v2/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import { createLimitedRelay } from '../utils.js'
import { ReservationStore, type ReservationStoreInit } from './reservation-store.js'
import { ReservationVoucherRecord } from './reservation-voucher.js'
import type { CircuitRelayService, RelayReservation } from '../index.js'
import type { ComponentLogger, Logger, Connection, Stream, ConnectionGater, PeerId, PeerStore, Startable, PrivateKey, Metrics, AbortOptions } from '@libp2p/interface'
import type { AddressManager, ConnectionManager, IncomingStreamData, Registrar } from '@libp2p/interface-internal'
import type { ComponentLogger, Logger, Connection, Stream, ConnectionGater, PeerId, PeerStore, Startable, PrivateKey, Metrics, AbortOptions, IncomingStreamData } from '@libp2p/interface'
import type { AddressManager, ConnectionManager, Registrar } from '@libp2p/interface-internal'
import type { PeerMap } from '@libp2p/peer-collections'

const isRelayAddr = (ma: Multiaddr): boolean => ma.protoCodes().includes(CIRCUIT_PROTO_CODE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { RelayDiscovery } from './discovery.js'
import { createListener } from './listener.js'
import { ReservationStore } from './reservation-store.js'
import type { CircuitRelayTransportComponents, CircuitRelayTransportInit } from './index.js'
import type { Transport, CreateListenerOptions, Listener, Upgrader, ComponentLogger, Logger, Connection, Stream, ConnectionGater, PeerId, PeerStore, OutboundConnectionUpgradeEvents, DialTransportOptions, OpenConnectionProgressEvents } from '@libp2p/interface'
import type { AddressManager, ConnectionManager, IncomingStreamData, Registrar, TransportManager } from '@libp2p/interface-internal'
import type { Transport, CreateListenerOptions, Listener, Upgrader, ComponentLogger, Logger, Connection, Stream, ConnectionGater, PeerId, PeerStore, OutboundConnectionUpgradeEvents, DialTransportOptions, OpenConnectionProgressEvents, IncomingStreamData } from '@libp2p/interface'
import type { AddressManager, ConnectionManager, Registrar, TransportManager } from '@libp2p/interface-internal'
import type { Multiaddr } from '@multiformats/multiaddr'
import type { ProgressEvent } from 'progress-events'

Expand Down
4 changes: 2 additions & 2 deletions packages/transport-circuit-relay-v2/test/stop.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import Sinon from 'sinon'
import { stubInterface, type StubbedInstance } from 'sinon-ts'
import { Status, StopMessage } from '../src/pb/index.js'
import { CircuitRelayTransport } from '../src/transport/transport.js'
import type { TypedEventTarget, ComponentLogger, Libp2pEvents, Connection, Stream, ConnectionGater, PeerId, PeerStore, Upgrader } from '@libp2p/interface'
import type { AddressManager, ConnectionManager, RandomWalk, Registrar, StreamHandler, TransportManager } from '@libp2p/interface-internal'
import type { TypedEventTarget, ComponentLogger, Libp2pEvents, Connection, Stream, ConnectionGater, PeerId, PeerStore, Upgrader, StreamHandler } from '@libp2p/interface'
import type { AddressManager, ConnectionManager, RandomWalk, Registrar, TransportManager } from '@libp2p/interface-internal'

interface StubbedCircuitRelayTransportComponents {
peerId: PeerId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { Message } from './pb/message.js'
import { SIGNALING_PROTO_ID, splitAddr, type WebRTCDialEvents, type WebRTCTransportMetrics } from './transport.js'
import { readCandidatesUntilConnected } from './util.js'
import type { DataChannelOptions } from '../index.js'
import type { LoggerOptions, Connection, ComponentLogger } from '@libp2p/interface'
import type { ConnectionManager, IncomingStreamData, TransportManager } from '@libp2p/interface-internal'
import type { LoggerOptions, Connection, ComponentLogger, IncomingStreamData } from '@libp2p/interface'
import type { ConnectionManager, TransportManager } from '@libp2p/interface-internal'
import type { Multiaddr } from '@multiformats/multiaddr'
import type { ProgressOptions } from 'progress-events'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { SDPHandshakeFailedError } from '../error.js'
import { type RTCPeerConnection, RTCSessionDescription } from '../webrtc/index.js'
import { Message } from './pb/message.js'
import { getConnectionState, readCandidatesUntilConnected } from './util.js'
import type { Logger } from '@libp2p/interface'
import type { IncomingStreamData } from '@libp2p/interface-internal'
import type { Logger, IncomingStreamData } from '@libp2p/interface'

export interface IncomingStreamOpts extends IncomingStreamData {
peerConnection: RTCPeerConnection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { initiateConnection } from './initiate-connection.js'
import { WebRTCPeerListener } from './listener.js'
import { handleIncomingStream } from './signaling-stream-handler.js'
import type { DataChannelOptions } from '../index.js'
import type { OutboundConnectionUpgradeEvents, CreateListenerOptions, DialTransportOptions, Transport, Listener, Upgrader, ComponentLogger, Logger, Connection, PeerId, CounterGroup, Metrics, Startable, OpenConnectionProgressEvents } from '@libp2p/interface'
import type { IncomingStreamData, Registrar, ConnectionManager, TransportManager } from '@libp2p/interface-internal'
import type { OutboundConnectionUpgradeEvents, CreateListenerOptions, DialTransportOptions, Transport, Listener, Upgrader, ComponentLogger, Logger, Connection, PeerId, CounterGroup, Metrics, Startable, OpenConnectionProgressEvents, IncomingStreamData } from '@libp2p/interface'
import type { Registrar, ConnectionManager, TransportManager } from '@libp2p/interface-internal'
import type { ProgressEvent } from 'progress-events'

const WEBRTC_TRANSPORT = '/webrtc'
Expand Down
Loading