Skip to content

Commit 5574c15

Browse files
feat: erc7579 modular accounts (#5487)
1 parent b2b95a5 commit 5574c15

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+4256
-245
lines changed

.changeset/odd-coats-cheer.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
BETA support for 7579 modular smart accounts
6+
7+
You can now create modular smart wallets using the 7579 preset.
8+
9+
Keep in mind that this is in BETA, and there might be breaking API changes.
10+
11+
```typescript
12+
import { sepolia } from "thirdweb/chains";
13+
import { smartWallet, Config } from "thirdweb/wallets/smart";
14+
const modularSmartWallet = smartWallet(
15+
Config.erc7579({
16+
chain: sepolia,
17+
sponsorGas: true,
18+
factoryAddress: "0x...", // the 7579 factory address
19+
validatorAddress: "0x...", // the default validator module address
20+
}),
21+
});
22+
```
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[
2+
"function accountId() view returns (string accountImplementationId)",
3+
"function execute(bytes32 mode, bytes executionCalldata) payable",
4+
"function executeFromExecutor(bytes32 mode, bytes executionCalldata) payable returns (bytes[] returnData)",
5+
"function installModule(uint256 moduleTypeId, address module, bytes initData) payable",
6+
"function isModuleInstalled(uint256 moduleTypeId, address module, bytes additionalContext) view returns (bool)",
7+
"function isValidSignature(bytes32 hash, bytes data) view returns (bytes4)",
8+
"function supportsExecutionMode(bytes32 encodedMode) view returns (bool)",
9+
"function supportsModule(uint256 moduleTypeId) view returns (bool)",
10+
"function uninstallModule(uint256 moduleTypeId, address module, bytes deInitData) payable",
11+
"event ModuleInstalled(uint256 moduleTypeId, address module)",
12+
"event ModuleUninstalled(uint256 moduleTypeId, address module)"
13+
]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[
2+
"constructor(address _entrypoint, address _owner, address _accountImplementation)",
3+
"function accountImplementation() view returns (address)",
4+
"function addStake(uint32 unstakeDelaySec) payable",
5+
"function createAccountWithModules(address owner, bytes salt, (uint256 moduleTypeId, address module, bytes initData)[] modules) payable returns (address)",
6+
"function entrypoint() view returns (address)",
7+
"function getAddress(address owner, bytes salt) view returns (address account)",
8+
"function implementation() view returns (address result)",
9+
"function owner() view returns (address result)",
10+
"function renounceOwnership()",
11+
"function transferOwnership(address newOwner)",
12+
"function unlockStake()",
13+
"function upgradeTo(address newImplementation)",
14+
"function withdraw(address to, address token, uint256 amount)",
15+
"function withdrawStake(address to)",
16+
"event OwnershipTransferred(address indexed oldOwner, address indexed newOwner)",
17+
"event Upgraded(address indexed implementation)",
18+
"error InitializationFailed()",
19+
"error InvalidModule(address module)",
20+
"error NewImplementationHasNoCode()",
21+
"error NewOwnerIsZeroAddress()",
22+
"error Unauthorized()"
23+
]

packages/thirdweb/scripts/typedoc.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const app = await Application.bootstrapWithPlugins({
88
"src/exports/**/*.ts",
99
"src/extensions/modules/**/index.ts",
1010
"src/adapters/eip1193/index.ts",
11+
"src/wallets/smart/presets/index.ts",
1112
],
1213
exclude: [
1314
"src/exports/*.native.ts",

packages/thirdweb/src/auth/verify-hash.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export async function verifyHash({
153153
}
154154

155155
const EIP_1271_MAGIC_VALUE = "0x1626ba7e";
156-
async function verifyEip1271Signature({
156+
export async function verifyEip1271Signature({
157157
hash,
158158
signature,
159159
contract,

packages/thirdweb/src/auth/verify-signature.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type Signature, recoverAddress } from "viem";
1+
import { type SignableMessage, type Signature, recoverAddress } from "viem";
22
import type { Chain } from "../chains/types.js";
33
import type { ThirdwebClient } from "../client/client.js";
44
import { type Hex, isHex } from "../utils/encoding/hex.js";
@@ -10,7 +10,7 @@ import { verifyHash } from "./verify-hash.js";
1010
* @auth
1111
*/
1212
export type VerifyEOASignatureParams = {
13-
message: string;
13+
message: string | SignableMessage;
1414
signature: string | Uint8Array | Signature;
1515
address: string;
1616
};

packages/thirdweb/src/contract/actions/resolve-abi.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ export function resolveContractAbi<abi extends Abi>(
4141
if (contract.abi) {
4242
return contract.abi as abi;
4343
}
44+
45+
// for local chains, we need to resolve the composite abi from bytecode
46+
if (contract.chain.id === 31337 || contract.chain.id === 1337) {
47+
return await resolveCompositeAbi(contract as ThirdwebContract);
48+
}
49+
4450
// try to get it from the api
4551
try {
4652
return await resolveAbiFromContractApi(contract, contractApiBaseUrl);

packages/thirdweb/src/exports/wallets/smart.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ export type {
3030
PaymasterResult,
3131
} from "../../wallets/smart/types.js";
3232

33+
// all preset configs
34+
export * as Config from "../../wallets/smart/presets/index.js";
35+
3336
export {
3437
ENTRYPOINT_ADDRESS_v0_6,
3538
ENTRYPOINT_ADDRESS_v0_7,

packages/thirdweb/src/extensions/erc7579/__generated__/IERC7579Account/events/ModuleInstalled.ts

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/thirdweb/src/extensions/erc7579/__generated__/IERC7579Account/events/ModuleUninstalled.ts

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/thirdweb/src/extensions/erc7579/__generated__/IERC7579Account/read/accountId.ts

Lines changed: 71 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/thirdweb/src/extensions/erc7579/__generated__/IERC7579Account/read/isModuleInstalled.ts

Lines changed: 153 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)