Skip to content

Commit

Permalink
refactor: removed unused attributes from jsonrpc
Browse files Browse the repository at this point in the history
  • Loading branch information
andreabadesso committed Jul 29, 2024
1 parent 4ca637f commit 9f86c56
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 27 deletions.
2 changes: 1 addition & 1 deletion packages/hathor-rpc-handler/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */

export default {
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testPathIgnorePatterns: ['<rootDir>/__tests__/mocks/']
Expand Down
5 changes: 3 additions & 2 deletions packages/hathor-rpc-handler/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

export * from './rpcHandler';
export * from './types';
export * from './rpcMethods';
export * from './errors';
export * from './rpcHandler';
export * from './rpcMethods';
export * from './rpcRequest';
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ import {
SendNanoContractRpcRequest,
} from '../types';

export function sendNanoContractTx(
export function sendNanoContractTxRpcRequest(
method: string,
blueprintId: string,
actions: NanoContractAction[],
args: unknown[],
pushTx: boolean,
ncId: string | null,
): Omit<SendNanoContractRpcRequest, 'id' | 'jsonrpc'> {
): SendNanoContractRpcRequest {
return {
method: RpcMethods.SendNanoContractTx,
params: {
method,
blueprint_id: blueprintId,
nc_id: ncId,
actions,
args,
push_tx: pushTx,
nc_id: ncId,
}
};
}
4 changes: 2 additions & 2 deletions packages/hathor-rpc-handler/src/rpcRequest/signOracleData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import {
SignOracleDataRpcRequest,
} from '../types';

export function signOracleData(
export function signOracleDataRpcRequest(
network: string,
data: string,
oracle: string,
): Omit<SignOracleDataRpcRequest, 'id' | 'jsonrpc'> {
): SignOracleDataRpcRequest {
return {
method: RpcMethods.SignOracleData,
params: {
Expand Down
4 changes: 2 additions & 2 deletions packages/hathor-rpc-handler/src/rpcRequest/signWithAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import {
SignWithAddressRpcRequest,
} from '../types';

export function signWithAddress(
export function signWithAddressRpcRequest(
network: string,
message: string,
addressIndex: number,
): Omit<SignWithAddressRpcRequest, 'id' | 'jsonrpc'> {
): SignWithAddressRpcRequest {
return {
method: RpcMethods.SignWithAddress,
params: {
Expand Down
29 changes: 13 additions & 16 deletions packages/hathor-rpc-handler/src/types/rpcRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@ export enum RpcMethods {
SignOracleData = 'htr_signOracleData',
}

export interface BaseRpcRequest {
method: string;
id: string;
jsonrpc: string;
}

export interface GetAddressRpcRequest extends BaseRpcRequest {
export interface GetAddressRpcRequest {
method: RpcMethods.GetAddress,
params: {
type: 'first_empty' | 'full_path' | 'index' | 'client';
Expand All @@ -36,7 +30,7 @@ export interface GetAddressRpcRequest extends BaseRpcRequest {
}
}

export interface GetBalanceRpcRequest extends BaseRpcRequest {
export interface GetBalanceRpcRequest {
method: RpcMethods.GetBalance,
params: {
network: string;
Expand All @@ -45,7 +39,7 @@ export interface GetBalanceRpcRequest extends BaseRpcRequest {
};
}

export interface GetUtxosRpcRequest extends BaseRpcRequest {
export interface GetUtxosRpcRequest {
method: RpcMethods.GetUtxos,
params: {
network: string;
Expand All @@ -60,7 +54,7 @@ export interface GetUtxosRpcRequest extends BaseRpcRequest {
};
}

export interface SignOracleDataRpcRequest extends BaseRpcRequest {
export interface SignOracleDataRpcRequest {
method: RpcMethods.SignOracleData,
params: {
network: string;
Expand All @@ -69,7 +63,7 @@ export interface SignOracleDataRpcRequest extends BaseRpcRequest {
}
}

export interface SignWithAddressRpcRequest extends BaseRpcRequest {
export interface SignWithAddressRpcRequest {
method: RpcMethods.SignWithAddress,
params: {
network: string;
Expand All @@ -87,7 +81,7 @@ export interface QueryUtxosFilters {
authorities?: number | null;
}

export interface SignOracleData extends BaseRpcRequest {
export interface SignOracleData {
method: RpcMethods.SignOracleData,
params: {
network: string;
Expand All @@ -96,7 +90,7 @@ export interface SignOracleData extends BaseRpcRequest {
}
}

export interface SendNanoContractRpcRequest extends BaseRpcRequest {
export interface SendNanoContractRpcRequest {
method: RpcMethods.SendNanoContractTx,
params: {
method: string;
Expand All @@ -112,11 +106,12 @@ export type RequestMetadata = {
[key: string]: string,
};

export interface GetConnectedNetworkRpcRequest extends BaseRpcRequest {
export interface GetConnectedNetworkRpcRequest {
method: RpcMethods.GetConnectedNetwork,
}

export interface GenericRpcRequest extends BaseRpcRequest {
export interface GenericRpcRequest {
method: string;
params?: unknown | null;
}

Expand All @@ -125,4 +120,6 @@ export type RpcRequest =
| GetBalanceRpcRequest
| GetUtxosRpcRequest
| SignWithAddressRpcRequest
| GenericRpcRequest;
| GenericRpcRequest
| SendNanoContractRpcRequest
| SignOracleDataRpcRequest;
3 changes: 2 additions & 1 deletion packages/hathor-rpc-handler/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"forceConsistentCasingInFileNames": true,
"outDir": "./dist",
"rootDir": "./src/",
"types": ["node", "jest"]
"types": ["node", "jest"],
"declaration": true
},
"exclude": [
"__tests__/",
Expand Down

0 comments on commit 9f86c56

Please sign in to comment.