-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: upload user & proofs to directus #12
base: main
Are you sure you want to change the base?
Conversation
Important Review skippedReview was skipped due to path filters Files ignored due to path filters (1)
You can disable this status message by setting the WalkthroughThis update centers around integrating the Directus SDK and enhancing Merkle tree functionalities. The key changes include adding the Directus SDK dependency, renaming and modifying functions related to Merkle trees in Changes
Poem
TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Outside diff range and nitpick comments (1)
src/sync/merkle.cjs (1)
Line range hint
12-21
:
Ensure proper error handling.While the function
getMerkleTree
appears correct, consider adding error handling to manage potential issues withgetCombinedPoints
or Merkle tree creation.async function getMerkleTree(chainId) { try { const data = await getCombinedPoints(chainId); console.log("Generating Merkle Root........"); const leaves = Object.keys(data).map((tokenId) => { return encodeLeaf(tokenId, data[tokenId]); }); const tree = new MerkleTree(leaves, keccack256, { sortPairs: true }); const root = tree.getHexRoot(); console.log("root:", root); return [tree, root]; } catch (error) { console.error("Error generating Merkle tree:", error); throw error; } }
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (4)
- package.json (1 hunks)
- src/sync/merkle.cjs (3 hunks)
- src/sync/sync.js (2 hunks)
- src/sync/utils.cjs (1 hunks)
Files skipped from review due to trivial changes (1)
- package.json
Additional comments not posted (7)
src/sync/merkle.cjs (2)
7-11
: Good practice: Added JSDoc comments.The JSDoc comments provide clear documentation for the
getMerkleTree
function, specifying the parameter type and return type.
30-30
: LGTM! Module exports updated correctly.The module exports have been updated to include
getMerkleTree
andencodeLeaf
.src/sync/sync.js (4)
4-4
: Updated import statements.The import statements have been updated to include
getMerkleTree
,encodeLeaf
,getCombinedPoints
,createDirectus
, andcreateItems
.
7-8
: New imports for Directus SDK.The imports for
createDirectus
andcreateItems
from@directus/sdk
are correctly added.
10-11
: Ensure environment variables are set.The
directusUrl
andstaticToken
environment variables are used. Ensure these variables are correctly set in the environment.
42-63
: Good practice: Improvedsync
function.The
sync
function is updated to handle combined points and interact with the Directus API. Ensure proper error handling and logging.src/sync/utils.cjs (1)
41-45
: Good practice: Added JSDoc comments.The JSDoc comments provide clear documentation for the
getCombinedPoints
function, specifying the parameter type and return type.
function getDirectusClient() { | ||
if (!directusUrl) throw new Error("Missing Params."); | ||
|
||
const client = createDirectus(process.env.DIRECTUS_URL) | ||
.with(authentication()) | ||
.with(rest()); | ||
|
||
if (staticToken) { | ||
client.setToken(staticToken); | ||
} | ||
return client; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good practice: Added getDirectusClient
function.
The getDirectusClient
function is well-structured to create and configure the Directus client. Consider handling potential errors when creating the client.
function getDirectusClient() {
if (!directusUrl) throw new Error("Missing Params.");
try {
const client = createDirectus(process.env.DIRECTUS_URL)
.with(authentication())
.with(rest());
if (staticToken) {
client.setToken(staticToken);
}
return client;
} catch (error) {
console.error("Error creating Directus client:", error);
throw error;
}
}
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
function getDirectusClient() { | |
if (!directusUrl) throw new Error("Missing Params."); | |
const client = createDirectus(process.env.DIRECTUS_URL) | |
.with(authentication()) | |
.with(rest()); | |
if (staticToken) { | |
client.setToken(staticToken); | |
} | |
return client; | |
} | |
function getDirectusClient() { | |
if (!directusUrl) throw new Error("Missing Params."); | |
try { | |
const client = createDirectus(process.env.DIRECTUS_URL) | |
.with(authentication()) | |
.with(rest()); | |
if (staticToken) { | |
client.setToken(staticToken); | |
} | |
return client; | |
} catch (error) { | |
console.error("Error creating Directus client:", error); | |
throw error; | |
} | |
} |
Summary by CodeRabbit
getCombinedPoints
function with JSDoc comments for better type information.getMerkleRoot
function togetMerkleTree
to return an array with the Merkle tree and root string.@directus/sdk
version15.0.3
to project dependencies.