@latticexyz/entrykit 2.2.14-entrykit-bfd56feb1d7af37a54c62f1e4883633d6a35a308 → 2.2.15-653f378403c7e4f234f87dec20c9dfe523f0def0

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.
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ // workaround for https://github.com/pnpm/pnpm/issues/1801
3
+ import "../dist/tsup/bin/deploy-local-prereqs.js";
@@ -0,0 +1,16 @@
1
+ import"dotenv/config";import{concatHex as c,createWalletClient as A,http as x,isHex as g,parseAbiParameters as d,encodeAbiParameters as i,size as s,parseEther as h}from"viem";import{privateKeyToAccount as v}from"viem/accounts";import{getRpcUrl as w}from"@latticexyz/common/foundry";import{ensureContractsDeployed as p,ensureDeployer as E,getContractAddress as y,waitForTransactions as H}from"@latticexyz/common/internal";import r from"@account-abstraction/contracts/artifacts/EntryPoint.json"assert{type:"json"};import n from"@account-abstraction/contracts/artifacts/SimpleAccountFactory.json"assert{type:"json"};import l from"@latticexyz/paymaster/out/GenerousPaymaster.sol/GenerousPaymaster.json"assert{type:"json"};import{getChainId as P}from"viem/actions";import{writeContract as B}from"@latticexyz/common";var m=process.env.PRIVATE_KEY;if(!g(m))throw new Error(`Missing \`PRIVATE_KEY\` environment variable. If you're using Anvil, run
2
+
3
+ echo "PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" > .env
4
+
5
+ to use a prefunded Anvil account.`);var T=v(m),C=await w(),e=A({transport:x(C),account:T}),I=await P(e),o=await E(e),b="0x90d8084deab30c2a37c45e8d47f49f2f7965183cb6990a98943ef94940681de3",t=y({deployerAddress:o,bytecode:r.bytecode,salt:b});await p({client:e,deployerAddress:o,contracts:[{bytecode:r.bytecode,salt:b,deployedBytecodeSize:s(r.deployedBytecode),debugLabel:"EntryPoint v0.7"}]});var f=c([l.bytecode.object,i(d("address"),[t])]),a=y({deployerAddress:o,bytecode:f});await p({client:e,deployerAddress:o,contracts:[{bytecode:c([n.bytecode,i(d("address"),[t])]),deployedBytecodeSize:s(n.deployedBytecode),debugLabel:"SimpleAccountFactory"},{bytecode:f,deployedBytecodeSize:s(l.deployedBytecode.object),debugLabel:"GenerousPaymaster"}]});console.log(`
6
+ Contracts deployed!
7
+ `);if(I===31337){let u=await B(e,{chain:null,address:t,abi:[{inputs:[{name:"account",type:"address"}],name:"depositTo",outputs:[],stateMutability:"payable",type:"function"}],functionName:"depositTo",args:[a],value:h("100")});await H({client:e,hashes:[u]}),console.log(`
8
+ Funded paymaster at:`,a,`
9
+ `)}else console.log(`
10
+ Be sure to fund the paymaster by making a deposit in the entrypoint contract. For example:
11
+
12
+ cast send ${t} "depositTo(address)" ${a} --value 1ether
13
+ `);console.log(`
14
+ EntryKit prerequisites complete!
15
+ `);process.exit(0);
16
+ //# sourceMappingURL=deploy-local-prereqs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/bin/deploy-local-prereqs.ts"],"sourcesContent":["import \"dotenv/config\";\nimport {\n Hex,\n concatHex,\n createWalletClient,\n http,\n isHex,\n parseAbiParameters,\n encodeAbiParameters,\n size,\n parseEther,\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 paymasterArtifact from \"@latticexyz/paymaster/out/GenerousPaymaster.sol/GenerousPaymaster.json\" assert { type: \"json\" };\nimport { getChainId } from \"viem/actions\";\nimport { writeContract } from \"@latticexyz/common\";\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);\n\n// TODO: rpc url flag/env var?\n// TODO: foundry profile flag/env var?\nconst rpc = await getRpcUrl();\n\nconst client = createWalletClient({\n transport: http(rpc),\n account,\n});\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});\n// TODO: assert that this matches Viem's entryPoint07Address\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\nconst paymasterBytecode = concatHex([\n paymasterArtifact.bytecode.object as Hex,\n encodeAbiParameters(parseAbiParameters(\"address\"), [entryPointAddress]),\n]);\nconst paymasterAddress = getContractAddress({ deployerAddress, bytecode: paymasterBytecode });\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 bytecode: paymasterBytecode,\n deployedBytecodeSize: size(paymasterArtifact.deployedBytecode.object as Hex),\n debugLabel: \"GenerousPaymaster\",\n },\n ],\n});\n\nconsole.log(\"\\nContracts deployed!\\n\");\n\nif (chainId === 31337) {\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: [paymasterAddress],\n value: parseEther(\"100\"),\n });\n await waitForTransactions({ client, hashes: [tx] });\n console.log(\"\\nFunded paymaster at:\", paymasterAddress, \"\\n\");\n} else {\n console.log(`\nBe sure to fund the paymaster by making a deposit in the entrypoint contract. For example:\n\n cast send ${entryPointAddress} \"depositTo(address)\" ${paymasterAddress} --value 1ether\n`);\n}\n\nconsole.log(\"\\nEntryKit prerequisites complete!\\n\");\nprocess.exit(0);\n"],"mappings":"AAAA,MAAO,gBACP,OAEE,aAAAA,EACA,sBAAAC,EACA,QAAAC,EACA,SAAAC,EACA,sBAAAC,EACA,uBAAAC,EACA,QAAAC,EACA,cAAAC,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,MAAuB,wEAAyE,MAAO,CAAE,KAAM,MAAO,EAC7H,OAAS,cAAAC,MAAkB,eAC3B,OAAS,iBAAAC,MAAqB,qBAI9B,IAAMC,EAAa,QAAQ,IAAI,YAC/B,GAAI,CAAChB,EAAMgB,CAAU,EAEnB,MAAM,IAAI,MACR;AAAA;AAAA;AAAA;AAAA,kCAK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KAAM,UACR,CACF,EACA,aAAc,YACd,KAAM,CAACE,CAAgB,EACvB,MAAOrB,EAAW,KAAK,CACzB,CAAC,EACD,MAAMM,EAAoB,CAAE,OAAAS,EAAQ,OAAQ,CAACO,CAAE,CAAE,CAAC,EAClD,QAAQ,IAAI;AAAA,sBAA0BD,EAAkB;AAAA,CAAI,OAE5D,QAAQ,IAAI;AAAA;AAAA;AAAA,cAGAF,0BAA0CE;AAAA,CACvD,EAGD,QAAQ,IAAI;AAAA;AAAA,CAAsC,EAClD,QAAQ,KAAK,CAAC","names":["concatHex","createWalletClient","http","isHex","parseAbiParameters","encodeAbiParameters","size","parseEther","privateKeyToAccount","getRpcUrl","ensureContractsDeployed","ensureDeployer","getContractAddress","waitForTransactions","entryPointArtifact","simpleAccountFactoryArtifact","paymasterArtifact","getChainId","writeContract","privateKey","account","rpc","client","chainId","deployerAddress","entryPointSalt","entryPointAddress","paymasterBytecode","paymasterAddress","tx"]}
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,122 @@
1
+ import { Address } from 'viem/accounts';
2
+ import { Chain, Client, Transport, Account, Address as Address$1 } from 'viem';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import { ReactNode } from 'react';
5
+ import { UseQueryResult } from '@tanstack/react-query';
6
+ import { CreateConfigParameters, Config, CreateConnectorFn } from 'wagmi';
7
+ import { WalletList } from '@rainbow-me/rainbowkit';
8
+
9
+ type EntryKitConfigInput = {
10
+ /**
11
+ * The chain ID where the world is deployed.
12
+ * There must be a matching chain entry in wagmi's configured chains.
13
+ * The session client returned by EntryKit will be tied to this chain.
14
+ */
15
+ readonly chainId: number;
16
+ /**
17
+ * The world address.
18
+ */
19
+ readonly worldAddress: Address;
20
+ /**
21
+ * EntryKit UI theme.
22
+ *
23
+ * If not set, defaults to OS' light or dark mode.
24
+ */
25
+ readonly theme?: "dark" | "light";
26
+ /**
27
+ * The app name.
28
+ */
29
+ readonly appName?: string;
30
+ /**
31
+ * The URL of the app icon used throughout the onboarding process.
32
+ * Icon should be 1:1 aspect ratio, at least 200x200.
33
+ */
34
+ readonly appIcon?: string;
35
+ };
36
+
37
+ type EntryKitConfig = {
38
+ /**
39
+ * The chain ID where the world is deployed.
40
+ * There must be a matching chain entry in wagmi's configured chains.
41
+ * The session client returned by EntryKit will be tied to this chain.
42
+ */
43
+ readonly chainId: number;
44
+ /**
45
+ * The world address.
46
+ */
47
+ readonly worldAddress: Address;
48
+ /**
49
+ * EntryKit UI theme.
50
+ *
51
+ * If not set, defaults to OS' light or dark mode.
52
+ */
53
+ readonly theme?: "dark" | "light";
54
+ /**
55
+ * The app name.
56
+ */
57
+ readonly appName: string;
58
+ /**
59
+ * The URL of the app icon used throughout the onboarding process.
60
+ * Icon should be 1:1 aspect ratio, at least 200x200.
61
+ */
62
+ readonly appIcon: string;
63
+ };
64
+
65
+ declare function defineConfig(input: EntryKitConfigInput): EntryKitConfig;
66
+
67
+ type ConnectedClient<chain extends Chain = Chain> = Client<Transport, chain, Account>;
68
+ type SessionClient<chain extends Chain = Chain> = ConnectedClient<chain> & {
69
+ readonly userAddress: Address$1;
70
+ };
71
+
72
+ type Props = {
73
+ config: EntryKitConfig;
74
+ children?: ReactNode;
75
+ };
76
+ declare function EntryKitProvider({ config, children }: Props): react_jsx_runtime.JSX.Element;
77
+
78
+ type ContextValue = EntryKitConfig & {
79
+ chain: Chain;
80
+ };
81
+ declare function useEntryKitConfig(): ContextValue;
82
+
83
+ declare function AccountButton(): react_jsx_runtime.JSX.Element;
84
+
85
+ type UseAccountModalResult = {
86
+ readonly accountModalOpen: boolean;
87
+ readonly openAccountModal: () => void;
88
+ readonly closeAccountModal: () => void;
89
+ readonly toggleAccountModal: (open: boolean) => void;
90
+ };
91
+ declare function useAccountModal(): UseAccountModalResult;
92
+
93
+ declare function useSessionClientReady(): UseQueryResult<SessionClient | undefined>;
94
+
95
+ type CreateWagmiConfigOptions<chains extends readonly [Chain, ...Chain[]] = readonly [Chain, ...Chain[]], transports extends Record<chains[number]["id"], Transport> = Record<chains[number]["id"], Transport>> = {
96
+ readonly chainId: number;
97
+ readonly chains: chains;
98
+ readonly transports: transports;
99
+ /**
100
+ * WalletConnect project ID, obtained from your WalletConnect dashboard.
101
+ */
102
+ readonly walletConnectProjectId: string;
103
+ readonly appName: string;
104
+ } & Pick<CreateConfigParameters<chains, transports>, "pollingInterval">;
105
+ declare function createWagmiConfig<const chains extends readonly [Chain, ...Chain[]], transports extends Record<chains[number]["id"], Transport>>(config: CreateWagmiConfigOptions<chains, transports>): Config<chains, transports>;
106
+
107
+ declare function getConnectors({ wallets, ...config }: {
108
+ readonly chainId: number;
109
+ /**
110
+ * WalletConnect project ID, obtained from your WalletConnect dashboard.
111
+ */
112
+ readonly walletConnectProjectId: string;
113
+ readonly appName: string;
114
+ } & {
115
+ readonly wallets?: WalletList;
116
+ }): CreateConnectorFn[];
117
+
118
+ declare function getWallets(_config: {
119
+ readonly chainId: number;
120
+ }): WalletList;
121
+
122
+ export { AccountButton, ConnectedClient, CreateWagmiConfigOptions, EntryKitConfig, EntryKitConfigInput, EntryKitProvider, SessionClient, createWagmiConfig, defineConfig, getConnectors, getWallets, useAccountModal, useEntryKitConfig, useSessionClientReady as useSessionClient };