Skip to content

Commit

Permalink
feat: erc7579 modular accounts (#5487)
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquim-verges authored Dec 6, 2024
1 parent b2b95a5 commit 5574c15
Show file tree
Hide file tree
Showing 51 changed files with 4,256 additions and 245 deletions.
22 changes: 22 additions & 0 deletions .changeset/odd-coats-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
"thirdweb": patch
---

BETA support for 7579 modular smart accounts

You can now create modular smart wallets using the 7579 preset.

Keep in mind that this is in BETA, and there might be breaking API changes.

```typescript
import { sepolia } from "thirdweb/chains";
import { smartWallet, Config } from "thirdweb/wallets/smart";
const modularSmartWallet = smartWallet(
Config.erc7579({
chain: sepolia,
sponsorGas: true,
factoryAddress: "0x...", // the 7579 factory address
validatorAddress: "0x...", // the default validator module address
}),
});
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
"function accountId() view returns (string accountImplementationId)",
"function execute(bytes32 mode, bytes executionCalldata) payable",
"function executeFromExecutor(bytes32 mode, bytes executionCalldata) payable returns (bytes[] returnData)",
"function installModule(uint256 moduleTypeId, address module, bytes initData) payable",
"function isModuleInstalled(uint256 moduleTypeId, address module, bytes additionalContext) view returns (bool)",
"function isValidSignature(bytes32 hash, bytes data) view returns (bytes4)",
"function supportsExecutionMode(bytes32 encodedMode) view returns (bool)",
"function supportsModule(uint256 moduleTypeId) view returns (bool)",
"function uninstallModule(uint256 moduleTypeId, address module, bytes deInitData) payable",
"event ModuleInstalled(uint256 moduleTypeId, address module)",
"event ModuleUninstalled(uint256 moduleTypeId, address module)"
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[
"constructor(address _entrypoint, address _owner, address _accountImplementation)",
"function accountImplementation() view returns (address)",
"function addStake(uint32 unstakeDelaySec) payable",
"function createAccountWithModules(address owner, bytes salt, (uint256 moduleTypeId, address module, bytes initData)[] modules) payable returns (address)",
"function entrypoint() view returns (address)",
"function getAddress(address owner, bytes salt) view returns (address account)",
"function implementation() view returns (address result)",
"function owner() view returns (address result)",
"function renounceOwnership()",
"function transferOwnership(address newOwner)",
"function unlockStake()",
"function upgradeTo(address newImplementation)",
"function withdraw(address to, address token, uint256 amount)",
"function withdrawStake(address to)",
"event OwnershipTransferred(address indexed oldOwner, address indexed newOwner)",
"event Upgraded(address indexed implementation)",
"error InitializationFailed()",
"error InvalidModule(address module)",
"error NewImplementationHasNoCode()",
"error NewOwnerIsZeroAddress()",
"error Unauthorized()"
]
1 change: 1 addition & 0 deletions packages/thirdweb/scripts/typedoc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const app = await Application.bootstrapWithPlugins({
"src/exports/**/*.ts",
"src/extensions/modules/**/index.ts",
"src/adapters/eip1193/index.ts",
"src/wallets/smart/presets/index.ts",
],
exclude: [
"src/exports/*.native.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/thirdweb/src/auth/verify-hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export async function verifyHash({
}

const EIP_1271_MAGIC_VALUE = "0x1626ba7e";
async function verifyEip1271Signature({
export async function verifyEip1271Signature({
hash,
signature,
contract,
Expand Down
4 changes: 2 additions & 2 deletions packages/thirdweb/src/auth/verify-signature.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Signature, recoverAddress } from "viem";
import { type SignableMessage, type Signature, recoverAddress } from "viem";
import type { Chain } from "../chains/types.js";
import type { ThirdwebClient } from "../client/client.js";
import { type Hex, isHex } from "../utils/encoding/hex.js";
Expand All @@ -10,7 +10,7 @@ import { verifyHash } from "./verify-hash.js";
* @auth
*/
export type VerifyEOASignatureParams = {
message: string;
message: string | SignableMessage;
signature: string | Uint8Array | Signature;
address: string;
};
Expand Down
6 changes: 6 additions & 0 deletions packages/thirdweb/src/contract/actions/resolve-abi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ export function resolveContractAbi<abi extends Abi>(
if (contract.abi) {
return contract.abi as abi;
}

// for local chains, we need to resolve the composite abi from bytecode
if (contract.chain.id === 31337 || contract.chain.id === 1337) {
return await resolveCompositeAbi(contract as ThirdwebContract);
}

// try to get it from the api
try {
return await resolveAbiFromContractApi(contract, contractApiBaseUrl);
Expand Down
3 changes: 3 additions & 0 deletions packages/thirdweb/src/exports/wallets/smart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export type {
PaymasterResult,
} from "../../wallets/smart/types.js";

// all preset configs
export * as Config from "../../wallets/smart/presets/index.js";

export {
ENTRYPOINT_ADDRESS_v0_6,
ENTRYPOINT_ADDRESS_v0_7,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5574c15

Please sign in to comment.