Skip to content

Commit

Permalink
updating OriginString to string type
Browse files Browse the repository at this point in the history
  • Loading branch information
NiranjanaBinoy committed Oct 4, 2024
1 parent 8452666 commit 4737ce1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import type {
JsonRpcParams,
Hex,
} from '@metamask/utils';
import { OriginString } from '@metamask/permission-controller';
import { MESSAGE_TYPE } from '../../../../../shared/constants/app';
import {
HandlerWrapper,
Expand All @@ -28,7 +27,7 @@ export type ProviderStateHandlerResult = {
};

export type GetProviderState = (
origin: OriginString,
origin: string,
) => Promise<ProviderStateHandlerResult>;

type GetProviderStateConstraint<Params extends JsonRpcParams = JsonRpcParams> =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { JsonRpcEngineEndCallback } from '@metamask/json-rpc-engine';
import { PendingJsonRpcResponse } from '@metamask/utils';
import { MESSAGE_TYPE } from '../../../../../shared/constants/app';
import { HandlerRequestType } from './types';
import { HandlerRequestType as LogWeb3ShimUsageHandlerRequest } from './types';
import logWeb3ShimUsage, {
GetWeb3ShimUsageState,
SetWeb3ShimUsageRecorded,
} from './log-web3-shim-usage';

describe('logWeb3ShimUsage', () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let mockEnd: jest.Mock<any, any, any>;
let mockEnd: JsonRpcEngineEndCallback;
let mockGetWeb3ShimUsageState: GetWeb3ShimUsageState;
let mockSetWeb3ShimUsageRecorded: SetWeb3ShimUsageRecorded;

Expand All @@ -19,7 +19,7 @@ describe('logWeb3ShimUsage', () => {
});

it('should call getWeb3ShimUsageState and setWeb3ShimUsageRecorded when the handler is invoked', async () => {
const req: HandlerRequestType = {
const req: LogWeb3ShimUsageHandlerRequest = {
origin: 'testOrigin',
params: [],
id: '22',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ import type {
JsonRpcEngineEndCallback,
} from '@metamask/json-rpc-engine';
import type { JsonRpcParams, PendingJsonRpcResponse } from '@metamask/utils';
import { OriginString } from '@metamask/permission-controller';
import { MESSAGE_TYPE } from '../../../../../shared/constants/app';
import {
HandlerWrapper,
HandlerRequestType as LogWeb3ShimUsageHandlerRequest,
} from './types';

export type GetWeb3ShimUsageState = (origin: OriginString) => undefined | 1 | 2;
export type SetWeb3ShimUsageRecorded = (origin: OriginString) => void;
export type GetWeb3ShimUsageState = (origin: string) => undefined | 1 | 2;
export type SetWeb3ShimUsageRecorded = (origin: string) => void;

export type LogWeb3ShimUsageOptions = {
getWeb3ShimUsageState: GetWeb3ShimUsageState;
Expand Down
3 changes: 1 addition & 2 deletions app/scripts/lib/rpc-method-middleware/handlers/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { OriginString } from '@metamask/permission-controller';
import { JsonRpcParams, JsonRpcRequest } from '@metamask/utils';
import { MessageType } from '../../../../../shared/constants/app';

Expand All @@ -9,5 +8,5 @@ export type HandlerWrapper = {

export type HandlerRequestType<Params extends JsonRpcParams = JsonRpcParams> =
Required<JsonRpcRequest<Params>> & {
origin: OriginString;
origin: string;
};

0 comments on commit 4737ce1

Please sign in to comment.