Skip to content

Commit

Permalink
Merge branch 'saurabh-token' into roshan-token
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronnieraj37 committed Nov 20, 2024
2 parents 5a9eb7f + afb1e6b commit c88da45
Show file tree
Hide file tree
Showing 12 changed files with 498 additions and 766 deletions.
2 changes: 0 additions & 2 deletions cairo/.gitignore

This file was deleted.

20 changes: 0 additions & 20 deletions cairo/Scarb.lock

This file was deleted.

19 changes: 0 additions & 19 deletions cairo/Scarb.toml

This file was deleted.

155 changes: 0 additions & 155 deletions cairo/src/HashToken.cairo

This file was deleted.

25 changes: 0 additions & 25 deletions cairo/src/interfaces/IHashToken.cairo

This file was deleted.

4 changes: 0 additions & 4 deletions cairo/src/lib.cairo

This file was deleted.

92 changes: 58 additions & 34 deletions solidity/src/AccessRegistry/AccessRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,49 +55,46 @@ abstract contract AccessRegistry is Context, SuperAdmin2Step, FallbackAdmin2Step
signers[_superAdmin] = true;
}

function addSigner(address _newSigner) external virtual onlySuperAdmin notZeroAddress(_newSigner) {
// require(!isSigner(_newSigner), "ACL::Already A Signer");
if (isSigner(_newSigner)) revert AlreadySigner();
signers[_newSigner] = true;
function addSigner(address _newSigner) external virtual onlySuperAdmin {
_addSigner(_newSigner);
assembly {
// Emit SignerAdded event
log2(
0x00, // start of data
0x00, // length of data (0 as no data needed)
0x47d1c22a25bb3a5d4e481b9b1e6944c2eade3181a0a20b495ed61d35b5323f24, // keccak256("SignerAdded(address)")
_newSigner // indexed parameter
)

sstore(_TOTAL_SIGNER_SLOT, add(sload(_TOTAL_SIGNER_SLOT), 1))
}
}

function removeSigner(address _signer) external virtual onlySuperAdmin {
if (!isSigner(_signer)) revert NonExistingSigner();
if (_signer == _msgSender()) revert SuperAdminCannotRemoved();
if (totalSigners() == 1) revert WalletCannotBeSignerLess();
// require(totalSigners() > 1, "ACL::wallet cannot be ownerless");
signers[_signer] = false;
function addBatchSigners(address[] calldata newSigners) external virtual onlySuperAdmin {
uint256 totalSigners = newSigners.length;

for (uint256 i = 0; i < totalSigners; i++) {
_addSigner(newSigners[i]);
}
assembly {
// Emit SignerAdded event
log2(
0x00, // start of data
0x00, // length of data (0 as no data needed)
0x3525e22824a8a7df2c9a6029941c824cf95b6447f1e13d5128fd3826d35afe8b, // keccak256("SignerRemoved(address)")
_signer // indexed parameter
)
sstore(_TOTAL_SIGNER_SLOT, add(sload(_TOTAL_SIGNER_SLOT), totalSigners))
}
}

function removeBatchSigners(address[] calldata exisitingSigner) external virtual onlySuperAdmin {
uint256 totalSigners = exisitingSigner.length;

for (uint256 i = 0; i < totalSigners; i++) {
_removeSigner(exisitingSigner[i]);
}
assembly {
sstore(_TOTAL_SIGNER_SLOT, sub(sload(_TOTAL_SIGNER_SLOT), totalSigners))
}
}

function removeSigner(address _signer) external virtual onlySuperAdmin {
_removeSigner(_signer);
assembly {
sstore(_TOTAL_SIGNER_SLOT, sub(sload(_TOTAL_SIGNER_SLOT), 1))
}
}

function renounceSignership(address _newSigner) public virtual onlySigner notZeroAddress(_newSigner) {
// require(_msgSender() != superAdmin(), "ACL:: Admin is restricted");
if (_msgSender() == superAdmin()) revert SuperAdminIsRestricted();
if (isSigner(_newSigner)) revert AlreadySigner();

// require(!isSigner(_newSigner), "ACL::New Address is Existing owner");

signers[_msgSender()] = false;
signers[_newSigner] = true;
assembly {
Expand All @@ -113,12 +110,7 @@ abstract contract AccessRegistry is Context, SuperAdmin2Step, FallbackAdmin2Step
}

function isSigner(address _check) public view returns (bool result) {
assembly {
mstore(0x00, _check)
mstore(0x20, signers.slot)
let signersKey := keccak256(0x00, 0x40)
result := sload(signersKey)
}
return signers[_check];
}

modifier onlySigner() {
Expand All @@ -133,4 +125,36 @@ abstract contract AccessRegistry is Context, SuperAdmin2Step, FallbackAdmin2Step
signers[_newSuperOwner] = true;
super._setSuperAdmin(_newSuperOwner);
}

function _addSigner(address signer) internal {
if (signer == address(0)) revert CallerZeroAddress();
if (isSigner(signer)) revert AlreadySigner();
signers[signer] = true;
assembly {
// Emit SignerAdded event
log2(
0x00, // start of data
0x00, // length of data (0 as no data needed)
0x47d1c22a25bb3a5d4e481b9b1e6944c2eade3181a0a20b495ed61d35b5323f24, // keccak256("SignerAdded(address)")
signer // indexed parameter
)
}
}

function _removeSigner(address _signer) internal {
if (_signer == address(0)) revert CallerZeroAddress();
if (!isSigner(_signer)) revert NonExistingSigner();
if (_signer == superAdmin()) revert SuperAdminCannotRemoved();
if (totalSigners() == 1) revert WalletCannotBeSignerLess();
signers[_signer] = false;
assembly {
// Emit SignerAdded event
log2(
0x00, // start of data
0x00, // length of data (0 as no data needed)
0x3525e22824a8a7df2c9a6029941c824cf95b6447f1e13d5128fd3826d35afe8b, // keccak256("SignerRemoved(address)")
_signer // indexed parameter
)
}
}
}
Loading

0 comments on commit c88da45

Please sign in to comment.