Skip to content

Commit

Permalink
feat: change the prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
barrutko committed Dec 16, 2024
1 parent c1aa644 commit 0125384
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/common-universal/src/types/CheckedAddress.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe(CheckedAddress.name, () => {

it('generates a random address with prefix', () => {
const address = CheckedAddress.random('alice')
expect(address.toLowerCase()).toMatchRegex(/^0x0000a11ce[0-9a-f]{31}$/)
expect(address.toLowerCase()).toMatchRegex(/^0xdeadbeefa11ce[0-9a-f]{27}$/)
})
})
})
2 changes: 1 addition & 1 deletion packages/common-universal/src/types/CheckedAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function CheckedAddress(value: string): CheckedAddress {
* Generates a random address. Tries to represent desired ascii prefix as hex value. Helps to identify transactions in the logs.
*/
CheckedAddress.random = (asciiPrefix = ''): CheckedAddress => {
const constantAddressPrefix = '0000'
const constantAddressPrefix = 'deadbeef'
const hexPrefix = asciiToHex(asciiPrefix)
const postfixLength = 40 - hexPrefix.length - constantAddressPrefix.length
assert(postfixLength >= 0, `Prefix too long: ${asciiPrefix}`)
Expand Down
2 changes: 1 addition & 1 deletion packages/common-universal/src/types/Hex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function Hex(hex: string, { allowEmpty = false } = {}): Hex {
}

Hex.random = (ascii = '', length = 64): Hex => {
const constantHexPrefix = '0000'
const constantHexPrefix = 'deadbeef'
assert(ascii.length <= length - constantHexPrefix.length, `Ascii prefix too long: ${ascii}`)
assert(length >= constantHexPrefix.length, `Total length too short: ${length}`)
return Hex(
Expand Down

0 comments on commit 0125384

Please sign in to comment.