Skip to content

Commit

Permalink
Move types to a different contract
Browse files Browse the repository at this point in the history
  • Loading branch information
seunlanlege committed Jul 23, 2024
1 parent 62989ce commit 2eeaf00
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 33 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@polytope-labs/solidity-merkle-trees",
"version": "0.2.1",
"version": "0.2.2",
"description": "The most advanced solidity library for merkle (multi) proof verification of different kinds of merkle trees",
"author": "Polytope Labs <hello@polytope.technology>",
"license": "Apache-2.0",
Expand Down
18 changes: 2 additions & 16 deletions src/MerkleMountainRange.sol
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
// SPDX-License-Identifier: Apache2
pragma solidity 0.8.17;

import "./MerkleMultiProof.sol";
import "openzeppelin/utils/math/Math.sol";

/// @title A representation of a MerkleMountainRange leaf
struct MmrLeaf {
// the leftmost index of a node
uint256 k_index;
// The position in the tree
uint256 leaf_index;
// The hash of the position in the tree
bytes32 hash;
}

struct Iterator {
uint256 offset;
bytes32[] data;
}
import "./MerkleMultiProof.sol";
import "./Types.sol";

/**
* @title A Merkle Mountain Range proof library
Expand Down
9 changes: 1 addition & 8 deletions src/MerkleMultiProof.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,7 @@
pragma solidity 0.8.17;

import "openzeppelin/utils/math/Math.sol";

/// @title A representation of a Merkle tree node
struct Node {
// Distance of the node to the leftmost node
uint256 k_index;
// A hash of the node itself
bytes32 node;
}
import "./Types.sol";

/**
* @title A Merkle Multi proof library
Expand Down
9 changes: 1 addition & 8 deletions src/MerklePatricia.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,10 @@ import "./trie/TrieDB.sol";

import "./trie/substrate/SubstrateTrieDB.sol";
import "./trie/ethereum/EthereumTrieDB.sol";
import "./Types.sol";

// SPDX-License-Identifier: Apache2

// Outcome of a successfully verified merkle-patricia proof
struct StorageValue {
// the storage key
bytes key;
// the encoded value
bytes value;
}

/**
* @title A Merkle Patricia library
* @author Polytope Labs
Expand Down
35 changes: 35 additions & 0 deletions src/Types.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
pragma solidity 0.8.17;

// SPDX-License-Identifier: Apache2

// Outcome of a successfully verified merkle-patricia proof
struct StorageValue {
// the storage key
bytes key;
// the encoded value
bytes value;
}

/// @title A representation of a Merkle tree node
struct Node {
// Distance of the node to the leftmost node
uint256 k_index;
// A hash of the node itself
bytes32 node;
}


/// @title A representation of a MerkleMountainRange leaf
struct MmrLeaf {
// the leftmost index of a node
uint256 k_index;
// The position in the tree
uint256 leaf_index;
// The hash of the position in the tree
bytes32 hash;
}

struct Iterator {
uint256 offset;
bytes32[] data;
}

0 comments on commit 2eeaf00

Please sign in to comment.