Skip to content

Commit

Permalink
revert template changes
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Apr 1, 2024
1 parent eb3f978 commit 53cc6ee
Show file tree
Hide file tree
Showing 15 changed files with 40 additions and 320 deletions.
3 changes: 0 additions & 3 deletions templates/react/mprocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,3 @@ procs:
client:
cwd: packages/client
shell: pnpm run dev
alto-bundler:
cwd: packages/account-abstraction
shell: pnpm run dev:alto
2 changes: 0 additions & 2 deletions templates/react/packages/account-abstraction/.gitignore

This file was deleted.

13 changes: 0 additions & 13 deletions templates/react/packages/account-abstraction/alto.config.json

This file was deleted.

17 changes: 0 additions & 17 deletions templates/react/packages/account-abstraction/dist/constants.js

This file was deleted.

This file was deleted.

27 changes: 0 additions & 27 deletions templates/react/packages/account-abstraction/package.json

This file was deleted.

38 changes: 0 additions & 38 deletions templates/react/packages/account-abstraction/src/constants.ts

This file was deleted.

55 changes: 0 additions & 55 deletions templates/react/packages/account-abstraction/src/index.ts

This file was deleted.

16 changes: 0 additions & 16 deletions templates/react/packages/account-abstraction/tsconfig.json

This file was deleted.

1 change: 0 additions & 1 deletion templates/react/packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"@latticexyz/utils": "link:../../../../packages/utils",
"@latticexyz/world": "link:../../../../packages/world",
"contracts": "workspace:*",
"permissionless": "^0.1.10",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rxjs": "7.5.5",
Expand Down
66 changes: 7 additions & 59 deletions templates/react/packages/client/src/mud/setupNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,19 @@ import {
fallback,
webSocket,
http,
createWalletClient,
Hex,
parseEther,
ClientConfig,
getContract,
PublicClient,
} from "viem";
import { ENTRYPOINT_ADDRESS_V07, createSmartAccountClient } from "permissionless";
import { signerToSimpleSmartAccount } from "permissionless/accounts";
import { createPimlicoBundlerClient } from "permissionless/clients/pimlico";
import { createFaucetService } from "@latticexyz/services/faucet";
import { syncToZustand } from "@latticexyz/store-sync/zustand";
import { getNetworkConfig } from "./getNetworkConfig";
import IWorldAbi from "contracts/out/IWorld.sol/IWorld.abi.json";
import { createBurnerAccount, transportObserver, ContractWrite } from "@latticexyz/common";
import { transactionQueue, writeObserver } from "@latticexyz/common/actions";
import { Subject, share } from "rxjs";
import { MOCK_PAYMASTER_ADDRESS } from "../../../account-abstraction/src/constants";

/*
* Import our MUD config, which includes strong types for
Expand All @@ -38,19 +34,6 @@ import mudConfig from "contracts/mud.config";

export type SetupNetworkResult = Awaited<ReturnType<typeof setupNetwork>>;

const waitForEntryPointDeployment = async (client: PublicClient) => {
// eslint-disable-next-line no-constant-condition
while (true) {
const code = client.getBytecode({ address: ENTRYPOINT_ADDRESS_V07 });

if (code !== undefined) {
break;
}

await new Promise((resolve) => setTimeout(resolve, 1000));
}
};

export async function setupNetwork() {
const networkConfig = await getNetworkConfig();

Expand All @@ -66,8 +49,6 @@ export async function setupNetwork() {

const publicClient = createPublicClient(clientOptions);

await waitForEntryPointDeployment(publicClient);

/*
* Create an observable for contract writes that we can
* pass into MUD dev tools for transaction observability.
Expand All @@ -79,44 +60,11 @@ export async function setupNetwork() {
* (see https://viem.sh/docs/clients/wallet.html).
*/
const burnerAccount = createBurnerAccount(networkConfig.privateKey as Hex);

const pimlicoBundlerClient = createPimlicoBundlerClient({
chain: clientOptions.chain,
transport: http("http://127.0.0.1:4337"),
entryPoint: ENTRYPOINT_ADDRESS_V07,
});

const burnerSmartAccount = await signerToSimpleSmartAccount(publicClient, {
entryPoint: ENTRYPOINT_ADDRESS_V07,
factoryAddress: "0x91E60e0613810449d098b0b5Ec8b51A0FE8c8985",
signer: burnerAccount,
});

const burnerSmartAccountClient = createSmartAccountClient({
chain: clientOptions.chain,
bundlerTransport: http("http://127.0.0.1:4337"),
middleware: {
sponsorUserOperation: async ({ userOperation }) => {
const gasEstimates = await pimlicoBundlerClient.estimateUserOperationGas({
userOperation: {
...userOperation,
paymaster: MOCK_PAYMASTER_ADDRESS,
paymasterData: "0x",
},
});

return {
paymasterData: "0x",
paymaster: MOCK_PAYMASTER_ADDRESS,
...gasEstimates,
};
},
gasPrice: async () => (await pimlicoBundlerClient.getUserOperationGasPrice()).fast,
},
entryPoint: ENTRYPOINT_ADDRESS_V07,
account: burnerSmartAccount,
const burnerWalletClient = createWalletClient({
...clientOptions,
account: burnerAccount,
})
.extend(transactionQueue(publicClient))
.extend(transactionQueue())
.extend(writeObserver({ onWrite: (write) => write$.next(write) }));

/*
Expand All @@ -125,7 +73,7 @@ export async function setupNetwork() {
const worldContract = getContract({
address: networkConfig.worldAddress as Hex,
abi: IWorldAbi,
client: { public: publicClient, wallet: burnerSmartAccountClient },
client: { public: publicClient, wallet: burnerWalletClient },
});

/*
Expand Down Expand Up @@ -173,7 +121,7 @@ export async function setupNetwork() {
tables,
useStore,
publicClient,
walletClient: burnerSmartAccountClient,
walletClient: burnerWalletClient,
latestBlock$,
storedBlockLogs$,
waitForTransaction,
Expand Down
66 changes: 32 additions & 34 deletions templates/react/packages/contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
{
"name": "contracts",
"version": "0.0.0",
"private": true,
"license": "MIT",
"scripts": {
"build": "mud build",
"clean": "forge clean && rimraf src/codegen",
"deploy:local": "pnpm run build && mud deploy",
"deploy:testnet": "pnpm run build && mud deploy --profile=lattice-testnet",
"dev": "pnpm mud dev-contracts",
"lint": "pnpm run prettier && pnpm run solhint",
"prettier": "prettier --write 'src/**/*.sol'",
"solhint": "solhint --config ./.solhint.json 'src/**/*.sol' --fix",
"test": "tsc --noEmit && mud test"
},
"dependencies": {
"@latticexyz/cli": "link:../../../../packages/cli",
"@latticexyz/schema-type": "link:../../../../packages/schema-type",
"@latticexyz/store": "link:../../../../packages/store",
"@latticexyz/world": "link:../../../../packages/world",
"@latticexyz/world-modules": "link:../../../../packages/world-modules"
},
"devDependencies": {
"@openzeppelin/contracts": "^5.0.0",
"@types/node": "^18.15.11",
"account-abstraction": "https://github.com/eth-infinitism/account-abstraction.git#7af70c8993a6f42973f520ae0752386a5032abe7",
"ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0",
"forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1",
"prettier": "3.2.5",
"prettier-plugin-solidity": "1.3.1",
"solhint": "^3.3.7",
"solhint-config-mud": "file:../../../../packages/solhint-config-mud",
"solhint-plugin-mud": "file:../../../../packages/solhint-plugin-mud"
}
"name": "contracts",
"version": "0.0.0",
"private": true,
"license": "MIT",
"scripts": {
"build": "mud build",
"clean": "forge clean && rimraf src/codegen",
"deploy:local": "pnpm run build && mud deploy",
"deploy:testnet": "pnpm run build && mud deploy --profile=lattice-testnet",
"dev": "pnpm mud dev-contracts",
"lint": "pnpm run prettier && pnpm run solhint",
"prettier": "prettier --write 'src/**/*.sol'",
"solhint": "solhint --config ./.solhint.json 'src/**/*.sol' --fix",
"test": "tsc --noEmit && mud test"
},
"dependencies": {
"@latticexyz/cli": "link:../../../../packages/cli",
"@latticexyz/schema-type": "link:../../../../packages/schema-type",
"@latticexyz/store": "link:../../../../packages/store",
"@latticexyz/world": "link:../../../../packages/world",
"@latticexyz/world-modules": "link:../../../../packages/world-modules"
},
"devDependencies": {
"@types/node": "^18.15.11",
"ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0",
"forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1",
"prettier": "3.2.5",
"prettier-plugin-solidity": "1.3.1",
"solhint": "^3.3.7",
"solhint-config-mud": "file:../../../../packages/solhint-config-mud",
"solhint-plugin-mud": "file:../../../../packages/solhint-plugin-mud"
}
}
1 change: 0 additions & 1 deletion templates/react/packages/contracts/remappings.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
ds-test/=node_modules/ds-test/src/
forge-std/=node_modules/forge-std/src/
@latticexyz/=node_modules/@latticexyz/
@account-abstraction/=node_modules/account-abstraction/contracts
24 changes: 0 additions & 24 deletions templates/react/packages/contracts/src/MockPaymaster.sol

This file was deleted.

2 changes: 1 addition & 1 deletion templates/react/packages/contracts/worlds.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"31337": {
"address": "0x4f4ddafbc93cf8d11a253f21ddbcf836139efdec"
"address": "0x6e9474e9c83676b9a71133ff96db43e7aa0a4342"
}
}

0 comments on commit 53cc6ee

Please sign in to comment.