Only the result property is ever used

This commit is contained in:
Franck Royer 2021-05-03 15:54:40 +10:00
parent 656227d431
commit de57b2691e
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4

View File

@ -137,20 +137,13 @@ export class NimWaku {
async peers(): Promise<string[]> { async peers(): Promise<string[]> {
this.checkProcess(); this.checkProcess();
const res = await this.rpcCall<string[]>('get_waku_v2_admin_v1_peers', []); return this.rpcCall<string[]>('get_waku_v2_admin_v1_peers', []);
return res.result;
} }
async info(): Promise<RpcInfoResponse> { async info(): Promise<RpcInfoResponse> {
this.checkProcess(); this.checkProcess();
const res = await this.rpcCall<RpcInfoResponse>( return this.rpcCall<RpcInfoResponse>('get_waku_v2_debug_v1_info', []);
'get_waku_v2_debug_v1_info',
[]
);
return res.result;
} }
async sendMessage(message: WakuMessage): Promise<boolean> { async sendMessage(message: WakuMessage): Promise<boolean> {
@ -165,23 +158,18 @@ export class NimWaku {
contentTopic: message.contentTopic, contentTopic: message.contentTopic,
}; };
const res = await this.rpcCall<boolean>('post_waku_v2_relay_v1_message', [ return this.rpcCall<boolean>('post_waku_v2_relay_v1_message', [
RelayDefaultTopic, RelayDefaultTopic,
rpcMessage, rpcMessage,
]); ]);
return res.result;
} }
async messages(): Promise<WakuMessage[]> { async messages(): Promise<WakuMessage[]> {
this.checkProcess(); this.checkProcess();
const res = await this.rpcCall<WakuMessage[]>( return this.rpcCall<WakuMessage[]>('get_waku_v2_relay_v1_messages', [
'get_waku_v2_relay_v1_messages', RelayDefaultTopic,
[RelayDefaultTopic] ]);
);
return res.result;
} }
async getPeerId(): Promise<PeerId> { async getPeerId(): Promise<PeerId> {
@ -220,7 +208,7 @@ export class NimWaku {
private async rpcCall<T>( private async rpcCall<T>(
method: string, method: string,
params: Array<string | number | unknown> params: Array<string | number | unknown>
): Promise<{ result: T }> { ): Promise<T> {
const res = await axios.post( const res = await axios.post(
this.rpcUrl, this.rpcUrl,
{ {
@ -234,7 +222,7 @@ export class NimWaku {
} }
); );
return res.data; return res.data.result;
} }
private checkProcess(): void { private checkProcess(): void {