@mentaproject/core 0.5.15 → 0.6.1
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/clients/createMentaAccount.d.ts +12 -12
- package/dist/clients/index.js +62 -1
- package/dist/clients/index.js.map +1 -1
- package/dist/clients/index.mjs +62 -1
- package/dist/clients/index.mjs.map +1 -1
- package/dist/types/CoreClient.d.ts +14 -5
- package/dist/types/MentaAccount.d.ts +3 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/createRoutedTransport.d.ts +22 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +59 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +59 -1
- package/dist/utils/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/clients/createMentaAccount.ts +13 -6
- package/src/types/CoreClient.ts +32 -14
- package/src/types/MentaAccount.ts +3 -0
- package/src/types/index.ts +1 -1
- package/src/utils/createRoutedTransport.ts +65 -0
- package/src/utils/index.ts +2 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MentaAccountParams } from "../types";
|
|
2
|
-
import type { Client, Transport, Chain,
|
|
3
|
-
export declare function createMentaAccount<TChain extends Chain | undefined>(client: Client<Transport, TChain,
|
|
2
|
+
import type { Client, Transport, Chain, Account } from "viem";
|
|
3
|
+
export declare function createMentaAccount<TChain extends Chain | undefined>(client: Client<Transport, TChain, Account | undefined>, params: MentaAccountParams): Promise<Client<Transport, undefined, object & {
|
|
4
4
|
client: Client<Transport, Chain | undefined, {
|
|
5
5
|
address: import("abitype").Address;
|
|
6
6
|
nonceManager?: import("viem").NonceManager | undefined;
|
|
@@ -18,7 +18,7 @@ export declare function createMentaAccount<TChain extends Chain | undefined>(cli
|
|
|
18
18
|
publicKey: import("viem").Hex;
|
|
19
19
|
source: string;
|
|
20
20
|
type: "local";
|
|
21
|
-
} | JsonRpcAccount | undefined>;
|
|
21
|
+
} | import("viem").JsonRpcAccount | undefined>;
|
|
22
22
|
entryPoint: {
|
|
23
23
|
abi: readonly [{
|
|
24
24
|
readonly inputs: readonly [{
|
|
@@ -1961,7 +1961,7 @@ export declare function createMentaAccount<TChain extends Chain | undefined>(cli
|
|
|
1961
1961
|
publicKey: import("viem").Hex;
|
|
1962
1962
|
source: string;
|
|
1963
1963
|
type: "local";
|
|
1964
|
-
} | JsonRpcAccount | undefined>;
|
|
1964
|
+
} | import("viem").JsonRpcAccount | undefined>;
|
|
1965
1965
|
entryPoint: {
|
|
1966
1966
|
abi: readonly [{
|
|
1967
1967
|
readonly inputs: readonly [{
|
|
@@ -4311,7 +4311,7 @@ export declare function createMentaAccount<TChain extends Chain | undefined>(cli
|
|
|
4311
4311
|
publicKey: import("viem").Hex;
|
|
4312
4312
|
source: string;
|
|
4313
4313
|
type: "local";
|
|
4314
|
-
} | JsonRpcAccount | undefined>;
|
|
4314
|
+
} | import("viem").JsonRpcAccount | undefined>;
|
|
4315
4315
|
entryPoint: {
|
|
4316
4316
|
abi: readonly [{
|
|
4317
4317
|
readonly inputs: readonly [{
|
|
@@ -6661,7 +6661,7 @@ export declare function createMentaAccount<TChain extends Chain | undefined>(cli
|
|
|
6661
6661
|
publicKey: import("viem").Hex;
|
|
6662
6662
|
source: string;
|
|
6663
6663
|
type: "local";
|
|
6664
|
-
} | JsonRpcAccount | undefined>;
|
|
6664
|
+
} | import("viem").JsonRpcAccount | undefined>;
|
|
6665
6665
|
entryPoint: {
|
|
6666
6666
|
abi: readonly [{
|
|
6667
6667
|
readonly inputs: readonly [{
|
|
@@ -9011,7 +9011,7 @@ export declare function createMentaAccount<TChain extends Chain | undefined>(cli
|
|
|
9011
9011
|
publicKey: import("viem").Hex;
|
|
9012
9012
|
source: string;
|
|
9013
9013
|
type: "local";
|
|
9014
|
-
} | JsonRpcAccount | undefined>;
|
|
9014
|
+
} | import("viem").JsonRpcAccount | undefined>;
|
|
9015
9015
|
entryPoint: {
|
|
9016
9016
|
abi: readonly [{
|
|
9017
9017
|
readonly inputs: readonly [{
|
|
@@ -11361,7 +11361,7 @@ export declare function createMentaAccount<TChain extends Chain | undefined>(cli
|
|
|
11361
11361
|
publicKey: import("viem").Hex;
|
|
11362
11362
|
source: string;
|
|
11363
11363
|
type: "local";
|
|
11364
|
-
} | JsonRpcAccount | undefined>;
|
|
11364
|
+
} | import("viem").JsonRpcAccount | undefined>;
|
|
11365
11365
|
entryPoint: {
|
|
11366
11366
|
abi: readonly [{
|
|
11367
11367
|
readonly inputs: readonly [{
|
|
@@ -13711,7 +13711,7 @@ export declare function createMentaAccount<TChain extends Chain | undefined>(cli
|
|
|
13711
13711
|
publicKey: import("viem").Hex;
|
|
13712
13712
|
source: string;
|
|
13713
13713
|
type: "local";
|
|
13714
|
-
} | JsonRpcAccount | undefined>;
|
|
13714
|
+
} | import("viem").JsonRpcAccount | undefined>;
|
|
13715
13715
|
entryPoint: {
|
|
13716
13716
|
abi: readonly [{
|
|
13717
13717
|
readonly inputs: readonly [{
|
|
@@ -16061,7 +16061,7 @@ export declare function createMentaAccount<TChain extends Chain | undefined>(cli
|
|
|
16061
16061
|
publicKey: import("viem").Hex;
|
|
16062
16062
|
source: string;
|
|
16063
16063
|
type: "local";
|
|
16064
|
-
} | JsonRpcAccount | undefined>;
|
|
16064
|
+
} | import("viem").JsonRpcAccount | undefined>;
|
|
16065
16065
|
entryPoint: {
|
|
16066
16066
|
abi: readonly [{
|
|
16067
16067
|
readonly inputs: readonly [{
|
|
@@ -18001,7 +18001,7 @@ export declare function createMentaAccount<TChain extends Chain | undefined>(cli
|
|
|
18001
18001
|
publicKey: import("viem").Hex;
|
|
18002
18002
|
source: string;
|
|
18003
18003
|
type: "local";
|
|
18004
|
-
} | JsonRpcAccount | undefined>;
|
|
18004
|
+
} | import("viem").JsonRpcAccount | undefined>;
|
|
18005
18005
|
entryPoint: {
|
|
18006
18006
|
abi: readonly [{
|
|
18007
18007
|
readonly inputs: readonly [{
|
|
@@ -19530,7 +19530,7 @@ export declare function createMentaAccount<TChain extends Chain | undefined>(cli
|
|
|
19530
19530
|
publicKey: import("viem").Hex;
|
|
19531
19531
|
source: string;
|
|
19532
19532
|
type: "local";
|
|
19533
|
-
} | JsonRpcAccount | undefined>;
|
|
19533
|
+
} | import("viem").JsonRpcAccount | undefined>;
|
|
19534
19534
|
entryPoint: {
|
|
19535
19535
|
abi: readonly [{
|
|
19536
19536
|
readonly inputs: readonly [{
|
package/dist/clients/index.js
CHANGED
|
@@ -5939,6 +5939,64 @@ const getValidatorAddress = (entryPoint, kernelVersion, validatorContractVersion
|
|
|
5939
5939
|
return validatorAddress ?? passKeyValidatorAddress ?? viem.zeroAddress;
|
|
5940
5940
|
};
|
|
5941
5941
|
|
|
5942
|
+
/**
|
|
5943
|
+
* RPC methods that should be routed to the bundler.
|
|
5944
|
+
* All other methods will be routed to the public RPC.
|
|
5945
|
+
*/
|
|
5946
|
+
const BUNDLER_METHODS = new Set([
|
|
5947
|
+
// ERC-4337 standard methods
|
|
5948
|
+
"eth_sendUserOperation",
|
|
5949
|
+
"eth_estimateUserOperationGas",
|
|
5950
|
+
"eth_getUserOperationByHash",
|
|
5951
|
+
"eth_getUserOperationReceipt",
|
|
5952
|
+
"eth_supportedEntryPoints",
|
|
5953
|
+
// Pimlico-specific methods
|
|
5954
|
+
"pimlico_getUserOperationGasPrice",
|
|
5955
|
+
"pimlico_getUserOperationStatus",
|
|
5956
|
+
"pimlico_sendCompressedUserOperation",
|
|
5957
|
+
// pm_ paymaster methods (used by some bundlers)
|
|
5958
|
+
"pm_getPaymasterData",
|
|
5959
|
+
"pm_getPaymasterStubData",
|
|
5960
|
+
"pm_sponsorUserOperation",
|
|
5961
|
+
"pm_validateSponsorshipPolicies",
|
|
5962
|
+
]);
|
|
5963
|
+
/**
|
|
5964
|
+
* Creates a transport that routes requests between a public RPC and a bundler RPC.
|
|
5965
|
+
*
|
|
5966
|
+
* Bundler-specific methods (ERC-4337) are routed to the bundler transport,
|
|
5967
|
+
* while all other methods (eth_getBlockByNumber, eth_call, etc.) are routed
|
|
5968
|
+
* to the public transport.
|
|
5969
|
+
*
|
|
5970
|
+
* @param publicTransport - Transport for standard Ethereum RPC calls
|
|
5971
|
+
* @param bundlerTransport - Transport for ERC-4337 bundler calls
|
|
5972
|
+
* @returns A unified transport that routes requests appropriately
|
|
5973
|
+
*
|
|
5974
|
+
* @example
|
|
5975
|
+
* import { http } from 'viem';
|
|
5976
|
+
* import { createRoutedTransport } from '@mentaproject/core/utils';
|
|
5977
|
+
*
|
|
5978
|
+
* const transport = createRoutedTransport(
|
|
5979
|
+
* http('https://eth-mainnet.g.alchemy.com/v2/...'),
|
|
5980
|
+
* http('https://api.pimlico.io/v2/1/rpc?apikey=...')
|
|
5981
|
+
* );
|
|
5982
|
+
*/
|
|
5983
|
+
function createRoutedTransport(publicTransport, bundlerTransport) {
|
|
5984
|
+
return (params) => {
|
|
5985
|
+
const publicClient = publicTransport(params);
|
|
5986
|
+
const bundlerClient = bundlerTransport(params);
|
|
5987
|
+
const request = async ({ method, params: reqParams }) => {
|
|
5988
|
+
if (BUNDLER_METHODS.has(method)) {
|
|
5989
|
+
return bundlerClient.request({ method, params: reqParams });
|
|
5990
|
+
}
|
|
5991
|
+
return publicClient.request({ method, params: reqParams });
|
|
5992
|
+
};
|
|
5993
|
+
return {
|
|
5994
|
+
...publicClient,
|
|
5995
|
+
request,
|
|
5996
|
+
};
|
|
5997
|
+
};
|
|
5998
|
+
}
|
|
5999
|
+
|
|
5942
6000
|
async function createMentaAccount(client, params) {
|
|
5943
6001
|
const validator = await toPasskeyValidator(client, {
|
|
5944
6002
|
webAuthnKey: params.signer,
|
|
@@ -5953,9 +6011,12 @@ async function createMentaAccount(client, params) {
|
|
|
5953
6011
|
owners: [validator],
|
|
5954
6012
|
client: client,
|
|
5955
6013
|
});
|
|
6014
|
+
// Create a routed transport that sends bundler methods to the bundler
|
|
6015
|
+
// and all other RPC calls to the public transport
|
|
6016
|
+
const routedTransport = createRoutedTransport(params.publicTransport, params.bundlerTransport);
|
|
5956
6017
|
return permissionless.createSmartAccountClient({
|
|
5957
6018
|
account: kernel,
|
|
5958
|
-
bundlerTransport:
|
|
6019
|
+
bundlerTransport: routedTransport,
|
|
5959
6020
|
}).extend(erc7579.erc7579Actions());
|
|
5960
6021
|
}
|
|
5961
6022
|
|