Skip to content

Fix sto receipts#1826

Merged
Neopallium merged 24 commits intodevelopfrom
fix_sto_receipts
Jun 3, 2025
Merged

Fix sto receipts#1826
Neopallium merged 24 commits intodevelopfrom
fix_sto_receipts

Conversation

@Neopallium
Copy link
Copy Markdown
Contributor

@Neopallium Neopallium commented May 23, 2025

changelog

new features

  • Fix STO support for offchain receipts for funding an investment in the STO.
  • Allow an STO to enable offchain funding.

modified external API

  • Change extrinsic Sto.invest to use support both onchain and offchain funding methods.

new external API

  • Add extrinsic Sto.enable_offchain_funding to enable support for offchain funding receipts.

modified events

  • Added missing AssetId value in Sto events: FundraiserCreated, FundraiserFrozen, FundraiserUnfrozen, FundraiserWindowModified, and FundraiserClosed.
  • Changed Sto event Invested. Moved the "offering token" to the second value to have the same ordering as the other events. Changed "raise token" type to FundingAsset enum to support both onchain and offchain funding.

new events

  • Added Sto event FundraiserOffchainFundingEnabled.

@Neopallium Neopallium changed the title Fix sto receipts [WIP] Fix sto receipts May 23, 2025
@Neopallium Neopallium changed the title [WIP] Fix sto receipts Fix sto receipts May 28, 2025
Copy link
Copy Markdown
Contributor

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

This PR disables the legacy offchain receipt support in Sto::invest, introduces new offchain receipt types and validation, and adds explicit extrinsics and weights for on-chain and off-chain funding.

  • Define new FundraiserReceipt and FundraiserReceiptDetails types in primitives.
  • Introduce Sto::enable_offchain_funding, split invest weights into invest_onchain/invest_offchain, and wire up receipt validation in the settlement pallet.
  • Update benchmarks, runtime tests, and integration tests to exercise on-chain and off-chain investment flows.

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
primitives/src/sto.rs Add new receipt ID type and offchain receipt structs.
primitives/src/lib.rs Register the new sto module in primitives.
pallets/weights/src/pallet_sto.rs Split and add weight functions for on-chain/off-chain funding.
pallets/sto/src/benchmarking.rs Add benchmarks for invest_onchain, invest_offchain, and enable_offchain_funding.
pallets/settlement/src/lib.rs Refactor receipt validation, add ensure_valid_receipt and mark_receipt_as_used.
pallets/settlement/src/benchmarking.rs Update receipt signing in settlement benchmarks.
pallets/runtime/tests/src/sto_test.rs Update unit tests to use FundingMethod::OnChain.
integration/tests/sto.rs New end-to-end integration tests for on-chain and off-chain STO funding.
integration/tests/settlements.rs Remove duplicate asset helper, bump test mint amounts.
integration/src/lib.rs Add helper to extract FundraiserId from events.
integration/src/asset_helper.rs Extract shared AssetHelper into a standalone module.
integration/Cargo.toml Add scale codec dependency for off-chain receipt encoding.
Comments suppressed due to low confidence (1)

pallets/settlement/src/lib.rs:2875

  • There are no unit tests covering the new ensure_valid_receipt or mark_receipt_as_used functions. Consider adding tests for valid, duplicate, and unauthorized receipt scenarios to ensure the logic behaves as expected.
pub fn mark_receipt_as_used(

@Neopallium
Copy link
Copy Markdown
Contributor Author

We are going to allow breaking the STO API, so the check_*_api failures will be ignored.

@Neopallium Neopallium merged commit eb34b17 into develop Jun 3, 2025
17 checks passed
@Neopallium Neopallium deleted the fix_sto_receipts branch June 3, 2025 19:42
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