Skip to content

Commit

Permalink
BT-129 - IRS ERC3643 implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihalis authored and Mihalis committed Dec 12, 2024
1 parent e2758cc commit f4d8168
Showing 1 changed file with 28 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ error ContractIsReadOnly();
error MaxIRByIRSReached(uint256 _max);


contract IdentityRegistryStorage is IERC3643IdentityRegistryStorage, AgentRoleUpgradeable, IRSStorage, IERC165 {
contract GlobalIdentityRegistryStorage is IERC3643IdentityRegistryStorage, AgentRoleUpgradeable, IRSStorage, IERC165 {
IIdFactory internal _iidFactory;
function init(_identityFactoryAddress) external initializer {
require(_identityFactoryAddress != address(0), ZeroAddress());
Expand All @@ -99,45 +99,49 @@ contract IdentityRegistryStorage is IERC3643IdentityRegistryStorage, AgentRoleUp
/**
* @dev See {IIdentityRegistryStorage-addIdentityToStorage}.
*/
function addIdentityToStorage() external view override onlyAgent {
revert ContractIsReadOnly();
function addIdentityToStorage(
address _userAddress,
IIdentity _identity,
uint16 _country

Check failure on line 105 in contracts/registry/implementation/GlobalIdentityRegistryStorageERC3643.sol

View workflow job for this annotation

GitHub Actions / Lint sources (18.x)

Variable "_country" is unused
) external view override onlyAgent {
bytes32 hash = keccak256(

Check failure on line 107 in contracts/registry/implementation/GlobalIdentityRegistryStorageERC3643.sol

View workflow job for this annotation

GitHub Actions / Lint sources (18.x)

Variable "hash" is unused
abi.encode(
"Authorize ONCHAINID wallet addition",
_identity,
_userAddress
)
);
}

/**
* @dev See {IIdentityRegistryStorage-modifyStoredIdentity}.
*/
function modifyStoredIdentity() external view override onlyAgent {

Check failure on line 119 in contracts/registry/implementation/GlobalIdentityRegistryStorageERC3643.sol

View workflow job for this annotation

GitHub Actions / Lint sources (18.x)

Code contains empty blocks
revert ContractIsReadOnly();

}

/**
* @dev See {IIdentityRegistryStorage-modifyStoredInvestorCountry}.
*/
function modifyStoredInvestorCountry() external view override onlyAgent {

Check failure on line 125 in contracts/registry/implementation/GlobalIdentityRegistryStorageERC3643.sol

View workflow job for this annotation

GitHub Actions / Lint sources (18.x)

Code contains empty blocks
revert ContractIsReadOnly();

}

/**
* @dev See {IIdentityRegistryStorage-removeIdentityFromStorage}.
*/
function removeIdentityFromStorage() external view override onlyAgent {
revert ContractIsReadOnly();
function removeIdentityFromStorage(address _userAddress) external view override onlyAgent {

Check failure on line 131 in contracts/registry/implementation/GlobalIdentityRegistryStorageERC3643.sol

View workflow job for this annotation

GitHub Actions / Lint sources (18.x)

Code contains empty blocks
// verify message sender
}

/**
* @dev See {IIdentityRegistryStorage-bindIdentityRegistry}.
*/
function bindIdentityRegistry() external view override {

Check failure on line 138 in contracts/registry/implementation/GlobalIdentityRegistryStorageERC3643.sol

View workflow job for this annotation

GitHub Actions / Lint sources (18.x)

Code contains empty blocks
revert ContractIsReadOnly();
}

/**
* @dev See {IIdentityRegistryStorage-unbindIdentityRegistry}.
*/
function unbindIdentityRegistry() external view override {

Check failure on line 144 in contracts/registry/implementation/GlobalIdentityRegistryStorageERC3643.sol

View workflow job for this annotation

GitHub Actions / Lint sources (18.x)

Code contains empty blocks
revert ContractIsReadOnly();
}

/**
Expand All @@ -151,14 +155,25 @@ contract IdentityRegistryStorage is IERC3643IdentityRegistryStorage, AgentRoleUp
* @dev See {IIdentityRegistryStorage-storedIdentity}.
*/
function storedIdentity(address _userAddress) external view override returns (IIdentity) {
return IIdentity(_iidFactory.getIdentity(_userAddress));
if (_identities[_userAddress] != address(0)) {
return _identities[_userAddress].identityContract;
}
address identity = _iidFactory.getIdentity(_userAddress);
if (identity != address(0)) {
_identities[_userAddress].identityContract = IIdentity(identity);
return _identities[_userAddress].identityContract;
}
return address(0);
}

/**
* @dev See {IIdentityRegistryStorage-storedInvestorCountry}.
*/
function storedInvestorCountry(address _userAddress) external view override returns (uint16) {
return _identities[_userAddress].investorCountry;
if(_identities[_userAddress].investorCountry != 0) {
return _identities[_userAddress].investorCountry;
}
return 42;
}

/**
Expand Down

0 comments on commit f4d8168

Please sign in to comment.