@latticexyz/entrykit 2.2.22-630621831e17a0f1d8d9b3ed313032a19f349d13 → 2.2.22-6508c1df5ea605f58112f192114a2f837f362ecc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tsup/bin/deploy.js
CHANGED
|
@@ -18,9 +18,9 @@ import {
|
|
|
18
18
|
getContractAddress,
|
|
19
19
|
waitForTransactions
|
|
20
20
|
} from "@latticexyz/common/internal";
|
|
21
|
-
import entryPointArtifact from "@account-abstraction/contracts/artifacts/EntryPoint.json"
|
|
22
|
-
import simpleAccountFactoryArtifact from "@account-abstraction/contracts/artifacts/SimpleAccountFactory.json"
|
|
23
|
-
import localPaymasterArtifact from "@latticexyz/paymaster/out/GenerousPaymaster.sol/GenerousPaymaster.json"
|
|
21
|
+
import entryPointArtifact from "@account-abstraction/contracts/artifacts/EntryPoint.json" with { type: "json" };
|
|
22
|
+
import simpleAccountFactoryArtifact from "@account-abstraction/contracts/artifacts/SimpleAccountFactory.json" with { type: "json" };
|
|
23
|
+
import localPaymasterArtifact from "@latticexyz/paymaster/out/GenerousPaymaster.sol/GenerousPaymaster.json" with { type: "json" };
|
|
24
24
|
import { getChainId } from "viem/actions";
|
|
25
25
|
import { writeContract } from "@latticexyz/common";
|
|
26
26
|
import { entryPoint07Address } from "viem/account-abstraction";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/bin/deploy.ts"],"sourcesContent":["import \"dotenv/config\";\nimport {\n Hex,\n concatHex,\n http,\n isHex,\n parseAbiParameters,\n encodeAbiParameters,\n size,\n parseEther,\n createClient,\n} from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport { getRpcUrl } from \"@latticexyz/common/foundry\";\nimport {\n ensureContractsDeployed,\n ensureDeployer,\n getContractAddress,\n waitForTransactions,\n} from \"@latticexyz/common/internal\";\nimport entryPointArtifact from \"@account-abstraction/contracts/artifacts/EntryPoint.json\"
|
|
1
|
+
{"version":3,"sources":["../../../src/bin/deploy.ts"],"sourcesContent":["import \"dotenv/config\";\nimport {\n Hex,\n concatHex,\n http,\n isHex,\n parseAbiParameters,\n encodeAbiParameters,\n size,\n parseEther,\n createClient,\n} from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport { getRpcUrl } from \"@latticexyz/common/foundry\";\nimport {\n ensureContractsDeployed,\n ensureDeployer,\n getContractAddress,\n waitForTransactions,\n} from \"@latticexyz/common/internal\";\nimport entryPointArtifact from \"@account-abstraction/contracts/artifacts/EntryPoint.json\" with { type: \"json\" };\nimport simpleAccountFactoryArtifact from \"@account-abstraction/contracts/artifacts/SimpleAccountFactory.json\" with { type: \"json\" };\nimport localPaymasterArtifact from \"@latticexyz/paymaster/out/GenerousPaymaster.sol/GenerousPaymaster.json\" with { type: \"json\" };\nimport { getChainId } from \"viem/actions\";\nimport { writeContract } from \"@latticexyz/common\";\nimport { entryPoint07Address } from \"viem/account-abstraction\";\n\n// TODO: parse env with arktype (to avoid zod dep) and throw when absent\n\nconst privateKey = process.env.PRIVATE_KEY;\nif (!isHex(privateKey)) {\n // TODO: detect anvil and automatically put this env var where it needs to go?\n throw new Error(\n `Missing \\`PRIVATE_KEY\\` environment variable. If you're using Anvil, run\n\n echo \"PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80\" > .env\n\nto use a prefunded Anvil account.`,\n );\n}\nconst account = privateKeyToAccount(privateKey);\nconst rpcUrl = await getRpcUrl();\n\nconst client = createClient({ account, transport: http(rpcUrl) });\n\nconst chainId = await getChainId(client);\n\nconsole.log(\"Deploying to chain\", chainId, \"from\", account.address, \"via\", rpcUrl);\n\n// TODO: deployer address flag/env var?\nconst deployerAddress = await ensureDeployer(client);\n\n// https://github.com/eth-infinitism/account-abstraction/blob/b3bae63bd9bc0ed394dfca8668008213127adb62/hardhat.config.ts#L11\nconst entryPointSalt = \"0x90d8084deab30c2a37c45e8d47f49f2f7965183cb6990a98943ef94940681de3\";\nconst entryPointAddress = getContractAddress({\n deployerAddress,\n bytecode: entryPointArtifact.bytecode as Hex,\n salt: entryPointSalt,\n});\nif (entryPointAddress !== entryPoint07Address) {\n throw new Error(\n `Unexpected EntryPoint v0.7 address\\n\\n Expected: ${entryPoint07Address}\\nActual: ${entryPointAddress}`,\n );\n}\n\n// Deploy entrypoint first, because following deploys need to be able to call it.\nawait ensureContractsDeployed({\n client,\n deployerAddress,\n contracts: [\n {\n bytecode: entryPointArtifact.bytecode as Hex,\n salt: entryPointSalt,\n deployedBytecodeSize: size(entryPointArtifact.deployedBytecode as Hex),\n debugLabel: \"EntryPoint v0.7\",\n },\n ],\n});\n\nawait ensureContractsDeployed({\n client,\n deployerAddress,\n contracts: [\n {\n bytecode: concatHex([\n simpleAccountFactoryArtifact.bytecode as Hex,\n encodeAbiParameters(parseAbiParameters(\"address\"), [entryPointAddress]),\n ]),\n deployedBytecodeSize: size(simpleAccountFactoryArtifact.deployedBytecode as Hex),\n debugLabel: \"SimpleAccountFactory\",\n },\n ],\n});\n\nif (chainId === 31337) {\n const localPaymasterBytecode = concatHex([\n localPaymasterArtifact.bytecode.object as Hex,\n encodeAbiParameters(parseAbiParameters(\"address\"), [entryPointAddress]),\n ]);\n const localPaymasterAddress = getContractAddress({ deployerAddress, bytecode: localPaymasterBytecode });\n\n await ensureContractsDeployed({\n client,\n deployerAddress,\n contracts: [\n {\n bytecode: localPaymasterBytecode,\n deployedBytecodeSize: size(localPaymasterArtifact.deployedBytecode.object as Hex),\n debugLabel: \"GenerousPaymaster\",\n },\n ],\n });\n\n const tx = await writeContract(client, {\n chain: null,\n address: entryPointAddress,\n abi: [\n {\n inputs: [{ name: \"account\", type: \"address\" }],\n name: \"depositTo\",\n outputs: [],\n stateMutability: \"payable\",\n type: \"function\",\n },\n ],\n functionName: \"depositTo\",\n args: [localPaymasterAddress],\n value: parseEther(\"100\"),\n });\n await waitForTransactions({ client, hashes: [tx] });\n console.log(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B,CAAC;AACD,QAAM,oBAAoB,EAAE,QAAQ,QAAQ,CAAC,EAAE,EAAE,CAAC;AAClD,UAAQ,IAAI,gCAAgC,uBAAuB,IAAI;AACzE;AAEA,QAAQ,IAAI,mCAAmC;AAC/C,QAAQ,KAAK,CAAC;","names":[]}
|
|
@@ -139,11 +139,8 @@ var debug2 = debug.extend("quarry");
|
|
|
139
139
|
|
|
140
140
|
// src/quarry/transports/userOpExecutor.ts
|
|
141
141
|
import { setBalance } from "viem/actions";
|
|
142
|
-
function userOpExecutor({
|
|
143
|
-
|
|
144
|
-
fallbackEth
|
|
145
|
-
}) {
|
|
146
|
-
return (opts) => {
|
|
142
|
+
function userOpExecutor({ executor }) {
|
|
143
|
+
return () => {
|
|
147
144
|
debug2("using a local user op executor", executor.account.address);
|
|
148
145
|
if (executor.chain.id === 31337) {
|
|
149
146
|
debug2("setting executor balance");
|
|
@@ -178,9 +175,7 @@ function userOpExecutor({
|
|
|
178
175
|
if (method === "eth_estimateUserOperationGas") {
|
|
179
176
|
return await estimateUserOperationGas(params);
|
|
180
177
|
}
|
|
181
|
-
|
|
182
|
-
const { request: fallbackRequest } = fallbackEth(opts);
|
|
183
|
-
return fallbackRequest({ method, params });
|
|
178
|
+
throw new Error(`userOpExecutor: method "${method}" not supported`);
|
|
184
179
|
};
|
|
185
180
|
return createTransport({
|
|
186
181
|
key: "userOpExecutor",
|
|
@@ -192,41 +187,20 @@ function userOpExecutor({
|
|
|
192
187
|
}
|
|
193
188
|
|
|
194
189
|
// src/getBundlerTransport.ts
|
|
195
|
-
import { wiresaw } from "@latticexyz/common/internal";
|
|
196
190
|
function getBundlerTransport(chain) {
|
|
197
|
-
const ethRpcUrl = chain.rpcUrls.default.http[0];
|
|
198
191
|
const bundlerHttpUrl = chain.rpcUrls.bundler?.http[0];
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
})
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
return wiresaw({
|
|
210
|
-
wiresaw: http(wiresawHttpUrl),
|
|
211
|
-
fallbackBundler: http(bundlerHttpUrl),
|
|
212
|
-
fallbackEth: http(ethRpcUrl)
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
if (bundlerHttpUrl) {
|
|
216
|
-
return http(bundlerHttpUrl);
|
|
217
|
-
}
|
|
218
|
-
if (chain.id === 31337) {
|
|
219
|
-
return userOpExecutor({
|
|
220
|
-
executor: createClient({
|
|
221
|
-
chain,
|
|
222
|
-
transport: fallback([webSocket(), http()]),
|
|
223
|
-
account: privateKeyToAccount(keccak256(stringToHex("local user op executor"))),
|
|
224
|
-
pollingInterval: 10
|
|
225
|
-
}).extend(transactionQueue()),
|
|
226
|
-
fallbackEth: http(ethRpcUrl)
|
|
227
|
-
});
|
|
192
|
+
const bundlerTransport = bundlerHttpUrl ? http(bundlerHttpUrl) : chain.id === 31337 ? userOpExecutor({
|
|
193
|
+
executor: createClient({
|
|
194
|
+
chain,
|
|
195
|
+
transport: fallback([webSocket(), http()]),
|
|
196
|
+
account: privateKeyToAccount(keccak256(stringToHex("local user op executor"))),
|
|
197
|
+
pollingInterval: 10
|
|
198
|
+
}).extend(transactionQueue())
|
|
199
|
+
}) : null;
|
|
200
|
+
if (!bundlerTransport) {
|
|
201
|
+
throw new Error(`Chain ${chain.id} config did not include a bundler RPC URL.`);
|
|
228
202
|
}
|
|
229
|
-
|
|
203
|
+
return bundlerTransport;
|
|
230
204
|
}
|
|
231
205
|
|
|
232
206
|
// src/EntryKitConfigProvider.tsx
|