-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from cardano-foundation/feat/is-48-query-speci…
…fic-clientstate-consensus-state feat: IS-48 Implement Client-Specific Query for Client State and Consensus State
- Loading branch information
Showing
12 changed files
with
469 additions
and
477 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { GrpcInvalidArgumentException } from 'nestjs-grpc-exceptions'; | ||
import { QueryClientStateRequest, QueryConsensusStateRequest } from '@plus/proto-types/src/ibc/core/client/v1/query'; | ||
import { CLIENT_ID_PREFIX } from '../../constant'; | ||
|
||
export function validQueryClientStateParam(request: QueryClientStateRequest): QueryClientStateRequest { | ||
if (!request.client_id) throw new GrpcInvalidArgumentException('Invalid argument: "client_id" must be provided'); | ||
// validate prefix client id | ||
if (!request.client_id.startsWith(`${CLIENT_ID_PREFIX}-`)) { | ||
throw new GrpcInvalidArgumentException( | ||
`Invalid argument: "client_id". Please use the prefix "${CLIENT_ID_PREFIX}-"`, | ||
); | ||
} | ||
|
||
request.client_id = request.client_id.replace(`${CLIENT_ID_PREFIX}-`, ''); | ||
return request; | ||
} | ||
|
||
export function validQueryConsensusStateParam(request: QueryConsensusStateRequest): QueryConsensusStateRequest { | ||
if (!request.client_id) throw new GrpcInvalidArgumentException('Invalid argument: "client_id" must be provided'); | ||
// validate prefix client id | ||
if (!request.client_id.startsWith(`${CLIENT_ID_PREFIX}-`)) { | ||
throw new GrpcInvalidArgumentException( | ||
`Invalid argument: "client_id". Please use the prefix "${CLIENT_ID_PREFIX}-"`, | ||
); | ||
} | ||
if (!request.height) { | ||
throw new GrpcInvalidArgumentException('Invalid argument: "height" must be provided'); | ||
} | ||
|
||
request.client_id = request.client_id.replace(`${CLIENT_ID_PREFIX}-`, ''); | ||
return request; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.