Skip to content

Commit

Permalink
Merge pull request #213 from gildlab/2025-01-05-receipt
Browse files Browse the repository at this point in the history
add receipt getter to erc20 vault
  • Loading branch information
thedavidmeister authored Jan 5, 2025
2 parents 98fa04e + 744ea97 commit 50dce8a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/concrete/vault/ERC20PriceOracleReceiptVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ contract ERC20PriceOracleReceiptVault is ReceiptVault {
return ICLONEABLE_V2_SUCCESS;
}

/// Not strictly necessary as the receipt address is emitted during
/// initialization but this is a convenience getter for the receipt address.
/// It isn't in the `ReceiptVault` implementation because we need to keep the
/// base contract code size down.
function receipt() external view returns (address) {
return address(sReceipt);
}

/// The ID is the current oracle price always, even if this ID has already
/// been issued for some other receipt, it will simply result in multiple
/// holders of receipts with amounts of the same ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ contract ERC20PriceOracleReceiptVaultConstructionTest is ERC20PriceOracleReceipt
address msgSender = address(0);
IPriceOracleV2 priceOracle = IPriceOracleV2(payable(0));
address assetAddress = address(0);
address receiptAddress = address(0);
string memory name = "";
string memory symbol = "";
bool eventFound = false; // Flag to indicate whether the event log was found
Expand All @@ -53,6 +54,7 @@ contract ERC20PriceOracleReceiptVaultConstructionTest is ERC20PriceOracleReceipt
name = config.receiptVaultConfig.vaultConfig.name;
symbol = config.receiptVaultConfig.vaultConfig.symbol;
assetAddress = address(config.receiptVaultConfig.vaultConfig.asset);
receiptAddress = address(config.receiptVaultConfig.receipt);
eventFound = true; // Set the flag to true since event log was found
break;
}
Expand All @@ -65,6 +67,7 @@ contract ERC20PriceOracleReceiptVaultConstructionTest is ERC20PriceOracleReceipt
assert(address(vault) != address(0));
assertEq(keccak256(bytes(vault.name())), keccak256(bytes(name)));
assertEq(keccak256(bytes(vault.symbol())), keccak256(bytes(symbol)));
assertEq(receiptAddress, vault.receipt());
}

/// Test creating several different vaults
Expand Down

0 comments on commit 50dce8a

Please sign in to comment.