Skip to content

Commit 8c28749

Browse files
authored
Merge pull request #48 from Open-Captable-Protocol/kkolze/added-views
external issuer view
2 parents 7e89faa + f45b13f commit 8c28749

File tree

4 files changed

+41
-6
lines changed

4 files changed

+41
-6
lines changed

chain/script/DeployFactory.s.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ library LibDeployment {
5757
return FacetCutInfo({ name: "DiamondLoupeFacet", selectors: selectors });
5858
}
5959
if (facetType == FacetType.Issuer) {
60-
bytes4[] memory selectors = new bytes4[](2);
60+
bytes4[] memory selectors = new bytes4[](3);
6161
selectors[0] = IssuerFacet.initializeIssuer.selector;
6262
selectors[1] = IssuerFacet.adjustIssuerAuthorizedShares.selector;
63+
selectors[2] = IssuerFacet.issuer.selector;
6364
return FacetCutInfo({ name: "IssuerFacet", selectors: selectors });
6465
}
6566
if (facetType == FacetType.Stakeholder) {

chain/src/facets/IssuerFacet.sol

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@ import { Issuer } from "@libraries/Structs.sol";
77
import { TxHelper, TxType } from "@libraries/TxHelper.sol";
88
import { AccessControl } from "@libraries/AccessControl.sol";
99
import { console } from "forge-std/console.sol";
10+
import { IIssuerFacet } from "@interfaces/IIssuerFacet.sol";
1011

11-
contract IssuerFacet {
12-
error IssuerAlreadyInitialized();
13-
14-
event IssuerAuthorizedSharesAdjusted(uint256 newSharesAuthorized);
15-
12+
contract IssuerFacet is IIssuerFacet {
1613
/// @notice Initialize the issuer with initial shares authorized
1714
/// @dev Can only be called once by an admin during setup
1815
function initializeIssuer(bytes16 id, uint256 initial_shares_authorized) external {
@@ -30,6 +27,10 @@ contract IssuerFacet {
3027
ds.issuer = Issuer({ id: id, shares_issued: 0, shares_authorized: initial_shares_authorized });
3128
}
3229

30+
function issuer() external view returns (Issuer memory) {
31+
return StorageLib.get().issuer;
32+
}
33+
3334
/// @notice Adjust the total number of authorized shares for the issuer
3435
/// @dev Only DEFAULT_ADMIN_ROLE can adjust authorized shares
3536
function adjustIssuerAuthorizedShares(bytes16 id, uint256 newSharesAuthorized) external {

chain/src/interfaces/IIssuerFacet.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ interface IIssuerFacet {
1616
/// @param initial_shares_authorized Initial number of authorized shares
1717
function initializeIssuer(bytes16 id, uint256 initial_shares_authorized) external;
1818

19+
/// @notice Getter for the Issuer struct
20+
function issuer() external view returns (Issuer memory);
21+
1922
/// @notice Adjust the total number of authorized shares for the issuer
2023
/// @dev Only DEFAULT_ADMIN_ROLE can adjust authorized shares
2124
/// @param id The unique identifier for the tx

chain/test/Issuer.t.sol

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
3+
4+
import "./TestBase.sol";
5+
import {
6+
StockActivePosition,
7+
WarrantActivePosition,
8+
ConvertibleActivePosition,
9+
EquityCompensationActivePosition,
10+
StakeholderPositions,
11+
IssueStockParams,
12+
IssueConvertibleParams,
13+
IssueEquityCompensationParams,
14+
Issuer
15+
} from "@libraries/Structs.sol";
16+
import { IStockFacet } from "@interfaces/IStockFacet.sol";
17+
import { IConvertiblesFacet } from "@interfaces/IConvertiblesFacet.sol";
18+
import { IEquityCompensationFacet } from "@interfaces/IEquityCompensationFacet.sol";
19+
import {ICapTable} from "../src/interfaces/ICapTable.sol";
20+
21+
contract IssuerTest is DiamondTestBase {
22+
23+
function test_issuer() public {
24+
ICapTable ct = ICapTable(address(capTable));
25+
Issuer memory iss = ct.issuer();
26+
assertTrue(iss.id != bytes16(0));
27+
assertGt(iss.shares_authorized, 0);
28+
assertEq(iss.shares_issued, 0);
29+
}
30+
}

0 commit comments

Comments
 (0)