Closed kemuru closed 1 month ago
The recent updates mainly enhance the kleros-sdk
by introducing JSON parsing, refining object property handling, and improving string placeholder replacements. Key changes include JSON parsing in jsonAction
function, the addition of a nested property access helper in createResultObject
, and enhanced replacePlaceholdersWithValues
functionality using the mustache
library.
File Path | Change Summary |
---|---|
.../jsonAction.ts |
Added JSON parsing for value before processing. |
.../executeActions.ts |
Introduced a blank line after the await executeAction call, no functional changes. |
.../createResultObject.ts |
Changed seek and populate to arrays, added nested property access helper (getNestedValue ). |
.../replacePlaceholdersWithValues.ts |
Improved placeholder replacements using mustache , added logic for string pattern handling. |
sequenceDiagram
participant User
participant SDK as kleros-sdk
participant JsonAction as jsonAction
participant ResultObj as createResultObject
User->>SDK: Call jsonAction with mapping
SDK->>JsonAction: jsonAction(mapping)
JsonAction->>JsonAction: Parse value if string
JsonAction-->>ResultObj: createResultObject(parsedValue, seek, populate)
ResultObj->>JsonAction: Return result
JsonAction->>SDK: Return result
SDK->>User: Provide processed result
In the land of code so bright,
Where JSON strings take flight,
Nested keys with glee,
Unlock truths like a key,
Through mustache and seek,
Data's future, sleek,
For devs, a wondrous sight!
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Name | Link |
---|---|
Latest commit | 1620fdaa1b7f7557223638054c449cbe786dbbd2 |
Latest deploy log | https://app.netlify.com/sites/kleros-v2-university/deploys/6670c7c2644c690008f417f4 |
Name | Link |
---|---|
Latest commit | 1620fdaa1b7f7557223638054c449cbe786dbbd2 |
Latest deploy log | https://app.netlify.com/sites/kleros-v2/deploys/6670c7c2ec8ef10008cbc1fa |
Deploy Preview | https://deploy-preview-1619--kleros-v2.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
Name | Link |
---|---|
Latest commit | 1620fdaa1b7f7557223638054c449cbe786dbbd2 |
Latest deploy log | https://app.netlify.com/sites/kleros-v2-neo/deploys/6670c7c20406550008d8bf7c |
Deploy Preview | https://deploy-preview-1619--kleros-v2-neo.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
Name | Link |
---|---|
Latest commit | 78dbbf69139004d751475f44dd5811ef6a52329d |
Latest deploy log | https://app.netlify.com/sites/kleros-v2-university/deploys/667a20f56fc82300082768f1 |
Name | Link |
---|---|
Latest commit | 78dbbf69139004d751475f44dd5811ef6a52329d |
Latest deploy log | https://app.netlify.com/sites/kleros-v2-neo/deploys/667a20f585c1660008900f28 |
Deploy Preview | https://deploy-preview-1619--kleros-v2-neo.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
Name | Link |
---|---|
Latest commit | 78dbbf69139004d751475f44dd5811ef6a52329d |
Latest deploy log | https://app.netlify.com/sites/kleros-v2/deploys/667a20f5c147fc0008436eb9 |
Deploy Preview | https://deploy-preview-1619--kleros-v2.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
Code Climate has analyzed commit 78dbbf69 and detected 2 issues on this pull request.
Here's the issue category breakdown:
Category | Count |
---|---|
Complexity | 2 |
View more on Code Climate.
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
ready for review.
LATEST UPDATE: I updated replacePlaceholdersWithValues() to use mustache instead of the direct string manipulation it was doing. I updated the Escrow V2 and Curate V2 mappings to add triple curly braches in some places too, you can find these updated mappings in the links below. contract would need to be updated with the updated templates/mappings too.
This PR makes the curate v2 mappings work. Also allows accessing indexes of an array returned by the subgraph.
How to check that the mappings work:
1) go to https://deploy-preview-1619--kleros-v2.netlify.app/#/dispute-template 2) paste these 3 things: externalDisputeID, template, and data mappings. You will find them below:
Curate V2 template and mappings: https://github.com/kleros/curate-v2/issues/33#issuecomment-2174530564 Escrow V2 template and mappings: https://github.com/kleros/escrow-v2/issues/12#issuecomment-2081673981
The idea is that, with just an
externalDisputeID
, we are able to populate all the needed information from any arbitrable, such as escrow v2, curate v2, or any arbitrable that we integrate with. that would be ideal and would make integrations super easyWe should make this SDK super bullet proof and understandable, make it a good dev experience, not only for the projects we integrate with, but also for us while building this.
(OUTDATED...
)
(OUTDATED.... on the SDK, I reverted some of the changes to jsonAction() and replacePlaceholdersWithValues(). basically Aleix reviewed and I realized that my changes are a hacky way to make the curate v2 "json" mapping work, but it will break normal jsons. context: we upload the item data json and registry metadata json with a different format to the contracts (picture 2) (subgraph link here with the query) and our jsonAction() mapping can't parse that. possible solutions?: upload the item data json and registry metadata jsons, with the supported format directly, or, make the jsonAction() mapping more sophisticated and handle the both cases (normal jsons, and stringified jsons with backlashes "\") correctly)
IGNORE:
some JSON Mappings I need to paste here to not lose this info, this is for testing purposes, ignore:
template:
data mappings:
PR-Codex overview
The focus of this PR is to improve data mapping functionality in the kleros-sdk by enhancing JSON parsing and placeholder replacement.
Detailed summary
jsonAction.ts
mustache
inreplacePlaceholdersWithValues.ts
createResultObject.ts
Summary by CodeRabbit
New Features
mustache
library, providing more robust and flexible string handling.Bug Fixes
These changes improve the overall functionality and reliability of the data mapping processes.