mirror of
https://github.com/vacp2p/linea-besu.git
synced 2026-01-09 21:17:54 -05:00
Onchain contracts upgrade to solidity 0.6, make parameter names in contracts more consistent (#1354)
* upgrade to solidity 0.6 * make parameter names in contracts more consistent Signed-off-by: Stefan Pingel <stefan.pingel@consensys.net>
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -102,7 +102,7 @@ public class OnChainPrivacyGroupManagementInterface extends Contract {
|
||||
super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider);
|
||||
}
|
||||
|
||||
public RemoteFunctionCall<TransactionReceipt> addParticipants(List<byte[]> participants) {
|
||||
public RemoteFunctionCall<TransactionReceipt> addParticipants(List<byte[]> publicEnclaveKeys) {
|
||||
final Function function =
|
||||
new Function(
|
||||
FUNC_ADDPARTICIPANTS,
|
||||
@@ -110,7 +110,7 @@ public class OnChainPrivacyGroupManagementInterface extends Contract {
|
||||
new org.web3j.abi.datatypes.DynamicArray<org.web3j.abi.datatypes.generated.Bytes32>(
|
||||
org.web3j.abi.datatypes.generated.Bytes32.class,
|
||||
org.web3j.abi.Utils.typeMap(
|
||||
participants, org.web3j.abi.datatypes.generated.Bytes32.class))),
|
||||
publicEnclaveKeys, org.web3j.abi.datatypes.generated.Bytes32.class))),
|
||||
Collections.<TypeReference<?>>emptyList());
|
||||
return executeRemoteCallTransaction(function);
|
||||
}
|
||||
@@ -164,11 +164,11 @@ public class OnChainPrivacyGroupManagementInterface extends Contract {
|
||||
return executeRemoteCallTransaction(function);
|
||||
}
|
||||
|
||||
public RemoteFunctionCall<TransactionReceipt> removeParticipant(byte[] account) {
|
||||
public RemoteFunctionCall<TransactionReceipt> removeParticipant(byte[] participant) {
|
||||
final Function function =
|
||||
new Function(
|
||||
FUNC_REMOVEPARTICIPANT,
|
||||
Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Bytes32(account)),
|
||||
Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Bytes32(participant)),
|
||||
Collections.<TypeReference<?>>emptyList());
|
||||
return executeRemoteCallTransaction(function);
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,4 +1,18 @@
|
||||
pragma solidity ^0.5.9;
|
||||
/*
|
||||
* Copyright ConsenSys AG.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
pragma solidity ^0.6.0;
|
||||
import "./OnChainPrivacyGroupManagementInterface.sol";
|
||||
|
||||
contract DefaultOnChainPrivacyGroupManagementContract is OnChainPrivacyGroupManagementInterface {
|
||||
@@ -9,27 +23,27 @@ contract DefaultOnChainPrivacyGroupManagementContract is OnChainPrivacyGroupMana
|
||||
bytes32[] private distributionList;
|
||||
mapping(bytes32 => uint256) private distributionIndexOf;
|
||||
|
||||
function getVersion() external view returns (bytes32) {
|
||||
function getVersion() external view override returns (bytes32) {
|
||||
return _version;
|
||||
}
|
||||
|
||||
function canExecute() external view returns (bool) {
|
||||
function canExecute() external view override returns (bool) {
|
||||
return _canExecute;
|
||||
}
|
||||
|
||||
function lock() public {
|
||||
function lock() public override {
|
||||
require(_canExecute);
|
||||
require(tx.origin == _owner, "Origin not the owner.");
|
||||
_canExecute = false;
|
||||
}
|
||||
|
||||
function unlock() public {
|
||||
function unlock() public override {
|
||||
require(!_canExecute);
|
||||
require(tx.origin == _owner, "Origin not the owner.");
|
||||
_canExecute = true;
|
||||
}
|
||||
|
||||
function addParticipants(bytes32[] memory _publicEnclaveKeys) public returns (bool) {
|
||||
function addParticipants(bytes32[] memory _publicEnclaveKeys) public override returns (bool) {
|
||||
require(!_canExecute);
|
||||
if (_owner == address(0x0)) {
|
||||
// The account creating this group is set to be the owner
|
||||
@@ -42,19 +56,19 @@ contract DefaultOnChainPrivacyGroupManagementContract is OnChainPrivacyGroupMana
|
||||
return result;
|
||||
}
|
||||
|
||||
function removeParticipant(bytes32 _member) public returns (bool) {
|
||||
function removeParticipant(bytes32 _participant) public override returns (bool) {
|
||||
require(_canExecute);
|
||||
require(tx.origin == _owner, "Origin not the owner.");
|
||||
bool result = removeInternal(_member);
|
||||
bool result = removeInternal(_participant);
|
||||
updateVersion();
|
||||
return result;
|
||||
}
|
||||
|
||||
function getParticipants() public view returns (bytes32[] memory) {
|
||||
function getParticipants() public view override returns (bytes32[] memory) {
|
||||
return distributionList;
|
||||
}
|
||||
|
||||
function canUpgrade() external returns (bool) {
|
||||
function canUpgrade() external override returns (bool) {
|
||||
return tx.origin == _owner;
|
||||
}
|
||||
|
||||
@@ -82,14 +96,15 @@ contract DefaultOnChainPrivacyGroupManagementContract is OnChainPrivacyGroupMana
|
||||
|
||||
function addParticipant(bytes32 _publicEnclaveKey) internal returns (bool) {
|
||||
if (distributionIndexOf[_publicEnclaveKey] == 0) {
|
||||
distributionIndexOf[_publicEnclaveKey] = distributionList.push(_publicEnclaveKey);
|
||||
distributionList.push(_publicEnclaveKey);
|
||||
distributionIndexOf[_publicEnclaveKey] = distributionList.length;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function removeInternal(bytes32 _member) internal returns (bool) {
|
||||
uint256 index = distributionIndexOf[_member];
|
||||
function removeInternal(bytes32 _participant) internal returns (bool) {
|
||||
uint256 index = distributionIndexOf[_participant];
|
||||
if (index > 0 && index <= distributionList.length) {
|
||||
//move last address into index being vacated (unless we are dealing with last index)
|
||||
if (index != distributionList.length) {
|
||||
@@ -97,8 +112,8 @@ contract DefaultOnChainPrivacyGroupManagementContract is OnChainPrivacyGroupMana
|
||||
distributionList[index - 1] = lastPublicKey;
|
||||
distributionIndexOf[lastPublicKey] = index;
|
||||
}
|
||||
distributionList.length -= 1;
|
||||
distributionIndexOf[_member] = 0;
|
||||
distributionList.pop();
|
||||
distributionIndexOf[_participant] = 0;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -1,9 +1,23 @@
|
||||
pragma solidity ^0.5.9;
|
||||
/*
|
||||
* Copyright ConsenSys AG.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
pragma solidity ^0.6.0;
|
||||
interface OnChainPrivacyGroupManagementInterface {
|
||||
|
||||
function addParticipants(bytes32[] calldata participants) external returns (bool);
|
||||
function addParticipants(bytes32[] calldata publicEnclaveKeys) external returns (bool);
|
||||
|
||||
function removeParticipant(bytes32 account) external returns (bool);
|
||||
function removeParticipant(bytes32 participant) external returns (bool);
|
||||
|
||||
function getParticipants() external view returns (bytes32[] memory);
|
||||
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
pragma solidity ^0.5.12;
|
||||
|
||||
pragma solidity ^0.5.9;
|
||||
/*
|
||||
* Copyright ConsenSys AG.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
pragma solidity ^0.6.0;
|
||||
import "./OnChainPrivacyGroupManagementInterface.sol";
|
||||
|
||||
contract OnChainPrivacyGroupManagementProxy is OnChainPrivacyGroupManagementInterface {
|
||||
@@ -15,46 +27,46 @@ contract OnChainPrivacyGroupManagementProxy is OnChainPrivacyGroupManagementInte
|
||||
implementation = _newImp;
|
||||
}
|
||||
|
||||
function addParticipants(bytes32[] memory _publicEnclaveKeys) public returns (bool) {
|
||||
function addParticipants(bytes32[] memory _publicEnclaveKeys) public override returns (bool) {
|
||||
OnChainPrivacyGroupManagementInterface privacyInterface = OnChainPrivacyGroupManagementInterface(implementation);
|
||||
return privacyInterface.addParticipants(_publicEnclaveKeys);
|
||||
}
|
||||
|
||||
function getParticipants() view public returns (bytes32[] memory) {
|
||||
function getParticipants() view public override returns (bytes32[] memory) {
|
||||
OnChainPrivacyGroupManagementInterface privacyInterface = OnChainPrivacyGroupManagementInterface(implementation);
|
||||
return privacyInterface.getParticipants();
|
||||
}
|
||||
|
||||
function removeParticipant(bytes32 _member) public returns (bool) {
|
||||
function removeParticipant(bytes32 _participant) public override returns (bool) {
|
||||
OnChainPrivacyGroupManagementInterface privacyInterface = OnChainPrivacyGroupManagementInterface(implementation);
|
||||
bool result = privacyInterface.removeParticipant(_member);
|
||||
bool result = privacyInterface.removeParticipant(_participant);
|
||||
if (result) {
|
||||
emit ParticipantRemoved(_member);
|
||||
emit ParticipantRemoved(_participant);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function lock() public {
|
||||
function lock() public override {
|
||||
OnChainPrivacyGroupManagementInterface privacyInterface = OnChainPrivacyGroupManagementInterface(implementation);
|
||||
return privacyInterface.lock();
|
||||
}
|
||||
|
||||
function unlock() public {
|
||||
function unlock() public override {
|
||||
OnChainPrivacyGroupManagementInterface privacyInterface = OnChainPrivacyGroupManagementInterface(implementation);
|
||||
return privacyInterface.unlock();
|
||||
}
|
||||
|
||||
function canExecute() public view returns (bool) {
|
||||
function canExecute() public view override returns (bool) {
|
||||
OnChainPrivacyGroupManagementInterface privacyInterface = OnChainPrivacyGroupManagementInterface(implementation);
|
||||
return privacyInterface.canExecute();
|
||||
}
|
||||
|
||||
function getVersion() public view returns (bytes32) {
|
||||
function getVersion() public view override returns (bytes32) {
|
||||
OnChainPrivacyGroupManagementInterface privacyInterface = OnChainPrivacyGroupManagementInterface(implementation);
|
||||
return privacyInterface.getVersion();
|
||||
}
|
||||
|
||||
function canUpgrade() external returns (bool) {
|
||||
function canUpgrade() external override returns (bool) {
|
||||
OnChainPrivacyGroupManagementInterface privacyInterface = OnChainPrivacyGroupManagementInterface(implementation);
|
||||
return privacyInterface.canUpgrade();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user