@alchemy/aa-core
Version:
viem based SDK that enables interactions with ERC-4337 Smart Accounts. ABIs are based off the definitions generated in @account-abstraction/contracts
26 lines (23 loc) • 762 B
text/typescript
import type { Address } from "abitype";
import type { Chain, Client, Transport } from "viem";
import type {
GetAccountParameter,
SmartContractAccount,
} from "../../account/smartContractAccount";
import { AccountNotFoundError } from "../../errors/account.js";
export const getAddress: <
TTransport extends Transport = Transport,
TChain extends Chain | undefined = Chain | undefined,
TAccount extends SmartContractAccount | undefined =
| SmartContractAccount
| undefined
>(
client: Client<TTransport, TChain, TAccount>,
args: GetAccountParameter<TAccount>
) => Address = (client, args) => {
const { account } = args ?? { account: client.account };
if (!account) {
throw new AccountNotFoundError();
}
return account.address;
};