Skip to content

Commit 9117732

Browse files
themariofranciajaime-iobermudezmanuel-campo-iobuildersManuIOBMiguelLZPF
authored
Sprint 3 (#96)
Signed-off-by: Mario Francia <mario@io.builders> Signed-off-by: jaime-iobermudez <jaime.bermudez@io.builders> Signed-off-by: Manuel Campo <manuel.campo@io.builders> Signed-off-by: Manu Fernandez <manuel@io.builders> Signed-off-by: Miguel_LZPF <miguel.carpena@io.builders> Co-authored-by: jaime-iobermudez <jaime.bermudez@io.builders> Co-authored-by: manuel-campo-iobuilders <139767014+manuel-campo-iobuilders@users.noreply.github.com> Co-authored-by: Manu Fernández <110894694+ManuIOB@users.noreply.github.com> Co-authored-by: Miguel_LZPF <miguel.carpena@io.builders>
1 parent 510efd1 commit 9117732

File tree

83 files changed

+6875
-227
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+6875
-227
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,5 @@ dist
133133
.pnp.*
134134

135135
package-lock.json
136+
137+
asset-tokenization-studio.iml

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ These variables are only required if you are integrating Hedera Wallet Connect f
114114
115115
REACT_APP_MIRROR_NODE="https://testnet.mirrornode.hedera.com/api/v1/"
116116
REACT_APP_RPC_NODE="https://testnet.hashio.io/api"
117-
REACT_APP_RPC_RESOLVER="0.0.3532144"
118-
REACT_APP_RPC_FACTORY="0.0.3532205"
117+
REACT_APP_RPC_RESOLVER="0.0.5038989"
118+
REACT_APP_RPC_FACTORY="0.0.5039041"
119119
120120
REACT_APP_PROJECT_ID="your_project_id_from_walletconnect"
121121
REACT_APP_DAPP_NAME="Asset Tokenization Studio"

contracts/contracts/layer_1/accessControl/AccessControlStorageWrapper.sol

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,26 @@ abstract contract AccessControlStorageWrapper is
290290
_remove(roleDataStorage, _roles[index], _account);
291291
}
292292
}
293+
for (uint256 index2 = 0; index2 < _roles.length; index2++) {
294+
if (_actives[index2]) {
295+
if (!_has(roleDataStorage, _roles[index2], _account))
296+
revert ApplyRoleContradiction(
297+
_roles,
298+
_actives,
299+
_roles[index2]
300+
);
301+
continue;
302+
} else {
303+
if (_has(roleDataStorage, _roles[index2], _account))
304+
revert ApplyRoleContradiction(
305+
_roles,
306+
_actives,
307+
_roles[index2]
308+
);
309+
continue;
310+
}
311+
}
312+
293313
success_ = true;
294314
}
295315

contracts/contracts/layer_1/constants/roles.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,3 +236,6 @@ bytes32 constant _SNAPSHOT_ROLE = 0x3fbb44760c0954eea3f6cb9f1f210568f5ae959dcbbe
236236

237237
// keccak256('security.token.standard.role.locker');
238238
bytes32 constant _LOCKER_ROLE = 0xd8aa8c6f92fe8ac3f3c0f88216e25f7c08b3a6c374b4452a04d200c29786ce88;
239+
240+
// keccak256('security.token.standard.role.bondManager');
241+
bytes32 constant _BOND_MANAGER_ROLE = 0x8e99f55d84328dd46dd7790df91f368b44ea448d246199c88b97896b3f83f65d;

contracts/contracts/layer_1/interfaces/accessControl/IAccessControlStorageWrapper.sol

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,4 +240,13 @@ interface IAccessControlStorageWrapper {
240240
uint256 rolesLength,
241241
uint256 activesLength
242242
);
243+
244+
/**
245+
* @dev Emitted when the there is a contradiction in the roles to apply, the same role must be granted and revoked
246+
*
247+
* @param roles This list of roles
248+
* @param actives grant or revoke roles
249+
* @param role the role for which there is a contradiction
250+
*/
251+
error ApplyRoleContradiction(bytes32[] roles, bool[] actives, bytes32 role);
243252
}

contracts/contracts/layer_2/bond/Bond.sol

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,10 @@ pragma solidity 0.8.18;
208208

209209
import {IBond} from '../interfaces/bond/IBond.sol';
210210
import {COUPON_CORPORATE_ACTION_TYPE} from '../constants/values.sol';
211-
import {_CORPORATE_ACTION_ROLE} from '../../layer_1/constants/roles.sol';
211+
import {
212+
_CORPORATE_ACTION_ROLE,
213+
_BOND_MANAGER_ROLE
214+
} from '../../layer_1/constants/roles.sol';
212215
import {BondStorageWrapper} from './BondStorageWrapper.sol';
213216
import {
214217
IStaticFunctionSelectors
@@ -270,6 +273,30 @@ abstract contract Bond is IBond, IStaticFunctionSelectors, BondStorageWrapper {
270273
);
271274
}
272275

276+
/**
277+
* @dev Updates the maturity date of the bond.
278+
* @param _newMaturityDate The new maturity date to be set.
279+
*/
280+
function updateMaturityDate(
281+
uint256 _newMaturityDate
282+
)
283+
external
284+
virtual
285+
override
286+
onlyUnpaused
287+
onlyRole(_BOND_MANAGER_ROLE)
288+
onlyAfterCurrentMaturityDate(_newMaturityDate)
289+
returns (bool success_)
290+
{
291+
emit MaturityDateUpdated(
292+
address(this),
293+
_newMaturityDate,
294+
_getMaturityDate()
295+
);
296+
success_ = _setMaturityDate(_newMaturityDate);
297+
return success_;
298+
}
299+
273300
function getCouponDetails()
274301
external
275302
view

contracts/contracts/layer_2/bond/BondStorageWrapper.sol

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,17 @@ abstract contract BondStorageWrapper is CorporateActionsStorageWrapperSecurity {
225225
bool initialized;
226226
}
227227

228+
/**
229+
* @dev Modifier to ensure that the function is called only after the current maturity date.
230+
* @param _maturityDate The maturity date to be checked against the current maturity date.
231+
* Reverts with `BondMaturityDateWrong` if the provided maturity date is less than or equal
232+
* to the current maturity date.
233+
*/
234+
modifier onlyAfterCurrentMaturityDate(uint256 _maturityDate) {
235+
if (_maturityDate <= _getMaturityDate()) revert BondMaturityDateWrong();
236+
_;
237+
}
238+
228239
function _storeBondDetails(
229240
IBond.BondDetailsData memory _bondDetails
230241
) internal returns (bool) {
@@ -294,6 +305,18 @@ abstract contract BondStorageWrapper is CorporateActionsStorageWrapperSecurity {
294305
);
295306
}
296307

308+
/**
309+
* @dev Internal function to set the maturity date of the bond.
310+
* @param _maturityDate The new maturity date to be set.
311+
* @return success_ True if the maturity date was set successfully.
312+
*/
313+
function _setMaturityDate(
314+
uint256 _maturityDate
315+
) internal returns (bool success_) {
316+
_bondStorage().bondDetail.maturityDate = _maturityDate;
317+
return true;
318+
}
319+
297320
function _getBondDetails()
298321
internal
299322
view
@@ -310,6 +333,10 @@ abstract contract BondStorageWrapper is CorporateActionsStorageWrapperSecurity {
310333
couponDetails_ = _bondStorage().couponDetail;
311334
}
312335

336+
function _getMaturityDate() internal view returns (uint256 maturityDate_) {
337+
return _bondStorage().bondDetail.maturityDate;
338+
}
339+
313340
function _getCoupon(
314341
uint256 _couponID
315342
)

contracts/contracts/layer_2/corporateActions/CorporateActionsStorageWrapperSecurity.sol

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ import {
222222
ICorporateActionsStorageWrapperSecurity
223223
} from '../interfaces/corporateActions/ICorporateActionsStorageWrapperSecurity.sol';
224224
import {IEquity} from '../interfaces/equity/IEquity.sol';
225+
import {IBond} from '../interfaces/bond/IBond.sol';
225226
import {
226227
ScheduledSnapshotsStorageWrapper
227228
} from '../scheduledSnapshots/ScheduledSnapshotsStorageWrapper.sol';
@@ -305,19 +306,19 @@ abstract contract CorporateActionsStorageWrapperSecurity is
305306
revert CouponCreationFailed();
306307
}
307308

308-
uint256 recordDate = abi.decode(_data, (uint256));
309+
IBond.Coupon memory newCoupon = abi.decode(_data, (IBond.Coupon));
309310

310-
_addScheduledSnapshot(recordDate, abi.encode(_actionId));
311+
_addScheduledSnapshot(newCoupon.recordDate, abi.encode(_actionId));
311312
}
312313

313314
function _onScheduledSnapshotTriggered(
314315
uint256 snapShotID,
315316
bytes memory data
316317
) internal virtual override {
317-
bytes32 actionId;
318-
if (data.length > 0) actionId = abi.decode(data, (bytes32));
319-
320-
_addSnapshotToAction(actionId, snapShotID);
318+
if (data.length > 0) {
319+
bytes32 actionId = abi.decode(data, (bytes32));
320+
_addSnapshotToAction(actionId, snapShotID);
321+
}
321322
}
322323

323324
function _addSnapshotToAction(

contracts/contracts/layer_2/interfaces/bond/IBond.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,10 @@ interface IBond {
248248
Coupon calldata _newCoupon
249249
) external returns (bool success_, uint256 couponID_);
250250

251+
function updateMaturityDate(
252+
uint256 _maturityDate
253+
) external returns (bool success_);
254+
251255
function getCouponDetails()
252256
external
253257
view

contracts/contracts/layer_2/interfaces/bond/IBondStorageWrapper.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,14 @@ interface IBondStorageWrapper {
216216
uint256 rate
217217
);
218218

219+
event MaturityDateUpdated(
220+
address indexed bondId,
221+
uint256 indexed maturityDate,
222+
uint256 indexed previousMaturityDate
223+
);
224+
219225
error CouponCreationFailed();
220226
error CouponFirstDateWrong();
221227
error CouponFrequencyWrong();
228+
error BondMaturityDateWrong();
222229
}

0 commit comments

Comments
 (0)