Skip to content

Commit

Permalink
fix: fix bug due to bundling of default Provider instances
Browse files Browse the repository at this point in the history
  • Loading branch information
gsgalloway committed Sep 27, 2022
1 parent 7ddb309 commit 99f2fd7
Show file tree
Hide file tree
Showing 17 changed files with 105 additions and 78 deletions.
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ npm install @standard-crypto/farcaster-js
```ts
import { publishCast } from "@standard-crypto/farcaster-js";
import { Wallet } from "ethers";
import { AlchemyProvider } from "@ethersproject/providers";

const provider = new AlchemyProvider("goerli");
const wallet = Wallet.fromMnemonic("twelve words here");
await publishCast(wallet, "Hello, Farcaster!");
await publishCast(wallet, provider, "Hello, Farcaster!");
```
<!-- AUTO-GENERATED-CONTENT:END -->

Expand All @@ -43,8 +45,9 @@ await publishCast(wallet, "Hello, Farcaster!");
<!-- The below code snippet is automatically added from ./examples/fetchUserActivity.ts -->
```ts
import { Farcaster } from "@standard-crypto/farcaster-js";
import { AlchemyProvider } from "@ethersproject/providers";

const farcaster = new Farcaster();
const farcaster = new Farcaster(new AlchemyProvider("goerli"));
for await (const activity of farcaster.getAllActivityForUser("dwr", {
includeRecasts: false,
})) {
Expand All @@ -60,11 +63,13 @@ for await (const activity of farcaster.getAllActivityForUser("dwr", {
```ts
import { Farcaster, publishCast } from "@standard-crypto/farcaster-js";
import { Wallet } from "ethers";
import { AlchemyProvider } from "@ethersproject/providers";

const farcaster = new Farcaster();
const provider = new AlchemyProvider("goerli");
const farcaster = new Farcaster(provider);
const latestCast = await farcaster.getLatestActivityForUser("dwr");
const wallet = Wallet.fromMnemonic("twelve words here");
await publishCast(wallet, "Replying to your cast!", latestCast);
await publishCast(wallet, provider, "Replying to your cast!", latestCast);
```
<!-- AUTO-GENERATED-CONTENT:END -->

Expand All @@ -74,8 +79,9 @@ await publishCast(wallet, "Replying to your cast!", latestCast);
<!-- The below code snippet is automatically added from ./examples/lookupUser.ts -->
```ts
import { UserRegistry } from "@standard-crypto/farcaster-js";
import { AlchemyProvider } from "@ethersproject/providers";

const userRegistry = new UserRegistry();
const userRegistry = new UserRegistry(new AlchemyProvider("goerli"));

// by username
await userRegistry.lookupByUsername("dwr");
Expand All @@ -94,10 +100,12 @@ await userRegistry.lookupByAddress(
```ts
import { Wallet } from "@ethersproject/wallet";
import { UserRegistry } from "@standard-crypto/farcaster-js";
import { AlchemyProvider } from "@ethersproject/providers";

const provider = new AlchemyProvider("goerli");
const ownerWallet = Wallet.fromMnemonic("twelve words here");
const recoveryWalletAddress = "0x...";
const userRegistry = new UserRegistry();
const userRegistry = new UserRegistry(provider);
const usernameToRegister = "new-username";

// Send transaction to pre-commit to this username
Expand Down
20 changes: 14 additions & 6 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ npm install @standard-crypto/farcaster-js
```ts
import { publishCast } from "@standard-crypto/farcaster-js";
import { Wallet } from "ethers";
import { AlchemyProvider } from "@ethersproject/providers";

const provider = new AlchemyProvider("goerli");
const wallet = Wallet.fromMnemonic("twelve words here");
await publishCast(wallet, "Hello, Farcaster!");
await publishCast(wallet, provider, "Hello, Farcaster!");
```
<!-- AUTO-GENERATED-CONTENT:END -->

Expand All @@ -45,8 +47,9 @@ await publishCast(wallet, "Hello, Farcaster!");
<!-- The below code snippet is automatically added from ./examples/fetchUserActivity.ts -->
```ts
import { Farcaster } from "@standard-crypto/farcaster-js";
import { AlchemyProvider } from "@ethersproject/providers";

const farcaster = new Farcaster();
const farcaster = new Farcaster(new AlchemyProvider("goerli"));
for await (const activity of farcaster.getAllActivityForUser("dwr", {
includeRecasts: false,
})) {
Expand All @@ -62,11 +65,13 @@ for await (const activity of farcaster.getAllActivityForUser("dwr", {
```ts
import { Farcaster, publishCast } from "@standard-crypto/farcaster-js";
import { Wallet } from "ethers";
import { AlchemyProvider } from "@ethersproject/providers";

const farcaster = new Farcaster();
const provider = new AlchemyProvider("goerli");
const farcaster = new Farcaster(provider);
const latestCast = await farcaster.getLatestActivityForUser("dwr");
const wallet = Wallet.fromMnemonic("twelve words here");
await publishCast(wallet, "Replying to your cast!", latestCast);
await publishCast(wallet, provider, "Replying to your cast!", latestCast);
```
<!-- AUTO-GENERATED-CONTENT:END -->

Expand All @@ -76,8 +81,9 @@ await publishCast(wallet, "Replying to your cast!", latestCast);
<!-- The below code snippet is automatically added from ./examples/lookupUser.ts -->
```ts
import { UserRegistry } from "@standard-crypto/farcaster-js";
import { AlchemyProvider } from "@ethersproject/providers";

const userRegistry = new UserRegistry();
const userRegistry = new UserRegistry(new AlchemyProvider("goerli"));

// by username
await userRegistry.lookupByUsername("dwr");
Expand All @@ -96,10 +102,12 @@ await userRegistry.lookupByAddress(
```ts
import { Wallet } from "@ethersproject/wallet";
import { UserRegistry } from "@standard-crypto/farcaster-js";
import { AlchemyProvider } from "@ethersproject/providers";

const provider = new AlchemyProvider("goerli");
const ownerWallet = Wallet.fromMnemonic("twelve words here");
const recoveryWalletAddress = "0x...";
const userRegistry = new UserRegistry();
const userRegistry = new UserRegistry(provider);
const usernameToRegister = "new-username";

// Send transaction to pre-commit to this username
Expand Down
24 changes: 15 additions & 9 deletions docs/classes/Farcaster.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,17 @@ High-level functionality for interacting with Farcaster

### constructor

**new Farcaster**()
**new Farcaster**(`web3Provider`)

#### Parameters

| Name | Type |
| :------ | :------ |
| `web3Provider` | `Provider` |

#### Defined in

[farcaster.ts:28](https://github.com/standard-crypto/farcaster-js/blob/main/src/farcaster.ts#L28)
[farcaster.ts:29](https://github.com/standard-crypto/farcaster-js/blob/main/src/farcaster.ts#L29)

## Properties

Expand All @@ -41,7 +47,7 @@ High-level functionality for interacting with Farcaster

#### Defined in

[farcaster.ts:26](https://github.com/standard-crypto/farcaster-js/blob/main/src/farcaster.ts#L26)
[farcaster.ts:27](https://github.com/standard-crypto/farcaster-js/blob/main/src/farcaster.ts#L27)

___

Expand All @@ -51,7 +57,7 @@ ___

#### Defined in

[farcaster.ts:25](https://github.com/standard-crypto/farcaster-js/blob/main/src/farcaster.ts#L25)
[farcaster.ts:26](https://github.com/standard-crypto/farcaster-js/blob/main/src/farcaster.ts#L26)

## Methods

Expand All @@ -75,7 +81,7 @@ Yields all [Messages](../interfaces/Message.md) from the given username, in orde

#### Defined in

[farcaster.ts:145](https://github.com/standard-crypto/farcaster-js/blob/main/src/farcaster.ts#L145)
[farcaster.ts:146](https://github.com/standard-crypto/farcaster-js/blob/main/src/farcaster.ts#L146)

___

Expand All @@ -97,7 +103,7 @@ Returns the most recent [Message](../interfaces/Message.md) published by the giv

#### Defined in

[farcaster.ts:130](https://github.com/standard-crypto/farcaster-js/blob/main/src/farcaster.ts#L130)
[farcaster.ts:131](https://github.com/standard-crypto/farcaster-js/blob/main/src/farcaster.ts#L131)

___

Expand All @@ -119,7 +125,7 @@ Validates a [CastRequest](../interfaces/CastRequest.md) and marshals it to an un

#### Defined in

[farcaster.ts:36](https://github.com/standard-crypto/farcaster-js/blob/main/src/farcaster.ts#L36)
[farcaster.ts:37](https://github.com/standard-crypto/farcaster-js/blob/main/src/farcaster.ts#L37)

___

Expand All @@ -142,7 +148,7 @@ Validates [signature](../interfaces/Message.md#signature) and [merkleRoot](../in

#### Defined in

[farcaster.ts:114](https://github.com/standard-crypto/farcaster-js/blob/main/src/farcaster.ts#L114)
[farcaster.ts:115](https://github.com/standard-crypto/farcaster-js/blob/main/src/farcaster.ts#L115)

___

Expand All @@ -169,4 +175,4 @@ Signs a cast.

#### Defined in

[farcaster.ts:92](https://github.com/standard-crypto/farcaster-js/blob/main/src/farcaster.ts#L92)
[farcaster.ts:93](https://github.com/standard-crypto/farcaster-js/blob/main/src/farcaster.ts#L93)
24 changes: 12 additions & 12 deletions docs/classes/UserRegistry.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ Registry of usernames and their corresponding owners, as well as the directory U

### constructor

**new UserRegistry**(`__namedParameters?`)
**new UserRegistry**(`web3Provider`, `__namedParameters?`)

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `web3Provider` | `Provider` | Provide Infura/Alchemy/etc |
| `__namedParameters` | `Object` | - |
| `__namedParameters.axiosInstance?` | `AxiosInstance` | Override for improved caching, rate-limiting, etcetera |
| `__namedParameters.web3Provider?` | `Provider` | Override to provide Infura/Alchemy/etc with an API key (and better performance) |

#### Defined in

Expand Down Expand Up @@ -156,7 +156,7 @@ username

#### Defined in

[userRegistry.ts:290](https://github.com/standard-crypto/farcaster-js/blob/main/src/userRegistry.ts#L290)
[userRegistry.ts:291](https://github.com/standard-crypto/farcaster-js/blob/main/src/userRegistry.ts#L291)

___

Expand All @@ -172,7 +172,7 @@ Yields all registered usernames, in no particular order

#### Defined in

[userRegistry.ts:247](https://github.com/standard-crypto/farcaster-js/blob/main/src/userRegistry.ts#L247)
[userRegistry.ts:248](https://github.com/standard-crypto/farcaster-js/blob/main/src/userRegistry.ts#L248)

___

Expand All @@ -188,7 +188,7 @@ Yields all registered users, in no particular order

#### Defined in

[userRegistry.ts:226](https://github.com/standard-crypto/farcaster-js/blob/main/src/userRegistry.ts#L226)
[userRegistry.ts:227](https://github.com/standard-crypto/farcaster-js/blob/main/src/userRegistry.ts#L227)

___

Expand All @@ -213,7 +213,7 @@ FarcasterID or 0 if user is not registered to one

#### Defined in

[userRegistry.ts:163](https://github.com/standard-crypto/farcaster-js/blob/main/src/userRegistry.ts#L163)
[userRegistry.ts:164](https://github.com/standard-crypto/farcaster-js/blob/main/src/userRegistry.ts#L164)

___

Expand All @@ -235,7 +235,7 @@ Fetches a full [User](../interfaces/User.md) by address, if any exists. Undefine

#### Defined in

[userRegistry.ts:203](https://github.com/standard-crypto/farcaster-js/blob/main/src/userRegistry.ts#L203)
[userRegistry.ts:204](https://github.com/standard-crypto/farcaster-js/blob/main/src/userRegistry.ts#L204)

___

Expand All @@ -257,7 +257,7 @@ Fetches a full [User](../interfaces/User.md) by username, if any exists. Undefin

#### Defined in

[userRegistry.ts:173](https://github.com/standard-crypto/farcaster-js/blob/main/src/userRegistry.ts#L173)
[userRegistry.ts:174](https://github.com/standard-crypto/farcaster-js/blob/main/src/userRegistry.ts#L174)

___

Expand All @@ -284,7 +284,7 @@ Registers a username after it was pre-committed via `commitToUsername`.

#### Defined in

[userRegistry.ts:344](https://github.com/standard-crypto/farcaster-js/blob/main/src/userRegistry.ts#L344)
[userRegistry.ts:345](https://github.com/standard-crypto/farcaster-js/blob/main/src/userRegistry.ts#L345)

___

Expand All @@ -309,7 +309,7 @@ Transfers ownership of a username to a new address. The Signer must be the curre

#### Defined in

[userRegistry.ts:261](https://github.com/standard-crypto/farcaster-js/blob/main/src/userRegistry.ts#L261)
[userRegistry.ts:262](https://github.com/standard-crypto/farcaster-js/blob/main/src/userRegistry.ts#L262)

___

Expand All @@ -335,7 +335,7 @@ UInt256 representation of the given username

#### Defined in

[userRegistry.ts:151](https://github.com/standard-crypto/farcaster-js/blob/main/src/userRegistry.ts#L151)
[userRegistry.ts:152](https://github.com/standard-crypto/farcaster-js/blob/main/src/userRegistry.ts#L152)

___

Expand All @@ -361,4 +361,4 @@ https://goerli.etherscan.io/address/0xf73bc3fa2f6f774d4b6791414b1092a40cd83831#c

#### Defined in

[userRegistry.ts:88](https://github.com/standard-crypto/farcaster-js/blob/main/src/userRegistry.ts#L88)
[userRegistry.ts:89](https://github.com/standard-crypto/farcaster-js/blob/main/src/userRegistry.ts#L89)
10 changes: 5 additions & 5 deletions docs/interfaces/CastRequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#### Defined in

[farcaster.ts:14](https://github.com/standard-crypto/farcaster-js/blob/main/src/farcaster.ts#L14)
[farcaster.ts:15](https://github.com/standard-crypto/farcaster-js/blob/main/src/farcaster.ts#L15)

___

Expand All @@ -30,7 +30,7 @@ ___

#### Defined in

[farcaster.ts:17](https://github.com/standard-crypto/farcaster-js/blob/main/src/farcaster.ts#L17)
[farcaster.ts:18](https://github.com/standard-crypto/farcaster-js/blob/main/src/farcaster.ts#L18)

___

Expand All @@ -40,7 +40,7 @@ ___

#### Defined in

[farcaster.ts:15](https://github.com/standard-crypto/farcaster-js/blob/main/src/farcaster.ts#L15)
[farcaster.ts:16](https://github.com/standard-crypto/farcaster-js/blob/main/src/farcaster.ts#L16)

___

Expand All @@ -50,7 +50,7 @@ ___

#### Defined in

[farcaster.ts:13](https://github.com/standard-crypto/farcaster-js/blob/main/src/farcaster.ts#L13)
[farcaster.ts:14](https://github.com/standard-crypto/farcaster-js/blob/main/src/farcaster.ts#L14)

___

Expand All @@ -60,4 +60,4 @@ ___

#### Defined in

[farcaster.ts:18](https://github.com/standard-crypto/farcaster-js/blob/main/src/farcaster.ts#L18)
[farcaster.ts:19](https://github.com/standard-crypto/farcaster-js/blob/main/src/farcaster.ts#L19)
5 changes: 3 additions & 2 deletions docs/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@

#### Defined in

[farcaster.ts:10](https://github.com/standard-crypto/farcaster-js/blob/main/src/farcaster.ts#L10)
[farcaster.ts:11](https://github.com/standard-crypto/farcaster-js/blob/main/src/farcaster.ts#L11)

## Functions

### publishCast

**publishCast**(`wallet`, `text`, `replyTo?`): `Promise`<[`SignedCast`](modules.md#signedcast)\>
**publishCast**(`wallet`, `web3Provider`, `text`, `replyTo?`): `Promise`<[`SignedCast`](modules.md#signedcast)\>

Signs and publishes a simple text string.
The cast will be attributed to the username currently registered
Expand All @@ -75,6 +75,7 @@ to the given private key's address.
| Name | Type | Description |
| :------ | :------ | :------ |
| `wallet` | `Wallet` | A Wallet derived from a private key or mnemonic phrase |
| `web3Provider` | `Provider` | A Provider instance (Infura/Alchemy/etc) |
| `text` | `string` | The text to be cast |
| `replyTo?` | `string` \| [`Message`](interfaces/Message.md) | A complete [Message](interfaces/Message.md), or the [merkleRoot](interfaces/Message.md#merkleroot) of a message, that this cast will reply to. Omit if not replying to any casts. |

Expand Down
3 changes: 2 additions & 1 deletion examples/fetchUserActivity.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Farcaster } from "@standard-crypto/farcaster-js";
import { AlchemyProvider } from "@ethersproject/providers";

const farcaster = new Farcaster();
const farcaster = new Farcaster(new AlchemyProvider("goerli"));
for await (const activity of farcaster.getAllActivityForUser("dwr", {
includeRecasts: false,
})) {
Expand Down
3 changes: 2 additions & 1 deletion examples/lookupUser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { UserRegistry } from "@standard-crypto/farcaster-js";
import { AlchemyProvider } from "@ethersproject/providers";

const userRegistry = new UserRegistry();
const userRegistry = new UserRegistry(new AlchemyProvider("goerli"));

// by username
await userRegistry.lookupByUsername("dwr");
Expand Down
Loading

0 comments on commit 99f2fd7

Please sign in to comment.