-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
base: master
Are you sure you want to change the base?
Conversation
…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>
WalkthroughThis 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 Changes
Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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? 🪧 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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ |
Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified. |
@philbuuza is attempting to deploy a commit to the Pipedreamers Team on Vercel. A member of the Team first needs to authorize it. |
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: 6
🧹 Outside diff range and nitpick comments (9)
components/overledger/actions/execute-signed-transaction/execute-signed-transaction.mjs (3)
14-15
: Approved: Improved clarity inrequestId
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 insignedTransaction
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 therun
method.While the current changes improve the action's usability through better property descriptions, there's an opportunity to further enhance the
run
method:
- Add more detailed error handling to provide specific error messages for different failure scenarios.
- Implement more comprehensive logging to aid in debugging and monitoring.
- Consider adding input validation for the
requestId
andsignedTransaction
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: NewsmartContractId
property addedThe 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 structureThe 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 newsmartContractId
and the direct processing ofinputParameters
usingparseObject
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 objectivesThe 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:
- Consider adding input validation for the
smartContractId
and other critical parameters to ensure data integrity before making the API call.- 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
: EnsurelocationNetwork
is always added toprops
In the
additionalProps
method, ifthis.locationTechnology
is not defined,locationNetwork
won't be added toprops
, which could lead to issues during runtime.Consider making
locationTechnology
a required field or providing a default value to ensurelocationNetwork
is consistently added.components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs (1)
19-19
: Ensure consistent labeling for form fieldsThe
label
for therequestId
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
📒 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:
- Enhancing error handling and logging in the
run
method.- Adding input validation for the properties.
- 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 descriptionThe 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 callThe update to the
prepareSmartContractTransaction
method call correctly utilizes the newly createdrequestBody
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
methodThe
_sandboxBaseUrl
method is correctly implemented to provide the sandbox base URL.
40-43
: Verify the use of sandbox base URL inprepareSmartContractTransaction
The
prepareSmartContractTransaction
method now usesthis._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 thesignTransaction
methodThe
signTransaction
method is correctly implemented using the sandbox base URL.
64-67
: Verify the use of sandbox base URL inexecuteSignedTransaction
The
executeSignedTransaction
method now usesthis._sandboxBaseUrl()
. Please confirm that this change is intentional and that this method should interact with the sandbox environment.
components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs
Outdated
Show resolved
Hide resolved
components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs
Outdated
Show resolved
Hide resolved
components/overledger/actions/read-from-a-smart-contract/read-from-smart-contract.mjs
Outdated
Show resolved
Hide resolved
components/overledger/actions/sign-a-transaction/sign-a-transaction.mjs
Outdated
Show resolved
Hide resolved
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.
Hi @philbuuza, Thanks for your contribution! LGTM! Ready for QA!
@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. |
Please if you can approve after reviewing this so I can test it in the UI. Many thanks |
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)
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".
… Live Overledger - altered basURL in hook methods create and delete
Hi @philbuuza, I'm trying to push a commit with some adjusts, but it looks like you changed some permissions. Could you please check? |
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. |
…ll as component key adjustments to alin with pipedream requirements
@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 |
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 (5)
components/overledger/common/constants.mjs (1)
64-71
: LGTM: New constantUNIT_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 Fabriccomponents/overledger/overledger.app.mjs (3)
13-18
: LGTM: Newenvironment
property added.The
environment
property is well-defined with appropriate attributes. Using theOVERLEDGER_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: NewreadFromSmartContract
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 theopts
.components/overledger/actions/prepare-smart-contract-transaction/prepare-smart-contract-transaction.mjs (1)
64-78
: LGTM: Improved structure inrun
method.The changes in the
run
method improve code readability and maintainability:
- The introduction of the
requestBody
object centralizes the request data.- The use of
parseObject
forinputParameters
ensures proper handling of JSON input.- The addition of the
environment
parameter aligns with the newenvironment
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
📒 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 thepropDefinition
from the overledger app.
20-20
: LGTM: Improved property descriptions.The updated descriptions for
requestId
andsignedTransaction
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 newenvironment
prop:
- Creation of
requestBody
object improves code structure.- Addition of
environment
toexecuteSignedTransaction
call aligns with the new prop.- Use of
requestBody
in thedata
parameter is appropriate.These modifications are consistent with the overall component changes.
components/overledger/common/constants.mjs (2)
53-63
: LGTM: New constantOVERLEDGER_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
andUNIT_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 newenvironment
property addition.
34-34
: LGTM:_makeRequest
method updated to use environment-based URL.The
_makeRequest
method has been correctly updated to accept theenvironment
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 suggestionsThe 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:
- The new
environment
property and_getBaseUrl
method effectively support multiple Overledger instances.- The
_makeRequest
method has been correctly updated to use the environment-based URL.- New methods (
readFromSmartContract
andsignTransaction
) 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: NewsignTransaction
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 thepropDefinition
from theoverledger
app.
31-31
: Description update forsigningAccountId
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
andUNIT_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., fornativeData
) is a good practice for maintaining context between actions.
71-75
: LGTM: Environment parameter correctly added to signTransaction callThe
environment
parameter has been correctly added to thesignTransaction
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 statementThe 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 issueMove
locationTechnology
insideprops
to ensure proper accessThe
locationTechnology
property is still defined outside of theprops
object. This may cause issues when trying to access it viathis.locationTechnology
in therun
method. To ensure it's properly accessible,locationTechnology
should be moved inside theprops
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 suggestionConsider making fee amounts configurable
The
gatewayFee
anddltFee
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 ofstring[]
forinputParameters
andoutputParameters
aligns with the learned approach.
50-61
: LGTM: additionalProps method is correctly implemented.The
additionalProps
method dynamically adds thelocationNetwork
prop based on the selectedlocationTechnology
. 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
. Therun
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.
components/overledger/actions/read-from-a-smart-contract/read-from-a-smart-contract.mjs
Show resolved
Hide resolved
Hi @philbuuza. Thanks for making the changes I recommend. We're almost there. |
…delete and creathooks to take in this param
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 |
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.
Hi @philbuuza, thanks for your contribution! LGTM! Ready for QA!
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 |
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 |
@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? |
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? |
Hi @philbuuza, here's the stacktrace I used the sample values in Overledger API Doc: https://developers.quant.network/reference/readsmartcontract |
have you got an Quant Connect account and created an app with client id and client key which are needed for Overledger to work |
@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 |
@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 |
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 |
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? |
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 Heres i the smart contract these are from. Where you can view the functions available: Please remember to have the sanbox instance of overledger set as well as selecting the Ethereum Sepolia Testnet. |
have ammended the Sign-a-Transaction failed issue with the nativeData: "Sign A Transaction - Fail Have added a default empty object to fix this undefined issue. |
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: 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 locationTechnologyThe 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 valueThe
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 messageThe 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
📒 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 appropriateThe 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-definedThe 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.
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 | ||
}; |
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.
🛠️ 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.
const response = await this.overledger.signTransaction({ | ||
$, | ||
environment: this.environment, | ||
data: requestBody, | ||
}); |
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.
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.
@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. |
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! |
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 |
Hi @philbuuza, you can publish your developed action into your own Pipedream account to test using Pipedream CLI.
Here's the quick start: https://pipedream.com/docs/components/actions-quickstart |
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.
Hi @philbuuza, I just added two more suggestions.
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
Improvements
Bug Fixes
Version Updates