Fix typographical errors (#5194)
Signed-off-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
@ -18,7 +18,7 @@ interface IERC1363Receiver {
|
|||||||
* (i.e. 0x88a7ca5c, or its own function selector).
|
* (i.e. 0x88a7ca5c, or its own function selector).
|
||||||
*
|
*
|
||||||
* @param operator The address which called `transferAndCall` or `transferFromAndCall` function.
|
* @param operator The address which called `transferAndCall` or `transferFromAndCall` function.
|
||||||
* @param from The address which are tokens transferred from.
|
* @param from The address which the tokens are transferred from.
|
||||||
* @param value The amount of tokens transferred.
|
* @param value The amount of tokens transferred.
|
||||||
* @param data Additional data with no specified format.
|
* @param data Additional data with no specified format.
|
||||||
* @return `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))` if transfer is allowed unless throwing.
|
* @return `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))` if transfer is allowed unless throwing.
|
||||||
|
|||||||
@ -15,7 +15,7 @@ library ERC1155Utils {
|
|||||||
* @dev Performs an acceptance check for the provided `operator` by calling {IERC1155-onERC1155Received}
|
* @dev Performs an acceptance check for the provided `operator` by calling {IERC1155-onERC1155Received}
|
||||||
* on the `to` address. The `operator` is generally the address that initiated the token transfer (i.e. `msg.sender`).
|
* on the `to` address. The `operator` is generally the address that initiated the token transfer (i.e. `msg.sender`).
|
||||||
*
|
*
|
||||||
* The acceptance call is not executed and treated as a no-op if the target address is doesn't contain code (i.e. an EOA).
|
* The acceptance call is not executed and treated as a no-op if the target address doesn't contain code (i.e. an EOA).
|
||||||
* Otherwise, the recipient must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value to accept
|
* Otherwise, the recipient must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value to accept
|
||||||
* the transfer.
|
* the transfer.
|
||||||
*/
|
*/
|
||||||
@ -50,7 +50,7 @@ library ERC1155Utils {
|
|||||||
* @dev Performs a batch acceptance check for the provided `operator` by calling {IERC1155-onERC1155BatchReceived}
|
* @dev Performs a batch acceptance check for the provided `operator` by calling {IERC1155-onERC1155BatchReceived}
|
||||||
* on the `to` address. The `operator` is generally the address that initiated the token transfer (i.e. `msg.sender`).
|
* on the `to` address. The `operator` is generally the address that initiated the token transfer (i.e. `msg.sender`).
|
||||||
*
|
*
|
||||||
* The acceptance call is not executed and treated as a no-op if the target address is doesn't contain code (i.e. an EOA).
|
* The acceptance call is not executed and treated as a no-op if the target address doesn't contain code (i.e. an EOA).
|
||||||
* Otherwise, the recipient must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value to accept
|
* Otherwise, the recipient must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value to accept
|
||||||
* the transfer.
|
* the transfer.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -50,7 +50,7 @@ library MerkleProof {
|
|||||||
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
|
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
|
||||||
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
|
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
|
||||||
* hash matches the root of the tree. When processing the proof, the pairs
|
* hash matches the root of the tree. When processing the proof, the pairs
|
||||||
* of leafs & pre-images are assumed to be sorted.
|
* of leaves & pre-images are assumed to be sorted.
|
||||||
*
|
*
|
||||||
* This version handles proofs in memory with the default hashing function.
|
* This version handles proofs in memory with the default hashing function.
|
||||||
*/
|
*/
|
||||||
@ -83,7 +83,7 @@ library MerkleProof {
|
|||||||
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
|
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
|
||||||
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
|
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
|
||||||
* hash matches the root of the tree. When processing the proof, the pairs
|
* hash matches the root of the tree. When processing the proof, the pairs
|
||||||
* of leafs & pre-images are assumed to be sorted.
|
* of leaves & pre-images are assumed to be sorted.
|
||||||
*
|
*
|
||||||
* This version handles proofs in memory with a custom hashing function.
|
* This version handles proofs in memory with a custom hashing function.
|
||||||
*/
|
*/
|
||||||
@ -115,7 +115,7 @@ library MerkleProof {
|
|||||||
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
|
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
|
||||||
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
|
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
|
||||||
* hash matches the root of the tree. When processing the proof, the pairs
|
* hash matches the root of the tree. When processing the proof, the pairs
|
||||||
* of leafs & pre-images are assumed to be sorted.
|
* of leaves & pre-images are assumed to be sorted.
|
||||||
*
|
*
|
||||||
* This version handles proofs in calldata with the default hashing function.
|
* This version handles proofs in calldata with the default hashing function.
|
||||||
*/
|
*/
|
||||||
@ -148,7 +148,7 @@ library MerkleProof {
|
|||||||
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
|
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
|
||||||
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
|
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
|
||||||
* hash matches the root of the tree. When processing the proof, the pairs
|
* hash matches the root of the tree. When processing the proof, the pairs
|
||||||
* of leafs & pre-images are assumed to be sorted.
|
* of leaves & pre-images are assumed to be sorted.
|
||||||
*
|
*
|
||||||
* This version handles proofs in calldata with a custom hashing function.
|
* This version handles proofs in calldata with a custom hashing function.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import {Math} from "../math/Math.sol";
|
|||||||
*
|
*
|
||||||
* This library supports PKCS#1 v1.5 padding to avoid malleability via chosen plaintext attacks in practical implementations.
|
* This library supports PKCS#1 v1.5 padding to avoid malleability via chosen plaintext attacks in practical implementations.
|
||||||
* The padding follows the EMSA-PKCS1-v1_5-ENCODE encoding definition as per section 9.2 of the RFC. This padding makes
|
* The padding follows the EMSA-PKCS1-v1_5-ENCODE encoding definition as per section 9.2 of the RFC. This padding makes
|
||||||
* RSA semanticaly secure for signing messages.
|
* RSA semantically secure for signing messages.
|
||||||
*
|
*
|
||||||
* Inspired by https://github.com/adria0/SolRsaVerify[Adrià Massanet's work]
|
* Inspired by https://github.com/adria0/SolRsaVerify[Adrià Massanet's work]
|
||||||
*/
|
*/
|
||||||
@ -26,7 +26,7 @@ library RSA {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Verifies a PKCSv1.5 signature given a digest according the verification
|
* @dev Verifies a PKCSv1.5 signature given a digest according to the verification
|
||||||
* method described in https://datatracker.ietf.org/doc/html/rfc8017#section-8.2.2[section 8.2.2 of RFC8017].
|
* method described in https://datatracker.ietf.org/doc/html/rfc8017#section-8.2.2[section 8.2.2 of RFC8017].
|
||||||
*
|
*
|
||||||
* IMPORTANT: Although this function allows for it, using n of length 1024 bits is considered unsafe.
|
* IMPORTANT: Although this function allows for it, using n of length 1024 bits is considered unsafe.
|
||||||
@ -136,7 +136,7 @@ library RSA {
|
|||||||
|
|
||||||
/// @dev Reads a bytes32 from a bytes array without bounds checking.
|
/// @dev Reads a bytes32 from a bytes array without bounds checking.
|
||||||
function _unsafeReadBytes32(bytes memory array, uint256 offset) private pure returns (bytes32 result) {
|
function _unsafeReadBytes32(bytes memory array, uint256 offset) private pure returns (bytes32 result) {
|
||||||
// Memory safetiness is guaranteed as long as the provided `array` is a Solidity-allocated bytes array
|
// Memory safeness is guaranteed as long as the provided `array` is a Solidity-allocated bytes array
|
||||||
// and `offset` is within bounds. This is the case for all calls to this private function from {pkcs1}.
|
// and `offset` is within bounds. This is the case for all calls to this private function from {pkcs1}.
|
||||||
assembly ("memory-safe") {
|
assembly ("memory-safe") {
|
||||||
result := mload(add(add(array, 0x20), offset))
|
result := mload(add(add(array, 0x20), offset))
|
||||||
|
|||||||
@ -91,7 +91,7 @@ library CircularBuffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Length of the buffer. This is the maximum number of elements kepts in the buffer.
|
* @dev Length of the buffer. This is the maximum number of elements kept in the buffer.
|
||||||
*/
|
*/
|
||||||
function length(Bytes32CircularBuffer storage self) internal view returns (uint256) {
|
function length(Bytes32CircularBuffer storage self) internal view returns (uint256) {
|
||||||
return self._data.length;
|
return self._data.length;
|
||||||
|
|||||||
@ -43,7 +43,7 @@ library Heap {
|
|||||||
using SafeCast for *;
|
using SafeCast for *;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Binary heap that support values of type uint256.
|
* @dev Binary heap that supports values of type uint256.
|
||||||
*
|
*
|
||||||
* Each element of that structure uses 2 storage slots.
|
* Each element of that structure uses 2 storage slots.
|
||||||
*/
|
*/
|
||||||
@ -235,7 +235,7 @@ library Heap {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Perform heap maintenance on `self`, starting at position `pos` (with the `value`), using `comp` as a
|
* @dev Perform heap maintenance on `self`, starting at position `pos` (with the `value`), using `comp` as a
|
||||||
* comparator, and moving toward the leafs of the underlying tree.
|
* comparator, and moving toward the leaves of the underlying tree.
|
||||||
*
|
*
|
||||||
* NOTE: This is a private function that is called in a trusted context with already cached parameters. `length`
|
* NOTE: This is a private function that is called in a trusted context with already cached parameters. `length`
|
||||||
* and `value` could be extracted from `self` and `pos`, but that would require redundant storage read. These
|
* and `value` could be extracted from `self` and `pos`, but that would require redundant storage read. These
|
||||||
@ -309,7 +309,7 @@ library Heap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Binary heap that support values of type uint208.
|
* @dev Binary heap that supports values of type uint208.
|
||||||
*
|
*
|
||||||
* Each element of that structure uses 1 storage slots.
|
* Each element of that structure uses 1 storage slots.
|
||||||
*/
|
*/
|
||||||
@ -501,7 +501,7 @@ library Heap {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Perform heap maintenance on `self`, starting at position `pos` (with the `value`), using `comp` as a
|
* @dev Perform heap maintenance on `self`, starting at position `pos` (with the `value`), using `comp` as a
|
||||||
* comparator, and moving toward the leafs of the underlying tree.
|
* comparator, and moving toward the leaves of the underlying tree.
|
||||||
*
|
*
|
||||||
* NOTE: This is a private function that is called in a trusted context with already cached parameters. `length`
|
* NOTE: This is a private function that is called in a trusted context with already cached parameters. `length`
|
||||||
* and `value` could be extracted from `self` and `pos`, but that would require redundant storage read. These
|
* and `value` could be extracted from `self` and `pos`, but that would require redundant storage read. These
|
||||||
|
|||||||
@ -45,7 +45,7 @@ import {Panic} from "../Panic.sol";
|
|||||||
|
|
||||||
const generate = ({ struct, node, valueType, indexType, blockSize }) => `\
|
const generate = ({ struct, node, valueType, indexType, blockSize }) => `\
|
||||||
/**
|
/**
|
||||||
* @dev Binary heap that support values of type ${valueType}.
|
* @dev Binary heap that supports values of type ${valueType}.
|
||||||
*
|
*
|
||||||
* Each element of that structure uses ${blockSize} storage slots.
|
* Each element of that structure uses ${blockSize} storage slots.
|
||||||
*/
|
*/
|
||||||
@ -237,7 +237,7 @@ function _swap(${struct} storage self, ${indexType} i, ${indexType} j) private {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Perform heap maintenance on \`self\`, starting at position \`pos\` (with the \`value\`), using \`comp\` as a
|
* @dev Perform heap maintenance on \`self\`, starting at position \`pos\` (with the \`value\`), using \`comp\` as a
|
||||||
* comparator, and moving toward the leafs of the underlying tree.
|
* comparator, and moving toward the leaves of the underlying tree.
|
||||||
*
|
*
|
||||||
* NOTE: This is a private function that is called in a trusted context with already cached parameters. \`length\`
|
* NOTE: This is a private function that is called in a trusted context with already cached parameters. \`length\`
|
||||||
* and \`value\` could be extracted from \`self\` and \`pos\`, but that would require redundant storage read. These
|
* and \`value\` could be extracted from \`self\` and \`pos\`, but that would require redundant storage read. These
|
||||||
|
|||||||
@ -66,7 +66,7 @@ function verify${suffix}(${(hash ? formatArgsMultiline : formatArgsSingleLine)(
|
|||||||
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
|
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
|
||||||
* from \`leaf\` using \`proof\`. A \`proof\` is valid if and only if the rebuilt
|
* from \`leaf\` using \`proof\`. A \`proof\` is valid if and only if the rebuilt
|
||||||
* hash matches the root of the tree. When processing the proof, the pairs
|
* hash matches the root of the tree. When processing the proof, the pairs
|
||||||
* of leafs & pre-images are assumed to be sorted.
|
* of leaves & pre-images are assumed to be sorted.
|
||||||
*
|
*
|
||||||
* This version handles proofs in ${location} with ${hash ? 'a custom' : 'the default'} hashing function.
|
* This version handles proofs in ${location} with ${hash ? 'a custom' : 'the default'} hashing function.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -6,9 +6,9 @@ const { StandardMerkleTree } = require('@openzeppelin/merkle-tree');
|
|||||||
|
|
||||||
const { generators } = require('../../helpers/random');
|
const { generators } = require('../../helpers/random');
|
||||||
|
|
||||||
const makeTree = (leafs = [ethers.ZeroHash]) =>
|
const makeTree = (leaves = [ethers.ZeroHash]) =>
|
||||||
StandardMerkleTree.of(
|
StandardMerkleTree.of(
|
||||||
leafs.map(leaf => [leaf]),
|
leaves.map(leaf => [leaf]),
|
||||||
['bytes32'],
|
['bytes32'],
|
||||||
{ sortLeaves: false },
|
{ sortLeaves: false },
|
||||||
);
|
);
|
||||||
@ -39,15 +39,15 @@ describe('MerkleTree', function () {
|
|||||||
|
|
||||||
describe('push', function () {
|
describe('push', function () {
|
||||||
it('tree is correctly updated', async function () {
|
it('tree is correctly updated', async function () {
|
||||||
const leafs = Array.from({ length: 2 ** Number(DEPTH) }, () => ethers.ZeroHash);
|
const leaves = Array.from({ length: 2 ** Number(DEPTH) }, () => ethers.ZeroHash);
|
||||||
|
|
||||||
// for each leaf slot
|
// for each leaf slot
|
||||||
for (const i in leafs) {
|
for (const i in leaves) {
|
||||||
// generate random leaf and hash it
|
// generate random leaf and hash it
|
||||||
const hashedLeaf = hashLeaf((leafs[i] = generators.bytes32()));
|
const hashedLeaf = hashLeaf((leaves[i] = generators.bytes32()));
|
||||||
|
|
||||||
// update leaf list and rebuild tree.
|
// update leaf list and rebuild tree.
|
||||||
const tree = makeTree(leafs);
|
const tree = makeTree(leaves);
|
||||||
|
|
||||||
// push value to tree
|
// push value to tree
|
||||||
await expect(this.mock.push(hashedLeaf)).to.emit(this.mock, 'LeafInserted').withArgs(hashedLeaf, i, tree.root);
|
await expect(this.mock.push(hashedLeaf)).to.emit(this.mock, 'LeafInserted').withArgs(hashedLeaf, i, tree.root);
|
||||||
@ -67,13 +67,13 @@ describe('MerkleTree', function () {
|
|||||||
|
|
||||||
it('reset', async function () {
|
it('reset', async function () {
|
||||||
// empty tree
|
// empty tree
|
||||||
const zeroLeafs = Array.from({ length: 2 ** Number(DEPTH) }, () => ethers.ZeroHash);
|
const zeroLeaves = Array.from({ length: 2 ** Number(DEPTH) }, () => ethers.ZeroHash);
|
||||||
const zeroTree = makeTree(zeroLeafs);
|
const zeroTree = makeTree(zeroLeaves);
|
||||||
|
|
||||||
// tree with one element
|
// tree with one element
|
||||||
const leafs = Array.from({ length: 2 ** Number(DEPTH) }, () => ethers.ZeroHash);
|
const leaves = Array.from({ length: 2 ** Number(DEPTH) }, () => ethers.ZeroHash);
|
||||||
const hashedLeaf = hashLeaf((leafs[0] = generators.bytes32())); // fill first leaf and hash it
|
const hashedLeaf = hashLeaf((leaves[0] = generators.bytes32())); // fill first leaf and hash it
|
||||||
const tree = makeTree(leafs);
|
const tree = makeTree(leaves);
|
||||||
|
|
||||||
// root should be that of a zero tree
|
// root should be that of a zero tree
|
||||||
expect(await this.mock.root()).to.equal(zeroTree.root);
|
expect(await this.mock.root()).to.equal(zeroTree.root);
|
||||||
|
|||||||
Reference in New Issue
Block a user