Skip to content

Commit

Permalink
refactor(farcaster/hub-nodejs): rename farcaster/js to farcaster/hub-…
Browse files Browse the repository at this point in the history
…nodejs (farcasterxyz#658)

* refactor: rename farcaster/js to farcaster/hub-nodejs

* chore: add changeset
  • Loading branch information
varunsrin authored Mar 16, 2023
1 parent 3a1ead3 commit a74ecb2
Show file tree
Hide file tree
Showing 21 changed files with 62 additions and 58 deletions.
5 changes: 5 additions & 0 deletions .changeset/dirty-weeks-watch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@farcaster/hub-nodejs': minor
---

rename package from farcaster/js to farcaster/hub-nodejs
1 change: 0 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ All changes should have supporting documentation that makes reviewing and unders
- Do not comment obvious changes (e.g. `starts the db` before the line `db.start()`)
- Add a `Safety: ..` comment explaining every use of `as`.
- Prefer active, present-tense doing form (`Gets the connection`) over other forms (`Connection is obtained`, `Get the connection`, `We get the connection`, `will get a connection`)
- To generate docs for `packages/js`, run `yarn docs` in the root of the monorepo. To see how the TSDoc comment is formatted, see [signMessageHash() in ed25519Signer.ts](packages/utils/src/signers/ed25519Signer.ts).

### 3.4. Handling Errors

Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ Hubble is a Typescript implementation of a [Farcaster Hub](https://github.com/fa
Hubble is organized as a monorepo with a stand-alone Hubble application, a library to interact with Hubble and shared utility packages.

- To run an instance of Hubble, follow the instructions in [@farcaster/hubble](/apps/hubble/README.md).
- To talk to a running Hubble server, follow the instructions in [@farcaster/js](/packages/js/README.md).
- To talk to a running Hubble server, follow the instructions in [@farcaster/hub-nodejs](/packages/hub-nodejs/README.md).

| Package Name | Description |
| -------------------------------------------- | ------------------------------------------------ |
| [@farcaster/hubble](/apps/hubble) | An executable Farcaster Hub |
| [@farcaster/js](/packages/js) | A Javascript library to interact with Hubble |
| [@farcaster/protobufs](/packages/protobufs/) | Protobufs schemas and generated files for Hubble |
| [@farcaster/utils](/packages/utils/) | Shared utility methods |
| Package Name | Description |
| --------------------------------------------- | ------------------------------------------------ |
| [@farcaster/hubble](/apps/hubble) | An executable Farcaster Hub |
| [@farcaster/hub-nodejs](/packages/hub-nodejs) | A Javascript library to interact with Hubble |
| [@farcaster/protobufs](/packages/protobufs/) | Protobufs schemas and generated files for Hubble |
| [@farcaster/utils](/packages/utils/) | Shared utility methods |

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion apps/hubble/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Hubble can be run on cloud servers with 2 vCPUs, 8 GiB RAM and 15 GiB of SSD sto

Hubble exposes [gRPC](https://grpc.io/) API's and uses [Protobufs](https://github.com/protocolbuffers/protobuf) for data serialization. SDK's are available in multiple languages to interact with Hubble API's:

- [Javascript / Typescript](../../packages/js/)
- [Javascript / Typescript](../../packages/hub-nodejs/)
- Golang (planned)

If an SDK is not available in your language, you can use the definitions in the [protobufs package](../../packages/protobufs/) to auto-generate bindings.
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions packages/js/CHANGELOG.md → packages/hub-nodejs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @farcaster/js
# @farcaster/hub-nodejs

## 0.3.0

Expand Down Expand Up @@ -119,7 +119,7 @@
### Patch Changes

- fix: switch to 160-bit hash
- c20daed: feat: add support for /subscribe gRPC method in @farcaster/js
- c20daed: feat: add support for /subscribe gRPC method in @farcaster/hub-nodejs
- 3b84ad2: chore: refactor functions in packages/\* to return HubResult
- Updated dependencies
- Updated dependencies [c20daed]
Expand Down
12 changes: 6 additions & 6 deletions packages/js/README.md → packages/hub-nodejs/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# farcaster.js
# @farcaster/hub-nodejs

A lightweight, fast Typescript interface for Farcaster Hubs. Designed to work with [Hubble](https://github.com/farcasterxyz/hubble/) and any other Hub that implements the [Farcaster protocol](https://github.com/farcasterxyz/protocol).

Expand All @@ -13,20 +13,20 @@ Read the [documentation](./docs/README.md), see more [examples](./examples/) or

## Installation

Install @farcaster/js with the package manager of your choice
Install @farcaster/hub-nodejs with the package manager of your choice

```bash
npm install @farcaster/js
yarn add @farcaster/js
pnpm install @farcaster/js
npm install @farcaster/hub-nodejs
yarn add @farcaster/hub-nodejs
pnpm install @farcaster/hub-nodejs
```

## Quickstart

### Fetching Data from Hubs

```typescript
import { getHubRpcClient, isCastAddMessage } from '@farcaster/js';
import { getHubRpcClient, isCastAddMessage } from '@farcaster/hub-nodejs';

(async () => {
const client = await getHubRpcClient('127.0.0.1:8080');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Before you can build messages, you'll need construct the following objects:
A [Ed25519Signer](./signers/Ed25519Signer.md) is an EdDSA key pair which is necessary for signing most messages on behalf of an fid. This example below shows how to construct a new `Ed25519Signer` using the [@noble](https://paulmillr.com/noble/) library :

```typescript
import { Ed25519Signer } from '@farcaster/js';
import { Ed25519Signer } from '@farcaster/hub-nodejs';
import * as ed from '@noble/ed25519';

const privateKey = ed.utils.randomPrivateKey(); // Applications must store this key securely.
Expand All @@ -28,7 +28,7 @@ const ed25519Signer = Ed25519Signer.fromPrivateKey(privateKey)._unsafeUnwrap();
An Eip712Signer is an ECDSA key pair which is necessary signing for some messages like `SignerAdds` and `Verifications`. This example shows how to construct an `Eip712Signer` from a wallet's recovery phrase:

```typescript
import { Eip712Signer } from '@farcaster/js';
import { Eip712Signer } from '@farcaster/hub-nodejs';
import { ethers } from 'ethers';

const mnemonic = 'your mnemonic apple orange banana ...';
Expand All @@ -42,7 +42,7 @@ const eip712Signer = Eip712Signer.fromSigner(wallet, wallet.address)._unsafeUnwr
A DataOptions object tells the factory some metadata about the message. This example shows how to create the `dataOptions` object to pass to the Factory:

```typescript
import { FarcasterNetwork } from '@farcaster/js';
import { FarcasterNetwork } from '@farcaster/hub-nodejs';

const dataOptions = {
fid: -9999, // Set to the fid of the user creating the message
Expand Down Expand Up @@ -71,7 +71,7 @@ Returns a message which authorizes a new Ed25519 Signer to create messages on be
#### Usage

```typescript
import { makeSignerAdd } from '@farcaster/js';
import { makeSignerAdd } from '@farcaster/hub-nodejs';

const signerAdd = await makeSignerAdd({ signer: ed25519Signer.signerKey, name: 'foo' }, dataOptions, eip712Signer);
```
Expand Down Expand Up @@ -99,7 +99,7 @@ Returns a message which revokes a previously authorized Ed25519 Signer.
#### Usage

```typescript
import { makeSignerRemove } from '@farcaster/js';
import { makeSignerRemove } from '@farcaster/hub-nodejs';

const signerRemove = await makeSignerRemove({ signer: ed25519Signer.signerKey }, dataOptions, eip712Signer);
```
Expand Down Expand Up @@ -127,7 +127,7 @@ Returns a message that adds a new Cast.
#### Usage

```typescript
import { makeCastAdd, types } from '@farcaster/js';
import { makeCastAdd, types } from '@farcaster/hub-nodejs';

const cast = await makeCastAdd(
{ text: 'hello world', embeds: ['http://www.farcaster.xyz'], mentions: [], mentionsPositions: [] },
Expand Down Expand Up @@ -159,7 +159,7 @@ Returns a message that removes an existing Cast.
#### Usage

```typescript
import { makeCastRemove } from '@farcaster/js';
import { makeCastRemove } from '@farcaster/hub-nodejs';

const targetHashHex = '006f082f70dfb2de81e7852f3b79f1cdf2aa6b86'; // Hash of the Cast being deleted as a hex string
const targetHashBytes = new Uint8Array(Buffer.from(targetHashHex, 'hex')); // Hash of the Cast being deleted as bytes
Expand Down Expand Up @@ -196,7 +196,7 @@ Returns a message that adds a Reaction to an existing Cast.
#### Usage

```typescript
import { makeReactionAdd, ReactionType } from '@farcaster/js';
import { makeReactionAdd, ReactionType } from '@farcaster/hub-nodejs';

const targetHashHex = '006f082f70dfb2de81e7852f3b79f1cdf2aa6b86'; // Hash of the Cast being deleted as a hex string
const targetHashBytes = new Uint8Array(Buffer.from(targetHashHex, 'hex')); // Hash of the Cast being deleted as bytes
Expand Down Expand Up @@ -235,7 +235,7 @@ Returns a message that removes an existing Reaction to an existing Cast.
#### Usage

```typescript
import { makeReactionRemove, ReactionType } from '@farcaster/js';
import { makeReactionRemove, ReactionType } from '@farcaster/hub-nodejs';

const targetHashHex = '006f082f70dfb2de81e7852f3b79f1cdf2aa6b86'; // Hash of the Cast being deleted as a hex string
const targetHashBytes = new Uint8Array(Buffer.from(targetHashHex, 'hex')); // Hash of the Cast being deleted as bytes
Expand Down Expand Up @@ -274,7 +274,7 @@ Returns a message that updates metadata about the user.
#### Usage

```typescript
import { makeUserDataAdd, UserDataType } from '@farcaster/js';
import { makeUserDataAdd, UserDataType } from '@farcaster/hub-nodejs';

const userDataPfpBody = {
type: UserDataType.PFP,
Expand Down Expand Up @@ -308,7 +308,7 @@ Returns a message that proves that a user owns an Ethereum address.
#### Usage

```typescript
import { makeVerificationAddEthAddress, types } from '@farcaster/js';
import { makeVerificationAddEthAddress, types } from '@farcaster/hub-nodejs';

const claimBody = {
fid: -1, // fid of the user
Expand Down Expand Up @@ -352,7 +352,7 @@ Returns a message that removes a previously added Verification.
#### Usage

```typescript
import { makeVerificationRemove } from '@farcaster/js';
import { makeVerificationRemove } from '@farcaster/hub-nodejs';

const verificationRemoveBody = {
address: '0x1234', // Ethereum Address of Verification to remove
Expand Down
32 changes: 16 additions & 16 deletions packages/js/docs/Client.md → packages/hub-nodejs/docs/Client.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Returns a Hub RPC Client, defaulting to an SSL connection if supported.
#### Usage

```typescript
import { getHubRpcClient } from '@farcaster/js';
import { getHubRpcClient } from '@farcaster/hub-nodejs';

(async () => {
const client = await getHubRpcClient('127.0.0.1:8080');
Expand Down Expand Up @@ -122,7 +122,7 @@ Returns all active signers created by an fid in reverse chronological order.
#### Usage

```typescript
import { getHubRpcClient } from '@farcaster/js';
import { getHubRpcClient } from '@farcaster/hub-nodejs';

(async () => {
const client = await getHubRpcClient('127.0.0.1:8080');
Expand Down Expand Up @@ -154,7 +154,7 @@ Returns all active and inactive signers created by an fid in reverse chronologic
#### Usage

```typescript
import { getHubRpcClient } from '@farcaster/js';
import { getHubRpcClient } from '@farcaster/hub-nodejs';

(async () => {
const client = await getHubRpcClient('127.0.0.1:8080');
Expand Down Expand Up @@ -241,7 +241,7 @@ Returns an active cast for a user.
#### Usage

```typescript
import { getHubRpcClient } from '@farcaster/js';
import { getHubRpcClient } from '@farcaster/hub-nodejs';

(async () => {
const client = await getHubRpcClient('127.0.0.1:8080');
Expand Down Expand Up @@ -277,7 +277,7 @@ Returns active casts for a user in reverse chronological order.
#### Usage

```typescript
import { getHubRpcClient } from '@farcaster/js';
import { getHubRpcClient } from '@farcaster/hub-nodejs';

(async () => {
const client = await getHubRpcClient('127.0.0.1:8080');
Expand Down Expand Up @@ -309,7 +309,7 @@ Returns all active casts that mention an fid in reverse chronological order.
#### Usage

```typescript
import { getHubRpcClient } from '@farcaster/js';
import { getHubRpcClient } from '@farcaster/hub-nodejs';

(async () => {
const client = await getHubRpcClient('127.0.0.1:8080');
Expand Down Expand Up @@ -341,7 +341,7 @@ Returns all active casts that are replies to a specific cast in reverse chronolo
#### Usage

```typescript
import { getHubRpcClient } from '@farcaster/js';
import { getHubRpcClient } from '@farcaster/hub-nodejs';

(async () => {
const client = await getHubRpcClient('127.0.0.1:8080');
Expand Down Expand Up @@ -376,7 +376,7 @@ Returns all active and inactive casts for a user in reverse chronological order.
#### Usage

```typescript
import { getHubRpcClient } from '@farcaster/js';
import { getHubRpcClient } from '@farcaster/hub-nodejs';

(async () => {
const client = await getHubRpcClient('127.0.0.1:8080');
Expand Down Expand Up @@ -407,7 +407,7 @@ Returns an active reaction of a particular type made by a user to a cast.
#### Usage

```typescript
import { getHubRpcClient, ReactionType } from '@farcaster/js';
import { getHubRpcClient, ReactionType } from '@farcaster/hub-nodejs';

(async () => {
const client = await getHubRpcClient('127.0.0.1:8080');
Expand Down Expand Up @@ -451,7 +451,7 @@ Returns all active reactions made by users to a cast.
#### Usage

```typescript
import { getHubRpcClient, ReactionType } from '@farcaster/js';
import { getHubRpcClient, ReactionType } from '@farcaster/hub-nodejs';

(async () => {
const client = await getHubRpcClient('127.0.0.1:8080');
Expand Down Expand Up @@ -493,7 +493,7 @@ Returns all active reactions made by a user in reverse chronological order.
#### Usage

```typescript
import { getHubRpcClient, ReactionType } from '@farcaster/js';
import { getHubRpcClient, ReactionType } from '@farcaster/hub-nodejs';

(async () => {
const client = await getHubRpcClient('127.0.0.1:8080');
Expand Down Expand Up @@ -526,7 +526,7 @@ Returns all active and inactive reactions made by a user in reverse chronologica
#### Usage

```typescript
import { getHubRpcClient } from '@farcaster/js';
import { getHubRpcClient } from '@farcaster/hub-nodejs';

(async () => {
const client = await getHubRpcClient('127.0.0.1:8080');
Expand Down Expand Up @@ -631,7 +631,7 @@ Subscribe to a stream of HubEvents from the Hub which are returned as protobufs.
#### Usage

```typescript
import { ... } from '@farcaster/js';
import { ... } from '@farcaster/hub-nodejs';

const client = new Client(...)
const result = await client.get...
Expand All @@ -658,7 +658,7 @@ Submits a new message to the Hub. Basic authentication may be required by the Hu
#### Usage

```typescript
import { getHubRpcClient } from '@farcaster/js';
import { getHubRpcClient } from '@farcaster/hub-nodejs';

(async () => {
const client = await getHubRpcClient('127.0.0.1:8080');
Expand Down Expand Up @@ -693,7 +693,7 @@ Returns the on-chain event most recently associated with changing an fid's owner
#### Usage

```typescript
import { getHubRpcClient } from '@farcaster/js';
import { getHubRpcClient } from '@farcaster/hub-nodejs';

(async () => {
const client = await getHubRpcClient('127.0.0.1:8080');
Expand Down Expand Up @@ -725,7 +725,7 @@ Returns the on-chain event most recently associated with changing an fname's own
#### Usage

```typescript
import { getHubRpcClient } from '@farcaster/js';
import { getHubRpcClient } from '@farcaster/hub-nodejs';

(async () => {
const client = await getHubRpcClient('127.0.0.1:8080');
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A Farcaster Message represents an action taken by a user.

Messages are atomic updates that add or remove content from the network. For example, a user can make a new cast by generating a `CastAdd` message and remove it with a `CastRemove` message. See the [protocol spec](https://github.com/farcasterxyz/protocol#3-delta-graph) for more information on how messages work.

Messages are protobufs which are converted by @farcaster/js converts into the Typescript types documented below. Each message is signed by a key pair that is provably controlled by the user. Some messages must be signed by the Ethereum address that controls the user's fid on-chain while other messages must be signed by an EdDSA key pair known as a Signer, which is authorized to act on behalf of the Ethereum address. The protocol specification defines the message types as:
Messages are protobufs which are converted by @farcaster/hub-nodejs converts into the Typescript types documented below. Each message is signed by a key pair that is provably controlled by the user. Some messages must be signed by the Ethereum address that controls the user's fid on-chain while other messages must be signed by an EdDSA key pair known as a Signer, which is authorized to act on behalf of the Ethereum address. The protocol specification defines the message types as:

| Message | Action |
| ------------------------- | ------------------------------------------------------------------- |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Documentation

@farcaster/js has four major components:
@farcaster/hub-nodejs has four major components:

- A [Client](./Client.md), which can send and receive messages from a Farcaster Hub.
- [Messages](./Messages.md), which are the atomic units of change on the Farcaster network.
Expand Down Expand Up @@ -37,8 +37,8 @@ const bytesString = new Uint8Array(Buffer.from(hexString, 'hex'));

### Error Handling

Error handling in @farcaster/js is monadic and functions do not throw exceptions. Each function call returns a Result object which contains a success value or error value. Read the [neverthrow](https://github.com/supermacro/neverthrow/blob/master/README.md) documentation to learn about handling Result types.
Error handling in @farcaster/hub-nodejs is monadic and functions do not throw exceptions. Each function call returns a Result object which contains a success value or error value. Read the [neverthrow](https://github.com/supermacro/neverthrow/blob/master/README.md) documentation to learn about handling Result types.

### Environments

@farcaster/js only works inside a NodeJS environment. Browser support is a [work in progress](https://github.com/farcasterxyz/hubble/issues/573).
@farcaster/hub-nodejs only works inside a NodeJS environment. Browser support is a [work in progress](https://github.com/farcasterxyz/hubble/issues/573).
Loading

0 comments on commit a74ecb2

Please sign in to comment.