Skip to content

Commit 457efcd

Browse files
committed
RPC: add validator for pingpong extension type
1 parent 11d0efe commit 457efcd

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

packages/cli/src/rpc/validators.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { bytesToHex } from '@ethereumjs/util'
2-
import { HistoryNetworkContentType, NetworkId } from 'portalnetwork'
2+
import { HistoryNetworkContentType, NetworkId, PingPongCustomPayload } from 'portalnetwork'
33

44
import { isValidEnr } from '../util.js'
55

@@ -506,4 +506,22 @@ export const validators = {
506506
}
507507
}
508508
},
509+
510+
get extension() {
511+
return (params: any[], index: number) => {
512+
if (typeof params[index] !== 'number') {
513+
return {
514+
code: INVALID_PARAMS,
515+
message: `invalid argument ${index}: argument must be a number`,
516+
}
517+
}
518+
if (!(params[index] in PingPongCustomPayload)) {
519+
return {
520+
code: INVALID_PARAMS,
521+
message: `invalid argument ${index}: argument must be a supported PingPong payload type`,
522+
}
523+
}
524+
}
525+
},
509526
}
527+

0 commit comments

Comments
 (0)