Skip to content

Commit

Permalink
changing ws contract event format
Browse files Browse the repository at this point in the history
  • Loading branch information
pragmaxim committed Jan 14, 2025
1 parent ad541e3 commit 6196a5d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions packages/web3/src/ws/websocket-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,12 @@ export class WebSocketClient extends EventEmitter {
return this.subscribe('subscribe', ['tx']);
}

public async subscribeToContractEvents(eventIndex: number, addresses: string[]): Promise<string> {
return this.subscribe('subscribe', ['contract', eventIndex, addresses]);
public async subscribeToContractEvents(addresses: string[]): Promise<string> {
return this.subscribe('subscribe', ['contract', {addresses: addresses}]);
}

public async subscribeToFilteredContractEvents(eventIndex: number, addresses: string[]): Promise<string> {
return this.subscribe('subscribe', ['contract', {eventIndex: eventIndex, addresses: addresses}]);
}

public onConnected(callback: () => void) {
Expand Down
2 changes: 1 addition & 1 deletion test/websocket-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('WebSocketClient', () => {
try {
blockSubscriptionId = await client.subscribeToBlock();
txSubscriptionId = await client.subscribeToTx();
contractEventsSubscriptionId = await client.subscribeToContractEvents(0, [randomContractAddress()]);
contractEventsSubscriptionId = await client.subscribeToContractEvents([randomContractAddress()]);
await signAndSubmitTx();
} catch (error) {
done(error);
Expand Down

0 comments on commit 6196a5d

Please sign in to comment.