-
Notifications
You must be signed in to change notification settings - Fork 10
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
PLT-8753 | Atomic Swap Contract in @marlowe.io/language-examples #131
Conversation
WalkthroughThe codebase has undergone a refactor, notably transitioning from direct function imports to accessing functions via imported objects. This encapsulation suggests a move towards a more modular and object-oriented approach. Additionally, there's an expansion of functionality and types in the atomic swap feature, enhancing its capabilities and contract logic. The changes streamline imports and exports, suggesting a tidier and more organized code structure. Changes
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 X ? TipsChat with CodeRabbit Bot (
|
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files ignored due to filter (1)
- packages/language/examples/typedoc.json
Files selected for processing (4)
- packages/language/examples/src/atomicSwap.ts (1 hunks)
- packages/language/examples/src/contract-one-notify.ts (1 hunks)
- packages/language/examples/src/index.ts (1 hunks)
- packages/language/examples/src/vesting.ts (1 hunks)
Files skipped from review due to trivial changes (2)
- packages/language/examples/src/contract-one-notify.ts
- packages/language/examples/src/vesting.ts
Files skipped from review as they are similar to previous changes (2)
- packages/language/examples/src/atomicSwap.ts
- packages/language/examples/src/index.ts
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.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files ignored due to filter (1)
- packages/language/examples/typedoc.json
Files selected for processing (7)
- examples/survey-workshop/participant/contract.js (3 hunks)
- packages/language/examples/src/atomicSwap.ts (1 hunks)
- packages/language/examples/src/contract-one-notify.ts (1 hunks)
- packages/language/examples/src/index.ts (1 hunks)
- packages/language/examples/src/vesting.ts (1 hunks)
- packages/runtime/lifecycle/test/examples/swap.ada.token.e2e.spec.ts (3 hunks)
- packages/runtime/lifecycle/test/generic/payouts.e2e.spec.ts (3 hunks)
Files skipped from review due to trivial changes (2)
- packages/language/examples/src/contract-one-notify.ts
- packages/language/examples/src/vesting.ts
Files skipped from review as they are similar to previous changes (1)
- packages/language/examples/src/index.ts
Additional comments: 11
examples/survey-workshop/participant/contract.js (4)
1-1: The import statement has been correctly updated to import
Survey
from@marlowe.io/language-examples
. This aligns with the PR objectives and the AI-generated summary.48-48: The
mkWorkshopSurvey
function has been correctly updated to useSurvey.survey
following the changes in the import statement.58-58: Verify that the
verifySurvey
function exists on theSurvey
object and is correctly referenced here.57-57: Ensure that the updated call to
Survey.verifySurvey
withinverifySurveyContract
maintains the same behavior as the previous direct call toverifySurvey
.packages/runtime/lifecycle/test/examples/swap.ada.token.e2e.spec.ts (4)
- 18-19: The import of
Swap
from@marlowe.io/language-examples
is correctly used to create a new atomic swap contract withSwap.mkAtomicSwap(scheme)
. Ensure that the removal of theExamples
import does not leave any orphaned references or unused code.Verification successful
The executed script was intended to search for any remaining references to
Examples
in theswap.ada.token.e2e.spec.ts
file after the import statement forExamples
was removed. The absence of output from therg
command indicates that there are no occurrences ofExamples
in the file, suggesting that the removal of theExamples
import did not leave any orphaned references in this specific file.However, the scope of the search was limited to the
swap.ada.token.e2e.spec.ts
file. To ensure that the removal of theExamples
import does not affect other parts of the codebase, a broader search across the entire codebase would be necessary.Let's perform a broader search to verify that the removal of
Examples
does not leave any orphaned references in other files within the codebase.
The search across the entire codebase for references to
Examples
has produced output indicating that the termExamples
appears in various files, but these occurrences are within documentation files (Readme.md
andpackages/wallet/Readme.md
) and an HTML file (examples/vesting-flow/index.html
). There are no indications from the search results that the termExamples
is used in a way that would suggest orphaned code references due to the removal of theExamples
import from theswap.ada.token.e2e.spec.ts
file.Based on this information, it can be concluded that the removal of the
Examples
import from theswap.ada.token.e2e.spec.ts
file has not left any orphaned references toExamples
in the codebase that would require attention.* 43-58: The reorganization of the `scheme` object appears consistent and well-structured. The new properties and their usage in `Swap.mkAtomicSwap(scheme)` align with the expected format for creating an atomic swap contract.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for any remaining references to `Examples` that might be orphaned. rg 'Examples' -- 'packages/runtime/lifecycle/test/examples/swap.ada.token.e2e.spec.ts'Length of output: 84
Script:
#!/bin/bash # Search for any remaining references to `Examples` across the entire codebase. rg 'Examples'Length of output: 170
66-69: The update to the
roles
object to usescheme.participants.buyer.role_token
is consistent with the newscheme
structure. This change appears to be correctly implemented.74-74: The update to the
waitConfirmation
method call to usetxCreatedContract
is correct and reflects the variable renaming accurately.packages/runtime/lifecycle/test/generic/payouts.e2e.spec.ts (3)
4-6: The changes in import statements align with the PR's objectives to demonstrate the atomic swap functionality.
38-56: The restructuring of the
scheme
object and the updatedswapContract
creation process are consistent with the new atomic swap contract example.62-62: The update to the
roles
object in thecreateContract
method correctly reflects the newscheme
structure.
packages/runtime/lifecycle/test/examples/swap.ada.token.e2e.spec.ts
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- changelog.d/20231215_173732_nicolas.henin.md (1 hunks)
Additional comments: 1
changelog.d/20231215_173732_nicolas.henin.md (1)
- 1-3: The changelog entry succinctly describes the enhancements made to the swap contract. It would be beneficial to ensure that all significant changes, especially those related to public or exported entities, are reflected in the changelog for clarity and completeness.
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files ignored due to filter (1)
- packages/language/examples/typedoc.json
Files selected for processing (9)
- changelog.d/20231215_173732_nicolas.henin.md (1 hunks)
- examples/survey-workshop/participant/contract.js (3 hunks)
- packages/language/examples/src/atomicSwap.ts (1 hunks)
- packages/language/examples/src/contract-one-notify.ts (1 hunks)
- packages/language/examples/src/index.ts (1 hunks)
- packages/language/examples/src/survey.ts (2 hunks)
- packages/language/examples/src/vesting.ts (4 hunks)
- packages/runtime/lifecycle/test/examples/swap.ada.token.e2e.spec.ts (3 hunks)
- packages/runtime/lifecycle/test/generic/payouts.e2e.spec.ts (3 hunks)
Files skipped from review due to trivial changes (3)
- changelog.d/20231215_173732_nicolas.henin.md
- packages/language/examples/src/contract-one-notify.ts
- packages/language/examples/src/vesting.ts
Files skipped from review as they are similar to previous changes (3)
- examples/survey-workshop/participant/contract.js
- packages/language/examples/src/index.ts
- packages/runtime/lifecycle/test/examples/swap.ada.token.e2e.spec.ts
Additional comments: 11
packages/language/examples/src/atomicSwap.ts (6)
1-60: The documentation provided at the beginning of the file is comprehensive and gives a clear overview of the module's purpose and usage. This is good practice for maintainability and clarity for future developers.
63-78: All imports should be used in the file. If any of the imported entities are not used, they should be removed to keep the code clean.
Verification successful
The executed script has verified that all imported entities from the
@marlowe.io/language-core-v1
package are indeed used in theatomicSwap.ts
file. The script iterated through each imported entity and checked for its presence in the file. Since the output indicates that all entities are used, there are no unused imports to be removed.Based on this information, the review comment has been addressed, and the imports in
atomicSwap.ts
are correctly utilized.* 106-206: The type declarations for `State`, `Action`, and `CloseReason` are comprehensive and seem to cover all necessary scenarios for the atomic swap contract. Ensure that all possible states and actions have been accounted for to prevent any unexpected behavior.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify that all imported entities are used within the file. rg --type ts --files-with-matches 'import {.*} from "@marlowe.io/language-core-v1";' | xargs rg --type ts --files-without-match 'Contract|close|TokenValue|Timeout|Party|PayeeParty|Input|MarloweState|IChoice|IDeposit|INotify|Address|datetoTimeout|Role'Length of output: 2662
Script:
#!/bin/bash # Verify that all imported entities are used within the atomicSwap.ts file. unused_imports=() for entity in Contract close TokenValue Timeout Party PayeeParty Input MarloweState IChoice IDeposit INotify Address datetoTimeout Role; do if ! rg --type ts --quiet "$entity" "packages/language/examples/src/atomicSwap.ts"; then unused_imports+=("$entity") fi done if [ ${#unused_imports[@]} -eq 0 ]; then echo "All imported entities are used in atomicSwap.ts." else echo "Unused imports in atomicSwap.ts: ${unused_imports[*]}" fiLength of output: 3150
220-375: The
getState
function's logic appears to correctly interpret the contract's rules based on the input history. However, ensure that the conditions for state transitions are thoroughly tested, especially since this function is central to the contract's operation.376-444: The
mkContract
function constructs the contract based on the provided scheme. Ensure that the contract is constructed correctly and that all possible paths are handled, including any error conditions that might not be immediately apparent.287-318: The handling of timeouts and tokens within the contract logic is critical. Ensure that the logic is secure and robust against potential attacks, such as reentrancy or timing attacks, which are common concerns in smart contract development.
packages/language/examples/src/survey.ts (2)
10-13: The change to export
SurveyOptions
type is correct and aligns with the PR objectives and AI-generated summary.19-22: The change to export
Question
type is correct and aligns with the PR objectives and AI-generated summary.packages/runtime/lifecycle/test/generic/payouts.e2e.spec.ts (3)
4-6: The import changes are consistent with the PR's focus on atomic swaps and the removal of unused imports is a good practice for code cleanliness.
38-56: The changes to the
scheme
object and the creation ofswapContract
usingSwap.mkAtomicSwap(scheme)
are consistent with the new atomic swap functionality being introduced.62-62: The update to the roles object in the
createContract
method to usescheme.participants.buyer.role_token
aligns with the newscheme
object structure and atomic swap logic.
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.
I've only did a shallow code review, didn't test if it works correctly or not. In future PR's please provide how to test/what to check for
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.
Review Status
Actionable comments generated: 3
Configuration used: CodeRabbit UI
Files selected for processing (6)
- changelog.d/20231215_173732_nicolas.henin.md (1 hunks)
- packages/language/examples/src/atomicSwap.ts (1 hunks)
- packages/language/examples/src/index.ts (1 hunks)
- packages/language/examples/src/vesting.ts (5 hunks)
- packages/runtime/lifecycle/test/examples/swap.ada.token.e2e.spec.ts (3 hunks)
- packages/runtime/lifecycle/test/generic/payouts.e2e.spec.ts (3 hunks)
Additional comments: 16
changelog.d/20231215_173732_nicolas.henin.md (1)
- 1-3: The changelog entry provides a clear description of the new swap contract version and its relevance to the Order Book Swap Prototype. It's good to see that the changelog includes a link to the PR for traceability.
packages/language/examples/src/atomicSwap.ts (9)
1-54: The module description is comprehensive and includes a clear explanation of the contract's functionality, participants, and stages. The example usage is also well-documented, which is beneficial for developers looking to implement or interact with the contract.
57-70: The imports are correctly structured, and it's good to see that only the necessary components are imported, which can help with tree shaking and keeping the bundle size small if used in a frontend application.
80-96: The
Scheme
type is well-defined and includes comments explaining the purpose of theswapConfirmation
phase, which is a good practice for complex types like this one.98-104: The
State
type union is clearly defined, with each state representing a distinct phase of the contract. This is a good use of TypeScript's union types to represent a finite state machine.142-156: The
Action
type union is well-defined, with each action representing a possible interaction with the contract. The comments provide additional context, which is helpful.192-198: The
CloseReason
type union is clearly defined, with each type representing a reason for the contract's closure. This explicitness is good for understanding the contract's possible end states.210-219: The
UnexpectedSwapContractState
class is well-defined and extends the nativeError
class, which is a common pattern for custom error handling in TypeScript.221-279: The
getAvailableActions
function is well-structured and uses a switch statement to handle different contract states. This is a clean approach to determining the available actions based on the current state.364-429: The
mkContract
function and its helper functions (mkOffer
,mkAsk
,mkSwapConfirmation
) are well-structured and provide a clear way to construct the contract. The use of closures to encapsulate the creation logic for each stage of the contract is a good practice.packages/language/examples/src/index.ts (1)
- 1-16: The updated documentation block provides a clear overview of the contract examples contained within the package. The restructuring of exports to directly export
Vesting
,AtomicSwap
, andSurvey
from their respective modules is a good practice as it simplifies the import paths for these modules.packages/language/examples/src/vesting.ts (3)
1-7: The module description is clear and concise, explaining the functionality of the vesting contract. It's good to see that the description includes a list of steps that outline the contract's behavior.
20-32: The addition of the "Limitations" section is a good practice as it sets expectations for the contract's deployment capabilities. It's important for users to be aware of any constraints.
43-47: The imports are correctly structured, and it's good to see that only the necessary components are imported. This can help with tree shaking and keeping the bundle size small if used in a frontend application.
packages/runtime/lifecycle/test/examples/swap.ada.token.e2e.spec.ts (1)
- 40-73: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [18-69]
The test case "can execute the nominal case" has been updated to use the new
AtomicSwap
contract. The changes reflect the updated import and usage of theAtomicSwap
module. It's important to ensure that the test still passes with these changes, as they alter the setup and execution of the swap contract.packages/runtime/lifecycle/test/generic/payouts.e2e.spec.ts (1)
- 35-66: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [4-62]
The test case "Payouts can be withdrawn" has been updated to use the new
AtomicSwap
contract. The changes reflect the updated import and usage of theAtomicSwap
module. It's important to ensure that the test still passes with these changes, as they alter the setup and execution of the swap contract.
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.
Review Status
Actionable comments generated: 5
Configuration used: CodeRabbit UI
Files selected for processing (6)
- changelog.d/20231215_173732_nicolas.henin.md (1 hunks)
- packages/language/examples/src/atomicSwap.ts (1 hunks)
- packages/language/examples/src/index.ts (1 hunks)
- packages/language/examples/src/vesting.ts (5 hunks)
- packages/runtime/lifecycle/test/examples/swap.ada.token.e2e.spec.ts (3 hunks)
- packages/runtime/lifecycle/test/generic/payouts.e2e.spec.ts (3 hunks)
Files skipped from review due to trivial changes (2)
- changelog.d/20231215_173732_nicolas.henin.md
- packages/language/examples/src/vesting.ts
Files skipped from review as they are similar to previous changes (1)
- packages/language/examples/src/index.ts
Additional comments: 11
packages/language/examples/src/atomicSwap.ts (5)
1-54: The documentation provided at the beginning of the
atomicSwap.ts
file is comprehensive and well-structured, offering a clear explanation of the module's purpose and usage. This is good for maintainability and for new developers who may use this module in the future.143-198: The
Action
andCloseReason
type definitions are comprehensive and cover all expected actions and reasons for closing the contract. It's good practice to keep these definitions close to each other as they are related, which has been done here.210-219: The
UnexpectedSwapContractState
class is a good use of custom error handling, providing clear feedback when the contract state is unexpected. Including thescheme
andstate
in the error is helpful for debugging.282-345: The
getState
andgetClosedState
functions are well-implemented, with clear logic for determining the state based on the input history. The use of a switch statement and the length of the input history to determine the state is a good approach.377-442: The
mkContract
function and its helper functions (mkOffer
,mkAsk
,mkSwapConfirmation
) are well-structured and provide a clear flow for contract creation. The use of closures to encapsulate the logic for each part of the contract is a good design choice.packages/runtime/lifecycle/test/examples/swap.ada.token.e2e.spec.ts (3)
- 18-19: The addition of the
mintRole
import and usage is a significant change. It's important to ensure that themintRole
function is properly tested and that its integration into the test does not introduce any side effects or dependencies that could affect the test's reliability.Verification successful
The initial search for unit tests covering the
mintRole
function did not yield any results. This could mean that there are no unit tests named withdescribe
blocks that specifically mentionmintRole
. However, it's possible that the function is tested within a broader context or with a different naming convention in the test descriptions.To ensure thorough verification, I will perform a broader search for any test files that might contain tests for the
mintRole
function, without relying on thedescribe
block naming.
The search results indicate that the
mintRole
function is referenced in two end-to-end test specification files:swap.ada.token.e2e.spec.ts
andpayouts.e2e.spec.ts
. This suggests that themintRole
function is likely exercised as part of the end-to-end testing process in these two test suites.Given this information, it can be inferred that the
mintRole
function is indeed covered by tests, specifically within the context of end-to-end tests for the swap and payouts functionality. Therefore, the integration of themintRole
function into theswap.ada.token.e2e.spec.ts
test file is supported by existing test coverage.* 43-57: The definition of the `scheme` object within the test is crucial for setting up the atomic swap contract. It's important to verify that the deadlines and asset values are appropriate for the test scenarios and that they align with the expected behavior of the contract.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify that mintRole function is covered by unit tests rg --type ts "describe\(.*mintRole.*\)"Length of output: 41
Script:
#!/bin/bash # Search for any test files that might contain tests for the mintRole function rg --type ts --files-with-matches "mintRole" | grep "\.spec\.ts$"Length of output: 193
Verification successful
The search results indicate that the
AtomicSwap.Scheme
type is used in multiple files within the test suite and examples. To verify the consistency of thescheme
object's deadlines and asset values, we should examine the usage ofAtomicSwap.Scheme
in these files.Let's write a script to extract the relevant portions of code from the
swap.ada.token.e2e.spec.ts
,payouts.e2e.spec.ts
, andatomicSwap.ts
files whereAtomicSwap.Scheme
is defined. This will allow us to compare thescheme
object's structure and values across different test setups.
The regex error occurred because the
{
character is a special character in regex, used for specifying quantities, and it needs to be escaped to be used as a literal character. Let's correct the script by escaping the{
character and rerun the search to extract the relevant portions of code whereAtomicSwap.Scheme
is defined.
The outputs from the scripts provide the definitions of the
scheme
object in three different files. Let's analyze the consistency of thescheme
object across these files:
In
swap.ada.token.e2e.spec.ts
, thescheme
object is defined with:
seller
's address fromadaProvider.address
- Deadlines set to one day from the current date for both
offer
andask
asset
foroffer
set toadaValue(2n)
asset
forask
set toruntimeTokenToMarloweTokenValue(tokenValueMinted)
In
payouts.e2e.spec.ts
, thescheme
object is similarly defined with:
seller
's address fromadaProvider.address
- Deadlines set to one day from the current date for both
offer
andask
asset
foroffer
set toadaValue(2n)
asset
forask
set toruntimeTokenToMarloweTokenValue(tokenValueMinted)
In
atomicSwap.ts
, thescheme
object is defined within an example in the documentation with:
- A hardcoded
seller
's address- Deadlines set to one day from the current date for both
offer
andask
asset
foroffer
set totokenValue(10n)(tokenA)
asset
forask
set totokenValue(10n)(tokenB)
The
scheme
object's structure is consistent across the test files (swap.ada.token.e2e.spec.ts
andpayouts.e2e.spec.ts
), with the same deadlines and similar asset values, which are appropriate for the test scenarios. The example inatomicSwap.ts
is for documentation purposes and uses different token values, but the structure and the approach to setting deadlines are consistent with the test files.Based on this analysis, the
scheme
object within theswap.ada.token.e2e.spec.ts
file is consistent with other test setups in terms of structure and the approach to defining deadlines and assets.* 59-69: The creation of the swap contract using the `AtomicSwap.mkContract` function is a key part of the test. It's important to ensure that the contract creation process is robust and that any potential errors are handled appropriately.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify that the scheme deadlines and asset values are consistent with other test setups rg --type ts "scheme: AtomicSwap.Scheme"Length of output: 336
Script:
#!/bin/bash # Extract the relevant portions of code where `AtomicSwap.Scheme` is defined in the mentioned files rg --type ts --context 10 "const scheme: AtomicSwap.Scheme = {" packages/runtime/lifecycle/test/examples/swap.ada.token.e2e.spec.ts rg --type ts --context 10 "const scheme: AtomicSwap.Scheme = {" packages/runtime/lifecycle/test/generic/payouts.e2e.spec.ts rg --type ts --context 10 "const scheme: AtomicSwap.Scheme = {" packages/language/examples/src/atomicSwap.tsLength of output: 772
Script:
#!/bin/bash # Correct the regex by escaping the '{' character and extract the relevant portions of code rg --type ts --context 10 "const scheme: AtomicSwap.Scheme = \{" packages/runtime/lifecycle/test/examples/swap.ada.token.e2e.spec.ts rg --type ts --context 10 "const scheme: AtomicSwap.Scheme = \{" packages/runtime/lifecycle/test/generic/payouts.e2e.spec.ts rg --type ts --context 10 "const scheme: AtomicSwap.Scheme = \{" packages/language/examples/src/atomicSwap.tsLength of output: 2721
packages/runtime/lifecycle/test/generic/payouts.e2e.spec.ts (3)
4-6: The changes in imports, specifically the addition of
AtomicSwap
and the removal ofNext
, suggest a significant refactoring. It's important to verify that these changes do not affect other parts of the test suite and that all tests still pass.38-52: The
scheme
object is central to the setup of the atomic swap contract in the test. It's important to verify that the scheme's structure and values are consistent with the contract's requirements and that they are used correctly throughout the test.Verification successful
The search results indicate that the
scheme: AtomicSwap.Scheme
type declaration is used in multiple test files (payouts.e2e.spec.ts
andswap.ada.token.e2e.spec.ts
) as well as in the source fileatomicSwap.ts
. To verify the consistency of thescheme
object's structure and values, we should examine its usage in these test files and compare it to the definition inatomicSwap.ts
.To do this, we can look for the definition of the
AtomicSwap.Scheme
type inatomicSwap.ts
and then ensure that thescheme
objects in the test files match this structure and use appropriate values.
The output from the scripts indicates that the
AtomicSwap.Scheme
type is exported fromatomicSwap.ts
and is used in bothpayouts.e2e.spec.ts
andswap.ada.token.e2e.spec.ts
. However, the output does not show the actual structure of theScheme
type or the details of how thescheme
object is used in the test files.To verify the consistency of the
scheme
object's structure and values, we need to see the full definition of theScheme
type fromatomicSwap.ts
and the actual usage in the test files. Let's retrieve the full type definition and the completescheme
object declarations from the test files.
The output provides the structure of the
AtomicSwap.Scheme
type fromatomicSwap.ts
and the declarations of thescheme
object in bothpayouts.e2e.spec.ts
andswap.ada.token.e2e.spec.ts
. TheScheme
type consists of two main parts:offer
andask
, each containingseller
orbuyer
information, anasset
, and adeadline
.Comparing this to the
scheme
object declarations in the test files, we can see that the structure is consistent with the type definition. Bothscheme
objects in the test files haveoffer
andask
sections with the appropriate fields:seller
orbuyer
,asset
, anddeadline
. The values used in the test files, such asadaProvider.address
,pipe(addDays(Date.now(), 1), datetoTimeout)
, andruntimeTokenToMarloweTokenValue(tokenValueMinted)
, are specific to the test setup and are not part of the type definition, but they are appropriate for the fields they are assigned to.Based on the provided output, the
scheme
object's structure and values in the test files are consistent with theAtomicSwap.Scheme
type definition inatomicSwap.ts
. Therefore, the usage of thescheme
object in the test files appears to be correct.* 54-63: The contract creation logic has been updated to use the new `scheme` object. It's important to ensure that this logic is consistent with the updated contract implementation and that the contract creation process is tested thoroughly.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify consistency of scheme object structure and values in tests rg --type ts "scheme: AtomicSwap.Scheme"Length of output: 336
Script:
#!/bin/bash # Find the definition of AtomicSwap.Scheme in atomicSwap.ts rg --type ts "export type Scheme =" "packages/language/examples/src/atomicSwap.ts" # Check the usage of the scheme object in the test files rg --type ts "const scheme: AtomicSwap.Scheme" "packages/runtime/lifecycle/test/generic/payouts.e2e.spec.ts" rg --type ts "const scheme: AtomicSwap.Scheme" "packages/runtime/lifecycle/test/examples/swap.ada.token.e2e.spec.ts"Length of output: 413
Script:
#!/bin/bash # Retrieve the full definition of AtomicSwap.Scheme from atomicSwap.ts rg --type ts -A 10 "export type Scheme =" "packages/language/examples/src/atomicSwap.ts" # Retrieve the full scheme object declarations from the test files rg --type ts -A 10 "const scheme: AtomicSwap.Scheme" "packages/runtime/lifecycle/test/generic/payouts.e2e.spec.ts" rg --type ts -A 10 "const scheme: AtomicSwap.Scheme" "packages/runtime/lifecycle/test/examples/swap.ada.token.e2e.spec.ts"Length of output: 1325
Summary by CodeRabbit
New Features
Survey
andAtomicSwap
modules with improved functionality and user experience.Documentation
Refactor
Tests
Bug Fixes