@latticexyz/entrykit 2.2.18-9fa07c8489f1fbf167d0db01cd9aaa645a29c8e2 → 2.2.18-c2ad22c7feb566e1731ff16e8be291746bdffb3e
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 +8 -117
- package/dist/tsup/bin/deploy.js.map +1 -1
- package/dist/tsup/exports/internal.js +1382 -2238
- package/dist/tsup/exports/internal.js.map +1 -1
- package/package.json +11 -28
- package/dist/tsup/bin/deploy.cjs +0 -132
- package/dist/tsup/bin/deploy.cjs.map +0 -1
- package/dist/tsup/bin/deploy.d.cts +0 -2
- package/dist/tsup/exports/index.cjs +0 -2
- package/dist/tsup/exports/index.cjs.map +0 -1
- package/dist/tsup/exports/index.d.cts +0 -2
- package/dist/tsup/exports/internal.cjs +0 -2287
- package/dist/tsup/exports/internal.cjs.map +0 -1
- package/dist/tsup/exports/internal.d.cts +0 -123
package/dist/tsup/bin/deploy.js
CHANGED
|
@@ -1,122 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
import "dotenv/config";
|
|
3
|
-
import {
|
|
4
|
-
concatHex,
|
|
5
|
-
http,
|
|
6
|
-
isHex,
|
|
7
|
-
parseAbiParameters,
|
|
8
|
-
encodeAbiParameters,
|
|
9
|
-
size,
|
|
10
|
-
parseEther,
|
|
11
|
-
createClient
|
|
12
|
-
} from "viem";
|
|
13
|
-
import { privateKeyToAccount } from "viem/accounts";
|
|
14
|
-
import { getRpcUrl } from "@latticexyz/common/foundry";
|
|
15
|
-
import {
|
|
16
|
-
ensureContractsDeployed,
|
|
17
|
-
ensureDeployer,
|
|
18
|
-
getContractAddress,
|
|
19
|
-
waitForTransactions
|
|
20
|
-
} from "@latticexyz/common/internal";
|
|
21
|
-
import entryPointArtifact from "@account-abstraction/contracts/artifacts/EntryPoint.json" assert { type: "json" };
|
|
22
|
-
import simpleAccountFactoryArtifact from "@account-abstraction/contracts/artifacts/SimpleAccountFactory.json" assert { type: "json" };
|
|
23
|
-
import localPaymasterArtifact from "@latticexyz/paymaster/out/GenerousPaymaster.sol/GenerousPaymaster.json" assert { type: "json" };
|
|
24
|
-
import { getChainId } from "viem/actions";
|
|
25
|
-
import { writeContract } from "@latticexyz/common";
|
|
26
|
-
import { entryPoint07Address } from "viem/account-abstraction";
|
|
27
|
-
(async () => {
|
|
28
|
-
const privateKey = process.env.PRIVATE_KEY;
|
|
29
|
-
if (!isHex(privateKey)) {
|
|
30
|
-
throw new Error(
|
|
31
|
-
`Missing \`PRIVATE_KEY\` environment variable. If you're using Anvil, run
|
|
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
|
|
32
2
|
|
|
33
3
|
echo "PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" > .env
|
|
34
4
|
|
|
35
|
-
to use a prefunded Anvil account.`
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
const account = privateKeyToAccount(privateKey);
|
|
39
|
-
const rpcUrl = await getRpcUrl();
|
|
40
|
-
const client = createClient({ account, transport: http(rpcUrl) });
|
|
41
|
-
const chainId = await getChainId(client);
|
|
42
|
-
const deployerAddress = await ensureDeployer(client);
|
|
43
|
-
const entryPointSalt = "0x90d8084deab30c2a37c45e8d47f49f2f7965183cb6990a98943ef94940681de3";
|
|
44
|
-
const entryPointAddress = getContractAddress({
|
|
45
|
-
deployerAddress,
|
|
46
|
-
bytecode: entryPointArtifact.bytecode,
|
|
47
|
-
salt: entryPointSalt
|
|
48
|
-
});
|
|
49
|
-
if (entryPointAddress !== entryPoint07Address) {
|
|
50
|
-
throw new Error(
|
|
51
|
-
`Unexpected EntryPoint v0.7 address
|
|
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
|
|
52
6
|
|
|
53
|
-
Expected: ${
|
|
54
|
-
Actual: ${
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
deployerAddress,
|
|
60
|
-
contracts: [
|
|
61
|
-
{
|
|
62
|
-
bytecode: entryPointArtifact.bytecode,
|
|
63
|
-
salt: entryPointSalt,
|
|
64
|
-
deployedBytecodeSize: size(entryPointArtifact.deployedBytecode),
|
|
65
|
-
debugLabel: "EntryPoint v0.7"
|
|
66
|
-
}
|
|
67
|
-
]
|
|
68
|
-
});
|
|
69
|
-
await ensureContractsDeployed({
|
|
70
|
-
client,
|
|
71
|
-
deployerAddress,
|
|
72
|
-
contracts: [
|
|
73
|
-
{
|
|
74
|
-
bytecode: concatHex([
|
|
75
|
-
simpleAccountFactoryArtifact.bytecode,
|
|
76
|
-
encodeAbiParameters(parseAbiParameters("address"), [entryPointAddress])
|
|
77
|
-
]),
|
|
78
|
-
deployedBytecodeSize: size(simpleAccountFactoryArtifact.deployedBytecode),
|
|
79
|
-
debugLabel: "SimpleAccountFactory"
|
|
80
|
-
}
|
|
81
|
-
]
|
|
82
|
-
});
|
|
83
|
-
if (chainId === 31337) {
|
|
84
|
-
const localPaymasterBytecode = concatHex([
|
|
85
|
-
localPaymasterArtifact.bytecode.object,
|
|
86
|
-
encodeAbiParameters(parseAbiParameters("address"), [entryPointAddress])
|
|
87
|
-
]);
|
|
88
|
-
const localPaymasterAddress = getContractAddress({ deployerAddress, bytecode: localPaymasterBytecode });
|
|
89
|
-
await ensureContractsDeployed({
|
|
90
|
-
client,
|
|
91
|
-
deployerAddress,
|
|
92
|
-
contracts: [
|
|
93
|
-
{
|
|
94
|
-
bytecode: localPaymasterBytecode,
|
|
95
|
-
deployedBytecodeSize: size(localPaymasterArtifact.deployedBytecode.object),
|
|
96
|
-
debugLabel: "GenerousPaymaster"
|
|
97
|
-
}
|
|
98
|
-
]
|
|
99
|
-
});
|
|
100
|
-
const tx = await writeContract(client, {
|
|
101
|
-
chain: null,
|
|
102
|
-
address: entryPointAddress,
|
|
103
|
-
abi: [
|
|
104
|
-
{
|
|
105
|
-
inputs: [{ name: "account", type: "address" }],
|
|
106
|
-
name: "depositTo",
|
|
107
|
-
outputs: [],
|
|
108
|
-
stateMutability: "payable",
|
|
109
|
-
type: "function"
|
|
110
|
-
}
|
|
111
|
-
],
|
|
112
|
-
functionName: "depositTo",
|
|
113
|
-
args: [localPaymasterAddress],
|
|
114
|
-
value: parseEther("100")
|
|
115
|
-
});
|
|
116
|
-
await waitForTransactions({ client, hashes: [tx] });
|
|
117
|
-
console.log("\nFunded local paymaster at:", localPaymasterAddress, "\n");
|
|
118
|
-
}
|
|
119
|
-
console.log("\nEntryKit contracts are ready!\n");
|
|
120
|
-
process.exit(0);
|
|
121
|
-
})();
|
|
7
|
+
Expected: ${y}
|
|
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
|
+
Funded local paymaster at:`,n,`
|
|
10
|
+
`)}console.log(`
|
|
11
|
+
EntryKit contracts are ready!
|
|
12
|
+
`);process.exit(0);
|
|
122
13
|
//# sourceMappingURL=deploy.js.map
|
|
@@ -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//
|
|
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,E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zB,EAAU,CAClBe,EAA6B,SAC7BX,EAAoBD,EAAmB,SAAS,EAAG,CAACwB,CAAiB,CAAC,CACxE,CAAC,EACD,qBAAsBtB,EAAKU,EAA6B,gBAAuB,EAC/E,WAAY,sBACd,CACF,CACF,CAAC,EAED,GAAIS,IAAY,MAAO,CACrB,IAAMI,EAAyB5B,EAAU,CACvCgB,EAAuB,SAAS,OAChCZ,EAAoBD,EAAmB,SAAS,EAAG,CAACwB,CAAiB,CAAC,CACxE,CAAC,EACKE,EAAwBjB,EAAmB,CAAE,gBAAAa,EAAiB,SAAUG,CAAuB,CAAC,EAEtG,MAAMlB,EAAwB,CAC5B,OAAAa,EACA,gBAAAE,EACA,UAAW,CACT,CACE,SAAUG,EACV,qBAAsBvB,EAAKW,EAAuB,iBAAiB,MAAa,EAChF,WAAY,mBACd,CACF,CACF,CAAC,EAED,IAAMc,EAAK,MAAMZ,EAAcK,EAAQ,CACrC,MAAO,KACP,QAASI,EACT,IAAK,CACH,CACE,OAAQ,CAAC,CAAE,KAAM,UAAW,KAAM,SAAU,CAAC,EAC7C,KAAM,YACN,QAAS,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"]}
|