Socket
Socket
Sign inDemoInstall

@alchemy/aa-accounts

Package Overview
Dependencies
Maintainers
2
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alchemy/aa-accounts - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

8

dist/cjs/light-account/account.js

@@ -26,5 +26,5 @@ "use strict";

]));
const version = implAddress === "0x0"
? factoryToVersion.get(this.factoryAddress)
: implToVersion.get(implAddress);
const version = (0, viem_1.fromHex)(implAddress, "bigint") === 0n
? factoryToVersion.get(this.factoryAddress.toLowerCase())
: implToVersion.get(implAddress.toLowerCase());
if (!version) {

@@ -166,3 +166,3 @@ throw new Error("Could not determine LightAccount version");

async getAccountInitCode() {
const index = utils_js_1.LightAccountUnsupported1271Factories.has(this.factoryAddress)
const index = utils_js_1.LightAccountUnsupported1271Factories.has(this.factoryAddress.toLowerCase())
? 0n

@@ -169,0 +169,0 @@ : this.index;

@@ -15,2 +15,21 @@ "use strict";

const undeployedOwner = aa_core_1.LocalAccountSigner.mnemonicToAccountSigner(constants_js_1.UNDEPLOYED_OWNER_MNEMONIC);
it.each([
{ version: "v1.0.1", expected: true },
{ version: "v1.0.2", throws: true },
{ version: "v1.1.0", expected: true },
])("LA version $version should correctly verify 1271 signatures", async ({ version, expected, throws }) => {
const provider = givenConnectedProvider({ owner, chain, version });
const message = "test";
if (!throws) {
const signature = await provider.signMessage(message);
expect(await provider.rpcClient.verifyMessage({
address: await provider.getAddress(),
message,
signature,
})).toBe(expected);
}
else {
await expect(provider.signMessage(message)).rejects.toThrowError();
}
});
it("should successfully get counterfactual address", async () => {

@@ -128,3 +147,3 @@ const provider = givenConnectedProvider({ owner, chain });

});
const givenConnectedProvider = ({ owner, chain, accountAddress, feeOptions, }) => {
const givenConnectedProvider = ({ owner, chain, accountAddress, feeOptions, version = "v1.1.0", }) => {
const provider = (0, index_js_1.createLightAccountProvider)({

@@ -139,2 +158,3 @@ rpcProvider: `${chain.rpcUrls.alchemy.http[0]}/${constants_js_1.API_KEY}`,

},
version,
});

@@ -141,0 +161,0 @@ return provider;

@@ -22,3 +22,3 @@ "use strict";

factoryAddress: config.factoryAddress ??
(0, utils_js_1.getDefaultLightAccountFactoryAddress)(config.chain),
(0, utils_js_1.getDefaultLightAccountFactoryAddress)(config.chain, config.version),
accountAddress: config.accountAddress,

@@ -25,0 +25,0 @@ }));

import { z } from "zod";
import { type LightAccountVersion } from "./utils.js";
export declare const LightAccountFactoryConfigSchema: z.ZodObject<{

@@ -7,2 +8,3 @@ owner: z.ZodType<import("@alchemy/aa-core").SmartAccountSigner<any>, z.ZodTypeDef, import("@alchemy/aa-core").SmartAccountSigner<any>>;

factoryAddress: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
version: z.ZodOptional<z.ZodEffects<z.ZodString, LightAccountVersion, string>>;
}, "strip", z.ZodTypeAny, {

@@ -13,2 +15,3 @@ owner: import("@alchemy/aa-core").SmartAccountSigner<any>;

factoryAddress?: `0x${string}` | undefined;
version?: LightAccountVersion | undefined;
}, {

@@ -19,2 +22,3 @@ owner: import("@alchemy/aa-core").SmartAccountSigner<any>;

factoryAddress?: string | undefined;
version?: string | undefined;
}>;

@@ -212,3 +216,3 @@ export declare const LightAccountProviderConfigSchema: z.ZodIntersection<z.ZodObject<{

}, "strip", z.ZodTypeAny, {
chain: import("viem/_types/types/chain").ChainConstants & import("viem/_types/types/chain").ChainConfig<import("viem").ChainFormatters | undefined>;
chain: import("viem/_types/types/chain.js").ChainConstants & import("viem/_types/types/chain.js").ChainConfig<import("viem").ChainFormatters | undefined>;
rpcProvider: (string | import("@alchemy/aa-core").PublicErc4337Client<import("viem").Transport>) & (string | import("@alchemy/aa-core").PublicErc4337Client<import("viem").Transport> | undefined);

@@ -249,3 +253,3 @@ opts: {

}, {
chain: import("viem/_types/types/chain").ChainConstants & import("viem/_types/types/chain").ChainConfig<import("viem").ChainFormatters | undefined>;
chain: import("viem/_types/types/chain.js").ChainConstants & import("viem/_types/types/chain.js").ChainConfig<import("viem").ChainFormatters | undefined>;
rpcProvider: (string | import("@alchemy/aa-core").PublicErc4337Client<import("viem").Transport>) & (string | import("@alchemy/aa-core").PublicErc4337Client<import("viem").Transport> | undefined);

@@ -290,2 +294,3 @@ entryPointAddress?: string | undefined;

factoryAddress: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
version: z.ZodOptional<z.ZodEffects<z.ZodString, LightAccountVersion, string>>;
}, "strip", z.ZodTypeAny, {

@@ -296,2 +301,3 @@ owner: import("@alchemy/aa-core").SmartAccountSigner<any>;

factoryAddress?: `0x${string}` | undefined;
version?: LightAccountVersion | undefined;
}, {

@@ -302,2 +308,3 @@ owner: import("@alchemy/aa-core").SmartAccountSigner<any>;

factoryAddress?: string | undefined;
version?: string | undefined;
}>>;

@@ -8,2 +8,9 @@ "use strict";

const zod_2 = require("zod");
const utils_js_1 = require("./utils.js");
const isLightAccountVersion = (x) => {
if (typeof x === "string" && x in utils_js_1.LightAccountVersions) {
return true;
}
return false;
};
exports.LightAccountFactoryConfigSchema = zod_2.z.object({

@@ -18,4 +25,8 @@ owner: aa_core_1.SignerSchema,

factoryAddress: zod_1.Address.optional().describe("Optional override for the factory address which deploys the smart account."),
version: zod_2.z
.string()
.refine(isLightAccountVersion, "Version must be a valid Light Account version.")
.optional(),
});
exports.LightAccountProviderConfigSchema = (0, aa_core_1.createSmartAccountProviderConfigSchema)().and(exports.LightAccountFactoryConfigSchema);
//# sourceMappingURL=schema.js.map

@@ -7,12 +7,12 @@ "use strict";

"v1.0.1": {
factoryAddress: "0x000000893A26168158fbeaDD9335Be5bC96592E2",
implAddress: "0xc1b2fc4197c9187853243e6e4eb5a4af8879a1c0",
factoryAddress: "0x000000893A26168158fbeaDD9335Be5bC96592E2".toLowerCase(),
implAddress: "0xc1b2fc4197c9187853243e6e4eb5a4af8879a1c0".toLowerCase(),
},
"v1.0.2": {
factoryAddress: "0x00000055C0b4fA41dde26A74435ff03692292FBD",
implAddress: "0x5467b1947F47d0646704EB801E075e72aeAe8113",
factoryAddress: "0x00000055C0b4fA41dde26A74435ff03692292FBD".toLowerCase(),
implAddress: "0x5467b1947F47d0646704EB801E075e72aeAe8113".toLowerCase(),
},
"v1.1.0": {
factoryAddress: "0x00004EC70002a32400f8ae005A26081065620D20",
implAddress: "0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba",
factoryAddress: "0x00004EC70002a32400f8ae005A26081065620D20".toLowerCase(),
implAddress: "0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba".toLowerCase(),
},

@@ -19,0 +19,0 @@ };

@@ -23,5 +23,5 @@ import { SimpleSmartContractAccount, } from "@alchemy/aa-core";

]));
const version = implAddress === "0x0"
? factoryToVersion.get(this.factoryAddress)
: implToVersion.get(implAddress);
const version = fromHex(implAddress, "bigint") === 0n
? factoryToVersion.get(this.factoryAddress.toLowerCase())
: implToVersion.get(implAddress.toLowerCase());
if (!version) {

@@ -163,3 +163,3 @@ throw new Error("Could not determine LightAccount version");

async getAccountInitCode() {
const index = LightAccountUnsupported1271Factories.has(this.factoryAddress)
const index = LightAccountUnsupported1271Factories.has(this.factoryAddress.toLowerCase())
? 0n

@@ -166,0 +166,0 @@ : this.index;

@@ -13,2 +13,21 @@ import { LocalAccountSigner, Logger, LogLevel, } from "@alchemy/aa-core";

const undeployedOwner = LocalAccountSigner.mnemonicToAccountSigner(UNDEPLOYED_OWNER_MNEMONIC);
it.each([
{ version: "v1.0.1", expected: true },
{ version: "v1.0.2", throws: true },
{ version: "v1.1.0", expected: true },
])("LA version $version should correctly verify 1271 signatures", async ({ version, expected, throws }) => {
const provider = givenConnectedProvider({ owner, chain, version });
const message = "test";
if (!throws) {
const signature = await provider.signMessage(message);
expect(await provider.rpcClient.verifyMessage({
address: await provider.getAddress(),
message,
signature,
})).toBe(expected);
}
else {
await expect(provider.signMessage(message)).rejects.toThrowError();
}
});
it("should successfully get counterfactual address", async () => {

@@ -126,3 +145,3 @@ const provider = givenConnectedProvider({ owner, chain });

});
const givenConnectedProvider = ({ owner, chain, accountAddress, feeOptions, }) => {
const givenConnectedProvider = ({ owner, chain, accountAddress, feeOptions, version = "v1.1.0", }) => {
const provider = createLightAccountProvider({

@@ -137,2 +156,3 @@ rpcProvider: `${chain.rpcUrls.alchemy.http[0]}/${API_KEY}`,

},
version,
});

@@ -139,0 +159,0 @@ return provider;

@@ -19,3 +19,3 @@ import { SmartAccountProvider } from "@alchemy/aa-core";

factoryAddress: config.factoryAddress ??
getDefaultLightAccountFactoryAddress(config.chain),
getDefaultLightAccountFactoryAddress(config.chain, config.version),
accountAddress: config.accountAddress,

@@ -22,0 +22,0 @@ }));

import { z } from "zod";
import { type LightAccountVersion } from "./utils.js";
export declare const LightAccountFactoryConfigSchema: z.ZodObject<{

@@ -7,2 +8,3 @@ owner: z.ZodType<import("@alchemy/aa-core").SmartAccountSigner<any>, z.ZodTypeDef, import("@alchemy/aa-core").SmartAccountSigner<any>>;

factoryAddress: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
version: z.ZodOptional<z.ZodEffects<z.ZodString, LightAccountVersion, string>>;
}, "strip", z.ZodTypeAny, {

@@ -13,2 +15,3 @@ owner: import("@alchemy/aa-core").SmartAccountSigner<any>;

factoryAddress?: `0x${string}` | undefined;
version?: LightAccountVersion | undefined;
}, {

@@ -19,2 +22,3 @@ owner: import("@alchemy/aa-core").SmartAccountSigner<any>;

factoryAddress?: string | undefined;
version?: string | undefined;
}>;

@@ -212,3 +216,3 @@ export declare const LightAccountProviderConfigSchema: z.ZodIntersection<z.ZodObject<{

}, "strip", z.ZodTypeAny, {
chain: import("viem/_types/types/chain").ChainConstants & import("viem/_types/types/chain").ChainConfig<import("viem").ChainFormatters | undefined>;
chain: import("viem/_types/types/chain.js").ChainConstants & import("viem/_types/types/chain.js").ChainConfig<import("viem").ChainFormatters | undefined>;
rpcProvider: (string | import("@alchemy/aa-core").PublicErc4337Client<import("viem").Transport>) & (string | import("@alchemy/aa-core").PublicErc4337Client<import("viem").Transport> | undefined);

@@ -249,3 +253,3 @@ opts: {

}, {
chain: import("viem/_types/types/chain").ChainConstants & import("viem/_types/types/chain").ChainConfig<import("viem").ChainFormatters | undefined>;
chain: import("viem/_types/types/chain.js").ChainConstants & import("viem/_types/types/chain.js").ChainConfig<import("viem").ChainFormatters | undefined>;
rpcProvider: (string | import("@alchemy/aa-core").PublicErc4337Client<import("viem").Transport>) & (string | import("@alchemy/aa-core").PublicErc4337Client<import("viem").Transport> | undefined);

@@ -290,2 +294,3 @@ entryPointAddress?: string | undefined;

factoryAddress: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
version: z.ZodOptional<z.ZodEffects<z.ZodString, LightAccountVersion, string>>;
}, "strip", z.ZodTypeAny, {

@@ -296,2 +301,3 @@ owner: import("@alchemy/aa-core").SmartAccountSigner<any>;

factoryAddress?: `0x${string}` | undefined;
version?: LightAccountVersion | undefined;
}, {

@@ -302,2 +308,3 @@ owner: import("@alchemy/aa-core").SmartAccountSigner<any>;

factoryAddress?: string | undefined;
version?: string | undefined;
}>>;

@@ -5,2 +5,9 @@ import { SignerSchema, createSmartAccountProviderConfigSchema, } from "@alchemy/aa-core";

import { z } from "zod";
import { LightAccountVersions } from "./utils.js";
const isLightAccountVersion = (x) => {
if (typeof x === "string" && x in LightAccountVersions) {
return true;
}
return false;
};
export const LightAccountFactoryConfigSchema = z.object({

@@ -15,4 +22,8 @@ owner: SignerSchema,

factoryAddress: Address.optional().describe("Optional override for the factory address which deploys the smart account."),
version: z
.string()
.refine(isLightAccountVersion, "Version must be a valid Light Account version.")
.optional(),
});
export const LightAccountProviderConfigSchema = createSmartAccountProviderConfigSchema().and(LightAccountFactoryConfigSchema);
//# sourceMappingURL=schema.js.map
import { arbitrum, arbitrumGoerli, arbitrumSepolia, base, baseGoerli, baseSepolia, goerli, mainnet, optimism, optimismGoerli, optimismSepolia, polygon, polygonMumbai, sepolia, } from "viem/chains";
export const LightAccountVersions = {
"v1.0.1": {
factoryAddress: "0x000000893A26168158fbeaDD9335Be5bC96592E2",
implAddress: "0xc1b2fc4197c9187853243e6e4eb5a4af8879a1c0",
factoryAddress: "0x000000893A26168158fbeaDD9335Be5bC96592E2".toLowerCase(),
implAddress: "0xc1b2fc4197c9187853243e6e4eb5a4af8879a1c0".toLowerCase(),
},
"v1.0.2": {
factoryAddress: "0x00000055C0b4fA41dde26A74435ff03692292FBD",
implAddress: "0x5467b1947F47d0646704EB801E075e72aeAe8113",
factoryAddress: "0x00000055C0b4fA41dde26A74435ff03692292FBD".toLowerCase(),
implAddress: "0x5467b1947F47d0646704EB801E075e72aeAe8113".toLowerCase(),
},
"v1.1.0": {
factoryAddress: "0x00004EC70002a32400f8ae005A26081065620D20",
implAddress: "0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba",
factoryAddress: "0x00004EC70002a32400f8ae005A26081065620D20".toLowerCase(),
implAddress: "0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba".toLowerCase(),
},

@@ -15,0 +15,0 @@ };

import { z } from "zod";
import { type LightAccountVersion } from "./utils.js";
export declare const LightAccountFactoryConfigSchema: z.ZodObject<{

@@ -7,2 +8,3 @@ owner: z.ZodType<import("@alchemy/aa-core").SmartAccountSigner<any>, z.ZodTypeDef, import("@alchemy/aa-core").SmartAccountSigner<any>>;

factoryAddress: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
version: z.ZodOptional<z.ZodEffects<z.ZodString, LightAccountVersion, string>>;
}, "strip", z.ZodTypeAny, {

@@ -13,2 +15,3 @@ owner: import("@alchemy/aa-core").SmartAccountSigner<any>;

factoryAddress?: `0x${string}` | undefined;
version?: LightAccountVersion | undefined;
}, {

@@ -19,2 +22,3 @@ owner: import("@alchemy/aa-core").SmartAccountSigner<any>;

factoryAddress?: string | undefined;
version?: string | undefined;
}>;

@@ -212,3 +216,3 @@ export declare const LightAccountProviderConfigSchema: z.ZodIntersection<z.ZodObject<{

}, "strip", z.ZodTypeAny, {
chain: import("viem/_types/types/chain").ChainConstants & import("viem/_types/types/chain").ChainConfig<import("viem").ChainFormatters | undefined>;
chain: import("viem/_types/types/chain.js").ChainConstants & import("viem/_types/types/chain.js").ChainConfig<import("viem").ChainFormatters | undefined>;
rpcProvider: (string | import("@alchemy/aa-core").PublicErc4337Client<import("viem").Transport>) & (string | import("@alchemy/aa-core").PublicErc4337Client<import("viem").Transport> | undefined);

@@ -249,3 +253,3 @@ opts: {

}, {
chain: import("viem/_types/types/chain").ChainConstants & import("viem/_types/types/chain").ChainConfig<import("viem").ChainFormatters | undefined>;
chain: import("viem/_types/types/chain.js").ChainConstants & import("viem/_types/types/chain.js").ChainConfig<import("viem").ChainFormatters | undefined>;
rpcProvider: (string | import("@alchemy/aa-core").PublicErc4337Client<import("viem").Transport>) & (string | import("@alchemy/aa-core").PublicErc4337Client<import("viem").Transport> | undefined);

@@ -290,2 +294,3 @@ entryPointAddress?: string | undefined;

factoryAddress: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
version: z.ZodOptional<z.ZodEffects<z.ZodString, LightAccountVersion, string>>;
}, "strip", z.ZodTypeAny, {

@@ -296,2 +301,3 @@ owner: import("@alchemy/aa-core").SmartAccountSigner<any>;

factoryAddress?: `0x${string}` | undefined;
version?: LightAccountVersion | undefined;
}, {

@@ -302,3 +308,4 @@ owner: import("@alchemy/aa-core").SmartAccountSigner<any>;

factoryAddress?: string | undefined;
version?: string | undefined;
}>>;
//# sourceMappingURL=schema.d.ts.map
{
"name": "@alchemy/aa-accounts",
"version": "2.0.0",
"version": "2.0.1",
"description": "A collection of ERC-4337 compliant smart contract account interfaces",

@@ -64,3 +64,3 @@ "author": "Alchemy",

"homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
"gitHead": "529e1be58d4a5ef3a81cd4127152c1192d0af3cf",
"gitHead": "6ecde1b7b163eb54e5b70eababa710aab29bd55d",
"dependencies": {

@@ -67,0 +67,0 @@ "@alchemy/aa-core": "^2.0.0",

@@ -93,5 +93,5 @@ import {

const version =
implAddress === "0x0"
? factoryToVersion.get(this.factoryAddress)
: implToVersion.get(implAddress);
fromHex(implAddress, "bigint") === 0n
? factoryToVersion.get(this.factoryAddress.toLowerCase() as Address)
: implToVersion.get(implAddress.toLowerCase() as Address);

@@ -257,3 +257,5 @@ if (!version) {

protected override async getAccountInitCode(): Promise<`0x${string}`> {
const index = LightAccountUnsupported1271Factories.has(this.factoryAddress)
const index = LightAccountUnsupported1271Factories.has(
this.factoryAddress.toLowerCase() as Address
)
? 0n

@@ -260,0 +262,0 @@ : this.index;

@@ -27,3 +27,3 @@ import { SmartAccountProvider } from "@alchemy/aa-core";

config.factoryAddress ??
getDefaultLightAccountFactoryAddress(config.chain),
getDefaultLightAccountFactoryAddress(config.chain, config.version),
accountAddress: config.accountAddress,

@@ -30,0 +30,0 @@ })

@@ -8,3 +8,12 @@ import {

import { z } from "zod";
import { LightAccountVersions, type LightAccountVersion } from "./utils.js";
const isLightAccountVersion = (x: unknown): x is LightAccountVersion => {
if (typeof x === "string" && x in LightAccountVersions) {
return true;
}
return false;
};
export const LightAccountFactoryConfigSchema = z.object({

@@ -23,2 +32,9 @@ owner: SignerSchema,

),
version: z
.string()
.refine<LightAccountVersion>(
isLightAccountVersion,
"Version must be a valid Light Account version."
)
.optional(),
});

@@ -25,0 +41,0 @@

@@ -34,12 +34,18 @@ import type { Address, Chain } from "viem";

"v1.0.1": {
factoryAddress: "0x000000893A26168158fbeaDD9335Be5bC96592E2",
implAddress: "0xc1b2fc4197c9187853243e6e4eb5a4af8879a1c0",
factoryAddress:
"0x000000893A26168158fbeaDD9335Be5bC96592E2".toLowerCase() as Address,
implAddress:
"0xc1b2fc4197c9187853243e6e4eb5a4af8879a1c0".toLowerCase() as Address,
},
"v1.0.2": {
factoryAddress: "0x00000055C0b4fA41dde26A74435ff03692292FBD",
implAddress: "0x5467b1947F47d0646704EB801E075e72aeAe8113",
factoryAddress:
"0x00000055C0b4fA41dde26A74435ff03692292FBD".toLowerCase() as Address,
implAddress:
"0x5467b1947F47d0646704EB801E075e72aeAe8113".toLowerCase() as Address,
},
"v1.1.0": {
factoryAddress: "0x00004EC70002a32400f8ae005A26081065620D20",
implAddress: "0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba",
factoryAddress:
"0x00004EC70002a32400f8ae005A26081065620D20".toLowerCase() as Address,
implAddress:
"0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba".toLowerCase() as Address,
},

@@ -46,0 +52,0 @@ };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc