Skip to content

Commit

Permalink
RPC: add validator for pingpong extension type
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottyPoi committed Feb 28, 2025
1 parent 11d0efe commit 457efcd
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion packages/cli/src/rpc/validators.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { bytesToHex } from '@ethereumjs/util'
import { HistoryNetworkContentType, NetworkId } from 'portalnetwork'
import { HistoryNetworkContentType, NetworkId, PingPongCustomPayload } from 'portalnetwork'

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

Expand Down Expand Up @@ -506,4 +506,22 @@ export const validators = {
}
}
},

get extension() {
return (params: any[], index: number) => {
if (typeof params[index] !== 'number') {
return {
code: INVALID_PARAMS,
message: `invalid argument ${index}: argument must be a number`,
}
}
if (!(params[index] in PingPongCustomPayload)) {
return {
code: INVALID_PARAMS,
message: `invalid argument ${index}: argument must be a supported PingPong payload type`,
}
}
}
},
}

0 comments on commit 457efcd

Please sign in to comment.