Skip to content

Commit

Permalink
Merge branch 'alchemyplatform:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
moldy530 authored Feb 13, 2024
2 parents f098fa1 + adae84a commit 9172698
Show file tree
Hide file tree
Showing 144 changed files with 1,982 additions and 586 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [3.0.0-alpha.8](https://github.com/alchemyplatform/aa-sdk/compare/v3.0.0-alpha.7...v3.0.0-alpha.8) (2024-02-11)

### Features

- add alchemy signer to aa-alchemy ([#441](https://github.com/alchemyplatform/aa-sdk/issues/441)) ([d8b17a7](https://github.com/alchemyplatform/aa-sdk/commit/d8b17a7df54b93c5e79c2034afa99e0bb9c6b637))

# [3.0.0-alpha.7](https://github.com/alchemyplatform/aa-sdk/compare/v3.0.0-alpha.6...v3.0.0-alpha.7) (2024-02-10)

**Note:** Version bump only for package root

# [3.0.0-alpha.6](https://github.com/alchemyplatform/aa-sdk/compare/v3.0.0-alpha.5...v3.0.0-alpha.6) (2024-02-08)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

We're excited to have you contribute to the `aa-sdk`. Here's a step-by-step guide to help you get started.

## Getting Started
## Getting started

1. **Fork and Clone**: First, [fork the `aa-sdk` repository](https://github.com/alchemyplatform/aa-sdk/fork). Then, clone your forked repo to your local machine.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The core SDK also implements an EIP-1193 provider interface to easily plug into

The `aa-sdk` is modular at every layer of the stack and can be easily extended to fit your custom needs. You can plug in any [smart account](https://accountkit.alchemy.com/smart-accounts/custom/using-your-own) implementation, [Signer](https://accountkit.alchemy.com/signers/overview), [Gas Manager API](https://accountkit.alchemy.com/getting-started/overview.html#gas-manager-api) and RPC Provider.

## Getting Started
## Getting started

The `aa-sdk` is part of [Account Kit](https://accountkit.alchemy.com). Check out this [quickstart guide](https://accountkit.alchemy.com/getting-started.html) to get started, or an [overview](https://accountkit.alchemy.com/overview/package-overview.html) of each of the SDKs in this repo.

Expand Down
2 changes: 1 addition & 1 deletion examples/alchemy-daapp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ cd aa-sdk/examples/alchemy-daapp
yarn install
```

## Getting Started
## Getting started
1. Update the .env file with your Alchemy API key(s):
```bash
MUMBAI_ALCHEMY_API_URL=https://polygon-mumbai.g.alchemy.com/v2/<YOUR_API_KEY>
Expand Down
4 changes: 2 additions & 2 deletions examples/contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Contracts Used for AA SDK

Built using foundry + Alchemy

- Foundry Getting Started: https://book.getfoundry.sh/getting-started/installation
- Alchemy Getting Started: https://docs.alchemy.com/reference/api-overview
- Foundry Getting started: https://book.getfoundry.sh/getting-started/installation
- Alchemy Getting started: https://docs.alchemy.com/reference/api-overview

## Index

Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "3.0.0-alpha.6",
"version": "3.0.0-alpha.8",
"npmClient": "yarn",
"conventionalCommits": true,
"conventionalPrerelease": true,
Expand Down
4 changes: 4 additions & 0 deletions packages/accounts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [3.0.0-alpha.7](https://github.com/alchemyplatform/aa-sdk/compare/v3.0.0-alpha.6...v3.0.0-alpha.7) (2024-02-10)

**Note:** Version bump only for package @alchemy/aa-accounts

# [3.0.0-alpha.6](https://github.com/alchemyplatform/aa-sdk/compare/v3.0.0-alpha.5...v3.0.0-alpha.6) (2024-02-08)

**Note:** Version bump only for package @alchemy/aa-accounts
Expand Down
2 changes: 1 addition & 1 deletion packages/accounts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This package contains various implementations of the [`BaseSmartContractAccount`

## Getting started

If you are already using the `@alchemy/aa-core` package, you can simply install this package and start using the accounts. If you are not using `@alchemy/aa-core`, you can install it and follow the instructions in the [Getting Started](https://accountkit.alchemy.com/packages/aa-accounts/) docs to get started.
If you are already using the `@alchemy/aa-core` package, you can simply install this package and start using the accounts. If you are not using `@alchemy/aa-core`, you can install it and follow the instructions in the [Getting started](https://accountkit.alchemy.com/packages/aa-accounts/) docs to get started.

via `yarn`

Expand Down
4 changes: 2 additions & 2 deletions packages/accounts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alchemy/aa-accounts",
"version": "3.0.0-alpha.6",
"version": "3.0.0-alpha.7",
"description": "A collection of ERC-4337 compliant smart contract account interfaces",
"author": "Alchemy",
"license": "MIT",
Expand Down Expand Up @@ -75,6 +75,6 @@
"gitHead": "ee46e8bb857de3b631044fa70714ea706d9e317d",
"dependencies": {
"@alchemy/aa-core": "^3.0.0-alpha.5",
"viem": "^2.5.0"
"viem": "^2.7.8"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const ManagementActionsGenPhase: Phase = async (input) => {
contract.name
} address for chain " + chain.name);
}
return installPlugin_(client, {
pluginAddress,
pluginInitData: encodeAbiParameters(${JSON.stringify(
Expand Down
9 changes: 5 additions & 4 deletions packages/accounts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
export type * from "./light-account/account.js";
export { createLightAccount } from "./light-account/account.js";
export { transferOwnership as transferLightAccountOwnership } from "./light-account/actions/transferOwnership.js";
export { createLightAccountClient } from "./light-account/createLightAccountClient.js";
export { getLightAccountVersion } from "./light-account/getLightAccountVersion.js";
export type * from "./light-account/lightAccountClientDecorator.js";
export { lightAccountClientActions } from "./light-account/lightAccountClientDecorator.js";
export { createLightAccountClient } from "./light-account/client.js";
export type * from "./light-account/decorator.js";
export { lightAccountClientActions } from "./light-account/decorator.js";
export {
LightAccountUnsupported1271Factories,
LightAccountUnsupported1271Impls,
LightAccountVersions,
getDefaultLightAccountFactoryAddress,
getLightAccountVersion,
type LightAccountVersion,
} from "./light-account/utils.js";

Expand All @@ -24,6 +24,7 @@ export { transferOwnership as transferNaniAccountOwnership } from "./nani-accoun
export { getDefaultNaniAccountFactoryAddress } from "./nani-account/utils.js";

// msca exports
export { IPluginAbi } from "./msca/abis/IPlugin.js";
export type * from "./msca/account-loupe/decorator.js";
export { accountLoupeActions } from "./msca/account-loupe/decorator.js";
export type * from "./msca/account/multiOwnerAccount.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/accounts/src/light-account/account.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
type SmartAccountSigner,
} from "@alchemy/aa-core";
import { custom, type Chain } from "viem";
import { createLightAccountClient } from "./createLightAccountClient.js";
import { createLightAccountClient } from "./client.js";

const chain = polygonMumbai;

Expand Down
15 changes: 6 additions & 9 deletions packages/accounts/src/light-account/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
FailedToGetStorageSlotError,
createBundlerClient,
getAccountAddress,
getDefaultEntryPointAddress,
getVersion060EntryPoint,
toSmartContractAccount,
type Address,
Expand All @@ -24,11 +23,11 @@ import {
} from "viem";
import { LightAccountAbi } from "./abis/LightAccountAbi.js";
import { LightAccountFactoryAbi } from "./abis/LightAccountFactoryAbi.js";
import { getLightAccountVersion } from "./getLightAccountVersion.js";
import {
LightAccountUnsupported1271Factories,
LightAccountVersions,
getDefaultLightAccountFactoryAddress,
getLightAccountVersion,
type LightAccountVersion,
} from "./utils.js";

Expand All @@ -48,13 +47,11 @@ export type CreateLightAccountParams<
TOwner extends SmartAccountSigner = SmartAccountSigner
> = Pick<
ToSmartContractAccountParams<"LightAccount", TTransport>,
"transport" | "chain"
"transport" | "chain" | "entryPoint" | "accountAddress"
> & {
owner: TOwner;
index?: bigint;
factoryAddress?: Address;
entryPointAddress?: Address;
accountAddress?: Address;
initCode?: Hex;
version?: LightAccountVersion;
};
Expand All @@ -70,10 +67,10 @@ export async function createLightAccount({
transport,
chain,
owner: owner_,
accountAddress,
initCode,
version = "v1.1.0",
entryPointAddress = getDefaultEntryPointAddress(chain),
entryPoint = getVersion060EntryPoint(chain),
accountAddress,
factoryAddress = getDefaultLightAccountFactoryAddress(chain, version),
index: index_ = 0n,
}: CreateLightAccountParams): Promise<LightAccount> {
Expand Down Expand Up @@ -104,7 +101,7 @@ export async function createLightAccount({

const address = await getAccountAddress({
client,
entryPointAddress,
entryPointAddress: entryPoint.address,
accountAddress,
getAccountInitCode,
});
Expand Down Expand Up @@ -170,7 +167,7 @@ export async function createLightAccount({
const account = await toSmartContractAccount({
transport,
chain,
entryPoint: getVersion060EntryPoint(chain, entryPointAddress),
entryPoint,
accountAddress: address,
source: "LightAccount",
getAccountInitCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import {
lightAccountClientActions,
type LightAccountClientActions,
} from "./lightAccountClientDecorator.js";
} from "./decorator.js";

export type CreateLightAccountClientParams<
TTransport extends Transport = Transport,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
type LightAccountVersion,
} from "../../index.js";
import { getMSCAUpgradeToData } from "../../msca/utils.js";
import { createLightAccountClient } from "../createLightAccountClient.js";
import { createLightAccountClient } from "../client.js";
import {
API_KEY,
LIGHT_ACCOUNT_OWNER_MNEMONIC,
Expand Down
35 changes: 0 additions & 35 deletions packages/accounts/src/light-account/getLightAccountVersion.ts

This file was deleted.

35 changes: 34 additions & 1 deletion packages/accounts/src/light-account/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import {
polygon,
polygonMumbai,
sepolia,
type SmartContractAccount,
} from "@alchemy/aa-core";
import type { Address, Chain } from "viem";
import { fromHex, type Address, type Chain } from "viem";

export type LightAccountVersion =
/** @deprecated This version does not support 1271 signature validation */
Expand Down Expand Up @@ -91,3 +92,35 @@ export const LightAccountUnsupported1271Impls = [
export const LightAccountUnsupported1271Factories = new Set(
LightAccountUnsupported1271Impls.map((x) => x.factoryAddress)
);

export const getLightAccountVersion = async <A extends SmartContractAccount>(
account: A
) => {
const implAddress = await account.getImplementationAddress();
const implToVersion = new Map(
Object.entries(LightAccountVersions).map(([key, value]) => [
value.implAddress,
key as LightAccountVersion,
])
);

const factoryToVersion = new Map(
Object.entries(LightAccountVersions).map(([key, value]) => [
value.factoryAddress,
key as LightAccountVersion,
])
);

const version =
fromHex(implAddress, "bigint") === 0n
? factoryToVersion.get(
account.getFactoryAddress().toLowerCase() as Address
)
: implToVersion.get(implAddress.toLowerCase() as Address);

if (!version) {
throw new Error("Could not determine LightAccount version");
}

return version;
};
6 changes: 6 additions & 0 deletions packages/alchemy/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [3.0.0-alpha.8](https://github.com/alchemyplatform/aa-sdk/compare/v3.0.0-alpha.7...v3.0.0-alpha.8) (2024-02-11)

### Features

- add alchemy signer to aa-alchemy ([#441](https://github.com/alchemyplatform/aa-sdk/issues/441)) ([d8b17a7](https://github.com/alchemyplatform/aa-sdk/commit/d8b17a7df54b93c5e79c2034afa99e0bb9c6b637))

# [3.0.0-alpha.6](https://github.com/alchemyplatform/aa-sdk/compare/v3.0.0-alpha.5...v3.0.0-alpha.6) (2024-02-08)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion packages/alchemy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This package contains `AlchemyProvider`, an implementation of `SmartAccountProvi

## Getting started

If you are already using the `@alchemy/aa-core` package, you can simply install this package and start using the `AlchemyProvider`. If you are not using `@alchemy/aa-core`, you can install it and follow the instructions in the ["Getting Started"](https://accountkit.alchemy.com/packages/aa-alchemy/) docs to get started.
If you are already using the `@alchemy/aa-core` package, you can simply install this package and start using the `AlchemyProvider`. If you are not using `@alchemy/aa-core`, you can install it and follow the instructions in the ["Getting started"](https://accountkit.alchemy.com/packages/aa-alchemy/) docs to get started.

```bash [yarn]
yarn add @alchemy/aa-alchemy
Expand Down
8 changes: 6 additions & 2 deletions packages/alchemy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alchemy/aa-alchemy",
"version": "3.0.0-alpha.6",
"version": "3.0.0-alpha.8",
"description": "adapters for @alchemy/aa-core for interacting with alchemy services",
"author": "Alchemy",
"license": "MIT",
Expand Down Expand Up @@ -47,7 +47,11 @@
},
"dependencies": {
"@alchemy/aa-core": "^3.0.0-alpha.5",
"viem": "^2.5.0"
"@turnkey/http": "^2.6.2",
"@turnkey/iframe-stamper": "^1.0.0",
"@turnkey/viem": "^0.4.8",
"@turnkey/webauthn-stamper": "^0.4.3",
"viem": "^2.7.8"
},
"publishConfig": {
"access": "public",
Expand Down
3 changes: 3 additions & 0 deletions packages/alchemy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ export { alchemyUserOperationSimulator } from "./middleware/userOperationSimulat
export type * from "./schema.js";
export { AlchemyProviderConfigSchema } from "./schema.js";
export type { AlchemyProviderConfig } from "./type.js";

export type * from "./signer/index.js";
export { AlchemySigner, AlchemySignerClient } from "./signer/index.js";
Loading

0 comments on commit 9172698

Please sign in to comment.