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

docs: update migration docs after alchemy transport #998

Open
wants to merge 1 commit into
base: moldy/core-transport-refactor
Choose a base branch
from
Open
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
11 changes: 7 additions & 4 deletions site/pages/core/multi-chain-apps.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ In order to support multiple chains in your app, the first thing you need to do

```ts twoslash
import { createConfig } from "@account-kit/core";
import { sepolia, mainnet } from "@account-kit/infra";
import { sepolia, mainnet, alchemy } from "@account-kit/infra";

export const config = createConfig({
apiKey: "ALCHEMY_API_KEY",
// use this transport for all chains
transport: alchemy({ apiKey: "ALCHEMY_API_KEY" }),
// this is the default chain
chain: sepolia,
chains: [
Expand All @@ -27,6 +28,8 @@ export const config = createConfig({
},
{
chain: sepolia,
// optional: override the default transport for this chain
transport: alchemy({ apiKey: "OTHER_API_KEY" }),
// optional: sponsor gas for this chain
policyId: "SEPOLIA_GAS_MANAGER_POLICY_ID",
},
Expand Down Expand Up @@ -55,10 +58,10 @@ await setChain(config, mainnet);

```ts twoslash [config.ts] filename="config.ts"
import { createConfig } from "@account-kit/core";
import { sepolia, mainnet } from "@account-kit/infra";
import { sepolia, mainnet, alchemy } from "@account-kit/infra";

export const config = createConfig({
apiKey: "ALCHEMY_API_KEY",
transport: alchemy({ apiKey: "ALCHEMY_API_KEY" }),
// this is the default chain
chain: sepolia,
chains: [
Expand Down
4 changes: 2 additions & 2 deletions site/pages/core/sponsor-gas.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ Remember to replace `ALCHEMY_API_KEY` with your Alchemy API key. If you don't ha

```ts twoslash
import { createConfig } from "@account-kit/core";
import { sepolia } from "@account-kit/infra";
import { sepolia, alchemy } from "@account-kit/infra";

export const config = createConfig({
apiKey: "ALCHEMY_API_KEY",
transport: alchemy({ apiKey: "ALCHEMY_API_KEY" }),
chain: sepolia,
policyId: "GAS_MANAGER_POLICY_ID", // [!code ++]
});
Expand Down
12 changes: 6 additions & 6 deletions site/pages/core/ssr.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ To enable this setting, you can set `ssr: true` when creating a config.

```ts twoslash
import { createConfig } from "@account-kit/core";
import { sepolia } from "@account-kit/infra";
import { sepolia, alchemy } from "@account-kit/infra";

export const config = createConfig({
apiKey: "YOUR_API_KEY",
transport: alchemy({ apiKey: "ALCHEMY_API_KEY" }),
chain: sepolia,
ssr: true, // [!code ++]
});
Expand Down Expand Up @@ -59,10 +59,10 @@ import {
createConfig,
cookieStorage, // [!code ++]
} from "@account-kit/core";
import { sepolia } from "@account-kit/infra";
import { sepolia, alchemy } from "@account-kit/infra";

export const config = createConfig({
apiKey: "YOUR_API_KEY",
transport: alchemy({ apiKey: "ALCHEMY_API_KEY" }),
chain: sepolia,
ssr: true, // [!code ++]
storage: cookieStorage, // [!code ++]
Expand Down Expand Up @@ -90,10 +90,10 @@ if (typeof window !== "undefined") {

```ts twoslash [config.ts] filename="config.ts"
import { createConfig, cookieStorage } from "@account-kit/core";
import { sepolia } from "@account-kit/infra";
import { sepolia, alchemy } from "@account-kit/infra";

export const config = createConfig({
apiKey: "YOUR_API_KEY",
transport: alchemy({ apiKey: "ALCHEMY_API_KEY" }),
chain: sepolia,
ssr: true,
storage: cookieStorage,
Expand Down
13 changes: 13 additions & 0 deletions site/pages/migration-guide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ We still support all Signers in the SDK!
use the guide above to integrate with any signer of your choice.
:::

### Alchemy Transport

A new `Transport` type has been added: `AlchemyTransport`. This impacts how Alchemy clients, middleware, and configs are created. The `AlchemyTransport` is a type of `viem` transport that makes it easier to configure your communication with Alchemy RPC.
It supports splitting traffic between Alchemy's AA infra and other Node providers (if needed). The `AlchemyTransport` has been added to `@account-kit/infra` and is exported as `alchemy`.

For Smart Account Clients, the impact of this change is that every `create*AlchemyClient` method has been updated to take in a `transport` property instead of `rpcUrl` or `apiKey` directly.

The `alchemyFeeEstimator` and `alchemyUserOperationSimulator` middleware methods no longer take in a `ClientWithAlchemyMethods` (returned by `createAlchemyPublicRpcClient`) and instead take in an `AlchemyTransport`.

Creating a config to be used with `@account-kit/core` or `@account-kit/react` has also been updated to accept an `AlchemyTransport` and the parameters of `createConfig` have been simplified as a result. Replace your `rpcUrl` or `apiKey` params with `transport: alchemy({...})`.

For more detailed examples, see the relevant guides, depending on which package you are using.

### Hooks: `useSendTransaction` and `useSendTransactions` removed

These methods have been removed since `useSendUserOperation` can be used to send transactions and user operations. If you were using `useSendTransaction` or `useSendTransactions`, you can replace them with
Expand Down
4 changes: 2 additions & 2 deletions site/shared/core/config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createConfig } from "@account-kit/core";
import { sepolia } from "@account-kit/infra";
import { alchemy, sepolia } from "@account-kit/infra";

export const config = createConfig({
apiKey: "YOUR_API_KEY",
transport: alchemy({ apiKey: "YOUR_API_KEY" }),
chain: sepolia,
// optional if you want to sponsor gas
policyId: "YOUR_POLICY_ID",
Expand Down
4 changes: 2 additions & 2 deletions site/shared/core/ssr-config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createConfig } from "@account-kit/core";
import { sepolia } from "@account-kit/infra";
import { alchemy, sepolia } from "@account-kit/infra";

export const config = createConfig({
apiKey: "YOUR_API_KEY",
transport: alchemy({ apiKey: "YOUR_API_KEY" }),
chain: sepolia,
ssr: true,
});
36 changes: 18 additions & 18 deletions site/sidebar/signer.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading