Skip to content
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

Overledger New actions added (read from smart contract and sign a transaction) and modification of existing Actions (Prepare and execute transactions) - tied to issue ticket submitted to Pipedream #14228

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

philbuuza
Copy link

@philbuuza philbuuza commented Oct 8, 2024

The Overledger Pipedream Actions did not have the correct properties in order to work with the the Quant Overledger API request parameters. As well as this other actions added to complete the API sequence. We want the Overledger app in pipedream to be able to perform the the read, monitoring and writing actions. please have a look at the issue submitted:

#14150.

Modifications have been to the prepare and execute actions as these did it seem to be functional.

Phil Buuza

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced new modules for signing transactions and reading from smart contracts.
    • Added a property to specify the environment in transaction preparation and execution.
    • Enhanced functionality for preparing smart contract transactions with improved parameter handling.
  • Improvements

    • Updated descriptions for transaction properties to enhance clarity.
    • Streamlined transaction preparation and signing processes with consolidated request bodies.
    • Added constants for mapping Overledger environments and technology options to token symbols.
    • Improved flexibility by allowing selection between different Overledger environments.
  • Bug Fixes

    • Corrected a typo in the summary method for account events.
  • Version Updates

    • Incremented version numbers for various modules to reflect recent changes.

philbuuza and others added 8 commits October 6, 2024 14:16
…from-smart-contract.mjs


Success message alteration to align with current context

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…from-smart-contract.mjs


inputParameters is an array of Objects so no need to parseObject

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

coderabbitai bot commented Oct 8, 2024

Walkthrough

This pull request introduces several enhancements to the Overledger components, including updates to property descriptions, the addition of new properties, and the introduction of new modules for reading and signing smart contract transactions. Key modifications include the addition of an environment property, the creation of new modules for reading from and signing transactions with smart contracts, and updates to existing methods to support environment configurations. Additionally, new constants for token symbols are introduced, and minor version updates are applied across various components.

Changes

File Change Summary
components/overledger/actions/execute-signed-transaction/execute-signed-transaction.mjs Updated descriptions for requestId and signedTransaction properties; added environment property; version updated to 0.0.2.
components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs Added environment and smartContractId properties; updated signingAccountId description; modified run method to construct requestBody object; version updated to 0.0.2.
components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs Introduced a new module for reading data from a smart contract, defining necessary properties and a run method for execution; version set to 0.0.1.
components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs Introduced a new module for signing transactions, defining properties and a run method for signing logic; version set to 0.0.1.
components/overledger/common/constants.mjs Added new constants OVERLEDGER_INSTANCE and UNIT_OPTIONS mapping technology options to token symbols.
components/overledger/overledger.app.mjs Added environment property, _getBaseUrl method, updated _makeRequest method, introduced readFromSmartContract and signTransaction methods.
components/overledger/package.json Updated version from "0.1.0" to "0.2.0".
components/overledger/sources/new-contract-event-instant/new-contract-event-instant.mjs Updated version from "0.0.1" to "0.0.2".
components/overledger/sources/watch-new-account-event-instant/watch-new-account-event-instant.mjs Updated version from "0.0.1" to "0.0.2" and corrected a typo in the getSummary method return string.
components/overledger/sources/common/base.mjs Added environment property to enhance hook functionality with environment context.

Possibly related issues

Possibly related PRs

  • New Components - v7_go #12949: The main PR and this PR both involve updates to components related to Overledger actions, specifically adding new properties and enhancing existing functionalities in similar files.
  • [Components] xata #13198 #13853: This PR introduces new components that may relate to the Overledger actions, as both involve actions that interact with external services, although the specific functionalities differ.
  • CustomJS: Add Run Puppoteer and HTML to PNG actions #14117: The main PR and this PR both introduce new action components, with the main PR focusing on Overledger and this one on Tricentis qTest, indicating a pattern of adding new functionalities across different services.
  • [Components] Easy Peasy AI: Added new action components #14190: Both the main PR and this PR involve the introduction of new action components, enhancing the capabilities of their respective services (Overledger and Easy Peasy AI).
  • New Components - Docnify #14203: The main PR and this PR both introduce new components for document management, indicating a focus on enhancing document-related functionalities in their respective services (Overledger and Docnify).
  • New Components - burstyai #14224: Both the main PR and this PR involve the introduction of new components that trigger workflows, highlighting a common theme of enhancing workflow capabilities across different platforms (Overledger and BurstyAI).

Suggested labels

action

Suggested reviewers

  • michelle0927
  • lcaresia

Poem

🐇 In the meadow, changes bloom,
New paths for contracts to consume.
With smart IDs and clearer ways,
Overledger shines on brighter days!
A sandbox here, a read to find,
In code we hop, with joy aligned! 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 7e639e0 and 1ae32d0.

📒 Files selected for processing (1)
  • components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@dylburger dylburger added the User submitted Submitted by a user label Oct 8, 2024
Copy link

vercel bot commented Oct 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
pipedream-docs ⬜️ Ignored (Inspect) Oct 20, 2024 10:46pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Oct 20, 2024 10:46pm

@pipedream-component-development
Copy link
Collaborator

Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified.

@pipedream-component-development
Copy link
Collaborator

Thanks for submitting this PR! When we review PRs, we follow the Pipedream component guidelines. If you're not familiar, here's a quick checklist:

Copy link

vercel bot commented Oct 8, 2024

@philbuuza is attempting to deploy a commit to the Pipedreamers Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Outside diff range and nitpick comments (9)
components/overledger/actions/execute-signed-transaction/execute-signed-transaction.mjs (3)

14-15: Approved: Improved clarity in requestId description.

The updated description for the requestId property provides more specific guidance to users, which aligns well with the PR objectives. This change will help ensure that users correctly link this action with the 'Prepare a Smart Contract Transaction' action.

Consider adding a note about the importance of using the correct requestId to maintain the transaction chain integrity.


19-20: Approved: Enhanced clarity in signedTransaction description.

The updated description for the signedTransaction property provides clearer guidance on the expected input, which aligns well with the PR objectives. This change will help users correctly populate this field with the output from the 'Sign a Transaction' action.

Consider adding a brief note about the importance of not modifying the signed transaction to maintain its validity.


Line range hint 24-34: Consider enhancing error handling and logging in the run method.

While the current changes improve the action's usability through better property descriptions, there's an opportunity to further enhance the run method:

  1. Add more detailed error handling to provide specific error messages for different failure scenarios.
  2. Implement more comprehensive logging to aid in debugging and monitoring.
  3. Consider adding input validation for the requestId and signedTransaction properties before making the API call.

These improvements would make the action more robust and easier to troubleshoot.

Would you like assistance in implementing these enhancements?

components/overledger/common/constants.mjs (1)

53-60: LGTM! Consider standardizing comment style.

The addition of the UNIT_OPTIONS constant is well-implemented and consistent with the existing code. It provides a clear mapping between technology options and their respective token symbols, which will be useful for other parts of the application.

Consider standardizing the comment style for consistency:

 export const UNIT_OPTIONS = {
-  "ethereum": "ETH",               // Ethereum's token symbol is ETH
-  "substrate": "DOT",              // Polkadot's token symbol is DOT
-  "xrp ledger": "XRP",             // XRP Ledger's token symbol is XRP
-  "bitcoin": "BTC",                // Bitcoin's token symbol is BTC
-  "hyperledger fabric": "FAB",     // Placeholder for Hyperledger Fabric's token symbol
+  "ethereum": "ETH",               // Token symbol for Ethereum
+  "substrate": "DOT",              // Token symbol for Polkadot
+  "xrp ledger": "XRP",             // Token symbol for XRP Ledger
+  "bitcoin": "BTC",                // Token symbol for Bitcoin
+  "hyperledger fabric": "FAB",     // Placeholder token symbol for Hyperledger Fabric
 };

This change makes the comments more concise and uniform.

components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs (3)

27-31: LGTM: New smartContractId property added

The addition of the smartContractId property is a valuable enhancement, allowing users to specify the smart contract they want to interact with. This aligns well with the PR objectives.

Consider adding a required: true field to this property definition, as it seems to be a crucial parameter for the action. This would ensure that users always provide this necessary information.


58-67: LGTM: Improved request body structure

The introduction of the requestBody object is a good refactoring step. It consolidates all necessary parameters for the transaction preparation, improving code organization and readability. The inclusion of the new smartContractId and the direct processing of inputParameters using parseObject are appropriate changes.

Consider adding a comment above the requestBody declaration to briefly explain its purpose and structure. This would further enhance code maintainability.


Line range hint 1-77: Overall assessment: Well-structured and aligned with PR objectives

The changes made to this file significantly improve the functionality and clarity of the Overledger app's smart contract transaction preparation process. The addition of the smartContractId property, the restructuring of the request body, and the updates to property descriptions all contribute to a more robust and user-friendly implementation.

The modifications align well with the PR objectives of enhancing the Overledger app within Pipedream by improving the prepare action for smart contract transactions.

To further improve the code:

  1. Consider adding input validation for the smartContractId and other critical parameters to ensure data integrity before making the API call.
  2. If not already implemented elsewhere, consider adding error handling for the API call to provide meaningful feedback to the user in case of failures.
components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs (1)

46-53: Ensure locationNetwork is always added to props

In the additionalProps method, if this.locationTechnology is not defined, locationNetwork won't be added to props, which could lead to issues during runtime.

Consider making locationTechnology a required field or providing a default value to ensure locationNetwork is consistently added.

components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs (1)

19-19: Ensure consistent labeling for form fields

The label for the requestId property is "requestId", which is inconsistent with the title case used in other labels such as "Signing Account ID". For consistency and better user experience, consider changing it to "Request ID".

Apply this diff to fix the label:

       label: "requestId",
+      label: "Request ID",
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 491fb31 and 281f0d6.

📒 Files selected for processing (7)
  • components/overledger/actions/execute-signed-transaction/execute-signed-transaction.mjs (1 hunks)
  • components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs (2 hunks)
  • components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs (1 hunks)
  • components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs (1 hunks)
  • components/overledger/common/constants.mjs (1 hunks)
  • components/overledger/overledger.app.mjs (4 hunks)
  • components/overledger/sources/watch-new-account-event-instant/watch-new-account-event-instant.mjs (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • components/overledger/sources/watch-new-account-event-instant/watch-new-account-event-instant.mjs
🧰 Additional context used
📓 Learnings (1)
components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs (2)
Learnt from: lukerQuant
PR: PipedreamHQ/pipedream#14217
File: components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs:27-32
Timestamp: 2024-10-07T08:20:28.836Z
Learning: In Overledger actions, define `inputParameters` and `outputParameters` as object arrays, and ensure they are treated consistently throughout the code. Refer to existing actions for examples.
Learnt from: lukerQuant
PR: PipedreamHQ/pipedream#14217
File: components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs:57-59
Timestamp: 2024-10-07T08:21:22.593Z
Learning: In Overledger actions, throw an error in the `run` method if `locationNetwork` is not selected, as not all Overledger customers have access to the same network.
🔇 Additional comments (7)
components/overledger/actions/execute-signed-transaction/execute-signed-transaction.mjs (1)

Line range hint 1-34: Overall assessment: Positive improvements with room for further enhancements.

The changes made to this file successfully improve the clarity and usability of the "Execute Signed Transaction" action. The updated property descriptions provide more specific guidance to users, which aligns well with the PR objectives of enhancing the Overledger app's functionality.

While these changes are valuable, there are opportunities for further improvements:

  1. Enhancing error handling and logging in the run method.
  2. Adding input validation for the properties.
  3. Providing additional context in the property descriptions about the importance of using correct values.

These suggested enhancements would further improve the robustness and user-friendliness of the action.

components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs (2)

25-26: LGTM: Improved property description

The updated description for signingAccountId is more concise and accurately describes its purpose. This change enhances the clarity of the code.


70-71: LGTM: Updated method call

The update to the prepareSmartContractTransaction method call correctly utilizes the newly created requestBody object. This change is consistent with the previous modifications and enhances the overall code clarity and structure.

components/overledger/overledger.app.mjs (4)

17-20: LGTM: Addition of the _sandboxBaseUrl method

The _sandboxBaseUrl method is correctly implemented to provide the sandbox base URL.


40-43: Verify the use of sandbox base URL in prepareSmartContractTransaction

The prepareSmartContractTransaction method now uses this._sandboxBaseUrl(). Please confirm that this method should always interact with the sandbox environment. If production usage is also intended, consider making the base URL configurable.


53-60: LGTM: Addition of the signTransaction method

The signTransaction method is correctly implemented using the sandbox base URL.


64-67: Verify the use of sandbox base URL in executeSignedTransaction

The executeSignedTransaction method now uses this._sandboxBaseUrl(). Please confirm that this change is intentional and that this method should interact with the sandbox environment.

luancazarine
luancazarine previously approved these changes Oct 8, 2024
Copy link
Collaborator

@luancazarine luancazarine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @philbuuza, Thanks for your contribution! LGTM! Ready for QA!

@philbuuza
Copy link
Author

@luancazarine just did one little additional update to the overledger.app which will allow for instance selection between Sandox version and Live Overledger as they use different BaseUrls. once user selects an option in the props dropdown menu in environment prop this will set the correct baseURLs in the methods.

@philbuuza
Copy link
Author

Please if you can approve after reviewing this so I can test it in the UI. Many thanks

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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)
components/overledger/overledger.app.mjs (1)

6-6: Correct the typos in the comment.

In the comment on line 6, there are typos:

  • "Sanbox" should be "Sandbox".
  • "ro determine" should be "to determine".
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 281f0d6 and 9dff018.

📒 Files selected for processing (1)
  • components/overledger/overledger.app.mjs (4 hunks)
🧰 Additional context used

components/overledger/overledger.app.mjs Outdated Show resolved Hide resolved
@luancazarine
Copy link
Collaborator

Hi @philbuuza, I'm trying to push a commit with some adjusts, but it looks like you changed some permissions. Could you please check?

@philbuuza
Copy link
Author

Hi @luancazarine. I think it is to do with the versioning. I did not increment the versioning on the components i altered so my mistake as well as folder naming structure I will fix these now. Thanks.

@philbuuza
Copy link
Author

@luancazarine - I have made the recommended changes as per your comments. Please review and merge if all ok. I did leave some reply comments on some of them but I seem to have clarified things now on further analysis

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 (5)
components/overledger/common/constants.mjs (1)

64-71: LGTM: New constant UNIT_OPTIONS added with a minor suggestion.

The new constant UNIT_OPTIONS provides a clear mapping between technologies and their corresponding token symbols, which is valuable for the Overledger app functionality.

Consider updating the comment for hyperledger fabric to clarify if "FAB" is the actual token symbol or if it needs to be replaced with the correct symbol in the future. For example:

-  "hyperledger fabric": "FAB",     // Placeholder for Hyperledger Fabric's token symbol
+  "hyperledger fabric": "FAB",     // TODO: Verify if "FAB" is the correct token symbol for Hyperledger Fabric
components/overledger/overledger.app.mjs (3)

13-18: LGTM: New environment property added.

The environment property is well-defined with appropriate attributes. Using the OVERLEDGER_INSTANCE constant for options is a good practice for maintainability.

Consider adding a default value to the environment property if there's a preferred or most common option:

environment: {
  type: "string",
  label: "Overledger Instance",
  description: "Select the Overledger instance to be used",
  options: OVERLEDGER_INSTANCE,
  default: "production", // or "sandbox", depending on your use case
},

28-32: LGTM: New _getBaseUrl method added.

The _getBaseUrl method correctly determines the base URL based on the environment.

Consider adding a default case to handle unexpected environment values:

_getBaseUrl(environment) {
  switch (environment) {
    case "sandbox":
      return "https://api.sandbox.overledger.io";
    case "production":
      return "https://api.overledger.io";
    default:
      console.warn(`Unexpected environment: ${environment}. Using production URL.`);
      return "https://api.overledger.io";
  }
},

This approach provides more explicit handling of different cases and includes a warning for unexpected values.


49-55: LGTM: New readFromSmartContract method added.

The readFromSmartContract method is correctly implemented using the _makeRequest method.

For consistency with other methods, consider explicitly passing the environment parameter:

readFromSmartContract({ environment, ...opts } = {}) {
  return this._makeRequest({
    method: "POST",
    path: "/api/smart-contracts/read",
    environment,
    ...opts,
  });
},

This ensures that the environment is always passed to _makeRequest, even if not provided in the opts.

components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs (1)

64-78: LGTM: Improved structure in run method.

The changes in the run method improve code readability and maintainability:

  1. The introduction of the requestBody object centralizes the request data.
  2. The use of parseObject for inputParameters ensures proper handling of JSON input.
  3. The addition of the environment parameter aligns with the new environment property.

These changes align well with the PR objectives and enhance the overall structure of the action.

Consider adding a comment explaining the purpose of the parseObject function for clarity:

inputParameters: parseObject(this.inputParameters), // Parse JSON string into object for use in request body
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between a2ec749 and f7a15ba.

📒 Files selected for processing (6)
  • components/overledger/actions/execute-signed-transaction/execute-signed-transaction.mjs (1 hunks)
  • components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs (3 hunks)
  • components/overledger/actions/read-from-a-smart-contract/read-from-a-smart-contract.mjs (1 hunks)
  • components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs (1 hunks)
  • components/overledger/common/constants.mjs (1 hunks)
  • components/overledger/overledger.app.mjs (3 hunks)
🧰 Additional context used
📓 Learnings (1)
components/overledger/actions/read-from-a-smart-contract/read-from-a-smart-contract.mjs (8)
Learnt from: lukerQuant
PR: PipedreamHQ/pipedream#14217
File: components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs:27-32
Timestamp: 2024-10-07T08:20:28.836Z
Learning: In Overledger actions, define `inputParameters` and `outputParameters` as object arrays, and ensure they are treated consistently throughout the code. Refer to existing actions for examples.
Learnt from: lukerQuant
PR: PipedreamHQ/pipedream#14217
File: components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs:27-32
Timestamp: 2024-10-08T15:33:38.240Z
Learning: In Overledger actions, define `inputParameters` and `outputParameters` as object arrays, and ensure they are treated consistently throughout the code. Refer to existing actions for examples.
Learnt from: lukerQuant
PR: PipedreamHQ/pipedream#14217
File: components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs:57-59
Timestamp: 2024-10-08T15:33:38.240Z
Learning: In Overledger actions, throw an error in the `run` method if `locationNetwork` is not selected, as not all Overledger customers have access to the same network.
Learnt from: lukerQuant
PR: PipedreamHQ/pipedream#14217
File: components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs:57-59
Timestamp: 2024-10-08T15:33:40.184Z
Learning: In Overledger actions, throw an error in the `run` method if `locationNetwork` is not selected, as not all Overledger customers have access to the same network.
Learnt from: lukerQuant
PR: PipedreamHQ/pipedream#14217
File: components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs:57-59
Timestamp: 2024-10-07T08:21:22.593Z
Learning: In Overledger actions, throw an error in the `run` method if `locationNetwork` is not selected, as not all Overledger customers have access to the same network.
Learnt from: philbuuza
PR: PipedreamHQ/pipedream#14228
File: components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs:27-32
Timestamp: 2024-10-08T16:26:11.372Z
Learning: In Overledger actions, `inputParameters` and `outputParameters` are defined as `string[]`, and are parsed within the code to create the required objects for the request.
Learnt from: lukerQuant
PR: PipedreamHQ/pipedream#14217
File: components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs:62-62
Timestamp: 2024-10-07T08:28:35.205Z
Learning: In Overledger actions, the `inputParameters` property is an array of objects and should be passed directly without parsing.
Learnt from: lukerQuant
PR: PipedreamHQ/pipedream#14217
File: components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs:62-62
Timestamp: 2024-10-08T15:33:38.240Z
Learning: In Overledger actions, the `inputParameters` property is an array of objects and should be passed directly without parsing.
🔇 Additional comments (25)
components/overledger/actions/execute-signed-transaction/execute-signed-transaction.mjs (4)

7-7: LGTM: Version update is appropriate.

The version increment from "0.0.1" to "0.0.2" accurately reflects the changes made to the component.


11-16: LGTM: Environment prop added as requested.

The addition of the environment prop correctly addresses the past review comment. It's properly implemented using the propDefinition from the overledger app.


20-20: LGTM: Improved property descriptions.

The updated descriptions for requestId and signedTransaction provide clearer guidance on the expected values, referencing other relevant Overledger actions. This enhancement improves user understanding and usability.

Also applies to: 25-25


30-39: LGTM: Improved run method implementation.

The changes in the run method enhance code readability and correctly incorporate the new environment prop:

  1. Creation of requestBody object improves code structure.
  2. Addition of environment to executeSignedTransaction call aligns with the new prop.
  3. Use of requestBody in the data parameter is appropriate.

These modifications are consistent with the overall component changes.

components/overledger/common/constants.mjs (2)

53-63: LGTM: New constant OVERLEDGER_INSTANCE added.

The new constant OVERLEDGER_INSTANCE is well-structured and provides a clear distinction between the Sandbox (test) and Overledger (live) environments. This addition aligns with the PR objectives of enhancing the Overledger app functionality.


Line range hint 1-71: Overall, the changes to this file are well-implemented and align with the PR objectives.

The addition of OVERLEDGER_INSTANCE and UNIT_OPTIONS constants enhances the Overledger app's functionality by providing clear environment options and token symbol mappings. These changes are consistent with the existing code structure and will likely improve the user experience when interacting with different blockchain technologies through the Overledger app.

components/overledger/overledger.app.mjs (4)

2-2: LGTM: New import statement added.

The import of OVERLEDGER_INSTANCE from the constants file is correctly implemented and aligns with the new environment property addition.


34-34: LGTM: _makeRequest method updated to use environment-based URL.

The _makeRequest method has been correctly updated to accept the environment parameter and use it with the new _getBaseUrl method. This change ensures that the correct base URL is used for each request based on the selected environment.

Also applies to: 38-38


Line range hint 1-91: Overall assessment: Good improvements with minor suggestions

The changes to the Overledger app are well-implemented and enhance its flexibility by introducing environment-based URL selection. The new methods for reading from smart contracts and signing transactions are valuable additions.

Key points:

  1. The new environment property and _getBaseUrl method effectively support multiple Overledger instances.
  2. The _makeRequest method has been correctly updated to use the environment-based URL.
  3. New methods (readFromSmartContract and signTransaction) have been added, expanding the app's capabilities.

Please consider the minor suggestions for improvements, particularly:

  • Adding a default value to the environment property.
  • Enhancing the robustness of the _getBaseUrl method.
  • Ensuring consistency in passing the environment parameter in new methods.

Lastly, please verify the correctness of the "/api/transaction-signing-sandbox" path for both environments in the signTransaction method.

These changes significantly improve the Overledger app's functionality and flexibility. Great work!


56-62: LGTM with a question: New signTransaction method added.

The signTransaction method is correctly implemented using the _makeRequest method.

The path "/api/transaction-signing-sandbox" suggests this might be specific to the sandbox environment. Can you confirm if this path is correct for both sandbox and production environments? If it's sandbox-specific, we might need to adjust the implementation to use different paths based on the environment.

To verify this, you can run the following script:

This script will help determine if the endpoint exists in both environments or if we need to use different paths based on the selected environment.

components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs (4)

11-11: Version update looks good.

The version increment from "0.0.1" to "0.0.2" appropriately reflects the changes made to this component.


15-20: LGTM: Environment property added.

The addition of the environment property allows users to select between different Overledger environments, which aligns with the PR objectives. The property is correctly defined using the propDefinition from the overledger app.


31-31: Description update for signingAccountId is appropriate.

The updated description for the signingAccountId property is clearer and accurately describes its purpose.


33-37: LGTM: Smart Contract ID property added.

The addition of the smartContractId property is appropriate and necessary for interacting with specific smart contracts. The property is correctly defined with suitable type, label, and description.

components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs (7)

1-2: LGTM: Imports are appropriate and correctly defined.

The import statements for overledger and UNIT_OPTIONS are correctly defined and seem appropriate for the module's functionality.


4-9: LGTM: Module metadata is well-defined and appropriate.

The module's metadata (key, name, description, version, and type) is correctly defined and aligns with the purpose of signing a transaction using Overledger.


10-41: LGTM: Props are well-defined and the past review comment has been addressed.

The props definition is comprehensive and appropriate for the module's functionality. The environment prop has been correctly added as suggested in the past review comment. The use of default values referencing previous steps (e.g., for nativeData) is a good practice for maintaining context between actions.


71-75: LGTM: Environment parameter correctly added to signTransaction call

The environment parameter has been correctly added to the signTransaction method call, addressing the past review comment. This ensures that the correct base URL is used based on the user's environment selection.


76-78: LGTM: Appropriate summary export and return statement

The method correctly exports a summary message indicating successful transaction signing and returns the response from the Overledger API. This provides good feedback to the user and allows for further processing of the API response if needed.


42-49: ⚠️ Potential issue

Move locationTechnology inside props to ensure proper access

The locationTechnology property is still defined outside of the props object. This may cause issues when trying to access it via this.locationTechnology in the run method. To ensure it's properly accessible, locationTechnology should be moved inside the props object.

Apply this diff to fix the issue:

 export default {
   key: "overledger-sign-a-transaction",
   name: "Sign a transaction",
   description: "Sign a transaction using Overledger",
   version: "0.0.1",
   type: "action",
   props: {
     overledger,
     environment: {
       propDefinition: [
         overledger,
         "environment",
       ],
     },
     // ... other props ...
+    locationTechnology: {
+      type: "string",
+      label: "Location Technology",
+      description: "The blockchain technology used for this transaction, e.g., ethereum, substrate.",
+      optional: true,
+      // Reference the output of the previous step
+      default: ({ steps }) => steps.prepare_smart_contract_transaction?.locationTechnology,
+    },
   },
-  locationTechnology: {
-    type: "string",
-    label: "Location Technology",
-    description: "The blockchain technology used for this transaction, e.g., ethereum, substrate.",
-    optional: true,
-    // Reference the output of the previous step
-    default: ({ steps }) => steps.prepare_smart_contract_transaction?.locationTechnology,
-  },
   async run({ $ }) {
     // ... rest of the code ...
   },
 };

52-60: 🛠️ Refactor suggestion

Consider making fee amounts configurable

The gatewayFee and dltFee amounts are still hardcoded within the action. This may limit flexibility, especially if fee structures change or differ across networks and environments. Consider adding these as props to allow users to specify custom fee amounts when signing a transaction.

Example implementation:

props: {
  // ... existing props ...
  gatewayFeeAmount: {
    type: "string",
    label: "Gateway Fee Amount",
    description: "The amount of the gateway fee",
    default: "0",
  },
  dltFeeAmount: {
    type: "string",
    label: "DLT Fee Amount",
    description: "The amount of the DLT fee",
    default: "0.000019897764079968",
  },
},
async run({ $ }) {
  const gatewayFee = {
    amount: this.gatewayFeeAmount,
    unit: "QNT",
  };
  const dltFee = {
    amount: this.dltFeeAmount,
    unit: UNIT_OPTIONS[this.locationTechnology] || "ETH",
  };
  // ... rest of the method ...
}
components/overledger/actions/read-from-a-smart-contract/read-from-a-smart-contract.mjs (4)

1-12: LGTM: Imports and module definition are well-structured.

The imports and module definition are correctly implemented. The use of constants and utility functions from common files promotes code reusability. The module definition follows the expected structure for a Pipedream action.


13-49: LGTM: Props are well-defined and include the environment prop.

The props definition is comprehensive and includes all necessary inputs for reading from a smart contract. The environment prop has been correctly added as per the previous review comment. The use of string[] for inputParameters and outputParameters aligns with the learned approach.


50-61: LGTM: additionalProps method is correctly implemented.

The additionalProps method dynamically adds the locationNetwork prop based on the selected locationTechnology. This approach ensures that users can only select networks relevant to the chosen technology.


1-83: Overall, the implementation is solid with minor improvements needed.

This new action for reading from a smart contract on the Overledger network is well-structured and follows Pipedream component guidelines. The props are well-defined, including the dynamic addition of locationNetwork. The run method is functional but could benefit from the suggested error handling and checks.

Once the improvements to the run method are implemented, this action will be a robust and valuable addition to the Overledger app in Pipedream.

@luancazarine
Copy link
Collaborator

Hi @philbuuza. Thanks for making the changes I recommend. We're almost there.
I just need you to add the environment prop to the common source file and pass it to the create and delete hook methods.

@philbuuza
Copy link
Author

I have added the environemnt to the common source file and pass it in the create and delete hook methods. Please review and see if this is ok. Many thanks for all your feedback

luancazarine
luancazarine previously approved these changes Oct 11, 2024
Copy link
Collaborator

@luancazarine luancazarine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @philbuuza, thanks for your contribution! LGTM! Ready for QA!

@philbuuza
Copy link
Author

Hi @luancazarine. Thanks for your help too. Is the final QA done by someone else in your team then. Is that the Vercel deploy thats waiting

@vunguyenhung
Copy link
Collaborator

Hello everyone, I have tested this PR and there're some test cases failed or needed improvement.

Please check the test report below for more information
https://vunguyenhung.notion.site/Overledger-New-actions-added-read-from-smart-contract-and-sign-a-transaction-and-modification-of-e-119bf548bb5e81148445e5643e6f00f2

@philbuuza
Copy link
Author

@luancazarine - I cant seem to find where the Type Error (this._sanboxBaseUrl is not a function) is coming from in the QA from @vunguyenhung. Its not a function we have in the code anywhere?. Am i missing something here?

@philbuuza
Copy link
Author

Also can I confirm that apart from the issues wth read-from-smart-contract and sign-a-transantion all the other actions and sources have passed and ar ok?

@vunguyenhung
Copy link
Collaborator

Hi @philbuuza, here's the stacktrace

image

I used the sample values in Overledger API Doc: https://developers.quant.network/reference/readsmartcontract

@philbuuza
Copy link
Author

have you got an Quant Connect account and created an app with client id and client key which are needed for Overledger to work

@philbuuza
Copy link
Author

@vunguyenhung Also looking at that function you are calling on that smart contract you need to provide input parameters for in. in this case it will be an address.:

//notice This is the test for making a call to a read function with a long function name
function readVeryLongFunctionNameReadVeryLongFunctionNameReadVeryLongFunctionName(address account) public view returns (address) {
return account;
}

@philbuuza
Copy link
Author

philbuuza commented Oct 14, 2024

@luancazarine @vunguyenhung you can try a simplere one to begin with - whixh does not require inputs like - readZeroInputsOneOutput. On the same smart contract address....

Also can I check if there is anyway for me to checkout to this PR branch and run the tests myself with the UI platform

@philbuuza
Copy link
Author

philbuuza commented Oct 14, 2024

Hi @vunguyenhung or @luancazarine could we check that the branch being tested is the most up to date. As the function ((this.sandboxBaseURL) is not even in the code base anymore. Something does not seem to be up to date. thanks

@vunguyenhung
Copy link
Collaborator

vunguyenhung commented Oct 14, 2024

Hi @philbuuza, thank you for your effort.

For the read function, I'll check again and test with the latest code.

For the sign transaction, I can not pushlish the action, could you check the test report and fix it?

@philbuuza
Copy link
Author

Hi @vunguyenhung ok sure. Also you can try a simpler function where you do not need to put any inputs and get a valued returned. like these:

1 - readZeroInputsOneOutput
2 - readZeroInputsTwoOutputs

Heres i the smart contract these are from. Where you can view the functions available:
https://sepolia.etherscan.io/address/0x3a637d769ed8530b483eeae70923d73dbad916c6#readContract

Please remember to have the sanbox instance of overledger set as well as selecting the Ethereum Sepolia Testnet.

@philbuuza
Copy link
Author

have ammended the Sign-a-Transaction failed issue with the nativeData:

"Sign A Transaction - Fail
I got an error when publishing the action
bad default value for prop nativeData: undefined (should be object)"

Have added a default empty object to fix this undefined issue.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (3)
components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs (3)

18-24: Enhance the description and error handling for locationTechnology

The description for the locationTechnology prop could be more specific about its purpose and accepted values. Additionally, consider adding error handling for cases where the previous step doesn't provide a value.

Consider updating the prop as follows:

locationTechnology: {
  type: "string",
  label: "Location Technology",
  description: "The blockchain technology used for this transaction (e.g., 'ethereum', 'substrate'). This is required to set the correct dltfee unit.",
  default: ({ steps }) => {
    const prevValue = steps.prepare_smart_contract_transaction?.locationTechnology;
    if (!prevValue) {
      console.warn("No locationTechnology provided from previous step. Defaulting to 'ethereum'.");
    }
    return prevValue || "ethereum";
  },
},

40-46: Improve error handling for nativeData default value

The nativeData prop's default value relies on the output of a previous step. It's good practice to add some error handling to ensure the prop receives valid data.

Consider updating the prop as follows:

nativeData: {
  type: "object",
  label: "Native Data",
  description: "A JSON object representing the transaction required to be signed.",
  default: ({ steps }) => {
    const prevData = steps.prepare_smart_contract_transaction?.nativeData;
    if (!prevData || Object.keys(prevData).length === 0) {
      throw new Error("No valid nativeData provided from the previous step.");
    }
    return prevData;
  },
},

This change will throw an error if the previous step doesn't provide valid nativeData, preventing potential issues later in the execution.


74-75: Enhance the summary message

The current summary message is static and doesn't provide any specific information about the signed transaction.

Consider including more details in the summary message:

$.export("$summary", `Transaction signed successfully. Request ID: ${this.requestId}`);

This change provides more context about the specific transaction that was signed.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 271233d and 7e639e0.

📒 Files selected for processing (1)
  • components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs (1 hunks)
🧰 Additional context used
🔇 Additional comments (2)
components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs (2)

1-2: LGTM: Imports are appropriate

The imports for the Overledger app and UNIT_OPTIONS constant are correctly included and necessary for the module's functionality.


4-9: LGTM: Metadata is well-defined

The metadata for the action, including key, name, description, version, and type, is appropriately defined and aligns with the purpose of signing a transaction using Overledger.

Comment on lines +50 to +58
const gatewayFee = {
amount: "0",
unit: "QNT",
};
// Define DLT Fee and dynamically set the 'unit/symbol' from UNIT_OPTIONS
const dltFee = {
amount: "0.000019897764079968",
unit: UNIT_OPTIONS[this.locationTechnology] || "ETH", // Use default if not found
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider making fee amounts configurable

The gatewayFee and dltFee amounts are currently hardcoded. This may limit flexibility, especially if fee structures change or differ across networks and environments.

Consider adding these as configurable props:

props: {
  // ... existing props
  gatewayFeeAmount: {
    type: "string",
    label: "Gateway Fee Amount",
    description: "The amount of the gateway fee",
    default: "0",
  },
  dltFeeAmount: {
    type: "string",
    label: "DLT Fee Amount",
    description: "The amount of the DLT fee",
    default: "0.000019897764079968",
  },
},

Then update the run method to use these props:

const gatewayFee = {
  amount: this.gatewayFeeAmount,
  unit: "QNT",
};
const dltFee = {
  amount: this.dltFeeAmount,
  unit: UNIT_OPTIONS[this.locationTechnology] || "ETH",
};

This change allows users to specify custom fee amounts when needed.

Comment on lines +69 to +73
const response = await this.overledger.signTransaction({
$,
environment: this.environment,
data: requestBody,
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add error handling for signTransaction call

The current implementation doesn't handle potential errors from the signTransaction method. It's important to catch and handle these errors gracefully.

Wrap the API call in a try-catch block:

try {
  const response = await this.overledger.signTransaction({
    $,
    environment: this.environment,
    data: requestBody,
  });
  $.export("$summary", "Transaction signed successfully");
  return response;
} catch (error) {
  console.error("Error signing transaction:", error);
  throw error;
}

This change will log any errors and re-throw them, allowing for better error handling and debugging.

@philbuuza
Copy link
Author

@luancazarine and @vunguyenhung I am still waiting on this PR. Can I get an update as to the progress of this. I dont have an upgraded account which would have allowed me to test this out myself so I kindly ask this is done so I can complete this task. Many thanks.

@vunguyenhung
Copy link
Collaborator

Hi @philbuuza, sorry for the late response. I've move forward this ticket to PR review.

We recommend to test your action to save back-and-forth time if possible.

Thank you for your contribution!

@philbuuza
Copy link
Author

Hi @vunguyenhung @luancazarine How do I test my action without being able to use the UI with it. Please if you could help me with this or direct me on how. would be much appreciated

@vunguyenhung
Copy link
Collaborator

Hi @philbuuza, you can publish your developed action into your own Pipedream account to test using Pipedream CLI.

pd publish <path-to-your-action-file>

Here's the quick start: https://pipedream.com/docs/components/actions-quickstart

Copy link
Collaborator

@luancazarine luancazarine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @philbuuza, I just added two more suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
User submitted Submitted by a user
Projects
Development

Successfully merging this pull request may close these issues.

5 participants