-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add aa-accounts subpackage (#23)
- Loading branch information
Showing
7 changed files
with
127 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# `@alchemy/aa-accounts` | ||
|
||
This package contains various implementations of the [`BaseSmartContractAccount`](../core/src/account/base.ts) class defined in `aa-core`. This repo is community maintained and we welcome contributions! | ||
|
||
## 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 [README](../../README.md) to get started. | ||
|
||
via `yarn` | ||
|
||
```bash | ||
yarn add @alchemy/aa-accounts | ||
``` | ||
|
||
via `npm` | ||
|
||
```bash | ||
npm i -s @alchemy/aa-accounts | ||
``` | ||
|
||
## Contributing | ||
|
||
If you are looking to add a new account type, please follow the following structure. | ||
|
||
1. Create a new folder in `src` with the name of your account type in `kebab-case` (we're following kebab casing for files throughout the project). | ||
2. Create a new file in the folder you just created called `account.ts` and add your implementation for `BaseSmartContractAccount` | ||
3. If needed, create a sub-folder in your account folder called `abis` and add your abis as `.ts` files. eg: | ||
|
||
```ts | ||
export const MyContractAbi = [] as const; // the as const is important so we can get correct typing from viem | ||
``` | ||
|
||
4. If you need to extend the [`SmartAccountProvider`](../core/src/provider/base.ts) class, add a file called `provider.ts` and add your implementation for `SmartAccountProvider`. | ||
|
||
- Ideally, your `Account` impl should _just_ work with the base provider provided by `aa-core`. | ||
- If not, consider generalizing the use case and updating SmartAccountProvider | ||
|
||
5. Add some tests for your account and provider (if created) by creating a subfolder in your `account/my-account` called `__tests__` and make sure your files end with the `.test.ts` suffix | ||
6. export the classes and types you've defined in `src/index.ts` | ||
7. Open a PR and we'll review it as soon as possible! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
{ | ||
"name": "@alchemy/aa-accounts", | ||
"version": "0.1.0-alpha.2", | ||
"description": "A collection of ERC-4337 compliant smart contract account interfaces", | ||
"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": { | ||
"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", | ||
"test:run": "vitest run" | ||
}, | ||
"devDependencies": { | ||
"@alchemy/aa-core": "^0.1.0-alpha.2", | ||
"typescript": "^5.0.4", | ||
"typescript-template": "*", | ||
"viem": "^0.3.50", | ||
"vitest": "^0.31.0" | ||
}, | ||
"peerDependencies": { | ||
"@alchemy/aa-core": "^0.1.0-alpha.1", | ||
"viem": "^0.3.50" | ||
}, | ||
"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": "b7e4cd3253f6d93032419a9a559ea16d2a4f71d8" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Add you exports here, make sure to export types separately from impls and use the `type` keyword when exporting them | ||
// Don't use wildcard exports, instead use named exports |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "typescript-template/build.json", | ||
"exclude": ["node_modules", "**/*/__tests__", "vitest.config.ts"], | ||
"include": ["src"], | ||
"compilerOptions": { | ||
"sourceMap": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "typescript-template/base.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { defineProject } from "vitest/config"; | ||
|
||
export default defineProject({ | ||
test: { | ||
globals: true, | ||
setupFiles: ["../../.vitest/setupTests.ts"], | ||
name: "accounts", | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters