Skip to content

Commit

Permalink
refactor: remove debug methods (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
sarvalabs-harshrastogi authored Feb 5, 2024
1 parent 51e20d7 commit c67269b
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 191 deletions.
6 changes: 0 additions & 6 deletions docs/source/providers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,6 @@ Query Methods

.. autofunction:: getNodeInfo

.. autofunction:: getDBEntry

.. autofunction:: getAccounts

.. autofunction:: getNewTesseractFilter

.. autofunction:: getNewTesseractsByAccountFilter
Expand All @@ -425,8 +421,6 @@ Query Methods

.. autofunction:: removeFilter

.. autofunction:: getConnections

Event Methods
~~~~~~~~~~~~~

Expand Down
15 changes: 0 additions & 15 deletions packages/js-moi-providers/__tests__/jsonrpc-provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,6 @@ describe("Test JsonRpcProvider Query Calls", () => {
});
});

describe("getAccounts", () => {
it('should return the accounts', async () => {
const accounts = await provider.getAccounts();
expect(accounts).toBeDefined();
expect(accounts.length).toBeGreaterThanOrEqual(2)
});
});

describe("getNewTesseractFilter", () => {
it("should return the filter object containing the filter id", async () => {
const filter = await provider.getNewTesseractFilter();
Expand Down Expand Up @@ -382,11 +374,4 @@ describe("Test JsonRpcProvider Query Calls", () => {
expect(Array.length).toBeGreaterThanOrEqual(1);
})
});

describe("getConnections", () => {
it('should return the connections info', async () => {
const info = await provider.getConnections();
expect(info).toBeDefined();
});
})
});
5 changes: 1 addition & 4 deletions packages/js-moi-providers/dist/abstract-provider.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { LogicManifest } from "js-moi-manifest";
import { Interaction, Tesseract } from "js-moi-utils";
import { EventType, Listener } from "../types/event";
import { AccountMetaInfo, AccountState, AssetInfo, CallorEstimateIxObject, CallorEstimateOptions, ConnectionsInfo, Content, ContentFrom, ContextInfo, Encoding, Filter, FilterDeletionResult, Inspect, InteractionCallResponse, InteractionReceipt, InteractionRequest, InteractionResponse, NodeInfo, Options, Registry, Status, SyncStatus, TDU } from "../types/jsonrpc";
import { AccountMetaInfo, AccountState, AssetInfo, CallorEstimateIxObject, CallorEstimateOptions, Content, ContentFrom, ContextInfo, Encoding, Filter, FilterDeletionResult, Inspect, InteractionCallResponse, InteractionReceipt, InteractionRequest, InteractionResponse, NodeInfo, Options, Registry, Status, SyncStatus, TDU } from "../types/jsonrpc";
/**
* Abstract class representing a provider for interacting with the MOI protocol.
* Provides methods for account operations, execution, and querying.
Expand Down Expand Up @@ -35,14 +35,11 @@ export declare abstract class AbstractProvider {
abstract getPeers(): Promise<string[]>;
abstract getVersion(): Promise<string>;
abstract getNodeInfo(): Promise<NodeInfo>;
abstract getDBEntry(key: string): Promise<string>;
abstract getAccounts(): Promise<string[]>;
abstract getNewTesseractFilter(): Promise<Filter>;
abstract getNewTesseractsByAccountFilter(address: string): Promise<Filter>;
abstract getPendingInteractionFilter(): Promise<Filter>;
abstract getFilterChanges<T extends any>(filter: Filter): Promise<T>;
abstract removeFilter(filter: Filter): Promise<FilterDeletionResult>;
abstract getConnections(): Promise<ConnectionsInfo>;
abstract on(eventName: EventType, listener: Listener): AbstractProvider;
abstract once(eventName: EventType, listener: Listener): AbstractProvider;
abstract listenerCount(eventName?: EventType): number;
Expand Down
30 changes: 1 addition & 29 deletions packages/js-moi-providers/dist/base-provider.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { LogicManifest } from "js-moi-manifest";
import { Interaction, Tesseract } from "js-moi-utils";
import { EventType, Listener } from "../types/event";
import { AccountMetaInfo, AccountState, AssetInfo, CallorEstimateIxObject, CallorEstimateOptions, ConnectionsInfo, Content, ContentFrom, ContextInfo, Encoding, Filter, FilterDeletionResult, Inspect, InteractionCallResponse, InteractionReceipt, InteractionRequest, InteractionResponse, NodeInfo, Options, Registry, RpcResponse, Status, SyncStatus, TDU } from "../types/jsonrpc";
import { AccountMetaInfo, AccountState, AssetInfo, CallorEstimateIxObject, CallorEstimateOptions, Content, ContentFrom, ContextInfo, Encoding, Filter, FilterDeletionResult, Inspect, InteractionCallResponse, InteractionReceipt, InteractionRequest, InteractionResponse, NodeInfo, Options, Registry, RpcResponse, Status, SyncStatus, TDU } from "../types/jsonrpc";
import { AbstractProvider } from "./abstract-provider";
import Event from "./event";
/**
Expand Down Expand Up @@ -356,34 +356,6 @@ export declare class BaseProvider extends AbstractProvider {
* the response.
*/
getNodeInfo(): Promise<NodeInfo>;
/**
* Retrieves the value of a database entry with the specified key.
*
* @param {string} key - The key of the database entry.
* @returns {Promise<string>} A Promise that resolves to the value of the
* database entry as a string.
* @throws {Error} if there is an error executing the RPC call or processing
* the response.
*/
getDBEntry(key: string): Promise<string>;
/**
* Retrieves the list of all registered accounts from a moipod.
*
* @returns {Promise<string[]>} A Promise that resolves to the list of
* accounts.
* @throws {Error} if there is an error executing the RPC call or processing
* the response.
*/
getAccounts(): Promise<string[]>;
/**
* Retrieves information about active network connections.
*
* @returns {Promise<ConnectionsInfo>} A Promise that resolves to an array of
* connection response object.
* @throws {Error} if there is an error executing the RPC call or processing
* the response.
*/
getConnections(): Promise<ConnectionsInfo>;
/**
* Waits for the interaction with the specified hash to be included in a tesseract
* and returns the interaction receipt.
Expand Down
55 changes: 0 additions & 55 deletions packages/js-moi-providers/dist/base-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -815,61 +815,6 @@ class BaseProvider extends abstract_provider_1.AbstractProvider {
throw error;
}
}
/**
* Retrieves the value of a database entry with the specified key.
*
* @param {string} key - The key of the database entry.
* @returns {Promise<string>} A Promise that resolves to the value of the
* database entry as a string.
* @throws {Error} if there is an error executing the RPC call or processing
* the response.
*/
async getDBEntry(key) {
try {
const params = {
key: key
};
const response = await this.execute("debug.DBGet", params);
return this.processResponse(response);
}
catch (error) {
throw error;
}
}
/**
* Retrieves the list of all registered accounts from a moipod.
*
* @returns {Promise<string[]>} A Promise that resolves to the list of
* accounts.
* @throws {Error} if there is an error executing the RPC call or processing
* the response.
*/
async getAccounts() {
try {
const response = await this.execute("debug.Accounts", null);
return this.processResponse(response);
}
catch (error) {
throw error;
}
}
/**
* Retrieves information about active network connections.
*
* @returns {Promise<ConnectionsInfo>} A Promise that resolves to an array of
* connection response object.
* @throws {Error} if there is an error executing the RPC call or processing
* the response.
*/
async getConnections() {
try {
const response = await this.execute("debug.Connections", null);
return this.processResponse(response);
}
catch (error) {
throw error;
}
}
/**
* Waits for the interaction with the specified hash to be included in a tesseract
* and returns the interaction receipt.
Expand Down
4 changes: 0 additions & 4 deletions packages/js-moi-providers/src/abstract-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
AssetInfo,
CallorEstimateIxObject,
CallorEstimateOptions,
ConnectionsInfo,
Content,
ContentFrom,
ContextInfo,
Expand Down Expand Up @@ -63,14 +62,11 @@ export abstract class AbstractProvider {
abstract getPeers(): Promise<string[]>
abstract getVersion(): Promise<string>
abstract getNodeInfo(): Promise<NodeInfo>
abstract getDBEntry(key: string): Promise<string>
abstract getAccounts(): Promise<string[]>
abstract getNewTesseractFilter(): Promise<Filter>
abstract getNewTesseractsByAccountFilter(address: string): Promise<Filter>
abstract getPendingInteractionFilter(): Promise<Filter>
abstract getFilterChanges<T extends any>(filter: Filter): Promise<T>
abstract removeFilter(filter: Filter): Promise<FilterDeletionResult>
abstract getConnections(): Promise<ConnectionsInfo>

// Event Emitter (ish)
abstract on(eventName: EventType, listener: Listener): AbstractProvider;
Expand Down
67 changes: 5 additions & 62 deletions packages/js-moi-providers/src/base-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { EventType, Listener } from "../types/event";
import {
AccountMetaInfo, AccountMetaInfoParams, AccountParamsBase, AccountState, AccountStateParams,
AssetInfo, AssetInfoParams, BalanceParams, CallorEstimateIxObject, CallorEstimateOptions,
ConnectionsInfo, Content, ContentFrom, ContextInfo, DBEntryParams, Encoding, Filter,
FilterDeletionResult, Inspect, InteractionByTesseractParams, InteractionCallResponse,
InteractionParams, InteractionReceipt, InteractionRequest, InteractionResponse,
LogicManifestParams, NodeInfo, Options, Registry, RpcResponse, Status, StorageParams,
SyncStatus, SyncStatusParams, TDU, TDUResponse, TesseractParams
Content, ContentFrom, ContextInfo, Encoding, Filter, FilterDeletionResult, Inspect,
InteractionByTesseractParams, InteractionCallResponse, InteractionParams, InteractionReceipt,
InteractionRequest, InteractionResponse, LogicManifestParams, NodeInfo, Options, Registry,
RpcResponse, Status, StorageParams, SyncStatus, SyncStatusParams, TDU, TDUResponse,
TesseractParams
} from "../types/jsonrpc";
import { AbstractProvider } from "./abstract-provider";
import Event from "./event";
Expand Down Expand Up @@ -940,63 +940,6 @@ export class BaseProvider extends AbstractProvider {
}
}

/**
* Retrieves the value of a database entry with the specified key.
*
* @param {string} key - The key of the database entry.
* @returns {Promise<string>} A Promise that resolves to the value of the
* database entry as a string.
* @throws {Error} if there is an error executing the RPC call or processing
* the response.
*/
public async getDBEntry(key: string): Promise<string> {
try {
const params: DBEntryParams = {
key: key
}

const response: RpcResponse = await this.execute("debug.DBGet", params)

return this.processResponse(response)
} catch (error) {
throw error;
}
}

/**
* Retrieves the list of all registered accounts from a moipod.
*
* @returns {Promise<string[]>} A Promise that resolves to the list of
* accounts.
* @throws {Error} if there is an error executing the RPC call or processing
* the response.
*/
public async getAccounts(): Promise<string[]> {
try {
const response: RpcResponse = await this.execute("debug.Accounts", null)
return this.processResponse(response)
} catch (error) {
throw error;
}
}

/**
* Retrieves information about active network connections.
*
* @returns {Promise<ConnectionsInfo>} A Promise that resolves to an array of
* connection response object.
* @throws {Error} if there is an error executing the RPC call or processing
* the response.
*/
public async getConnections(): Promise<ConnectionsInfo> {
try {
const response: RpcResponse = await this.execute("debug.Connections", null)
return this.processResponse(response)
} catch (error) {
throw error;
}
}

/**
* Waits for the interaction with the specified hash to be included in a tesseract
* and returns the interaction receipt.
Expand Down
16 changes: 0 additions & 16 deletions packages/js-moi-providers/types/jsonrpc.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,6 @@ export interface StorageParams {
options: Options;
}

export interface DBEntryParams {
key: string;
}

// Type alias for encoding type
type Encoding = "JSON" | "POLO";

Expand Down Expand Up @@ -237,18 +233,6 @@ interface Stream {
direction: number;
}

interface Connection {
peer_id: string;
streams: Stream[];
}

export interface ConnectionsInfo {
connections: Connection[];
inbound_conn_count: number;
outbound_conn_count: number;
active_pub_sub_topics: { [topic: string]: number };
}

export interface AssetCreatePayload {
symbol: string;
supply: number | bigint;
Expand Down

0 comments on commit c67269b

Please sign in to comment.