Skip to content

Commit 744ea97

Browse files
add receipt getter to erc20 vault
1 parent 98fa04e commit 744ea97

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/concrete/vault/ERC20PriceOracleReceiptVault.sol

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,14 @@ contract ERC20PriceOracleReceiptVault is ReceiptVault {
113113
return ICLONEABLE_V2_SUCCESS;
114114
}
115115

116+
/// Not strictly necessary as the receipt address is emitted during
117+
/// initialization but this is a convenience getter for the receipt address.
118+
/// It isn't in the `ReceiptVault` implementation because we need to keep the
119+
/// base contract code size down.
120+
function receipt() external view returns (address) {
121+
return address(sReceipt);
122+
}
123+
116124
/// The ID is the current oracle price always, even if this ID has already
117125
/// been issued for some other receipt, it will simply result in multiple
118126
/// holders of receipts with amounts of the same ID.

test/src/concrete/vault/ERC20PriceOracleReceiptVault.construct.t.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ contract ERC20PriceOracleReceiptVaultConstructionTest is ERC20PriceOracleReceipt
3535
address msgSender = address(0);
3636
IPriceOracleV2 priceOracle = IPriceOracleV2(payable(0));
3737
address assetAddress = address(0);
38+
address receiptAddress = address(0);
3839
string memory name = "";
3940
string memory symbol = "";
4041
bool eventFound = false; // Flag to indicate whether the event log was found
@@ -53,6 +54,7 @@ contract ERC20PriceOracleReceiptVaultConstructionTest is ERC20PriceOracleReceipt
5354
name = config.receiptVaultConfig.vaultConfig.name;
5455
symbol = config.receiptVaultConfig.vaultConfig.symbol;
5556
assetAddress = address(config.receiptVaultConfig.vaultConfig.asset);
57+
receiptAddress = address(config.receiptVaultConfig.receipt);
5658
eventFound = true; // Set the flag to true since event log was found
5759
break;
5860
}
@@ -65,6 +67,7 @@ contract ERC20PriceOracleReceiptVaultConstructionTest is ERC20PriceOracleReceipt
6567
assert(address(vault) != address(0));
6668
assertEq(keccak256(bytes(vault.name())), keccak256(bytes(name)));
6769
assertEq(keccak256(bytes(vault.symbol())), keccak256(bytes(symbol)));
70+
assertEq(receiptAddress, vault.receipt());
6871
}
6972

7073
/// Test creating several different vaults

0 commit comments

Comments
 (0)