Skip to content

Feat/add ttl support#122

Open
thinktanktom wants to merge 2 commits intoOpenZeppelin:mainfrom
thinktanktom:feat/add-ttl-support
Open

Feat/add ttl support#122
thinktanktom wants to merge 2 commits intoOpenZeppelin:mainfrom
thinktanktom:feat/add-ttl-support

Conversation

@thinktanktom
Copy link
Copy Markdown

Description

This PR implements support for Extend Footprint TTL operations as requested in #47.

Changes

I've added TTL (Time To Live) extension support across multiple layers of the API:

Low-level Operation

  • Added Operations::extend_footprint_ttl() method in operation.rs
  • Creates the XDR operation for extending ledger entry lifetimes
  • Added comprehensive tests for the operation

High-level APIs

  • Added Contract::extend_ttl() method in contract.rs

    • Provides an easy way to extend deployed contract TTLs
    • Handles transaction building, simulation, signing, and submission automatically
  • Added TransactionBuilder::extend_footprint_ttl() convenience method in transaction.rs

    • Enables fluent API for building TTL extension transactions

Documentation & Examples

  • Added example file examples/extend_ttl.rs demonstrating usage
  • Updated README.md with TTL extension documentation
  • Added inline documentation for all new methods

Testing

All tests pass:

cargo test --workspace

New tests added:

  • test_extend_footprint_ttl() - Tests operation creation
  • test_extend_footprint_ttl_different_values() - Tests edge cases

Usage Example

// Deploy a contract
let contract = Contract::new("path/to/contract.wasm", None)?;
let deployed = contract.deploy(&env, &mut account, None).await?;

// Extend TTL to prevent archival
deployed.extend_ttl(2_000_000, &env, &mut account).await?;

Checklist

  • Added low-level operation support
  • Added high-level Contract API
  • Added TransactionBuilder convenience method
  • Added tests
  • Added example
  • Updated README
  • All tests pass
  • Code formatted with cargo fmt
  • No clippy warnings

Closes #47

- Extract simulation logic into standalone simulate_transaction() function
- Refactor simulate_and_build() to use the new function internally
- Add test for simulate_transaction()
- Update lib.rs to export simulate_transaction()
- Maintain backward compatibility with existing simulate_and_build() API

Closes OpenZeppelin#48
- Add Operations::extend_footprint_ttl() for creating TTL extension operations
- Add Contract::extend_ttl() for easy contract TTL management
- Add TransactionBuilder::extend_footprint_ttl() convenience method
- Add example demonstrating TTL extension usage
- Update README with TTL extension documentation
- Add comprehensive tests for TTL operations

Fixes OpenZeppelin#47
Copy link
Copy Markdown
Member

@MCarlomagno MCarlomagno left a comment

Choose a reason for hiding this comment

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

LGTM

@merkle-maren
Copy link
Copy Markdown

Useful feature and approved 2 months ago. Who can merge it?

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.

Add support to TTL operations

3 participants