UNPKG

@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

54 lines 1.84 kB
import { getAddress, } from "viem"; import { InvalidSignerTypeError } from "../errors/signer.js"; export class WalletClientSigner { constructor(client, signerType) { Object.defineProperty(this, "signerType", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "inner", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "getAddress", { enumerable: true, configurable: true, writable: true, value: async () => { let addresses = await this.inner.getAddresses(); return getAddress(addresses[0]); } }); Object.defineProperty(this, "signMessage", { enumerable: true, configurable: true, writable: true, value: async (message) => { const account = this.inner.account ?? (await this.getAddress()); return this.inner.signMessage({ message, account }); } }); Object.defineProperty(this, "signTypedData", { enumerable: true, configurable: true, writable: true, value: async (typedData) => { const account = this.inner.account ?? (await this.getAddress()); return this.inner.signTypedData({ account, ...typedData, }); } }); this.inner = client; if (!signerType) { throw new InvalidSignerTypeError(signerType); } this.signerType = signerType; } } //# sourceMappingURL=wallet-client.js.map