@mentaproject/core 0.6.2 → 0.6.3

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.
@@ -76,19 +76,22 @@ function createRoutedTransport(publicTransport, bundlerTransport) {
76
76
  };
77
77
  }
78
78
 
79
+ // WebAuthn Validator address for Kernel v0.3.3 (PasskeyValidator v0.0.3)
80
+ const WEBAUTHN_VALIDATOR_ADDRESS = "0x7ab16Ff354AcB328452F1D445b3Ddee9a91e9e69";
79
81
  async function createMentaAccount(client, params) {
80
82
  // Get the WebAuthnAccount from the signer
81
83
  // The signer must have a toWebAuthnAccount() method that returns
82
84
  // a viem-compatible WebAuthnAccount
83
85
  if (!("toWebAuthnAccount" in params.signer)) {
84
86
  throw new Error("Signer must have a toWebAuthnAccount() method. " +
85
- "Make sure you're using @mentaproject/signer-react-native >= 0.0.17");
87
+ "Make sure you are using @mentaproject/signer-react-native >= 0.0.17");
86
88
  }
87
89
  const webAuthnAccount = params.signer.toWebAuthnAccount();
88
90
  const kernel = await accounts.toKernelSmartAccount({
89
91
  owners: [webAuthnAccount],
90
92
  client: client,
91
93
  version: "0.3.3",
94
+ validatorAddress: WEBAUTHN_VALIDATOR_ADDRESS,
92
95
  });
93
96
  // Create a routed transport that sends bundler methods to the bundler
94
97
  // and all other RPC calls to the public transport
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/clients/createClient.ts","../../src/utils/createRoutedTransport.ts","../../src/clients/createMentaAccount.ts"],"sourcesContent":["import type { CoreClient, CoreClientConfig } from '../types';\n\nimport { createClient as viemCreateClient } from 'viem';\n\n\nexport function createClient(parameters: CoreClientConfig): CoreClient {\n const {\n client: client_,\n key = \"bundler\",\n name = \"Bundler Client\",\n paymaster,\n paymasterContext,\n transport,\n userOperation\n } = parameters\n\n const client = Object.assign(\n viemCreateClient({\n ...parameters,\n chain: parameters.chain ?? client_?.chain,\n transport,\n key,\n name,\n type: \"bundlerClient\" // TODO: Is this okay?\n }),\n { client: client_, paymaster, paymasterContext, userOperation }\n )\n\n return client;\n}","import type { EIP1193RequestFn, Transport } from \"viem\";\n\n/**\n * RPC methods that should be routed to the bundler.\n * All other methods will be routed to the public RPC.\n */\nconst BUNDLER_METHODS = new Set([\n // ERC-4337 standard methods\n \"eth_sendUserOperation\",\n \"eth_estimateUserOperationGas\",\n \"eth_getUserOperationByHash\",\n \"eth_getUserOperationReceipt\",\n \"eth_supportedEntryPoints\",\n // Pimlico-specific methods\n \"pimlico_getUserOperationGasPrice\",\n \"pimlico_getUserOperationStatus\",\n \"pimlico_sendCompressedUserOperation\",\n // pm_ paymaster methods (used by some bundlers)\n \"pm_getPaymasterData\",\n \"pm_getPaymasterStubData\",\n \"pm_sponsorUserOperation\",\n \"pm_validateSponsorshipPolicies\",\n]);\n\n/**\n * Creates a transport that routes requests between a public RPC and a bundler RPC.\n *\n * Bundler-specific methods (ERC-4337) are routed to the bundler transport,\n * while all other methods (eth_getBlockByNumber, eth_call, etc.) are routed\n * to the public transport.\n *\n * @param publicTransport - Transport for standard Ethereum RPC calls\n * @param bundlerTransport - Transport for ERC-4337 bundler calls\n * @returns A unified transport that routes requests appropriately\n *\n * @example\n * import { http } from 'viem';\n * import { createRoutedTransport } from '@mentaproject/core/utils';\n *\n * const transport = createRoutedTransport(\n * http('https://eth-mainnet.g.alchemy.com/v2/...'),\n * http('https://api.pimlico.io/v2/1/rpc?apikey=...')\n * );\n */\nexport function createRoutedTransport(\n publicTransport: Transport,\n bundlerTransport: Transport,\n): Transport {\n return (params) => {\n const publicClient = publicTransport(params);\n const bundlerClient = bundlerTransport(params);\n\n const request: EIP1193RequestFn = async ({ method, params: reqParams }) => {\n if (BUNDLER_METHODS.has(method)) {\n return bundlerClient.request({ method, params: reqParams } as any);\n }\n return publicClient.request({ method, params: reqParams } as any);\n };\n\n return {\n ...publicClient,\n request,\n };\n };\n}\n","import { MentaAccountParams } from \"../types\";\nimport { toKernelSmartAccount } from \"permissionless/accounts\";\nimport { createSmartAccountClient } from \"permissionless\";\nimport { erc7579Actions } from \"permissionless/actions/erc7579\";\nimport { createRoutedTransport } from \"../utils/createRoutedTransport\";\nimport type { Client, Transport, Chain, Account } from \"viem\";\n\nexport async function createMentaAccount<TChain extends Chain | undefined>(\n client: Client<Transport, TChain, Account | undefined>,\n params: MentaAccountParams,\n) {\n // Get the WebAuthnAccount from the signer\n // The signer must have a toWebAuthnAccount() method that returns\n // a viem-compatible WebAuthnAccount\n if (!(\"toWebAuthnAccount\" in params.signer)) {\n throw new Error(\n \"Signer must have a toWebAuthnAccount() method. \" +\n \"Make sure you're using @mentaproject/signer-react-native >= 0.0.17\"\n );\n }\n\n const webAuthnAccount = (params.signer as any).toWebAuthnAccount();\n\n const kernel = await toKernelSmartAccount({\n owners: [webAuthnAccount],\n client: client as any,\n version: \"0.3.3\",\n });\n\n // Create a routed transport that sends bundler methods to the bundler\n // and all other RPC calls to the public transport\n const routedTransport = createRoutedTransport(\n params.publicTransport,\n params.bundlerTransport,\n );\n\n return createSmartAccountClient({\n account: kernel,\n bundlerTransport: routedTransport,\n }).extend(erc7579Actions());\n}\n"],"names":["viemCreateClient","toKernelSmartAccount","createSmartAccountClient","erc7579Actions"],"mappings":";;;;;;;AAKM,SAAU,YAAY,CAAC,UAA4B,EAAA;IACrD,MAAM,EACF,MAAM,EAAE,OAAO,EACf,GAAG,GAAG,SAAS,EACf,IAAI,GAAG,gBAAgB,EACvB,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,aAAa,EAChB,GAAG,UAAU;AAEd,IAAA,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CACxBA,iBAAgB,CAAC;AACb,QAAA,GAAG,UAAU;AACb,QAAA,KAAK,EAAE,UAAU,CAAC,KAAK,IAAI,OAAO,EAAE,KAAK;QACzC,SAAS;QACT,GAAG;QACH,IAAI;QACJ,IAAI,EAAE,eAAe;AACxB,KAAA,CAAC,EACF,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAg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IAAA,MAAM,MAAM,GAAG,MAAMC,6BAAoB,CAAC;QACxC,MAAM,EAAE,CAAC,eAAe,CAAC;AACzB,QAAA,MAAM,EAAE,MAAa;AACrB,QAAA,OAAO,EAAE,OAAO;AACjB,KAAA,CAAC;;;AAIF,IAAA,MAAM,eAAe,GAAG,qBAAqB,CAC3C,MAAM,CAAC,eAAe,EACtB,MAAM,CAAC,gBAAgB,CACxB;AAED,IAAA,OAAOC,uCAAwB,CAAC;AAC9B,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,gBAAgB,EAAE,eAAe;AAClC,KAAA,CAAC,CAAC,MAAM,CAACC,sBAAc,EAAE,CAAC;AAC7B;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/clients/createClient.ts","../../src/utils/createRoutedTransport.ts","../../src/clients/createMentaAccount.ts"],"sourcesContent":["import type { CoreClient, CoreClientConfig } from '../types';\n\nimport { createClient as viemCreateClient } from 'viem';\n\n\nexport function createClient(parameters: CoreClientConfig): CoreClient {\n const {\n client: client_,\n key = \"bundler\",\n name = \"Bundler Client\",\n paymaster,\n paymasterContext,\n transport,\n userOperation\n } = parameters\n\n const client = Object.assign(\n viemCreateClient({\n ...parameters,\n chain: parameters.chain ?? client_?.chain,\n transport,\n key,\n name,\n type: \"bundlerClient\" // TODO: Is this okay?\n }),\n { client: client_, paymaster, paymasterContext, userOperation }\n )\n\n return client;\n}","import type { EIP1193RequestFn, Transport } from \"viem\";\n\n/**\n * RPC methods that should be routed to the bundler.\n * All other methods will be routed to the public RPC.\n */\nconst BUNDLER_METHODS = new Set([\n // ERC-4337 standard methods\n \"eth_sendUserOperation\",\n \"eth_estimateUserOperationGas\",\n \"eth_getUserOperationByHash\",\n \"eth_getUserOperationReceipt\",\n \"eth_supportedEntryPoints\",\n // Pimlico-specific methods\n \"pimlico_getUserOperationGasPrice\",\n \"pimlico_getUserOperationStatus\",\n \"pimlico_sendCompressedUserOperation\",\n // pm_ paymaster methods (used by some bundlers)\n \"pm_getPaymasterData\",\n \"pm_getPaymasterStubData\",\n \"pm_sponsorUserOperation\",\n \"pm_validateSponsorshipPolicies\",\n]);\n\n/**\n * Creates a transport that routes requests between a public RPC and a bundler RPC.\n *\n * Bundler-specific methods (ERC-4337) are routed to the bundler transport,\n * while all other methods (eth_getBlockByNumber, eth_call, etc.) are routed\n * to the public transport.\n *\n * @param publicTransport - Transport for standard Ethereum RPC calls\n * @param bundlerTransport - Transport for ERC-4337 bundler calls\n * @returns A unified transport that routes requests appropriately\n *\n * @example\n * import { http } from 'viem';\n * import { createRoutedTransport } from '@mentaproject/core/utils';\n *\n * const transport = createRoutedTransport(\n * http('https://eth-mainnet.g.alchemy.com/v2/...'),\n * http('https://api.pimlico.io/v2/1/rpc?apikey=...')\n * );\n */\nexport function createRoutedTransport(\n publicTransport: Transport,\n bundlerTransport: Transport,\n): Transport {\n return (params) => {\n const publicClient = publicTransport(params);\n const bundlerClient = bundlerTransport(params);\n\n const request: EIP1193RequestFn = async ({ method, params: reqParams }) => {\n if (BUNDLER_METHODS.has(method)) {\n return bundlerClient.request({ method, params: reqParams } as any);\n }\n return publicClient.request({ method, params: reqParams } as any);\n };\n\n return {\n ...publicClient,\n request,\n };\n };\n}\n","import { MentaAccountParams } from \"../types\";\nimport { toKernelSmartAccount } from \"permissionless/accounts\";\nimport { createSmartAccountClient } from \"permissionless\";\nimport { erc7579Actions } from \"permissionless/actions/erc7579\";\nimport { createRoutedTransport } from \"../utils/createRoutedTransport\";\nimport type { Client, Transport, Chain, Account } from \"viem\";\n\n// WebAuthn Validator address for Kernel v0.3.3 (PasskeyValidator v0.0.3)\nconst WEBAUTHN_VALIDATOR_ADDRESS = \"0x7ab16Ff354AcB328452F1D445b3Ddee9a91e9e69\" as const;\n\nexport async function createMentaAccount<TChain extends Chain | undefined>(\n client: Client<Transport, TChain, Account | undefined>,\n params: MentaAccountParams,\n) {\n // Get the WebAuthnAccount from the signer\n // The signer must have a toWebAuthnAccount() method that returns\n // a viem-compatible WebAuthnAccount\n if (!(\"toWebAuthnAccount\" in params.signer)) {\n throw new Error(\n \"Signer must have a toWebAuthnAccount() method. \" +\n \"Make sure you are using @mentaproject/signer-react-native >= 0.0.17\"\n );\n }\n\n const webAuthnAccount = (params.signer as any).toWebAuthnAccount();\n\n const kernel = await toKernelSmartAccount({\n owners: [webAuthnAccount],\n client: client as any,\n version: \"0.3.3\",\n validatorAddress: WEBAUTHN_VALIDATOR_ADDRESS,\n });\n\n // Create a routed transport that sends bundler methods to the bundler\n // and all other RPC calls to the public transport\n const routedTransport = createRoutedTransport(\n params.publicTransport,\n params.bundlerTransport,\n );\n\n return createSmartAccountClient({\n account: kernel,\n bundlerTransport: routedTransport,\n }).extend(erc7579Actions());\n}\n"],"names":["viemCreateClient","toKernelSmartAccount","createSmartAccountClient","erc7579Actions"],"mappings":";;;;;;;AAKM,SAAU,YAAY,CAAC,UAA4B,EAAA;IACrD,MAAM,EACF,MAAM,EAAE,OAAO,EACf,GAAG,GAAG,SAAS,EACf,IAAI,GAAG,gBAAgB,EACvB,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,aAAa,EAChB,GAAG,UAAU;AAEd,IAAA,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CACxBA,iBAAgB,CAAC;AACb,QAAA,GAAG,UAAU;AACb,QAAA,KAAK,EAAE,UAAU,CAAC,KAAK,IAAI,OAAO,EAAE,KAAK;QACzC,SAAS;QACT,GAAG;QACH,IAAI;QACJ,IAAI,EAAE,eAAe;AACxB,KAAA,CAAC,EACF,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,aAAa,EAAE,CAClE;AAED,IAAA,OAAO,MAAM;AACjB;;AC3BA;;;AAGG;AACH,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;;IAE9B,uBAAuB;IACvB,8BAA8B;IAC9B,4BAA4B;IAC5B,6BAA6B;IAC7B,0BAA0B;;IAE1B,kCAAkC;IAClC,gCAAgC;IAChC,qCAAqC;;IAErC,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,IAAA,MAAM,eAAe,GAAG,qBAAqB,CAC3C,MAAM,CAAC,eAAe,EACtB,MAAM,CAAC,gBAAgB,CACxB;AAED,IAAA,OAAOC,uCAAwB,CAAC;AAC9B,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,gBAAgB,EAAE,eAAe;AAClC,KAAA,CAAC,CAAC,MAAM,CAACC,sBAAc,EAAE,CAAC;AAC7B;;;;;"}
@@ -74,19 +74,22 @@ function createRoutedTransport(publicTransport, bundlerTransport) {
74
74
  };
75
75
  }
76
76
 
77
+ // WebAuthn Validator address for Kernel v0.3.3 (PasskeyValidator v0.0.3)
78
+ const WEBAUTHN_VALIDATOR_ADDRESS = "0x7ab16Ff354AcB328452F1D445b3Ddee9a91e9e69";
77
79
  async function createMentaAccount(client, params) {
78
80
  // Get the WebAuthnAccount from the signer
79
81
  // The signer must have a toWebAuthnAccount() method that returns
80
82
  // a viem-compatible WebAuthnAccount
81
83
  if (!("toWebAuthnAccount" in params.signer)) {
82
84
  throw new Error("Signer must have a toWebAuthnAccount() method. " +
83
- "Make sure you're using @mentaproject/signer-react-native >= 0.0.17");
85
+ "Make sure you are using @mentaproject/signer-react-native >= 0.0.17");
84
86
  }
85
87
  const webAuthnAccount = params.signer.toWebAuthnAccount();
86
88
  const kernel = await toKernelSmartAccount({
87
89
  owners: [webAuthnAccount],
88
90
  client: client,
89
91
  version: "0.3.3",
92
+ validatorAddress: WEBAUTHN_VALIDATOR_ADDRESS,
90
93
  });
91
94
  // Create a routed transport that sends bundler methods to the bundler
92
95
  // and all other RPC calls to the public transport
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/clients/createClient.ts","../../src/utils/createRoutedTransport.ts","../../src/clients/createMentaAccount.ts"],"sourcesContent":["import type { CoreClient, CoreClientConfig } from '../types';\n\nimport { createClient as viemCreateClient } from 'viem';\n\n\nexport function createClient(parameters: CoreClientConfig): CoreClient {\n const {\n client: client_,\n key = \"bundler\",\n name = \"Bundler Client\",\n paymaster,\n paymasterContext,\n transport,\n userOperation\n } = parameters\n\n const client = Object.assign(\n viemCreateClient({\n ...parameters,\n chain: parameters.chain ?? client_?.chain,\n transport,\n key,\n name,\n type: \"bundlerClient\" // TODO: Is this okay?\n }),\n { client: client_, paymaster, paymasterContext, userOperation }\n )\n\n return client;\n}","import type { EIP1193RequestFn, Transport } from \"viem\";\n\n/**\n * RPC methods that should be routed to the bundler.\n * All other methods will be routed to the public RPC.\n */\nconst BUNDLER_METHODS = new Set([\n // ERC-4337 standard methods\n \"eth_sendUserOperation\",\n \"eth_estimateUserOperationGas\",\n \"eth_getUserOperationByHash\",\n \"eth_getUserOperationReceipt\",\n \"eth_supportedEntryPoints\",\n // Pimlico-specific methods\n \"pimlico_getUserOperationGasPrice\",\n \"pimlico_getUserOperationStatus\",\n \"pimlico_sendCompressedUserOperation\",\n // pm_ paymaster methods (used by some bundlers)\n \"pm_getPaymasterData\",\n \"pm_getPaymasterStubData\",\n \"pm_sponsorUserOperation\",\n \"pm_validateSponsorshipPolicies\",\n]);\n\n/**\n * Creates a transport that routes requests between a public RPC and a bundler RPC.\n *\n * Bundler-specific methods (ERC-4337) are routed to the bundler transport,\n * while all other methods (eth_getBlockByNumber, eth_call, etc.) are routed\n * to the public transport.\n *\n * @param publicTransport - Transport for standard Ethereum RPC calls\n * @param bundlerTransport - Transport for ERC-4337 bundler calls\n * @returns A unified transport that routes requests appropriately\n *\n * @example\n * import { http } from 'viem';\n * import { createRoutedTransport } from '@mentaproject/core/utils';\n *\n * const transport = createRoutedTransport(\n * http('https://eth-mainnet.g.alchemy.com/v2/...'),\n * http('https://api.pimlico.io/v2/1/rpc?apikey=...')\n * );\n */\nexport function createRoutedTransport(\n publicTransport: Transport,\n bundlerTransport: Transport,\n): Transport {\n return (params) => {\n const publicClient = publicTransport(params);\n const bundlerClient = bundlerTransport(params);\n\n const request: EIP1193RequestFn = async ({ method, params: reqParams }) => {\n if (BUNDLER_METHODS.has(method)) {\n return bundlerClient.request({ method, params: reqParams } as any);\n }\n return publicClient.request({ method, params: reqParams } as any);\n };\n\n return {\n ...publicClient,\n request,\n };\n };\n}\n","import { MentaAccountParams } from \"../types\";\nimport { toKernelSmartAccount } from \"permissionless/accounts\";\nimport { createSmartAccountClient } from \"permissionless\";\nimport { erc7579Actions } from \"permissionless/actions/erc7579\";\nimport { createRoutedTransport } from \"../utils/createRoutedTransport\";\nimport type { Client, Transport, Chain, Account } from \"viem\";\n\nexport async function createMentaAccount<TChain extends Chain | undefined>(\n client: Client<Transport, TChain, Account | undefined>,\n params: MentaAccountParams,\n) {\n // Get the WebAuthnAccount from the signer\n // The signer must have a toWebAuthnAccount() method that returns\n // a viem-compatible WebAuthnAccount\n if (!(\"toWebAuthnAccount\" in params.signer)) {\n throw new Error(\n \"Signer must have a toWebAuthnAccount() method. \" +\n \"Make sure you're using @mentaproject/signer-react-native >= 0.0.17\"\n );\n }\n\n const webAuthnAccount = (params.signer as any).toWebAuthnAccount();\n\n const kernel = await toKernelSmartAccount({\n owners: [webAuthnAccount],\n client: client as any,\n version: \"0.3.3\",\n });\n\n // Create a routed transport that sends bundler methods to the bundler\n // and all other RPC calls to the public transport\n const routedTransport = createRoutedTransport(\n params.publicTransport,\n params.bundlerTransport,\n );\n\n return createSmartAccountClient({\n account: kernel,\n bundlerTransport: routedTransport,\n }).extend(erc7579Actions());\n}\n"],"names":["viemCreateClient"],"mappings":";;;;;AAKM,SAAU,YAAY,CAAC,UAA4B,EAAA;IACrD,MAAM,EACF,MAAM,EAAE,OAAO,EACf,GAAG,GAAG,SAAS,EACf,IAAI,GAAG,gBAAgB,EACvB,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,aAAa,EAChB,GAAG,UAAU;AAEd,IAAA,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CACxBA,cAAgB,CAAC;AACb,QAAA,GAAG,UAAU;AACb,QAAA,KAAK,EAAE,UAAU,CAAC,KAAK,IAAI,OAAO,EAAE,KAAK;QACzC,SAAS;QACT,GAAG;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AiD;AAC/C,YAAA,oEAAoE,CACvE;IACH;IAEA,MAAM,eAAe,GAAI,MAAM,CAAC,MAAc,CAAC,iBAAiB,EAAE;AAElE,IAAA,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC;QACxC,MAAM,EAAE,CAAC,eAAe,CAAC;AACzB,QAAA,MAAM,EAAE,MAAa;AACrB,QAAA,OAAO,EAAE,OAAO;AACjB,KAAA,CAAC;;;AAIF,IAAA,MAAM,eAAe,GAAG,qBAAqB,CAC3C,MAAM,CAAC,eAAe,EACtB,MAAM,CAAC,gBAAgB,CACxB;AAED,IAAA,OAAO,wBAAwB,CAAC;AAC9B,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,gBAAgB,EAAE,eAAe;AAClC,KAAA,CAAC,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;AAC7B;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../src/clients/createClient.ts","../../src/utils/createRoutedTransport.ts","../../src/clients/createMentaAccount.ts"],"sourcesContent":["import type { CoreClient, CoreClientConfig } from '../types';\n\nimport { createClient as viemCreateClient } from 'viem';\n\n\nexport function createClient(parameters: CoreClientConfig): CoreClient {\n const {\n client: client_,\n key = \"bundler\",\n name = \"Bundler Client\",\n paymaster,\n paymasterContext,\n transport,\n userOperation\n } = parameters\n\n const client = Object.assign(\n viemCreateClient({\n ...parameters,\n chain: parameters.chain ?? client_?.chain,\n transport,\n key,\n name,\n type: \"bundlerClient\" // TODO: Is this okay?\n }),\n { client: client_, paymaster, paymasterContext, userOperation }\n )\n\n return client;\n}","import type { EIP1193RequestFn, Transport } from \"viem\";\n\n/**\n * RPC methods that should be routed to the bundler.\n * All other methods will be routed to the public RPC.\n */\nconst BUNDLER_METHODS = new Set([\n // ERC-4337 standard methods\n \"eth_sendUserOperation\",\n \"eth_estimateUserOperationGas\",\n \"eth_getUserOperationByHash\",\n \"eth_getUserOperationReceipt\",\n \"eth_supportedEntryPoints\",\n // Pimlico-specific methods\n \"pimlico_getUserOperationGasPrice\",\n \"pimlico_getUserOperationStatus\",\n \"pimlico_sendCompressedUserOperation\",\n // pm_ paymaster methods (used by some bundlers)\n \"pm_getPaymasterData\",\n \"pm_getPaymasterStubData\",\n \"pm_sponsorUserOperation\",\n \"pm_validateSponsorshipPolicies\",\n]);\n\n/**\n * Creates a transport that routes requests between a public RPC and a bundler RPC.\n *\n * Bundler-specific methods (ERC-4337) are routed to the bundler transport,\n * while all other methods (eth_getBlockByNumber, eth_call, etc.) are routed\n * to the public transport.\n *\n * @param publicTransport - Transport for standard Ethereum RPC calls\n * @param bundlerTransport - Transport for ERC-4337 bundler calls\n * @returns A unified transport that routes requests appropriately\n *\n * @example\n * import { http } from 'viem';\n * import { createRoutedTransport } from '@mentaproject/core/utils';\n *\n * const transport = createRoutedTransport(\n * http('https://eth-mainnet.g.alchemy.com/v2/...'),\n * http('https://api.pimlico.io/v2/1/rpc?apikey=...')\n * );\n */\nexport function createRoutedTransport(\n publicTransport: Transport,\n bundlerTransport: Transport,\n): Transport {\n return (params) => {\n const publicClient = publicTransport(params);\n const bundlerClient = bundlerTransport(params);\n\n const request: EIP1193RequestFn = async ({ method, params: reqParams }) => {\n if (BUNDLER_METHODS.has(method)) {\n return bundlerClient.request({ method, params: reqParams } as any);\n }\n return publicClient.request({ method, params: reqParams } as any);\n };\n\n return {\n ...publicClient,\n request,\n };\n };\n}\n","import { MentaAccountParams } from \"../types\";\nimport { toKernelSmartAccount } from \"permissionless/accounts\";\nimport { createSmartAccountClient } from \"permissionless\";\nimport { erc7579Actions } from \"permissionless/actions/erc7579\";\nimport { createRoutedTransport } from \"../utils/createRoutedTransport\";\nimport type { Client, Transport, Chain, Account } from \"viem\";\n\n// WebAuthn Validator address for Kernel v0.3.3 (PasskeyValidator v0.0.3)\nconst WEBAUTHN_VALIDATOR_ADDRESS = \"0x7ab16Ff354AcB328452F1D445b3Ddee9a91e9e69\" as const;\n\nexport async function createMentaAccount<TChain extends Chain | undefined>(\n client: Client<Transport, TChain, Account | undefined>,\n params: MentaAccountParams,\n) {\n // Get the WebAuthnAccount from the signer\n // The signer must have a toWebAuthnAccount() method that returns\n // a viem-compatible WebAuthnAccount\n if (!(\"toWebAuthnAccount\" in params.signer)) {\n throw new Error(\n \"Signer must have a toWebAuthnAccount() method. \" +\n \"Make sure you are using @mentaproject/signer-react-native >= 0.0.17\"\n );\n }\n\n const webAuthnAccount = (params.signer as any).toWebAuthnAccount();\n\n const kernel = await toKernelSmartAccount({\n owners: [webAuthnAccount],\n client: client as any,\n version: \"0.3.3\",\n validatorAddress: WEBAUTHN_VALIDATOR_ADDRESS,\n });\n\n // Create a routed transport that sends bundler methods to the bundler\n // and all other RPC calls to the public transport\n const routedTransport = createRoutedTransport(\n params.publicTransport,\n params.bundlerTransport,\n );\n\n return createSmartAccountClient({\n account: kernel,\n bundlerTransport: routedTransport,\n }).extend(erc7579Actions());\n}\n"],"names":["viemCreateClient"],"mappings":";;;;;AAKM,SAAU,YAAY,CAAC,UAA4B,EAAA;IACrD,MAAM,EACF,MAAM,EAAE,OAAO,EACf,GAAG,GAAG,SAAS,EACf,IAAI,GAAG,gBAAgB,EACvB,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,aAAa,EAChB,GAAG,UAAU;AAEd,IAAA,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CACxBA,cAAgB,CAAC;AACb,QAAA,GAAG,UAAU;AACb,QAAA,KAAK,EAAE,UAAU,CAAC,KAAK,IAAI,OAAO,EAAE,KAAK;QACzC,SAAS;QACT,GAAG;QACH,IAAI;QACJ,IAAI,EAAE,eAAe;AACxB,KAAA,CAAC,EACF,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,aAAa,EAAE,CAClE;AAED,IAAA,OAAO,MAAM;AACjB;;AC3BA;;;AAGG;AACH,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;;IAE9B,uBAAuB;IACvB,8BAA8B;IAC9B,4BAA4B;IAC5B,6BAA6B;IAC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O;AAChB,QAAA,gBAAgB,EAAE,0BAA0B;AAC7C,KAAA,CAAC;;;AAIF,IAAA,MAAM,eAAe,GAAG,qBAAqB,CAC3C,MAAM,CAAC,eAAe,EACtB,MAAM,CAAC,gBAAgB,CACxB;AAED,IAAA,OAAO,wBAAwB,CAAC;AAC9B,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,gBAAgB,EAAE,eAAe;AAClC,KAAA,CAAC,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;AAC7B;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mentaproject/core",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "Core library for menta packages, it includes all basic evm instances like Account, Transactions, Blocks etc...",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -5,6 +5,9 @@ import { erc7579Actions } from "permissionless/actions/erc7579";
5
5
  import { createRoutedTransport } from "../utils/createRoutedTransport";
6
6
  import type { Client, Transport, Chain, Account } from "viem";
7
7
 
8
+ // WebAuthn Validator address for Kernel v0.3.3 (PasskeyValidator v0.0.3)
9
+ const WEBAUTHN_VALIDATOR_ADDRESS = "0x7ab16Ff354AcB328452F1D445b3Ddee9a91e9e69" as const;
10
+
8
11
  export async function createMentaAccount<TChain extends Chain | undefined>(
9
12
  client: Client<Transport, TChain, Account | undefined>,
10
13
  params: MentaAccountParams,
@@ -15,7 +18,7 @@ export async function createMentaAccount<TChain extends Chain | undefined>(
15
18
  if (!("toWebAuthnAccount" in params.signer)) {
16
19
  throw new Error(
17
20
  "Signer must have a toWebAuthnAccount() method. " +
18
- "Make sure you're using @mentaproject/signer-react-native >= 0.0.17"
21
+ "Make sure you are using @mentaproject/signer-react-native >= 0.0.17"
19
22
  );
20
23
  }
21
24
 
@@ -25,6 +28,7 @@ export async function createMentaAccount<TChain extends Chain | undefined>(
25
28
  owners: [webAuthnAccount],
26
29
  client: client as any,
27
30
  version: "0.3.3",
31
+ validatorAddress: WEBAUTHN_VALIDATOR_ADDRESS,
28
32
  });
29
33
 
30
34
  // Create a routed transport that sends bundler methods to the bundler