@latticexyz/entrykit 2.2.18-88af9325733387259f29dfdafd2fdbc23f2ab499 → 2.2.18-8d0ce55e964e646a1c804c401df01c4deb866f30
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
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import"dotenv/config";import{concatHex as p,http as
|
|
1
|
+
import"dotenv/config";import{concatHex as p,http as x,isHex as P,parseAbiParameters as l,encodeAbiParameters as m,size as r,parseEther as w,createClient as E}from"viem";import{privateKeyToAccount as g}from"viem/accounts";import{getRpcUrl as v}from"@latticexyz/common/foundry";import{ensureContractsDeployed as s,ensureDeployer as h,getContractAddress as b,waitForTransactions as H}from"@latticexyz/common/internal";import a from"@account-abstraction/contracts/artifacts/EntryPoint.json"assert{type:"json"};import d from"@account-abstraction/contracts/artifacts/SimpleAccountFactory.json"assert{type:"json"};import i from"@latticexyz/paymaster/out/GenerousPaymaster.sol/GenerousPaymaster.json"assert{type:"json"};import{getChainId as B}from"viem/actions";import{writeContract as T}from"@latticexyz/common";import{entryPoint07Address as y}from"viem/account-abstraction";var f=process.env.PRIVATE_KEY;if(!P(f))throw new Error(`Missing \`PRIVATE_KEY\` environment variable. If you're using Anvil, run
|
|
2
2
|
|
|
3
3
|
echo "PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" > .env
|
|
4
4
|
|
|
5
|
-
to use a prefunded Anvil account.`);var
|
|
5
|
+
to use a prefunded Anvil account.`);var I=g(f),K=await v(),e=E({account:I,transport:x(K)}),j=await B(e),t=await h(e),u="0x90d8084deab30c2a37c45e8d47f49f2f7965183cb6990a98943ef94940681de3",o=b({deployerAddress:t,bytecode:a.bytecode,salt:u});if(o!==y)throw new Error(`Unexpected EntryPoint v0.7 address
|
|
6
6
|
|
|
7
7
|
Expected: ${y}
|
|
8
|
-
Actual: ${o}`);await s({client:e,deployerAddress:t,contracts:[{bytecode:a.bytecode,salt:
|
|
8
|
+
Actual: ${o}`);await s({client:e,deployerAddress:t,contracts:[{bytecode:a.bytecode,salt:u,deployedBytecodeSize:r(a.deployedBytecode),debugLabel:"EntryPoint v0.7"}]});await s({client:e,deployerAddress:t,contracts:[{bytecode:p([d.bytecode,m(l("address"),[o])]),deployedBytecodeSize:r(d.deployedBytecode),debugLabel:"SimpleAccountFactory"}]});if(j===31337){let c=p([i.bytecode.object,m(l("address"),[o])]),n=b({deployerAddress:t,bytecode:c});await s({client:e,deployerAddress:t,contracts:[{bytecode:c,deployedBytecodeSize:r(i.deployedBytecode.object),debugLabel:"GenerousPaymaster"}]});let A=await T(e,{chain:null,address:o,abi:[{inputs:[{name:"account",type:"address"}],name:"depositTo",outputs:[],stateMutability:"payable",type:"function"}],functionName:"depositTo",args:[n],value:w("100")});await H({client:e,hashes:[A]}),console.log(`
|
|
9
9
|
Funded local paymaster at:`,n,`
|
|
10
10
|
`)}console.log(`
|
|
11
11
|
EntryKit contracts are ready!
|
|
@@ -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\" assert { type: \"json\" };\nimport simpleAccountFactoryArtifact from \"@account-abstraction/contracts/artifacts/SimpleAccountFactory.json\" assert { type: \"json\" };\nimport localPaymasterArtifact from \"@latticexyz/paymaster/out/GenerousPaymaster.sol/GenerousPaymaster.json\" assert { 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\
|
|
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\" assert { type: \"json\" };\nimport simpleAccountFactoryArtifact from \"@account-abstraction/contracts/artifacts/SimpleAccountFactory.json\" assert { type: \"json\" };\nimport localPaymasterArtifact from \"@latticexyz/paymaster/out/GenerousPaymaster.sol/GenerousPaymaster.json\" assert { 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\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(\"\\nFunded local paymaster at:\", localPaymasterAddress, \"\\n\");\n}\n\nconsole.log(\"\\nEntryKit contracts are ready!\\n\");\nprocess.exit(0);\n"],"mappings":"AAAA,MAAO,gBACP,OAEE,aAAAA,EACA,QAAAC,EACA,SAAAC,EACA,sBAAAC,EACA,uBAAAC,EACA,QAAAC,EACA,cAAAC,EACA,gBAAAC,MACK,OACP,OAAS,uBAAAC,MAA2B,gBACpC,OAAS,aAAAC,MAAiB,6BAC1B,OACE,2BAAAC,EACA,kBAAAC,EACA,sBAAAC,EACA,uBAAAC,MACK,8BACP,OAAOC,MAAwB,0DAA2D,MAAO,CAAE,KAAM,MAAO,EAChH,OAAOC,MAAkC,oEAAqE,MAAO,CAAE,KAAM,MAAO,EACpI,OAAOC,MAA4B,wEAAyE,MAAO,CAAE,KAAM,MAAO,EAClI,OAAS,cAAAC,MAAkB,eAC3B,OAAS,iBAAAC,MAAqB,qBAC9B,OAAS,uBAAAC,MAA2B,2BAIpC,IAAMC,EAAa,QAAQ,IAAI,YAC/B,GAAI,CAAClB,EAAMkB,CAAU,EAEnB,MAAM,IAAI,MACR;AAAA;AAAA;AAAA;AAAA,kCAKF,EAEF,IAAMC,EAAUb,EAAoBY,CAAU,EACxCE,EAAS,MAAMb,EAAU,EAEzBc,EAAShB,EAAa,CAAE,QAAAc,EAAS,UAAW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CAAC,EACV,gBAAiB,UACjB,KAAM,UACR,CACF,EACA,aAAc,YACd,KAAM,CAACE,CAAqB,EAC5B,MAAOvB,EAAW,KAAK,CACzB,CAAC,EACD,MAAMO,EAAoB,CAAE,OAAAU,EAAQ,OAAQ,CAACO,CAAE,CAAE,CAAC,EAClD,QAAQ,IAAI;AAAA,4BAAgCD,EAAuB;AAAA,CAAI,CACzE,CAEA,QAAQ,IAAI;AAAA;AAAA,CAAmC,EAC/C,QAAQ,KAAK,CAAC","names":["concatHex","http","isHex","parseAbiParameters","encodeAbiParameters","size","parseEther","createClient","privateKeyToAccount","getRpcUrl","ensureContractsDeployed","ensureDeployer","getContractAddress","waitForTransactions","entryPointArtifact","simpleAccountFactoryArtifact","localPaymasterArtifact","getChainId","writeContract","entryPoint07Address","privateKey","account","rpcUrl","client","chainId","deployerAddress","entryPointSalt","entryPointAddress","localPaymasterBytecode","localPaymasterAddress","tx"]}
|