@mentaproject/client 0.1.25 → 0.1.28
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 { CoreClient } from "
|
|
1
|
+
import type { CoreClient } from "@mentaproject/core/types";
|
|
2
2
|
import { ICache } from "../types/Cache";
|
|
3
3
|
/**
|
|
4
4
|
* A higher-order function that enhances a class method with caching capabilities.
|
|
@@ -9,4 +9,4 @@ import { ICache } from "../types/Cache";
|
|
|
9
9
|
* @param cache The cache implementation (ICache) to use for storing and retrieving responses.
|
|
10
10
|
* @returns The enhanced CoreClient instance with caching enabled.
|
|
11
11
|
*/
|
|
12
|
-
export declare function withCache(client:
|
|
12
|
+
export declare function withCache<T extends CoreClient>(client: T, cache: ICache): T;
|
package/dist/utils/withCache.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mentaproject/client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.28",
|
|
4
4
|
"description": "High level EVM library used into the Menta App to facilitate Blockchain interactions. ",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"license": "ISC",
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@mentaproject/contracts": "^0.0.11",
|
|
35
|
-
"@mentaproject/core": "^0.
|
|
35
|
+
"@mentaproject/core": "^0.6.1",
|
|
36
36
|
"@modelcontextprotocol/sdk": "^1.13.0",
|
|
37
37
|
"@shazow/whatsabi": "^0.21.1"
|
|
38
38
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module MentaClient
|
|
3
3
|
*/
|
|
4
|
-
import type {
|
|
4
|
+
import type { MentaAccountClient } from "@mentaproject/core/types";
|
|
5
5
|
import { createMentaAccount } from "@mentaproject/core/clients";
|
|
6
6
|
|
|
7
7
|
import { BlockManager } from "../managers/BlockManager";
|
|
@@ -131,7 +131,7 @@ export class MentaClient {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
async init() {
|
|
134
|
-
let coreClient = createClient(this.params)
|
|
134
|
+
let coreClient = createClient(this.params);
|
|
135
135
|
|
|
136
136
|
if (this.params.cache) {
|
|
137
137
|
coreClient = withCache(coreClient, this.params.cache);
|
|
@@ -140,6 +140,7 @@ export class MentaClient {
|
|
|
140
140
|
this._rpc = await createMentaAccount(coreClient, {
|
|
141
141
|
signer: this.params.signer,
|
|
142
142
|
bundlerTransport: this.params.bundlerTransport,
|
|
143
|
+
publicTransport: this.params.transport,
|
|
143
144
|
});
|
|
144
145
|
}
|
|
145
146
|
|
package/src/utils/withCache.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module withCache
|
|
3
3
|
*/
|
|
4
4
|
import { watchBlockNumber } from "@mentaproject/core/actions";
|
|
5
|
-
import { CoreClient } from "
|
|
5
|
+
import type { CoreClient } from "@mentaproject/core/types";
|
|
6
6
|
import { ICache } from "../types/Cache";
|
|
7
7
|
import { Methods } from "../types/JsonRPC";
|
|
8
8
|
|
|
@@ -15,7 +15,7 @@ import { Methods } from "../types/JsonRPC";
|
|
|
15
15
|
* @param cache The cache implementation (ICache) to use for storing and retrieving responses.
|
|
16
16
|
* @returns The enhanced CoreClient instance with caching enabled.
|
|
17
17
|
*/
|
|
18
|
-
export function withCache(client:
|
|
18
|
+
export function withCache<T extends CoreClient>(client: T, cache: ICache): T {
|
|
19
19
|
watchBlockNumber(client, {
|
|
20
20
|
onBlockNumber: (blockNumber) => {
|
|
21
21
|
cache.setBlockNumber(blockNumber);
|
|
@@ -47,4 +47,4 @@ export function withCache(client: CoreClient, cache: ICache) {
|
|
|
47
47
|
}) as any;
|
|
48
48
|
|
|
49
49
|
return client;
|
|
50
|
-
}
|
|
50
|
+
}
|
|
@@ -8,6 +8,23 @@ import { PersistenceManager } from '../../src/managers/PersistenceManager';
|
|
|
8
8
|
import { MentaClientConfig } from '../../src/types/MentaClient';
|
|
9
9
|
import { http } from '@mentaproject/core';
|
|
10
10
|
import { mainnet } from 'viem/chains';
|
|
11
|
+
import type { PasskeySigner } from '@mentaproject/core/types';
|
|
12
|
+
|
|
13
|
+
// Mock passkey signer for testing
|
|
14
|
+
const mockSigner = {
|
|
15
|
+
address: '0x0000000000000000000000000000000000000000',
|
|
16
|
+
type: 'local',
|
|
17
|
+
source: 'custom',
|
|
18
|
+
publicKey: '0x00',
|
|
19
|
+
pubX: 0n,
|
|
20
|
+
pubY: 0n,
|
|
21
|
+
authenticatorId: 'mock-authenticator',
|
|
22
|
+
authenticatorIdHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
23
|
+
rpID: 'localhost',
|
|
24
|
+
signMessage: async () => '0x00',
|
|
25
|
+
signTransaction: async () => '0x00',
|
|
26
|
+
signTypedData: async () => '0x00',
|
|
27
|
+
} as unknown as PasskeySigner;
|
|
11
28
|
|
|
12
29
|
describe('MentaClient', () => {
|
|
13
30
|
let client: MentaClient;
|
|
@@ -15,6 +32,8 @@ describe('MentaClient', () => {
|
|
|
15
32
|
transport: http('http://localhost:8545'),
|
|
16
33
|
chain: mainnet,
|
|
17
34
|
persistenceAdapter: mockPersistenceAdapter,
|
|
35
|
+
bundlerTransport: http('http://localhost:4337'),
|
|
36
|
+
signer: mockSigner,
|
|
18
37
|
};
|
|
19
38
|
|
|
20
39
|
beforeEach(() => {
|
|
@@ -33,8 +52,10 @@ describe('MentaClient', () => {
|
|
|
33
52
|
const clientWithoutPersistence = new MentaClient({
|
|
34
53
|
transport: http('http://localhost:8545'),
|
|
35
54
|
chain: mainnet,
|
|
55
|
+
bundlerTransport: http('http://localhost:4337'),
|
|
56
|
+
signer: mockSigner,
|
|
36
57
|
});
|
|
37
58
|
expect(clientWithoutPersistence.persistenceManager).toBeUndefined();
|
|
38
59
|
expect(clientWithoutPersistence.accounts).toBeInstanceOf(AccountManager);
|
|
39
60
|
});
|
|
40
|
-
});
|
|
61
|
+
});
|