@mentaproject/client 0.1.14 → 0.1.15

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,8 +1,8 @@
1
1
  import { Address } from '@mentaproject/core/types';
2
2
  import { IPersistenceAdapter } from '../types/PersistenceAdapter';
3
3
  import { Account } from '../structures/Account';
4
- import { MentaClient, Transaction } from '../structures';
5
- import { GetTransactionsParams } from 'src/types';
4
+ import { MentaClient } from '../structures';
5
+ import { GetTransactionsParams, JSONTransaction } from 'src/types';
6
6
  /**
7
7
  * Manages the persistence of data, including transactions, using a specified persistence adapter.
8
8
  * It handles fetching data from both local storage and remote sources, and synchronizing them.
@@ -21,7 +21,7 @@ export declare class PersistenceManager {
21
21
  * @param params - Parameters for retrieving transactions.
22
22
  * @returns A promise that resolves to an array of transactions with associated account information.
23
23
  */
24
- getTransactions(address: Address, params: GetTransactionsParams): Promise<Transaction[]>;
24
+ getTransactions(address: Address, params: GetTransactionsParams): Promise<JSONTransaction[]>;
25
25
  /**
26
26
  * Synchronizes an account's transactions from the remote source to the local persistence.
27
27
  * It fetches new transactions starting from the last synced block and updates the local storage.
@@ -1,4 +1,5 @@
1
1
  import { fetchByBlockRange, getBalance, getBlockNumber, getCode, getTransaction, getTransactionCount, sendTransaction, traceFilter } from "@mentaproject/core/actions";
2
+ import { Transaction } from "./Transaction";
2
3
  import { toHex } from "@mentaproject/core/utils";
3
4
  import { getContractType } from "@mentaproject/contracts";
4
5
  import { toJSON } from "../utils/toJSON";
@@ -101,7 +102,7 @@ export class Account {
101
102
  return transactions;
102
103
  }
103
104
  const cachedTransactions = await this.persistenceManager.getTransactions(this.address, params);
104
- return cachedTransactions;
105
+ return cachedTransactions.map(t => new Transaction(this.client, t));
105
106
  }
106
107
  /**
107
108
  * Synchronizes the account's transactions with the remote data source using the configured `PersistenceManager`.
@@ -1,6 +1,7 @@
1
1
  import { Address } from '@mentaproject/core/types';
2
2
  import { Transaction } from '../structures/Transaction';
3
3
  import { GetTransactionsParams } from './Account';
4
+ import { JSONTransaction } from './Transaction';
4
5
  /**
5
6
  * @interface IPersistenceAdapter
6
7
  * @description Defines the contract for persistence layers, ensuring consistent data storage and retrieval operations.
@@ -19,7 +20,7 @@ export interface IPersistenceAdapter {
19
20
  * @param {GetTransactionsFilters} filters - An object containing filters for retrieving transactions, such as account address, block range, pagination, and sort order.
20
21
  * @returns {Promise<Transaction[]>} A Promise that resolves with an array of transactions matching the filters.
21
22
  */
22
- getTransactions(address: Address, params: GetTransactionsParams): Promise<Transaction[]>;
23
+ getTransactions(address: Address, params: GetTransactionsParams): Promise<JSONTransaction[]>;
23
24
  /**
24
25
  * @method getLastSyncedBlock
25
26
  * @description Retrieves the last synced block number for a given account. This is used to track the synchronization progress of an account's transactions.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mentaproject/client",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
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",