alchemyplatform / aa-sdk

https://www.alchemy.com/account-abstraction
MIT License
234 stars 125 forks source link

FR: Dont wrap wagmi viem, integrate underneath like @coinbase/onchain-kit #1142

Open polus-arcticus opened 1 week ago

polus-arcticus commented 1 week ago

Integrating this package into an existing react app is quite burdensome, as now i have to import the exact same function names but with alchemy's sdk, it'd be far nicer if there i didnt have to make a separate config and stick if statements in every compontent if alchemy or if not.

thanks!

moldy530 commented 1 week ago

Can you explain a bit more? What are some expected APIs you'd expect here?

polus-arcticus commented 1 week ago

Hi @moldy530 thanks for taking a look at this issue, sure thing.

Let one consider an existing dapp who built upon the viem/wagmi stack.
https://accountkit.alchemy.com/react/quickstart#existing-project under https://accountkit.alchemy.com/react/quickstart#3b-customize-authentication-methods

one finds

import { createConfig, cookieStorage } from "@account-kit/react";

in fact one realizes that the aa-sdk mirrors nearly 1-to-1 with the wagmi api

https://wagmi.sh/react/getting-started#create-config

import { http, createConfig } from 'wagmi'

It is not immediately apparent, or desirable for code liability to change all wagmi imports to aa-sdk imports.

Now one finds they have to duplicate all methods, such as

https://wagmi.sh/react/api/hooks/useAccount https://accountkit.alchemy.com/reference/account-kit/react/hooks/useAccount

import { useAccount } from 'wagmi'
import { useAccount as useAlchemyAAAcount} from '@account-kit/react'
function App() {
 const acount = useAccount()
 const alchemyAccount = useAlchemyAAAcount()
}

and than write a bunch of conditional logic based on how the user injected thier web3 with the dapp

now, what one finds that, with the coinbase onchain kit https://onchainkit.xyz/installation/vite

that they dont wrap around wagmi, but integrate within it. This is much more desirable for maintainability and future compatibility