-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: fix @ethereumjs/util mock
- Loading branch information
Showing
4 changed files
with
34 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,32 @@ | ||
const zeroAddress = function() { | ||
const addressLength = 20 | ||
const addr = zeros(addressLength) | ||
return bufferToHex(addr) | ||
} | ||
// Vendored from @ethereumjs/[email protected] / [email protected] | ||
|
||
/** | ||
* Converts a `Buffer` into a `0x`-prefixed hex `String`. | ||
* | ||
* @param buf - `Buffer` object to convert | ||
*/ | ||
const bufferToHex = function (buf) { | ||
// buf = toBuffer(buf); | ||
return `0x${buf.toString('hex')}`; | ||
}; | ||
|
||
/** | ||
* Returns a buffer filled with 0s. | ||
* | ||
* @param bytes - the number of bytes the buffer should be | ||
*/ | ||
const zeros = function (bytes) { | ||
return Buffer.allocUnsafe(bytes).fill(0); | ||
}; | ||
|
||
/** | ||
* Returns the zero address. | ||
*/ | ||
const zeroAddress = function () { | ||
const addressLength = 20; | ||
const addr = zeros(addressLength); | ||
return bufferToHex(addr); | ||
}; | ||
|
||
module.exports = { | ||
zeroAddress, | ||
|
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