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

New runtime lifecycle contracts API & Initial Account Deposits (runtime v1.0.0) #188

Merged
merged 14 commits into from
May 11, 2024

Conversation

hrajchert
Copy link
Collaborator

@hrajchert hrajchert commented Mar 8, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a new Contract API for enhanced smart contract management.
    • Added initial account deposits feature for contract creation.
    • Updated example applications to utilize new features and APIs for contract management.
  • Bug Fixes

    • Revised handling of contract and transaction IDs in example node.js applications for more robust contract interactions.
  • Documentation

    • Updated comments in the environment module to provide clearer explanations of time intervals and environments.
  • Refactor

    • Simplified contract creation and management code across various modules.
    • Enhanced type checks and error handling in the runtime client modules.
  • Style

    • Minor updates to code styling and structure for better readability and maintenance.
  • Tests

    • Adjusted test cases to align with the updated contract management functionalities.
  • Chores

    • General codebase maintenance and minor updates to improve performance and compatibility.

Copy link
Contributor

coderabbitai bot commented Mar 8, 2024

Warning

Rate Limit Exceeded

@nhenin has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 16 minutes and 0 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 as a PR comment. 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 de8769b and a058f7f.

Walkthrough

This update revolutionizes the runtime lifecycle, introducing initial account deposits for streamlined contract creation and a new Contract API for smarter contract management. These changes enhance developer control, streamline interfaces, and boost the efficiency of smart contract operations.

Changes

Files Summary
.../runtime-core, .../runtime-lifecycle, .../runtime-rest-client Introduced accountDeposits and a new Contract API for enhanced smart contract management.
examples/nodejs/src/... Updated examples to leverage the new Contract API and accountDeposits features.
packages/adapter/src/..., packages/language/core/v1/src/..., packages/runtime/core/src/... Added new functions, refined error handling, and enhanced module exports.
packages/runtime/client/rest/src/... Refactored REST client functions with dynamic type checks and updated contract transaction interfaces.

🐇✨
In the realm of code, where changes thrive,
A rabbit dances, keeping systems alive.
With a leap and a bound, new features unfold,
Smart contracts bloom, in a story untold.
Let's celebrate this update so grand,
Innovation shines across the land! 🚀🌟
🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

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

Documentation and Community

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

@hrajchert hrajchert marked this pull request as draft March 8, 2024 14:27
Base automatically changed from hrajchert/applicable-inputs-refactor to main March 11, 2024 16:23
@nhenin nhenin force-pushed the hrajchert/runtime-lifecycle-refactor branch from fa8def4 to fb7ef61 Compare April 18, 2024 13:56
@nhenin nhenin force-pushed the hrajchert/runtime-lifecycle-refactor branch from fb7ef61 to dd24739 Compare April 18, 2024 14:45
jsdelivr-npm-importmap.js Outdated Show resolved Hide resolved
packages/runtime/core/src/asset/index.ts Dismissed Show dismissed Hide dismissed
@nhenin nhenin force-pushed the hrajchert/runtime-lifecycle-refactor branch 3 times, most recently from 5751458 to ba14e9c Compare May 11, 2024 10:26
@nhenin nhenin changed the title Draft: New runtime lifecycle contracts API New runtime lifecycle contracts API & Initial Account Deposits (runtime v1.0.0) May 11, 2024
@nhenin nhenin self-assigned this May 11, 2024
@nhenin nhenin added the enhancement New feature or request label May 11, 2024
@nhenin nhenin marked this pull request as ready for review May 11, 2024 10:29
@nhenin nhenin force-pushed the hrajchert/runtime-lifecycle-refactor branch from ba14e9c to 93e516a Compare May 11, 2024 10:34
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

Out of diff range and nitpick comments (2)
changelog.d/20240511_113958_nicolas.henin_runtime_lifecycle_refactor.md (1)

5-5: Consider adding the article "the" before "account setup process" for grammatical correctness.

packages/runtime/client/rest/src/index.ts (1)

239-239: Consider enhancing the error message for the strict parameter to be more informative, e.g., "Expected 'strict' to be a boolean value."

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between ba14e9c and 93e516a.
Files selected for processing (31)
  • changelog.d/20240511_113958_nicolas.henin_runtime_lifecycle_refactor.md (1 hunks)
  • examples/nodejs/src/experimental-features/source-map.ts (3 hunks)
  • examples/nodejs/src/marlowe-object-flow.ts (4 hunks)
  • examples/rest-client-flow/index.html (4 hunks)
  • packages/adapter/src/io-ts.ts (2 hunks)
  • packages/adapter/src/time.ts (1 hunks)
  • packages/language/core/v1/src/index.ts (1 hunks)
  • packages/language/core/v1/src/semantics.ts (2 hunks)
  • packages/language/examples/src/atomicSwap.ts (12 hunks)
  • packages/language/examples/test/atomicSwap.spec.ts (13 hunks)
  • packages/language/specification-client/src/main.ts (2 hunks)
  • packages/runtime/client/rest/src/contract/endpoints/collection.ts (4 hunks)
  • packages/runtime/client/rest/src/index.ts (4 hunks)
  • packages/runtime/client/rest/src/runtime/version.ts (1 hunks)
  • packages/runtime/core/src/asset/index.ts (3 hunks)
  • packages/runtime/core/src/contract/accountDeposits.ts (1 hunks)
  • packages/runtime/core/src/index.ts (1 hunks)
  • packages/runtime/core/src/payout/index.ts (3 hunks)
  • packages/runtime/lifecycle/src/browser/index.ts (3 hunks)
  • packages/runtime/lifecycle/src/generic/applicable-actions.ts (22 hunks)
  • packages/runtime/lifecycle/src/generic/contracts.ts (6 hunks)
  • packages/runtime/lifecycle/src/generic/new-contract-api.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 (5 hunks)
  • packages/runtime/lifecycle/test/generic/contracts.e2e.spec.ts (3 hunks)
  • packages/testing-kit/src/environment/index.ts (2 hunks)
  • packages/testing-kit/src/logging.ts (1 hunks)
  • packages/testing-kit/src/wallet/lucid/index.ts (3 hunks)
  • packages/testing-kit/src/wallet/lucid/provisionning.ts (1 hunks)
  • packages/wallet/src/lucid/index.ts (1 hunks)
Files skipped from review as they are similar to previous changes (26)
  • examples/nodejs/src/experimental-features/source-map.ts
  • examples/nodejs/src/marlowe-object-flow.ts
  • examples/rest-client-flow/index.html
  • packages/adapter/src/io-ts.ts
  • packages/adapter/src/time.ts
  • packages/language/core/v1/src/index.ts
  • packages/language/core/v1/src/semantics.ts
  • packages/language/examples/src/atomicSwap.ts
  • packages/language/examples/test/atomicSwap.spec.ts
  • packages/language/specification-client/src/main.ts
  • packages/runtime/client/rest/src/contract/endpoints/collection.ts
  • packages/runtime/client/rest/src/runtime/version.ts
  • packages/runtime/core/src/contract/accountDeposits.ts
  • packages/runtime/core/src/index.ts
  • packages/runtime/core/src/payout/index.ts
  • packages/runtime/lifecycle/src/browser/index.ts
  • packages/runtime/lifecycle/src/generic/applicable-actions.ts
  • packages/runtime/lifecycle/src/index.ts
  • packages/runtime/lifecycle/src/nodejs/index.ts
  • packages/runtime/lifecycle/test/examples/swap.ada.token.e2e.spec.ts
  • packages/runtime/lifecycle/test/generic/contracts.e2e.spec.ts
  • packages/testing-kit/src/environment/index.ts
  • packages/testing-kit/src/logging.ts
  • packages/testing-kit/src/wallet/lucid/index.ts
  • packages/testing-kit/src/wallet/lucid/provisionning.ts
  • packages/wallet/src/lucid/index.ts
Additional Context Used
LanguageTool (5)
changelog.d/20240511_113958_nicolas.henin_runtime_lifecycle_refactor.md (5)

Near line 5: You might be missing the article “the” here.
Context: ...e the account setup process and enhance user experience. - Benefits: This feat...


Near line 14: A punctuation mark might be missing here.
Context: ...ion (BuildCreateContractTxRequest via buildCreateContractTx)([PR-188](https:/...


Near line 27: Did you mean the adjective “end-to-end” (spelled with hyphens)?
Context: ...t of ContractInstance object) - see end to end tests for examples (e.g : `swap.ada.tok...


Near line 30: The abbreviation “e.g.” (= for example) requires two periods.
Context: ...arameter field accountDeposits in - e.g ```ts const sellerContractInstance = a...


Near line 43: Did you mean the adjective “end-to-end” (spelled with hyphens)?
Context: ...re (initial account deposits) - see end to end tests for examples (e.g : `swap.ada.tok...

GitHub Check Runs (1)
CodeQL success (1)

packages/runtime/core/src/asset/index.ts: [warning] 98-98: Prototype-polluting assignment
This assignment may alter Object.prototype if a malicious 'proto' string is injected from library input.
This assignment may alter Object.prototype if a malicious 'proto' string is injected from library input.
This assignment may alter Object.prototype if a malicious 'proto' string is injected from library input.

Additional comments not posted (6)
packages/runtime/core/src/asset/index.ts (2)

41-58: Ensure that the AssetsGuard type definition correctly handles nullable fields and complex types.


85-100: The function mapAsset correctly handles optional fields and maps assets to their respective types. Good use of nullish coalescing operator for default values.

packages/runtime/lifecycle/src/generic/new-contract-api.ts (1)

53-72: The function mkContractsAPI correctly uses a map to cache instances of ContractInstanceAPI. This is a good practice to avoid unnecessary re-instantiations.

packages/runtime/lifecycle/src/generic/contracts.ts (1)

Line range hint 372-488: The function createContract and applyInputs are well-structured and handle various contract creation and input application scenarios. Ensure that all parameters are validated before use to prevent injection attacks.

packages/runtime/client/rest/src/index.ts (2)

216-229: The implementation of withDynamicTypeCheck function correctly adds optional runtime type checking based on the strict parameter. Good use of conditional logic.


262-423: The use of withDynamicTypeCheck across various methods in the RestClient interface enhances type safety and robustness. This is consistent with the changes in the mkRestClient function and aligns with the overall goal of the PR.

@nhenin nhenin force-pushed the hrajchert/runtime-lifecycle-refactor branch from 93e516a to 086b483 Compare May 11, 2024 11:05
@nhenin nhenin force-pushed the hrajchert/runtime-lifecycle-refactor branch from 086b483 to de8769b Compare May 11, 2024 11:06
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

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

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

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@nhenin nhenin force-pushed the hrajchert/runtime-lifecycle-refactor branch from 820a24c to a058f7f Compare May 11, 2024 11:10
@nhenin nhenin merged commit 2ef0439 into main May 11, 2024
4 checks passed
@nhenin nhenin deleted the hrajchert/runtime-lifecycle-refactor branch May 11, 2024 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants