-
Notifications
You must be signed in to change notification settings - Fork 116
Add SimpleMerkleTree #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
302fa2d
Simple MerkleTree alternative
ernestognw f24e205
wip
Amxx 30d150c
Use generic MerkleTreeImpl
Amxx 21399c1
MerkleTree interface
Amxx eabc28e
explicit type
Amxx 6eaf646
use bind instead of curation
Amxx d9678a6
fix default
Amxx 034ce88
newline
Amxx 2da68b1
add prettier (config ported from @openzeppelin/contracts)
Amxx b2d34fc
more generic multiproof: input support all BytesLike, output is expli…
Amxx bcfc765
Merge branch 'master' into support-raw-leaves-inheritance
Amxx 62ab129
remove empty file
Amxx ec339e1
Apply PR suggestions
ernestognw 826ffab
Unify all error interfaces
ernestognw ada28f1
Unify errors
ernestognw b73e3c4
fix naming
Amxx 72057f3
Update src/merkletree.ts
Amxx de39370
rename leafHasher to leafHash, and make mark it as public
Amxx 1be7ece
rewrite checks
Amxx 5e69b25
remove duplicate test
Amxx de68246
simplify
Amxx e13943e
naming consistency
Amxx e5e035e
refactor
Amxx 64b7dfa
split value validation and leafHashing
Amxx 5d5deb8
deduplicate type definition
Amxx 2ce3d55
specify type
Amxx 1ad4309
fix lint
Amxx b13748a
refactor
Amxx fd1cf28
Nits
ernestognw a87db4c
Merge branch 'master' into support-raw-leaves-inheritance
Amxx d2b6e97
Add dumps
Amxx 84e96d5
fix name
Amxx 640e378
remove duplicate
Amxx 6578293
up
Amxx 1b587e8
Exclude number type support from MerkleTree
ernestognw a0e8b20
Address comments from @frangio
Amxx f48455e
fix lint
Amxx 5d1ceb7
types → interfaces
Amxx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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,19 +1,12 @@ | ||
| import { bytesToHex } from 'ethereum-cryptography/utils'; | ||
| import type { BytesLike } from '@ethersproject/bytes'; | ||
| type HexString = string; | ||
|
|
||
| export type Bytes = Uint8Array; | ||
| import { arrayify as toBytes, hexlify as toHex, concat } from '@ethersproject/bytes'; | ||
|
|
||
| export function compareBytes(a: Bytes, b: Bytes): number { | ||
| const n = Math.min(a.length, b.length); | ||
|
|
||
| for (let i = 0; i < n; i++) { | ||
| if (a[i] !== b[i]) { | ||
| return a[i]! - b[i]!; | ||
| } | ||
| } | ||
|
|
||
| return a.length - b.length; | ||
| function compare(a: BytesLike, b: BytesLike): number { | ||
| const diff = BigInt(toHex(a)) - BigInt(toHex(b)); | ||
| return diff > 0 ? 1 : diff < 0 ? -1 : 0; | ||
| } | ||
|
|
||
| export function hex(b: Bytes): string { | ||
| return '0x' + bytesToHex(b); | ||
| } | ||
| export type { HexString, BytesLike }; | ||
| export { toBytes, toHex, concat, compare }; | ||
This file contains hidden or 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 hidden or 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 hidden or 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,9 @@ | ||
| import assert from 'assert/strict'; | ||
| import { SimpleMerkleTree, StandardMerkleTree } from '.'; | ||
|
|
||
| describe('index properties', () => { | ||
| it('classes are exported', () => { | ||
| assert.notEqual(SimpleMerkleTree, undefined); | ||
| assert.notEqual(StandardMerkleTree, undefined); | ||
| }); | ||
| }); |
This file contains hidden or 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 +1,2 @@ | ||
| export { SimpleMerkleTree } from './simple'; | ||
| export { StandardMerkleTree } from './standard'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.