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

Open Roles & Clean buildCreateContractTx Request #54

Merged
merged 13 commits into from
Dec 8, 2023
Merged

Open Roles & Clean buildCreateContractTx Request #54

merged 13 commits into from
Dec 8, 2023

Conversation

bjornkihlberg
Copy link
Contributor

@bjornkihlberg bjornkihlberg commented Oct 25, 2023

This PR fulfills 2 issues :

Summary by CodeRabbit

  • New Features

    • Search functionality now available with a new search bar.
    • Enhanced contract creation flexibility with broader input scope.
    • New dynamic type guards for JSON schemas in the Runtime Rest API.
    • Additional role configuration options for system contracts.
    • Improved transaction creation process for contract interactions.
  • Enhancements

    • Updated documentation comments for better clarity on endpoints.
    • Streamlined import map structure for improved maintainability.
  • Bug Fixes

    • Fixed wallet name matching logic to be case-insensitive.
  • Refactor

    • Renamed and restructured several internal entities to align with updated functionality.
  • Style

    • Adjusted quotes in script element creation for consistency.
  • Documentation

    • Updated category tags in documentation comments for clearer navigation.
  • Tests

    • Expanded test coverage to include new features and changes.
  • Chores

    • General codebase maintenance and cleanup.

@nhenin nhenin mentioned this pull request Nov 8, 2023
11 tasks
@nhenin nhenin self-assigned this Nov 13, 2023
@nhenin nhenin changed the title PLT-8261: Support for open roles and thread tokens Support for open roles and thread tokens Nov 14, 2023
@nhenin nhenin changed the title Support for open roles and thread tokens Support for open roles Nov 22, 2023
@nhenin nhenin changed the title Support for open roles Support for open roles (Implementation in Progress) Nov 25, 2023
Copy link
Contributor

coderabbitai bot commented Nov 25, 2023

Warning

Rate Limit Exceeded

@nhenin has exceeded the limit for the number of files or commits that can be reviewed per hour. Please wait 3 minutes and 58 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between 03f231f and 09fc3cd.

Walkthrough

The updates reflect a significant refactoring in contract creation and management, with a shift from direct contract creation to building transactions for contract operations. This includes renaming functions and parameters to align with the new transaction-based approach, enhancing role configurations, and updating type guards. Additionally, there's a move towards deprecating older REST client functions in favor of new implementations, and various changes to improve consistency and future-proofing of the codebase.

Changes

File(s) Summary
examples/.../index.html, examples/.../index.js Updated createContract to createContractOrSourceId across example files.
jsdelivr-npm-importmap.js Reformatted importMap object and updated script element quotes.
packages/.../codec.ts, packages/.../address.ts, packages/.../guards.ts, packages/.../index.ts, packages/.../participants.ts, packages/.../policyId.ts, packages/.../token.ts Added new classes, types, functions, and updated existing ones for error handling, type guarding, and contract management.
packages/.../rest/... Introduced modifications for contract creation and management, role configurations, and wallet interactions.
packages/.../core/... Added new exports and removed an import, indicating new features and cleanup.
packages/.../lifecycle/... Refactored to accommodate new restClient parameter and updated function calls and imports.
packages/wallet/... Modified wallet name comparison logic for case-insensitivity.
changelog.d/... Documented changes to createContract endpoint and functionality.

"In the code's woven warren, changes hop and leap,
Refactoring flows like streams, through valleys deep.
Transactions build, contracts take new form,
As the rabbit codes, a new software norm." 🐇💻✨


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

@nhenin nhenin marked this pull request as ready for review December 7, 2023 14:01
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.

Review Status

Actionable comments generated: 14

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between b757e1a and ac9d93c.
Files ignored due to filter (2)
  • flake.lock
  • packages/runtime/client/rest/package.json
Files selected for processing (32)
  • examples/get-my-contract-ids-flow/index.html (1 hunks)
  • examples/rest-client-flow/index.html (1 hunks)
  • examples/run-lite/index.html (1 hunks)
  • examples/survey-workshop/participant/index.js (1 hunks)
  • examples/vesting-flow/index.html (1 hunks)
  • jsdelivr-npm-importmap.js (1 hunks)
  • packages/adapter/src/codec.ts (1 hunks)
  • packages/language/core/v1/src/address.ts (1 hunks)
  • packages/language/core/v1/src/guards.ts (2 hunks)
  • packages/language/core/v1/src/index.ts (1 hunks)
  • packages/language/core/v1/src/participants.ts (1 hunks)
  • packages/language/core/v1/src/policyId.ts (1 hunks)
  • packages/language/core/v1/src/token.ts (2 hunks)
  • packages/runtime/client/rest/src/contract/details.ts (2 hunks)
  • packages/runtime/client/rest/src/contract/endpoints/collection.ts (8 hunks)
  • packages/runtime/client/rest/src/contract/guards.ts (1 hunks)
  • packages/runtime/client/rest/src/contract/header.ts (2 hunks)
  • packages/runtime/client/rest/src/contract/index.ts (1 hunks)
  • packages/runtime/client/rest/src/contract/rolesConfigurations.ts (1 hunks)
  • packages/runtime/client/rest/src/index.ts (9 hunks)
  • packages/runtime/core/src/address.ts (2 hunks)
  • packages/runtime/core/src/index.ts (1 hunks)
  • packages/runtime/lifecycle/src/api.ts (2 hunks)
  • packages/runtime/lifecycle/src/browser/index.ts (2 hunks)
  • packages/runtime/lifecycle/src/generic/contracts.ts (7 hunks)
  • packages/runtime/lifecycle/src/generic/payouts.ts (3 hunks)
  • packages/runtime/lifecycle/src/generic/runtime.ts (1 hunks)
  • packages/runtime/lifecycle/src/nodejs/index.ts (2 hunks)
  • packages/runtime/lifecycle/test/examples/swap.ada.token.e2e.spec.ts (2 hunks)
  • packages/runtime/lifecycle/test/generic/contracts.e2e.spec.ts (2 hunks)
  • packages/runtime/lifecycle/test/generic/payouts.e2e.spec.ts (2 hunks)
  • packages/wallet/src/browser/index.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • jsdelivr-npm-importmap.js
Additional comments: 49
examples/get-my-contract-ids-flow/index.html (1)
  • 41-45: The change from contract to contractOrSourceId in the runtimeLifeCycle.contracts.createContract call is consistent with the PR objectives and AI-generated summaries, indicating a broader scope of accepted input for the createContract function.
examples/rest-client-flow/index.html (1)
  • 78-88: The changes to the input element's ID and value, as well as the hyperlink URL, are consistent with the PR's objective of renaming the createContract function to buildCreateContractTx. This suggests an update to the UI to reflect backend changes.
examples/run-lite/index.html (1)
  • 108-116: The change in the createContract function call to use an object with a contractOrSourceId field aligns with the PR's objective to refactor contract creation functions and enhance type safety.
examples/survey-workshop/participant/index.js (1)
  • 126-128: The change from contract to contractOrSourceId in the createContract function call is consistent with the PR objectives and the summary provided. This change suggests that the function now accepts a broader range of inputs, which could be either a contract or a source ID.
examples/vesting-flow/index.html (1)
  • 117-121: The change from contract to contractOrSourceId in the createContract function call aligns with the PR's objective to modify contract creation functions and introduce new types and guards related to roles and transactions. This change should be reflected in all relevant parts of the codebase where createContract is used.
packages/language/core/v1/src/guards.ts (2)
  • 16-16: The addition of the export PolicyIdGuard as PolicyId aligns with the PR objectives and the summary provided.

  • 63-63: The addition of the export RoleNameGuard as RoleName is consistent with the PR objectives and the summary.

packages/language/core/v1/src/index.ts (1)
  • 58-58: The addition of RoleName to the export list in participants.js is correctly reflected in the code.
packages/language/core/v1/src/participants.ts (1)
  • 32-33: The changes to export RoleName and RoleNameGuard are correctly implemented and align with the PR objectives and the provided summary.
packages/runtime/client/rest/src/contract/details.ts (1)
  • 40-54: The updated documentation comments for the Get Contract By Id endpoint, including the new category tag, are correctly reflected in the code. This enhances clarity and categorization for the endpoint.
packages/runtime/client/rest/src/contract/endpoints/collection.ts (9)
  • 43-44: The renaming of RolesConfig to RolesConfiguration and the update of its import path is correctly reflected in the code.

  • 255-255: The use of BuildCreateContractTxRequest in the code suggests that the renaming from CreateContractRequest has taken place as mentioned in the summary.

  • 508-508: The use of BuildCreateContractTxResponse in the code suggests that the renaming from CreateContractResponse has taken place as mentioned in the summary.

  • 205-205: The addition of ContractOrSourceId is correctly reflected in the code.

  • 211-211: The addition of ContractOrSourceIdGuard is correctly reflected in the code.

  • 66-66: The code for GetContractsRequest appears to be well-defined and documented.

  • 168-168: The code for GetContractsResponse appears to be well-defined and documented.

  • 492-492: The code for PostContractsRequest appears to be well-defined and documented.

  • 549-549: The code for postViaAxios appears to be well-defined and documented.

packages/runtime/client/rest/src/contract/guards.ts (1)
  • 16-27: The export statements for the guards are consistent with the PR objectives and summaries, which indicate the introduction of new types and guards for enhanced type safety and validation.
packages/runtime/client/rest/src/contract/header.ts (2)
  • 22-27: The update to the @category tag in the documentation comments for ContractHeader aligns with the PR's objective to enhance documentation and categorization.

  • 58-64: The update to the @category tag in the documentation comments for ContractHeaderGuard is consistent with the changes made to ContractHeader and the PR's objective to improve documentation.

packages/runtime/client/rest/src/contract/index.ts (4)
  • 14-51: The summary does not mention the removal of RolesConfig, but it has been removed as per the hunk. This should be noted in the summary to accurately reflect the changes made to the codebase.

  • 39-39: The summary does not mention the addition of ContractOrSourceId, but it has been added as per the hunk. This should be noted in the summary to accurately reflect the changes made to the codebase.

  • 19-19: The summary does not mention the addition of AddressBech32Brand, but it has been added as per the hunk. This should be noted in the summary to accurately reflect the changes made to the codebase.

  • 22-33: The summary does not mention the addition of several new exports such as ClosedRole, OpenRole, Openness, UsePolicyWithClosedRoleTokens, UsePolicyWithOpenRoleTokens, MintRolesTokens, TokenMetadataFile, TokenMetadata, Recipient, TokenQuantity, and RoleTokenConfiguration, but they have been added as per the hunk. This should be noted in the summary to accurately reflect the changes made to the codebase.

packages/runtime/client/rest/src/contract/rolesConfigurations.ts (2)
  • 10-24: The introduction of AddressBech32Brand and AddressBech32Guard seems to contradict the discussion in the PR comments about replacing the AddressBech32 type with one from the Runtime Rest Client Package. Please ensure that this change aligns with the intended refactoring and issue resolution strategy.

  • 177-210: The @category tags for mintRole and useMintedRoles functions correctly categorize them under both "Roles Configuration" and "Endpoint : Build Create Contract Tx", reflecting their dual relevance.

packages/runtime/client/rest/src/index.ts (6)
  • 450-453: The summary indicates that the RestDI type was renamed, but the hunk shows that RestDI is a new type. Please clarify if this is a new addition or a renaming of an existing type.

  • 234-254: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [237-264]

The changes to buildCreateContractTx method reflect the PR's objective to shift towards building transactions for contract creation. The method now accepts a more complex request object and handles optional properties with spread syntax.

  • 119-127: The summary suggests that the applyInputsToContract method should be renamed to buildApplyInputsToContractTx, but the method name has not been changed in the hunk. Please confirm if the method should be renamed or if the summary is incorrect.

  • 153-161: The summary suggests that the withdrawPayouts method should be renamed to buildWithdrawPayoutsTx, but the method name has not been changed in the hunk. Please confirm if the method should be renamed or if the summary is incorrect.

  • 57-61: The updates to the RestClient interface, including new method signatures and documentation, align with the PR's objectives to enhance the codebase and improve transaction building.

  • 79-81: The new method buildCreateContractTx in the RestClient interface with updated parameters and return types aligns with the PR's objectives to improve transaction building.

packages/runtime/core/src/address.ts (2)
  • 21-27: The addition of the StakeAddressBech32 type and associated functions for wrapping and unwrapping the newtype is correctly implemented and follows the existing pattern for AddressBech32.

  • 17-18: The AddressesAndCollaterals type is correctly defined using the AddressBech32 and TxOutRef types.

packages/runtime/core/src/index.ts (1)
  • 9-9: The addition of export * from "./source/id.js"; is confirmed and aligns with the PR objectives and the summary provided.
packages/runtime/lifecycle/src/api.ts (3)
  • 6-17: The summary does not mention the removal of RolesConfig import and the addition of ContractOrSourceId and RolesConfiguration imports.

  • 168-192: The summary does not mention the addition of tags and metadata properties to CreateContractRequest.

  • 51-148: The summary does not mention the addition of stakeAddress, threadRoleName, and roles properties to CreateContractRequest.

packages/runtime/lifecycle/src/browser/index.ts (1)
  • 34-39: The changes to mkRuntimeLifecycle function correctly reflect the PR's objective to introduce a new restClient parameter and maintain the existing deprecatedRestAPI. This update aligns with the PR's goal of enhancing the contract creation functions and introducing new types and guards related to roles and transactions.
packages/runtime/lifecycle/src/generic/contracts.ts (1)
  • 7-10: The summary indicates that the minUTxODepositDefault import was removed, but this change is not visible in the provided hunk. Please verify if this change occurred in another part of the file or if the summary is incorrect.
packages/runtime/lifecycle/src/generic/runtime.ts (2)
  • 9-19: The changes to the mkRuntimeLifecycle function, including the addition of the restClient parameter and the renaming of restAPI to deprecatedRestAPI, are correctly implemented as per the PR objectives and the summary provided.

  • 16-17: The restClient parameter is being correctly passed to the mkContractLifecycle and mkPayoutLifecycle functions, aligning with the intended changes.

packages/runtime/lifecycle/src/nodejs/index.ts (2)
  • 1-6: The changes to the imports align with the PR's objective to refactor and introduce new types and functions, as well as the summary provided.

  • 19-24: The update to mkRuntimeLifecycle to include both deprecatedRestAPI and restClient is consistent with the PR's objective to refactor functions and enhance type safety.

packages/runtime/lifecycle/test/generic/contracts.e2e.spec.ts (2)
  • 33-39: The update from contract to contractOrSourceId in the createContract method call aligns with the PR's objective to modify contract creation functions. This change seems to be correctly implemented in the test suite.

  • 51-57: The update from contract to contractOrSourceId in the createContract method call is consistently applied here as well, which is in line with the PR's objective to modify contract creation functions.

packages/wallet/src/browser/index.ts (1)
  • 77-84: The logic change in the mkBrowserWallet function to compare wallet names in lowercase is a good practice for case-insensitive comparison, ensuring that the function works correctly regardless of the case of the input walletName.

packages/language/core/v1/src/token.ts Show resolved Hide resolved
packages/language/core/v1/src/policyId.ts Show resolved Hide resolved
packages/language/core/v1/src/address.ts Show resolved Hide resolved
packages/adapter/src/codec.ts Outdated Show resolved Hide resolved
packages/runtime/lifecycle/src/api.ts Outdated Show resolved Hide resolved
@nhenin nhenin linked an issue Dec 7, 2023 that may be closed by this pull request
9 tasks
@nhenin nhenin removed the User Story label Dec 7, 2023
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.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 79e5963 and 60602d3.
Files ignored due to filter (2)
  • flake.lock
  • packages/runtime/client/rest/package.json
Files selected for processing (29)
  • examples/rest-client-flow/index.html (1 hunks)
  • examples/run-lite/index.html (1 hunks)
  • examples/survey-workshop/participant/index.js (1 hunks)
  • jsdelivr-npm-importmap.js (1 hunks)
  • packages/adapter/src/codec.ts (1 hunks)
  • packages/language/core/v1/src/address.ts (1 hunks)
  • packages/language/core/v1/src/guards.ts (2 hunks)
  • packages/language/core/v1/src/index.ts (1 hunks)
  • packages/language/core/v1/src/participants.ts (1 hunks)
  • packages/language/core/v1/src/policyId.ts (1 hunks)
  • packages/language/core/v1/src/token.ts (2 hunks)
  • packages/runtime/client/rest/src/contract/details.ts (2 hunks)
  • packages/runtime/client/rest/src/contract/endpoints/collection.ts (8 hunks)
  • packages/runtime/client/rest/src/contract/guards.ts (1 hunks)
  • packages/runtime/client/rest/src/contract/header.ts (2 hunks)
  • packages/runtime/client/rest/src/contract/index.ts (1 hunks)
  • packages/runtime/client/rest/src/contract/rolesConfigurations.ts (1 hunks)
  • packages/runtime/client/rest/src/index.ts (9 hunks)
  • packages/runtime/core/src/address.ts (2 hunks)
  • packages/runtime/core/src/index.ts (1 hunks)
  • packages/runtime/lifecycle/src/api.ts (2 hunks)
  • packages/runtime/lifecycle/src/browser/index.ts (2 hunks)
  • packages/runtime/lifecycle/src/generic/contracts.ts (7 hunks)
  • packages/runtime/lifecycle/src/generic/payouts.ts (3 hunks)
  • packages/runtime/lifecycle/src/generic/runtime.ts (1 hunks)
  • packages/runtime/lifecycle/src/nodejs/index.ts (2 hunks)
  • packages/runtime/lifecycle/test/examples/swap.ada.token.e2e.spec.ts (2 hunks)
  • packages/runtime/lifecycle/test/generic/payouts.e2e.spec.ts (2 hunks)
  • packages/wallet/src/browser/index.ts (1 hunks)
Files skipped from review due to trivial changes (5)
  • jsdelivr-npm-importmap.js
  • packages/adapter/src/codec.ts
  • packages/language/core/v1/src/guards.ts
  • packages/runtime/client/rest/src/contract/details.ts
  • packages/runtime/lifecycle/src/browser/index.ts
Files skipped from review as they are similar to previous changes (16)
  • examples/rest-client-flow/index.html
  • examples/run-lite/index.html
  • examples/survey-workshop/participant/index.js
  • packages/language/core/v1/src/address.ts
  • packages/language/core/v1/src/index.ts
  • packages/language/core/v1/src/participants.ts
  • packages/language/core/v1/src/policyId.ts
  • packages/language/core/v1/src/token.ts
  • packages/runtime/client/rest/src/contract/header.ts
  • packages/runtime/client/rest/src/index.ts
  • packages/runtime/core/src/address.ts
  • packages/runtime/core/src/index.ts
  • packages/runtime/lifecycle/src/generic/runtime.ts
  • packages/runtime/lifecycle/src/nodejs/index.ts
  • packages/runtime/lifecycle/test/generic/payouts.e2e.spec.ts
  • packages/wallet/src/browser/index.ts
Additional comments: 30
packages/runtime/client/rest/src/contract/endpoints/collection.ts (9)
  • 41-45: The renaming of RolesConfig to RolesConfiguration and the update of its import path from ../role.js to ../rolesConfigurations.js is correctly reflected in the code.

  • 220-225: The renaming of CreateContractRequest to BuildCreateContractTxRequest is implied by the presence of BuildCreateContractTxRequestWithContract which extends BuildCreateContractTxRequestOptions. However, the direct definition of BuildCreateContractTxRequest is not visible in the provided code.

  • 205-214: The addition of ContractOrSourceId and ContractOrSourceIdGuard is correctly implemented in the code.

  • 555-561: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [534-561]

The update of CreateContractResponse to BuildCreateContractTxResponse and the modification of its properties and comments are correctly reflected in the code.

  • 574-589: The update of the type of postViaAxios to BuildCreateContractTxEndpoint is correctly implemented in the code.

  • 66-67: The GetContractsRequest interface has been updated with documentation comments and potential refactoring, which is not mentioned in the summary but seems appropriate.

  • 168-168: The GetContractsResponse interface has been updated with documentation comments and potential refactoring, which is not mentioned in the summary but seems appropriate.

  • 517-528: The PostContractsRequest type has been updated with documentation comments and potential refactoring, which is not mentioned in the summary but seems appropriate.

  • 574-589: The postViaAxios function has been updated with documentation comments and potential refactoring, which is not mentioned in the summary but seems appropriate.

packages/runtime/client/rest/src/contract/guards.ts (2)
  • 25-25: The export RolesConfigurationGuard suggests that it is a guard for RolesConfiguration. Verify that this aligns with the new RolesConfiguration entity and that the guard is correctly implemented and used wherever RolesConfiguration is expected.

  • 16-27: Verify that the new guards such as PolicyIdGuard, RoleNameGuard, RoleName, and StakeAddressBech32 mentioned in the summary are defined and exported correctly in the appropriate modules, as they are not visible in the provided hunk.

packages/runtime/client/rest/src/contract/index.ts (1)
  • 14-54: The changes to the exported entities align with the PR objectives and summaries provided, indicating a refactor in contract creation and role configuration. Ensure that all dependent modules and external code that import these entities are updated to reflect these changes.

The verification process confirms that the changes made to the exported entities are consistent with the PR objectives and summaries. The removed entities RolesConfig, CreateContractRequest, and CreateContractResponse are no longer present in the updated files, and the new entities BuildCreateContractTxRequest, BuildCreateContractTxResponse, and RolesConfiguration are being used in the codebase as intended.

packages/runtime/lifecycle/src/api.ts (5)
  • 37-41: The summary indicates that the contract property in CreateContractRequest should be changed to contractOrSourceId, but the hunk still shows contract. Please verify if the property name should be updated.
-  contract: Contract;
+  contractOrSourceId: ContractOrSourceId;
  • 47-209: The summary does not mention the addition of stakeAddress, threadRoleName, roles, tags, and metadata properties to CreateContractRequest, but they are present in the hunk. This seems to be an oversight in the summary.

  • 59-145: The extensive documentation on the roles configuration in CreateContractRequest is a significant addition that is not mentioned in the summary.

  • 150-207: The detailed information about Marlowe Tags and Cardano Metadata in CreateContractRequest is a significant addition that is not mentioned in the summary.

  • 212-212: The summary does not mention the addition of invalidBefore and invalidHereafter properties to ApplyInputsRequest, but they are present in the hunk. This seems to be an oversight in the summary.

packages/runtime/lifecycle/src/generic/contracts.ts (6)
  • 7-10: The summary indicates that the minUTxODepositDefault import was removed, but this change is not visible in the provided hunks. Please verify if this change occurred outside the provided hunks.

  • 60-71: The summary does not mention changes to the submitApplyInputsTx function, but the hunk shows modifications in its implementation. Please verify if these changes are intentional and if they should be documented in the summary.

  • 83-97: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [73-91]

The summary does not mention changes to the getApplicableInputs function, but the hunk shows modifications in its implementation. Please verify if these changes are intentional and if they should be documented in the summary.

  • 102-110: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [93-110]

The summary does not mention changes to the getContractIds function, but the hunk shows modifications in its implementation. Please verify if these changes are intentional and if they should be documented in the summary.

  • 139-139: The summary does not mention changes to the getParties function, but the hunk shows modifications in its implementation. Please verify if these changes are intentional and if they should be documented in the summary.

  • 149-196: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [141-190]

The summary does not mention changes to the submitCreateTxFpTs function, but the hunk shows modifications in its implementation. Please verify if these changes are intentional and if they should be documented in the summary.

packages/runtime/lifecycle/src/generic/payouts.ts (4)
  • 27-35: The changes to the mkPayoutLifecycle function, including the addition of the restClient parameter and renaming of rest to deprecatedRestAPI, are consistent with the PR's objectives to refactor the REST API client interface.

  • 40-64: The updates to the function signatures for fetchAvailablePayouts, withdrawPayouts, and fetchWithdrawnPayouts to use deprecatedRestAPI are consistent with the PR's objectives to refactor the REST API client interface.

  • 173-181: The modifications to the convertAsset and convertTokens functions to use types from RestPayout are consistent with the PR's objectives to refactor the payout processes.

  • 170-171: Consider throwing an Error object instead of a string for better error handling and stack tracing.

- throw `Rest API Inconsistencies for Payout API (payout withdrawn without a withdrawalID) : ${stringify(payoutDetails)}`;
+ throw new Error(`Rest API Inconsistencies for Payout API (payout withdrawn without a withdrawalID) : ${stringify(payoutDetails)}`);
packages/runtime/lifecycle/test/examples/swap.ada.token.e2e.spec.ts (3)
  • 13-26: The addition of new imports unAddressBech32, mintRole, openRole, AddressBech32, and AddressBech32Guard is consistent with the changes described in the summary.

  • 67-68: The createContract method still uses the contract parameter instead of the updated contractOrSourceId as mentioned in the summary. This needs to be verified and potentially corrected to align with the intended changes.

  • 70-75: The usage of mintRole to assign roles to swapRequest.provider.roleName and swapRequest.swapper.roleName aligns with the changes described in the summary.

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 60602d3 and 27a8dd0.
Files selected for processing (1)
  • changelog.d/20231208_095010_nicolas.henin.md (1 hunks)
Additional comments: 2
changelog.d/20231208_095010_nicolas.henin.md (2)
  • 3-4: The changelog correctly documents the renaming of the createContract endpoint to buildCreateContractTx and its parity with the REST API request structure.

  • 8-8: The changelog entry for createContract being complete request-wise for creating non-merkleized contracts aligns with the PR's objectives to enhance the contract creation process.

@nhenin nhenin requested a review from hrajchert December 8, 2023 09:08
@nhenin nhenin dismissed hrajchert’s stale review December 8, 2023 09:09

Already multiple rounds of reviews have been done.

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between a73844b and d3a5b77.
Files ignored due to filter (1)
  • packages/runtime/client/rest/package.json
Files selected for processing (31)
  • changelog.d/20231208_095010_nicolas.henin.md (1 hunks)
  • examples/rest-client-flow/index.html (1 hunks)
  • examples/run-lite/index.html (1 hunks)
  • examples/survey-workshop/participant/index.js (1 hunks)
  • jsdelivr-npm-importmap.js (1 hunks)
  • packages/adapter/src/codec.ts (1 hunks)
  • packages/language/core/v1/src/address.ts (1 hunks)
  • packages/language/core/v1/src/guards.ts (2 hunks)
  • packages/language/core/v1/src/index.ts (1 hunks)
  • packages/language/core/v1/src/participants.ts (1 hunks)
  • packages/language/core/v1/src/policyId.ts (1 hunks)
  • packages/language/core/v1/src/token.ts (2 hunks)
  • packages/runtime/client/rest/src/contract/details.ts (2 hunks)
  • packages/runtime/client/rest/src/contract/endpoints/collection.ts (8 hunks)
  • packages/runtime/client/rest/src/contract/guards.ts (1 hunks)
  • packages/runtime/client/rest/src/contract/header.ts (2 hunks)
  • packages/runtime/client/rest/src/contract/index.ts (1 hunks)
  • packages/runtime/client/rest/src/contract/rolesConfigurations.ts (1 hunks)
  • packages/runtime/client/rest/src/index.ts (9 hunks)
  • packages/runtime/core/src/address.ts (2 hunks)
  • packages/runtime/core/src/index.ts (1 hunks)
  • packages/runtime/lifecycle/src/api.ts (2 hunks)
  • packages/runtime/lifecycle/src/browser/index.ts (2 hunks)
  • packages/runtime/lifecycle/src/generic/contracts.ts (7 hunks)
  • packages/runtime/lifecycle/src/generic/payouts.ts (3 hunks)
  • packages/runtime/lifecycle/src/generic/runtime.ts (1 hunks)
  • packages/runtime/lifecycle/src/index.ts (2 hunks)
  • packages/runtime/lifecycle/src/nodejs/index.ts (1 hunks)
  • packages/runtime/lifecycle/test/examples/swap.ada.token.e2e.spec.ts (2 hunks)
  • packages/runtime/lifecycle/test/generic/payouts.e2e.spec.ts (2 hunks)
  • packages/wallet/src/browser/index.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • changelog.d/20231208_095010_nicolas.henin.md
Files skipped from review as they are similar to previous changes (24)
  • examples/rest-client-flow/index.html
  • examples/run-lite/index.html
  • examples/survey-workshop/participant/index.js
  • jsdelivr-npm-importmap.js
  • packages/adapter/src/codec.ts
  • packages/language/core/v1/src/address.ts
  • packages/language/core/v1/src/guards.ts
  • packages/language/core/v1/src/index.ts
  • packages/language/core/v1/src/participants.ts
  • packages/language/core/v1/src/policyId.ts
  • packages/language/core/v1/src/token.ts
  • packages/runtime/client/rest/src/contract/details.ts
  • packages/runtime/client/rest/src/contract/guards.ts
  • packages/runtime/client/rest/src/contract/header.ts
  • packages/runtime/client/rest/src/contract/index.ts
  • packages/runtime/client/rest/src/index.ts
  • packages/runtime/core/src/address.ts
  • packages/runtime/core/src/index.ts
  • packages/runtime/lifecycle/src/api.ts
  • packages/runtime/lifecycle/src/browser/index.ts
  • packages/runtime/lifecycle/src/generic/runtime.ts
  • packages/runtime/lifecycle/test/examples/swap.ada.token.e2e.spec.ts
  • packages/runtime/lifecycle/test/generic/payouts.e2e.spec.ts
  • packages/wallet/src/browser/index.ts
Additional comments: 19
packages/runtime/client/rest/src/contract/endpoints/collection.ts (7)
  • 11-17: The import of RoleName from @marlowe.io/language-core-v1 is consistent with the summary.

  • 43-45: The renaming of RolesConfig to RolesConfiguration and the update of its import path is consistent with the summary.

  • 205-214: The addition of ContractOrSourceId and ContractOrSourceIdGuard is present and consistent with the summary.

  • 534-537: The renaming of CreateContractResponse to BuildCreateContractTxResponse is not directly visible in the provided code. However, the presence of BuildCreateContractTxResponse interface suggests that the renaming has taken place.

  • 574-589: The type of postViaAxios has been updated to BuildCreateContractTxEndpoint, which is consistent with the summary.

  • 211-214: The documentation for ContractOrSourceIdGuard should follow the established style mentioned in the previous comments by hrajchert. Verify if the documentation style for guards is consistent across the codebase.


The review comment requested verification of the documentation style for ContractOrSourceIdGuard to ensure consistency across the codebase. The shell command was executed to search for the guard documentation style, and it returned a single instance where the guard for ContractOrSourceId type is documented.

Since only one instance was found, it suggests that there may not be a well-established style for guard documentation across the codebase, or that the style is not consistently applied. However, without further instances to compare, we cannot definitively conclude that the style is inconsistent.

Final review comment:

The documentation for `ContractOrSourceIdGuard` is present, but we only found one instance of guard documentation in the codebase. It's recommended to ensure that the documentation style for guards is consistent across the codebase if there are other guards present.

  • 517-528: The PostContractsRequest type has been updated with new fields and guards, which is consistent with the changes mentioned in the summary. However, the summary does not mention the addition of threadTokenName and minUTxODeposit fields. Verify if these additions are intentional and correctly implemented.
packages/runtime/client/rest/src/contract/rolesConfigurations.ts (3)
  • 39-46: Consider consolidating the OpenRole type and the openRole constant into a single entity to avoid duplication and potential inconsistencies.

  • 210-216: Ensure that the useMintedRoles function is used correctly throughout the codebase, especially considering the changes in role configuration.

  • 226-239: Ensure that the mintRole function is used correctly throughout the codebase, especially considering the changes in role configuration.

packages/runtime/lifecycle/src/generic/contracts.ts (3)
  • 60-71: The summary does not mention the logic within submitApplyInputsTx function, which seems to have been updated to use deprecatedRestAPI instead of the new restClient. This change should be verified to ensure it aligns with the intended use of the deprecated API.

  • 149-196: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [139-188]

The summary does not mention the logic within getParties function, which seems to have been updated to include additional logic for filtering tokens by roleMintingPolicyId and mapping them to Party objects. This change should be verified to ensure it aligns with the intended functionality.

  • 149-190: The summary does not mention the detailed logic within submitCreateTxFpTs function, which includes building a transaction for contract creation and submitting it. This change should be verified to ensure it aligns with the intended functionality and the new buildCreateContractTx and submitContract methods are used correctly.
packages/runtime/lifecycle/src/generic/payouts.ts (4)
  • 27-35: The addition of the restClient parameter to mkPayoutLifecycle is consistent with the PR's objective to transition to a new REST client implementation.

  • 40-64: The update to use deprecatedRestAPI in fetchAvailablePayouts, withdrawPayouts, and fetchWithdrawnPayouts functions aligns with the PR's objective to maintain compatibility with both the deprecated and new REST API implementations.

  • 173-181: The modifications in convertAsset and convertTokens functions to use types from RestPayout are consistent with the PR's objective to refactor and rename related entities.

  • 170-171: Consider throwing an Error object instead of a string for better error handling and stack tracing.

- throw `Rest API Inconsistencies for Payout API (payout withdrawn without a withdrawalID) : ${stringify(payoutDetails)}`;
+ throw new Error(`Rest API Inconsistencies for Payout API (payout withdrawn without a withdrawalID) : ${stringify(payoutDetails)}`);
packages/runtime/lifecycle/src/index.ts (1)
  • 42-47: The changes to mkRuntimeLifecycle function are consistent with the PR objectives and the provided summary. The introduction of a new REST client (restClient) alongside the deprecated one (deprecatedRestAPI) is clear and matches the updated function signature in Generic.mkRuntimeLifecycle. Ensure that the rest of the codebase and any documentation are updated to reflect these changes.
packages/runtime/lifecycle/src/nodejs/index.ts (1)
  • 22-24: The function now initializes two REST clients, deprecatedRestAPI and restClient, to support both the old and new REST API implementations during the transition phase. Ensure that downstream code that uses mkRuntimeLifecycle is updated to handle both REST client instances appropriately.

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.

Review Status

Actionable comments generated: 4

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between a73844b and 7bfcdf6.
Files ignored due to filter (1)
  • packages/runtime/client/rest/package.json
Files selected for processing (32)
  • changelog.d/20231208_095010_nicolas.henin.md (1 hunks)
  • examples/rest-client-flow/index.html (1 hunks)
  • examples/run-lite/index.html (1 hunks)
  • examples/survey-workshop/participant/index.js (1 hunks)
  • jsdelivr-npm-importmap.js (1 hunks)
  • packages/adapter/src/codec.ts (1 hunks)
  • packages/language/core/v1/src/address.ts (1 hunks)
  • packages/language/core/v1/src/guards.ts (2 hunks)
  • packages/language/core/v1/src/index.ts (1 hunks)
  • packages/language/core/v1/src/participants.ts (1 hunks)
  • packages/language/core/v1/src/policyId.ts (1 hunks)
  • packages/language/core/v1/src/token.ts (2 hunks)
  • packages/runtime/client/rest/src/contract/details.ts (2 hunks)
  • packages/runtime/client/rest/src/contract/endpoints/collection.ts (8 hunks)
  • packages/runtime/client/rest/src/contract/guards.ts (1 hunks)
  • packages/runtime/client/rest/src/contract/header.ts (2 hunks)
  • packages/runtime/client/rest/src/contract/index.ts (1 hunks)
  • packages/runtime/client/rest/src/contract/rolesConfigurations.ts (1 hunks)
  • packages/runtime/client/rest/src/index.ts (9 hunks)
  • packages/runtime/core/src/address.ts (2 hunks)
  • packages/runtime/core/src/index.ts (1 hunks)
  • packages/runtime/core/src/sourceId.ts (1 hunks)
  • packages/runtime/lifecycle/src/api.ts (2 hunks)
  • packages/runtime/lifecycle/src/browser/index.ts (2 hunks)
  • packages/runtime/lifecycle/src/generic/contracts.ts (7 hunks)
  • packages/runtime/lifecycle/src/generic/payouts.ts (3 hunks)
  • packages/runtime/lifecycle/src/generic/runtime.ts (1 hunks)
  • packages/runtime/lifecycle/src/index.ts (2 hunks)
  • packages/runtime/lifecycle/src/nodejs/index.ts (1 hunks)
  • packages/runtime/lifecycle/test/examples/swap.ada.token.e2e.spec.ts (2 hunks)
  • packages/runtime/lifecycle/test/generic/payouts.e2e.spec.ts (2 hunks)
  • packages/wallet/src/browser/index.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • jsdelivr-npm-importmap.js
Files skipped from review as they are similar to previous changes (22)
  • changelog.d/20231208_095010_nicolas.henin.md
  • examples/rest-client-flow/index.html
  • examples/run-lite/index.html
  • examples/survey-workshop/participant/index.js
  • packages/adapter/src/codec.ts
  • packages/language/core/v1/src/address.ts
  • packages/language/core/v1/src/guards.ts
  • packages/language/core/v1/src/index.ts
  • packages/language/core/v1/src/participants.ts
  • packages/language/core/v1/src/policyId.ts
  • packages/language/core/v1/src/token.ts
  • packages/runtime/client/rest/src/contract/details.ts
  • packages/runtime/client/rest/src/contract/guards.ts
  • packages/runtime/client/rest/src/contract/header.ts
  • packages/runtime/core/src/address.ts
  • packages/runtime/core/src/index.ts
  • packages/runtime/lifecycle/src/api.ts
  • packages/runtime/lifecycle/src/browser/index.ts
  • packages/runtime/lifecycle/src/generic/runtime.ts
  • packages/runtime/lifecycle/test/examples/swap.ada.token.e2e.spec.ts
  • packages/runtime/lifecycle/test/generic/payouts.e2e.spec.ts
  • packages/wallet/src/browser/index.ts
Additional comments: 30
packages/runtime/client/rest/src/contract/endpoints/collection.ts (10)
  • 11-17: The import of RoleName from @marlowe.io/language-core-v1 aligns with the PR's objective to enhance role configuration management.

  • 41-45: Renaming RolesConfig to RolesConfiguration and updating the import path is consistent with the PR's objective to refactor role-related entities.

  • 205-214: The addition of ContractOrSourceId and ContractOrSourceIdGuard is consistent with the PR's objective to improve the contract creation process.

  • 555-561: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [534-561]

The update of CreateContractResponse to BuildCreateContractTxResponse and the modification of its properties and comments align with the PR's objective to transition to a new REST client implementation.

  • 574-589: The update of the type of postViaAxios to BuildCreateContractTxEndpoint is consistent with the PR's objective to refactor the contract creation endpoint.

  • 66-67: The changes to GetContractsRequest are not mentioned in the summary. Please ensure that these changes are intentional and consistent with the PR's objectives.

  • 168-168: The changes to GetContractsResponse are not mentioned in the summary. Please ensure that these changes are intentional and consistent with the PR's objectives.

  • 286-286: The changes to BuildCreateContractTxRequestOptions are not mentioned in the summary. Please ensure that these changes are intentional and consistent with the PR's objectives.

  • 518-518: The changes to PostContractsRequest are not mentioned in the summary. Please ensure that these changes are intentional and consistent with the PR's objectives.

  • 534-534: The changes to BuildCreateContractTxResponse are not mentioned in the summary. Please ensure that these changes are intentional and consistent with the PR's objectives.

packages/runtime/client/rest/src/contract/index.ts (1)
  • 14-54: The changes to the exported entities are consistent with the PR objectives and the provided summary. The removal of RolesConfig and the addition of new entities from rolesConfigurations.js, as well as the renaming of contract-related entities, are correctly reflected in the exports.
packages/runtime/client/rest/src/index.ts (7)
  • 80-82: The renaming of createContract to buildCreateContractTx aligns with the PR's objective to shift functionality from creating a contract directly to building a transaction for contract creation.

  • 454-454: The renaming of RestDI to include deprecatedRestAPI and restClient is consistent with the PR's objective to transition to a new REST client implementation.

  • 411-411: The update of the ContractsAPI interface with the new post type Contracts.BuildCreateContractTxEndpoint is consistent with the renaming of the createContract function.

  • 235-255: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [238-263]

The implementation of buildCreateContractTx has been updated to reflect the new request structure, which is consistent with the PR's objective to enhance the contract creation process.

  • 123-125: The previous comments regarding the potential renaming and documentation updates within the RestClient interface have been addressed in the current code.

  • 238-238: The previous comment by hrajchert regarding the name change in the backend for future release to maintain 1-1 parity has been addressed in the current code.

  • 240-240: The previous comment by bjornkihlberg regarding the clean and simple idiomatic TypeScript has been addressed in the current code.

packages/runtime/core/src/sourceId.ts (1)
  • 3-4: The changes to SourceId and SourceIdGuard are straightforward and do not introduce any issues.
packages/runtime/lifecycle/src/generic/contracts.ts (6)
  • 7-10: The summary indicates that the minUTxODepositDefault import was removed, but this is not reflected in the provided hunk. Please verify if this change is present elsewhere in the file or if the summary is incorrect.

  • 19-25: The addition of transactionWitnessSetTextEnvelope and RestClient imports aligns with the PR objectives to enhance contract creation and REST client implementation.

  • 36-44: The mkContractLifecycle function's signature has been correctly updated to include the restClient parameter, aligning with the PR's goal of transitioning to a new REST client implementation.

  • 50-53: The renaming of the rest parameter to restClient in the submitCreateTx function is consistent with the PR's refactoring goals.

  • 141-144: The submitCreateTxFpTs function's signature has been correctly updated to take a RestClient type, aligning with the PR's goal of transitioning to a new REST client implementation.

  • 149-189: The changes within submitCreateTxFpTs function to use client.buildCreateContractTx and client.submitContract are in line with the PR's objectives to refactor contract creation into a transaction-building process.

packages/runtime/lifecycle/src/generic/payouts.ts (3)
  • 27-35: The changes to the mkPayoutLifecycle function align with the PR objectives and summaries, indicating a transition to a new REST client implementation.

  • 40-64: The updates to the fetchAvailablePayouts, withdrawPayouts, and fetchWithdrawnPayouts functions to use deprecatedRestAPI are in line with the PR objectives and summaries.

  • 173-181: The modifications to the convertAsset and convertTokens functions to use RestPayout types are consistent with the PR objectives and summaries.

packages/runtime/lifecycle/src/index.ts (1)
  • 17-23: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [17-47]

The changes to mkRuntimeLifecycle function correctly reflect the PR's objective to support both the deprecated and new REST clients. The function now initializes two REST clients and passes them to Generic.mkRuntimeLifecycle along with the wallet parameter, which aligns with the PR's goal of transitioning to a new REST client implementation.

packages/runtime/lifecycle/src/nodejs/index.ts (1)
  • 8-24: The changes to mkRuntimeLifecycle function correctly implement the transition to a new REST client alongside the deprecated one, as per the PR objectives. The function now initializes both deprecatedRestAPI and restClient with the same runtimeURL and passes them along with the wallet to Generic.mkRuntimeLifecycle. This is consistent with the intended transition phase where both REST API implementations are in use.

Comment on lines 170 to 171
)
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider throwing an Error object instead of a string for better error handling and stack tracing.

- throw `Rest API Inconsistencies for Payout API (payout withdrawn without a withdrawalID) : ${stringify(payoutDetails)}`;
+ throw new Error(`Rest API Inconsistencies for Payout API (payout withdrawn without a withdrawalID) : ${stringify(payoutDetails)}`);

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
)
);
throw new Error(`Rest API Inconsistencies for Payout API (payout withdrawn without a withdrawalID) : ${stringify(payoutDetails)}`);

Comment on lines +123 to +125
// TODO: Jamie, remove the `s from the end of the endpoint name in the docs site
// DISCUSSION: @Jamie, @N.H: Should this be called `buildApplyInputsToContractTx` instead? As it is not applying inputs to the
// contract, rather it is creating the transaction to be signed
Copy link
Contributor

Choose a reason for hiding this comment

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

The TODO comments and discussions within the code should be resolved or removed to avoid confusion in the final codebase.

Comment on lines +157 to +159
// TODO: Jamie, remove the `s from the end of the endpoint name in the docs site
// DISCUSSION: @Jamie, @N.H: Should this be called `buildWithdrawPayoutsTx` instead? As it is not withdrawing the
// payout, rather it is creating the transaction to be signed
Copy link
Contributor

Choose a reason for hiding this comment

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

The TODO comments and discussions within the code should be resolved or removed to avoid confusion in the final codebase.

@nhenin nhenin merged commit ebf25e7 into main Dec 8, 2023
2 checks passed
@nhenin nhenin deleted the PLT-8261 branch December 8, 2023 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Open Role Support
3 participants