Skip to content

Commit

Permalink
refactor: split aa-alchemy into account-kit packages (#704)
Browse files Browse the repository at this point in the history
* refactor: split aa-alchemy into account-kit packages

BREAKING CHANGE: this removes the @alchemy/aa-alchemy package in favor of @account-kit/*

* refactor: delete aa-accounts and move to @account-kit/accounts (#706)

BREAKING CHANGE: @alchemy/aa-accounts was deleted in favor of @account-kit/accounts

* refactor: further rename packages
  • Loading branch information
moldy530 committed Jun 14, 2024
1 parent 6c9c720 commit 6c41e22
Show file tree
Hide file tree
Showing 716 changed files with 1,995 additions and 13,198 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
},
"homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
"dependencies": {
"@alchemy/aa-accounts": "^3.18.2",
"@alchemy/aa-core": "^3.18.2",
"bundle-require": "^4.0.2",
"cac": "^6.7.14",
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { IPluginAbi } from "@alchemy/aa-accounts";
import { asyncPipe } from "@alchemy/aa-core";
import { kebabCase } from "change-case";
import dedent from "dedent";
Expand All @@ -14,6 +13,7 @@ import {
} from "viem";
import z from "zod";
import type { Config, PluginConfig } from "../../config.js";
import { IPluginAbi } from "../../IPlugin.js";
import * as logger from "../../logger.js";
import { findConfig } from "../../utils/findConfig.js";
import { format } from "../../utils/format.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ export const PluginActionsGenPhase: Phase = async (input) => {
isType: true,
});
addImport("@alchemy/aa-core", {
name: "EntryPointVersion",
name: "GetEntryPointFromAccount",
isType: true,
});
addImport("@alchemy/aa-core", {
name: "UserOperationOverridesParameter",
isType: true,
});
addImport("@alchemy/aa-core", {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,24 @@ const addImports = (

addImport("@alchemy/aa-core", { name: "ChainNotFoundError" });
addImport("viem", { name: "encodeAbiParameters" });
addImport("@alchemy/aa-accounts", {
addImport("@account-kit/smart-contracts", {
name: "installPlugin as installPlugin_",
});
addImport("@alchemy/aa-core", {
name: "GetAccountParameter",
isType: true,
});
addImport("@alchemy/aa-accounts", {
name: "FunctionReference",
addImport("@alchemy/aa-core", {
name: "GetEntryPointFromAccount",
isType: true,
});
addImport("@alchemy/aa-accounts", {
addImport("@alchemy/aa-core", {
name: "UserOperationContext",
isType: true,
});
addImport("@account-kit/smart-contracts", {
name: "FunctionReference",
isType: true,
});
addImport("@alchemy/aa-core", { name: "GetContextParameter", isType: true });
};
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ export const AccountReadActionsGenPhase: Phase = async (input) => {
n.inputs.length > 0
? dedent`${readMethodName}: (
args: Pick<EncodeFunctionDataParameters<typeof ${executionAbiConst}, "${n.name}">, "args"> &
GetAccountParameter<TEntryPointVersion, TAccount>
GetAccountParameter<TAccount>
) => Promise<ReadContractReturnType<typeof ${executionAbiConst}, "${n.name}">>`
: dedent`${readMethodName}: (args: GetAccountParameter<TEntryPointVersion, TAccount>) =>
: dedent`${readMethodName}: (args: GetAccountParameter<TAccount>) =>
Promise<ReadContractReturnType<typeof ${executionAbiConst}, "${n.name}">>`
);

Expand Down Expand Up @@ -82,7 +82,6 @@ export const AccountReadActionsGenPhase: Phase = async (input) => {
const typeName = input.hasReadMethods
? `ReadAndEncodeActions<
TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined,
TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>,
>`
: "ReadAndEncodeActions";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const PluginGeneratorPhase: Phase = async (input) => {
content: [],
});

addImport("@alchemy/aa-accounts", { name: "Plugin", isType: true });
addImport("@account-kit/smart-contracts", { name: "Plugin", isType: true });

input.content.push(dedent`
export const ${pluginConfig.name}: Plugin<typeof ${
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IPluginAbi } from "@alchemy/aa-accounts";
import type { GetContractReturnType, PublicClient } from "viem";
import type { Config, PluginConfig } from "../../config.js";
import type { IPluginAbi } from "../../IPlugin.js";

export type PhaseInput = {
content: string[];
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions aa-sdk/plugingen/src/exports/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { IPluginAbi } from "../IPlugin.js";
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
77 changes: 77 additions & 0 deletions account-kit/core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"name": "@account-kit/core",
"version": "3.18.2",
"description": "Core library for account kit that provides state management and framework indepednent abstractions across infra, Alchemy Signer, and Smart Contracts",
"author": "Alchemy",
"license": "MIT",
"private": false,
"type": "module",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts",
"typings": "./dist/types/index.d.ts",
"sideEffects": false,
"files": [
"dist",
"src/**/*.ts",
"!dist/**/*.tsbuildinfo",
"!vitest.config.ts",
"!.env",
"!src/**/*.test.ts",
"!src/__tests__/**/*"
],
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"import": "./dist/esm/index.js",
"default": "./dist/cjs/index.js"
},
"./package.json": "./package.json"
},
"scripts": {
"prebuild": "node --loader ts-node/esm ./inject-version.ts",
"build": "yarn clean && yarn build:cjs && yarn build:esm && yarn build:types",
"build:cjs": "tsc --project tsconfig.build.json --module commonjs --outDir ./dist/cjs --removeComments --verbatimModuleSyntax false && echo > ./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
"build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir ./dist/esm --removeComments && echo > ./dist/esm/package.json '{\"type\":\"module\"}'",
"build:types": "tsc --project tsconfig.build.json --module esnext --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
"clean": "rm -rf ./dist",
"test": "vitest --passWithNoTests",
"test:run": "vitest run --passWithNoTests",
"test:run-e2e": "vitest run --config vitest.config.e2e.ts --passWithNoTests"
},
"devDependencies": {
"typescript": "^5.0.4",
"typescript-template": "*",
"vitest": "^0.31.0"
},
"dependencies": {
"@account-kit/infra": "^3.18.2",
"@wagmi/core": "^2.9.8",
"js-cookie": "^3.0.5",
"viem": "2.8.6",
"zod": "^3.22.4",
"zustand": "^4.5.2"
},
"peerDependencies": {
"viem": "2.8.6"
},
"resolutions": {
"viem": "2.8.6"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"repository": {
"type": "git",
"url": "git+https://github.com/alchemyplatform/aa-sdk.git"
},
"bugs": {
"url": "https://github.com/alchemyplatform/aa-sdk/issues"
},
"homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
"gitHead": "ee46e8bb857de3b631044fa70714ea706d9e317d",
"optionalDependencies": {
"alchemy-sdk": "^3.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import {
createLightAccount,
createMultiOwnerModularAccount,
createModularAccount,
type CreateLightAccountParams,
type CreateMultiOwnerModularAccountParams,
type GetLightAccountVersion,
} from "@alchemy/aa-accounts";
} from "@account-kit/infra";
import { type SmartAccountSigner } from "@alchemy/aa-core";
import { custom, type Transport } from "viem";
import { ClientOnlyPropertyError } from "../errors.js";
import type {
AlchemyAccountsConfig,
SupportedAccountTypes,
SupportedAccounts,
} from "../types";
} from "../types.js";
import { getBundlerClient } from "./getBundlerClient.js";
import { getSigner } from "./getSigner.js";
import { getSignerStatus } from "./getSignerStatus.js";
Expand Down Expand Up @@ -75,7 +75,7 @@ export async function createAccount<TAccount extends SupportedAccountTypes>(
chain,
});
case "MultiOwnerModularAccount":
return createMultiOwnerModularAccount({
return createModularAccount({
...params,
...cachedConfig,
signer,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { AccountState } from "../store/types.js";
import type { AlchemyAccountsConfig, SupportedAccountTypes } from "../types";
import type { AlchemyAccountsConfig, SupportedAccountTypes } from "../types.js";
import { type CreateAccountParams } from "./createAccount.js";
import { getChain } from "./getChain.js";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ClientWithAlchemyMethods } from "../../client/types";
import type { ClientWithAlchemyMethods } from "@account-kit/infra";
import type { AlchemyAccountsConfig } from "../types";

export const getBundlerClient = (
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChainNotFoundError } from "../errors.js";
import type { AlchemyAccountsConfig, Connection } from "../types";
import type { AlchemyAccountsConfig, Connection } from "../types.js";
import { getChain } from "./getChain.js";

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AlchemySigner } from "../../signer/signer.js";
import type { AlchemyAccountsConfig } from "../types";
import type { AlchemyAccountsConfig } from "../types.js";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import type { AlchemyWebSigner } from "@account-kit/infra";
import type { hydrate } from "../hydrate.js";

/**
Expand All @@ -13,6 +13,6 @@ import type { hydrate } from "../hydrate.js";
*/
export const getSigner = (
config: AlchemyAccountsConfig
): AlchemySigner | null => {
): AlchemyWebSigner | null => {
return config.clientStore.getState().signer ?? null;
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { User } from "../../signer";
import type { User } from "@account-kit/infra";
import type { AlchemyAccountsConfig } from "../types";

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createSigner } from "../store/client.js";
import type { AlchemyAccountsConfig } from "../types";
import type { AlchemyAccountsConfig } from "../types.js";
import { createAccount } from "./createAccount.js";
import { getChain } from "./getChain.js";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createAlchemyPublicRpcClient } from "@account-kit/infra";
import { switchChain } from "@wagmi/core";
import type { Chain } from "viem";
import { createAlchemyPublicRpcClient } from "../../client/rpcClient.js";
import { ChainNotFoundError } from "../errors.js";
import type { AlchemyAccountsConfig } from "../types";
import type { AlchemyAccountsConfig } from "../types.js";

/**
* Allows you to change the current chain in the core store
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ClientOnlyPropertyError } from "../errors.js";
import type { AlchemyAccountsConfig, SupportedAccountTypes } from "../types";
import type { AlchemyAccountsConfig, SupportedAccountTypes } from "../types.js";
import { type GetAccountResult } from "./getAccount.js";
import { getChain } from "./getChain.js";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ClientWithAlchemyMethods } from "../../client/types";
import type { ClientWithAlchemyMethods } from "@account-kit/infra";
import type { AlchemyAccountsConfig } from "../types";

export const watchBundlerClient =
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AlchemySigner } from "../../signer";
import type { AlchemyWebSigner } from "@account-kit/infra";
import type { AlchemyAccountsConfig } from "../types";

/**
Expand All @@ -9,6 +9,6 @@ import type { AlchemyAccountsConfig } from "../types";
*/
export const watchSigner =
(config: AlchemyAccountsConfig) =>
(onChange: (signer?: AlchemySigner) => void) => {
(onChange: (signer?: AlchemyWebSigner) => void) => {
return config.clientStore.subscribe(({ signer }) => signer, onChange);
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { SignerStatus } from "../store/types.js";
import type { AlchemyAccountsConfig } from "../types";
import type { AlchemyAccountsConfig } from "../types.js";

export const watchSignerStatus =
(config: AlchemyAccountsConfig) =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { User } from "../../signer";
import type { User } from "@account-kit/infra";
import type { AlchemyAccountsConfig } from "../types";

export const watchUser =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { DEFAULT_SESSION_MS } from "@account-kit/infra";
import { ConnectionConfigSchema } from "@alchemy/aa-core";
import { createStorage, createConfig as createWagmiConfig } from "@wagmi/core";
import { DEFAULT_SESSION_MS } from "../signer/session/manager.js";
import { createClientStore } from "./store/client.js";
import { createCoreStore } from "./store/core.js";
import { DEFAULT_STORAGE_KEY } from "./store/types.js";
import type {
AlchemyAccountsConfig,
Connection,
CreateConfigProps,
} from "./types";
} from "./types.js";

export const DEFAULT_IFRAME_CONTAINER_ID = "alchemy-signer-iframe-container";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { BaseError as CoreBaseError } from "@alchemy/aa-core";
import type { Chain } from "viem";
import { BaseError } from "../errors/base.js";
import { VERSION } from "./version.js";

export abstract class BaseError extends CoreBaseError {
// This version could be different from the aa-core version so we overwrite this here.
override version = VERSION;
}

export class ClientOnlyPropertyError extends BaseError {
name: string = "ClientOnlyPropertyError";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { AlchemySignerStatus } from "@account-kit/infra";
import type { Address } from "@alchemy/aa-core";
import { hydrate as wagmi_hydrate } from "@wagmi/core";
import { AlchemySignerStatus } from "../signer/index.js";
import { reconnect } from "./actions/reconnect.js";
import {
convertSignerStatusToState,
createDefaultAccountState,
defaultAccountState,
} from "./store/client.js";
import type { AccountState, ClientState, StoredState } from "./store/types";
import type { AlchemyAccountsConfig, SupportedAccountTypes } from "./types";
import type { AccountState, ClientState, StoredState } from "./store/types.js";
import type { AlchemyAccountsConfig, SupportedAccountTypes } from "./types.js";

/**
* Will hydrate the client store with the provided initial state if one is provided.
Expand Down
39 changes: 39 additions & 0 deletions account-kit/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
export type * from "./actions/createAccount.js";
export { createAccount } from "./actions/createAccount.js";
export type * from "./actions/getAccount.js";
export { getAccount } from "./actions/getAccount.js";
export type * from "./actions/getBundlerClient.js";
export { getBundlerClient } from "./actions/getBundlerClient.js";
export { getChain } from "./actions/getChain.js";
export type * from "./actions/getConnection.js";
export { getConnection } from "./actions/getConnection.js";
export type * from "./actions/getSigner.js";
export { getSigner } from "./actions/getSigner.js";
export type * from "./actions/getSignerStatus.js";
export { getSignerStatus } from "./actions/getSignerStatus.js";
export type * from "./actions/getUser.js";
export { getUser } from "./actions/getUser.js";
export type * from "./actions/reconnect.js";
export { reconnect } from "./actions/reconnect.js";
export { setChain } from "./actions/setChain.js";
export type * from "./actions/watchAccount.js";
export { watchAccount } from "./actions/watchAccount.js";
export type * from "./actions/watchBundlerClient.js";
export { watchBundlerClient } from "./actions/watchBundlerClient.js";
export { watchChain } from "./actions/watchChain.js";
export type * from "./actions/watchConnection.js";
export { watchConnection } from "./actions/watchConnection.js";
export type * from "./actions/watchSigner.js";
export { watchSigner } from "./actions/watchSigner.js";
export type * from "./actions/watchSignerStatus.js";
export { watchSignerStatus } from "./actions/watchSignerStatus.js";
export type * from "./actions/watchUser.js";
export { watchUser } from "./actions/watchUser.js";
export { DEFAULT_IFRAME_CONTAINER_ID, createConfig } from "./createConfig.js";
export type * from "./createConfig.js";
export { ClientOnlyPropertyError } from "./errors.js";
export { hydrate } from "./hydrate.js";
export { defaultAccountState } from "./store/client.js";
export type { SignerStatus } from "./store/types.js";
export type * from "./types.js";
export { cookieStorage, cookieToInitialState } from "./utils/cookies.js";
Loading

0 comments on commit 6c41e22

Please sign in to comment.