@latticexyz/entrykit 2.2.15-entrykit-510cc59769bcf83670255be3102d702c4b673225 → 2.2.15-f9de085862ac62ce15fe3b7743916cfd631592ea
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/bin/deploy-local-prereqs.js +3 -0
- package/dist/tsup/bin/deploy-local-prereqs.js +16 -0
- package/dist/tsup/bin/deploy-local-prereqs.js.map +1 -0
- package/dist/tsup/exports/index.d.ts +2 -0
- package/dist/tsup/{internal.d.ts → exports/internal.d.ts} +4 -35
- package/dist/tsup/exports/internal.js +1398 -0
- package/dist/tsup/exports/internal.js.map +1 -0
- package/package.json +19 -20
- package/dist/tsup/internal.js +0 -1442
- package/dist/tsup/internal.js.map +0 -1
- /package/dist/tsup/{index.d.ts → bin/deploy-local-prereqs.d.ts} +0 -0
- /package/dist/tsup/{index.js → exports/index.js} +0 -0
- /package/dist/tsup/{index.js.map → exports/index.js.map} +0 -0
|
@@ -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,u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B,SAAS,EAAG,CAACsB,CAAiB,CAAC,CACxE,CAAC,EACD,qBAAsBpB,EAAKS,EAA6B,gBAAuB,EAC/E,WAAY,sBACd,EACA,CACE,SAAUY,EACV,qBAAsBrB,EAAKU,EAAkB,iBAAiB,MAAa,EAC3E,WAAY,mBACd,CACF,CACF,CAAC,EAED,QAAQ,IAAI;AAAA;AAAA,CAAyB,EAErC,GAAIO,IAAY,MAAO,CACrB,IAAMM,EAAK,MAAMX,EAAcI,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,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"]}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { Address } from 'viem/accounts';
|
|
2
|
-
import { Chain, Client, Transport, Account, Address as Address$1
|
|
2
|
+
import { Chain, Client, Transport, Account, Address as Address$1 } from 'viem';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
5
|
import { UseQueryResult } from '@tanstack/react-query';
|
|
6
6
|
import { CreateConfigParameters, Config, CreateConnectorFn } from 'wagmi';
|
|
7
|
-
import {
|
|
8
|
-
import { Wallet, WalletList } from '@rainbow-me/rainbowkit';
|
|
7
|
+
import { WalletList } from '@rainbow-me/rainbowkit';
|
|
9
8
|
|
|
10
9
|
type EntryKitConfigInput = {
|
|
11
10
|
/**
|
|
@@ -78,7 +77,6 @@ declare function EntryKitProvider({ config, children }: Props): react_jsx_runtim
|
|
|
78
77
|
|
|
79
78
|
type ContextValue = EntryKitConfig & {
|
|
80
79
|
chain: Chain;
|
|
81
|
-
paymasterAddress: Address$1;
|
|
82
80
|
};
|
|
83
81
|
declare function useEntryKitConfig(): ContextValue;
|
|
84
82
|
|
|
@@ -94,8 +92,6 @@ declare function useAccountModal(): UseAccountModalResult;
|
|
|
94
92
|
|
|
95
93
|
declare function useSessionClientReady(): UseQueryResult<SessionClient | undefined>;
|
|
96
94
|
|
|
97
|
-
type CredentialOptions = Pick<GetCredentialCreationOptionsParameters, "rp">;
|
|
98
|
-
|
|
99
95
|
type CreateWagmiConfigOptions<chains extends readonly [Chain, ...Chain[]] = readonly [Chain, ...Chain[]], transports extends Record<chains[number]["id"], Transport> = Record<chains[number]["id"], Transport>> = {
|
|
100
96
|
readonly chainId: number;
|
|
101
97
|
readonly chains: chains;
|
|
@@ -105,36 +101,9 @@ type CreateWagmiConfigOptions<chains extends readonly [Chain, ...Chain[]] = read
|
|
|
105
101
|
*/
|
|
106
102
|
readonly walletConnectProjectId: string;
|
|
107
103
|
readonly appName: string;
|
|
108
|
-
readonly credentialOptions?: CredentialOptions;
|
|
109
104
|
} & Pick<CreateConfigParameters<chains, transports>, "pollingInterval">;
|
|
110
105
|
declare function createWagmiConfig<const chains extends readonly [Chain, ...Chain[]], transports extends Record<chains[number]["id"], Transport>>(config: CreateWagmiConfigOptions<chains, transports>): Config<chains, transports>;
|
|
111
106
|
|
|
112
|
-
type PasskeyConnectorOptions = {
|
|
113
|
-
chainId: number;
|
|
114
|
-
credentialOptions?: CredentialOptions;
|
|
115
|
-
};
|
|
116
|
-
type PasskeyProvider = {
|
|
117
|
-
request: EIP1193RequestFn<EIP1474Methods>;
|
|
118
|
-
};
|
|
119
|
-
type PasskeyConnectorProperties = {
|
|
120
|
-
createPasskey(): Promise<void>;
|
|
121
|
-
reusePasskey(): Promise<void>;
|
|
122
|
-
hasPasskey(): boolean;
|
|
123
|
-
getClient(parameters?: {
|
|
124
|
-
chainId?: number | undefined;
|
|
125
|
-
} | undefined): Promise<Client>;
|
|
126
|
-
onConnect(connectInfo: ProviderConnectInfo): void;
|
|
127
|
-
};
|
|
128
|
-
type CreatePasskeyConnector = CreateConnectorFn<PasskeyProvider, PasskeyConnectorProperties, {}>;
|
|
129
|
-
type PasskeyConnector = ReturnType<CreatePasskeyConnector>;
|
|
130
|
-
declare function passkeyConnector({ chainId, credentialOptions }: PasskeyConnectorOptions): CreatePasskeyConnector;
|
|
131
|
-
declare namespace passkeyConnector {
|
|
132
|
-
var type: "passkey";
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
type PasskeyWalletOptions = PasskeyConnectorOptions;
|
|
136
|
-
declare const passkeyWallet: (opts: PasskeyWalletOptions) => () => Wallet;
|
|
137
|
-
|
|
138
107
|
declare function getConnectors({ wallets, ...config }: {
|
|
139
108
|
readonly chainId: number;
|
|
140
109
|
/**
|
|
@@ -146,8 +115,8 @@ declare function getConnectors({ wallets, ...config }: {
|
|
|
146
115
|
readonly wallets?: WalletList;
|
|
147
116
|
}): CreateConnectorFn[];
|
|
148
117
|
|
|
149
|
-
declare function getWallets(
|
|
118
|
+
declare function getWallets(_config: {
|
|
150
119
|
readonly chainId: number;
|
|
151
120
|
}): WalletList;
|
|
152
121
|
|
|
153
|
-
export { AccountButton, ConnectedClient,
|
|
122
|
+
export { AccountButton, ConnectedClient, CreateWagmiConfigOptions, EntryKitConfig, EntryKitConfigInput, EntryKitProvider, SessionClient, createWagmiConfig, defineConfig, getConnectors, getWallets, useAccountModal, useEntryKitConfig, useSessionClientReady as useSessionClient };
|