@mentaproject/client 0.1.28 → 0.1.32
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.
|
@@ -8,6 +8,7 @@ import { ContractManager } from "../managers/ContractManager";
|
|
|
8
8
|
import { AccountManager } from "../managers/AccountManager";
|
|
9
9
|
import { PersistenceManager } from "../managers/PersistenceManager";
|
|
10
10
|
import { ClientEvents, GetListenerCallback, MentaClientConfig } from "../types/MentaClient";
|
|
11
|
+
import { Account } from "./Account";
|
|
11
12
|
/**
|
|
12
13
|
* The main client for interacting with the Menta API.
|
|
13
14
|
* It provides managers for blocks, transactions, contracts, and accounts.
|
|
@@ -19,11 +20,17 @@ import { ClientEvents, GetListenerCallback, MentaClientConfig } from "../types/M
|
|
|
19
20
|
export declare class MentaClient {
|
|
20
21
|
protected params: MentaClientConfig;
|
|
21
22
|
protected _rpc?: MentaAccountClient;
|
|
23
|
+
protected _account?: Account;
|
|
22
24
|
/**
|
|
23
25
|
* The underlying RPC client used for blockchain interactions.
|
|
24
26
|
* @description This client is responsible for low-level communication with the RPC node.
|
|
25
27
|
*/
|
|
26
28
|
get rpc(): MentaAccountClient;
|
|
29
|
+
/**
|
|
30
|
+
* The account associated with the client.
|
|
31
|
+
* @description This account is used for signing transactions and interacting with the blockchain.
|
|
32
|
+
*/
|
|
33
|
+
get account(): Account;
|
|
27
34
|
/**
|
|
28
35
|
* Manager for block-related operations.
|
|
29
36
|
* @description Provides methods to query and interact with blockchain blocks.
|
|
@@ -26,6 +26,16 @@ export class MentaClient {
|
|
|
26
26
|
}
|
|
27
27
|
return this._rpc;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* The account associated with the client.
|
|
31
|
+
* @description This account is used for signing transactions and interacting with the blockchain.
|
|
32
|
+
*/
|
|
33
|
+
get account() {
|
|
34
|
+
if (!this._account) {
|
|
35
|
+
throw new Error("Account not initialized");
|
|
36
|
+
}
|
|
37
|
+
return this._account;
|
|
38
|
+
}
|
|
29
39
|
/**
|
|
30
40
|
* Subscribes to a specific client event.
|
|
31
41
|
* @template TEvent The type of the event to listen for.
|
|
@@ -99,5 +109,6 @@ export class MentaClient {
|
|
|
99
109
|
bundlerTransport: this.params.bundlerTransport,
|
|
100
110
|
publicTransport: this.params.transport,
|
|
101
111
|
});
|
|
112
|
+
this._account = this.accounts.get(this.rpc.account.address);
|
|
102
113
|
}
|
|
103
114
|
}
|
package/package.json
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
} from "../types/MentaClient";
|
|
17
17
|
import { withCache } from "../utils/withCache";
|
|
18
18
|
import { createClient } from "@mentaproject/core";
|
|
19
|
+
import { Account } from "./Account";
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* The main client for interacting with the Menta API.
|
|
@@ -27,6 +28,7 @@ import { createClient } from "@mentaproject/core";
|
|
|
27
28
|
*/
|
|
28
29
|
export class MentaClient {
|
|
29
30
|
protected _rpc?: MentaAccountClient;
|
|
31
|
+
protected _account?: Account;
|
|
30
32
|
/**
|
|
31
33
|
* The underlying RPC client used for blockchain interactions.
|
|
32
34
|
* @description This client is responsible for low-level communication with the RPC node.
|
|
@@ -38,6 +40,17 @@ export class MentaClient {
|
|
|
38
40
|
return this._rpc;
|
|
39
41
|
}
|
|
40
42
|
|
|
43
|
+
/**
|
|
44
|
+
* The account associated with the client.
|
|
45
|
+
* @description This account is used for signing transactions and interacting with the blockchain.
|
|
46
|
+
*/
|
|
47
|
+
public get account(): Account {
|
|
48
|
+
if (!this._account) {
|
|
49
|
+
throw new Error("Account not initialized");
|
|
50
|
+
}
|
|
51
|
+
return this._account;
|
|
52
|
+
}
|
|
53
|
+
|
|
41
54
|
/**
|
|
42
55
|
* Manager for block-related operations.
|
|
43
56
|
* @description Provides methods to query and interact with blockchain blocks.
|
|
@@ -142,6 +155,8 @@ export class MentaClient {
|
|
|
142
155
|
bundlerTransport: this.params.bundlerTransport,
|
|
143
156
|
publicTransport: this.params.transport,
|
|
144
157
|
});
|
|
158
|
+
|
|
159
|
+
this._account = this.accounts.get(this.rpc.account.address);
|
|
145
160
|
}
|
|
146
161
|
|
|
147
162
|
/**
|