Skip to content

Commit 0064851

Browse files
authored
Compatible v2.4.22 (#566)
* updated to backward compatible * lint * removed __startedOn check
1 parent da4fb94 commit 0064851

File tree

5 files changed

+16
-77
lines changed

5 files changed

+16
-77
lines changed

contracts/ContinuousOffering.sol

+1-23
Original file line numberDiff line numberDiff line change
@@ -197,30 +197,10 @@ contract ContinuousOffering
197197
{
198198
if(address(whitelist) != address(0))
199199
{
200-
//automatically activate wallet _from
201-
//does not activate if,
202-
//1. _from is zero address,
203-
//2. it is burn
204-
if(!whitelist.walletActivated(_from) && _from != address(0) && !(_to == address(0) && !_isSell)){
205-
whitelist.activateWallet(_from);
206-
}
207-
//automatically activate wallet _to
208-
//does not activate if,
209-
//1. _to is zero address,
210-
if(!whitelist.walletActivated(_to) && _to != address(0)){
211-
whitelist.activateWallet(_to);
212-
}
213200
// This is not set for the minting of initialReserve
214201
whitelist.authorizeTransfer(_from, _to, _value, _isSell);
215202
}
216203
_;
217-
if(address(whitelist) != address(0)){
218-
//automatically deactivates _from if _from's balance is zero
219-
if(balanceOf(_from) == 0 && _from != address(0) && !(_to==address(0) && !_isSell)){
220-
//deactivate wallets without balance
221-
whitelist.deactivateWallet(_from);
222-
}
223-
}
224204
}
225205

226206
/**
@@ -648,9 +628,7 @@ contract ContinuousOffering
648628
{
649629
emit StateChange(state, STATE_RUN);
650630
state = STATE_RUN;
651-
if(__startedOn == 0) {
652-
__startedOn = block.timestamp;
653-
}
631+
__startedOn = block.timestamp;
654632

655633
// Math worst case:
656634
// MAX_BEFORE_SQUARE * MAX_BEFORE_SQUARE * MAX_BEFORE_SQUARE/2

contracts/Whitelist.sol

+11-10
Original file line numberDiff line numberDiff line change
@@ -700,15 +700,8 @@ contract Whitelist is IWhitelist, Ownable, OperatorRole {
700700
/**
701701
* @notice activate wallet enlist user when user is not enlisted
702702
* @dev This function can be called even user does not have balance
703-
* only owner or callingContract can call this function
703+
* only owner can call this function
704704
*/
705-
function activateWallet(
706-
address _wallet
707-
) external {
708-
require(msg.sender == address(callingContract) || isOperator(msg.sender), "CALL_VIA_CONTRACT_OR_OPERATOR_ONLY");
709-
_activateWallet(_wallet);
710-
}
711-
712705
function activateWallets(
713706
address[] calldata _wallets
714707
) external onlyOperator {
@@ -839,8 +832,16 @@ contract Whitelist is IWhitelist, Ownable, OperatorRole {
839832
);
840833
address toUserId = authorizedWalletToUserId[_to];
841834
require(toUserId != address(0) || _to == address(0), "TO_USER_UNKNOWN");
842-
require(walletActivated[_from] || _from == address(0),"FROM_DEACTIVATED_WALLET");
843-
require(walletActivated[_to] || _to == address(0),"TO_DEACTIVATED_WALLET");
835+
if(!walletActivated[_from] && _from != address(0)){
836+
_activateWallet(_from);
837+
}
838+
if(!walletActivated[_to] && _to != address(0)){
839+
_activateWallet(_to);
840+
}
841+
if(callingContract.balanceOf(_from) == _value && _from != address(0)){
842+
//deactivate wallets without balance
843+
_deactivateWallet(_from);
844+
}
844845

845846
// A single user can move funds between wallets they control without restriction
846847
if (fromUserId != toUserId) {

contracts/interfaces/IWhitelist.sol

-8
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,6 @@ interface IWhitelist {
4444
bool _isSell
4545
) external;
4646

47-
function activateWallet(
48-
address _wallet
49-
) external;
50-
51-
function deactivateWallet(
52-
address _wallet
53-
) external;
54-
5547
function walletActivated(
5648
address _wallet
5749
) external returns(bool);

test/whitelist/activateWallet.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ contract("whitelist / activateWallet", (accounts) => {
2929

3030
it("shouldFail when msg.sender is not callingContract nor owner", async () => {
3131
await expectRevert(
32-
contracts.whitelist.activateWallet(accounts[4], { from: accounts[4] }),
33-
"CALL_VIA_CONTRACT_OR_OPERATOR_ONLY"
32+
contracts.whitelist.activateWallets([accounts[4]], { from: accounts[4] }),
33+
"OperatorRole: caller does not have the Operator role"
3434
);
3535
});
3636

@@ -48,7 +48,7 @@ contract("whitelist / activateWallet", (accounts) => {
4848
from: operatorAccount,
4949
});
5050
await expectRevert(
51-
contracts.whitelist.activateWallet(accounts[4], {
51+
contracts.whitelist.activateWallets([accounts[4]], {
5252
from: operatorAccount,
5353
}),
5454
"ALREADY_ACTIVATED_WALLET"

test/whitelist/authorizeTransfer.js

+1-33
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ contract("whitelist / authorizeTransfer", (accounts) => {
8888
await whitelist.updateJurisdictionFlows([1, 4, 4], [4, 1, 4], [1, 1, 1], {
8989
from: accounts[0],
9090
});
91-
91+
await whitelist.addOperator(operatorAccount, { from: accounts[0] });
9292
await whitelist.approveNewUsers([accounts[4], accounts[7]], [4, 4], {
9393
from: accounts[0],
9494
});
@@ -117,38 +117,6 @@ contract("whitelist / authorizeTransfer", (accounts) => {
117117
"TO_USER_UNKNOWN"
118118
);
119119
});
120-
121-
it("should fail if _from is not activated", async () => {
122-
await whitelist.addApprovedUserWallets([accounts[4]], [accounts[5]], {
123-
from: accounts[0],
124-
});
125-
await whitelist.addApprovedUserWallets([accounts[7]], [accounts[6]], {
126-
from: accounts[0],
127-
});
128-
await whitelist.activateWallet(accounts[6], { from: accounts[1] });
129-
await expectRevert(
130-
whitelist.authorizeTransfer(accounts[5], accounts[6], 100, false, {
131-
from: accounts[1],
132-
}),
133-
"FROM_DEACTIVATED_WALLET"
134-
);
135-
});
136-
137-
it("should fail if _to is not activated", async () => {
138-
await whitelist.addApprovedUserWallets([accounts[4]], [accounts[5]], {
139-
from: accounts[0],
140-
});
141-
await whitelist.addApprovedUserWallets([accounts[7]], [accounts[6]], {
142-
from: accounts[0],
143-
});
144-
await whitelist.activateWallet(accounts[5], { from: accounts[1] });
145-
await expectRevert(
146-
whitelist.authorizeTransfer(accounts[5], accounts[6], 100, false, {
147-
from: accounts[1],
148-
}),
149-
"TO_DEACTIVATED_WALLET"
150-
);
151-
});
152120
});
153121

154122
describe("when blocked by jurisdiction flow", () => {

0 commit comments

Comments
 (0)