Skip to content

Commit

Permalink
revert some MR changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammad-Altabba committed Jun 18, 2023
1 parent 2ff5a00 commit 4d533cb
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions packages/web3-core/src/web3_subscription_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ export class Web3SubscriptionManager<
if (sub) {
// for EIP-1193 provider
if (data?.data) {
sub.processSubscriptionResult(data?.data?.result ?? data?.data);
sub._processSubscriptionResult(data?.data?.result ?? data?.data);
} else if (
data &&
jsonRpc.isResponseWithNotification(
data as unknown as JsonRpcSubscriptionResult | JsonRpcNotification<Log>,
)
) {
sub.processSubscriptionResult(data?.params.result);
sub._processSubscriptionResult(data?.params.result);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-core/src/web3_subscriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export abstract class Web3Subscription<
}

// eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars
public processSubscriptionResult(_data: unknown) {
protected _processSubscriptionResult(_data: unknown) {
// Do nothing - This should be overridden in subclass.
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('Web3Subscription', () => {
},
},
};
const processResult = jest.spyOn(sub, 'processSubscriptionResult');
const processResult = jest.spyOn(sub, '_processSubscriptionResult');
provider.emit('data', testData);
expect(processResult).toHaveBeenCalledWith(testData.data.result);
});
Expand All @@ -79,7 +79,7 @@ describe('Web3Subscription', () => {
},
},
};
const processResult = jest.spyOn(sub, 'processSubscriptionResult');
const processResult = jest.spyOn(sub, '_processSubscriptionResult');
provider.emit('data', testData);
expect(processResult).toHaveBeenCalledWith(testData.data);
});
Expand All @@ -97,7 +97,7 @@ describe('Web3Subscription', () => {
},
},
};
const processResult = jest.spyOn(sub, 'processSubscriptionResult');
const processResult = jest.spyOn(sub, '_processSubscriptionResult');
eipProvider.emit('message', testData);
expect(processResult).toHaveBeenCalledWith(testData.data.result);
});
Expand All @@ -116,7 +116,7 @@ describe('Web3Subscription', () => {
},
},
};
const processResult = jest.spyOn(sub, 'processSubscriptionResult');
const processResult = jest.spyOn(sub, '_processSubscriptionResult');
eipProvider.emit('message', testData);
expect(processResult).toHaveBeenCalledWith(testData.data);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-eth-contract/src/log_subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class LogsSubscription extends Web3Subscription<
];
}

public processSubscriptionResult(data: LogsInput): void {
public _processSubscriptionResult(data: LogsInput): void {
const decoded = decodeEventABI(this.abi, data, this.jsonInterface, super.returnFormat);
this.emit('data', decoded);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-eth/src/web3_eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,7 @@ export class Web3Eth extends Web3Context<Web3EthExecutionAPI, RegisteredSubscrip
this.getPastLogs(args)
.then(logs => {
for (const log of logs) {
subscription.processSubscriptionResult(log as LogsOutput);
subscription._processSubscriptionResult(log as LogsOutput);
}
})
.catch(e => {
Expand Down
10 changes: 5 additions & 5 deletions packages/web3-eth/src/web3_subscriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ export class LogsSubscription extends Web3Subscription<
return ['logs', this.args] as ['logs', any];
}

public processSubscriptionResult(data: LogsOutput) {
public _processSubscriptionResult(data: LogsOutput) {
this.emit('data', format(logSchema, data, super.returnFormat));
}

protected _processSubscriptionError(error: Error) {
public _processSubscriptionError(error: Error) {
this.emit('error', error);
}
}
Expand All @@ -87,7 +87,7 @@ export class NewPendingTransactionsSubscription extends Web3Subscription<
return ['newPendingTransactions'] as ['newPendingTransactions'];
}

public processSubscriptionResult(data: string) {
protected _processSubscriptionResult(data: string) {
this.emit('data', format({ format: 'string' }, data, super.returnFormat));
}

Expand Down Expand Up @@ -135,7 +135,7 @@ export class NewHeadsSubscription extends Web3Subscription<
return ['newHeads'] as ['newHeads'];
}

public processSubscriptionResult(data: BlockHeaderOutput) {
protected _processSubscriptionResult(data: BlockHeaderOutput) {
this.emit('data', format(blockHeaderSchema, data, super.returnFormat));
}

Expand Down Expand Up @@ -174,7 +174,7 @@ export class SyncingSubscription extends Web3Subscription<
return ['syncing'] as ['syncing'];
}

public processSubscriptionResult(
protected _processSubscriptionResult(
data:
| {
syncing: boolean;
Expand Down
6 changes: 3 additions & 3 deletions packages/web3-eth/test/unit/web3_eth_subscription.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('Web3Eth subscribe and clear subscriptions', () => {
expect(logs).toStrictEqual(dummyLogs);
});

it('should call `processSubscriptionResult` when the logs are of type LogsSubscription and the `fromBlock` is provided', async () => {
it('should call `_processSubscriptionResult` when the logs are of type LogsSubscription and the `fromBlock` is provided', async () => {
const requestManager = { send: jest.fn(), on: jest.fn(), provider: { on: jest.fn() } };
const subManager = new Web3SubscriptionManager(requestManager as any, undefined as any);

Expand All @@ -59,15 +59,15 @@ describe('Web3Eth subscribe and clear subscriptions', () => {
} as unknown as Web3BaseProvider,
subscriptionManager: subManager,
});
jest.spyOn(dummyLogs, 'processSubscriptionResult');
jest.spyOn(dummyLogs, '_processSubscriptionResult');

const logs = await web3Eth.subscribe('logs', {
fromBlock: 0,
});
await sleep(100);

expect(logs).toStrictEqual(dummyLogs);
expect(dummyLogs.processSubscriptionResult).toHaveBeenCalled();
expect(dummyLogs._processSubscriptionResult).toHaveBeenCalled();
});

it('should be able to clear subscriptions', async () => {
Expand Down

0 comments on commit 4d533cb

Please sign in to comment.