mirror of
https://github.com/selfxyz/self.git
synced 2026-04-05 03:00:53 -04:00
add fetchTreeFromUrl in utils.ts
This commit is contained in:
@@ -87,4 +87,17 @@ export function generateCommitment(secret: string, attestation_id: string, pubke
|
||||
dg2Hash2
|
||||
]);
|
||||
return commitment;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export async function fetchTreeFromUrl(url: string): Promise<LeanIMT> {
|
||||
const response = await fetch(url);
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
const commitmentMerkleTree = await response.json();
|
||||
console.log("\x1b[90m%s\x1b[0m", "commitment merkle tree: ", commitmentMerkleTree);
|
||||
const tree = new LeanIMT((a, b) => poseidon2([a, b]));
|
||||
tree.import(commitmentMerkleTree);
|
||||
return tree;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user