Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/hebao_v2/contracts/base/SmartWallet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ contract SmartWallet is ERC1271
require(owner != address(0), "INVALID_OWNER");

wallet.owner = owner;
if (guardians.length != 0) {
wallet.setInitialGuardians(guardians);
}
wallet.addGuardiansImmediately(guardians);

if (quota != 0) {
wallet.setQuota(quota, 0);
}

if (inheritor != address(0)) {
wallet.setInheritor(inheritor, 365 days);
}
Expand Down
12 changes: 7 additions & 5 deletions packages/hebao_v2/contracts/base/libwallet/GuardianLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,17 @@ library GuardianLib
event GuardianAdded (address guardian, uint effectiveTime);
event GuardianRemoved (address guardian, uint effectiveTime);

function setInitialGuardians(
function addGuardiansImmediately(
Wallet storage wallet,
address[] memory _guardians
)
external
{
require(_guardians.length < MAX_GUARDIANS, "TOO_MANY_GUARDIANS");
for (uint i = 0; i < _guardians.length; i++) {
_addGuardian(wallet, _guardians[i], 0, true);
address guardian = address(0);
for (uint i = 0; i < _guardians.length; i++) {
require(_guardians[i] > guardian, "INVALID_ORDERING");
guardian = _guardians[i];
_addGuardian(wallet, guardian, 0, true);
}
}

Expand Down Expand Up @@ -314,7 +316,7 @@ library GuardianLib

uint pos = wallet.guardianIdx[addr];

if(pos == 0) {
if (pos == 0) {
// Add the new guardian
Guardian memory _g = Guardian(
addr,
Expand Down
5 changes: 3 additions & 2 deletions packages/hebao_v2/contracts/base/libwallet/RecoverLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@ library RecoverLib

wallet.owner = newOwner;
wallet.setLock(address(this), false);

if (newGuardians.length > 0) {
wallet.removeAllGuardians();
for (uint i = 0; i < newGuardians.length; i++) {
require(newGuardians[i] != newOwner, "INVALID_NEW_WALLET_GUARDIAN");
}
wallet.setInitialGuardians(newGuardians);
wallet.removeAllGuardians();
wallet.addGuardiansImmediately(newGuardians);
} else {
if (wallet.isGuardian(newOwner, true)) {
wallet.deleteGuardian(newOwner, block.timestamp, true);
Expand Down
4 changes: 2 additions & 2 deletions packages/hebao_v2/contracts/base/libwallet/WalletData.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct Wallet
// relayer => nonce
uint nonce;
// hash => consumed
mapping(bytes32 => bool) hashes;
mapping (bytes32 => bool) hashes;

bool locked;

Expand All @@ -65,5 +65,5 @@ struct Wallet
Quota quota;

// whitelisted address => effective timestamp
mapping(address => uint) whitelisted;
mapping (address => uint) whitelisted;
}
2 changes: 1 addition & 1 deletion packages/hebao_v2/contracts/test/LRCToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ library SafeMath {
*/
contract BasicToken is ERC20Basic {
using SafeMath for uint;
mapping(address => uint) balances;
mapping (address => uint) balances;
uint totalSupply_;
/**
* @dev total number of tokens in existence
Expand Down
28 changes: 14 additions & 14 deletions packages/hebao_v2/contracts/thirdparty/MockContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@ contract MockContract is MockInterface {
bytes4 public constant SENTINEL_ANY_MOCKS = hex"01";

// A linked list allows easy iteration and inclusion checks
mapping(bytes32 => bytes) calldataMocks;
mapping(bytes => MockType) calldataMockTypes;
mapping(bytes => bytes) calldataExpectations;
mapping(bytes => string) calldataRevertMessage;
mapping(bytes32 => uint) calldataInvocations;

mapping(bytes4 => bytes4) methodIdMocks;
mapping(bytes4 => MockType) methodIdMockTypes;
mapping(bytes4 => bytes) methodIdExpectations;
mapping(bytes4 => string) methodIdRevertMessages;
mapping(bytes32 => uint) methodIdInvocations;
mapping (bytes32 => bytes) calldataMocks;
mapping (bytes => MockType) calldataMockTypes;
mapping (bytes => bytes) calldataExpectations;
mapping (bytes => string) calldataRevertMessage;
mapping (bytes32 => uint) calldataInvocations;

mapping (bytes4 => bytes4) methodIdMocks;
mapping (bytes4 => MockType) methodIdMockTypes;
mapping (bytes4 => bytes) methodIdExpectations;
mapping (bytes4 => string) methodIdRevertMessages;
mapping (bytes32 => uint) methodIdInvocations;

MockType fallbackMockType;
bytes fallbackExpectation;
Expand Down Expand Up @@ -262,7 +262,7 @@ contract MockContract is MockInterface {
bytes memory nextMock = calldataMocks[MOCKS_LIST_START];
bytes32 mockHash = keccak256(nextMock);
// We cannot compary bytes
while(mockHash != MOCKS_LIST_END_HASH) {
while (mockHash != MOCKS_LIST_END_HASH) {
// Reset all mock maps
calldataMockTypes[nextMock] = MockType.Return;
calldataExpectations[nextMock] = hex"";
Expand All @@ -279,7 +279,7 @@ contract MockContract is MockInterface {

// Reset all any calldataMocks
bytes4 nextAnyMock = methodIdMocks[SENTINEL_ANY_MOCKS];
while(nextAnyMock != SENTINEL_ANY_MOCKS) {
while (nextAnyMock != SENTINEL_ANY_MOCKS) {
bytes4 currentAnyMock = nextAnyMock;
methodIdMockTypes[currentAnyMock] = MockType.Return;
methodIdExpectations[currentAnyMock] = hex"";
Expand All @@ -298,7 +298,7 @@ contract MockContract is MockInterface {
}

function useAllGas() private {
while(true) {
while (true) {
bool s;
assembly {
//expensive call to EC multiply contract
Expand Down
24 changes: 12 additions & 12 deletions packages/hebao_v2/contracts/thirdparty/strings.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ library strings {

function memcpy(uint dest, uint src, uint _len) private pure {
// Copy word-length chunks while possible
for(; _len >= 32; _len -= 32) {
for (; _len >= 32; _len -= 32) {
assembly {
mstore(dest, mload(src))
}
Expand Down Expand Up @@ -165,13 +165,13 @@ library strings {
assembly { b := and(mload(ptr), 0xFF) }
if (b < 0x80) {
ptr += 1;
} else if(b < 0xE0) {
} else if (b < 0xE0) {
ptr += 2;
} else if(b < 0xF0) {
} else if (b < 0xF0) {
ptr += 3;
} else if(b < 0xF8) {
} else if (b < 0xF8) {
ptr += 4;
} else if(b < 0xFC) {
} else if (b < 0xFC) {
ptr += 5;
} else {
ptr += 6;
Expand Down Expand Up @@ -214,7 +214,7 @@ library strings {
if (a != b) {
// Mask out irrelevant bytes and check again
uint256 mask = uint256(-1); // 0xffff...
if(shortest < 32) {
if (shortest < 32) {
mask = ~(2 ** (8 * (32 - shortest + idx)) - 1);
}
uint256 diff = (a & mask) - (b & mask);
Expand Down Expand Up @@ -258,9 +258,9 @@ library strings {
assembly { b := and(mload(sub(mload(add(self, 32)), 31)), 0xFF) }
if (b < 0x80) {
l = 1;
} else if(b < 0xE0) {
} else if (b < 0xE0) {
l = 2;
} else if(b < 0xF0) {
} else if (b < 0xF0) {
l = 3;
} else {
l = 4;
Expand Down Expand Up @@ -310,10 +310,10 @@ library strings {
if (b < 0x80) {
ret = b;
length = 1;
} else if(b < 0xE0) {
} else if (b < 0xE0) {
ret = b & 0x1F;
length = 2;
} else if(b < 0xF0) {
} else if (b < 0xF0) {
ret = b & 0x0F;
length = 3;
} else {
Expand Down Expand Up @@ -697,14 +697,14 @@ library strings {
return "";

uint length = self._len * (parts.length - 1);
for(uint i = 0; i < parts.length; i++)
for (uint i = 0; i < parts.length; i++)
length += parts[i]._len;

string memory ret = new string(length);
uint retptr;
assembly { retptr := add(ret, 32) }

for(uint i = 0; i < parts.length; i++) {
for (uint i = 0; i < parts.length; i++) {
memcpy(retptr, parts[i]._ptr, parts[i]._len);
retptr += parts[i]._len;
if (i < parts.length - 1) {
Expand Down