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

Atomic Bridge: Add get_bridge_transfer_details view function and fix duplicate create_time_lock calls #85

Merged
merged 4 commits into from
Oct 16, 2024

Conversation

andygolay
Copy link

@andygolay andygolay commented Oct 15, 2024

Description

See #83 , opened this due to issues working with the branch after merge to movement was reverted.

  • Add get_bridge_transfers_initiator and get_bridge_transfers_counterparty view functions into atomic_bridge_store module with corresponding Move unit tests. All tests pass with movement move test
  • Fix a bug where create_time_lock was called twice, resulting in time locks farther into the future than expected.

Type of Change

  • New feature
  • Bug fix
  • Breaking change
  • Performance improvement
  • Refactoring
  • Dependency update
  • Documentation update
  • [ x] Tests

Which Components or Systems Does This Change Impact?

  • Validator Node
  • Full Node (API, Indexer, etc.)
  • Move/Aptos Virtual Machine
  • Aptos Framework
  • Aptos CLI/SDK
  • Developer Infrastructure
  • Other (specify)

How Has This Been Tested?

In aptos-move/framework/aptos-framework/sources run movement move test or aptos move test.

Key Areas to Review

I think this works better as two separate functions because of the way it aligns with the BridgeContract trait in our Rust code. However, it could be possible to combine them into one function if someone wants to do that. For now this seems like a good solution to being able to fetch details without relying on event monitoring.


*details_ref
}

Copy link

@andyjsbell andyjsbell Oct 15, 2024

Choose a reason for hiding this comment

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

Would this be clearer? Would need documentation around this I think.

#[view]
    public fun get_bridge_transfer_details_initiator(
        bridge_transfer_id: vector<u8>
    ): BridgeTransferDetails<address, EthereumAddress> acquires SmartTableWrapper {
        get_bridge_transfer_details(bridge_transfer_id)
    }

    #[view]
    public fun get_bridge_transfer_details_counterparty(
        bridge_transfer_id: vector<u8>
    ): BridgeTransferDetails<EthereumAddress, address> acquires SmartTableWrapper {
        get_bridge_transfer_details(bridge_transfer_id)
    }

    fun get_bridge_transfer_details<Initiator: store + copy, Recipient: store + copy>(bridge_transfer_id: vector<u8>
    ): BridgeTransferDetails<Initiator, Recipient> acquires SmartTableWrapper {
        let table = borrow_global<SmartTableWrapper<vector<u8>, BridgeTransferDetails<Initiator, Recipient>>>(@aptos_framework);

        let details_ref = smart_table::borrow(
            &table.inner,
            bridge_transfer_id
        );

        *details_ref
    }

Copy link
Author

@andygolay andygolay Oct 15, 2024

Choose a reason for hiding this comment

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

Updated, yep clearer, thanks.

Added doc comments to the two new view functions.

Copy link
Collaborator

@0xmovses 0xmovses left a comment

Choose a reason for hiding this comment

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

Look good, Danke.

Copy link

@andyjsbell andyjsbell left a comment

Choose a reason for hiding this comment

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

Thanks @andygolay

@andyjsbell andyjsbell merged commit 7a0e210 into movement Oct 16, 2024
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.

3 participants