@mentaproject/core 0.5.13 → 0.6.0
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 +23 -22
- package/dist/clients/index.js +65 -4
- package/dist/clients/index.js.map +1 -1
- package/dist/clients/index.mjs +65 -4
- package/dist/clients/index.mjs.map +1 -1
- package/dist/types/CoreClient.d.ts +10 -1
- 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 +21 -6
- package/src/types/CoreClient.ts +13 -1
- 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,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { MentaAccountParams } from "../types";
|
|
2
|
+
import type { Client, Transport, Chain, JsonRpcAccount, LocalAccount } from "viem";
|
|
3
|
+
export declare function createMentaAccount<TChain extends Chain | undefined>(client: Client<Transport, TChain, JsonRpcAccount | LocalAccount | undefined>, params: MentaAccountParams): Promise<Client<Transport, undefined, object & {
|
|
4
|
+
client: Client<Transport, Chain | undefined, {
|
|
4
5
|
address: import("abitype").Address;
|
|
5
6
|
nonceManager?: import("viem").NonceManager | undefined;
|
|
6
7
|
sign?: ((parameters: {
|
|
@@ -17,7 +18,7 @@ export declare function createMentaAccount(coreClient: CoreClient, params: Menta
|
|
|
17
18
|
publicKey: import("viem").Hex;
|
|
18
19
|
source: string;
|
|
19
20
|
type: "local";
|
|
20
|
-
} |
|
|
21
|
+
} | JsonRpcAccount | undefined>;
|
|
21
22
|
entryPoint: {
|
|
22
23
|
abi: readonly [{
|
|
23
24
|
readonly inputs: readonly [{
|
|
@@ -1533,7 +1534,7 @@ export declare function createMentaAccount(coreClient: CoreClient, params: Menta
|
|
|
1533
1534
|
account?: import("viem/account-abstraction").SmartAccount | undefined;
|
|
1534
1535
|
} | undefined) => Promise<string>;
|
|
1535
1536
|
installModule: (args: import("permissionless/actions/erc7579").InstallModuleParameters<object & {
|
|
1536
|
-
client:
|
|
1537
|
+
client: Client<Transport, Chain | undefined, {
|
|
1537
1538
|
address: import("abitype").Address;
|
|
1538
1539
|
nonceManager?: import("viem").NonceManager | undefined;
|
|
1539
1540
|
sign?: ((parameters: {
|
|
@@ -1960,7 +1961,7 @@ export declare function createMentaAccount(coreClient: CoreClient, params: Menta
|
|
|
1960
1961
|
publicKey: import("viem").Hex;
|
|
1961
1962
|
source: string;
|
|
1962
1963
|
type: "local";
|
|
1963
|
-
} |
|
|
1964
|
+
} | JsonRpcAccount | undefined>;
|
|
1964
1965
|
entryPoint: {
|
|
1965
1966
|
abi: readonly [{
|
|
1966
1967
|
readonly inputs: readonly [{
|
|
@@ -3883,7 +3884,7 @@ export declare function createMentaAccount(coreClient: CoreClient, params: Menta
|
|
|
3883
3884
|
type: "smart";
|
|
3884
3885
|
}>) => Promise<import("viem").Hash>;
|
|
3885
3886
|
installModules: (args: import("node_modules/permissionless/_types/actions/erc7579/installModules").InstallModulesParameters<object & {
|
|
3886
|
-
client:
|
|
3887
|
+
client: Client<Transport, Chain | undefined, {
|
|
3887
3888
|
address: import("abitype").Address;
|
|
3888
3889
|
nonceManager?: import("viem").NonceManager | undefined;
|
|
3889
3890
|
sign?: ((parameters: {
|
|
@@ -4310,7 +4311,7 @@ export declare function createMentaAccount(coreClient: CoreClient, params: Menta
|
|
|
4310
4311
|
publicKey: import("viem").Hex;
|
|
4311
4312
|
source: string;
|
|
4312
4313
|
type: "local";
|
|
4313
|
-
} |
|
|
4314
|
+
} | JsonRpcAccount | undefined>;
|
|
4314
4315
|
entryPoint: {
|
|
4315
4316
|
abi: readonly [{
|
|
4316
4317
|
readonly inputs: readonly [{
|
|
@@ -6233,7 +6234,7 @@ export declare function createMentaAccount(coreClient: CoreClient, params: Menta
|
|
|
6233
6234
|
type: "smart";
|
|
6234
6235
|
}>) => Promise<import("viem").Hash>;
|
|
6235
6236
|
isModuleInstalled: (args: import("permissionless/actions/erc7579").IsModuleInstalledParameters<object & {
|
|
6236
|
-
client:
|
|
6237
|
+
client: Client<Transport, Chain | undefined, {
|
|
6237
6238
|
address: import("abitype").Address;
|
|
6238
6239
|
nonceManager?: import("viem").NonceManager | undefined;
|
|
6239
6240
|
sign?: ((parameters: {
|
|
@@ -6660,7 +6661,7 @@ export declare function createMentaAccount(coreClient: CoreClient, params: Menta
|
|
|
6660
6661
|
publicKey: import("viem").Hex;
|
|
6661
6662
|
source: string;
|
|
6662
6663
|
type: "local";
|
|
6663
|
-
} |
|
|
6664
|
+
} | JsonRpcAccount | undefined>;
|
|
6664
6665
|
entryPoint: {
|
|
6665
6666
|
abi: readonly [{
|
|
6666
6667
|
readonly inputs: readonly [{
|
|
@@ -8583,7 +8584,7 @@ export declare function createMentaAccount(coreClient: CoreClient, params: Menta
|
|
|
8583
8584
|
type: "smart";
|
|
8584
8585
|
}>) => Promise<boolean>;
|
|
8585
8586
|
supportsExecutionMode: (args: import("permissionless/actions/erc7579").SupportsExecutionModeParameters<object & {
|
|
8586
|
-
client:
|
|
8587
|
+
client: Client<Transport, Chain | undefined, {
|
|
8587
8588
|
address: import("abitype").Address;
|
|
8588
8589
|
nonceManager?: import("viem").NonceManager | undefined;
|
|
8589
8590
|
sign?: ((parameters: {
|
|
@@ -9010,7 +9011,7 @@ export declare function createMentaAccount(coreClient: CoreClient, params: Menta
|
|
|
9010
9011
|
publicKey: import("viem").Hex;
|
|
9011
9012
|
source: string;
|
|
9012
9013
|
type: "local";
|
|
9013
|
-
} |
|
|
9014
|
+
} | JsonRpcAccount | undefined>;
|
|
9014
9015
|
entryPoint: {
|
|
9015
9016
|
abi: readonly [{
|
|
9016
9017
|
readonly inputs: readonly [{
|
|
@@ -10933,7 +10934,7 @@ export declare function createMentaAccount(coreClient: CoreClient, params: Menta
|
|
|
10933
10934
|
type: "smart";
|
|
10934
10935
|
}>) => Promise<boolean>;
|
|
10935
10936
|
supportsModule: (args: import("permissionless/actions/erc7579").SupportsModuleParameters<object & {
|
|
10936
|
-
client:
|
|
10937
|
+
client: Client<Transport, Chain | undefined, {
|
|
10937
10938
|
address: import("abitype").Address;
|
|
10938
10939
|
nonceManager?: import("viem").NonceManager | undefined;
|
|
10939
10940
|
sign?: ((parameters: {
|
|
@@ -11360,7 +11361,7 @@ export declare function createMentaAccount(coreClient: CoreClient, params: Menta
|
|
|
11360
11361
|
publicKey: import("viem").Hex;
|
|
11361
11362
|
source: string;
|
|
11362
11363
|
type: "local";
|
|
11363
|
-
} |
|
|
11364
|
+
} | JsonRpcAccount | undefined>;
|
|
11364
11365
|
entryPoint: {
|
|
11365
11366
|
abi: readonly [{
|
|
11366
11367
|
readonly inputs: readonly [{
|
|
@@ -13283,7 +13284,7 @@ export declare function createMentaAccount(coreClient: CoreClient, params: Menta
|
|
|
13283
13284
|
type: "smart";
|
|
13284
13285
|
}>) => Promise<boolean>;
|
|
13285
13286
|
uninstallModule: (args: import("permissionless/actions/erc7579").UninstallModuleParameters<object & {
|
|
13286
|
-
client:
|
|
13287
|
+
client: Client<Transport, Chain | undefined, {
|
|
13287
13288
|
address: import("abitype").Address;
|
|
13288
13289
|
nonceManager?: import("viem").NonceManager | undefined;
|
|
13289
13290
|
sign?: ((parameters: {
|
|
@@ -13710,7 +13711,7 @@ export declare function createMentaAccount(coreClient: CoreClient, params: Menta
|
|
|
13710
13711
|
publicKey: import("viem").Hex;
|
|
13711
13712
|
source: string;
|
|
13712
13713
|
type: "local";
|
|
13713
|
-
} |
|
|
13714
|
+
} | JsonRpcAccount | undefined>;
|
|
13714
13715
|
entryPoint: {
|
|
13715
13716
|
abi: readonly [{
|
|
13716
13717
|
readonly inputs: readonly [{
|
|
@@ -15633,7 +15634,7 @@ export declare function createMentaAccount(coreClient: CoreClient, params: Menta
|
|
|
15633
15634
|
type: "smart";
|
|
15634
15635
|
}>) => Promise<import("viem").Hash>;
|
|
15635
15636
|
uninstallModules: (args: import("node_modules/permissionless/_types/actions/erc7579/uninstallModules").UninstallModulesParameters<object & {
|
|
15636
|
-
client:
|
|
15637
|
+
client: Client<Transport, Chain | undefined, {
|
|
15637
15638
|
address: import("abitype").Address;
|
|
15638
15639
|
nonceManager?: import("viem").NonceManager | undefined;
|
|
15639
15640
|
sign?: ((parameters: {
|
|
@@ -16060,7 +16061,7 @@ export declare function createMentaAccount(coreClient: CoreClient, params: Menta
|
|
|
16060
16061
|
publicKey: import("viem").Hex;
|
|
16061
16062
|
source: string;
|
|
16062
16063
|
type: "local";
|
|
16063
|
-
} |
|
|
16064
|
+
} | JsonRpcAccount | undefined>;
|
|
16064
16065
|
entryPoint: {
|
|
16065
16066
|
abi: readonly [{
|
|
16066
16067
|
readonly inputs: readonly [{
|
|
@@ -17983,7 +17984,7 @@ export declare function createMentaAccount(coreClient: CoreClient, params: Menta
|
|
|
17983
17984
|
type: "smart";
|
|
17984
17985
|
}>) => Promise<import("viem").Hash>;
|
|
17985
17986
|
} & import("viem/account-abstraction").BundlerActions<object & {
|
|
17986
|
-
client:
|
|
17987
|
+
client: Client<Transport, Chain | undefined, {
|
|
17987
17988
|
address: import("abitype").Address;
|
|
17988
17989
|
nonceManager?: import("viem").NonceManager | undefined;
|
|
17989
17990
|
sign?: ((parameters: {
|
|
@@ -18000,7 +18001,7 @@ export declare function createMentaAccount(coreClient: CoreClient, params: Menta
|
|
|
18000
18001
|
publicKey: import("viem").Hex;
|
|
18001
18002
|
source: string;
|
|
18002
18003
|
type: "local";
|
|
18003
|
-
} |
|
|
18004
|
+
} | JsonRpcAccount | undefined>;
|
|
18004
18005
|
entryPoint: {
|
|
18005
18006
|
abi: readonly [{
|
|
18006
18007
|
readonly inputs: readonly [{
|
|
@@ -19512,7 +19513,7 @@ export declare function createMentaAccount(coreClient: CoreClient, params: Menta
|
|
|
19512
19513
|
isDeployed: () => Promise<boolean>;
|
|
19513
19514
|
type: "smart";
|
|
19514
19515
|
}> & import("permissionless").SmartAccountActions<undefined, object & {
|
|
19515
|
-
client:
|
|
19516
|
+
client: Client<Transport, Chain | undefined, {
|
|
19516
19517
|
address: import("abitype").Address;
|
|
19517
19518
|
nonceManager?: import("viem").NonceManager | undefined;
|
|
19518
19519
|
sign?: ((parameters: {
|
|
@@ -19529,7 +19530,7 @@ export declare function createMentaAccount(coreClient: CoreClient, params: Menta
|
|
|
19529
19530
|
publicKey: import("viem").Hex;
|
|
19530
19531
|
source: string;
|
|
19531
19532
|
type: "local";
|
|
19532
|
-
} |
|
|
19533
|
+
} | JsonRpcAccount | undefined>;
|
|
19533
19534
|
entryPoint: {
|
|
19534
19535
|
abi: readonly [{
|
|
19535
19536
|
readonly inputs: readonly [{
|
package/dist/clients/index.js
CHANGED
|
@@ -5939,8 +5939,66 @@ const getValidatorAddress = (entryPoint, kernelVersion, validatorContractVersion
|
|
|
5939
5939
|
return validatorAddress ?? passKeyValidatorAddress ?? viem.zeroAddress;
|
|
5940
5940
|
};
|
|
5941
5941
|
|
|
5942
|
-
|
|
5943
|
-
|
|
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
|
+
|
|
6000
|
+
async function createMentaAccount(client, params) {
|
|
6001
|
+
const validator = await toPasskeyValidator(client, {
|
|
5944
6002
|
webAuthnKey: params.signer,
|
|
5945
6003
|
entryPoint: {
|
|
5946
6004
|
address: accountAbstraction.entryPoint07Address,
|
|
@@ -5951,11 +6009,14 @@ async function createMentaAccount(coreClient, params) {
|
|
|
5951
6009
|
});
|
|
5952
6010
|
const kernel = await accounts$1.toKernelSmartAccount({
|
|
5953
6011
|
owners: [validator],
|
|
5954
|
-
client:
|
|
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
|
|