Skip to content

Commit bc81b82

Browse files
committed
external getStakeholderIndex view
1 parent 8c28749 commit bc81b82

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

chain/script/DeployFactory.s.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,12 @@ library LibDeployment {
6464
return FacetCutInfo({ name: "IssuerFacet", selectors: selectors });
6565
}
6666
if (facetType == FacetType.Stakeholder) {
67-
bytes4[] memory selectors = new bytes4[](4);
67+
bytes4[] memory selectors = new bytes4[](5);
6868
selectors[0] = StakeholderFacet.createStakeholder.selector;
6969
selectors[1] = StakeholderFacet.getStakeholderPositions.selector;
7070
selectors[2] = StakeholderFacet.linkStakeholderAddress.selector;
7171
selectors[3] = StakeholderFacet.getStakeholderId.selector;
72+
selectors[4] = StakeholderFacet.getStakeholderIndex.selector;
7273
return FacetCutInfo({ name: "StakeholderFacet", selectors: selectors });
7374
}
7475
if (facetType == FacetType.StockClass) {

chain/src/facets/StakeholderFacet.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ contract StakeholderFacet {
7070
return stakeholder_id;
7171
}
7272

73+
/// @notice Get stakeholder idx for a stakeholder id
74+
function getStakeholderIndex(bytes16 stakeholder_id) external view returns (uint256) {
75+
return StorageLib.get().stakeholderIndex[stakeholder_id];
76+
}
77+
7378
/// @notice Get all positions for a stakeholder
7479
/// @dev INVESTOR_ROLE can only view their own positions, OPERATOR_ROLE and above can view any
7580
function getStakeholderPositions(bytes16 stakeholder_id) external view returns (StakeholderPositions memory) {

chain/src/interfaces/IStakeholderFacet.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ interface IStakeholderFacet {
4141
/// @param ensure_exists If true, will revert if the address is not linked to a stakeholder
4242
function getStakeholderId(address wallet_address, bool ensure_exists) external view returns (bytes16);
4343

44+
/// @notice Get stakeholder idx for a stakeholder id
45+
function getStakeholderIndex(bytes16 stakeholder_id) external view returns (uint256);
46+
4447
/// @notice Get all positions for a stakeholder
4548
/// @dev INVESTOR_ROLE can only view their own positions, OPERATOR_ROLE and above can view any
4649
/// @param stakeholder_id The stakeholder to get positions for

chain/test/StakeholderPositions.t.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ contract DiamondStakeholderPositionsTest is DiamondTestBase {
107107
// Ensure it exists
108108
id = sf.getStakeholderId(wallet, true);
109109
assertNotEq(id, bytes16(0));
110+
111+
// Ensure it returns a non-0 idx
112+
assertGt(sf.getStakeholderIndex(id), 0);
110113
}
111114

112115
function testGetStakeholderPositions() public {

0 commit comments

Comments
 (0)