-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: versions format and other PR comments
- Loading branch information
1 parent
8792ad1
commit da8359c
Showing
6 changed files
with
51 additions
and
45 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
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
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
export const formatBtcVersion = (version: number) => { | ||
const parts = getBtcVersionParts(version) | ||
if (parts.length < 3) return '' | ||
if (parts[0] === 0) { | ||
return `v${parts[0]}.${parts[1]}.${parts[2]}` | ||
} else { | ||
return `v${parts[0]}.${parts[1]}` | ||
} | ||
} | ||
|
||
export const formatDogeVersion = (version: number) => { | ||
const parts = getBtcVersionParts(version) | ||
if (parts.length < 3) return '' | ||
return `v${parts[0]}.${parts[1]}.${parts[2]}` | ||
} | ||
|
||
export const formatEthVersion = (version: string) => { | ||
const parts = version.split('/') | ||
const clientName = parts.length > 0 ? parts[0] : '' | ||
const fullVersion = parts.length > 1 ? parts[1] : '' | ||
const simplifiedVersion = fullVersion.split('-')[0] | ||
return `${clientName}/${simplifiedVersion}` | ||
} | ||
|
||
export const getBtcVersionParts = (version: number) => | ||
version | ||
.toString() | ||
.padStart(8, '0') | ||
.match(/.{1,2}/g) | ||
?.map((item) => +item) || [] |