This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle StarkWare proxy version 5 (#149)
* Handle StarkWare proxy version 5 * Format and lint fixes * Changeset
- Loading branch information
1 parent
d0a563d
commit 9fba046
Showing
7 changed files
with
205 additions
and
52 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 @@ | ||
# @l2beat/discovery | ||
|
||
## 0.44.6 | ||
|
||
### Patch Changes | ||
|
||
- Handle StarkWare proxy version 5 | ||
|
||
## 0.44.5 | ||
|
||
### Patch 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { expect } from 'earl' | ||
|
||
import { parseSemver } from './semver' | ||
|
||
describe(parseSemver.name, () => { | ||
it('should parse a version', () => { | ||
expect(parseSemver('1.2.3')).toEqual({ major: 1, minor: 2, patch: 3 }) | ||
expect(parseSemver('0.0.0')).toEqual({ major: 0, minor: 0, patch: 0 }) | ||
expect(parseSemver('1.0.0')).toEqual({ major: 1, minor: 0, patch: 0 }) | ||
expect(parseSemver('0.1.0')).toEqual({ major: 0, minor: 1, patch: 0 }) | ||
expect(parseSemver('0.0.1')).toEqual({ major: 0, minor: 0, patch: 1 }) | ||
expect(parseSemver('999.999.999')).toEqual({ | ||
major: 999, | ||
minor: 999, | ||
patch: 999, | ||
}) | ||
}) | ||
|
||
it('should throw on invalid characters in the version string', () => { | ||
expect(() => parseSemver('1.2.3!')).toThrow() | ||
}) | ||
|
||
it('should handle leading zeros in the version string', () => { | ||
expect(parseSemver('1.02.03')).toEqual({ major: 1, minor: 2, patch: 3 }) | ||
expect(parseSemver('01.02.03')).toEqual({ major: 1, minor: 2, patch: 3 }) | ||
}) | ||
|
||
it('throws on invalid semantic version string', () => { | ||
expect(() => parseSemver('1.2')).toThrow() | ||
expect(() => parseSemver('1.a.3')).toThrow() | ||
expect(() => parseSemver('1.2.3.4')).toThrow() | ||
expect(() => parseSemver('')).toThrow() | ||
}) | ||
}) |
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,24 @@ | ||
import { assert } from '@l2beat/backend-tools' | ||
|
||
export interface Semver { | ||
major: number | ||
minor: number | ||
patch: number | ||
} | ||
|
||
export function parseSemver(version: string): Semver { | ||
const numbers = version.split('.').map(Number) | ||
|
||
assert(numbers.length === 3, 'Invalid semantic version string') | ||
assert( | ||
numbers.every((n) => !isNaN(n)), | ||
'Invalid semantic version string', | ||
) | ||
|
||
const [major, minor, patch] = numbers | ||
assert(major !== undefined, 'Failed to parse major version') | ||
assert(minor !== undefined, 'Failed to parse minor version') | ||
assert(patch !== undefined, 'Failed to parse patch version') | ||
|
||
return { major, minor, patch } | ||
} |