@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
58 lines • 2 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WalletClientSigner = void 0;
const viem_1 = require("viem");
const signer_js_1 = require("../errors/signer.js");
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 (0, viem_1.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 signer_js_1.InvalidSignerTypeError(signerType);
}
this.signerType = signerType;
}
}
exports.WalletClientSigner = WalletClientSigner;
//# sourceMappingURL=wallet-client.js.map