diff --git a/packages/programs/acl/trusted-network/src/controller.ts b/packages/programs/acl/trusted-network/src/controller.ts index 183e9c7a0..5f6f433c0 100644 --- a/packages/programs/acl/trusted-network/src/controller.ts +++ b/packages/programs/acl/trusted-network/src/controller.ts @@ -9,7 +9,7 @@ import { CanRead, TransactionContext } from "@peerbit/document"; -import { AppendOptions, Entry } from "@peerbit/log"; +import { AppendOptions } from "@peerbit/log"; import { PublicSignKey, getPublicKeyFromPeerId } from "@peerbit/crypto"; import { DeleteOperation } from "@peerbit/document"; import { @@ -19,8 +19,7 @@ import { hasPath, getFromByTo, getToByFrom, - getRelation, - AbstractRelation + getRelation } from "./identity-graph.js"; import { Program } from "@peerbit/program"; import { sha256Base64Sync } from "@peerbit/crypto"; diff --git a/packages/programs/data/document/src/document-store.ts b/packages/programs/data/document/src/document-store.ts index 4798d0ae6..869985c98 100644 --- a/packages/programs/data/document/src/document-store.ts +++ b/packages/programs/data/document/src/document-store.ts @@ -8,7 +8,7 @@ import { } from "@dao-xyz/borsh"; import { Change, Entry, EntryType, TrimOptions } from "@peerbit/log"; import { Program, ProgramEvents } from "@peerbit/program"; -import { AccessError, DecryptedThing, PublicSignKey } from "@peerbit/crypto"; +import { AccessError, DecryptedThing } from "@peerbit/crypto"; import { logger as loggerFn } from "@peerbit/logger"; import { AppendOptions } from "@peerbit/log"; import { CustomEvent } from "@libp2p/interface/events"; @@ -20,6 +20,7 @@ import { SharedLogOptions, SharedAppendOptions } from "@peerbit/shared-log"; + export { Role, Observer, Replicator }; // For convenience (so that consumers does not have to do the import above from shared-log packages) import { diff --git a/packages/programs/data/shared-log/src/__tests__/leader.test.ts b/packages/programs/data/shared-log/src/__tests__/leader.test.ts index 005fcdc54..4fafcf8a2 100644 --- a/packages/programs/data/shared-log/src/__tests__/leader.test.ts +++ b/packages/programs/data/shared-log/src/__tests__/leader.test.ts @@ -4,7 +4,7 @@ import { delay, waitForResolved } from "@peerbit/time"; import { DirectSub } from "@peerbit/pubsub"; import { DirectBlock } from "@peerbit/blocks"; import { getPublicKeyFromPeerId } from "@peerbit/crypto"; -import { Observer } from "../role"; +import { Observer } from "../role.js"; describe(`leaders`, function () { let session: TestSession; diff --git a/packages/programs/data/shared-log/src/index.ts b/packages/programs/data/shared-log/src/index.ts index e9fd3a3fe..235afee09 100644 --- a/packages/programs/data/shared-log/src/index.ts +++ b/packages/programs/data/shared-log/src/index.ts @@ -347,7 +347,7 @@ export class SharedLog extends Program< if (v.equals(this.node.identity.publicKey)) { return; } - this.handleSubscriptionChange(v, [{ topic: this.topic }], true); + this.handleSubscriptionChange(v, [this.topic], true); } ); @@ -836,13 +836,13 @@ export class SharedLog extends Program< async handleSubscriptionChange( publicKey: PublicSignKey, - changes: { topic: string }[], + changes: string[], subscribed: boolean ) { if (subscribed) { if (this.role instanceof Replicator) { for (const subscription of changes) { - if (this.log.idString !== subscription.topic) { + if (this.log.idString !== subscription) { continue; } await this.rpc.send(new ResponseRoleMessage(this.role), { @@ -855,7 +855,7 @@ export class SharedLog extends Program< //if(evt.detail.subscriptions.map((x) => x.topic).includes()) } else { for (const topic of changes) { - if (this.log.idString !== topic.topic) { + if (this.log.idString !== topic) { continue; } const change = await this.modifyReplicatorsCache( @@ -1153,7 +1153,7 @@ export class SharedLog extends Program< async _onUnsubscription(evt: CustomEvent) { logger.debug( `Peer disconnected '${evt.detail.from.hashcode()}' from '${JSON.stringify( - evt.detail.unsubscriptions.map((x) => x.topic) + evt.detail.unsubscriptions.map((x) => x) )}'` ); @@ -1167,7 +1167,7 @@ export class SharedLog extends Program< async _onSubscription(evt: CustomEvent) { logger.debug( `New peer '${evt.detail.from.hashcode()}' connected to '${JSON.stringify( - evt.detail.subscriptions.map((x) => x.topic) + evt.detail.subscriptions.map((x) => x) )}'` ); return this.handleSubscriptionChange( diff --git a/packages/programs/program/src/__tests__/utils.ts b/packages/programs/program/src/__tests__/utils.ts index 24fe1604e..d40854717 100644 --- a/packages/programs/program/src/__tests__/utils.ts +++ b/packages/programs/program/src/__tests__/utils.ts @@ -6,10 +6,8 @@ import { } from "@peerbit/crypto"; import { ProgramClient, ProgramHandler } from "../program"; import { - Subscription, SubscriptionEvent, - UnsubcriptionEvent, - Unsubscription + UnsubcriptionEvent } from "@peerbit/pubsub-interface"; import { CustomEvent } from "@libp2p/interface/events"; @@ -87,9 +85,7 @@ export const createPeer = async ( }); dispatchEvent( new CustomEvent("subscribe", { - detail: new SubscriptionEvent(keypair.publicKey, [ - new Subscription(topic) - ]) + detail: new SubscriptionEvent(keypair.publicKey, [topic]) }) ); }, @@ -108,9 +104,7 @@ export const createPeer = async ( if (ret) { dispatchEvent( new CustomEvent("unsubscribe", { - detail: new UnsubcriptionEvent(keypair.publicKey, [ - new Unsubscription(topic) - ]) + detail: new UnsubcriptionEvent(keypair.publicKey, [topic]) }) ); } @@ -144,7 +138,7 @@ export const createPeer = async ( // TODO undefined checks detail: new SubscriptionEvent( state.peers.get(hash)!.identity.publicKey!, - [new Subscription(topic)] + [topic] ) }), true diff --git a/packages/programs/program/src/program.ts b/packages/programs/program/src/program.ts index 90776cd12..7ab995c9c 100644 --- a/packages/programs/program/src/program.ts +++ b/packages/programs/program/src/program.ts @@ -8,6 +8,7 @@ import { waitFor } from "@peerbit/time"; import { Blocks } from "@peerbit/blocks-interface"; import { PeerId as Libp2pPeerId } from "@libp2p/interface/peer-id"; import { + PubSub, SubscriptionEvent, UnsubcriptionEvent } from "@peerbit/pubsub-interface"; diff --git a/packages/programs/rpc/src/controller.ts b/packages/programs/rpc/src/controller.ts index 801d13f88..b668c806c 100644 --- a/packages/programs/rpc/src/controller.ts +++ b/packages/programs/rpc/src/controller.ts @@ -16,17 +16,14 @@ import { } from "@peerbit/crypto"; import { RequestV0, ResponseV0, RPCMessage } from "./encoding.js"; import { RPCOptions, logger, RPCResponse, PublishOptions } from "./io.js"; -import { Address } from "@peerbit/program"; import { DataEvent, - PubSubData, PublishOptions as PubSubPublishOptions } from "@peerbit/pubsub-interface"; import { Program } from "@peerbit/program"; import { DataMessage } from "@peerbit/stream-interface"; import pDefer, { DeferredPromise } from "p-defer"; import { waitFor } from "@peerbit/time"; -import { equals } from "uint8arrays"; export type RPCSetupOptions = { topic: string; diff --git a/packages/transport/blocks/src/streams.ts b/packages/transport/blocks/src/streams.ts deleted file mode 100644 index 4cdb1f351..000000000 --- a/packages/transport/blocks/src/streams.ts +++ /dev/null @@ -1 +0,0 @@ -export const x = 123;