Skip to content

Feat/delivery contract initialization - #40

Merged
Tybravo merged 2 commits into
SwiftChainn:mainfrom
BigJohn-dev:feat/delivery-contract-initialization
Apr 25, 2026
Merged

Feat/delivery contract initialization#40
Tybravo merged 2 commits into
SwiftChainn:mainfrom
BigJohn-dev:feat/delivery-contract-initialization

Conversation

@BigJohn-dev

Copy link
Copy Markdown
Contributor

Closes #19

Description

This PR implements the unified init function for the Delivery Contract, establishing the essential cross-contract link to the Escrow contract upon instantiation. It refactors the previous fragmented approach by replacing init_admin and set_escrow_contract with a single, atomic initialization path.

Summary of Work Done

  • Implemented init(env: Env, admin: Address, escrow_contract: Address) to store both administrative and escrow contract addresses dynamically inside instance storage.
  • Enforced an AlreadyInitialized panic to guarantee the contract cannot be re-initialized.
  • Successfully seeded the global delivery_counter variable to 0 inside persistent storage.
  • Added logic to emit the DeliveryContractInitialized event payload securely on successful resolution.
  • Refactored test.rs mock suite: Simplified legacy helper functions by registering the MockEscrow instantly inside setup_test.
  • Delivered two new comprehensive unit tests ensuring validation of the event payload (test_init_state_and_event) and double-invocation handling (test_double_init).

Cross-Contract Dependencies Introduced

No new crate dependencies were introduced; however, the logic solidifies the architectural boundary that a Delivery Contract now inherently depends on a valid Escrow Address during the bootstrap phase rather than at runtime lazily.

Test

All unit tests have been strictly verified to pass locally matching the expected acceptance criteria.

@drips-wave

drips-wave Bot commented Apr 25, 2026

Copy link
Copy Markdown

@BigJohn-dev Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Tybravo
Tybravo merged commit 3541709 into SwiftChainn:main Apr 25, 2026
1 check failed
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.

Smart Contract: Initialize Delivery Contract and Link to Escrow

2 participants