-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@embark/core): ensure 0x0 address are extended to full zero addre…
…sses This was a regression introduced in a web3 upgrade where `0x0` addresses where no longer accepted as valid addresses and have to be replaced with full zero addresses. This commit ensures that, if Embark apps still make use of `0x0` addresses in their configs, they are properly replaced or extended to satisfy web3's APIs. Fixes #956
- Loading branch information
Showing
5 changed files
with
155 additions
and
52 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const ZERO_ADDRESS_SHORTHAND_REGEX = /^0x0$/; | ||
const ZERO_ADDRESS_SHORTHAND_SEARCH_REGEX = /'0x0'/g; | ||
const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"; | ||
|
||
export function extendZeroAddressShorthand(value: string) { | ||
if (value.match(ZERO_ADDRESS_SHORTHAND_REGEX) !== null) { | ||
return ZERO_ADDRESS; | ||
} | ||
return value; | ||
} | ||
|
||
export function replaceZeroAddressShorthand(value: string) { | ||
return value.replace(ZERO_ADDRESS_SHORTHAND_SEARCH_REGEX, `'${ZERO_ADDRESS}'`); | ||
} |
Oops, something went wrong.