Skip to content

Commit

Permalink
Create LibReceiptCreator
Browse files Browse the repository at this point in the history
  • Loading branch information
ninokeldishvili committed Oct 31, 2024
1 parent 7211a0e commit df1dd15
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/lib/LibReceiptCreator.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: LicenseRef-DCL-1.0
// SPDX-FileCopyrightText: Copyright (c) 2020 thedavidmeister
pragma solidity =0.8.25;

import {ICloneableFactoryV2} from "rain.factory/interface/ICloneableFactoryV2.sol";
import {ReceiptFactoryTest} from "../abstract/ReceiptFactoryTest.sol";
import {Receipt} from "src/concrete/receipt/Receipt.sol";
import {TestReceipt} from "test/concrete/TestReceipt.sol";

library LibReceiptCreator {
/// Helper to create child receipt.
function createReceipt(
ICloneableFactoryV2 factory,
Receipt receiptImplementation,
address owner
) internal returns (TestReceipt) {
// Clone TestReceipt using the factory and initialize it with the owner
address clone = factory.clone(address(receiptImplementation), abi.encode(owner));
// Return the clone cast to TestReceipt type
return TestReceipt(clone);
}
}

0 comments on commit df1dd15

Please sign in to comment.