diff --git a/contracts/test/abi.js b/contracts/test/abi.js deleted file mode 100644 index 5781d68..0000000 --- a/contracts/test/abi.js +++ /dev/null @@ -1,22 +0,0 @@ -export const abi = [ - { - inputs: [{ internalType: 'address', name: 'account', type: 'address' }], - name: 'config', - outputs: [ - { internalType: 'uint48', name: 'lastAccess', type: 'uint48' }, - { internalType: 'uint48', name: 'timeout', type: 'uint48' }, - { internalType: 'address', name: 'nominee', type: 'address' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { internalType: 'address', name: 'smartAccount', type: 'address' }, - ], - name: 'isInitialized', - outputs: [{ internalType: 'bool', name: '', type: 'bool' }], - stateMutability: 'view', - type: 'function', - }, -] diff --git a/contracts/test/add-module-to-account.js b/contracts/test/add-module-to-account.js deleted file mode 100644 index ec43284..0000000 --- a/contracts/test/add-module-to-account.js +++ /dev/null @@ -1,46 +0,0 @@ -import { generatePrivateKey, privateKeyToAccount } from "viem/accounts"; -import { abi } from "./abi"; -import { createSmartWallet } from "./create-smart-account"; - -const beneficiaryPK = generatePrivateKey(); - -const timeout = 123123123; -const beneficiary = privateKeyToAccount(beneficiaryPK); - -async function installModule({smartClient, beneficiaryAddress, timeout, moduleType, hook, account, bundlerClient, moduleAddress, publicClient}) { - const module = { - module: moduleAddress, - initData: '0x', - deInitData: '0x', - additionalContext: '0x', - type: moduleType, - hook, - } - - - const opHash = await smartClient.installModule({ - type: module.type, - address: module.module, - context: module.initData, - }); - - const receipt = await bundlerClient.waitForUserOperationReceipt({ hash: opHash }) -} - -const { smartAccountClient, safeAccount, pimlicoBundlerClient, publicClient } = await createSmartWallet({ - privateKey: "", - bundlerUrl: "https://api.pimlico.io/v2/sepolia/rpc?apikey=" -}) - -installModule({ - smartClient: smartAccountClient, - beneficiaryAddress: beneficiary.address, - timeout, - moduleType: "executor", - hook: '0x', - account: safeAccount, - bundlerClient: pimlicoBundlerClient, - moduleAddress: "0xbDa1dE70eAE1A18BbfdCaE95B42b5Ff6d3352492", - publicClient -}); - diff --git a/contracts/test/backup-abi.js b/contracts/test/backup-abi.js deleted file mode 100644 index 7caca8f..0000000 --- a/contracts/test/backup-abi.js +++ /dev/null @@ -1,26 +0,0 @@ -export const generateBackupAbiWithArgs = ({name, unlockAt, beneficiaries}) => ({ - abi: [ - { - name: "updateBackup", - type: "function", - stateMutability: "nonpayable", - inputs: [ - { internalType: 'string', name: 'name', type: 'string' }, - { internalType: 'uint48', name: 'unlockAt', type: 'uint48' }, - { - internalType: 'struct Wingman.Beneficiary[]', - name: 'beneficiaries', - type: 'tuple[]', - components: [ - { internalType: 'address', name: 'account', type: 'address' }, - { internalType: 'uint8', name: 'percentage', type: 'uint8' }, - { internalType: 'uint256', name: 'amount', type: 'uint256' } - ] - } - ], - outputs: [] - } - ], - functionName: "updateBackup", - args: [name, unlockAt, beneficiaries] -}) diff --git a/contracts/test/create-backup.js b/contracts/test/create-backup.js deleted file mode 100644 index c28a452..0000000 --- a/contracts/test/create-backup.js +++ /dev/null @@ -1,72 +0,0 @@ -import {parseAccount, sendUserOperation} from "permissionless"; -import {generateBackupAbiWithArgs} from "./backup-abi"; -import {createSmartWallet} from "./create-smart-account"; - -async function updateBackup({ - smartClient, - accountAddress, - moduleAddress, - name, - unlockAt, - beneficiaries, - bundlerClient -}) { - const account = parseAccount(accountAddress); - - const updateBackupCallData = account.encodeFunctionData( - generateBackupAbiWithArgs({name, unlockAt, beneficiaries}) - ); - - const opHash = await smartClient.sendUserOperation({ - sender: account.address, - updateBackupCallData, - to: moduleAddress - }); - - const receipt = await bundlerClient.waitForUserOperationReceipt({ hash: opHash }); - return receipt; -} - -async function main({ - name, - unlockAt, - beneficiaries -}) { - const { - smartAccountClient, - safeAccount, - pimlicoBundlerClient - } = createSmartWallet({ - privateKey: "", - bundlerUrl: "", - }); - - await updateBackup({ - smartClient: smartAccountClient, - accountAddress: safeAccount.address, - moduleAddress: "0xab614e4a5398bb2a2a0bf73f9c913ec7ff47d81f", - name, - unlockAt, - beneficiaries, - bundlerClient: pimlicoBundlerClient - }); - - console.log("Backup updated successfully!"); -} - -main({ - name: "name", - unlockAt: 1231231233, - beneficiaries: [ - { - account: "0xAddress1", - percentage: 50, - amount: BigInt(1000) - }, - { - account: "0xAddress2", - percentage: 50, - amount: BigInt(1000) - } - ] -}) diff --git a/contracts/test/create-smart-account.js b/contracts/test/create-smart-account.js deleted file mode 100644 index 3538ecc..0000000 --- a/contracts/test/create-smart-account.js +++ /dev/null @@ -1,59 +0,0 @@ -import { - ENTRYPOINT_ADDRESS_V07, - createSmartAccountClient, -} from "permissionless"; -import { signerToSafeSmartAccount } from "permissionless/accounts"; -import { createPimlicoBundlerClient, createPimlicoPaymasterClient } from "permissionless/clients/pimlico"; -import { createPublicClient, http } from "viem"; -import { sepolia } from "viem/chains"; -import { privateKeyToAccount } from "viem/accounts"; -import { erc7579Actions } from "permissionless/actions/erc7579.js"; -import { pimlicoPaymasterActions } from "permissionless/actions/pimlico"; - - -export async function createSmartWallet({privateKey, bundlerUrl}) { - const signer = privateKeyToAccount(privateKey); - - - const publicClient = createPublicClient({ - transport: http("https://rpc.ankr.com/eth_sepolia"), - }); - - const paymasterClient = createPimlicoPaymasterClient({ - transport: http(bundlerUrl), - entryPoint: ENTRYPOINT_ADDRESS_V07, - }); - - const pimlicoBundlerClient = createPimlicoBundlerClient({ - transport: http(bundlerUrl), - entryPoint: ENTRYPOINT_ADDRESS_V07, - }); - - const safeAccount = await signerToSafeSmartAccount(publicClient, { - signer, - safeVersion: "1.4.1", - entryPoint: ENTRYPOINT_ADDRESS_V07, - safe4337ModuleAddress: "0x3Fdb5BC686e861480ef99A6E3FaAe03c0b9F32e2", - erc7579LaunchpadAddress: "0xEBe001b3D534B9B6E2500FB78E67a1A137f561CE", - }) - - const smartAccountClient = createSmartAccountClient({ - account: safeAccount, - entryPoint: ENTRYPOINT_ADDRESS_V07, - chain: sepolia, - bundlerTransport: http(bundlerUrl), - middleware: { - sponsorUserOperation: paymasterClient.sponsorUserOperation, - gasPrice: async () => (await pimlicoBundlerClient.getUserOperationGasPrice()).fast - }, - }); - - return { smartAccountClient, safeAccount, pimlicoBundlerClient, publicClient } -} - -const { safeAccount } = await createSmartWallet({ - privateKey: process.env.PK, - bundlerUrl: "https://api.pimlico.io/v2/sepolia/rpc?apikey=" + process.env.PIMLICO_API_KEY, -}); -console.log(safeAccount); -console.log("Safe account address:", safeAccount.address);