Skip to content

Commit

Permalink
chore: upgrade to latest version of viem and wagmi (#941)
Browse files Browse the repository at this point in the history
  • Loading branch information
moldy530 committed Aug 28, 2024
1 parent 5fa07c6 commit 70ecb99
Show file tree
Hide file tree
Showing 30 changed files with 512 additions and 325 deletions.
2 changes: 1 addition & 1 deletion .vitest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"prool": "^0.0.15",
"tar": "^7.4.1",
"typescript-template": "*",
"viem": "2.8.6"
"viem": "2.20.0"
},
"dependencies": {
"@aa-sdk/core": "^4.0.0-alpha.8"
Expand Down
17 changes: 8 additions & 9 deletions aa-sdk/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "viem based SDK that enables interactions with ERC-4337 Smart Accounts. ABIs are based off the definitions generated in @account-abstraction/contracts",
"author": "Alchemy",
"type": "module",
"main": "./dist/cjs/index.js",
"main": "./dist/esm/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts",
"typings": "./dist/types/index.d.ts",
Expand All @@ -23,7 +23,7 @@
".": {
"types": "./dist/types/index.d.ts",
"import": "./dist/esm/index.js",
"default": "./dist/cjs/index.js"
"default": "./dist/esm/index.js"
},
"./package.json": "./package.json"
},
Expand All @@ -32,11 +32,10 @@
"registry": "https://registry.npmjs.org/"
},
"scripts": {
"prebuild": "node --loader ts-node/esm ./inject-version.ts",
"build": "yarn clean && yarn build:cjs && yarn build:esm && yarn build:types",
"build:cjs": "tsc --project tsconfig.build.json --module commonjs --outDir ./dist/cjs --removeComments --verbatimModuleSyntax false && echo > ./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
"build:esm": "tsc --project tsconfig.build.json --module es2020 --outDir ./dist/esm --removeComments && echo > ./dist/esm/package.json '{\"type\":\"module\"}'",
"build:types": "tsc --project tsconfig.build.json --module esnext --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
"prebuild": "npx tsx ./inject-version.ts",
"build": "yarn clean && yarn build:esm && yarn build:types",
"build:esm": "tsc --project tsconfig.build.json --outDir ./dist/esm",
"build:types": "tsc --project tsconfig.build.json --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
"docs:gen": "npx ak-docgen generate --in ./src/index.ts --out ../../site/pages/reference/aa-sdk/core",
"clean": "rm -rf ./dist",
"test": "vitest",
Expand All @@ -53,11 +52,11 @@
"dependencies": {
"abitype": "^0.8.3",
"eventemitter3": "^5.0.1",
"viem": "2.8.6",
"viem": "2.20.0",
"zod": "^3.22.4"
},
"peerDependencies": {
"viem": "2.8.6"
"viem": "2.20.0"
},
"repository": {
"type": "git",
Expand Down
6 changes: 3 additions & 3 deletions aa-sdk/core/src/account/smartContractAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export type SmartContractAccount<
typedDataDefinition: TypedDataDefinition<typedData, primaryType>
) => Promise<Hex>;
encodeUpgradeToAndCall: (params: UpgradeToAndCallParams) => Promise<Hex>;
getNonce(nonceKey?: bigint): Promise<bigint>;
getAccountNonce(nonceKey?: bigint): Promise<bigint>;
getInitCode: () => Promise<Hex>;
isAccountDeployed: () => Promise<boolean>;
getFactoryAddress: () => Promise<Address>;
Expand Down Expand Up @@ -374,7 +374,7 @@ export async function toSmartContractAccount(
if (deploymentState === DeploymentState.DEPLOYED) {
return "0x";
}
const contractCode = await client.getBytecode({
const contractCode = await client.getCode({
address: accountAddress_,
});

Expand Down Expand Up @@ -509,7 +509,7 @@ export async function toSmartContractAccount(
encodeUpgradeToAndCall: encodeUpgradeToAndCall_,
getEntryPoint: () => entryPoint,
isAccountDeployed,
getNonce,
getAccountNonce: getNonce,
signMessageWith6492,
signTypedDataWith6492,
getImplementationAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export async function _initUserOperation<

const signature = account.getDummySignature();

const nonce = account.getNonce(overrides?.nonceKey);
const nonce = account.getAccountNonce(overrides?.nonceKey);

const struct =
entryPoint.version === "0.6.0"
Expand Down
1 change: 0 additions & 1 deletion aa-sdk/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export type { Abi } from "abitype";
export type { Address, HttpTransport } from "viem";
export * as chains from "viem/chains";

export { EntryPointAbi_v6 } from "./abis/EntryPointAbi_v6.js";
export { EntryPointAbi_v7 } from "./abis/EntryPointAbi_v7.js";
Expand Down
15 changes: 7 additions & 8 deletions aa-sdk/ethers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Ethers.js wrapper for @aa-sdk/core",
"author": "Alchemy",
"type": "module",
"main": "./dist/cjs/index.js",
"main": "./dist/esm/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts",
"typings": "./dist/types/index.d.ts",
Expand All @@ -23,7 +23,7 @@
".": {
"types": "./dist/types/index.d.ts",
"import": "./dist/esm/index.js",
"default": "./dist/cjs/index.js"
"default": "./dist/esm/index.js"
},
"./package.json": "./package.json"
},
Expand All @@ -32,10 +32,9 @@
"registry": "https://registry.npmjs.org/"
},
"scripts": {
"build": "yarn clean && yarn build:cjs && yarn build:esm && yarn build:types",
"build:cjs": "tsc --project tsconfig.build.json --module commonjs --outDir ./dist/cjs --removeComments --verbatimModuleSyntax false && echo > ./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
"build:esm": "tsc --project tsconfig.build.json --module es2020 --outDir ./dist/esm --removeComments && echo > ./dist/esm/package.json '{\"type\":\"module\"}'",
"build:types": "tsc --project tsconfig.build.json --module esnext --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
"build": "yarn clean && yarn build:esm && yarn build:types",
"build:esm": "tsc --project tsconfig.build.json --outDir ./dist/esm",
"build:types": "tsc --project tsconfig.build.json --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
"docs:gen": "npx ak-docgen generate --in ./src/index.ts --out ../../site/pages/reference/aa-sdk/ethers",
"clean": "rm -rf ./dist",
"test": "vitest",
Expand All @@ -60,10 +59,10 @@
"@ethersproject/keccak256": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@ethersproject/wallet": "^5.7.0",
"viem": "2.8.6"
"viem": "2.20.0"
},
"peerDependencies": {
"viem": "2.8.6"
"viem": "2.20.0"
},
"repository": {
"type": "git",
Expand Down
22 changes: 11 additions & 11 deletions account-kit/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "MIT",
"private": false,
"type": "module",
"main": "./dist/cjs/index.js",
"main": "./dist/esm/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts",
"typings": "./dist/types/index.d.ts",
Expand All @@ -24,16 +24,15 @@
".": {
"types": "./dist/types/index.d.ts",
"import": "./dist/esm/index.js",
"default": "./dist/cjs/index.js"
"default": "./dist/esm/index.js"
},
"./package.json": "./package.json"
},
"scripts": {
"prebuild": "node --loader ts-node/esm ./inject-version.ts",
"build": "yarn clean && yarn build:cjs && yarn build:esm && yarn build:types",
"build:cjs": "tsc --project tsconfig.build.json --module commonjs --outDir ./dist/cjs --removeComments --verbatimModuleSyntax false && echo > ./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
"build:esm": "tsc --project tsconfig.build.json --module es2020 --outDir ./dist/esm --removeComments && echo > ./dist/esm/package.json '{\"type\":\"module\"}'",
"build:types": "tsc --project tsconfig.build.json --module esnext --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
"prebuild": "npx tsx ./inject-version.ts",
"build": "yarn clean && yarn build:esm && yarn build:types",
"build:esm": "tsc --project tsconfig.build.json --outDir ./dist/esm",
"build:types": "tsc --project tsconfig.build.json --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
"clean": "rm -rf ./dist",
"docs:gen": "npx ak-docgen generate --in ./src/index.ts --out ../../site/pages/reference/account-kit/core",
"test": "vitest --passWithNoTests",
Expand All @@ -49,17 +48,18 @@
"@account-kit/infra": "^4.0.0-alpha.12",
"@account-kit/signer": "^4.0.0-alpha.12",
"@account-kit/smart-contracts": "^4.0.0-alpha.12",
"@wagmi/core": "^2.9.8",
"js-cookie": "^3.0.5",
"viem": "2.8.6",
"wagmi": "2.12.7",
"viem": "2.20.0",
"zod": "^3.22.4",
"zustand": "^4.5.2"
},
"peerDependencies": {
"viem": "2.8.6"
"wagmi": "2.12.7",
"viem": "2.20.0"
},
"resolutions": {
"viem": "2.8.6"
"viem": "2.20.0"
},
"publishConfig": {
"access": "public",
Expand Down
19 changes: 9 additions & 10 deletions account-kit/infra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "MIT",
"private": false,
"type": "module",
"main": "./dist/cjs/index.js",
"main": "./dist/esm/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts",
"typings": "./dist/types/index.d.ts",
Expand All @@ -24,16 +24,15 @@
".": {
"types": "./dist/types/index.d.ts",
"import": "./dist/esm/index.js",
"default": "./dist/cjs/index.js"
"default": "./dist/esm/index.js"
},
"./package.json": "./package.json"
},
"scripts": {
"prebuild": "node --loader ts-node/esm ./inject-version.ts",
"build": "yarn clean && yarn build:cjs && yarn build:esm && yarn build:types",
"build:cjs": "tsc --project tsconfig.build.json --module commonjs --outDir ./dist/cjs --removeComments --verbatimModuleSyntax false && echo > ./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
"build:esm": "tsc --project tsconfig.build.json --module es2020 --outDir ./dist/esm --removeComments && echo > ./dist/esm/package.json '{\"type\":\"module\"}'",
"build:types": "tsc --project tsconfig.build.json --module esnext --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
"prebuild": "npx tsx ./inject-version.ts",
"build": "yarn clean && yarn build:esm && yarn build:types",
"build:esm": "tsc --project tsconfig.build.json --outDir ./dist/esm",
"build:types": "tsc --project tsconfig.build.json --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
"docs:gen": "npx ak-docgen generate --in ./src/index.ts --out ../../site/pages/reference/account-kit/infra",
"clean": "rm -rf ./dist",
"test": "vitest",
Expand All @@ -48,14 +47,14 @@
"dependencies": {
"@aa-sdk/core": "^4.0.0-alpha.12",
"eventemitter3": "^5.0.1",
"viem": "2.8.6",
"viem": "2.20.0",
"zod": "^3.22.4"
},
"peerDependencies": {
"viem": "2.8.6"
"viem": "2.20.0"
},
"resolutions": {
"viem": "2.8.6"
"viem": "2.20.0"
},
"publishConfig": {
"access": "public",
Expand Down
24 changes: 13 additions & 11 deletions account-kit/infra/src/client/decorators/alchemyEnhancedApis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,18 @@ export type AlchemyEnhancedApis = {
* @param {Alchemy} alchemy The Alchemy instance containing the SDK client
* @returns {(client: AlchemySmartAccountClient) => AlchemyEnhancedApis} A client decorator for Alchemy Smart Account clients that adds the enhanced API methods
*/
export const alchemyEnhancedApiActions =
(alchemy: Alchemy) =>
<
TTransport extends Transport = Transport,
TChain extends Chain | undefined = Chain | undefined,
TAccount extends SmartContractAccount | undefined =
| SmartContractAccount
| undefined
>(
client: AlchemySmartAccountClient<TTransport, TChain, TAccount>
): AlchemyEnhancedApis => {
export function alchemyEnhancedApiActions(
alchemy: Alchemy
): <
TTransport extends Transport = Transport,
TChain extends Chain | undefined = Chain | undefined,
TAccount extends SmartContractAccount | undefined =
| SmartContractAccount
| undefined
>(
client: AlchemySmartAccountClient<TTransport, TChain, TAccount>
) => AlchemyEnhancedApis {
return (client) => {
const alchemySdk = AlchemySdkClientSchema.parse(alchemy);

if (client.transport.type === "http") {
Expand Down Expand Up @@ -69,3 +70,4 @@ export const alchemyEnhancedApiActions =
config: alchemySdk.config,
};
};
}
6 changes: 3 additions & 3 deletions account-kit/infra/src/client/isAlchemySmartAccountClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ import type { AlchemySmartAccountClient } from "./smartAccountClient";
* @param {Client<TTransport, TChain, TAccount>} client The client instance to be checked
* @returns {boolean} `true` if the client is an Alchemy Smart Account Client, otherwise `false`
*/
export const isAlchemySmartAccountClient = <
export function isAlchemySmartAccountClient<
TTransport extends Transport = Transport,
TChain extends Chain | undefined = Chain | undefined,
TAccount extends SmartContractAccount | undefined =
| SmartContractAccount
| undefined
>(
client: Client<TTransport, TChain, TAccount>
): client is AlchemySmartAccountClient<TTransport, TChain, TAccount> => {
): client is AlchemySmartAccountClient<TTransport, TChain, TAccount> {
// TODO: the goal of this check is to make sure that the client supports certain RPC methods
// we should probably do this by checking the client's transport and configured URL, since alchemy
// clients have to be RPC clients. this is difficult to do though because the transport might
// point to a proxy url :/
return isSmartAccountClient(client);
};
}
10 changes: 5 additions & 5 deletions account-kit/plugingen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
"plugingen": "./dist/esm/cli.js"
},
"scripts": {
"prebuild": "node --loader ts-node/esm ./inject-version.ts",
"prebuild": "npx tsx ./inject-version.ts",
"build": "yarn clean && yarn build:esm && yarn build:types",
"build:esm": "tsc --project tsconfig.build.json --module es2020 --outDir ./dist/esm --removeComments && echo > ./dist/esm/package.json '{\"type\":\"module\"}'",
"build:types": "tsc --project tsconfig.build.json --module esnext --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
"build:esm": "tsc --project tsconfig.build.json --outDir ./dist/esm",
"build:types": "tsc --project tsconfig.build.json --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
"postbuild": "chmod +x ./dist/esm/cli.js",
"clean": "rm -rf ./dist"
},
Expand Down Expand Up @@ -73,10 +73,10 @@
"pathe": "^1.1.2",
"picocolors": "^1.0.0",
"prettier": "^3.2.5",
"viem": "2.8.6",
"viem": "2.20.0",
"zod": "^3.22.4"
},
"peerDependencies": {
"viem": "2.8.6"
"viem": "2.20.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const GetContractGenPhase: Phase = async (input) => {
address: address || addresses[client.chain.id],
abi: ${pluginConfig.name}Abi,
client: client,
});
}) as GetContractReturnType<typeof ${pluginConfig.name}Abi, PublicClient, Address>;
}`);

return input;
Expand Down
Loading

0 comments on commit 70ecb99

Please sign in to comment.