-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update testnet preview matcher (#48)
- Loading branch information
Showing
6 changed files
with
57 additions
and
54 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 |
---|---|---|
@@ -1,5 +1,11 @@ | ||
# @penumbra-labs/registry | ||
|
||
## 9.1.1 | ||
|
||
### Patch Changes | ||
|
||
- Fix testnet-preview parsing | ||
|
||
## 9.1.0 | ||
|
||
### Minor Changes | ||
|
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
const TESTNET_PREVIEW_PATTERN = /^(penumbra-testnet-(?:\w+-)*\w+)-[a-f0-9]{8}$/; | ||
|
||
export const isTestnetPreviewChainId = (chainId: string) => { | ||
return TESTNET_PREVIEW_PATTERN.test(chainId); | ||
// Test preview chain ids end with -x followed by a hexadecimal string | ||
export const isTestnetPreviewChainId = (chainId: string): boolean => { | ||
const previewRegex = /-x[0-9a-f]+$/i; | ||
return previewRegex.test(chainId); | ||
}; | ||
|
||
export const deriveTestnetChainIdFromPreview = (previewChainId: string): string | undefined => { | ||
const match = previewChainId.match(TESTNET_PREVIEW_PATTERN); | ||
if (match) { | ||
return match[1]; | ||
} | ||
return undefined; | ||
export const deriveTestnetChainIdFromPreview = (previewChainId: string): string => { | ||
const index = previewChainId.lastIndexOf('-x'); | ||
return previewChainId.substring(0, index); | ||
}; |