Skip to content

Conversation

@mvadari
Copy link
Collaborator

@mvadari mvadari commented Mar 11, 2025

High Level Overview of Change

Adds xrpl-py support for Smart Escrows.

Also reorganizes the Escrow integration tests into one file.

Context of Change

XRPLF/XRPL-Standards#270

Type of Change

  • New feature (non-breaking change which adds functionality)

Did you update CHANGELOG.md?

  • Yes
  • No, this change does not impact library users

Test Plan

Added some basic tests

Integration tests expected to fail right now, since this is a new feature.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 11, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch smart-escrows

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mvadari mvadari requested review from ckeshava, Copilot and khancode July 7, 2025 13:41
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds Smart Escrows support to xrpl-py by introducing new fields in escrow transactions, updating serialization definitions, extending fee logic, and reorganizing tests.

  • Introduces finish_function and data in EscrowCreate, and computation_allowance in EscrowFinish
  • Updates binary codec definitions for new fields and WASM-related error codes
  • Extends async fee calculation to include gas pricing and finish function costs
  • Reorganizes escrow integration tests into a consolidated file and updates wallet faucet logic

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
xrpl/models/transactions/escrow_create.py Add finish_function & data fields and validation logic
xrpl/models/transactions/escrow_finish.py Add computation_allowance field
xrpl/core/binarycodec/definitions/definitions.json Register new serialization definitions & WASM errors
xrpl/asyncio/wallet/wallet_generation.py Update faucet URLs, map new network, add request timeout
xrpl/asyncio/transaction/main.py Incorporate gas price and finish_function into fee calc
tests/unit/models/transactions/test_escrow_create.py Add unit tests for new finish_function logic
tests/unit/asyn/wallet/test_wallet.py Update unit tests for new faucet mappings
tests/integration/transactions/test_escrow.py Consolidate escrow integration tests
tests/integration/it_utils.py Add wait parameter to ledger acceptance helpers
pyproject.toml Bump version to beta
Comments suppressed due to low confidence (2)

tests/unit/models/transactions/test_escrow_create.py:8

  • Add unit tests for the new data field in EscrowCreate, covering both serialization and validation scenarios when data is provided or omitted.
    def test_all_fields_valid(self):

xrpl/asyncio/transaction/main.py:610

  • ServerState is not imported in this module, causing a NameError. Add from xrpl.models.requests import ServerState (or the correct import) at the top.
    server_state = await client._request_impl(ServerState())


finish_function: Optional[str] = None

data: Optional[str] = None
Copy link

Copilot AI Jul 7, 2025

Choose a reason for hiding this comment

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

The new data field lacks a corresponding entry in definitions.json, so it won't be serialized. Add a "Data" definition under the escrow fields section with the appropriate isSerialized, nth, and type settings.

Copilot uses AI. Check for mistakes.
if usage_context is not None:
json_body["usageContext"] = usage_context
response = await http_client.post(url=url, json=json_body)
response = await http_client.post(url=url, json=json_body, timeout=10)
Copy link

Copilot AI Jul 7, 2025

Choose a reason for hiding this comment

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

Hard-coding timeout=10 duplicates the existing _TIMEOUT_SECONDS constant. Use timeout=_TIMEOUT_SECONDS to keep timeout behavior consistent.

Suggested change
response = await http_client.post(url=url, json=json_body, timeout=10)
response = await http_client.post(url=url, json=json_body, timeout=_TIMEOUT_SECONDS)

Copilot uses AI. Check for mistakes.
if transaction.transaction_type == TransactionType.ESCROW_CREATE:
escrow_create = cast(EscrowCreate, transaction)
if escrow_create.finish_function is not None:
base_fee += 1000
Copy link

Copilot AI Jul 7, 2025

Choose a reason for hiding this comment

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

[nitpick] The 1000 finish-function surcharge is a magic number. Extract it into a named constant (e.g., FINISH_FUNCTION_FEE) and document its origin.

Suggested change
base_fee += 1000
base_fee += FINISH_FUNCTION_FEE

Copilot uses AI. Check for mistakes.
"""Credentials associated with sender of this transaction. The credentials included
must not be expired."""

computation_allowance: Optional[int] = None
Copy link

Copilot AI Jul 7, 2025

Choose a reason for hiding this comment

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

[nitpick] Add validation in _get_errors to ensure that computation_allowance is only set when a finish_function is provided, otherwise reject or warn.

Copilot uses AI. Check for mistakes.
@mvadari mvadari removed request for ckeshava and khancode July 7, 2025 14:59
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.

2 participants