@zerodev/sdk 4.0.7 → 4.0.8

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.
@@ -1,4 +1,4 @@
1
- import { type HttpTransport, type PublicErc4337Client } from "@alchemy/aa-core";
1
+ import { type PublicErc4337Client, type HttpTransport } from "@alchemy/aa-core";
2
2
  import { type Chain } from "viem";
3
3
  import type { PaymasterAndBundlerProviders } from "../paymaster/types.js";
4
4
  interface ZeroDevClientConfig {
@@ -4,15 +4,44 @@ exports.createZeroDevPublicErc4337Client = void 0;
4
4
  const aa_core_1 = require("@alchemy/aa-core");
5
5
  const viem_1 = require("viem");
6
6
  const constants_js_1 = require("../constants.js");
7
+ function isMethodInErc4337RpcSchema(variable) {
8
+ return [
9
+ "eth_sendUserOperation",
10
+ "eth_estimateUserOperationGas",
11
+ "eth_getUserOperationReceipt",
12
+ "eth_getUserOperationByHash",
13
+ "eth_supportedEntryPoints",
14
+ "eth_maxPriorityFeePerGas",
15
+ ].includes(variable);
16
+ }
7
17
  const createZeroDevPublicErc4337Client = ({ chain, rpcUrl, projectId, bundlerProvider, }) => {
18
+ const erc4337Transport = (0, viem_1.http)(rpcUrl, {
19
+ fetchOptions: {
20
+ headers: rpcUrl === constants_js_1.BUNDLER_URL ? { projectId, bundlerProvider } : {},
21
+ },
22
+ name: "Connected bundler network",
23
+ key: "connected-bundler-network",
24
+ });
25
+ const publicTransport = (0, viem_1.http)(constants_js_1.CHAIN_ID_TO_NODE[chain.id]);
8
26
  let client = (0, aa_core_1.createPublicErc4337FromClient)((0, viem_1.createPublicClient)({
9
27
  chain,
10
- transport: (0, viem_1.http)(rpcUrl, {
11
- fetchOptions: {
12
- headers: rpcUrl === constants_js_1.BUNDLER_URL ? { projectId, bundlerProvider } : {},
28
+ transport: (0, viem_1.custom)({
29
+ async request({ method, params }) {
30
+ let response;
31
+ if (isMethodInErc4337RpcSchema(method)) {
32
+ response = await erc4337Transport({ chain }).request({
33
+ method,
34
+ params,
35
+ });
36
+ }
37
+ else {
38
+ response = await publicTransport({ chain }).request({
39
+ method,
40
+ params,
41
+ });
42
+ }
43
+ return response;
13
44
  },
14
- name: "Connected bundler network",
15
- key: "connected-bundler-network",
16
45
  }),
17
46
  }));
18
47
  return client;
@@ -1 +1 @@
1
- {"version":3,"file":"create-client.js","sourceRoot":"","sources":["../../../../src/kernel-zerodev/client/create-client.ts"],"names":[],"mappings":";;;AAAA,8CAI0B;AAC1B,+BAA4D;AAC5D,kDAA8C;AAUvC,MAAM,gCAAgC,GAAG,CAAC,EAC/C,KAAK,EACL,MAAM,EACN,SAAS,EACT,eAAe,GACK,EAAsC,EAAE;IAC5D,IAAI,MAAM,GAAG,IAAA,uCAA6B,EACxC,IAAA,yBAAkB,EAAC;QACjB,KAAK;QACL,SAAS,EAAE,IAAA,WAAI,EAAC,MAAM,EAAE;YACtB,YAAY,EAAE;gBACZ,OAAO,EAAE,MAAM,KAAK,0BAAW,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE;aACtE;YACD,IAAI,EAAE,2BAA2B;YACjC,GAAG,EAAE,2BAA2B;SACjC,CAAC;KACH,CAAC,CACH,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AApBW,QAAA,gCAAgC,oCAoB3C","sourcesContent":["import {\n createPublicErc4337FromClient,\n type HttpTransport,\n type PublicErc4337Client,\n} from \"@alchemy/aa-core\";\nimport { http, createPublicClient, type Chain } from \"viem\";\nimport { BUNDLER_URL } from \"../constants.js\";\nimport type { PaymasterAndBundlerProviders } from \"../paymaster/types.js\";\n\ninterface ZeroDevClientConfig {\n chain: Chain;\n projectId: string;\n rpcUrl?: string;\n bundlerProvider?: PaymasterAndBundlerProviders;\n}\n\nexport const createZeroDevPublicErc4337Client = ({\n chain,\n rpcUrl,\n projectId,\n bundlerProvider,\n}: ZeroDevClientConfig): PublicErc4337Client<HttpTransport> => {\n let client = createPublicErc4337FromClient(\n createPublicClient({\n chain,\n transport: http(rpcUrl, {\n fetchOptions: {\n headers: rpcUrl === BUNDLER_URL ? { projectId, bundlerProvider } : {},\n },\n name: \"Connected bundler network\",\n key: \"connected-bundler-network\",\n }),\n })\n );\n\n return client;\n};\n"]}
1
+ {"version":3,"file":"create-client.js","sourceRoot":"","sources":["../../../../src/kernel-zerodev/client/create-client.ts"],"names":[],"mappings":";;;AAAA,8CAK0B;AAC1B,+BAAoE;AACpE,kDAAgE;AAYhE,SAAS,0BAA0B,CACjC,QAAgB;IAEhB,OACE;QACE,uBAAuB;QACvB,8BAA8B;QAC9B,6BAA6B;QAC7B,4BAA4B;QAC5B,0BAA0B;QAC1B,0BAA0B;KAE7B,CAAC,QAAQ,CAAC,QAAqC,CAAC,CAAC;AACpD,CAAC;AAEM,MAAM,gCAAgC,GAAG,CAAC,EAC/C,KAAK,EACL,MAAM,EACN,SAAS,EACT,eAAe,GACK,EAAsC,EAAE;IAC5D,MAAM,gBAAgB,GAAG,IAAA,WAAI,EAAC,MAAM,EAAE;QACpC,YAAY,EAAE;YACZ,OAAO,EAAE,MAAM,KAAK,0BAAW,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE;SACtE;QACD,IAAI,EAAE,2BAA2B;QACjC,GAAG,EAAE,2BAA2B;KACjC,CAAC,CAAC;IACH,MAAM,eAAe,GAAG,IAAA,WAAI,EAAC,+BAAgB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;IACzD,IAAI,MAAM,GAAG,IAAA,uCAA6B,EACxC,IAAA,yBAAkB,EAAC;QACjB,KAAK;QACL,SAAS,EAAE,IAAA,aAAM,EAAC;YAChB,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE;gBAC9B,IAAI,QAAQ,CAAC;gBACb,IAAI,0BAA0B,CAAC,MAAM,CAAC,EAAE;oBACtC,QAAQ,GAAG,MAAM,gBAAgB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC;wBACnD,MAAM;wBACN,MAAM;qBACA,CAAC,CAAC;iBACX;qBAAM;oBACL,QAAQ,GAAG,MAAM,eAAe,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC;wBAClD,MAAM;wBACN,MAAM;qBACA,CAAC,CAAC;iBACX;gBACD,OAAO,QAAQ,CAAC;YAClB,CAAC;SACF,CAAC;KACH,CAAC,CACH,CAAC;IAEF,OAAO,MAAuD,CAAC;AACjE,CAAC,CAAC;AAtCW,QAAA,gCAAgC,oCAsC3C","sourcesContent":["import {\n createPublicErc4337FromClient,\n type PublicErc4337Client,\n type Erc337RpcSchema,\n type HttpTransport,\n} from \"@alchemy/aa-core\";\nimport { http, createPublicClient, type Chain, custom } from \"viem\";\nimport { BUNDLER_URL, CHAIN_ID_TO_NODE } from \"../constants.js\";\nimport type { PaymasterAndBundlerProviders } from \"../paymaster/types.js\";\n\ninterface ZeroDevClientConfig {\n chain: Chain;\n projectId: string;\n rpcUrl?: string;\n bundlerProvider?: PaymasterAndBundlerProviders;\n}\n\ntype MethodsOfErc4337RpcSchema = Erc337RpcSchema[number][\"Method\"];\n\nfunction isMethodInErc4337RpcSchema(\n variable: string\n): variable is MethodsOfErc4337RpcSchema {\n return (\n [\n \"eth_sendUserOperation\",\n \"eth_estimateUserOperationGas\",\n \"eth_getUserOperationReceipt\",\n \"eth_getUserOperationByHash\",\n \"eth_supportedEntryPoints\",\n \"eth_maxPriorityFeePerGas\",\n ] as const\n ).includes(variable as MethodsOfErc4337RpcSchema);\n}\n\nexport const createZeroDevPublicErc4337Client = ({\n chain,\n rpcUrl,\n projectId,\n bundlerProvider,\n}: ZeroDevClientConfig): PublicErc4337Client<HttpTransport> => {\n const erc4337Transport = http(rpcUrl, {\n fetchOptions: {\n headers: rpcUrl === BUNDLER_URL ? { projectId, bundlerProvider } : {},\n },\n name: \"Connected bundler network\",\n key: \"connected-bundler-network\",\n });\n const publicTransport = http(CHAIN_ID_TO_NODE[chain.id]);\n let client = createPublicErc4337FromClient(\n createPublicClient({\n chain,\n transport: custom({\n async request({ method, params }) {\n let response;\n if (isMethodInErc4337RpcSchema(method)) {\n response = await erc4337Transport({ chain }).request({\n method,\n params,\n } as any);\n } else {\n response = await publicTransport({ chain }).request({\n method,\n params,\n } as any);\n }\n return response;\n },\n }),\n })\n );\n\n return client as unknown as PublicErc4337Client<HttpTransport>;\n};\n"]}
@@ -1,4 +1,4 @@
1
- import { type HttpTransport, type PublicErc4337Client } from "@alchemy/aa-core";
1
+ import { type PublicErc4337Client, type HttpTransport } from "@alchemy/aa-core";
2
2
  import { type Chain } from "viem";
3
3
  import type { PaymasterAndBundlerProviders } from "../paymaster/types.js";
4
4
  interface ZeroDevClientConfig {
@@ -1,15 +1,44 @@
1
1
  import { createPublicErc4337FromClient, } from "@alchemy/aa-core";
2
- import { http, createPublicClient } from "viem";
3
- import { BUNDLER_URL } from "../constants.js";
2
+ import { http, createPublicClient, custom } from "viem";
3
+ import { BUNDLER_URL, CHAIN_ID_TO_NODE } from "../constants.js";
4
+ function isMethodInErc4337RpcSchema(variable) {
5
+ return [
6
+ "eth_sendUserOperation",
7
+ "eth_estimateUserOperationGas",
8
+ "eth_getUserOperationReceipt",
9
+ "eth_getUserOperationByHash",
10
+ "eth_supportedEntryPoints",
11
+ "eth_maxPriorityFeePerGas",
12
+ ].includes(variable);
13
+ }
4
14
  export const createZeroDevPublicErc4337Client = ({ chain, rpcUrl, projectId, bundlerProvider, }) => {
15
+ const erc4337Transport = http(rpcUrl, {
16
+ fetchOptions: {
17
+ headers: rpcUrl === BUNDLER_URL ? { projectId, bundlerProvider } : {},
18
+ },
19
+ name: "Connected bundler network",
20
+ key: "connected-bundler-network",
21
+ });
22
+ const publicTransport = http(CHAIN_ID_TO_NODE[chain.id]);
5
23
  let client = createPublicErc4337FromClient(createPublicClient({
6
24
  chain,
7
- transport: http(rpcUrl, {
8
- fetchOptions: {
9
- headers: rpcUrl === BUNDLER_URL ? { projectId, bundlerProvider } : {},
25
+ transport: custom({
26
+ async request({ method, params }) {
27
+ let response;
28
+ if (isMethodInErc4337RpcSchema(method)) {
29
+ response = await erc4337Transport({ chain }).request({
30
+ method,
31
+ params,
32
+ });
33
+ }
34
+ else {
35
+ response = await publicTransport({ chain }).request({
36
+ method,
37
+ params,
38
+ });
39
+ }
40
+ return response;
10
41
  },
11
- name: "Connected bundler network",
12
- key: "connected-bundler-network",
13
42
  }),
14
43
  }));
15
44
  return client;
@@ -1 +1 @@
1
- {"version":3,"file":"create-client.js","sourceRoot":"","sources":["../../../../src/kernel-zerodev/client/create-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,GAG9B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAc,MAAM,MAAM,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAU9C,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,EAC/C,KAAK,EACL,MAAM,EACN,SAAS,EACT,eAAe,GACK,EAAsC,EAAE;IAC5D,IAAI,MAAM,GAAG,6BAA6B,CACxC,kBAAkB,CAAC;QACjB,KAAK;QACL,SAAS,EAAE,IAAI,CAAC,MAAM,EAAE;YACtB,YAAY,EAAE;gBACZ,OAAO,EAAE,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE;aACtE;YACD,IAAI,EAAE,2BAA2B;YACjC,GAAG,EAAE,2BAA2B;SACjC,CAAC;KACH,CAAC,CACH,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import {\n createPublicErc4337FromClient,\n type HttpTransport,\n type PublicErc4337Client,\n} from \"@alchemy/aa-core\";\nimport { http, createPublicClient, type Chain } from \"viem\";\nimport { BUNDLER_URL } from \"../constants.js\";\nimport type { PaymasterAndBundlerProviders } from \"../paymaster/types.js\";\n\ninterface ZeroDevClientConfig {\n chain: Chain;\n projectId: string;\n rpcUrl?: string;\n bundlerProvider?: PaymasterAndBundlerProviders;\n}\n\nexport const createZeroDevPublicErc4337Client = ({\n chain,\n rpcUrl,\n projectId,\n bundlerProvider,\n}: ZeroDevClientConfig): PublicErc4337Client<HttpTransport> => {\n let client = createPublicErc4337FromClient(\n createPublicClient({\n chain,\n transport: http(rpcUrl, {\n fetchOptions: {\n headers: rpcUrl === BUNDLER_URL ? { projectId, bundlerProvider } : {},\n },\n name: \"Connected bundler network\",\n key: \"connected-bundler-network\",\n }),\n })\n );\n\n return client;\n};\n"]}
1
+ {"version":3,"file":"create-client.js","sourceRoot":"","sources":["../../../../src/kernel-zerodev/client/create-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,GAI9B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAc,MAAM,EAAE,MAAM,MAAM,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAYhE,SAAS,0BAA0B,CACjC,QAAgB;IAEhB,OACE;QACE,uBAAuB;QACvB,8BAA8B;QAC9B,6BAA6B;QAC7B,4BAA4B;QAC5B,0BAA0B;QAC1B,0BAA0B;KAE7B,CAAC,QAAQ,CAAC,QAAqC,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,EAC/C,KAAK,EACL,MAAM,EACN,SAAS,EACT,eAAe,GACK,EAAsC,EAAE;IAC5D,MAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,EAAE;QACpC,YAAY,EAAE;YACZ,OAAO,EAAE,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE;SACtE;QACD,IAAI,EAAE,2BAA2B;QACjC,GAAG,EAAE,2BAA2B;KACjC,CAAC,CAAC;IACH,MAAM,eAAe,GAAG,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;IACzD,IAAI,MAAM,GAAG,6BAA6B,CACxC,kBAAkB,CAAC;QACjB,KAAK;QACL,SAAS,EAAE,MAAM,CAAC;YAChB,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE;gBAC9B,IAAI,QAAQ,CAAC;gBACb,IAAI,0BAA0B,CAAC,MAAM,CAAC,EAAE;oBACtC,QAAQ,GAAG,MAAM,gBAAgB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC;wBACnD,MAAM;wBACN,MAAM;qBACA,CAAC,CAAC;iBACX;qBAAM;oBACL,QAAQ,GAAG,MAAM,eAAe,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC;wBAClD,MAAM;wBACN,MAAM;qBACA,CAAC,CAAC;iBACX;gBACD,OAAO,QAAQ,CAAC;YAClB,CAAC;SACF,CAAC;KACH,CAAC,CACH,CAAC;IAEF,OAAO,MAAuD,CAAC;AACjE,CAAC,CAAC","sourcesContent":["import {\n createPublicErc4337FromClient,\n type PublicErc4337Client,\n type Erc337RpcSchema,\n type HttpTransport,\n} from \"@alchemy/aa-core\";\nimport { http, createPublicClient, type Chain, custom } from \"viem\";\nimport { BUNDLER_URL, CHAIN_ID_TO_NODE } from \"../constants.js\";\nimport type { PaymasterAndBundlerProviders } from \"../paymaster/types.js\";\n\ninterface ZeroDevClientConfig {\n chain: Chain;\n projectId: string;\n rpcUrl?: string;\n bundlerProvider?: PaymasterAndBundlerProviders;\n}\n\ntype MethodsOfErc4337RpcSchema = Erc337RpcSchema[number][\"Method\"];\n\nfunction isMethodInErc4337RpcSchema(\n variable: string\n): variable is MethodsOfErc4337RpcSchema {\n return (\n [\n \"eth_sendUserOperation\",\n \"eth_estimateUserOperationGas\",\n \"eth_getUserOperationReceipt\",\n \"eth_getUserOperationByHash\",\n \"eth_supportedEntryPoints\",\n \"eth_maxPriorityFeePerGas\",\n ] as const\n ).includes(variable as MethodsOfErc4337RpcSchema);\n}\n\nexport const createZeroDevPublicErc4337Client = ({\n chain,\n rpcUrl,\n projectId,\n bundlerProvider,\n}: ZeroDevClientConfig): PublicErc4337Client<HttpTransport> => {\n const erc4337Transport = http(rpcUrl, {\n fetchOptions: {\n headers: rpcUrl === BUNDLER_URL ? { projectId, bundlerProvider } : {},\n },\n name: \"Connected bundler network\",\n key: \"connected-bundler-network\",\n });\n const publicTransport = http(CHAIN_ID_TO_NODE[chain.id]);\n let client = createPublicErc4337FromClient(\n createPublicClient({\n chain,\n transport: custom({\n async request({ method, params }) {\n let response;\n if (isMethodInErc4337RpcSchema(method)) {\n response = await erc4337Transport({ chain }).request({\n method,\n params,\n } as any);\n } else {\n response = await publicTransport({ chain }).request({\n method,\n params,\n } as any);\n }\n return response;\n },\n }),\n })\n );\n\n return client as unknown as PublicErc4337Client<HttpTransport>;\n};\n"]}
@@ -1,4 +1,4 @@
1
- import { type HttpTransport, type PublicErc4337Client } from "@alchemy/aa-core";
1
+ import { type PublicErc4337Client, type HttpTransport } from "@alchemy/aa-core";
2
2
  import { type Chain } from "viem";
3
3
  import type { PaymasterAndBundlerProviders } from "../paymaster/types.js";
4
4
  interface ZeroDevClientConfig {
@@ -1 +1 @@
1
- {"version":3,"file":"create-client.d.ts","sourceRoot":"","sources":["../../../../src/kernel-zerodev/client/create-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACzB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAA4B,KAAK,KAAK,EAAE,MAAM,MAAM,CAAC;AAE5D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAE1E,UAAU,mBAAmB;IAC3B,KAAK,EAAE,KAAK,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,4BAA4B,CAAC;CAChD;AAED,eAAO,MAAM,gCAAgC,mDAK1C,mBAAmB,KAAG,oBAAoB,aAAa,CAezD,CAAC"}
1
+ {"version":3,"file":"create-client.d.ts","sourceRoot":"","sources":["../../../../src/kernel-zerodev/client/create-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,mBAAmB,EAExB,KAAK,aAAa,EACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAA4B,KAAK,KAAK,EAAU,MAAM,MAAM,CAAC;AAEpE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAE1E,UAAU,mBAAmB;IAC3B,KAAK,EAAE,KAAK,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,4BAA4B,CAAC;CAChD;AAmBD,eAAO,MAAM,gCAAgC,mDAK1C,mBAAmB,KAAG,oBAAoB,aAAa,CAiCzD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerodev/sdk",
3
- "version": "4.0.7",
3
+ "version": "4.0.8",
4
4
  "description": "A collection of ERC-4337 compliant smart contract account interfaces",
5
5
  "author": "ZeroDev",
6
6
  "license": "MIT",
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  createPublicErc4337FromClient,
3
- type HttpTransport,
4
3
  type PublicErc4337Client,
4
+ type Erc337RpcSchema,
5
+ type HttpTransport,
5
6
  } from "@alchemy/aa-core";
6
- import { http, createPublicClient, type Chain } from "viem";
7
- import { BUNDLER_URL } from "../constants.js";
7
+ import { http, createPublicClient, type Chain, custom } from "viem";
8
+ import { BUNDLER_URL, CHAIN_ID_TO_NODE } from "../constants.js";
8
9
  import type { PaymasterAndBundlerProviders } from "../paymaster/types.js";
9
10
 
10
11
  interface ZeroDevClientConfig {
@@ -14,24 +15,59 @@ interface ZeroDevClientConfig {
14
15
  bundlerProvider?: PaymasterAndBundlerProviders;
15
16
  }
16
17
 
18
+ type MethodsOfErc4337RpcSchema = Erc337RpcSchema[number]["Method"];
19
+
20
+ function isMethodInErc4337RpcSchema(
21
+ variable: string
22
+ ): variable is MethodsOfErc4337RpcSchema {
23
+ return (
24
+ [
25
+ "eth_sendUserOperation",
26
+ "eth_estimateUserOperationGas",
27
+ "eth_getUserOperationReceipt",
28
+ "eth_getUserOperationByHash",
29
+ "eth_supportedEntryPoints",
30
+ "eth_maxPriorityFeePerGas",
31
+ ] as const
32
+ ).includes(variable as MethodsOfErc4337RpcSchema);
33
+ }
34
+
17
35
  export const createZeroDevPublicErc4337Client = ({
18
36
  chain,
19
37
  rpcUrl,
20
38
  projectId,
21
39
  bundlerProvider,
22
40
  }: ZeroDevClientConfig): PublicErc4337Client<HttpTransport> => {
41
+ const erc4337Transport = http(rpcUrl, {
42
+ fetchOptions: {
43
+ headers: rpcUrl === BUNDLER_URL ? { projectId, bundlerProvider } : {},
44
+ },
45
+ name: "Connected bundler network",
46
+ key: "connected-bundler-network",
47
+ });
48
+ const publicTransport = http(CHAIN_ID_TO_NODE[chain.id]);
23
49
  let client = createPublicErc4337FromClient(
24
50
  createPublicClient({
25
51
  chain,
26
- transport: http(rpcUrl, {
27
- fetchOptions: {
28
- headers: rpcUrl === BUNDLER_URL ? { projectId, bundlerProvider } : {},
52
+ transport: custom({
53
+ async request({ method, params }) {
54
+ let response;
55
+ if (isMethodInErc4337RpcSchema(method)) {
56
+ response = await erc4337Transport({ chain }).request({
57
+ method,
58
+ params,
59
+ } as any);
60
+ } else {
61
+ response = await publicTransport({ chain }).request({
62
+ method,
63
+ params,
64
+ } as any);
65
+ }
66
+ return response;
29
67
  },
30
- name: "Connected bundler network",
31
- key: "connected-bundler-network",
32
68
  }),
33
69
  })
34
70
  );
35
71
 
36
- return client;
72
+ return client as unknown as PublicErc4337Client<HttpTransport>;
37
73
  };